@noble/curves 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +49 -8
  2. package/lib/_shortw_utils.d.ts +11 -26
  3. package/lib/abstract/bls.d.ts +51 -35
  4. package/lib/abstract/bls.js +77 -139
  5. package/lib/abstract/{group.d.ts → curve.d.ts} +31 -1
  6. package/lib/abstract/{group.js → curve.js} +39 -2
  7. package/lib/abstract/edwards.d.ts +30 -81
  8. package/lib/abstract/edwards.js +225 -420
  9. package/lib/abstract/hash-to-curve.d.ts +25 -6
  10. package/lib/abstract/hash-to-curve.js +40 -12
  11. package/lib/abstract/modular.d.ts +20 -7
  12. package/lib/abstract/modular.js +80 -51
  13. package/lib/abstract/montgomery.js +3 -4
  14. package/lib/abstract/poseidon.d.ts +29 -0
  15. package/lib/abstract/poseidon.js +115 -0
  16. package/lib/abstract/utils.d.ts +5 -34
  17. package/lib/abstract/utils.js +23 -63
  18. package/lib/abstract/weierstrass.d.ts +56 -79
  19. package/lib/abstract/weierstrass.js +509 -641
  20. package/lib/bls12-381.d.ts +1 -0
  21. package/lib/bls12-381.js +75 -65
  22. package/lib/bn.js +1 -1
  23. package/lib/ed25519.d.ts +7 -5
  24. package/lib/ed25519.js +87 -84
  25. package/lib/ed448.d.ts +3 -0
  26. package/lib/ed448.js +88 -84
  27. package/lib/esm/abstract/bls.js +77 -139
  28. package/lib/esm/abstract/{group.js → curve.js} +37 -1
  29. package/lib/esm/abstract/edwards.js +223 -418
  30. package/lib/esm/abstract/hash-to-curve.js +38 -11
  31. package/lib/esm/abstract/modular.js +77 -50
  32. package/lib/esm/abstract/montgomery.js +4 -7
  33. package/lib/esm/abstract/poseidon.js +109 -0
  34. package/lib/esm/abstract/utils.js +21 -59
  35. package/lib/esm/abstract/weierstrass.js +508 -640
  36. package/lib/esm/bls12-381.js +86 -76
  37. package/lib/esm/bn.js +1 -1
  38. package/lib/esm/ed25519.js +85 -83
  39. package/lib/esm/ed448.js +86 -83
  40. package/lib/esm/jubjub.js +6 -5
  41. package/lib/esm/p256.js +11 -9
  42. package/lib/esm/p384.js +11 -9
  43. package/lib/esm/p521.js +13 -12
  44. package/lib/esm/secp256k1.js +118 -157
  45. package/lib/esm/stark.js +104 -39
  46. package/lib/jubjub.d.ts +3 -2
  47. package/lib/jubjub.js +6 -5
  48. package/lib/p192.d.ts +22 -52
  49. package/lib/p224.d.ts +22 -52
  50. package/lib/p256.d.ts +25 -52
  51. package/lib/p256.js +13 -10
  52. package/lib/p384.d.ts +25 -52
  53. package/lib/p384.js +13 -10
  54. package/lib/p521.d.ts +25 -52
  55. package/lib/p521.js +15 -13
  56. package/lib/secp256k1.d.ts +26 -42
  57. package/lib/secp256k1.js +118 -157
  58. package/lib/stark.d.ts +36 -21
  59. package/lib/stark.js +107 -39
  60. package/package.json +14 -9
@@ -1,7 +1,5 @@
1
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
- import * as mod from './modular.js';
3
1
  export declare type Hex = Uint8Array | string;
4
- export declare type PrivKey = Hex | bigint | number;
2
+ export declare type PrivKey = Hex | bigint;
5
3
  export declare type CHash = {
6
4
  (message: Uint8Array | string): Uint8Array;
7
5
  blockLen: number;
@@ -10,45 +8,18 @@ export declare type CHash = {
10
8
  dkLen?: number;
11
9
  }): any;
12
10
  };
13
- export declare type BasicCurve<T> = {
14
- Fp: mod.Field<T>;
15
- n: bigint;
16
- nBitLength?: number;
17
- nByteLength?: number;
18
- h: bigint;
19
- hEff?: bigint;
20
- Gx: T;
21
- Gy: T;
22
- wrapPrivateKey?: boolean;
23
- allowInfinityPoint?: boolean;
24
- };
25
- export declare function validateOpts<FP, T>(curve: BasicCurve<FP> & T): Readonly<{
26
- readonly nBitLength: number;
27
- readonly nByteLength: number;
28
- } & BasicCurve<FP> & T>;
29
- export declare function bytesToHex(uint8a: Uint8Array): string;
11
+ export declare type FHash = (message: Uint8Array | string) => Uint8Array;
12
+ export declare function bytesToHex(bytes: Uint8Array): string;
30
13
  export declare function numberToHexUnpadded(num: number | bigint): string;
31
14
  export declare function hexToNumber(hex: string): bigint;
32
15
  export declare function hexToBytes(hex: string): Uint8Array;
33
16
  export declare function bytesToNumberBE(bytes: Uint8Array): bigint;
34
- export declare function bytesToNumberLE(uint8a: Uint8Array): bigint;
17
+ export declare function bytesToNumberLE(bytes: Uint8Array): bigint;
35
18
  export declare const numberToBytesBE: (n: bigint, len: number) => Uint8Array;
36
19
  export declare const numberToBytesLE: (n: bigint, len: number) => Uint8Array;
20
+ export declare const numberToVarBytesBE: (n: bigint) => Uint8Array;
37
21
  export declare function ensureBytes(hex: Hex, expectedLength?: number): Uint8Array;
38
22
  export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
39
- export declare function nLength(n: bigint, nBitLength?: number): {
40
- nBitLength: number;
41
- nByteLength: number;
42
- };
43
- /**
44
- * Can take (n+8) or more bytes of uniform input e.g. from CSPRNG or KDF
45
- * and convert them into private scalar, with the modulo bias being neglible.
46
- * As per FIPS 186 B.4.1.
47
- * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/
48
- * @param hash hash output from sha512, or a similar function
49
- * @returns valid private scalar
50
- */
51
- export declare function hashToPrivateScalar(hash: Hex, CURVE_ORDER: bigint, isLE?: boolean): bigint;
52
23
  export declare function equalBytes(b1: Uint8Array, b2: Uint8Array): boolean;
53
24
  export declare function bitLen(n: bigint): number;
54
25
  export declare const bitGet: (n: bigint, pos: number) => bigint;
@@ -1,39 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bitMask = exports.bitSet = exports.bitGet = exports.bitLen = exports.equalBytes = exports.hashToPrivateScalar = exports.nLength = exports.concatBytes = exports.ensureBytes = exports.numberToBytesLE = exports.numberToBytesBE = exports.bytesToNumberLE = exports.bytesToNumberBE = exports.hexToBytes = exports.hexToNumber = exports.numberToHexUnpadded = exports.bytesToHex = exports.validateOpts = void 0;
3
+ exports.bitMask = exports.bitSet = exports.bitGet = exports.bitLen = exports.equalBytes = exports.concatBytes = exports.ensureBytes = exports.numberToVarBytesBE = exports.numberToBytesLE = exports.numberToBytesBE = exports.bytesToNumberLE = exports.bytesToNumberBE = exports.hexToBytes = exports.hexToNumber = exports.numberToHexUnpadded = exports.bytesToHex = void 0;
4
4
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
- const mod = require("./modular.js");
6
5
  const _0n = BigInt(0);
7
6
  const _1n = BigInt(1);
8
7
  const _2n = BigInt(2);
9
- function validateOpts(curve) {
10
- mod.validateField(curve.Fp);
11
- for (const i of ['n', 'h']) {
12
- if (typeof curve[i] !== 'bigint')
13
- throw new Error(`Invalid curve param ${i}=${curve[i]} (${typeof curve[i]})`);
14
- }
15
- if (!curve.Fp.isValid(curve.Gx))
16
- throw new Error('Invalid generator X coordinate Fp element');
17
- if (!curve.Fp.isValid(curve.Gy))
18
- throw new Error('Invalid generator Y coordinate Fp element');
19
- for (const i of ['nBitLength', 'nByteLength']) {
20
- if (curve[i] === undefined)
21
- continue; // Optional
22
- if (!Number.isSafeInteger(curve[i]))
23
- throw new Error(`Invalid curve param ${i}=${curve[i]} (${typeof curve[i]})`);
24
- }
25
- // Set defaults
26
- return Object.freeze({ ...nLength(curve.n, curve.nBitLength), ...curve });
27
- }
28
- exports.validateOpts = validateOpts;
8
+ const u8a = (a) => a instanceof Uint8Array;
29
9
  const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
30
- function bytesToHex(uint8a) {
31
- if (!(uint8a instanceof Uint8Array))
10
+ function bytesToHex(bytes) {
11
+ if (!u8a(bytes))
32
12
  throw new Error('Expected Uint8Array');
33
13
  // pre-caching improves the speed 6x
34
14
  let hex = '';
35
- for (let i = 0; i < uint8a.length; i++) {
36
- hex += hexes[uint8a[i]];
15
+ for (let i = 0; i < bytes.length; i++) {
16
+ hex += hexes[bytes[i]];
37
17
  }
38
18
  return hex;
39
19
  }
@@ -44,18 +24,16 @@ function numberToHexUnpadded(num) {
44
24
  }
45
25
  exports.numberToHexUnpadded = numberToHexUnpadded;
46
26
  function hexToNumber(hex) {
47
- if (typeof hex !== 'string') {
48
- throw new TypeError('hexToNumber: expected string, got ' + typeof hex);
49
- }
27
+ if (typeof hex !== 'string')
28
+ throw new Error('hexToNumber: expected string, got ' + typeof hex);
50
29
  // Big Endian
51
30
  return BigInt(`0x${hex}`);
52
31
  }
53
32
  exports.hexToNumber = hexToNumber;
54
33
  // Caching slows it down 2-3x
55
34
  function hexToBytes(hex) {
56
- if (typeof hex !== 'string') {
57
- throw new TypeError('hexToBytes: expected string, got ' + typeof hex);
58
- }
35
+ if (typeof hex !== 'string')
36
+ throw new Error('hexToBytes: expected string, got ' + typeof hex);
59
37
  if (hex.length % 2)
60
38
  throw new Error('hexToBytes: received invalid unpadded hex ' + hex.length);
61
39
  const array = new Uint8Array(hex.length / 2);
@@ -75,20 +53,28 @@ function bytesToNumberBE(bytes) {
75
53
  return hexToNumber(bytesToHex(bytes));
76
54
  }
77
55
  exports.bytesToNumberBE = bytesToNumberBE;
78
- function bytesToNumberLE(uint8a) {
79
- if (!(uint8a instanceof Uint8Array))
56
+ function bytesToNumberLE(bytes) {
57
+ if (!u8a(bytes))
80
58
  throw new Error('Expected Uint8Array');
81
- return BigInt('0x' + bytesToHex(Uint8Array.from(uint8a).reverse()));
59
+ return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse()));
82
60
  }
83
61
  exports.bytesToNumberLE = bytesToNumberLE;
84
62
  const numberToBytesBE = (n, len) => hexToBytes(n.toString(16).padStart(len * 2, '0'));
85
63
  exports.numberToBytesBE = numberToBytesBE;
86
64
  const numberToBytesLE = (n, len) => (0, exports.numberToBytesBE)(n, len).reverse();
87
65
  exports.numberToBytesLE = numberToBytesLE;
66
+ // Returns variable number bytes (minimal bigint encoding?)
67
+ const numberToVarBytesBE = (n) => {
68
+ let hex = n.toString(16);
69
+ if (hex.length & 1)
70
+ hex = '0' + hex;
71
+ return hexToBytes(hex);
72
+ };
73
+ exports.numberToVarBytesBE = numberToVarBytesBE;
88
74
  function ensureBytes(hex, expectedLength) {
89
75
  // Uint8Array.from() instead of hash.slice() because node.js Buffer
90
76
  // is instance of Uint8Array, and its slice() creates **mutable** copy
91
- const bytes = hex instanceof Uint8Array ? Uint8Array.from(hex) : hexToBytes(hex);
77
+ const bytes = u8a(hex) ? Uint8Array.from(hex) : hexToBytes(hex);
92
78
  if (typeof expectedLength === 'number' && bytes.length !== expectedLength)
93
79
  throw new Error(`Expected ${expectedLength} bytes`);
94
80
  return bytes;
@@ -96,7 +82,7 @@ function ensureBytes(hex, expectedLength) {
96
82
  exports.ensureBytes = ensureBytes;
97
83
  // Copies several Uint8Arrays into one.
98
84
  function concatBytes(...arrays) {
99
- if (!arrays.every((b) => b instanceof Uint8Array))
85
+ if (!arrays.every((b) => u8a(b)))
100
86
  throw new Error('Uint8Array list expected');
101
87
  if (arrays.length === 1)
102
88
  return arrays[0];
@@ -110,32 +96,6 @@ function concatBytes(...arrays) {
110
96
  return result;
111
97
  }
112
98
  exports.concatBytes = concatBytes;
113
- // CURVE.n lengths
114
- function nLength(n, nBitLength) {
115
- // Bit size, byte size of CURVE.n
116
- const _nBitLength = nBitLength !== undefined ? nBitLength : n.toString(2).length;
117
- const nByteLength = Math.ceil(_nBitLength / 8);
118
- return { nBitLength: _nBitLength, nByteLength };
119
- }
120
- exports.nLength = nLength;
121
- /**
122
- * Can take (n+8) or more bytes of uniform input e.g. from CSPRNG or KDF
123
- * and convert them into private scalar, with the modulo bias being neglible.
124
- * As per FIPS 186 B.4.1.
125
- * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/
126
- * @param hash hash output from sha512, or a similar function
127
- * @returns valid private scalar
128
- */
129
- function hashToPrivateScalar(hash, CURVE_ORDER, isLE = false) {
130
- hash = ensureBytes(hash);
131
- const orderLen = nLength(CURVE_ORDER).nByteLength;
132
- const minLen = orderLen + 8;
133
- if (orderLen < 16 || hash.length < minLen || hash.length > 1024)
134
- throw new Error('Expected valid bytes of private key as per FIPS 186');
135
- const num = isLE ? bytesToNumberLE(hash) : bytesToNumberBE(hash);
136
- return mod.mod(num, CURVE_ORDER - _1n) + _1n;
137
- }
138
- exports.hashToPrivateScalar = hashToPrivateScalar;
139
99
  function equalBytes(b1, b2) {
140
100
  // We don't care about timing attacks here
141
101
  if (b1.length !== b2.length)
@@ -1,9 +1,9 @@
1
1
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
2
  import * as mod from './modular.js';
3
- import { Hex, PrivKey } from './utils.js';
4
- import * as utils from './utils.js';
5
- import { htfOpts } from './hash-to-curve.js';
6
- import { Group, GroupConstructor } from './group.js';
3
+ import * as ut from './utils.js';
4
+ import { Hex, PrivKey, CHash } from './utils.js';
5
+ import { Group, GroupConstructor, AbstractCurve, AffinePoint } from './curve.js';
6
+ export type { AffinePoint };
7
7
  declare type HmacFnSync = (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
8
8
  declare type EndomorphismOpts = {
9
9
  beta: bigint;
@@ -14,23 +14,24 @@ declare type EndomorphismOpts = {
14
14
  k2: bigint;
15
15
  };
16
16
  };
17
- export declare type BasicCurve<T> = utils.BasicCurve<T> & {
17
+ export declare type BasicCurve<T> = AbstractCurve<T> & {
18
18
  a: T;
19
19
  b: T;
20
20
  normalizePrivateKey?: (key: PrivKey) => PrivKey;
21
+ wrapPrivateKey?: boolean;
21
22
  endo?: EndomorphismOpts;
22
- isTorsionFree?: (c: ProjectiveConstructor<T>, point: ProjectivePointType<T>) => boolean;
23
- clearCofactor?: (c: ProjectiveConstructor<T>, point: ProjectivePointType<T>) => ProjectivePointType<T>;
24
- htfDefaults?: htfOpts;
25
- mapToCurve?: (scalar: bigint[]) => {
26
- x: T;
27
- y: T;
28
- };
23
+ isTorsionFree?: (c: ProjConstructor<T>, point: ProjPointType<T>) => boolean;
24
+ clearCofactor?: (c: ProjConstructor<T>, point: ProjPointType<T>) => ProjPointType<T>;
29
25
  };
30
26
  declare type Entropy = Hex | true;
31
- declare type SignOpts = {
27
+ export declare type SignOpts = {
32
28
  lowS?: boolean;
33
29
  extraEntropy?: Entropy;
30
+ prehash?: boolean;
31
+ };
32
+ export declare type VerOpts = {
33
+ lowS?: boolean;
34
+ prehash?: boolean;
34
35
  };
35
36
  /**
36
37
  * ### Design rationale for types
@@ -53,54 +54,41 @@ declare type SignOpts = {
53
54
  *
54
55
  * TODO: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#unique-symbol
55
56
  */
56
- export interface ProjectivePointType<T> extends Group<ProjectivePointType<T>> {
57
- readonly x: T;
58
- readonly y: T;
59
- readonly z: T;
60
- multiply(scalar: number | bigint, affinePoint?: PointType<T>): ProjectivePointType<T>;
61
- multiplyUnsafe(scalar: bigint): ProjectivePointType<T>;
62
- toAffine(invZ?: T): PointType<T>;
63
- }
64
- export interface ProjectiveConstructor<T> extends GroupConstructor<ProjectivePointType<T>> {
65
- new (x: T, y: T, z: T): ProjectivePointType<T>;
66
- fromAffine(p: PointType<T>): ProjectivePointType<T>;
67
- toAffineBatch(points: ProjectivePointType<T>[]): PointType<T>[];
68
- normalizeZ(points: ProjectivePointType<T>[]): ProjectivePointType<T>[];
69
- }
70
- export interface PointType<T> extends Group<PointType<T>> {
71
- readonly x: T;
72
- readonly y: T;
57
+ export interface ProjPointType<T> extends Group<ProjPointType<T>> {
58
+ readonly px: T;
59
+ readonly py: T;
60
+ readonly pz: T;
61
+ multiply(scalar: bigint): ProjPointType<T>;
62
+ multiplyUnsafe(scalar: bigint): ProjPointType<T>;
63
+ multiplyAndAddUnsafe(Q: ProjPointType<T>, a: bigint, b: bigint): ProjPointType<T> | undefined;
73
64
  _setWindowSize(windowSize: number): void;
65
+ toAffine(iz?: T): AffinePoint<T>;
66
+ isTorsionFree(): boolean;
67
+ clearCofactor(): ProjPointType<T>;
68
+ assertValidity(): void;
74
69
  hasEvenY(): boolean;
75
70
  toRawBytes(isCompressed?: boolean): Uint8Array;
76
71
  toHex(isCompressed?: boolean): string;
77
- assertValidity(): void;
78
- multiplyAndAddUnsafe(Q: PointType<T>, a: bigint, b: bigint): PointType<T> | undefined;
79
72
  }
80
- export interface PointConstructor<T> extends GroupConstructor<PointType<T>> {
81
- new (x: T, y: T): PointType<T>;
82
- fromHex(hex: Hex): PointType<T>;
83
- fromPrivateKey(privateKey: PrivKey): PointType<T>;
84
- hashToCurve(msg: Hex, options?: Partial<htfOpts>): PointType<T>;
85
- encodeToCurve(msg: Hex, options?: Partial<htfOpts>): PointType<T>;
73
+ export interface ProjConstructor<T> extends GroupConstructor<ProjPointType<T>> {
74
+ new (x: T, y: T, z: T): ProjPointType<T>;
75
+ fromAffine(p: AffinePoint<T>): ProjPointType<T>;
76
+ fromHex(hex: Hex): ProjPointType<T>;
77
+ fromPrivateKey(privateKey: PrivKey): ProjPointType<T>;
78
+ normalizeZ(points: ProjPointType<T>[]): ProjPointType<T>[];
86
79
  }
87
80
  export declare type CurvePointsType<T> = BasicCurve<T> & {
88
- fromBytes: (bytes: Uint8Array) => {
89
- x: T;
90
- y: T;
91
- };
92
- toBytes: (c: PointConstructor<T>, point: PointType<T>, compressed: boolean) => Uint8Array;
81
+ fromBytes: (bytes: Uint8Array) => AffinePoint<T>;
82
+ toBytes: (c: ProjConstructor<T>, point: ProjPointType<T>, compressed: boolean) => Uint8Array;
93
83
  };
94
84
  export declare type CurvePointsRes<T> = {
95
- Point: PointConstructor<T>;
96
- ProjectivePoint: ProjectiveConstructor<T>;
85
+ ProjectivePoint: ProjConstructor<T>;
97
86
  normalizePrivateKey: (key: PrivKey) => bigint;
98
87
  weierstrassEquation: (x: T) => T;
99
88
  isWithinCurveOrder: (num: bigint) => boolean;
100
89
  };
101
90
  export declare function weierstrassPoints<T>(opts: CurvePointsType<T>): {
102
- Point: PointConstructor<T>;
103
- ProjectivePoint: ProjectiveConstructor<T>;
91
+ ProjectivePoint: ProjConstructor<T>;
104
92
  normalizePrivateKey: (key: PrivKey) => bigint;
105
93
  weierstrassEquation: (x: T) => T;
106
94
  isWithinCurveOrder: (num: bigint) => boolean;
@@ -110,27 +98,32 @@ export interface SignatureType {
110
98
  readonly s: bigint;
111
99
  readonly recovery?: number;
112
100
  assertValidity(): void;
113
- copyWithRecoveryBit(recovery: number): SignatureType;
101
+ addRecoveryBit(recovery: number): SignatureType;
114
102
  hasHighS(): boolean;
115
103
  normalizeS(): SignatureType;
116
- recoverPublicKey(msgHash: Hex): PointType<bigint>;
117
- toDERRawBytes(isCompressed?: boolean): Uint8Array;
118
- toDERHex(isCompressed?: boolean): string;
104
+ recoverPublicKey(msgHash: Hex): ProjPointType<bigint>;
119
105
  toCompactRawBytes(): Uint8Array;
120
106
  toCompactHex(): string;
107
+ toDERRawBytes(isCompressed?: boolean): Uint8Array;
108
+ toDERHex(isCompressed?: boolean): string;
121
109
  }
122
110
  export declare type SignatureConstructor = {
123
111
  new (r: bigint, s: bigint): SignatureType;
124
112
  fromCompact(hex: Hex): SignatureType;
125
113
  fromDER(hex: Hex): SignatureType;
126
114
  };
127
- export declare type PubKey = Hex | PointType<bigint>;
115
+ declare type SignatureLike = {
116
+ r: bigint;
117
+ s: bigint;
118
+ };
119
+ export declare type PubKey = Hex | ProjPointType<bigint>;
128
120
  export declare type CurveType = BasicCurve<bigint> & {
129
121
  lowS?: boolean;
130
- hash: utils.CHash;
122
+ hash: CHash;
131
123
  hmac: HmacFnSync;
132
124
  randomBytes: (bytesLength?: number) => Uint8Array;
133
- truncateHash?: (hash: Uint8Array, truncateOnly?: boolean) => bigint;
125
+ bits2int?: (bytes: Uint8Array) => bigint;
126
+ bits2int_modN?: (bytes: Uint8Array) => bigint;
134
127
  };
135
128
  declare function validateOpts(curve: CurveType): Readonly<{
136
129
  readonly nBitLength: number;
@@ -145,42 +138,27 @@ declare function validateOpts(curve: CurveType): Readonly<{
145
138
  readonly allowInfinityPoint?: boolean | undefined;
146
139
  readonly a: bigint;
147
140
  readonly b: bigint;
148
- readonly normalizePrivateKey?: ((key: PrivKey) => PrivKey) | undefined;
141
+ readonly normalizePrivateKey?: ((key: ut.PrivKey) => ut.PrivKey) | undefined;
149
142
  readonly endo?: EndomorphismOpts | undefined;
150
- readonly isTorsionFree?: ((c: ProjectiveConstructor<bigint>, point: ProjectivePointType<bigint>) => boolean) | undefined;
151
- readonly clearCofactor?: ((c: ProjectiveConstructor<bigint>, point: ProjectivePointType<bigint>) => ProjectivePointType<bigint>) | undefined;
152
- readonly htfDefaults?: htfOpts | undefined;
153
- readonly mapToCurve?: ((scalar: bigint[]) => {
154
- x: bigint;
155
- y: bigint;
156
- }) | undefined;
143
+ readonly isTorsionFree?: ((c: ProjConstructor<bigint>, point: ProjPointType<bigint>) => boolean) | undefined;
144
+ readonly clearCofactor?: ((c: ProjConstructor<bigint>, point: ProjPointType<bigint>) => ProjPointType<bigint>) | undefined;
157
145
  lowS: boolean;
158
- readonly hash: utils.CHash;
146
+ readonly hash: ut.CHash;
159
147
  readonly hmac: HmacFnSync;
160
148
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
161
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
149
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
150
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
162
151
  }>;
163
152
  export declare type CurveFn = {
164
153
  CURVE: ReturnType<typeof validateOpts>;
165
154
  getPublicKey: (privateKey: PrivKey, isCompressed?: boolean) => Uint8Array;
166
- getSharedSecret: (privateA: PrivKey, publicB: PubKey, isCompressed?: boolean) => Uint8Array;
155
+ getSharedSecret: (privateA: PrivKey, publicB: Hex, isCompressed?: boolean) => Uint8Array;
167
156
  sign: (msgHash: Hex, privKey: PrivKey, opts?: SignOpts) => SignatureType;
168
- verify: (signature: Hex | SignatureType, msgHash: Hex, publicKey: PubKey, opts?: {
169
- lowS?: boolean;
170
- }) => boolean;
171
- Point: PointConstructor<bigint>;
172
- ProjectivePoint: ProjectiveConstructor<bigint>;
157
+ verify: (signature: Hex | SignatureLike, msgHash: Hex, publicKey: Hex, opts?: VerOpts) => boolean;
158
+ ProjectivePoint: ProjConstructor<bigint>;
173
159
  Signature: SignatureConstructor;
174
160
  utils: {
175
- mod: (a: bigint, b?: bigint) => bigint;
176
- invert: (number: bigint, modulo?: bigint) => bigint;
177
- _bigintToBytes: (num: bigint) => Uint8Array;
178
- _bigintToString: (num: bigint) => string;
179
161
  _normalizePrivateKey: (key: PrivKey) => bigint;
180
- _normalizePublicKey: (publicKey: PubKey) => PointType<bigint>;
181
- _isWithinCurveOrder: (num: bigint) => boolean;
182
- _isValidFieldElement: (num: bigint) => boolean;
183
- _weierstrassEquation: (x: bigint) => bigint;
184
162
  isValidPrivateKey(privateKey: PrivKey): boolean;
185
163
  hashToPrivateKey: (hash: Hex) => Uint8Array;
186
164
  randomPrivateKey: () => Uint8Array;
@@ -199,4 +177,3 @@ export declare function mapToCurveSimpleSWU<T>(Fp: mod.Field<T>, opts: {
199
177
  x: T;
200
178
  y: T;
201
179
  };
202
- export {};