@noble/post-quantum 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/esm/ml-dsa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */
2
2
  import { shake256 } from '@noble/hashes/sha3';
3
- import { genCrystals, XOF128, XOF256, XOF_AES } from './_crystals.js';
3
+ import { genCrystals, XOF128, XOF256 } from './_crystals.js';
4
4
  import { cleanBytes, ensureBytes, equalBytes, randomBytes, splitCoder, vecCoder, } from './utils.js';
5
5
  /*
6
6
  Lattice-based digital signature algorithm. See
@@ -8,11 +8,6 @@ Lattice-based digital signature algorithm. See
8
8
  [repo](https://github.com/pq-crystals/dilithium).
9
9
  Dilithium has similar internals to Kyber, but their keys and params are different.
10
10
 
11
- Three versions are provided:
12
-
13
- 1. Dilithium v3.0, v3.0 AES
14
- 2. Dilithium v3.1, v3.1 AES
15
- 3. ML-DSA aka [FIPS-204](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.204.ipd.pdf)
16
11
  */
17
12
  // Constants
18
13
  const N = 256;
@@ -96,7 +91,7 @@ function RejNTTPoly(xof) {
96
91
  }
97
92
  function getDilithium(opts) {
98
93
  const { K, L, GAMMA1, GAMMA2, TAU, ETA, OMEGA } = opts;
99
- const { FIPS204, V31, CRH_BYTES, TR_BYTES, C_TILDE_BYTES, XOF128, XOF256 } = opts;
94
+ const { CRH_BYTES, TR_BYTES, C_TILDE_BYTES, XOF128, XOF256 } = opts;
100
95
  if (![2, 4].includes(ETA))
101
96
  throw new Error('Wrong ETA');
102
97
  if (![1 << 17, 1 << 19].includes(GAMMA1))
@@ -126,6 +121,8 @@ function getDilithium(opts) {
126
121
  // But they return different results! However, decompose is same.
127
122
  // So, either there is a bug in Dilithium ref implementation or in FIPS204.
128
123
  // For now, lets use dilithium one, so test vectors can be passed.
124
+ // See
125
+ // https://github.com/GiacomoPope/dilithium-py?tab=readme-ov-file#optimising-decomposition-and-making-hints
129
126
  return res0;
130
127
  };
131
128
  const UseHint = (h, r) => {
@@ -214,7 +211,7 @@ function getDilithium(opts) {
214
211
  const SampleInBall = (seed) => {
215
212
  // Samples a polynomial c ∈ Rq with coeffcients from {−1, 0, 1} and Hamming weight τ
216
213
  const pre = newPoly(N);
217
- const s = shake256.create({}).update(seed.slice(0, 32));
214
+ const s = shake256.create({}).update(seed);
218
215
  const buf = new Uint8Array(shake256.blockLen);
219
216
  s.xofInto(buf);
220
217
  const masks = buf.slice(0, 8);
@@ -261,15 +258,19 @@ function getDilithium(opts) {
261
258
  }
262
259
  return { v, cnt };
263
260
  };
264
- const signRandBytes = FIPS204 ? 32 : CRH_BYTES;
265
- const seedCoder = splitCoder(32, V31 ? 64 : 32, 32);
266
- const seedXOF = V31 ? XOF256 : XOF128;
261
+ const signRandBytes = 32;
262
+ const seedCoder = splitCoder(32, 64, 32);
267
263
  // API & argument positions are exactly as in FIPS204.
268
264
  return {
269
265
  signRandBytes,
270
266
  keygen: (seed = randomBytes(32)) => {
271
- const [rho, rhoPrime, K_] = seedCoder.decode(shake256(seed, { dkLen: seedCoder.bytesLen }));
272
- const xofPrime = seedXOF(rhoPrime);
267
+ // H(𝜉||IntegerToBytes(𝑘, 1)||IntegerToBytes(ℓ, 1), 128) 2: expand seed
268
+ const seedDst = new Uint8Array(32 + 2);
269
+ seedDst.set(seed);
270
+ seedDst[32] = K;
271
+ seedDst[33] = L;
272
+ const [rho, rhoPrime, K_] = seedCoder.decode(shake256(seedDst, { dkLen: seedCoder.bytesLen }));
273
+ const xofPrime = XOF256(rhoPrime);
273
274
  const s1 = [];
274
275
  for (let i = 0; i < L; i++)
275
276
  s1.push(RejBoundedPoly(xofPrime.get(i & 0xff, (i >> 8) & 0xff)));
@@ -301,7 +302,7 @@ function getDilithium(opts) {
301
302
  // STATS
302
303
  // Kyber512: { calls: 4, xofs: 12 }, Kyber768: { calls: 9, xofs: 27 }, Kyber1024: { calls: 16, xofs: 48 }
303
304
  // DSA44: { calls: 24, xofs: 24 }, DSA65: { calls: 41, xofs: 41 }, DSA87: { calls: 71, xofs: 71 }
304
- cleanBytes(rho, rhoPrime, K_, s1, s2, s1Hat, t, t0, t1, tr);
305
+ cleanBytes(rho, rhoPrime, K_, s1, s2, s1Hat, t, t0, t1, tr, seedDst);
305
306
  return { publicKey, secretKey };
306
307
  },
307
308
  // NOTE: random is optional.
@@ -327,17 +328,15 @@ function getDilithium(opts) {
327
328
  }
328
329
  // This part is per msg
329
330
  const mu = shake256.create({ dkLen: CRH_BYTES }).update(tr).update(msg).digest(); // 6: µ ← H(tr||M, 512) ▷ Compute message representative µ
330
- let rhoprime; // Compute private random seed
331
- if (FIPS204) {
332
- const rnd = random ? random : new Uint8Array(32);
333
- ensureBytes(rnd);
334
- rhoprime = shake256.create({ dkLen: CRH_BYTES }).update(_K).update(rnd).update(mu).digest(); // ρ′← H(K||rnd||µ, 512)
335
- }
336
- else {
337
- rhoprime = random
338
- ? random
339
- : shake256.create({ dkLen: CRH_BYTES }).update(_K).update(mu).digest();
340
- }
331
+ // Compute private random seed
332
+ const rnd = random ? random : new Uint8Array(32);
333
+ ensureBytes(rnd);
334
+ const rhoprime = shake256
335
+ .create({ dkLen: CRH_BYTES })
336
+ .update(_K)
337
+ .update(rnd)
338
+ .update(mu)
339
+ .digest(); // ρ′← H(K||rnd||µ, 512)
341
340
  ensureBytes(rhoprime, CRH_BYTES);
342
341
  const x256 = XOF256(rhoprime, ZCoder.bytesLen);
343
342
  // Rejection sampling loop
@@ -364,7 +363,7 @@ function getDilithium(opts) {
364
363
  .update(W1Vec.encode(w1))
365
364
  .digest();
366
365
  // Verifer’s challenge
367
- const cHat = NTT.encode(SampleInBall(cTilde.subarray(0, 32))); // c ← SampleInBall(c˜1); cˆ ← NTT(c)
366
+ const cHat = NTT.encode(SampleInBall(cTilde)); // c ← SampleInBall(c˜1); cˆ ← NTT(c)
368
367
  // ⟨⟨cs1⟩⟩ ← NTT−1(cˆ◦ sˆ1)
369
368
  const cs1 = s1.map((i) => MultiplyNTTs(i, cHat));
370
369
  for (let i = 0; i < L; i++) {
@@ -414,7 +413,7 @@ function getDilithium(opts) {
414
413
  return false;
415
414
  const mu = shake256.create({ dkLen: CRH_BYTES }).update(tr).update(msg).digest(); // 7: µ ← H(tr||M, 512)
416
415
  // Compute verifer’s challenge from c˜
417
- const c = NTT.encode(SampleInBall(cTilde.subarray(0, 32))); // c ← SampleInBall(c˜1)
416
+ const c = NTT.encode(SampleInBall(cTilde)); // c ← SampleInBall(c˜1)
418
417
  const zNtt = z.map((i) => i.slice()); // zNtt = NTT(z)
419
418
  for (let i = 0; i < L; i++)
420
419
  NTT.encode(zNtt[i]);
@@ -439,62 +438,20 @@ function getDilithium(opts) {
439
438
  .update(mu)
440
439
  .update(W1Vec.encode(wTick1))
441
440
  .digest();
442
- if (FIPS204) {
443
- // Additional checks in FIPS-204:
444
- // [[ ||z||∞ < γ1 − β ]] and [[c ˜ = c˜′]] and [[number of 1’s in h is ≤ ω]]
445
- for (const t of h) {
446
- const sum = t.reduce((acc, i) => acc + i, 0);
447
- if (!(sum <= OMEGA))
448
- return false;
449
- }
450
- for (const t of z)
451
- if (polyChknorm(t, GAMMA1 - BETA))
452
- return false;
441
+ // Additional checks in FIPS-204:
442
+ // [[ ||z||∞ < γ1 − β ]] and [[c ˜ = c˜′]] and [[number of 1’s in h is ≤ ω]]
443
+ for (const t of h) {
444
+ const sum = t.reduce((acc, i) => acc + i, 0);
445
+ if (!(sum <= OMEGA))
446
+ return false;
453
447
  }
448
+ for (const t of z)
449
+ if (polyChknorm(t, GAMMA1 - BETA))
450
+ return false;
454
451
  return equalBytes(cTilde, c2);
455
452
  },
456
453
  };
457
454
  }
458
- function getDilithiumVersions(cfg) {
459
- return {
460
- dilithium2: getDilithium({ ...PARAMS[2], ...cfg }),
461
- dilithium3: getDilithium({ ...PARAMS[3], ...cfg }),
462
- dilithium5: getDilithium({ ...PARAMS[5], ...cfg }),
463
- };
464
- }
465
- // v30 is NIST round 3 submission, for original vectors and benchmarking.
466
- // v31 is kyber: more secure than v30.
467
- // ml-dsa is NIST FIPS 204, but it is still a draft and may change.
468
- export const dilithium_v30 = /* @__PURE__ */ getDilithiumVersions({
469
- CRH_BYTES: 48,
470
- TR_BYTES: 48,
471
- C_TILDE_BYTES: 32,
472
- XOF128,
473
- XOF256,
474
- });
475
- export const dilithium_v31 = /* @__PURE__ */ getDilithiumVersions({
476
- CRH_BYTES: 64,
477
- TR_BYTES: 32,
478
- C_TILDE_BYTES: 32,
479
- XOF128,
480
- XOF256,
481
- V31: true,
482
- });
483
- export const dilithium_v30_aes = /* @__PURE__ */ getDilithiumVersions({
484
- CRH_BYTES: 48,
485
- TR_BYTES: 48,
486
- C_TILDE_BYTES: 32,
487
- XOF128: XOF_AES,
488
- XOF256: XOF_AES,
489
- });
490
- export const dilithium_v31_aes = /* @__PURE__ */ getDilithiumVersions({
491
- CRH_BYTES: 64,
492
- TR_BYTES: 32,
493
- C_TILDE_BYTES: 32,
494
- XOF128: XOF_AES,
495
- XOF256: XOF_AES,
496
- V31: true,
497
- });
498
455
  // ML-DSA
499
456
  export const ml_dsa44 = /* @__PURE__ */ getDilithium({
500
457
  ...PARAMS[2],
@@ -503,8 +460,6 @@ export const ml_dsa44 = /* @__PURE__ */ getDilithium({
503
460
  C_TILDE_BYTES: 32,
504
461
  XOF128,
505
462
  XOF256,
506
- V31: true,
507
- FIPS204: true,
508
463
  });
509
464
  export const ml_dsa65 = /* @__PURE__ */ getDilithium({
510
465
  ...PARAMS[3],
@@ -513,8 +468,6 @@ export const ml_dsa65 = /* @__PURE__ */ getDilithium({
513
468
  C_TILDE_BYTES: 48,
514
469
  XOF128,
515
470
  XOF256,
516
- V31: true,
517
- FIPS204: true,
518
471
  });
519
472
  export const ml_dsa87 = /* @__PURE__ */ getDilithium({
520
473
  ...PARAMS[5],
@@ -523,7 +476,5 @@ export const ml_dsa87 = /* @__PURE__ */ getDilithium({
523
476
  C_TILDE_BYTES: 64,
524
477
  XOF128,
525
478
  XOF256,
526
- V31: true,
527
- FIPS204: true,
528
479
  });
529
480
  //# sourceMappingURL=ml-dsa.js.map
package/esm/ml-dsa.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ml-dsa.js","sourceRoot":"","sources":["../src/ml-dsa.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAO,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAGL,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;EAWE;AAEF,YAAY;AACZ,MAAM,CAAC,GAAG,GAAG,CAAC;AACd,mGAAmG;AACnG,MAAM,CAAC,GAAG,OAAO,CAAC;AAClB,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,yDAAyD;AACzD,MAAM,CAAC,GAAG,OAAO,CAAC;AAClB,MAAM,CAAC,GAAG,EAAE,CAAC;AACb,+FAA+F;AAC/F,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;AAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;AAc9C,kBAAkB;AAClB,MAAM,CAAC,MAAM,MAAM,GAA0B;IAC3C,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACnF,CAAC,E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,CAAC;oBAAE,OAAO,KAAK,CAAC;YACpC,CAAC;YACD,KAAK,MAAM,CAAC,IAAI,CAAC;gBAAE,IAAI,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;oBAAE,OAAO,KAAK,CAAC;YACnE,OAAO,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS;AACT,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC,YAAY,CAAC;IACnD,GAAG,MAAM,CAAC,CAAC,CAAC;IACZ,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,EAAE;IACjB,MAAM;IACN,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC,YAAY,CAAC;IACnD,GAAG,MAAM,CAAC,CAAC,CAAC;IACZ,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,EAAE;IACjB,MAAM;IACN,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC,YAAY,CAAC;IACnD,GAAG,MAAM,CAAC,CAAC,CAAC;IACZ,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,EAAE;IACjB,MAAM;IACN,MAAM;CACP,CAAC,CAAC"}
@@ -0,0 +1,55 @@
1
+ type ParameterSet = {
2
+ N: number;
3
+ K: number;
4
+ Q: number;
5
+ ETA1: number;
6
+ ETA2: number;
7
+ du: number;
8
+ dv: number;
9
+ RBGstrength: number;
10
+ };
11
+ export declare const PARAMS: Record<string, ParameterSet>;
12
+ /**
13
+ * FIPS-203 ML-KEM.
14
+ */
15
+ export declare const ml_kem512: {
16
+ publicKeyLen: number;
17
+ msgLen: number;
18
+ keygen: (seed?: Uint8Array) => {
19
+ publicKey: Uint8Array;
20
+ secretKey: Uint8Array;
21
+ };
22
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
23
+ cipherText: Uint8Array;
24
+ sharedSecret: Uint8Array;
25
+ };
26
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
27
+ };
28
+ export declare const ml_kem768: {
29
+ publicKeyLen: number;
30
+ msgLen: number;
31
+ keygen: (seed?: Uint8Array) => {
32
+ publicKey: Uint8Array;
33
+ secretKey: Uint8Array;
34
+ };
35
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
36
+ cipherText: Uint8Array;
37
+ sharedSecret: Uint8Array;
38
+ };
39
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
40
+ };
41
+ export declare const ml_kem1024: {
42
+ publicKeyLen: number;
43
+ msgLen: number;
44
+ keygen: (seed?: Uint8Array) => {
45
+ publicKey: Uint8Array;
46
+ secretKey: Uint8Array;
47
+ };
48
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
49
+ cipherText: Uint8Array;
50
+ sharedSecret: Uint8Array;
51
+ };
52
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
53
+ };
54
+ export {};
55
+ //# sourceMappingURL=ml-kem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ml-kem.d.ts","sourceRoot":"","sources":["../src/ml-kem.ts"],"names":[],"mappings":"AAmDA,KAAK,YAAY,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAItC,CAAC;AAuQX;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;6BAtDO,UAAU;;;;8BAmBT,UAAU,aAAa,UAAU;CAsC7D,CAAC;AACH,eAAO,MAAM,SAAS;;;;;;;6BA1DO,UAAU;;;;8BAmBT,UAAU,aAAa,UAAU;CA0C7D,CAAC;AACH,eAAO,MAAM,UAAU;;;;;;;6BA9DM,UAAU;;;;8BAmBT,UAAU,aAAa,UAAU;CA8C7D,CAAC"}
package/esm/ml-kem.js CHANGED
@@ -1,9 +1,7 @@
1
1
  /*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */
2
- import { ctr } from '@noble/ciphers/aes';
3
- import { sha256, sha512 } from '@noble/hashes/sha2';
4
2
  import { sha3_256, sha3_512, shake256 } from '@noble/hashes/sha3';
5
3
  import { u32 } from '@noble/hashes/utils';
6
- import { genCrystals, XOF_AES, XOF128 } from './_crystals.js';
4
+ import { genCrystals, XOF128 } from './_crystals.js';
7
5
  import { cleanBytes, ensureBytes, equalBytes, randomBytes, splitCoder, vecCoder, } from './utils.js';
8
6
  /*
9
7
  Lattice-based key encapsulation mechanism.
@@ -25,15 +23,10 @@ There are some concerns with regards to security: see
25
23
  [djb blog](https://blog.cr.yp.to/20231003-countcorrectly.html) and
26
24
  [mailing list](https://groups.google.com/a/list.nist.gov/g/pqc-forum/c/W2VOzy0wz_E).
27
25
 
28
- Three versions are provided:
29
-
30
- 1. Kyber
31
- 2. Kyber-90s, using algorithms from 1990s
32
- 3. ML-KEM aka [FIPS-203](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.203.ipd.pdf)
33
26
  */
34
27
  const N = 256; // Kyber (not FIPS-203) supports different lengths, but all std modes were using 256
35
28
  const Q = 3329; // 13*(2**8)+1, modulo prime
36
- const F = 3303; // 3303 ≡ 128−1 mod q (FIPS-203)
29
+ const F = 3303; // 3303 ≡ 128**(−1) mod q (FIPS-203)
37
30
  const ROOT_OF_UNITY = 17; // ζ = 17 ∈ Zq is a primitive 256-th root of unity modulo Q. ζ**128 ≡−1
38
31
  const { mod, nttZetas, NTT, bitsCoder } = genCrystals({
39
32
  N,
@@ -146,7 +139,7 @@ function sampleCBD(PRF, seed, nonce, eta) {
146
139
  // K-PKE
147
140
  // As per FIPS-203, it doesn't perform any input validation and can't be used in standalone fashion.
148
141
  const genKPKE = (opts) => {
149
- const { K, PRF, XOF, HASH512, ETA1, ETA2, du, dv, FIPS203 } = opts;
142
+ const { K, PRF, XOF, HASH512, ETA1, ETA2, du, dv } = opts;
150
143
  const poly1 = polyCoder(1);
151
144
  const polyV = polyCoder(dv);
152
145
  const polyU = polyCoder(du);
@@ -160,7 +153,11 @@ const genKPKE = (opts) => {
160
153
  publicKeyLen: publicCoder.bytesLen,
161
154
  cipherTextLen: cipherCoder.bytesLen,
162
155
  keygen: (seed) => {
163
- const [rho, sigma] = seedCoder.decode(HASH512(seed));
156
+ const seedDst = new Uint8Array(33);
157
+ seedDst.set(seed);
158
+ seedDst[32] = K;
159
+ const seedHash = HASH512(seedDst);
160
+ const [rho, sigma] = seedCoder.decode(seedHash);
164
161
  const sHat = [];
165
162
  const tHat = [];
166
163
  for (let i = 0; i < K; i++)
@@ -169,7 +166,7 @@ const genKPKE = (opts) => {
169
166
  for (let i = 0; i < K; i++) {
170
167
  const e = NTT.encode(sampleCBD(PRF, sigma, K + i, ETA1));
171
168
  for (let j = 0; j < K; j++) {
172
- const aji = SampleNTT(FIPS203 ? x.get(i, j) : x.get(j, i)); // A[j][i], inplace
169
+ const aji = SampleNTT(x.get(j, i)); // A[j][i], inplace
173
170
  polyAdd(e, MultiplyNTTs(aji, sHat[j]));
174
171
  }
175
172
  tHat.push(e); // t ← A ◦ s + e
@@ -179,7 +176,7 @@ const genKPKE = (opts) => {
179
176
  publicKey: publicCoder.encode([tHat, rho]),
180
177
  secretKey: secretCoder.encode(sHat),
181
178
  };
182
- cleanBytes(rho, sigma, sHat, tHat);
179
+ cleanBytes(rho, sigma, sHat, tHat, seedDst, seedHash);
183
180
  return res;
184
181
  },
185
182
  encrypt: (publicKey, msg, seed) => {
@@ -194,7 +191,7 @@ const genKPKE = (opts) => {
194
191
  const e1 = sampleCBD(PRF, seed, K + i, ETA2);
195
192
  const tmp = new Uint16Array(N);
196
193
  for (let j = 0; j < K; j++) {
197
- const aij = SampleNTT(FIPS203 ? x.get(j, i) : x.get(i, j)); // A[i][j], inplace
194
+ const aij = SampleNTT(x.get(i, j)); // A[i][j], inplace
198
195
  polyAdd(tmp, MultiplyNTTs(aij, rHat[j])); // t += aij * rHat[j]
199
196
  }
200
197
  polyAdd(e1, NTT.decode(tmp)); // e1 += tmp
@@ -224,7 +221,7 @@ const genKPKE = (opts) => {
224
221
  };
225
222
  function createKyber(opts) {
226
223
  const KPKE = genKPKE(opts);
227
- const { HASH256, HASH512, KDF, FIPS203 } = opts;
224
+ const { HASH256, HASH512, KDF } = opts;
228
225
  const { secretCoder: KPKESecretCoder, cipherTextLen } = KPKE;
229
226
  const publicKeyLen = KPKE.publicKeyLen; // 384*K+32
230
227
  const secretCoder = splitCoder(KPKE.secretKeyLen, KPKE.publicKeyLen, 32, 32);
@@ -245,31 +242,20 @@ function createKyber(opts) {
245
242
  encapsulate: (publicKey, msg = randomBytes(32)) => {
246
243
  ensureBytes(publicKey, publicKeyLen);
247
244
  ensureBytes(msg, msgLen);
248
- if (!FIPS203)
249
- msg = HASH256(msg); // NOTE: ML-KEM doesn't have this step!
250
- else {
251
- // FIPS-203 includes additional verification check for modulus
252
- const eke = publicKey.subarray(0, 384 * opts.K);
253
- const ek = KPKESecretCoder.encode(KPKESecretCoder.decode(eke.slice())); // Copy because of inplace encoding
254
- // (Modulus check.) Perform the computation ek ← ByteEncode12(ByteDecode12(eke)).
255
- // If ek = ̸ eke, the input is invalid. (See Section 4.2.1.)
256
- if (!equalBytes(ek, eke)) {
257
- cleanBytes(ek);
258
- throw new Error('ML-KEM.encapsulate: wrong publicKey modulus');
259
- }
245
+ // FIPS-203 includes additional verification check for modulus
246
+ const eke = publicKey.subarray(0, 384 * opts.K);
247
+ const ek = KPKESecretCoder.encode(KPKESecretCoder.decode(eke.slice())); // Copy because of inplace encoding
248
+ // (Modulus check.) Perform the computation ek ← ByteEncode12(ByteDecode12(eke)).
249
+ // If ek = ̸ eke, the input is invalid. (See Section 4.2.1.)
250
+ if (!equalBytes(ek, eke)) {
260
251
  cleanBytes(ek);
252
+ throw new Error('ML-KEM.encapsulate: wrong publicKey modulus');
261
253
  }
254
+ cleanBytes(ek);
262
255
  const kr = HASH512.create().update(msg).update(HASH256(publicKey)).digest(); // derive randomness
263
256
  const cipherText = KPKE.encrypt(publicKey, msg, kr.subarray(32, 64));
264
- if (FIPS203)
265
- return { cipherText, sharedSecret: kr.subarray(0, 32) };
266
- const cipherTextHash = HASH256(cipherText);
267
- const sharedSecret = KDF.create({})
268
- .update(kr.subarray(0, 32))
269
- .update(cipherTextHash)
270
- .digest();
271
- cleanBytes(kr, cipherTextHash);
272
- return { cipherText, sharedSecret };
257
+ kr.subarray(32).fill(0);
258
+ return { cipherText, sharedSecret: kr.subarray(0, 32) };
273
259
  },
274
260
  decapsulate: (cipherText, secretKey) => {
275
261
  ensureBytes(secretKey, secretKeyLen); // 768*k + 96
@@ -280,39 +266,12 @@ function createKyber(opts) {
280
266
  const Khat = kr.subarray(0, 32);
281
267
  const cipherText2 = KPKE.encrypt(publicKey, msg, kr.subarray(32, 64)); // re-encrypt using the derived randomness
282
268
  const isValid = equalBytes(cipherText, cipherText2); // if ciphertexts do not match, “implicitly reject”
283
- if (FIPS203) {
284
- const Kbar = KDF.create({ dkLen: 32 }).update(z).update(cipherText).digest();
285
- cleanBytes(msg, cipherText2, !isValid ? Khat : Kbar);
286
- return isValid ? Khat : Kbar;
287
- }
288
- const cipherTextHash = HASH256(cipherText);
289
- const sharedSecret = KDF.create({ dkLen: 32 })
290
- .update(isValid ? Khat : z)
291
- .update(cipherTextHash)
292
- .digest();
293
- cleanBytes(msg, cipherTextHash, cipherText2, Khat, z);
294
- return sharedSecret;
269
+ const Kbar = KDF.create({ dkLen: 32 }).update(z).update(cipherText).digest();
270
+ cleanBytes(msg, cipherText2, !isValid ? Khat : Kbar);
271
+ return isValid ? Khat : Kbar;
295
272
  },
296
273
  };
297
274
  }
298
- function PRF(l, key, nonce) {
299
- const _nonce = new Uint8Array(16);
300
- _nonce[0] = nonce;
301
- return ctr(key, _nonce).encrypt(new Uint8Array(l));
302
- }
303
- const opts90s = { HASH256: sha256, HASH512: sha512, KDF: sha256, XOF: XOF_AES, PRF };
304
- export const kyber512_90s = /* @__PURE__ */ createKyber({
305
- ...opts90s,
306
- ...PARAMS[512],
307
- });
308
- export const kyber768_90s = /* @__PURE__ */ createKyber({
309
- ...opts90s,
310
- ...PARAMS[768],
311
- });
312
- export const kyber1024_90s = /* @__PURE__ */ createKyber({
313
- ...opts90s,
314
- ...PARAMS[1024],
315
- });
316
275
  function shakePRF(dkLen, key, nonce) {
317
276
  return shake256
318
277
  .create({ dkLen })
@@ -327,35 +286,19 @@ const opts = {
327
286
  XOF: XOF128,
328
287
  PRF: shakePRF,
329
288
  };
330
- export const kyber512 = /* @__PURE__ */ createKyber({
331
- ...opts,
332
- ...PARAMS[512],
333
- });
334
- export const kyber768 = /* @__PURE__ */ createKyber({
335
- ...opts,
336
- ...PARAMS[768],
337
- });
338
- export const kyber1024 = /* @__PURE__ */ createKyber({
339
- ...opts,
340
- ...PARAMS[1024],
341
- });
342
289
  /**
343
- * FIPS-203 (draft) ML-KEM.
344
- * Unsafe: we can't cross-verify, because there are no test vectors or other implementations.
290
+ * FIPS-203 ML-KEM.
345
291
  */
346
292
  export const ml_kem512 = /* @__PURE__ */ createKyber({
347
293
  ...opts,
348
294
  ...PARAMS[512],
349
- FIPS203: true,
350
295
  });
351
296
  export const ml_kem768 = /* @__PURE__ */ createKyber({
352
297
  ...opts,
353
298
  ...PARAMS[768],
354
- FIPS203: true,
355
299
  });
356
300
  export const ml_kem1024 = /* @__PURE__ */ createKyber({
357
301
  ...opts,
358
302
  ...PARAMS[1024],
359
- FIPS203: true,
360
303
  });
361
304
  //# sourceMappingURL=ml-kem.js.map