@noble/curves 2.0.1 → 2.2.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 (110) hide show
  1. package/README.md +214 -122
  2. package/abstract/bls.d.ts +299 -16
  3. package/abstract/bls.d.ts.map +1 -1
  4. package/abstract/bls.js +82 -22
  5. package/abstract/bls.js.map +1 -1
  6. package/abstract/curve.d.ts +274 -27
  7. package/abstract/curve.d.ts.map +1 -1
  8. package/abstract/curve.js +177 -23
  9. package/abstract/curve.js.map +1 -1
  10. package/abstract/edwards.d.ts +166 -30
  11. package/abstract/edwards.d.ts.map +1 -1
  12. package/abstract/edwards.js +221 -86
  13. package/abstract/edwards.js.map +1 -1
  14. package/abstract/fft.d.ts +322 -10
  15. package/abstract/fft.d.ts.map +1 -1
  16. package/abstract/fft.js +154 -12
  17. package/abstract/fft.js.map +1 -1
  18. package/abstract/frost.d.ts +293 -0
  19. package/abstract/frost.d.ts.map +1 -0
  20. package/abstract/frost.js +704 -0
  21. package/abstract/frost.js.map +1 -0
  22. package/abstract/hash-to-curve.d.ts +173 -24
  23. package/abstract/hash-to-curve.d.ts.map +1 -1
  24. package/abstract/hash-to-curve.js +170 -31
  25. package/abstract/hash-to-curve.js.map +1 -1
  26. package/abstract/modular.d.ts +429 -37
  27. package/abstract/modular.d.ts.map +1 -1
  28. package/abstract/modular.js +414 -119
  29. package/abstract/modular.js.map +1 -1
  30. package/abstract/montgomery.d.ts +83 -12
  31. package/abstract/montgomery.d.ts.map +1 -1
  32. package/abstract/montgomery.js +32 -7
  33. package/abstract/montgomery.js.map +1 -1
  34. package/abstract/oprf.d.ts +164 -91
  35. package/abstract/oprf.d.ts.map +1 -1
  36. package/abstract/oprf.js +88 -29
  37. package/abstract/oprf.js.map +1 -1
  38. package/abstract/poseidon.d.ts +138 -7
  39. package/abstract/poseidon.d.ts.map +1 -1
  40. package/abstract/poseidon.js +178 -15
  41. package/abstract/poseidon.js.map +1 -1
  42. package/abstract/tower.d.ts +122 -3
  43. package/abstract/tower.d.ts.map +1 -1
  44. package/abstract/tower.js +323 -139
  45. package/abstract/tower.js.map +1 -1
  46. package/abstract/weierstrass.d.ts +339 -76
  47. package/abstract/weierstrass.d.ts.map +1 -1
  48. package/abstract/weierstrass.js +395 -205
  49. package/abstract/weierstrass.js.map +1 -1
  50. package/bls12-381.d.ts +16 -2
  51. package/bls12-381.d.ts.map +1 -1
  52. package/bls12-381.js +199 -209
  53. package/bls12-381.js.map +1 -1
  54. package/bn254.d.ts +11 -2
  55. package/bn254.d.ts.map +1 -1
  56. package/bn254.js +93 -38
  57. package/bn254.js.map +1 -1
  58. package/ed25519.d.ts +125 -14
  59. package/ed25519.d.ts.map +1 -1
  60. package/ed25519.js +202 -40
  61. package/ed25519.js.map +1 -1
  62. package/ed448.d.ts +108 -14
  63. package/ed448.d.ts.map +1 -1
  64. package/ed448.js +194 -42
  65. package/ed448.js.map +1 -1
  66. package/index.js +7 -1
  67. package/index.js.map +1 -1
  68. package/misc.d.ts +106 -7
  69. package/misc.d.ts.map +1 -1
  70. package/misc.js +141 -32
  71. package/misc.js.map +1 -1
  72. package/nist.d.ts +112 -11
  73. package/nist.d.ts.map +1 -1
  74. package/nist.js +139 -17
  75. package/nist.js.map +1 -1
  76. package/package.json +11 -6
  77. package/secp256k1.d.ts +92 -15
  78. package/secp256k1.d.ts.map +1 -1
  79. package/secp256k1.js +211 -28
  80. package/secp256k1.js.map +1 -1
  81. package/src/abstract/bls.ts +350 -67
  82. package/src/abstract/curve.ts +327 -44
  83. package/src/abstract/edwards.ts +367 -143
  84. package/src/abstract/fft.ts +369 -36
  85. package/src/abstract/frost.ts +1092 -0
  86. package/src/abstract/hash-to-curve.ts +255 -56
  87. package/src/abstract/modular.ts +591 -144
  88. package/src/abstract/montgomery.ts +114 -30
  89. package/src/abstract/oprf.ts +383 -194
  90. package/src/abstract/poseidon.ts +235 -35
  91. package/src/abstract/tower.ts +428 -159
  92. package/src/abstract/weierstrass.ts +710 -312
  93. package/src/bls12-381.ts +239 -236
  94. package/src/bn254.ts +107 -46
  95. package/src/ed25519.ts +227 -55
  96. package/src/ed448.ts +227 -57
  97. package/src/index.ts +7 -1
  98. package/src/misc.ts +154 -35
  99. package/src/nist.ts +143 -20
  100. package/src/secp256k1.ts +284 -41
  101. package/src/utils.ts +583 -81
  102. package/src/webcrypto.ts +302 -73
  103. package/utils.d.ts +457 -24
  104. package/utils.d.ts.map +1 -1
  105. package/utils.js +410 -53
  106. package/utils.js.map +1 -1
  107. package/webcrypto.d.ts +167 -25
  108. package/webcrypto.d.ts.map +1 -1
  109. package/webcrypto.js +165 -58
  110. package/webcrypto.js.map +1 -1
package/nist.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"nist.d.ts","sourceRoot":"","sources":["src/nist.ts"],"names":[],"mappings":"AAOA,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAIL,KAAK,KAAK,EAEV,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAyEnC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,IAAI,EAAE,KAAiD,CAAC;AACrE,mEAAmE;AACnE,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAkB5D,CAAC;AACL,sCAAsC;AACtC,eAAO,MAAM,SAAS,EAAE,IAOjB,CAAC;AAIR,qGAAqG;AACrG,eAAO,MAAM,IAAI,EAAE,KAAiD,CAAC;AACrE,mEAAmE;AACnE,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAkB5D,CAAC;AACL,sCAAsC;AACtC,eAAO,MAAM,SAAS,EAAE,IAOjB,CAAC;AAKR,qGAAqG;AACrG,eAAO,MAAM,IAAI,EAAE,KAAiD,CAAC;AACrE,mEAAmE;AACn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S,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAkB5D,CAAC;AACL;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,EAAE,IAAI,CAAC,IAAI,CAO1B,CAAC"}
package/nist.js CHANGED
@@ -5,10 +5,11 @@
5
5
  */
6
6
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7
7
  import { sha256, sha384, sha512 } from '@noble/hashes/sha2.js';
8
+ import { createFROST } from "./abstract/frost.js";
8
9
  import { createHasher } from "./abstract/hash-to-curve.js";
9
- import { Field } from "./abstract/modular.js";
10
- import { createORPF } from "./abstract/oprf.js";
10
+ import { createOPRF } from "./abstract/oprf.js";
11
11
  import { ecdsa, mapToCurveSimpleSWU, weierstrass, } from "./abstract/weierstrass.js";
12
+ import {} from "./utils.js";
12
13
  // p = 2n**224n * (2n**32n-1n) + 2n**192n + 2n**96n - 1n
13
14
  // a = Fp256.create(BigInt('-3'));
14
15
  const p256_CURVE = /* @__PURE__ */ (() => ({
@@ -41,8 +42,11 @@ const p521_CURVE = /* @__PURE__ */ (() => ({
41
42
  Gy: BigInt('0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650'),
42
43
  }))();
43
44
  function createSWU(Point, opts) {
44
- const map = mapToCurveSimpleSWU(Point.Fp, opts);
45
- return (scalars) => map(scalars[0]);
45
+ let map;
46
+ // RFC 9380's NIST suites here all use m = 1, so createHasher passes one field element per map.
47
+ // Building the SWU sqrt-ratio helper eagerly adds noticeable `nist.js` import cost, so defer it
48
+ // to first use; after that the cached mapper is reused directly.
49
+ return (scalars) => (map || (map = mapToCurveSimpleSWU(Point.Fp, opts)))(scalars[0]);
46
50
  }
47
51
  // NIST P256
48
52
  const p256_Point = /* @__PURE__ */ weierstrass(p256_CURVE);
@@ -51,6 +55,8 @@ const p256_Point = /* @__PURE__ */ weierstrass(p256_CURVE);
51
55
  * Hashes inputs with sha256 by default.
52
56
  *
53
57
  * @example
58
+ * Generate one P-256 keypair, sign a message, and verify it.
59
+ *
54
60
  * ```js
55
61
  * import { p256 } from '@noble/curves/nist.js';
56
62
  * const { secretKey, publicKey } = p256.keygen();
@@ -62,7 +68,15 @@ const p256_Point = /* @__PURE__ */ weierstrass(p256_CURVE);
62
68
  * ```
63
69
  */
64
70
  export const p256 = /* @__PURE__ */ ecdsa(p256_Point, sha256);
65
- /** Hashing / encoding to p256 points / field. RFC 9380 methods. */
71
+ /**
72
+ * Hashing / encoding to p256 points / field. RFC 9380 methods.
73
+ * @example
74
+ * Hash one message onto the P-256 curve.
75
+ *
76
+ * ```ts
77
+ * const point = p256_hasher.hashToCurve(new TextEncoder().encode('hello noble'));
78
+ * ```
79
+ */
66
80
  export const p256_hasher = /* @__PURE__ */ (() => {
67
81
  return createHasher(p256_Point, createSWU(p256_Point, {
68
82
  A: p256_CURVE.a,
@@ -78,19 +92,68 @@ export const p256_hasher = /* @__PURE__ */ (() => {
78
92
  hash: sha256,
79
93
  });
80
94
  })();
81
- /** p256 OPRF, defined in RFC 9497. */
82
- export const p256_oprf = /* @__PURE__ */ (() => createORPF({
95
+ /**
96
+ * p256 OPRF, defined in RFC 9497.
97
+ * @example
98
+ * Run one blind/evaluate/finalize OPRF round over P-256.
99
+ *
100
+ * ```ts
101
+ * const input = new TextEncoder().encode('hello noble');
102
+ * const keys = p256_oprf.oprf.generateKeyPair();
103
+ * const blind = p256_oprf.oprf.blind(input);
104
+ * const evaluated = p256_oprf.oprf.blindEvaluate(keys.secretKey, blind.blinded);
105
+ * const output = p256_oprf.oprf.finalize(input, blind.blind, evaluated);
106
+ * ```
107
+ */
108
+ export const p256_oprf = /* @__PURE__ */ (() => createOPRF({
83
109
  name: 'P256-SHA256',
84
110
  Point: p256_Point,
85
111
  hash: sha256,
86
112
  hashToGroup: p256_hasher.hashToCurve,
87
113
  hashToScalar: p256_hasher.hashToScalar,
88
114
  }))();
115
+ /**
116
+ * FROST threshold signatures over p256. RFC 9591.
117
+ * @example
118
+ * Create one trusted-dealer package for 2-of-3 p256 signing.
119
+ *
120
+ * ```ts
121
+ * const alice = p256_FROST.Identifier.derive('alice@example.com');
122
+ * const bob = p256_FROST.Identifier.derive('bob@example.com');
123
+ * const carol = p256_FROST.Identifier.derive('carol@example.com');
124
+ * const deal = p256_FROST.trustedDealer({ min: 2, max: 3 }, [alice, bob, carol]);
125
+ * ```
126
+ */
127
+ export const p256_FROST = /* @__PURE__ */ (() => createFROST({
128
+ name: 'FROST-P256-SHA256-v1',
129
+ Point: p256_Point,
130
+ hashToScalar: p256_hasher.hashToScalar,
131
+ hash: sha256,
132
+ }))();
89
133
  // NIST P384
90
134
  const p384_Point = /* @__PURE__ */ weierstrass(p384_CURVE);
91
- /** NIST P384 (aka secp384r1) curve, ECDSA and ECDH methods. Hashes inputs with sha384 by default. */
135
+ /**
136
+ * NIST P384 (aka secp384r1) curve, ECDSA and ECDH methods. Hashes inputs with sha384 by default.
137
+ * @example
138
+ * Generate one P-384 keypair, sign a message, and verify it.
139
+ *
140
+ * ```ts
141
+ * const { secretKey, publicKey } = p384.keygen();
142
+ * const msg = new TextEncoder().encode('hello noble');
143
+ * const sig = p384.sign(msg, secretKey);
144
+ * const isValid = p384.verify(sig, msg, publicKey);
145
+ * ```
146
+ */
92
147
  export const p384 = /* @__PURE__ */ ecdsa(p384_Point, sha384);
93
- /** Hashing / encoding to p384 points / field. RFC 9380 methods. */
148
+ /**
149
+ * Hashing / encoding to p384 points / field. RFC 9380 methods.
150
+ * @example
151
+ * Hash one message onto the P-384 curve.
152
+ *
153
+ * ```ts
154
+ * const point = p384_hasher.hashToCurve(new TextEncoder().encode('hello noble'));
155
+ * ```
156
+ */
94
157
  export const p384_hasher = /* @__PURE__ */ (() => {
95
158
  return createHasher(p384_Point, createSWU(p384_Point, {
96
159
  A: p384_CURVE.a,
@@ -106,8 +169,20 @@ export const p384_hasher = /* @__PURE__ */ (() => {
106
169
  hash: sha384,
107
170
  });
108
171
  })();
109
- /** p384 OPRF, defined in RFC 9497. */
110
- export const p384_oprf = /* @__PURE__ */ (() => createORPF({
172
+ /**
173
+ * p384 OPRF, defined in RFC 9497.
174
+ * @example
175
+ * Run one blind/evaluate/finalize OPRF round over P-384.
176
+ *
177
+ * ```ts
178
+ * const input = new TextEncoder().encode('hello noble');
179
+ * const keys = p384_oprf.oprf.generateKeyPair();
180
+ * const blind = p384_oprf.oprf.blind(input);
181
+ * const evaluated = p384_oprf.oprf.blindEvaluate(keys.secretKey, blind.blinded);
182
+ * const output = p384_oprf.oprf.finalize(input, blind.blind, evaluated);
183
+ * ```
184
+ */
185
+ export const p384_oprf = /* @__PURE__ */ (() => createOPRF({
111
186
  name: 'P384-SHA384',
112
187
  Point: p384_Point,
113
188
  hash: sha384,
@@ -115,11 +190,46 @@ export const p384_oprf = /* @__PURE__ */ (() => createORPF({
115
190
  hashToScalar: p384_hasher.hashToScalar,
116
191
  }))();
117
192
  // NIST P521
118
- const Fn521 = /* @__PURE__ */ (() => Field(p521_CURVE.n, { allowedLengths: [65, 66] }))();
119
- const p521_Point = /* @__PURE__ */ weierstrass(p521_CURVE, { Fn: Fn521 });
120
- /** NIST P521 (aka secp521r1) curve, ECDSA and ECDH methods. Hashes inputs with sha512 by default. */
193
+ // RFC 7518 fixes the canonical JWK/JOSE width at 66 bytes:
194
+ // - Section 3.4 says ECDSA octet strings must not omit leading zero octets
195
+ // - Sections 6.2.1.2/6.2.1.3 say P-521 coordinates "x"/"y" must be 66 octets
196
+ // - Section 6.2.2.1 says private scalar "d" must be ceil(log2(n)/8) octets, i.e. 66 for P-521
197
+ // NIST FIPS 186-5 Appendix A.3.3 also routes deterministic ECDSA private keys through Appendix
198
+ // B.2.3, whose Integer-to-Octet-String output has explicit fixed length L; for P-521 that is the
199
+ // same 66-byte order width.
200
+ // RFC 6979 matches that width too: private key x is an integer, while `int2octets(x)` uses
201
+ // rlen = 8 * ceil(qlen/8); for P-521, qlen = 521 so the canonical octet width is 66 bytes.
202
+ // Wycheproof ECDH stores private values as integers, not fixed-width scalar bytes, so it does not
203
+ // require a dedicated 65-byte parser path; the repo tests now normalize those integer fixtures to
204
+ // the canonical 66-byte width before use. There is no good standards or oracle reason to accept
205
+ // exactly 65 bytes here: the coherent choices are canonical 66 only, or a broader integer-style
206
+ // parser across many widths. Since this field parser is fixed-width, keep it canonical and use the
207
+ // default exact-66-byte scalar field path.
208
+ const p521_Point = /* @__PURE__ */ weierstrass(p521_CURVE);
209
+ /**
210
+ * NIST P521 (aka secp521r1) curve, ECDSA and ECDH methods. Hashes inputs with sha512 by default.
211
+ * Deterministic `keygen(seed)` expects 99 seed bytes here because the generic scalar-derivation
212
+ * helper uses `getMinHashLength(n)`, not the 66-byte canonical secret-key width.
213
+ * @example
214
+ * Generate one P-521 keypair, sign a message, and verify it.
215
+ *
216
+ * ```ts
217
+ * const { secretKey, publicKey } = p521.keygen();
218
+ * const msg = new TextEncoder().encode('hello noble');
219
+ * const sig = p521.sign(msg, secretKey);
220
+ * const isValid = p521.verify(sig, msg, publicKey);
221
+ * ```
222
+ */
121
223
  export const p521 = /* @__PURE__ */ ecdsa(p521_Point, sha512);
122
- /** Hashing / encoding to p521 points / field. RFC 9380 methods. */
224
+ /**
225
+ * Hashing / encoding to p521 points / field. RFC 9380 methods.
226
+ * @example
227
+ * Hash one message onto the P-521 curve.
228
+ *
229
+ * ```ts
230
+ * const point = p521_hasher.hashToCurve(new TextEncoder().encode('hello noble'));
231
+ * ```
232
+ */
123
233
  export const p521_hasher = /* @__PURE__ */ (() => {
124
234
  return createHasher(p521_Point, createSWU(p521_Point, {
125
235
  A: p521_CURVE.a,
@@ -135,8 +245,20 @@ export const p521_hasher = /* @__PURE__ */ (() => {
135
245
  hash: sha512,
136
246
  });
137
247
  })();
138
- /** p521 OPRF, defined in RFC 9497. */
139
- export const p521_oprf = /* @__PURE__ */ (() => createORPF({
248
+ /**
249
+ * p521 OPRF, defined in RFC 9497.
250
+ * @example
251
+ * Run one blind/evaluate/finalize OPRF round over P-521.
252
+ *
253
+ * ```ts
254
+ * const input = new TextEncoder().encode('hello noble');
255
+ * const keys = p521_oprf.oprf.generateKeyPair();
256
+ * const blind = p521_oprf.oprf.blind(input);
257
+ * const evaluated = p521_oprf.oprf.blindEvaluate(keys.secretKey, blind.blinded);
258
+ * const output = p521_oprf.oprf.finalize(input, blind.blind, evaluated);
259
+ * ```
260
+ */
261
+ export const p521_oprf = /* @__PURE__ */ (() => createOPRF({
140
262
  name: 'P521-SHA512',
141
263
  Point: p521_Point,
142
264
  hash: sha512,
package/nist.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"nist.js","sourceRoot":"","sources":["src/nist.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,sEAAsE;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAkB,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAa,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,KAAK,EACL,mBAAmB,EACnB,WAAW,GAIZ,MAAM,2BAA2B,CAAC;AAEnC,wDAAwD;AACxD,kCAAkC;AAClC,MAAM,UAAU,GAA4B,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAClE,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,EAAE,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAChF,EAAE,EAAE,MAAM,CAAC,oEAAoE,CAAC;CACjF,CAAC,CAAC,EAAE,CAAC;AAEN,mDAAmD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version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "description": "Audited & minimal JS implementation of elliptic curve cryptography",
5
5
  "files": [
6
6
  "*.js",
@@ -11,23 +11,27 @@
11
11
  "src"
12
12
  ],
13
13
  "dependencies": {
14
- "@noble/hashes": "2.0.1"
14
+ "@noble/hashes": "2.2.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@paulmillr/jsbt": "0.4.4",
18
- "@types/node": "24.2.1",
17
+ "@paulmillr/jsbt": "0.5.0",
18
+ "@types/node": "25.3.0",
19
19
  "fast-check": "4.2.0",
20
20
  "prettier": "3.6.2",
21
- "typescript": "5.9.2"
21
+ "typescript": "6.0.2"
22
22
  },
23
23
  "scripts": {
24
24
  "bench": "cd test/benchmark; node secp256k1.ts; node curves.ts; node utils.ts; node bls.ts",
25
25
  "bench:install": "cd test/benchmark; npm install; npm install ../.. --install-links",
26
26
  "build": "tsc",
27
27
  "build:release": "npx --no @paulmillr/jsbt esbuild test/build",
28
+ "check": "npm run check:readme && npm run check:treeshake && npm run check:jsdoc",
29
+ "check:readme": "npx --no @paulmillr/jsbt readme package.json",
30
+ "check:treeshake": "npx --no @paulmillr/jsbt treeshake package.json test/build/out-treeshake",
31
+ "check:jsdoc": "npx --no @paulmillr/jsbt tsdoc package.json",
28
32
  "build:clean": "rm {.,abstract}/*.{js,d.ts,d.ts.map,js.map} 2> /dev/null",
29
33
  "format": "prettier --write 'src/**/*.{js,ts}' 'test/*.{js,ts}'",
30
- "test": "node --experimental-strip-types --disable-warning=ExperimentalWarning test/index.ts",
34
+ "test": "node test/index.ts",
31
35
  "test:bun": "bun test/index.ts",
32
36
  "test:deno": "deno --allow-env --allow-read test/index.ts",
33
37
  "test:node20": "cd test; npx tsc; node compiled/test/index.js",
@@ -39,6 +43,7 @@
39
43
  "./abstract/curve.js": "./abstract/curve.js",
40
44
  "./abstract/edwards.js": "./abstract/edwards.js",
41
45
  "./abstract/fft.js": "./abstract/fft.js",
46
+ "./abstract/frost.js": "./abstract/frost.js",
42
47
  "./abstract/hash-to-curve.js": "./abstract/hash-to-curve.js",
43
48
  "./abstract/modular.js": "./abstract/modular.js",
44
49
  "./abstract/montgomery.js": "./abstract/montgomery.js",
package/secp256k1.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { type CurveLengths } from './abstract/curve.ts';
2
+ import { type FROST } from './abstract/frost.ts';
2
3
  import { type H2CHasher } from './abstract/hash-to-curve.ts';
3
4
  import { type ECDSA, type WeierstrassPoint as PointType, type WeierstrassPointCons } from './abstract/weierstrass.ts';
5
+ import { type TArg, type TRet } from './utils.ts';
4
6
  /**
5
7
  * secp256k1 curve: ECDSA and ECDH methods.
6
8
  *
@@ -8,6 +10,8 @@ import { type ECDSA, type WeierstrassPoint as PointType, type WeierstrassPointCo
8
10
  * pass `{ prehash: false }` to sign / verify.
9
11
  *
10
12
  * @example
13
+ * Generate one secp256k1 keypair, sign a message, and verify it.
14
+ *
11
15
  * ```js
12
16
  * import { secp256k1 } from '@noble/curves/secp256k1.js';
13
17
  * const { secretKey, publicKey } = secp256k1.keygen();
@@ -19,47 +23,84 @@ import { type ECDSA, type WeierstrassPoint as PointType, type WeierstrassPointCo
19
23
  * ```
20
24
  */
21
25
  export declare const secp256k1: ECDSA;
22
- declare function taggedHash(tag: string, ...messages: Uint8Array[]): Uint8Array;
26
+ declare function taggedHash(tag: string, ...messages: TArg<Uint8Array[]>): TRet<Uint8Array>;
23
27
  /**
24
28
  * lift_x from BIP340. Convert 32-byte x coordinate to elliptic curve point.
25
29
  * @returns valid point checked for being on-curve
26
30
  */
27
31
  declare function lift_x(x: bigint): PointType<bigint>;
28
- /**
29
- * Schnorr public key is just `x` coordinate of Point as per BIP340.
30
- */
31
- declare function schnorrGetPublicKey(secretKey: Uint8Array): Uint8Array;
32
+ /** Schnorr public key is just `x` coordinate of Point as per BIP340. */
33
+ declare function schnorrGetPublicKey(secretKey: TArg<Uint8Array>): TRet<Uint8Array>;
32
34
  /**
33
35
  * Creates Schnorr signature as per BIP340. Verifies itself before returning anything.
34
- * auxRand is optional and is not the sole source of k generation: bad CSPRNG won't be dangerous.
36
+ * `auxRand` is optional and is not the sole source of `k` generation: bad CSPRNG output will not
37
+ * be catastrophic, but BIP-340 still recommends fresh auxiliary randomness when available to harden
38
+ * deterministic signing against side-channel and fault-injection attacks.
35
39
  */
36
- declare function schnorrSign(message: Uint8Array, secretKey: Uint8Array, auxRand?: Uint8Array): Uint8Array;
40
+ declare function schnorrSign(message: TArg<Uint8Array>, secretKey: TArg<Uint8Array>, auxRand?: TArg<Uint8Array>): TRet<Uint8Array>;
37
41
  /**
38
42
  * Verifies Schnorr signature.
39
43
  * Will swallow errors & return false except for initial type validation of arguments.
40
44
  */
41
- declare function schnorrVerify(signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean;
45
+ declare function schnorrVerify(signature: TArg<Uint8Array>, message: TArg<Uint8Array>, publicKey: TArg<Uint8Array>): boolean;
46
+ export declare const __TEST: {
47
+ lift_x: typeof lift_x;
48
+ };
49
+ /** Schnorr-specific secp256k1 API from BIP340. */
42
50
  export type SecpSchnorr = {
43
- keygen: (seed?: Uint8Array) => {
44
- secretKey: Uint8Array;
45
- publicKey: Uint8Array;
51
+ /**
52
+ * Generate one Schnorr secret/public keypair.
53
+ * @param seed - Optional seed for deterministic testing or custom randomness.
54
+ * @returns Fresh secret/public keypair.
55
+ */
56
+ keygen: (seed?: TArg<Uint8Array>) => {
57
+ secretKey: TRet<Uint8Array>;
58
+ publicKey: TRet<Uint8Array>;
46
59
  };
60
+ /**
61
+ * Derive the x-only public key from a secret key.
62
+ * @param secretKey - Secret key bytes.
63
+ * @returns X-only public key bytes.
64
+ */
47
65
  getPublicKey: typeof schnorrGetPublicKey;
66
+ /**
67
+ * Create one BIP340 Schnorr signature.
68
+ * @param message - Message bytes to sign.
69
+ * @param secretKey - Secret key bytes.
70
+ * @param auxRand - Optional auxiliary randomness.
71
+ * @returns Compact Schnorr signature bytes.
72
+ */
48
73
  sign: typeof schnorrSign;
74
+ /**
75
+ * Verify one BIP340 Schnorr signature.
76
+ * @param signature - Compact signature bytes.
77
+ * @param message - Signed message bytes.
78
+ * @param publicKey - X-only public key bytes.
79
+ * @returns `true` when the signature is valid.
80
+ */
49
81
  verify: typeof schnorrVerify;
82
+ /** Underlying secp256k1 point constructor. */
50
83
  Point: WeierstrassPointCons<bigint>;
84
+ /** Helper utilities for Schnorr-specific key handling and tagged hashing. */
51
85
  utils: {
52
- randomSecretKey: (seed?: Uint8Array) => Uint8Array;
53
- pointToBytes: (point: PointType<bigint>) => Uint8Array;
86
+ /** Generate one Schnorr secret key. */
87
+ randomSecretKey: (seed?: TArg<Uint8Array>) => TRet<Uint8Array>;
88
+ /** Convert one point into its x-only BIP340 byte encoding. */
89
+ pointToBytes: (point: TArg<PointType<bigint>>) => TRet<Uint8Array>;
90
+ /** Lift one x coordinate into the unique even-Y point. */
54
91
  lift_x: typeof lift_x;
92
+ /** Compute a BIP340 tagged hash. */
55
93
  taggedHash: typeof taggedHash;
56
94
  };
95
+ /** Public byte lengths for keys, signatures, and seeds. */
57
96
  lengths: CurveLengths;
58
97
  };
59
98
  /**
60
99
  * Schnorr signatures over secp256k1.
61
- * https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
100
+ * See {@link https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki | BIP 340}.
62
101
  * @example
102
+ * Generate one BIP340 Schnorr keypair, sign a message, and verify it.
103
+ *
63
104
  * ```js
64
105
  * import { schnorr } from '@noble/curves/secp256k1.js';
65
106
  * const { secretKey, publicKey } = schnorr.keygen();
@@ -70,7 +111,43 @@ export type SecpSchnorr = {
70
111
  * ```
71
112
  */
72
113
  export declare const schnorr: SecpSchnorr;
73
- /** Hashing / encoding to secp256k1 points / field. RFC 9380 methods. */
114
+ /**
115
+ * Hashing / encoding to secp256k1 points / field. RFC 9380 methods.
116
+ * @example
117
+ * Hash one message onto secp256k1.
118
+ *
119
+ * ```ts
120
+ * const point = secp256k1_hasher.hashToCurve(new TextEncoder().encode('hello noble'));
121
+ * ```
122
+ */
74
123
  export declare const secp256k1_hasher: H2CHasher<WeierstrassPointCons<bigint>>;
124
+ /**
125
+ * FROST threshold signatures over secp256k1. RFC 9591.
126
+ * @example
127
+ * Create one trusted-dealer package for 2-of-3 secp256k1 signing.
128
+ *
129
+ * ```ts
130
+ * const alice = secp256k1_FROST.Identifier.derive('alice@example.com');
131
+ * const bob = secp256k1_FROST.Identifier.derive('bob@example.com');
132
+ * const carol = secp256k1_FROST.Identifier.derive('carol@example.com');
133
+ * const deal = secp256k1_FROST.trustedDealer({ min: 2, max: 3 }, [alice, bob, carol]);
134
+ * ```
135
+ */
136
+ export declare const secp256k1_FROST: TRet<FROST>;
137
+ /**
138
+ * FROST threshold signatures over secp256k1-schnorr-taproot. RFC 9591.
139
+ * DKG outputs are auto-tweaked with the empty Taproot merkle root for compatibility, while
140
+ * `trustedDealer()` outputs stay untweaked unless callers apply the Taproot tweak themselves.
141
+ * @example
142
+ * Create one trusted-dealer package for Taproot-compatible FROST signing.
143
+ *
144
+ * ```ts
145
+ * const alice = schnorr_FROST.Identifier.derive('alice@example.com');
146
+ * const bob = schnorr_FROST.Identifier.derive('bob@example.com');
147
+ * const carol = schnorr_FROST.Identifier.derive('carol@example.com');
148
+ * const deal = schnorr_FROST.trustedDealer({ min: 2, max: 3 }, [alice, bob, carol]);
149
+ * ```
150
+ */
151
+ export declare const schnorr_FROST: TRet<FROST>;
75
152
  export {};
76
153
  //# sourceMappingURL=secp256k1.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"secp256k1.d.ts","sourceRoot":"","sources":["src/secp256k1.ts"],"names":[],"mappings":"AAUA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAgB,KAAK,SAAS,EAAc,MAAM,6BAA6B,CAAC;AAEvF,OAAO,EACL,KAAK,KAAK,EAIV,KAAK,gBAAgB,IAAI,SAAS,EAGlC,KAAK,oBAAoB,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