@noble/curves 0.5.2 → 0.6.1

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 (61) hide show
  1. package/README.md +115 -41
  2. package/lib/_shortw_utils.d.ts +13 -24
  3. package/lib/abstract/bls.d.ts +39 -32
  4. package/lib/abstract/bls.js +74 -73
  5. package/lib/abstract/{group.d.ts → curve.d.ts} +30 -1
  6. package/lib/abstract/{group.js → curve.js} +33 -2
  7. package/lib/abstract/edwards.d.ts +30 -72
  8. package/lib/abstract/edwards.js +206 -389
  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 +21 -8
  12. package/lib/abstract/modular.js +72 -48
  13. package/lib/abstract/montgomery.js +23 -68
  14. package/lib/abstract/poseidon.d.ts +29 -0
  15. package/lib/abstract/poseidon.js +115 -0
  16. package/lib/abstract/utils.d.ts +9 -37
  17. package/lib/abstract/utils.js +61 -87
  18. package/lib/abstract/weierstrass.d.ts +58 -81
  19. package/lib/abstract/weierstrass.js +485 -679
  20. package/lib/bls12-381.js +63 -58
  21. package/lib/bn.js +1 -1
  22. package/lib/ed25519.d.ts +7 -5
  23. package/lib/ed25519.js +82 -79
  24. package/lib/ed448.d.ts +3 -0
  25. package/lib/ed448.js +86 -83
  26. package/lib/esm/abstract/bls.js +75 -74
  27. package/lib/esm/abstract/{group.js → curve.js} +31 -1
  28. package/lib/esm/abstract/edwards.js +204 -387
  29. package/lib/esm/abstract/hash-to-curve.js +38 -11
  30. package/lib/esm/abstract/modular.js +69 -47
  31. package/lib/esm/abstract/montgomery.js +24 -69
  32. package/lib/esm/abstract/poseidon.js +109 -0
  33. package/lib/esm/abstract/utils.js +58 -82
  34. package/lib/esm/abstract/weierstrass.js +484 -678
  35. package/lib/esm/bls12-381.js +75 -70
  36. package/lib/esm/bn.js +1 -1
  37. package/lib/esm/ed25519.js +80 -78
  38. package/lib/esm/ed448.js +84 -82
  39. package/lib/esm/jubjub.js +1 -1
  40. package/lib/esm/p224.js +1 -1
  41. package/lib/esm/p256.js +11 -9
  42. package/lib/esm/p384.js +11 -9
  43. package/lib/esm/p521.js +12 -23
  44. package/lib/esm/secp256k1.js +124 -162
  45. package/lib/esm/stark.js +105 -41
  46. package/lib/jubjub.d.ts +2 -2
  47. package/lib/jubjub.js +1 -1
  48. package/lib/p192.d.ts +26 -48
  49. package/lib/p224.d.ts +26 -48
  50. package/lib/p224.js +1 -1
  51. package/lib/p256.d.ts +29 -48
  52. package/lib/p256.js +13 -10
  53. package/lib/p384.d.ts +29 -48
  54. package/lib/p384.js +13 -10
  55. package/lib/p521.d.ts +37 -57
  56. package/lib/p521.js +14 -24
  57. package/lib/secp256k1.d.ts +37 -46
  58. package/lib/secp256k1.js +124 -162
  59. package/lib/stark.d.ts +39 -22
  60. package/lib/stark.js +108 -41
  61. package/package.json +15 -10
package/lib/p192.d.ts CHANGED
@@ -9,11 +9,11 @@ export declare const P192: Readonly<{
9
9
  readonly hEff?: bigint | undefined;
10
10
  readonly Gx: bigint;
11
11
  readonly Gy: bigint;
12
- readonly wrapPrivateKey?: boolean | undefined;
13
12
  readonly allowInfinityPoint?: boolean | undefined;
14
13
  readonly a: bigint;
15
14
  readonly b: bigint;
16
- readonly normalizePrivateKey?: ((key: import("./abstract/utils.js").PrivKey) => import("./abstract/utils.js").PrivKey) | undefined;
15
+ readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
16
+ readonly wrapPrivateKey?: boolean | undefined;
17
17
  readonly endo?: {
18
18
  beta: bigint;
19
19
  splitScalar: (k: bigint) => {
@@ -23,37 +23,26 @@ export declare const P192: Readonly<{
23
23
  k2: bigint;
24
24
  };
25
25
  } | undefined;
26
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
27
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
28
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
29
- readonly mapToCurve?: ((scalar: bigint[]) => {
30
- x: bigint;
31
- y: bigint;
32
- }) | undefined;
33
- lowS: boolean;
26
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
27
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
34
28
  readonly hash: import("./abstract/utils.js").CHash;
35
29
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
36
30
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
37
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
31
+ lowS: boolean;
32
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
33
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
38
34
  }>;
39
35
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
40
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
36
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
41
37
  sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
42
- signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
43
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
44
- lowS?: boolean | undefined;
45
- } | undefined) => boolean;
46
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
47
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
38
+ verify: (signature: import("./abstract/utils.js").Hex | {
39
+ r: bigint;
40
+ s: bigint;
41
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
42
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
48
43
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
49
44
  utils: {
50
- _bigintToBytes: (num: bigint) => Uint8Array;
51
- _bigintToString: (num: bigint) => string;
52
45
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
53
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
54
- _isWithinCurveOrder: (num: bigint) => boolean;
55
- _isValidFieldElement: (num: bigint) => boolean;
56
- _weierstrassEquation: (x: bigint) => bigint;
57
46
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
58
47
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
59
48
  randomPrivateKey: () => Uint8Array;
@@ -70,11 +59,11 @@ export declare const secp192r1: Readonly<{
70
59
  readonly hEff?: bigint | undefined;
71
60
  readonly Gx: bigint;
72
61
  readonly Gy: bigint;
73
- readonly wrapPrivateKey?: boolean | undefined;
74
62
  readonly allowInfinityPoint?: boolean | undefined;
75
63
  readonly a: bigint;
76
64
  readonly b: bigint;
77
- readonly normalizePrivateKey?: ((key: import("./abstract/utils.js").PrivKey) => import("./abstract/utils.js").PrivKey) | undefined;
65
+ readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
66
+ readonly wrapPrivateKey?: boolean | undefined;
78
67
  readonly endo?: {
79
68
  beta: bigint;
80
69
  splitScalar: (k: bigint) => {
@@ -84,37 +73,26 @@ export declare const secp192r1: Readonly<{
84
73
  k2: bigint;
85
74
  };
86
75
  } | undefined;
87
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
88
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
89
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
90
- readonly mapToCurve?: ((scalar: bigint[]) => {
91
- x: bigint;
92
- y: bigint;
93
- }) | undefined;
94
- lowS: boolean;
76
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
77
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
95
78
  readonly hash: import("./abstract/utils.js").CHash;
96
79
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
97
80
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
98
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
81
+ lowS: boolean;
82
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
83
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
99
84
  }>;
100
85
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
101
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
86
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
102
87
  sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
103
- signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
104
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
105
- lowS?: boolean | undefined;
106
- } | undefined) => boolean;
107
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
108
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
88
+ verify: (signature: import("./abstract/utils.js").Hex | {
89
+ r: bigint;
90
+ s: bigint;
91
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
92
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
109
93
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
110
94
  utils: {
111
- _bigintToBytes: (num: bigint) => Uint8Array;
112
- _bigintToString: (num: bigint) => string;
113
95
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
114
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
115
- _isWithinCurveOrder: (num: bigint) => boolean;
116
- _isValidFieldElement: (num: bigint) => boolean;
117
- _weierstrassEquation: (x: bigint) => bigint;
118
96
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
119
97
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
120
98
  randomPrivateKey: () => Uint8Array;
package/lib/p224.d.ts CHANGED
@@ -9,11 +9,11 @@ export declare const P224: Readonly<{
9
9
  readonly hEff?: bigint | undefined;
10
10
  readonly Gx: bigint;
11
11
  readonly Gy: bigint;
12
- readonly wrapPrivateKey?: boolean | undefined;
13
12
  readonly allowInfinityPoint?: boolean | undefined;
14
13
  readonly a: bigint;
15
14
  readonly b: bigint;
16
- readonly normalizePrivateKey?: ((key: import("./abstract/utils.js").PrivKey) => import("./abstract/utils.js").PrivKey) | undefined;
15
+ readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
16
+ readonly wrapPrivateKey?: boolean | undefined;
17
17
  readonly endo?: {
18
18
  beta: bigint;
19
19
  splitScalar: (k: bigint) => {
@@ -23,37 +23,26 @@ export declare const P224: Readonly<{
23
23
  k2: bigint;
24
24
  };
25
25
  } | undefined;
26
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
27
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
28
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
29
- readonly mapToCurve?: ((scalar: bigint[]) => {
30
- x: bigint;
31
- y: bigint;
32
- }) | undefined;
33
- lowS: boolean;
26
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
27
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
34
28
  readonly hash: import("./abstract/utils.js").CHash;
35
29
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
36
30
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
37
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
31
+ lowS: boolean;
32
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
33
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
38
34
  }>;
39
35
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
40
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
36
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
41
37
  sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
42
- signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
43
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
44
- lowS?: boolean | undefined;
45
- } | undefined) => boolean;
46
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
47
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
38
+ verify: (signature: import("./abstract/utils.js").Hex | {
39
+ r: bigint;
40
+ s: bigint;
41
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
42
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
48
43
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
49
44
  utils: {
50
- _bigintToBytes: (num: bigint) => Uint8Array;
51
- _bigintToString: (num: bigint) => string;
52
45
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
53
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
54
- _isWithinCurveOrder: (num: bigint) => boolean;
55
- _isValidFieldElement: (num: bigint) => boolean;
56
- _weierstrassEquation: (x: bigint) => bigint;
57
46
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
58
47
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
59
48
  randomPrivateKey: () => Uint8Array;
@@ -70,11 +59,11 @@ export declare const secp224r1: Readonly<{
70
59
  readonly hEff?: bigint | undefined;
71
60
  readonly Gx: bigint;
72
61
  readonly Gy: bigint;
73
- readonly wrapPrivateKey?: boolean | undefined;
74
62
  readonly allowInfinityPoint?: boolean | undefined;
75
63
  readonly a: bigint;
76
64
  readonly b: bigint;
77
- readonly normalizePrivateKey?: ((key: import("./abstract/utils.js").PrivKey) => import("./abstract/utils.js").PrivKey) | undefined;
65
+ readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
66
+ readonly wrapPrivateKey?: boolean | undefined;
78
67
  readonly endo?: {
79
68
  beta: bigint;
80
69
  splitScalar: (k: bigint) => {
@@ -84,37 +73,26 @@ export declare const secp224r1: Readonly<{
84
73
  k2: bigint;
85
74
  };
86
75
  } | undefined;
87
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
88
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
89
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
90
- readonly mapToCurve?: ((scalar: bigint[]) => {
91
- x: bigint;
92
- y: bigint;
93
- }) | undefined;
94
- lowS: boolean;
76
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
77
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
95
78
  readonly hash: import("./abstract/utils.js").CHash;
96
79
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
97
80
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
98
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
81
+ lowS: boolean;
82
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
83
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
99
84
  }>;
100
85
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
101
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
86
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
102
87
  sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
103
- signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
104
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
105
- lowS?: boolean | undefined;
106
- } | undefined) => boolean;
107
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
108
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
88
+ verify: (signature: import("./abstract/utils.js").Hex | {
89
+ r: bigint;
90
+ s: bigint;
91
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
92
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
109
93
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
110
94
  utils: {
111
- _bigintToBytes: (num: bigint) => Uint8Array;
112
- _bigintToString: (num: bigint) => string;
113
95
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
114
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
115
- _isWithinCurveOrder: (num: bigint) => boolean;
116
- _isValidFieldElement: (num: bigint) => boolean;
117
- _weierstrassEquation: (x: bigint) => bigint;
118
96
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
119
97
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
120
98
  randomPrivateKey: () => Uint8Array;
package/lib/p224.js CHANGED
@@ -11,7 +11,7 @@ exports.P224 = (0, _shortw_utils_js_1.createCurve)({
11
11
  // Params: a, b
12
12
  a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe'),
13
13
  b: BigInt('0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4'),
14
- // Field over which we'll do calculations; 2n**224n - 2n**96n + 1n
14
+ // Field over which we'll do calculations;
15
15
  Fp: (0, modular_js_1.Fp)(BigInt('0xffffffffffffffffffffffffffffffff000000000000000000000001')),
16
16
  // Curve order, total count of valid points in the field
17
17
  n: BigInt('0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d'),
package/lib/p256.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as htf from './abstract/hash-to-curve.js';
1
2
  export declare const P256: Readonly<{
2
3
  create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn;
3
4
  CURVE: Readonly<{
@@ -9,11 +10,11 @@ export declare const P256: Readonly<{
9
10
  readonly hEff?: bigint | undefined;
10
11
  readonly Gx: bigint;
11
12
  readonly Gy: bigint;
12
- readonly wrapPrivateKey?: boolean | undefined;
13
13
  readonly allowInfinityPoint?: boolean | undefined;
14
14
  readonly a: bigint;
15
15
  readonly b: bigint;
16
- readonly normalizePrivateKey?: ((key: import("./abstract/utils.js").PrivKey) => import("./abstract/utils.js").PrivKey) | undefined;
16
+ readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
17
+ readonly wrapPrivateKey?: boolean | undefined;
17
18
  readonly endo?: {
18
19
  beta: bigint;
19
20
  splitScalar: (k: bigint) => {
@@ -23,37 +24,26 @@ export declare const P256: Readonly<{
23
24
  k2: bigint;
24
25
  };
25
26
  } | undefined;
26
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
27
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
28
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
29
- readonly mapToCurve?: ((scalar: bigint[]) => {
30
- x: bigint;
31
- y: bigint;
32
- }) | undefined;
33
- lowS: boolean;
27
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
28
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
34
29
  readonly hash: import("./abstract/utils.js").CHash;
35
30
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
36
31
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
37
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
32
+ lowS: boolean;
33
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
34
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
38
35
  }>;
39
36
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
40
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
37
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
41
38
  sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
42
- signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
43
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
44
- lowS?: boolean | undefined;
45
- } | undefined) => boolean;
46
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
47
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
39
+ verify: (signature: import("./abstract/utils.js").Hex | {
40
+ r: bigint;
41
+ s: bigint;
42
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
43
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
48
44
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
49
45
  utils: {
50
- _bigintToBytes: (num: bigint) => Uint8Array;
51
- _bigintToString: (num: bigint) => string;
52
46
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
53
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
54
- _isWithinCurveOrder: (num: bigint) => boolean;
55
- _isValidFieldElement: (num: bigint) => boolean;
56
- _weierstrassEquation: (x: bigint) => bigint;
57
47
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
58
48
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
59
49
  randomPrivateKey: () => Uint8Array;
@@ -70,11 +60,11 @@ export declare const secp256r1: Readonly<{
70
60
  readonly hEff?: bigint | undefined;
71
61
  readonly Gx: bigint;
72
62
  readonly Gy: bigint;
73
- readonly wrapPrivateKey?: boolean | undefined;
74
63
  readonly allowInfinityPoint?: boolean | undefined;
75
64
  readonly a: bigint;
76
65
  readonly b: bigint;
77
- readonly normalizePrivateKey?: ((key: import("./abstract/utils.js").PrivKey) => import("./abstract/utils.js").PrivKey) | undefined;
66
+ readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
67
+ readonly wrapPrivateKey?: boolean | undefined;
78
68
  readonly endo?: {
79
69
  beta: bigint;
80
70
  splitScalar: (k: bigint) => {
@@ -84,39 +74,30 @@ export declare const secp256r1: Readonly<{
84
74
  k2: bigint;
85
75
  };
86
76
  } | undefined;
87
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
88
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
89
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
90
- readonly mapToCurve?: ((scalar: bigint[]) => {
91
- x: bigint;
92
- y: bigint;
93
- }) | undefined;
94
- lowS: boolean;
77
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
78
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
95
79
  readonly hash: import("./abstract/utils.js").CHash;
96
80
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
97
81
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
98
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
82
+ lowS: boolean;
83
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
84
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
99
85
  }>;
100
86
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
101
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
87
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
102
88
  sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
103
- signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
104
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
105
- lowS?: boolean | undefined;
106
- } | undefined) => boolean;
107
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
108
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
89
+ verify: (signature: import("./abstract/utils.js").Hex | {
90
+ r: bigint;
91
+ s: bigint;
92
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
93
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
109
94
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
110
95
  utils: {
111
- _bigintToBytes: (num: bigint) => Uint8Array;
112
- _bigintToString: (num: bigint) => string;
113
96
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
114
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
115
- _isWithinCurveOrder: (num: bigint) => boolean;
116
- _isValidFieldElement: (num: bigint) => boolean;
117
- _weierstrassEquation: (x: bigint) => bigint;
118
97
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
119
98
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
120
99
  randomPrivateKey: () => Uint8Array;
121
100
  };
122
101
  }>;
102
+ declare const hashToCurve: (msg: import("./abstract/utils.js").Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>, encodeToCurve: (msg: import("./abstract/utils.js").Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>;
103
+ export { hashToCurve, encodeToCurve };
package/lib/p256.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.secp256r1 = exports.P256 = void 0;
3
+ exports.encodeToCurve = exports.hashToCurve = exports.secp256r1 = exports.P256 = void 0;
4
4
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
5
  const _shortw_utils_js_1 = require("./_shortw_utils.js");
6
6
  const sha256_1 = require("@noble/hashes/sha256");
7
7
  const modular_js_1 = require("./abstract/modular.js");
8
8
  const weierstrass_js_1 = require("./abstract/weierstrass.js");
9
+ const htf = require("./abstract/hash-to-curve.js");
9
10
  // NIST secp256r1 aka P256
10
11
  // https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-256
11
12
  // Field over which we'll do calculations; 2n**224n * (2n**32n-1n) + 2n**192n + 2n**96n-1n
@@ -29,14 +30,16 @@ exports.P256 = (0, _shortw_utils_js_1.createCurve)({
29
30
  Gy: BigInt('0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5'),
30
31
  h: BigInt(1),
31
32
  lowS: false,
32
- mapToCurve: (scalars) => mapSWU(scalars[0]),
33
- htfDefaults: {
34
- DST: 'P256_XMD:SHA-256_SSWU_RO_',
35
- p: Fp.ORDER,
36
- m: 1,
37
- k: 128,
38
- expand: 'xmd',
39
- hash: sha256_1.sha256,
40
- },
41
33
  }, sha256_1.sha256);
42
34
  exports.secp256r1 = exports.P256;
35
+ const { hashToCurve, encodeToCurve } = htf.hashToCurve(exports.secp256r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
36
+ DST: 'P256_XMD:SHA-256_SSWU_RO_',
37
+ encodeDST: 'P256_XMD:SHA-256_SSWU_NU_',
38
+ p: Fp.ORDER,
39
+ m: 1,
40
+ k: 128,
41
+ expand: 'xmd',
42
+ hash: sha256_1.sha256,
43
+ });
44
+ exports.hashToCurve = hashToCurve;
45
+ exports.encodeToCurve = encodeToCurve;
package/lib/p384.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as htf from './abstract/hash-to-curve.js';
1
2
  export declare const P384: Readonly<{
2
3
  create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn;
3
4
  CURVE: Readonly<{
@@ -9,11 +10,11 @@ export declare const P384: Readonly<{
9
10
  readonly hEff?: bigint | undefined;
10
11
  readonly Gx: bigint;
11
12
  readonly Gy: bigint;
12
- readonly wrapPrivateKey?: boolean | undefined;
13
13
  readonly allowInfinityPoint?: boolean | undefined;
14
14
  readonly a: bigint;
15
15
  readonly b: bigint;
16
- readonly normalizePrivateKey?: ((key: import("./abstract/utils.js").PrivKey) => import("./abstract/utils.js").PrivKey) | undefined;
16
+ readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
17
+ readonly wrapPrivateKey?: boolean | undefined;
17
18
  readonly endo?: {
18
19
  beta: bigint;
19
20
  splitScalar: (k: bigint) => {
@@ -23,37 +24,26 @@ export declare const P384: Readonly<{
23
24
  k2: bigint;
24
25
  };
25
26
  } | undefined;
26
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
27
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
28
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
29
- readonly mapToCurve?: ((scalar: bigint[]) => {
30
- x: bigint;
31
- y: bigint;
32
- }) | undefined;
33
- lowS: boolean;
27
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
28
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
34
29
  readonly hash: import("./abstract/utils.js").CHash;
35
30
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
36
31
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
37
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
32
+ lowS: boolean;
33
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
34
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
38
35
  }>;
39
36
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
40
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
37
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
41
38
  sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
42
- signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
43
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
44
- lowS?: boolean | undefined;
45
- } | undefined) => boolean;
46
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
47
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
39
+ verify: (signature: import("./abstract/utils.js").Hex | {
40
+ r: bigint;
41
+ s: bigint;
42
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
43
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
48
44
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
49
45
  utils: {
50
- _bigintToBytes: (num: bigint) => Uint8Array;
51
- _bigintToString: (num: bigint) => string;
52
46
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
53
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
54
- _isWithinCurveOrder: (num: bigint) => boolean;
55
- _isValidFieldElement: (num: bigint) => boolean;
56
- _weierstrassEquation: (x: bigint) => bigint;
57
47
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
58
48
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
59
49
  randomPrivateKey: () => Uint8Array;
@@ -70,11 +60,11 @@ export declare const secp384r1: Readonly<{
70
60
  readonly hEff?: bigint | undefined;
71
61
  readonly Gx: bigint;
72
62
  readonly Gy: bigint;
73
- readonly wrapPrivateKey?: boolean | undefined;
74
63
  readonly allowInfinityPoint?: boolean | undefined;
75
64
  readonly a: bigint;
76
65
  readonly b: bigint;
77
- readonly normalizePrivateKey?: ((key: import("./abstract/utils.js").PrivKey) => import("./abstract/utils.js").PrivKey) | undefined;
66
+ readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
67
+ readonly wrapPrivateKey?: boolean | undefined;
78
68
  readonly endo?: {
79
69
  beta: bigint;
80
70
  splitScalar: (k: bigint) => {
@@ -84,39 +74,30 @@ export declare const secp384r1: Readonly<{
84
74
  k2: bigint;
85
75
  };
86
76
  } | undefined;
87
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
88
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
89
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
90
- readonly mapToCurve?: ((scalar: bigint[]) => {
91
- x: bigint;
92
- y: bigint;
93
- }) | undefined;
94
- lowS: boolean;
77
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
78
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
95
79
  readonly hash: import("./abstract/utils.js").CHash;
96
80
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
97
81
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
98
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
82
+ lowS: boolean;
83
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
84
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
99
85
  }>;
100
86
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
101
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
87
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
102
88
  sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
103
- signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
104
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
105
- lowS?: boolean | undefined;
106
- } | undefined) => boolean;
107
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
108
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
89
+ verify: (signature: import("./abstract/utils.js").Hex | {
90
+ r: bigint;
91
+ s: bigint;
92
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
93
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
109
94
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
110
95
  utils: {
111
- _bigintToBytes: (num: bigint) => Uint8Array;
112
- _bigintToString: (num: bigint) => string;
113
96
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
114
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
115
- _isWithinCurveOrder: (num: bigint) => boolean;
116
- _isValidFieldElement: (num: bigint) => boolean;
117
- _weierstrassEquation: (x: bigint) => bigint;
118
97
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
119
98
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
120
99
  randomPrivateKey: () => Uint8Array;
121
100
  };
122
101
  }>;
102
+ declare const hashToCurve: (msg: import("./abstract/utils.js").Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>, encodeToCurve: (msg: import("./abstract/utils.js").Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>;
103
+ export { hashToCurve, encodeToCurve };