@theqrl/dilithium5 1.2.0 → 1.2.2

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.
@@ -44,7 +44,9 @@ export const zetas: readonly number[];
44
44
  * @param seed - Optional 32-byte seed for deterministic key generation (null for random)
45
45
  * @param pk - Output buffer for public key (must be CryptoPublicKeyBytes length)
46
46
  * @param sk - Output buffer for secret key (must be CryptoSecretKeyBytes length)
47
- * @returns The seed used for key generation
47
+ * @returns The seed used for key generation. **Secret-key-equivalent**: anyone
48
+ * holding it can regenerate the full keypair — store it with the same care
49
+ * as `sk` and `zeroize()` it when no longer needed.
48
50
  * @throws Error if pk/sk buffers are wrong size or null
49
51
  */
50
52
  export function cryptoSignKeypair(
@@ -182,43 +184,67 @@ export function zeroize(buffer: Uint8Array): void;
182
184
  */
183
185
  export function isZero(buffer: Uint8Array): boolean;
184
186
 
187
+ /**
188
+ * Zero the coefficient arrays of a polynomial vector (best-effort, see
189
+ * SECURITY.md). Centralizes the secret-wiping pattern used by signing paths.
190
+ */
191
+ export function zeroizePolyVec(polyVec: PolyVecK | PolyVecL): void;
192
+
185
193
  // Internal classes (exported but primarily for internal use)
186
194
 
195
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
187
196
  export class Poly {
188
197
  coeffs: Int32Array;
189
198
  constructor();
190
199
  copy(poly: Poly): void;
191
200
  }
192
201
 
202
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
193
203
  export class PolyVecK {
194
204
  vec: Poly[];
195
205
  constructor();
196
206
  }
197
207
 
208
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
198
209
  export class PolyVecL {
199
210
  vec: Poly[];
200
211
  constructor();
201
212
  copy(polyVecL: PolyVecL): void;
202
213
  }
203
214
 
215
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
204
216
  export class KeccakState {
205
217
  constructor();
206
218
  }
207
219
 
208
220
  // Internal functions (exported but primarily for internal use)
221
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
209
222
  export function polyNTT(a: Poly): void;
223
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
210
224
  export function polyInvNTTToMont(a: Poly): void;
225
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
211
226
  export function polyChallenge(c: Poly, seed: Uint8Array): void;
227
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
212
228
  export function ntt(a: Int32Array): void;
229
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
213
230
  export function invNTTToMont(a: Int32Array): void;
231
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
214
232
  export function montgomeryReduce(a: bigint): bigint;
233
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
215
234
  export function reduce32(a: number): number;
235
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
216
236
  export function cAddQ(a: number): number;
237
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
217
238
  export function decompose(a0: Int32Array, i: number, a: number): number;
239
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
218
240
  export function power2round(a0: Int32Array, i: number, a: number): number;
241
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
219
242
  export function makeHint(a0: number, a1: number): number;
243
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
220
244
  export function useHint(a: number, hint: number): number;
245
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
221
246
  export function packPk(pk: Uint8Array, rho: Uint8Array, t1: PolyVecK): void;
247
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
222
248
  export function packSk(
223
249
  sk: Uint8Array,
224
250
  rho: Uint8Array,
@@ -228,13 +254,16 @@ export function packSk(
228
254
  s1: PolyVecL,
229
255
  s2: PolyVecK
230
256
  ): void;
257
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
231
258
  export function packSig(
232
259
  sig: Uint8Array,
233
260
  c: Uint8Array,
234
261
  z: PolyVecL,
235
262
  h: PolyVecK
236
263
  ): void;
264
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
237
265
  export function unpackPk(rho: Uint8Array, t1: PolyVecK, pk: Uint8Array): void;
266
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
238
267
  export function unpackSk(
239
268
  rho: Uint8Array,
240
269
  tr: Uint8Array,
@@ -244,6 +273,7 @@ export function unpackSk(
244
273
  s2: PolyVecK,
245
274
  sk: Uint8Array
246
275
  ): void;
276
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
247
277
  export function unpackSig(
248
278
  c: Uint8Array,
249
279
  z: PolyVecL,
@@ -252,18 +282,26 @@ export function unpackSig(
252
282
  ): number;
253
283
 
254
284
  // FIPS 202 SHAKE primitives (low-level XOF interface, primarily internal)
285
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
255
286
  export function shake128Init(state: KeccakState): void;
287
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
256
288
  export function shake128Absorb(state: KeccakState, input: Uint8Array): void;
289
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
257
290
  export function shake128Finalize(state: KeccakState): void;
291
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
258
292
  export function shake128SqueezeBlocks(
259
293
  out: Uint8Array,
260
294
  outputOffset: number,
261
295
  nBlocks: number,
262
296
  state: KeccakState
263
297
  ): void;
298
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
264
299
  export function shake256Init(state: KeccakState): void;
300
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
265
301
  export function shake256Absorb(state: KeccakState, input: Uint8Array): void;
302
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
266
303
  export function shake256Finalize(state: KeccakState): void;
304
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
267
305
  export function shake256SqueezeBlocks(
268
306
  out: Uint8Array,
269
307
  outputOffset: number,
@@ -272,11 +310,13 @@ export function shake256SqueezeBlocks(
272
310
  ): void;
273
311
 
274
312
  // Dilithium-specific stream initializers
313
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
275
314
  export function dilithiumShake128StreamInit(
276
315
  state: KeccakState,
277
316
  seed: Uint8Array,
278
317
  nonce: number
279
318
  ): void;
319
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
280
320
  export function dilithiumShake256StreamInit(
281
321
  state: KeccakState,
282
322
  seed: Uint8Array,
@@ -284,17 +324,29 @@ export function dilithiumShake256StreamInit(
284
324
  ): void;
285
325
 
286
326
  // Polynomial operations (internal)
327
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
287
328
  export function polyReduce(a: Poly): void;
329
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
288
330
  export function polyCAddQ(a: Poly): void;
331
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
289
332
  export function polyAdd(c: Poly, a: Poly, b: Poly): void;
333
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
290
334
  export function polySub(c: Poly, a: Poly, b: Poly): void;
335
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
291
336
  export function polyShiftL(a: Poly): void;
337
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
292
338
  export function polyPointWiseMontgomery(c: Poly, a: Poly, b: Poly): void;
339
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
293
340
  export function polyPower2round(a1: Poly, a0: Poly, a: Poly): void;
341
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
294
342
  export function polyDecompose(a1: Poly, a0: Poly, a: Poly): void;
343
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
295
344
  export function polyMakeHint(h: Poly, a0: Poly, a1: Poly): number;
345
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
296
346
  export function polyUseHint(b: Poly, a: Poly, h: Poly): void;
347
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
297
348
  export function polyChkNorm(a: Poly, b: number): number;
349
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
298
350
  export function rejUniform(
299
351
  a: Int32Array,
300
352
  aOffset: number,
@@ -302,7 +354,9 @@ export function rejUniform(
302
354
  buf: Uint8Array,
303
355
  bufLen: number
304
356
  ): number;
357
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
305
358
  export function polyUniform(a: Poly, seed: Uint8Array, nonce: number): void;
359
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
306
360
  export function rejEta(
307
361
  a: Int32Array,
308
362
  aOffset: number,
@@ -310,58 +364,95 @@ export function rejEta(
310
364
  buf: Uint8Array,
311
365
  bufLen: number
312
366
  ): number;
367
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
313
368
  export function polyUniformEta(a: Poly, seed: Uint8Array, nonce: number): void;
369
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
314
370
  export function polyZUnpack(r: Poly, a: Uint8Array, aOffset: number): void;
371
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
315
372
  export function polyUniformGamma1(a: Poly, seed: Uint8Array, nonce: number): void;
373
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
316
374
  export function polyEtaPack(r: Uint8Array, rOffset: number, a: Poly): void;
375
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
317
376
  export function polyEtaUnpack(r: Poly, a: Uint8Array, aOffset: number): void;
377
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
318
378
  export function polyT1Pack(r: Uint8Array, rOffset: number, a: Poly): void;
379
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
319
380
  export function polyT1Unpack(r: Poly, a: Uint8Array, aOffset: number): void;
381
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
320
382
  export function polyT0Pack(r: Uint8Array, rOffset: number, a: Poly): void;
383
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
321
384
  export function polyT0Unpack(r: Poly, a: Uint8Array, aOffset: number): void;
385
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
322
386
  export function polyZPack(r: Uint8Array, rOffset: number, a: Poly): void;
387
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
323
388
  export function polyW1Pack(r: Uint8Array, rOffset: number, a: Poly): void;
324
389
 
325
390
  // Polynomial vector operations (internal)
391
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
326
392
  export function polyVecMatrixExpand(mat: PolyVecL[], rho: Uint8Array): void;
393
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
327
394
  export function polyVecMatrixPointWiseMontgomery(
328
395
  t: PolyVecK,
329
396
  mat: PolyVecL[],
330
397
  v: PolyVecL
331
398
  ): void;
399
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
332
400
  export function polyVecLUniformEta(v: PolyVecL, seed: Uint8Array, nonce: number): void;
401
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
333
402
  export function polyVecLUniformGamma1(v: PolyVecL, seed: Uint8Array, nonce: number): void;
403
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
334
404
  export function polyVecLReduce(v: PolyVecL): void;
405
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
335
406
  export function polyVecLAdd(w: PolyVecL, u: PolyVecL, v: PolyVecL): void;
407
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
336
408
  export function polyVecLNTT(v: PolyVecL): void;
409
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
337
410
  export function polyVecLInvNTTToMont(v: PolyVecL): void;
411
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
338
412
  export function polyVecLPointWisePolyMontgomery(
339
413
  r: PolyVecL,
340
414
  a: Poly,
341
415
  v: PolyVecL
342
416
  ): void;
417
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
343
418
  export function polyVecLPointWiseAccMontgomery(
344
419
  w: Poly,
345
420
  u: PolyVecL,
346
421
  v: PolyVecL
347
422
  ): void;
423
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
348
424
  export function polyVecLChkNorm(v: PolyVecL, bound: number): number;
425
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
349
426
  export function polyVecKUniformEta(v: PolyVecK, seed: Uint8Array, nonce: number): void;
427
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
350
428
  export function polyVecKReduce(v: PolyVecK): void;
429
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
351
430
  export function polyVecKCAddQ(v: PolyVecK): void;
431
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
352
432
  export function polyVecKAdd(w: PolyVecK, u: PolyVecK, v: PolyVecK): void;
433
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
353
434
  export function polyVecKSub(w: PolyVecK, u: PolyVecK, v: PolyVecK): void;
435
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
354
436
  export function polyVecKShiftL(v: PolyVecK): void;
437
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
355
438
  export function polyVecKNTT(v: PolyVecK): void;
439
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
356
440
  export function polyVecKInvNTTToMont(v: PolyVecK): void;
441
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
357
442
  export function polyVecKPointWisePolyMontgomery(
358
443
  r: PolyVecK,
359
444
  a: Poly,
360
445
  v: PolyVecK
361
446
  ): void;
447
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
362
448
  export function polyVecKChkNorm(v: PolyVecK, bound: number): number;
449
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
363
450
  export function polyVecKPower2round(v1: PolyVecK, v0: PolyVecK, v: PolyVecK): void;
451
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
364
452
  export function polyVecKDecompose(v1: PolyVecK, v0: PolyVecK, v: PolyVecK): void;
453
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
365
454
  export function polyVecKMakeHint(h: PolyVecK, v0: PolyVecK, v1: PolyVecK): number;
455
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
366
456
  export function polyVecKUseHint(w: PolyVecK, u: PolyVecK, h: PolyVecK): void;
457
+ /** @deprecated Internal API — not part of the stable documented surface; will move behind a subpath or be removed at the next major version. See CONTRIBUTING.md "Public API surface policy". */
367
458
  export function polyVecKPackW1(r: Uint8Array, w1: PolyVecK): void;