From cde1d5c4885eb30573f536ab4900a2880a69275b Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Tue, 14 Feb 2023 22:51:11 +0000 Subject: [PATCH] Fix tests --- test/basic.test.js | 30 +++++++++++++++--------------- test/bls12-381.test.js | 8 ++++---- test/ed25519-addons.test.js | 4 ++-- test/ed25519.helpers.js | 2 +- test/ed448.test.js | 4 ++-- test/hash-to-curve.test.js | 18 +++++++++--------- test/jubjub.test.js | 2 +- test/nist.test.js | 14 +++++++------- test/poseidon.test.js | 6 +++--- test/secp256k1-schnorr.test.js | 2 +- test/secp256k1.helpers.js | 8 ++++---- test/stark/basic.test.js | 2 +- test/stark/benchmark/index.js | 2 +- test/stark/poseidon.test.js | 2 +- test/stark/property.test.js | 2 +- test/stark/stark.test.js | 4 ++-- 16 files changed, 55 insertions(+), 55 deletions(-) diff --git a/test/basic.test.js b/test/basic.test.js index 8e0b324..ffd8070 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -1,22 +1,22 @@ import { deepStrictEqual, throws } from 'assert'; import { should, describe } from 'micro-should'; import * as fc from 'fast-check'; -import * as mod from '../lib/esm/abstract/modular.js'; -import { bytesToHex as toHex } from '../lib/esm/abstract/utils.js'; +import * as mod from '../esm/abstract/modular.js'; +import { bytesToHex as toHex } from '../esm/abstract/utils.js'; // Generic tests for all curves in package -import { secp192r1 } from '../lib/esm/p192.js'; -import { secp224r1 } from '../lib/esm/p224.js'; -import { secp256r1 } from '../lib/esm/p256.js'; -import { secp384r1 } from '../lib/esm/p384.js'; -import { secp521r1 } from '../lib/esm/p521.js'; -import { secp256k1 } from '../lib/esm/secp256k1.js'; -import { ed25519, ed25519ctx, ed25519ph, x25519 } from '../lib/esm/ed25519.js'; -import { ed448, ed448ph } from '../lib/esm/ed448.js'; -import { starkCurve } from '../lib/esm/stark.js'; -import { pallas, vesta } from '../lib/esm/pasta.js'; -import { bn254 } from '../lib/esm/bn.js'; -import { jubjub } from '../lib/esm/jubjub.js'; -import { bls12_381 } from '../lib/esm/bls12-381.js'; +import { secp192r1 } from '../esm/p192.js'; +import { secp224r1 } from '../esm/p224.js'; +import { secp256r1 } from '../esm/p256.js'; +import { secp384r1 } from '../esm/p384.js'; +import { secp521r1 } from '../esm/p521.js'; +import { secp256k1 } from '../esm/secp256k1.js'; +import { ed25519, ed25519ctx, ed25519ph, x25519 } from '../esm/ed25519.js'; +import { ed448, ed448ph } from '../esm/ed448.js'; +import { starkCurve } from '../esm/stark.js'; +import { pallas, vesta } from '../esm/pasta.js'; +import { bn254 } from '../esm/bn.js'; +import { jubjub } from '../esm/jubjub.js'; +import { bls12_381 } from '../esm/bls12-381.js'; // Fields tests const FIELDS = { diff --git a/test/bls12-381.test.js b/test/bls12-381.test.js index 786a12a..f8da2e6 100644 --- a/test/bls12-381.test.js +++ b/test/bls12-381.test.js @@ -2,10 +2,10 @@ import { deepStrictEqual, notDeepStrictEqual, throws } from 'assert'; import * as fc from 'fast-check'; import { readFileSync } from 'fs'; import { describe, should } from 'micro-should'; -import { wNAF } from '../lib/esm/abstract/curve.js'; -import { bytesToHex, utf8ToBytes } from '../lib/esm/abstract/utils.js'; -import { hash_to_field } from '../lib/esm/abstract/hash-to-curve.js'; -import { bls12_381 as bls } from '../lib/esm/bls12-381.js'; +import { wNAF } from '../esm/abstract/curve.js'; +import { bytesToHex, utf8ToBytes } from '../esm/abstract/utils.js'; +import { hash_to_field } from '../esm/abstract/hash-to-curve.js'; +import { bls12_381 as bls } from '../esm/bls12-381.js'; import zkVectors from './bls12-381/zkcrypto/converted.json' assert { type: 'json' }; import pairingVectors from './bls12-381/go_pairing_vectors/pairing.json' assert { type: 'json' }; diff --git a/test/ed25519-addons.test.js b/test/ed25519-addons.test.js index 4d16f11..c128194 100644 --- a/test/ed25519-addons.test.js +++ b/test/ed25519-addons.test.js @@ -2,9 +2,9 @@ import { sha512 } from '@noble/hashes/sha512'; import { hexToBytes, bytesToHex, randomBytes } from '@noble/hashes/utils'; import { deepStrictEqual, strictEqual, throws } from 'assert'; import { describe, should } from 'micro-should'; -import { numberToBytesLE } from '../lib/esm/abstract/utils.js'; +import { numberToBytesLE } from '../esm/abstract/utils.js'; import { default as x25519vectors } from './wycheproof/x25519_test.json' assert { type: 'json' }; -import { ed25519ctx, ed25519ph, RistrettoPoint, x25519 } from '../lib/esm/ed25519.js'; +import { ed25519ctx, ed25519ph, RistrettoPoint, x25519 } from '../esm/ed25519.js'; // const ed = ed25519; const hex = bytesToHex; diff --git a/test/ed25519.helpers.js b/test/ed25519.helpers.js index 69246e8..c426896 100644 --- a/test/ed25519.helpers.js +++ b/test/ed25519.helpers.js @@ -1 +1 @@ -export { ed25519, ED25519_TORSION_SUBGROUP } from '../lib/esm/ed25519.js'; +export { ed25519, ED25519_TORSION_SUBGROUP } from '../esm/ed25519.js'; diff --git a/test/ed448.test.js b/test/ed448.test.js index 12bd87b..08b74b7 100644 --- a/test/ed448.test.js +++ b/test/ed448.test.js @@ -1,9 +1,9 @@ import { deepStrictEqual, throws } from 'assert'; import { describe, should } from 'micro-should'; import * as fc from 'fast-check'; -import { ed448, ed448ph, x448 } from '../lib/esm/ed448.js'; +import { ed448, ed448ph, x448 } from '../esm/ed448.js'; import { hexToBytes, bytesToHex, randomBytes } from '@noble/hashes/utils'; -import { numberToBytesLE } from '../lib/esm/abstract/utils.js'; +import { numberToBytesLE } from '../esm/abstract/utils.js'; import { default as ed448vectors } from './wycheproof/ed448_test.json' assert { type: 'json' }; import { default as x448vectors } from './wycheproof/x448_test.json' assert { type: 'json' }; diff --git a/test/hash-to-curve.test.js b/test/hash-to-curve.test.js index 044b8f1..a23b67f 100644 --- a/test/hash-to-curve.test.js +++ b/test/hash-to-curve.test.js @@ -5,15 +5,15 @@ import { bytesToHex } from '@noble/hashes/utils'; import { sha256 } from '@noble/hashes/sha256'; import { sha512 } from '@noble/hashes/sha512'; import { shake128, shake256 } from '@noble/hashes/sha3'; -import * as secp256r1 from '../lib/esm/p256.js'; -import * as secp384r1 from '../lib/esm/p384.js'; -import * as secp521r1 from '../lib/esm/p521.js'; -import * as ed25519 from '../lib/esm/ed25519.js'; -import * as ed448 from '../lib/esm/ed448.js'; -import * as secp256k1 from '../lib/esm/secp256k1.js'; -import { bls12_381 } from '../lib/esm/bls12-381.js'; -import { expand_message_xmd, expand_message_xof } from '../lib/esm/abstract/hash-to-curve.js'; -import { utf8ToBytes } from '../lib/esm/abstract/utils.js'; +import * as secp256r1 from '../esm/p256.js'; +import * as secp384r1 from '../esm/p384.js'; +import * as secp521r1 from '../esm/p521.js'; +import * as ed25519 from '../esm/ed25519.js'; +import * as ed448 from '../esm/ed448.js'; +import * as secp256k1 from '../esm/secp256k1.js'; +import { bls12_381 } from '../esm/bls12-381.js'; +import { expand_message_xmd, expand_message_xof } from '../esm/abstract/hash-to-curve.js'; +import { utf8ToBytes } from '../esm/abstract/utils.js'; // XMD import { default as xmd_sha256_38 } from './hash-to-curve/expand_message_xmd_SHA256_38.json' assert { type: 'json' }; import { default as xmd_sha256_256 } from './hash-to-curve/expand_message_xmd_SHA256_256.json' assert { type: 'json' }; diff --git a/test/jubjub.test.js b/test/jubjub.test.js index 0ce59f9..e443bff 100644 --- a/test/jubjub.test.js +++ b/test/jubjub.test.js @@ -1,4 +1,4 @@ -import { jubjub, findGroupHash } from '../lib/esm/jubjub.js'; +import { jubjub, findGroupHash } from '../esm/jubjub.js'; import { describe, should } from 'micro-should'; import { deepStrictEqual, throws } from 'assert'; const Point = jubjub.ExtendedPoint; diff --git a/test/nist.test.js b/test/nist.test.js index f93f15d..bee9e25 100644 --- a/test/nist.test.js +++ b/test/nist.test.js @@ -1,12 +1,12 @@ import { deepStrictEqual, throws } from 'assert'; import { describe, should } from 'micro-should'; -import { secp192r1, P192 } from '../lib/esm/p192.js'; -import { secp224r1, P224 } from '../lib/esm/p224.js'; -import { secp256r1, P256 } from '../lib/esm/p256.js'; -import { secp384r1, P384 } from '../lib/esm/p384.js'; -import { secp521r1, P521 } from '../lib/esm/p521.js'; -import { secp256k1 } from '../lib/esm/secp256k1.js'; -import { hexToBytes, bytesToHex } from '../lib/esm/abstract/utils.js'; +import { secp192r1, P192 } from '../esm/p192.js'; +import { secp224r1, P224 } from '../esm/p224.js'; +import { secp256r1, P256 } from '../esm/p256.js'; +import { secp384r1, P384 } from '../esm/p384.js'; +import { secp521r1, P521 } from '../esm/p521.js'; +import { secp256k1 } from '../esm/secp256k1.js'; +import { hexToBytes, bytesToHex } from '../esm/abstract/utils.js'; import { default as ecdsa } from './wycheproof/ecdsa_test.json' assert { type: 'json' }; import { default as ecdh } from './wycheproof/ecdh_test.json' assert { type: 'json' }; import { default as rfc6979 } from './fixtures/rfc6979.json' assert { type: 'json' }; diff --git a/test/poseidon.test.js b/test/poseidon.test.js index ef94eb4..e469fc7 100644 --- a/test/poseidon.test.js +++ b/test/poseidon.test.js @@ -1,8 +1,8 @@ import { deepStrictEqual, throws } from 'assert'; import { should, describe } from 'micro-should'; -import * as poseidon from '../lib/esm/abstract/poseidon.js'; -import * as stark from '../lib/esm/stark.js'; -import * as mod from '../lib/esm/abstract/modular.js'; +import * as poseidon from '../esm/abstract/poseidon.js'; +import * as stark from '../esm/stark.js'; +import * as mod from '../esm/abstract/modular.js'; import { default as pvectors } from './vectors/poseidon.json' assert { type: 'json' }; const { st1, st2, st3, st4 } = pvectors; diff --git a/test/secp256k1-schnorr.test.js b/test/secp256k1-schnorr.test.js index e173697..6e0d887 100644 --- a/test/secp256k1-schnorr.test.js +++ b/test/secp256k1-schnorr.test.js @@ -2,7 +2,7 @@ import { deepStrictEqual, throws } from 'assert'; import { readFileSync } from 'fs'; import { should, describe } from 'micro-should'; import { bytesToHex as hex } from '@noble/hashes/utils'; -import { schnorr } from '../lib/esm/secp256k1.js'; +import { schnorr } from '../esm/secp256k1.js'; const schCsv = readFileSync('./test/vectors/schnorr.csv', 'utf-8'); describe('schnorr.sign()', () => { diff --git a/test/secp256k1.helpers.js b/test/secp256k1.helpers.js index d3a9e7d..c907ddd 100644 --- a/test/secp256k1.helpers.js +++ b/test/secp256k1.helpers.js @@ -1,8 +1,8 @@ // @ts-ignore -export { secp256k1 as secp } from '../lib/esm/secp256k1.js'; -import { secp256k1 as _secp } from '../lib/esm/secp256k1.js'; -export { bytesToNumberBE, numberToBytesBE } from '../lib/esm/abstract/utils.js'; -export { mod } from '../lib/esm/abstract/modular.js'; +export { secp256k1 as secp } from '../esm/secp256k1.js'; +import { secp256k1 as _secp } from '../esm/secp256k1.js'; +export { bytesToNumberBE, numberToBytesBE } from '../esm/abstract/utils.js'; +export { mod } from '../esm/abstract/modular.js'; export const sigFromDER = (der) => { return _secp.Signature.fromDER(der); }; diff --git a/test/stark/basic.test.js b/test/stark/basic.test.js index f29e192..a63d491 100644 --- a/test/stark/basic.test.js +++ b/test/stark/basic.test.js @@ -1,6 +1,6 @@ import { deepStrictEqual, throws } from 'assert'; import { describe, should } from 'micro-should'; -import * as starknet from '../../lib/esm/stark.js'; +import * as starknet from '../../esm/stark.js'; import { default as issue2 } from './fixtures/issue2.json' assert { type: 'json' }; import * as bip32 from '@scure/bip32'; import * as bip39 from '@scure/bip39'; diff --git a/test/stark/benchmark/index.js b/test/stark/benchmark/index.js index 4f3d3ca..f283d36 100644 --- a/test/stark/benchmark/index.js +++ b/test/stark/benchmark/index.js @@ -1,4 +1,4 @@ -import * as microStark from '../../../lib/esm/stark.js'; +import * as microStark from '../../../esm/stark.js'; import * as starkwareCrypto from '@starkware-industries/starkware-crypto-utils'; import * as bench from 'micro-bmark'; const { run, mark } = bench; // or bench.mark diff --git a/test/stark/poseidon.test.js b/test/stark/poseidon.test.js index e73a492..c1ddd6b 100644 --- a/test/stark/poseidon.test.js +++ b/test/stark/poseidon.test.js @@ -1,6 +1,6 @@ import { deepStrictEqual, throws } from 'assert'; import { describe, should } from 'micro-should'; -import * as starknet from '../../lib/esm/stark.js'; +import * as starknet from '../../esm/stark.js'; import * as fs from 'fs'; function parseTest(path) { diff --git a/test/stark/property.test.js b/test/stark/property.test.js index eab8590..930861f 100644 --- a/test/stark/property.test.js +++ b/test/stark/property.test.js @@ -1,6 +1,6 @@ import { deepStrictEqual, throws } from 'assert'; import { describe, should } from 'micro-should'; -import * as starknet from '../../lib/esm/stark.js'; +import * as starknet from '../../esm/stark.js'; import * as fc from 'fast-check'; const FC_BIGINT = fc.bigInt(1n + 1n, starknet.CURVE.n - 1n); diff --git a/test/stark/stark.test.js b/test/stark/stark.test.js index d193de7..c1aa007 100644 --- a/test/stark/stark.test.js +++ b/test/stark/stark.test.js @@ -1,9 +1,9 @@ import { deepStrictEqual, throws } from 'assert'; import { describe, should } from 'micro-should'; -import { utf8ToBytes } from '@noble/hashes/utils.js'; +import { utf8ToBytes } from '@noble/hashes/utils'; import * as bip32 from '@scure/bip32'; import * as bip39 from '@scure/bip39'; -import * as starknet from '../../lib/esm/stark.js'; +import * as starknet from '../../esm/stark.js'; import { default as sigVec } from './fixtures/rfc6979_signature_test_vector.json' assert { type: 'json' }; import { default as precomputedKeys } from './fixtures/keys_precomputed.json' assert { type: 'json' };