@theqrl/mldsa87 1.1.1 → 2.0.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.
package/README.md CHANGED
@@ -26,12 +26,13 @@ const pk = new Uint8Array(CryptoPublicKeyBytes); // 2592 bytes
26
26
  const sk = new Uint8Array(CryptoSecretKeyBytes); // 4896 bytes
27
27
  cryptoSignKeypair(null, pk, sk); // null = random seed
28
28
 
29
- // Sign a message (uses default "ZOND" context)
29
+ // Sign a message
30
30
  const message = new TextEncoder().encode('Hello, quantum world!');
31
- const signedMessage = cryptoSign(message, sk, false); // false = deterministic
31
+ const ctx = new Uint8Array([0x5a, 0x4f, 0x4e, 0x44]); // "ZOND"
32
+ const signedMessage = cryptoSign(message, sk, false, ctx); // false = deterministic
32
33
 
33
- // Verify and extract
34
- const extracted = cryptoSignOpen(signedMessage, pk);
34
+ // Verify and extract (context must match)
35
+ const extracted = cryptoSignOpen(signedMessage, pk, ctx);
35
36
  if (extracted === undefined) {
36
37
  throw new Error('Invalid signature');
37
38
  }
@@ -40,20 +41,21 @@ console.log(new TextDecoder().decode(extracted)); // "Hello, quantum world!"
40
41
 
41
42
  ## Context Parameter
42
43
 
43
- ML-DSA-87 supports a context parameter for domain separation (FIPS 204 feature). This allows the same keypair to be used safely across different applications.
44
+ ML-DSA-87 requires a context parameter for domain separation (FIPS 204 feature). This allows the same keypair to be used safely across different applications.
44
45
 
45
46
  ```javascript
46
- // With custom context
47
+ // With application-specific context
47
48
  const ctx = new TextEncoder().encode('my-app-v1');
48
49
  const signed = cryptoSign(message, sk, false, ctx);
49
50
  const extracted = cryptoSignOpen(signed, pk, ctx);
50
51
 
51
52
  // Context must match for verification
52
- cryptoSignOpen(signed, pk); // undefined - wrong context (default "ZOND")
53
- cryptoSignOpen(signed, pk, ctx); // message - correct context
53
+ const wrongCtx = new Uint8Array(0);
54
+ cryptoSignOpen(signed, pk, wrongCtx); // undefined - wrong context
55
+ cryptoSignOpen(signed, pk, ctx); // message - correct context
54
56
  ```
55
57
 
56
- The default context is `"ZOND"` (for QRL Zond network compatibility). Context can be 0-255 bytes.
58
+ Context is a required `Uint8Array` and can be 0-255 bytes. Use an empty `Uint8Array(0)` if no domain separation is needed.
57
59
 
58
60
  ## API
59
61
 
@@ -77,26 +79,26 @@ Generate a keypair from a seed.
77
79
  - `sk`: `Uint8Array(4896)` - output buffer for secret key
78
80
  - Returns: The seed used (useful when `seed` is `null`)
79
81
 
80
- #### `cryptoSign(message, sk, randomized, context?)`
82
+ #### `cryptoSign(message, sk, randomized, context)`
81
83
 
82
84
  Sign a message (combined mode: returns signature || message).
83
85
 
84
86
  - `message`: `Uint8Array` or `string` - message bytes; if `string`, it must be hex only (optional `0x`, even length). Plain-text strings are not accepted.
85
87
  - `sk`: `Uint8Array(4896)` - secret key
86
88
  - `randomized`: `boolean` - `true` for hedged signing, `false` for deterministic
87
- - `context`: `Uint8Array` (optional) - context string, 0-255 bytes. Default: `"ZOND"`
89
+ - `context`: `Uint8Array` - context string for domain separation, 0-255 bytes
88
90
  - Returns: `Uint8Array` containing signature + message
89
91
 
90
- #### `cryptoSignOpen(signedMessage, pk, context?)`
92
+ #### `cryptoSignOpen(signedMessage, pk, context)`
91
93
 
92
94
  Verify and extract message from signed message.
93
95
 
94
96
  - `signedMessage`: `Uint8Array` - output from `cryptoSign()`
95
97
  - `pk`: `Uint8Array(2592)` - public key
96
- - `context`: `Uint8Array` (optional) - must match signing context
98
+ - `context`: `Uint8Array` - must match signing context
97
99
  - Returns: Original message if valid, `undefined` if verification fails
98
100
 
99
- #### `cryptoSignSignature(sig, message, sk, randomized, context?)`
101
+ #### `cryptoSignSignature(sig, message, sk, randomized, context)`
100
102
 
101
103
  Create a detached signature.
102
104
 
@@ -104,17 +106,17 @@ Create a detached signature.
104
106
  - `message`: `Uint8Array` or `string` - message bytes; if `string`, it must be hex only (optional `0x`, even length). Plain-text strings are not accepted.
105
107
  - `sk`: `Uint8Array(4896)` - secret key
106
108
  - `randomized`: `boolean` - `true` for hedged, `false` for deterministic
107
- - `context`: `Uint8Array` (optional) - context string, 0-255 bytes
109
+ - `context`: `Uint8Array` - context string for domain separation, 0-255 bytes
108
110
  - Returns: `0` on success
109
111
 
110
- #### `cryptoSignVerify(sig, message, pk, context?)`
112
+ #### `cryptoSignVerify(sig, message, pk, context)`
111
113
 
112
114
  Verify a detached signature.
113
115
 
114
116
  - `sig`: `Uint8Array(4627)` - signature to verify
115
117
  - `message`: `Uint8Array` or `string` - original message bytes; if `string`, it must be hex only (optional `0x`, even length). Plain-text strings are not accepted.
116
118
  - `pk`: `Uint8Array(2592)` - public key
117
- - `context`: `Uint8Array` (optional) - must match signing context
119
+ - `context`: `Uint8Array` - must match signing context
118
120
  - Returns: `true` if valid, `false` otherwise
119
121
 
120
122
  **Note:** To sign or verify plain text, convert it to bytes (e.g., `new TextEncoder().encode('Hello')`). String inputs are interpreted as hex only.
@@ -553,7 +553,7 @@ function cAddQ(a) {
553
553
 
554
554
  function ntt(a) {
555
555
  let k = 0;
556
- let j = 0;
556
+ let j;
557
557
 
558
558
  for (let len = 128; len > 0; len >>= 1) {
559
559
  for (let start = 0; start < N; start = j + len) {
@@ -569,7 +569,7 @@ function ntt(a) {
569
569
 
570
570
  function invNTTToMont(a) {
571
571
  const f = 41978n; // mont^2/256
572
- let j = 0;
572
+ let j;
573
573
  let k = 256;
574
574
 
575
575
  for (let len = 1; len < N; len <<= 1) {
@@ -1486,13 +1486,6 @@ function isZero(buffer) {
1486
1486
  return acc === 0;
1487
1487
  }
1488
1488
 
1489
- /**
1490
- * Default signing context ("ZOND" in ASCII).
1491
- * Used for domain separation per FIPS 204.
1492
- * @constant {Uint8Array}
1493
- */
1494
- const DEFAULT_CTX = new Uint8Array([0x5a, 0x4f, 0x4e, 0x44]); // "ZOND"
1495
-
1496
1489
  /**
1497
1490
  * Convert hex string to Uint8Array with strict validation.
1498
1491
  *
@@ -1566,9 +1559,9 @@ function cryptoSignKeypair(passedSeed, pk, sk) {
1566
1559
  }
1567
1560
  } catch (e) {
1568
1561
  if (e instanceof TypeError) {
1569
- throw new Error(`pk/sk cannot be null`);
1562
+ throw new Error(`pk/sk cannot be null`, { cause: e });
1570
1563
  } else {
1571
- throw new Error(`${e.message}`);
1564
+ throw new Error(`${e.message}`, { cause: e });
1572
1565
  }
1573
1566
  }
1574
1567
 
@@ -1647,21 +1640,22 @@ function cryptoSignKeypair(passedSeed, pk, sk) {
1647
1640
  * @param {Uint8Array} sk - Secret key (must be CryptoSecretKeyBytes = 4896 bytes)
1648
1641
  * @param {boolean} randomizedSigning - If true, use random nonce for hedged signing.
1649
1642
  * If false, use deterministic nonce derived from message and key.
1650
- * @param {Uint8Array} [ctx=DEFAULT_CTX] - Context string for domain separation (max 255 bytes).
1651
- * Defaults to "ZOND" for QRL compatibility.
1643
+ * @param {Uint8Array} ctx - Context string for domain separation (max 255 bytes).
1652
1644
  * @returns {number} 0 on success
1653
- * @throws {Error} If sk is wrong size or context exceeds 255 bytes
1645
+ * @throws {Error} If ctx is missing, sk is wrong size, or context exceeds 255 bytes
1654
1646
  *
1655
1647
  * @example
1656
1648
  * const sig = new Uint8Array(CryptoBytes);
1657
- * cryptoSignSignature(sig, message, sk, false);
1658
- * // Or with custom context:
1659
- * cryptoSignSignature(sig, message, sk, false, new Uint8Array([0x01, 0x02]));
1649
+ * const ctx = new Uint8Array([0x01, 0x02]);
1650
+ * cryptoSignSignature(sig, message, sk, false, ctx);
1660
1651
  */
1661
- function cryptoSignSignature(sig, m, sk, randomizedSigning, ctx = DEFAULT_CTX) {
1652
+ function cryptoSignSignature(sig, m, sk, randomizedSigning, ctx) {
1662
1653
  if (!sig || sig.length < CryptoBytes) {
1663
1654
  throw new Error(`sig must be at least ${CryptoBytes} bytes`);
1664
1655
  }
1656
+ if (!(ctx instanceof Uint8Array)) {
1657
+ throw new TypeError('ctx is required and must be a Uint8Array');
1658
+ }
1665
1659
  if (ctx.length > 255) throw new Error(`invalid context length: ${ctx.length} (max 255)`);
1666
1660
  if (sk.length !== CryptoSecretKeyBytes) {
1667
1661
  throw new Error(`invalid sk length ${sk.length} | Expected length ${CryptoSecretKeyBytes}`);
@@ -1788,16 +1782,18 @@ function cryptoSignSignature(sig, m, sk, randomizedSigning, ctx = DEFAULT_CTX) {
1788
1782
  * @param {string|Uint8Array} msg - Message to sign (hex string, optional 0x prefix, or Uint8Array)
1789
1783
  * @param {Uint8Array} sk - Secret key (must be CryptoSecretKeyBytes = 4896 bytes)
1790
1784
  * @param {boolean} randomizedSigning - If true, use random nonce; if false, deterministic
1791
- * @param {Uint8Array} [ctx=DEFAULT_CTX] - Context string for domain separation (max 255 bytes).
1792
- * Defaults to "ZOND" for QRL compatibility.
1785
+ * @param {Uint8Array} ctx - Context string for domain separation (max 255 bytes).
1793
1786
  * @returns {Uint8Array} Signed message (CryptoBytes + msg.length bytes)
1794
1787
  * @throws {Error} If signing fails
1795
1788
  *
1796
1789
  * @example
1797
- * const signedMsg = cryptoSign(message, sk, false);
1790
+ * const signedMsg = cryptoSign(message, sk, false, ctx);
1798
1791
  * // signedMsg contains: signature (4627 bytes) || message
1799
1792
  */
1800
- function cryptoSign(msg, sk, randomizedSigning, ctx = DEFAULT_CTX) {
1793
+ function cryptoSign(msg, sk, randomizedSigning, ctx) {
1794
+ if (!(ctx instanceof Uint8Array)) {
1795
+ throw new TypeError('ctx is required and must be a Uint8Array');
1796
+ }
1801
1797
  const msgBytes = messageToBytes(msg);
1802
1798
 
1803
1799
  const sm = new Uint8Array(CryptoBytes + msgBytes.length);
@@ -1824,17 +1820,19 @@ function cryptoSign(msg, sk, randomizedSigning, ctx = DEFAULT_CTX) {
1824
1820
  * @param {Uint8Array} sig - Signature to verify (must be CryptoBytes = 4627 bytes)
1825
1821
  * @param {string|Uint8Array} m - Message that was signed (hex string, optional 0x prefix, or Uint8Array)
1826
1822
  * @param {Uint8Array} pk - Public key (must be CryptoPublicKeyBytes = 2592 bytes)
1827
- * @param {Uint8Array} [ctx=DEFAULT_CTX] - Context string used during signing (max 255 bytes).
1828
- * Defaults to "ZOND" for QRL compatibility.
1823
+ * @param {Uint8Array} ctx - Context string used during signing (max 255 bytes).
1829
1824
  * @returns {boolean} true if signature is valid, false otherwise
1830
1825
  *
1831
1826
  * @example
1832
- * const isValid = cryptoSignVerify(signature, message, pk);
1827
+ * const isValid = cryptoSignVerify(signature, message, pk, ctx);
1833
1828
  * if (!isValid) {
1834
1829
  * throw new Error('Invalid signature');
1835
1830
  * }
1836
1831
  */
1837
- function cryptoSignVerify(sig, m, pk, ctx = DEFAULT_CTX) {
1832
+ function cryptoSignVerify(sig, m, pk, ctx) {
1833
+ if (!(ctx instanceof Uint8Array)) {
1834
+ throw new TypeError('ctx is required and must be a Uint8Array');
1835
+ }
1838
1836
  if (ctx.length > 255) return false;
1839
1837
  let i;
1840
1838
  const buf = new Uint8Array(K * PolyW1PackedBytes);
@@ -1922,17 +1920,19 @@ function cryptoSignVerify(sig, m, pk, ctx = DEFAULT_CTX) {
1922
1920
  *
1923
1921
  * @param {Uint8Array} sm - Signed message (signature || message)
1924
1922
  * @param {Uint8Array} pk - Public key (must be CryptoPublicKeyBytes = 2592 bytes)
1925
- * @param {Uint8Array} [ctx=DEFAULT_CTX] - Context string used during signing (max 255 bytes).
1926
- * Defaults to "ZOND" for QRL compatibility.
1923
+ * @param {Uint8Array} ctx - Context string used during signing (max 255 bytes).
1927
1924
  * @returns {Uint8Array|undefined} The original message if valid, undefined if verification fails
1928
1925
  *
1929
1926
  * @example
1930
- * const message = cryptoSignOpen(signedMsg, pk);
1927
+ * const message = cryptoSignOpen(signedMsg, pk, ctx);
1931
1928
  * if (message === undefined) {
1932
1929
  * throw new Error('Invalid signature');
1933
1930
  * }
1934
1931
  */
1935
- function cryptoSignOpen(sm, pk, ctx = DEFAULT_CTX) {
1932
+ function cryptoSignOpen(sm, pk, ctx) {
1933
+ if (!(ctx instanceof Uint8Array)) {
1934
+ throw new TypeError('ctx is required and must be a Uint8Array');
1935
+ }
1936
1936
  if (sm.length < CryptoBytes) {
1937
1937
  return undefined;
1938
1938
  }
@@ -174,7 +174,7 @@ function cAddQ(a) {
174
174
 
175
175
  function ntt(a) {
176
176
  let k = 0;
177
- let j = 0;
177
+ let j;
178
178
 
179
179
  for (let len = 128; len > 0; len >>= 1) {
180
180
  for (let start = 0; start < N; start = j + len) {
@@ -190,7 +190,7 @@ function ntt(a) {
190
190
 
191
191
  function invNTTToMont(a) {
192
192
  const f = 41978n; // mont^2/256
193
- let j = 0;
193
+ let j;
194
194
  let k = 256;
195
195
 
196
196
  for (let len = 1; len < N; len <<= 1) {
@@ -1107,13 +1107,6 @@ function isZero(buffer) {
1107
1107
  return acc === 0;
1108
1108
  }
1109
1109
 
1110
- /**
1111
- * Default signing context ("ZOND" in ASCII).
1112
- * Used for domain separation per FIPS 204.
1113
- * @constant {Uint8Array}
1114
- */
1115
- const DEFAULT_CTX = new Uint8Array([0x5a, 0x4f, 0x4e, 0x44]); // "ZOND"
1116
-
1117
1110
  /**
1118
1111
  * Convert hex string to Uint8Array with strict validation.
1119
1112
  *
@@ -1187,9 +1180,9 @@ function cryptoSignKeypair(passedSeed, pk, sk) {
1187
1180
  }
1188
1181
  } catch (e) {
1189
1182
  if (e instanceof TypeError) {
1190
- throw new Error(`pk/sk cannot be null`);
1183
+ throw new Error(`pk/sk cannot be null`, { cause: e });
1191
1184
  } else {
1192
- throw new Error(`${e.message}`);
1185
+ throw new Error(`${e.message}`, { cause: e });
1193
1186
  }
1194
1187
  }
1195
1188
 
@@ -1268,21 +1261,22 @@ function cryptoSignKeypair(passedSeed, pk, sk) {
1268
1261
  * @param {Uint8Array} sk - Secret key (must be CryptoSecretKeyBytes = 4896 bytes)
1269
1262
  * @param {boolean} randomizedSigning - If true, use random nonce for hedged signing.
1270
1263
  * If false, use deterministic nonce derived from message and key.
1271
- * @param {Uint8Array} [ctx=DEFAULT_CTX] - Context string for domain separation (max 255 bytes).
1272
- * Defaults to "ZOND" for QRL compatibility.
1264
+ * @param {Uint8Array} ctx - Context string for domain separation (max 255 bytes).
1273
1265
  * @returns {number} 0 on success
1274
- * @throws {Error} If sk is wrong size or context exceeds 255 bytes
1266
+ * @throws {Error} If ctx is missing, sk is wrong size, or context exceeds 255 bytes
1275
1267
  *
1276
1268
  * @example
1277
1269
  * const sig = new Uint8Array(CryptoBytes);
1278
- * cryptoSignSignature(sig, message, sk, false);
1279
- * // Or with custom context:
1280
- * cryptoSignSignature(sig, message, sk, false, new Uint8Array([0x01, 0x02]));
1270
+ * const ctx = new Uint8Array([0x01, 0x02]);
1271
+ * cryptoSignSignature(sig, message, sk, false, ctx);
1281
1272
  */
1282
- function cryptoSignSignature(sig, m, sk, randomizedSigning, ctx = DEFAULT_CTX) {
1273
+ function cryptoSignSignature(sig, m, sk, randomizedSigning, ctx) {
1283
1274
  if (!sig || sig.length < CryptoBytes) {
1284
1275
  throw new Error(`sig must be at least ${CryptoBytes} bytes`);
1285
1276
  }
1277
+ if (!(ctx instanceof Uint8Array)) {
1278
+ throw new TypeError('ctx is required and must be a Uint8Array');
1279
+ }
1286
1280
  if (ctx.length > 255) throw new Error(`invalid context length: ${ctx.length} (max 255)`);
1287
1281
  if (sk.length !== CryptoSecretKeyBytes) {
1288
1282
  throw new Error(`invalid sk length ${sk.length} | Expected length ${CryptoSecretKeyBytes}`);
@@ -1409,16 +1403,18 @@ function cryptoSignSignature(sig, m, sk, randomizedSigning, ctx = DEFAULT_CTX) {
1409
1403
  * @param {string|Uint8Array} msg - Message to sign (hex string, optional 0x prefix, or Uint8Array)
1410
1404
  * @param {Uint8Array} sk - Secret key (must be CryptoSecretKeyBytes = 4896 bytes)
1411
1405
  * @param {boolean} randomizedSigning - If true, use random nonce; if false, deterministic
1412
- * @param {Uint8Array} [ctx=DEFAULT_CTX] - Context string for domain separation (max 255 bytes).
1413
- * Defaults to "ZOND" for QRL compatibility.
1406
+ * @param {Uint8Array} ctx - Context string for domain separation (max 255 bytes).
1414
1407
  * @returns {Uint8Array} Signed message (CryptoBytes + msg.length bytes)
1415
1408
  * @throws {Error} If signing fails
1416
1409
  *
1417
1410
  * @example
1418
- * const signedMsg = cryptoSign(message, sk, false);
1411
+ * const signedMsg = cryptoSign(message, sk, false, ctx);
1419
1412
  * // signedMsg contains: signature (4627 bytes) || message
1420
1413
  */
1421
- function cryptoSign(msg, sk, randomizedSigning, ctx = DEFAULT_CTX) {
1414
+ function cryptoSign(msg, sk, randomizedSigning, ctx) {
1415
+ if (!(ctx instanceof Uint8Array)) {
1416
+ throw new TypeError('ctx is required and must be a Uint8Array');
1417
+ }
1422
1418
  const msgBytes = messageToBytes(msg);
1423
1419
 
1424
1420
  const sm = new Uint8Array(CryptoBytes + msgBytes.length);
@@ -1445,17 +1441,19 @@ function cryptoSign(msg, sk, randomizedSigning, ctx = DEFAULT_CTX) {
1445
1441
  * @param {Uint8Array} sig - Signature to verify (must be CryptoBytes = 4627 bytes)
1446
1442
  * @param {string|Uint8Array} m - Message that was signed (hex string, optional 0x prefix, or Uint8Array)
1447
1443
  * @param {Uint8Array} pk - Public key (must be CryptoPublicKeyBytes = 2592 bytes)
1448
- * @param {Uint8Array} [ctx=DEFAULT_CTX] - Context string used during signing (max 255 bytes).
1449
- * Defaults to "ZOND" for QRL compatibility.
1444
+ * @param {Uint8Array} ctx - Context string used during signing (max 255 bytes).
1450
1445
  * @returns {boolean} true if signature is valid, false otherwise
1451
1446
  *
1452
1447
  * @example
1453
- * const isValid = cryptoSignVerify(signature, message, pk);
1448
+ * const isValid = cryptoSignVerify(signature, message, pk, ctx);
1454
1449
  * if (!isValid) {
1455
1450
  * throw new Error('Invalid signature');
1456
1451
  * }
1457
1452
  */
1458
- function cryptoSignVerify(sig, m, pk, ctx = DEFAULT_CTX) {
1453
+ function cryptoSignVerify(sig, m, pk, ctx) {
1454
+ if (!(ctx instanceof Uint8Array)) {
1455
+ throw new TypeError('ctx is required and must be a Uint8Array');
1456
+ }
1459
1457
  if (ctx.length > 255) return false;
1460
1458
  let i;
1461
1459
  const buf = new Uint8Array(K * PolyW1PackedBytes);
@@ -1543,17 +1541,19 @@ function cryptoSignVerify(sig, m, pk, ctx = DEFAULT_CTX) {
1543
1541
  *
1544
1542
  * @param {Uint8Array} sm - Signed message (signature || message)
1545
1543
  * @param {Uint8Array} pk - Public key (must be CryptoPublicKeyBytes = 2592 bytes)
1546
- * @param {Uint8Array} [ctx=DEFAULT_CTX] - Context string used during signing (max 255 bytes).
1547
- * Defaults to "ZOND" for QRL compatibility.
1544
+ * @param {Uint8Array} ctx - Context string used during signing (max 255 bytes).
1548
1545
  * @returns {Uint8Array|undefined} The original message if valid, undefined if verification fails
1549
1546
  *
1550
1547
  * @example
1551
- * const message = cryptoSignOpen(signedMsg, pk);
1548
+ * const message = cryptoSignOpen(signedMsg, pk, ctx);
1552
1549
  * if (message === undefined) {
1553
1550
  * throw new Error('Invalid signature');
1554
1551
  * }
1555
1552
  */
1556
- function cryptoSignOpen(sm, pk, ctx = DEFAULT_CTX) {
1553
+ function cryptoSignOpen(sm, pk, ctx) {
1554
+ if (!(ctx instanceof Uint8Array)) {
1555
+ throw new TypeError('ctx is required and must be a Uint8Array');
1556
+ }
1557
1557
  if (sm.length < CryptoBytes) {
1558
1558
  return undefined;
1559
1559
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theqrl/mldsa87",
3
- "version": "1.1.1",
3
+ "version": "2.0.0",
4
4
  "description": "ML-DSA-87 cryptography",
5
5
  "keywords": [
6
6
  "ml-dsa",
@@ -53,20 +53,39 @@
53
53
  "node": ">=20.19.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@eslint/js": "^10.0.1",
57
- "@rollup/plugin-node-resolve": "^16.0.3",
58
- "c8": "^10.1.3",
59
- "chai": "^6.2.2",
60
- "eslint": "^10.0.0",
61
- "eslint-config-prettier": "^10.1.8",
62
- "eslint-plugin-import-x": "^4.15.0",
63
- "eslint-plugin-prettier": "^5.5.4",
64
- "globals": "^17.3.0",
65
- "mocha": "^11.7.5",
66
- "prettier": "^3.8.1",
67
- "rollup": "^4.57.1"
56
+ "@eslint/js": "10.0.1",
57
+ "@rollup/plugin-node-resolve": "16.0.3",
58
+ "c8": "11.0.0",
59
+ "chai": "6.2.2",
60
+ "eslint": "10.0.3",
61
+ "eslint-config-prettier": "10.1.8",
62
+ "eslint-plugin-import-x": "4.16.2",
63
+ "eslint-plugin-prettier": "5.5.5",
64
+ "globals": "17.4.0",
65
+ "minimatch": "10.2.4",
66
+ "mocha": "11.7.5",
67
+ "prettier": "3.8.1",
68
+ "rollup": "4.59.0",
69
+ "serialize-javascript": "7.0.4",
70
+ "tar": "7.5.11"
68
71
  },
69
72
  "dependencies": {
70
- "@noble/hashes": "^2.0.1"
73
+ "@noble/hashes": "2.0.1"
74
+ },
75
+ "overrides": {
76
+ "diff": "8.0.3",
77
+ "minimatch": "10.2.4"
78
+ },
79
+ "c8": {
80
+ "include": [
81
+ "src/**"
82
+ ],
83
+ "exclude": [
84
+ "**/dist/**",
85
+ "**/test/**",
86
+ "**/browser-tests/**",
87
+ "**/*.d.ts"
88
+ ],
89
+ "all": true
71
90
  }
72
91
  }
package/src/index.d.ts CHANGED
@@ -56,12 +56,12 @@ export function cryptoSignKeypair(
56
56
  ): Uint8Array;
57
57
 
58
58
  /**
59
- * Create a signature for a message with optional context
59
+ * Create a signature for a message
60
60
  * @param sig - Output buffer for signature (must be CryptoBytes length minimum)
61
61
  * @param m - Message to sign (hex string or Uint8Array; strings are parsed as hex only)
62
62
  * @param sk - Secret key
63
63
  * @param randomizedSigning - If true, use random nonce; if false, deterministic
64
- * @param ctx - Optional context string (max 255 bytes, defaults to "ZOND")
64
+ * @param ctx - Context string (max 255 bytes)
65
65
  * @returns 0 on success
66
66
  * @throws Error if sk is wrong size or context too long
67
67
  */
@@ -70,7 +70,7 @@ export function cryptoSignSignature(
70
70
  m: Uint8Array | string,
71
71
  sk: Uint8Array,
72
72
  randomizedSigning: boolean,
73
- ctx?: Uint8Array
73
+ ctx: Uint8Array
74
74
  ): number;
75
75
 
76
76
  /**
@@ -78,7 +78,7 @@ export function cryptoSignSignature(
78
78
  * @param msg - Message to sign
79
79
  * @param sk - Secret key
80
80
  * @param randomizedSigning - If true, use random nonce; if false, deterministic
81
- * @param ctx - Optional context string (max 255 bytes, defaults to "ZOND")
81
+ * @param ctx - Context string (max 255 bytes)
82
82
  * @returns Signed message (signature || message)
83
83
  * @throws Error if signing fails
84
84
  */
@@ -86,35 +86,35 @@ export function cryptoSign(
86
86
  msg: Uint8Array | string,
87
87
  sk: Uint8Array,
88
88
  randomizedSigning: boolean,
89
- ctx?: Uint8Array
89
+ ctx: Uint8Array
90
90
  ): Uint8Array;
91
91
 
92
92
  /**
93
- * Verify a signature with optional context
93
+ * Verify a signature
94
94
  * @param sig - Signature to verify
95
95
  * @param m - Message that was signed (hex string or Uint8Array; strings are parsed as hex only)
96
96
  * @param pk - Public key
97
- * @param ctx - Optional context string (max 255 bytes, defaults to "ZOND")
97
+ * @param ctx - Context string (max 255 bytes)
98
98
  * @returns true if signature is valid, false otherwise
99
99
  */
100
100
  export function cryptoSignVerify(
101
101
  sig: Uint8Array,
102
102
  m: Uint8Array | string,
103
103
  pk: Uint8Array,
104
- ctx?: Uint8Array
104
+ ctx: Uint8Array
105
105
  ): boolean;
106
106
 
107
107
  /**
108
108
  * Open a signed message (verify and extract message)
109
109
  * @param sm - Signed message (signature || message)
110
110
  * @param pk - Public key
111
- * @param ctx - Optional context string (max 255 bytes, defaults to "ZOND")
111
+ * @param ctx - Context string (max 255 bytes)
112
112
  * @returns Message if valid, undefined if verification fails
113
113
  */
114
114
  export function cryptoSignOpen(
115
115
  sm: Uint8Array,
116
116
  pk: Uint8Array,
117
- ctx?: Uint8Array
117
+ ctx: Uint8Array
118
118
  ): Uint8Array | undefined;
119
119
 
120
120
  // Utility functions