forked from tornado-packages/noble-curves
test: remove common.js support
This commit is contained in:
parent
4a8f447c8d
commit
7c461af2b2
@ -1,21 +1,21 @@
|
|||||||
import { deepStrictEqual, throws } from 'assert';
|
import { deepStrictEqual, throws } from 'assert';
|
||||||
import { should, describe } from 'micro-should';
|
import { should, describe } from 'micro-should';
|
||||||
import * as fc from 'fast-check';
|
import * as fc from 'fast-check';
|
||||||
import * as mod from '../esm/abstract/modular.js';
|
import * as mod from '../abstract/modular.js';
|
||||||
import { bytesToHex as toHex } from '../esm/abstract/utils.js';
|
import { bytesToHex as toHex } from '../abstract/utils.js';
|
||||||
// Generic tests for all curves in package
|
// Generic tests for all curves in package
|
||||||
import { secp192r1, secp224r1 } from './_more-curves.helpers.js';
|
import { secp192r1, secp224r1 } from './_more-curves.helpers.js';
|
||||||
import { secp256r1 } from '../esm/p256.js';
|
import { secp256r1 } from '../p256.js';
|
||||||
import { secp384r1 } from '../esm/p384.js';
|
import { secp384r1 } from '../p384.js';
|
||||||
import { secp521r1 } from '../esm/p521.js';
|
import { secp521r1 } from '../p521.js';
|
||||||
import { secp256k1 } from '../esm/secp256k1.js';
|
import { secp256k1 } from '../secp256k1.js';
|
||||||
import { ed25519, ed25519ctx, ed25519ph, x25519 } from '../esm/ed25519.js';
|
import { ed25519, ed25519ctx, ed25519ph, x25519 } from '../ed25519.js';
|
||||||
import { ed448, ed448ph } from '../esm/ed448.js';
|
import { ed448, ed448ph } from '../ed448.js';
|
||||||
import { _starkCurve as starkCurve } from '../esm/stark.js';
|
import { _starkCurve as starkCurve } from '../stark.js';
|
||||||
import { pallas, vesta } from '../esm/pasta.js';
|
import { pallas, vesta } from '../pasta.js';
|
||||||
import { bn254 } from '../esm/bn.js';
|
import { bn254 } from '../bn.js';
|
||||||
import { jubjub } from '../esm/jubjub.js';
|
import { jubjub } from '../jubjub.js';
|
||||||
import { bls12_381 } from '../esm/bls12-381.js';
|
import { bls12_381 } from '../bls12-381.js';
|
||||||
|
|
||||||
// Fields tests
|
// Fields tests
|
||||||
const FIELDS = {
|
const FIELDS = {
|
||||||
|
@ -2,10 +2,10 @@ import { deepStrictEqual, notDeepStrictEqual, throws } from 'assert';
|
|||||||
import * as fc from 'fast-check';
|
import * as fc from 'fast-check';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { describe, should } from 'micro-should';
|
import { describe, should } from 'micro-should';
|
||||||
import { wNAF } from '../esm/abstract/curve.js';
|
import { wNAF } from '../abstract/curve.js';
|
||||||
import { bytesToHex, utf8ToBytes } from '../esm/abstract/utils.js';
|
import { bytesToHex, utf8ToBytes } from '../abstract/utils.js';
|
||||||
import { hash_to_field } from '../esm/abstract/hash-to-curve.js';
|
import { hash_to_field } from '../abstract/hash-to-curve.js';
|
||||||
import { bls12_381 as bls } from '../esm/bls12-381.js';
|
import { bls12_381 as bls } from '../bls12-381.js';
|
||||||
|
|
||||||
import zkVectors from './bls12-381/zkcrypto/converted.json' assert { type: 'json' };
|
import zkVectors from './bls12-381/zkcrypto/converted.json' assert { type: 'json' };
|
||||||
import pairingVectors from './bls12-381/go_pairing_vectors/pairing.json' assert { type: 'json' };
|
import pairingVectors from './bls12-381/go_pairing_vectors/pairing.json' assert { type: 'json' };
|
||||||
|
@ -2,9 +2,9 @@ import { sha512 } from '@noble/hashes/sha512';
|
|||||||
import { hexToBytes, bytesToHex, randomBytes } from '@noble/hashes/utils';
|
import { hexToBytes, bytesToHex, randomBytes } from '@noble/hashes/utils';
|
||||||
import { deepStrictEqual, strictEqual, throws } from 'assert';
|
import { deepStrictEqual, strictEqual, throws } from 'assert';
|
||||||
import { describe, should } from 'micro-should';
|
import { describe, should } from 'micro-should';
|
||||||
import { bytesToNumberLE, numberToBytesLE } from '../esm/abstract/utils.js';
|
import { bytesToNumberLE, numberToBytesLE } from '../abstract/utils.js';
|
||||||
import { default as x25519vectors } from './wycheproof/x25519_test.json' assert { type: 'json' };
|
import { default as x25519vectors } from './wycheproof/x25519_test.json' assert { type: 'json' };
|
||||||
import { ed25519ctx, ed25519ph, RistrettoPoint, x25519 } from '../esm/ed25519.js';
|
import { ed25519ctx, ed25519ph, RistrettoPoint, x25519 } from '../ed25519.js';
|
||||||
|
|
||||||
// const ed = ed25519;
|
// const ed = ed25519;
|
||||||
const hex = bytesToHex;
|
const hex = bytesToHex;
|
||||||
|
@ -1 +1 @@
|
|||||||
export { ed25519, ED25519_TORSION_SUBGROUP } from '../esm/ed25519.js';
|
export { ed25519, ED25519_TORSION_SUBGROUP } from '../ed25519.js';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { deepStrictEqual, throws } from 'assert';
|
import { deepStrictEqual, throws } from 'assert';
|
||||||
import { describe, should } from 'micro-should';
|
import { describe, should } from 'micro-should';
|
||||||
import * as fc from 'fast-check';
|
import * as fc from 'fast-check';
|
||||||
import { ed448, ed448ph, x448 } from '../esm/ed448.js';
|
import { ed448, ed448ph, x448 } from '../ed448.js';
|
||||||
import { hexToBytes, bytesToHex, randomBytes } from '@noble/hashes/utils';
|
import { hexToBytes, bytesToHex, randomBytes } from '@noble/hashes/utils';
|
||||||
import { numberToBytesLE } from '../esm/abstract/utils.js';
|
import { numberToBytesLE } from '../abstract/utils.js';
|
||||||
import { default as ed448vectors } from './wycheproof/ed448_test.json' assert { type: 'json' };
|
import { default as ed448vectors } from './wycheproof/ed448_test.json' assert { type: 'json' };
|
||||||
import { default as x448vectors } from './wycheproof/x448_test.json' assert { type: 'json' };
|
import { default as x448vectors } from './wycheproof/x448_test.json' assert { type: 'json' };
|
||||||
|
|
||||||
|
@ -5,15 +5,15 @@ import { bytesToHex } from '@noble/hashes/utils';
|
|||||||
import { sha256 } from '@noble/hashes/sha256';
|
import { sha256 } from '@noble/hashes/sha256';
|
||||||
import { sha512 } from '@noble/hashes/sha512';
|
import { sha512 } from '@noble/hashes/sha512';
|
||||||
import { shake128, shake256 } from '@noble/hashes/sha3';
|
import { shake128, shake256 } from '@noble/hashes/sha3';
|
||||||
import * as secp256r1 from '../esm/p256.js';
|
import * as secp256r1 from '../p256.js';
|
||||||
import * as secp384r1 from '../esm/p384.js';
|
import * as secp384r1 from '../p384.js';
|
||||||
import * as secp521r1 from '../esm/p521.js';
|
import * as secp521r1 from '../p521.js';
|
||||||
import * as ed25519 from '../esm/ed25519.js';
|
import * as ed25519 from '../ed25519.js';
|
||||||
import * as ed448 from '../esm/ed448.js';
|
import * as ed448 from '../ed448.js';
|
||||||
import * as secp256k1 from '../esm/secp256k1.js';
|
import * as secp256k1 from '../secp256k1.js';
|
||||||
import { bls12_381 } from '../esm/bls12-381.js';
|
import { bls12_381 } from '../bls12-381.js';
|
||||||
import { expand_message_xmd, expand_message_xof } from '../esm/abstract/hash-to-curve.js';
|
import { expand_message_xmd, expand_message_xof } from '../abstract/hash-to-curve.js';
|
||||||
import { utf8ToBytes } from '../esm/abstract/utils.js';
|
import { utf8ToBytes } from '../abstract/utils.js';
|
||||||
// XMD
|
// 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_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' };
|
import { default as xmd_sha256_256 } from './hash-to-curve/expand_message_xmd_SHA256_256.json' assert { type: 'json' };
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { jubjub, findGroupHash } from '../esm/jubjub.js';
|
import { jubjub, findGroupHash } from '../jubjub.js';
|
||||||
import { describe, should } from 'micro-should';
|
import { describe, should } from 'micro-should';
|
||||||
import { deepStrictEqual, throws } from 'assert';
|
import { deepStrictEqual, throws } from 'assert';
|
||||||
const Point = jubjub.ExtendedPoint;
|
const Point = jubjub.ExtendedPoint;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { deepStrictEqual } from 'assert';
|
import { deepStrictEqual } from 'assert';
|
||||||
import { describe, should } from 'micro-should';
|
import { describe, should } from 'micro-should';
|
||||||
import { secp192r1, secp224r1, P192, P224 } from './_more-curves.helpers.js';
|
import { secp192r1, secp224r1, P192, P224 } from './_more-curves.helpers.js';
|
||||||
import { secp256r1, P256 } from '../esm/p256.js';
|
import { secp256r1, P256 } from '../p256.js';
|
||||||
import { secp384r1, P384 } from '../esm/p384.js';
|
import { secp384r1, P384 } from '../p384.js';
|
||||||
import { secp521r1, P521 } from '../esm/p521.js';
|
import { secp521r1, P521 } from '../p521.js';
|
||||||
import { secp256k1 } from '../esm/secp256k1.js';
|
import { secp256k1 } from '../secp256k1.js';
|
||||||
import { hexToBytes, bytesToHex } from '../esm/abstract/utils.js';
|
import { hexToBytes, bytesToHex } from '../abstract/utils.js';
|
||||||
import { default as ecdsa } from './wycheproof/ecdsa_test.json' assert { type: 'json' };
|
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 ecdh } from './wycheproof/ecdh_test.json' assert { type: 'json' };
|
||||||
import { default as rfc6979 } from './fixtures/rfc6979.json' assert { type: 'json' };
|
import { default as rfc6979 } from './fixtures/rfc6979.json' assert { type: 'json' };
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { deepStrictEqual, throws } from 'assert';
|
import { deepStrictEqual, throws } from 'assert';
|
||||||
import { should, describe } from 'micro-should';
|
import { should, describe } from 'micro-should';
|
||||||
import * as poseidon from '../esm/abstract/poseidon.js';
|
import * as poseidon from '../abstract/poseidon.js';
|
||||||
import * as stark from '../esm/stark.js';
|
import * as stark from '../stark.js';
|
||||||
import * as mod from '../esm/abstract/modular.js';
|
import * as mod from '../abstract/modular.js';
|
||||||
import { default as pvectors } from './vectors/poseidon.json' assert { type: 'json' };
|
import { default as pvectors } from './vectors/poseidon.json' assert { type: 'json' };
|
||||||
const { st1, st2, st3, st4 } = pvectors;
|
const { st1, st2, st3, st4 } = pvectors;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { deepStrictEqual, throws } from 'assert';
|
|||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { should, describe } from 'micro-should';
|
import { should, describe } from 'micro-should';
|
||||||
import { bytesToHex as hex } from '@noble/hashes/utils';
|
import { bytesToHex as hex } from '@noble/hashes/utils';
|
||||||
import { schnorr } from '../esm/secp256k1.js';
|
import { schnorr } from '../secp256k1.js';
|
||||||
const schCsv = readFileSync('./test/vectors/schnorr.csv', 'utf-8');
|
const schCsv = readFileSync('./test/vectors/schnorr.csv', 'utf-8');
|
||||||
|
|
||||||
describe('schnorr.sign()', () => {
|
describe('schnorr.sign()', () => {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export { secp256k1 as secp } from '../esm/secp256k1.js';
|
export { secp256k1 as secp } from '../secp256k1.js';
|
||||||
import { secp256k1 as _secp } from '../esm/secp256k1.js';
|
import { secp256k1 as _secp } from '../secp256k1.js';
|
||||||
export { bytesToNumberBE, numberToBytesBE } from '../esm/abstract/utils.js';
|
export { bytesToNumberBE, numberToBytesBE } from '../abstract/utils.js';
|
||||||
export { mod } from '../esm/abstract/modular.js';
|
export { mod } from '../abstract/modular.js';
|
||||||
export const sigFromDER = (der) => {
|
export const sigFromDER = (der) => {
|
||||||
return _secp.Signature.fromDER(der);
|
return _secp.Signature.fromDER(der);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { deepStrictEqual, throws } from 'assert';
|
import { deepStrictEqual, throws } from 'assert';
|
||||||
import { describe, should } from 'micro-should';
|
import { describe, should } from 'micro-should';
|
||||||
import * as starknet from '../../esm/stark.js';
|
import * as starknet from '../../stark.js';
|
||||||
import { default as issue2 } from './fixtures/issue2.json' assert { type: 'json' };
|
import { default as issue2 } from './fixtures/issue2.json' assert { type: 'json' };
|
||||||
import * as bip32 from '@scure/bip32';
|
import * as bip32 from '@scure/bip32';
|
||||||
import * as bip39 from '@scure/bip39';
|
import * as bip39 from '@scure/bip39';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as microStark from '../../../esm/stark.js';
|
import * as microStark from '../../../stark.js';
|
||||||
import * as starkwareCrypto from '@starkware-industries/starkware-crypto-utils';
|
import * as starkwareCrypto from '@starkware-industries/starkware-crypto-utils';
|
||||||
import * as bench from 'micro-bmark';
|
import * as bench from 'micro-bmark';
|
||||||
const { run, mark } = bench; // or bench.mark
|
const { run, mark } = bench; // or bench.mark
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { deepStrictEqual, throws } from 'assert';
|
import { deepStrictEqual, throws } from 'assert';
|
||||||
import { describe, should } from 'micro-should';
|
import { describe, should } from 'micro-should';
|
||||||
import * as starknet from '../../esm/stark.js';
|
import * as starknet from '../../stark.js';
|
||||||
import { bytesToHex as hex } from '@noble/hashes/utils';
|
import { bytesToHex as hex } from '@noble/hashes/utils';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { deepStrictEqual, throws } from 'assert';
|
import { deepStrictEqual, throws } from 'assert';
|
||||||
import { describe, should } from 'micro-should';
|
import { describe, should } from 'micro-should';
|
||||||
import * as starknet from '../../esm/stark.js';
|
import * as starknet from '../../stark.js';
|
||||||
import * as fc from 'fast-check';
|
import * as fc from 'fast-check';
|
||||||
|
|
||||||
const FC_BIGINT = fc.bigInt(1n + 1n, starknet.CURVE.n - 1n);
|
const FC_BIGINT = fc.bigInt(1n + 1n, starknet.CURVE.n - 1n);
|
||||||
|
@ -3,7 +3,7 @@ import { describe, should } from 'micro-should';
|
|||||||
import { utf8ToBytes } from '@noble/hashes/utils';
|
import { utf8ToBytes } from '@noble/hashes/utils';
|
||||||
import * as bip32 from '@scure/bip32';
|
import * as bip32 from '@scure/bip32';
|
||||||
import * as bip39 from '@scure/bip39';
|
import * as bip39 from '@scure/bip39';
|
||||||
import * as starknet from '../../esm/stark.js';
|
import * as starknet from '../../stark.js';
|
||||||
import { default as sigVec } from './fixtures/rfc6979_signature_test_vector.json' assert { type: 'json' };
|
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' };
|
import { default as precomputedKeys } from './fixtures/keys_precomputed.json' assert { type: 'json' };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user