Skip to content

Commit fa50a11

Browse files
committed
Improve type stripping compat: Change .js extensions to .ts.
1 parent 94d0066 commit fa50a11

20 files changed

+82
-82
lines changed

src/_shortw_utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
66
import { hmac } from '@noble/hashes/hmac';
77
import { concatBytes, randomBytes } from '@noble/hashes/utils';
8-
import type { CHash } from './abstract/utils.js';
9-
import { type CurveFn, type CurveType, weierstrass } from './abstract/weierstrass.js';
8+
import type { CHash } from './abstract/utils.ts';
9+
import { type CurveFn, type CurveType, weierstrass } from './abstract/weierstrass.ts';
1010

1111
/** connects noble-curves to noble-hashes */
1212
export function getHash(hash: CHash): {

src/abstract/bls.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616
* @module
1717
**/
1818
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
19-
// TODO: import { AffinePoint } from './curve.js';
20-
import { type IField, getMinHashLength, mapHashToField } from './modular.js';
21-
import { type CHash, type Hex, type PrivKey, ensureBytes, memoized } from './utils.js';
22-
// prettier-ignore
19+
// TODO: import { AffinePoint } from './curve.ts';
2320
import {
24-
type H2CPointConstructor, type htfBasicOpts,
21+
type H2CPointConstructor,
22+
type htfBasicOpts,
2523
type Opts as HTFOpts,
2624
type MapToCurve,
27-
createHasher
28-
} from './hash-to-curve.js';
29-
import type { Fp12, Fp12Bls, Fp2, Fp2Bls, Fp6 } from './tower.js';
25+
createHasher,
26+
} from './hash-to-curve.ts';
27+
import { type IField, getMinHashLength, mapHashToField } from './modular.ts';
28+
import type { Fp12, Fp12Bls, Fp2, Fp2Bls, Fp6 } from './tower.ts';
29+
import { type CHash, type Hex, type PrivKey, ensureBytes, memoized } from './utils.ts';
3030
import {
3131
type CurvePointsRes,
3232
type CurvePointsType,
3333
type ProjPointType,
3434
weierstrassPoints,
35-
} from './weierstrass.js';
35+
} from './weierstrass.ts';
3636

3737
type Fp = bigint; // Can be different field?
3838

src/abstract/curve.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @module
55
*/
66
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7-
import { type IField, nLength, validateField } from './modular.js';
8-
import { bitLen, validateObject } from './utils.js';
7+
import { type IField, nLength, validateField } from './modular.ts';
8+
import { bitLen, validateObject } from './utils.ts';
99

1010
const _0n = BigInt(0);
1111
const _1n = BigInt(1);

src/abstract/edwards.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import {
1212
pippenger,
1313
validateBasic,
1414
wNAF,
15-
} from './curve.js';
16-
import { Field, mod } from './modular.js';
17-
import * as ut from './utils.js';
18-
import { abool, ensureBytes, type FHash, type Hex, memoized } from './utils.js';
15+
} from './curve.ts';
16+
import { Field, mod } from './modular.ts';
17+
import * as ut from './utils.ts';
18+
import { abool, ensureBytes, type FHash, type Hex, memoized } from './utils.ts';
1919

2020
// Be friendly to bad ECMAScript parsers by not using bigint literals
2121
// prettier-ignore

src/abstract/hash-to-curve.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* @module
55
*/
66
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7-
import type { AffinePoint, Group, GroupConstructor } from './curve.js';
8-
import { type IField, mod } from './modular.js';
9-
import type { CHash } from './utils.js';
10-
import { abytes, bytesToNumberBE, concatBytes, utf8ToBytes, validateObject } from './utils.js';
7+
import type { AffinePoint, Group, GroupConstructor } from './curve.ts';
8+
import { type IField, mod } from './modular.ts';
9+
import type { CHash } from './utils.ts';
10+
import { abytes, bytesToNumberBE, concatBytes, utf8ToBytes, validateObject } from './utils.ts';
1111

1212
export type UnicodeOrBytes = string | Uint8Array;
1313

src/abstract/modular.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
numberToBytesBE,
1414
numberToBytesLE,
1515
validateObject,
16-
} from './utils.js';
16+
} from './utils.ts';
1717

1818
// prettier-ignore
1919
const _0n = BigInt(0), _1n = BigInt(1), _2n = /* @__PURE__ */ BigInt(2), _3n = /* @__PURE__ */ BigInt(3);

src/abstract/montgomery.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* @module
66
*/
77
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
8-
import { mod, pow } from './modular.js';
8+
import { mod, pow } from './modular.ts';
99
import {
1010
aInRange,
1111
bytesToNumberLE,
1212
ensureBytes,
1313
numberToBytesLE,
1414
validateObject,
15-
} from './utils.js';
15+
} from './utils.ts';
1616

1717
const _0n = BigInt(0);
1818
const _1n = BigInt(1);

src/abstract/poseidon.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @module
88
*/
99
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
10-
import { FpPow, type IField, validateField } from './modular.js';
10+
import { FpPow, type IField, validateField } from './modular.ts';
1111

1212
export type PoseidonOpts = {
1313
Fp: IField<bigint>;

src/abstract/tower.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* @module
1111
*/
1212
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
13-
import * as mod from './modular.js';
14-
import { bitLen, bitMask, concatBytes, notImplemented } from './utils.js';
15-
import type { ProjConstructor, ProjPointType } from './weierstrass.js';
13+
import * as mod from './modular.ts';
14+
import { bitLen, bitMask, concatBytes, notImplemented } from './utils.ts';
15+
import type { ProjConstructor, ProjPointType } from './weierstrass.ts';
1616

1717
// Be friendly to bad ECMAScript parsers by not using bigint literals
1818
// prettier-ignore

src/abstract/weierstrass.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
pippenger,
3434
validateBasic,
3535
wNAF,
36-
} from './curve.js';
36+
} from './curve.ts';
3737
import {
3838
Field,
3939
type IField,
@@ -42,9 +42,9 @@ import {
4242
mapHashToField,
4343
mod,
4444
validateField,
45-
} from './modular.js';
46-
import * as ut from './utils.js';
47-
import { type CHash, type Hex, type PrivKey, abool, ensureBytes, memoized } from './utils.js';
45+
} from './modular.ts';
46+
import * as ut from './utils.ts';
47+
import { type CHash, type Hex, type PrivKey, abool, ensureBytes, memoized } from './utils.ts';
4848

4949
export type { AffinePoint };
5050
type HmacFnSync = (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;

src/bls12-381.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6262
import { sha256 } from '@noble/hashes/sha256';
6363
import { randomBytes } from '@noble/hashes/utils';
64-
import { bls, type CurveFn } from './abstract/bls.js';
65-
import * as mod from './abstract/modular.js';
64+
import { bls, type CurveFn } from './abstract/bls.ts';
65+
import * as mod from './abstract/modular.ts';
6666
import {
6767
bitGet,
6868
bitLen,
@@ -72,16 +72,16 @@ import {
7272
ensureBytes,
7373
type Hex,
7474
numberToBytesBE,
75-
} from './abstract/utils.js';
75+
} from './abstract/utils.ts';
7676
// Types
77-
import { isogenyMap } from './abstract/hash-to-curve.js';
78-
import type { Fp, Fp12, Fp2, Fp6 } from './abstract/tower.js';
79-
import { psiFrobenius, tower12 } from './abstract/tower.js';
77+
import { isogenyMap } from './abstract/hash-to-curve.ts';
78+
import type { Fp, Fp12, Fp2, Fp6 } from './abstract/tower.ts';
79+
import { psiFrobenius, tower12 } from './abstract/tower.ts';
8080
import {
8181
type AffinePoint,
8282
mapToCurveSimpleSWU,
8383
type ProjPointType,
84-
} from './abstract/weierstrass.js';
84+
} from './abstract/weierstrass.ts';
8585

8686
// Be friendly to bad ECMAScript parsers by not using bigint literals
8787
// prettier-ignore

src/bn254.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ Ate loop size: 6x+2
4747
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4848
import { sha256 } from '@noble/hashes/sha256';
4949
import { randomBytes } from '@noble/hashes/utils';
50-
import { getHash } from './_shortw_utils.js';
50+
import { getHash } from './_shortw_utils.ts';
5151
import {
5252
bls,
5353
type CurveFn as BLSCurveFn,
5454
type PostPrecomputeFn,
5555
type PostPrecomputePointAddFn,
56-
} from './abstract/bls.js';
57-
import { Field } from './abstract/modular.js';
58-
import type { Fp, Fp12, Fp2, Fp6 } from './abstract/tower.js';
59-
import { psiFrobenius, tower12 } from './abstract/tower.js';
60-
import { bitGet, bitLen, notImplemented } from './abstract/utils.js';
61-
import { type CurveFn, weierstrass } from './abstract/weierstrass.js';
56+
} from './abstract/bls.ts';
57+
import { Field } from './abstract/modular.ts';
58+
import type { Fp, Fp12, Fp2, Fp6 } from './abstract/tower.ts';
59+
import { psiFrobenius, tower12 } from './abstract/tower.ts';
60+
import { bitGet, bitLen, notImplemented } from './abstract/utils.ts';
61+
import { type CurveFn, weierstrass } from './abstract/weierstrass.ts';
6262
// prettier-ignore
6363
const _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3);
6464
const _6n = BigInt(6);

src/ed25519.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
99
import { sha512 } from '@noble/hashes/sha512';
1010
import { concatBytes, randomBytes, utf8ToBytes } from '@noble/hashes/utils';
11-
import { type AffinePoint, type Group, pippenger } from './abstract/curve.js';
12-
import { type CurveFn, type ExtPointType, twistedEdwards } from './abstract/edwards.js';
11+
import { type AffinePoint, type Group, pippenger } from './abstract/curve.ts';
12+
import { type CurveFn, type ExtPointType, twistedEdwards } from './abstract/edwards.ts';
1313
import {
1414
createHasher,
1515
expand_message_xmd,
1616
type htfBasicOpts,
1717
type HTFMethod,
18-
} from './abstract/hash-to-curve.js';
19-
import { Field, FpSqrtEven, isNegativeLE, mod, pow2 } from './abstract/modular.js';
20-
import { montgomery, type CurveFn as XCurveFn } from './abstract/montgomery.js';
18+
} from './abstract/hash-to-curve.ts';
19+
import { Field, FpSqrtEven, isNegativeLE, mod, pow2 } from './abstract/modular.ts';
20+
import { montgomery, type CurveFn as XCurveFn } from './abstract/montgomery.ts';
2121
import {
2222
bytesToHex,
2323
bytesToNumberLE,
2424
ensureBytes,
2525
equalBytes,
2626
type Hex,
2727
numberToBytesLE,
28-
} from './abstract/utils.js';
28+
} from './abstract/utils.ts';
2929

3030
const ED25519_P = BigInt(
3131
'57896044618658097711785492504343953926634992332820282019728792003956564819949'

src/ed448.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1010
import { shake256 } from '@noble/hashes/sha3';
1111
import { concatBytes, randomBytes, utf8ToBytes, wrapConstructor } from '@noble/hashes/utils';
12-
import type { AffinePoint, Group } from './abstract/curve.js';
13-
import { pippenger } from './abstract/curve.js';
14-
import { type CurveFn, type ExtPointType, twistedEdwards } from './abstract/edwards.js';
12+
import type { AffinePoint, Group } from './abstract/curve.ts';
13+
import { pippenger } from './abstract/curve.ts';
14+
import { type CurveFn, type ExtPointType, twistedEdwards } from './abstract/edwards.ts';
1515
import {
1616
createHasher,
1717
expand_message_xof,
1818
type htfBasicOpts,
1919
type HTFMethod,
20-
} from './abstract/hash-to-curve.js';
21-
import { Field, isNegativeLE, mod, pow2 } from './abstract/modular.js';
22-
import { montgomery, type CurveFn as XCurveFn } from './abstract/montgomery.js';
20+
} from './abstract/hash-to-curve.ts';
21+
import { Field, isNegativeLE, mod, pow2 } from './abstract/modular.ts';
22+
import { montgomery, type CurveFn as XCurveFn } from './abstract/montgomery.ts';
2323
import {
2424
bytesToHex,
2525
bytesToNumberLE,
2626
ensureBytes,
2727
equalBytes,
2828
type Hex,
2929
numberToBytesLE,
30-
} from './abstract/utils.js';
30+
} from './abstract/utils.ts';
3131

3232
const shake256_114 = wrapConstructor(() => shake256.create({ dkLen: 114 }));
3333
const shake256_64 = wrapConstructor(() => shake256.create({ dkLen: 64 }));

src/jubjub.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import { blake2s } from '@noble/hashes/blake2s';
99
import { sha512 } from '@noble/hashes/sha512';
1010
import { concatBytes, randomBytes, utf8ToBytes } from '@noble/hashes/utils';
11-
import { type CurveFn, type ExtPointType, twistedEdwards } from './abstract/edwards.js';
12-
import { Field } from './abstract/modular.js';
11+
import { type CurveFn, type ExtPointType, twistedEdwards } from './abstract/edwards.ts';
12+
import { Field } from './abstract/modular.ts';
1313

1414
export const jubjub: CurveFn = /* @__PURE__ */ twistedEdwards({
1515
// Params: a, d

src/p256.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
*/
66
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
77
import { sha256 } from '@noble/hashes/sha256';
8-
import { createCurve, type CurveFnWithCreate } from './_shortw_utils.js';
9-
import { createHasher, type HTFMethod } from './abstract/hash-to-curve.js';
10-
import { Field } from './abstract/modular.js';
11-
import { mapToCurveSimpleSWU } from './abstract/weierstrass.js';
8+
import { createCurve, type CurveFnWithCreate } from './_shortw_utils.ts';
9+
import { createHasher, type HTFMethod } from './abstract/hash-to-curve.ts';
10+
import { Field } from './abstract/modular.ts';
11+
import { mapToCurveSimpleSWU } from './abstract/weierstrass.ts';
1212

1313
const Fp256 = Field(BigInt('0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff'));
1414
const CURVE_A = Fp256.create(BigInt('-3'));

src/p384.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
*/
66
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
77
import { sha384 } from '@noble/hashes/sha512';
8-
import { createCurve, type CurveFnWithCreate } from './_shortw_utils.js';
9-
import { createHasher, type HTFMethod } from './abstract/hash-to-curve.js';
10-
import { Field } from './abstract/modular.js';
11-
import { mapToCurveSimpleSWU } from './abstract/weierstrass.js';
8+
import { createCurve, type CurveFnWithCreate } from './_shortw_utils.ts';
9+
import { createHasher, type HTFMethod } from './abstract/hash-to-curve.ts';
10+
import { Field } from './abstract/modular.ts';
11+
import { mapToCurveSimpleSWU } from './abstract/weierstrass.ts';
1212

1313
// Field over which we'll do calculations.
1414
// prettier-ignore

src/p521.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
*/
77
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
88
import { sha512 } from '@noble/hashes/sha512';
9-
import { createCurve, type CurveFnWithCreate } from './_shortw_utils.js';
10-
import { createHasher, type HTFMethod } from './abstract/hash-to-curve.js';
11-
import { Field } from './abstract/modular.js';
12-
import { mapToCurveSimpleSWU } from './abstract/weierstrass.js';
9+
import { createCurve, type CurveFnWithCreate } from './_shortw_utils.ts';
10+
import { createHasher, type HTFMethod } from './abstract/hash-to-curve.ts';
11+
import { Field } from './abstract/modular.ts';
12+
import { mapToCurveSimpleSWU } from './abstract/weierstrass.ts';
1313

1414
// Field over which we'll do calculations.
1515
// prettier-ignore

src/pasta.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*/
55
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
66
import { sha256 } from '@noble/hashes/sha256';
7-
import { getHash } from './_shortw_utils.js';
8-
import { Field, mod } from './abstract/modular.js';
9-
import { type CurveFn, weierstrass } from './abstract/weierstrass.js';
7+
import { getHash } from './_shortw_utils.ts';
8+
import { Field, mod } from './abstract/modular.ts';
9+
import { type CurveFn, weierstrass } from './abstract/weierstrass.ts';
1010

1111
export const p: bigint = BigInt(
1212
'0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001'

src/secp256k1.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1414
import { sha256 } from '@noble/hashes/sha256';
1515
import { randomBytes } from '@noble/hashes/utils';
16-
import { createCurve, type CurveFnWithCreate } from './_shortw_utils.js';
17-
import { createHasher, type HTFMethod, isogenyMap } from './abstract/hash-to-curve.js';
18-
import { Field, mod, pow2 } from './abstract/modular.js';
19-
import type { Hex, PrivKey } from './abstract/utils.js';
16+
import { createCurve, type CurveFnWithCreate } from './_shortw_utils.ts';
17+
import { createHasher, type HTFMethod, isogenyMap } from './abstract/hash-to-curve.ts';
18+
import { Field, mod, pow2 } from './abstract/modular.ts';
19+
import type { Hex, PrivKey } from './abstract/utils.ts';
2020
import {
2121
aInRange,
2222
bytesToNumberBE,
2323
concatBytes,
2424
ensureBytes,
2525
inRange,
2626
numberToBytesBE,
27-
} from './abstract/utils.js';
28-
import { mapToCurveSimpleSWU, type ProjPointType as PointType } from './abstract/weierstrass.js';
27+
} from './abstract/utils.ts';
28+
import { mapToCurveSimpleSWU, type ProjPointType as PointType } from './abstract/weierstrass.ts';
2929

3030
const secp256k1P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f');
3131
const secp256k1N = BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141');

0 commit comments

Comments
 (0)