@noble/post-quantum 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/ml-dsa.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ml-dsa.js","sourceRoot":"","sources":["src/ml-dsa.ts"],"names":[],"mappings":";;;AAAA,4EAA4E;AAC5E,6CAA8C;AAC9C,iDAA2E;AAC3E,yCASoB;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;AACL,QAAA,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,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,EAAE,EAAE,CAAC,EAAE,CAAC,E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EAAE,IAAI;CACd,CAAC,CAAC"}
package/ml-kem.d.ts ADDED
@@ -0,0 +1,134 @@
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
+ export declare const kyber512_90s: {
13
+ publicKeyLen: number;
14
+ msgLen: number;
15
+ keygen: (seed?: Uint8Array) => {
16
+ publicKey: Uint8Array;
17
+ secretKey: Uint8Array;
18
+ };
19
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
20
+ cipherText: Uint8Array;
21
+ sharedSecret: Uint8Array;
22
+ };
23
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
24
+ };
25
+ export declare const kyber768_90s: {
26
+ publicKeyLen: number;
27
+ msgLen: number;
28
+ keygen: (seed?: Uint8Array) => {
29
+ publicKey: Uint8Array;
30
+ secretKey: Uint8Array;
31
+ };
32
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
33
+ cipherText: Uint8Array;
34
+ sharedSecret: Uint8Array;
35
+ };
36
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
37
+ };
38
+ export declare const kyber1024_90s: {
39
+ publicKeyLen: number;
40
+ msgLen: number;
41
+ keygen: (seed?: Uint8Array) => {
42
+ publicKey: Uint8Array;
43
+ secretKey: Uint8Array;
44
+ };
45
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
46
+ cipherText: Uint8Array;
47
+ sharedSecret: Uint8Array;
48
+ };
49
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
50
+ };
51
+ export declare const kyber512: {
52
+ publicKeyLen: number;
53
+ msgLen: number;
54
+ keygen: (seed?: Uint8Array) => {
55
+ publicKey: Uint8Array;
56
+ secretKey: Uint8Array;
57
+ };
58
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
59
+ cipherText: Uint8Array;
60
+ sharedSecret: Uint8Array;
61
+ };
62
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
63
+ };
64
+ export declare const kyber768: {
65
+ publicKeyLen: number;
66
+ msgLen: number;
67
+ keygen: (seed?: Uint8Array) => {
68
+ publicKey: Uint8Array;
69
+ secretKey: Uint8Array;
70
+ };
71
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
72
+ cipherText: Uint8Array;
73
+ sharedSecret: Uint8Array;
74
+ };
75
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
76
+ };
77
+ export declare const kyber1024: {
78
+ publicKeyLen: number;
79
+ msgLen: number;
80
+ keygen: (seed?: Uint8Array) => {
81
+ publicKey: Uint8Array;
82
+ secretKey: Uint8Array;
83
+ };
84
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
85
+ cipherText: Uint8Array;
86
+ sharedSecret: Uint8Array;
87
+ };
88
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
89
+ };
90
+ /**
91
+ * FIPS-203 (draft) ML-KEM.
92
+ * Unsafe: we can't cross-verify, because there are no test vectors or other implementations.
93
+ */
94
+ export declare const ml_kem512: {
95
+ publicKeyLen: number;
96
+ msgLen: number;
97
+ keygen: (seed?: Uint8Array) => {
98
+ publicKey: Uint8Array;
99
+ secretKey: Uint8Array;
100
+ };
101
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
102
+ cipherText: Uint8Array;
103
+ sharedSecret: Uint8Array;
104
+ };
105
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
106
+ };
107
+ export declare const ml_kem768: {
108
+ publicKeyLen: number;
109
+ msgLen: number;
110
+ keygen: (seed?: Uint8Array) => {
111
+ publicKey: Uint8Array;
112
+ secretKey: Uint8Array;
113
+ };
114
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
115
+ cipherText: Uint8Array;
116
+ sharedSecret: Uint8Array;
117
+ };
118
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
119
+ };
120
+ export declare const ml_kem1024: {
121
+ publicKeyLen: number;
122
+ msgLen: number;
123
+ keygen: (seed?: Uint8Array) => {
124
+ publicKey: Uint8Array;
125
+ secretKey: Uint8Array;
126
+ };
127
+ encapsulate: (publicKey: Uint8Array, msg?: Uint8Array) => {
128
+ cipherText: Uint8Array;
129
+ sharedSecret: Uint8Array;
130
+ };
131
+ decapsulate: (cipherText: Uint8Array, secretKey: Uint8Array) => Uint8Array;
132
+ };
133
+ export {};
134
+ //# 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":"AA0DA,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;AA4QX,eAAO,MAAM,YAAY;;;;;;;6BA5DI,UAAU;;;;8BA2BT,UAAU,aAAa,UAAU;CAoC7D,CAAC;AACH,eAAO,MAAM,YAAY;;;;;;;6BAhEI,UAAU;;;;8BA2BT,UAAU,aAAa,UAAU;CAwC7D,CAAC;AACH,eAAO,MAAM,aAAa;;;;;;;6BApEG,UAAU;;;;8BA2BT,UAAU,aAAa,UAAU;CA4C7D,CAAC;AAkBH,eAAO,MAAM,QAAQ;;;;;;;6BAzFQ,UAAU;;;;8BA2BT,UAAU,aAAa,UAAU;CAiE7D,CAAC;AACH,eAAO,MAAM,QAAQ;;;;;;;6BA7FQ,UAAU;;;;8BA2BT,UAAU,aAAa,UAAU;CAqE7D,CAAC;AACH,eAAO,MAAM,SAAS;;;;;;;6BAjGO,UAAU;;;;8BA2BT,UAAU,aAAa,UAAU;CAyE7D,CAAC;AAEH;;;GAGG;AAEH,eAAO,MAAM,SAAS;;;;;;;6BA3GO,UAAU;;;;8BA2BT,UAAU,aAAa,UAAU;CAoF7D,CAAC;AACH,eAAO,MAAM,SAAS;;;;;;;6BAhHO,UAAU;;;;8BA2BT,UAAU,aAAa,UAAU;CAyF7D,CAAC;AACH,eAAO,MAAM,UAAU;;;;;;;6BArHM,UAAU;;;;8BA2BT,UAAU,aAAa,UAAU;CA8F7D,CAAC"}
package/ml-kem.js ADDED
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ml_kem1024 = exports.ml_kem768 = exports.ml_kem512 = exports.kyber1024 = exports.kyber768 = exports.kyber512 = exports.kyber1024_90s = exports.kyber768_90s = exports.kyber512_90s = exports.PARAMS = void 0;
4
+ /*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */
5
+ const aes_1 = require("@noble/ciphers/aes");
6
+ const sha2_1 = require("@noble/hashes/sha2");
7
+ const sha3_1 = require("@noble/hashes/sha3");
8
+ const utils_1 = require("@noble/hashes/utils");
9
+ const _crystals_js_1 = require("./_crystals.js");
10
+ const utils_js_1 = require("./utils.js");
11
+ /*
12
+ Lattice-based key encapsulation mechanism.
13
+ See [official site](https://www.pq-crystals.org/kyber/resources.shtml),
14
+ [repo](https://github.com/pq-crystals/kyber),
15
+ [spec](https://datatracker.ietf.org/doc/draft-cfrg-schwabe-kyber/).
16
+
17
+ Key encapsulation is similar to DH / ECDH (think X25519), with important differences:
18
+
19
+ - We can't verify if it was "Bob" who've sent the shared secret.
20
+ In ECDH, it's always verified
21
+ - Kyber is probabalistic and relies on quality of randomness (CSPRNG).
22
+ ECDH doesn't (to this extent).
23
+ - Kyber decapsulation never throws an error, even when shared secret was
24
+ encrypted by a different public key. It will just return a different
25
+ shared secret
26
+
27
+ There are some concerns with regards to security: see
28
+ [djb blog](https://blog.cr.yp.to/20231003-countcorrectly.html) and
29
+ [mailing list](https://groups.google.com/a/list.nist.gov/g/pqc-forum/c/W2VOzy0wz_E).
30
+
31
+ Three versions are provided:
32
+
33
+ 1. Kyber
34
+ 2. Kyber-90s, using algorithms from 1990s
35
+ 3. ML-KEM aka [FIPS-203](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.203.ipd.pdf)
36
+ */
37
+ const N = 256; // Kyber (not FIPS-203) supports different lengths, but all std modes were using 256
38
+ const Q = 3329; // 13*(2**8)+1, modulo prime
39
+ const F = 3303; // 3303 ≡ 128−1 mod q (FIPS-203)
40
+ const ROOT_OF_UNITY = 17; // ζ = 17 ∈ Zq is a primitive 256-th root of unity modulo Q. ζ**128 ≡−1
41
+ const { mod, nttZetas, NTT, bitsCoder } = (0, _crystals_js_1.genCrystals)({
42
+ N,
43
+ Q,
44
+ F,
45
+ ROOT_OF_UNITY,
46
+ newPoly: (n) => new Uint16Array(n),
47
+ brvBits: 7,
48
+ isKyber: true,
49
+ });
50
+ // prettier-ignore
51
+ exports.PARAMS = {
52
+ 512: { N, Q, K: 2, ETA1: 3, ETA2: 2, du: 10, dv: 4, RBGstrength: 128 },
53
+ 768: { N, Q, K: 3, ETA1: 2, ETA2: 2, du: 10, dv: 4, RBGstrength: 192 },
54
+ 1024: { N, Q, K: 4, ETA1: 2, ETA2: 2, du: 11, dv: 5, RBGstrength: 256 },
55
+ };
56
+ // FIPS-203: compress/decompress
57
+ const compress = (d) => {
58
+ // Special case, no need to compress, pass as is, but strip high bytes on compression
59
+ if (d >= 12)
60
+ return { encode: (i) => i, decode: (i) => i };
61
+ // NOTE: we don't use float arithmetic (forbidden by FIPS-203 and high chance of bugs).
62
+ // Comments map to python implementation in RFC (draft-cfrg-schwabe-kyber)
63
+ // const round = (i: number) => Math.floor(i + 0.5) | 0;
64
+ const a = 2 ** (d - 1);
65
+ return {
66
+ // const compress = (i: number) => round((2 ** d / Q) * i) % 2 ** d;
67
+ encode: (i) => ((i << d) + Q / 2) / Q,
68
+ // const decompress = (i: number) => round((Q / 2 ** d) * i);
69
+ decode: (i) => (i * Q + a) >>> d,
70
+ };
71
+ };
72
+ // NOTE: we merge encoding and compress because it is faster, also both require same d param
73
+ // Converts between bytes and d-bits compressed representation. Kinda like convertRadix2 from @scure/base
74
+ // decode(encode(t)) == t, but there is loss of information on encode(decode(t))
75
+ const polyCoder = (d) => bitsCoder(d, compress(d));
76
+ function polyAdd(a, b) {
77
+ for (let i = 0; i < N; i++)
78
+ a[i] = mod(a[i] + b[i]); // a += b
79
+ }
80
+ function polySub(a, b) {
81
+ for (let i = 0; i < N; i++)
82
+ a[i] = mod(a[i] - b[i]); // a -= b
83
+ }
84
+ // FIPS-203: Computes the product of two degree-one polynomials with respect to a quadratic modulus
85
+ function BaseCaseMultiply(a0, a1, b0, b1, zeta) {
86
+ const c0 = mod(a1 * b1 * zeta + a0 * b0);
87
+ const c1 = mod(a0 * b1 + a1 * b0);
88
+ return { c0, c1 };
89
+ }
90
+ // FIPS-203: Computes the product (in the ring Tq) of two NTT representations. NOTE: works inplace for f
91
+ // NOTE: since multiply defined only for NTT representation, we need to convert to NTT, multiply and convert back
92
+ function MultiplyNTTs(f, g) {
93
+ for (let i = 0; i < N / 2; i++) {
94
+ let z = nttZetas[64 + (i >> 1)];
95
+ if (i & 1)
96
+ z = -z;
97
+ const { c0, c1 } = BaseCaseMultiply(f[2 * i + 0], f[2 * i + 1], g[2 * i + 0], g[2 * i + 1], z);
98
+ f[2 * i + 0] = c0;
99
+ f[2 * i + 1] = c1;
100
+ }
101
+ return f;
102
+ }
103
+ // Return poly in NTT representation
104
+ function SampleNTT(xof) {
105
+ const r = new Uint16Array(N);
106
+ for (let j = 0; j < N;) {
107
+ const b = xof();
108
+ if (b.length % 3)
109
+ throw new Error('SampleNTT: unaligned block');
110
+ for (let i = 0; j < N && i + 3 <= b.length; i += 3) {
111
+ const d1 = ((b[i + 0] >> 0) | (b[i + 1] << 8)) & 0xfff;
112
+ const d2 = ((b[i + 1] >> 4) | (b[i + 2] << 4)) & 0xfff;
113
+ if (d1 < Q)
114
+ r[j++] = d1;
115
+ if (j < N && d2 < Q)
116
+ r[j++] = d2;
117
+ }
118
+ }
119
+ return r;
120
+ }
121
+ // Sampling from the centered binomial distribution
122
+ // Returns poly with small coefficients (noise/errors)
123
+ function sampleCBD(PRF, seed, nonce, eta) {
124
+ const buf = PRF((eta * N) / 4, seed, nonce);
125
+ const r = new Uint16Array(N);
126
+ const b32 = (0, utils_1.u32)(buf);
127
+ let len = 0;
128
+ for (let i = 0, p = 0, bb = 0, t0 = 0; i < b32.length; i++) {
129
+ let b = b32[i];
130
+ for (let j = 0; j < 32; j++) {
131
+ bb += b & 1;
132
+ b >>= 1;
133
+ len += 1;
134
+ if (len === eta) {
135
+ t0 = bb;
136
+ bb = 0;
137
+ }
138
+ else if (len === 2 * eta) {
139
+ r[p++] = mod(t0 - bb);
140
+ bb = 0;
141
+ len = 0;
142
+ }
143
+ }
144
+ }
145
+ if (len)
146
+ throw new Error(`sampleCBD: leftover bits: ${len}`);
147
+ return r;
148
+ }
149
+ // K-PKE
150
+ // As per FIPS-203, it doesn't perform any input validation and can't be used in standalone fashion.
151
+ const genKPKE = (opts) => {
152
+ const { K, PRF, XOF, HASH512, ETA1, ETA2, du, dv, FIPS203 } = opts;
153
+ const poly1 = polyCoder(1);
154
+ const polyV = polyCoder(dv);
155
+ const polyU = polyCoder(du);
156
+ const publicCoder = (0, utils_js_1.splitCoder)((0, utils_js_1.vecCoder)(polyCoder(12), K), 32);
157
+ const secretCoder = (0, utils_js_1.vecCoder)(polyCoder(12), K);
158
+ const cipherCoder = (0, utils_js_1.splitCoder)((0, utils_js_1.vecCoder)(polyU, K), polyV);
159
+ const seedCoder = (0, utils_js_1.splitCoder)(32, 32);
160
+ return {
161
+ secretCoder,
162
+ secretKeyLen: secretCoder.bytesLen,
163
+ publicKeyLen: publicCoder.bytesLen,
164
+ cipherTextLen: cipherCoder.bytesLen,
165
+ keygen: (seed) => {
166
+ const [rho, sigma] = seedCoder.decode(HASH512(seed));
167
+ const sHat = [];
168
+ const tHat = [];
169
+ for (let i = 0; i < K; i++)
170
+ sHat.push(NTT.encode(sampleCBD(PRF, sigma, i, ETA1)));
171
+ const x = XOF(rho);
172
+ for (let i = 0; i < K; i++) {
173
+ const e = NTT.encode(sampleCBD(PRF, sigma, K + i, ETA1));
174
+ for (let j = 0; j < K; j++) {
175
+ const aji = SampleNTT(FIPS203 ? x.get(i, j) : x.get(j, i)); // A[j][i], inplace
176
+ polyAdd(e, MultiplyNTTs(aji, sHat[j]));
177
+ }
178
+ tHat.push(e); // t ← A ◦ s + e
179
+ }
180
+ x.clean();
181
+ const res = {
182
+ publicKey: publicCoder.encode([tHat, rho]),
183
+ secretKey: secretCoder.encode(sHat),
184
+ };
185
+ (0, utils_js_1.cleanBytes)(rho, sigma, sHat, tHat);
186
+ return res;
187
+ },
188
+ encrypt: (publicKey, msg, seed) => {
189
+ const [tHat, rho] = publicCoder.decode(publicKey);
190
+ const rHat = [];
191
+ for (let i = 0; i < K; i++)
192
+ rHat.push(NTT.encode(sampleCBD(PRF, seed, i, ETA1)));
193
+ const x = XOF(rho);
194
+ const tmp2 = new Uint16Array(N);
195
+ const u = [];
196
+ for (let i = 0; i < K; i++) {
197
+ const e1 = sampleCBD(PRF, seed, K + i, ETA2);
198
+ const tmp = new Uint16Array(N);
199
+ for (let j = 0; j < K; j++) {
200
+ const aij = SampleNTT(FIPS203 ? x.get(j, i) : x.get(i, j)); // A[i][j], inplace
201
+ polyAdd(tmp, MultiplyNTTs(aij, rHat[j])); // t += aij * rHat[j]
202
+ }
203
+ polyAdd(e1, NTT.decode(tmp)); // e1 += tmp
204
+ u.push(e1);
205
+ polyAdd(tmp2, MultiplyNTTs(tHat[i], rHat[i])); // t2 += tHat[i] * rHat[i]
206
+ tmp.fill(0);
207
+ }
208
+ x.clean();
209
+ const e2 = sampleCBD(PRF, seed, 2 * K, ETA2);
210
+ polyAdd(e2, NTT.decode(tmp2)); // e2 += tmp2
211
+ const v = poly1.decode(msg); // encode plaintext m into polynomial v
212
+ polyAdd(v, e2); // v += e2
213
+ (0, utils_js_1.cleanBytes)(tHat, rHat, tmp2, e2);
214
+ return cipherCoder.encode([u, v]);
215
+ },
216
+ decrypt: (cipherText, privateKey) => {
217
+ const [u, v] = cipherCoder.decode(cipherText);
218
+ const sk = secretCoder.decode(privateKey); // s ← ByteDecode_12(dkPKE)
219
+ const tmp = new Uint16Array(N);
220
+ for (let i = 0; i < K; i++)
221
+ polyAdd(tmp, MultiplyNTTs(sk[i], NTT.encode(u[i]))); // tmp += sk[i] * u[i]
222
+ polySub(v, NTT.decode(tmp)); // v += tmp
223
+ (0, utils_js_1.cleanBytes)(tmp, sk, u);
224
+ return poly1.encode(v);
225
+ },
226
+ };
227
+ };
228
+ function createKyber(opts) {
229
+ const KPKE = genKPKE(opts);
230
+ const { HASH256, HASH512, KDF, FIPS203 } = opts;
231
+ const { secretCoder: KPKESecretCoder, cipherTextLen } = KPKE;
232
+ const publicKeyLen = KPKE.publicKeyLen; // 384*K+32
233
+ const secretCoder = (0, utils_js_1.splitCoder)(KPKE.secretKeyLen, KPKE.publicKeyLen, 32, 32);
234
+ const secretKeyLen = secretCoder.bytesLen;
235
+ const msgLen = 32;
236
+ return {
237
+ publicKeyLen,
238
+ msgLen,
239
+ keygen: (seed = (0, utils_js_1.randomBytes)(64)) => {
240
+ (0, utils_js_1.ensureBytes)(seed, 64);
241
+ const { publicKey, secretKey: sk } = KPKE.keygen(seed.subarray(0, 32));
242
+ const publicKeyHash = HASH256(publicKey);
243
+ // (dkPKE||ek||H(ek)||z)
244
+ const secretKey = secretCoder.encode([sk, publicKey, publicKeyHash, seed.subarray(32)]);
245
+ (0, utils_js_1.cleanBytes)(sk, publicKeyHash);
246
+ return { publicKey, secretKey };
247
+ },
248
+ encapsulate: (publicKey, msg = (0, utils_js_1.randomBytes)(32)) => {
249
+ (0, utils_js_1.ensureBytes)(publicKey, publicKeyLen);
250
+ (0, utils_js_1.ensureBytes)(msg, msgLen);
251
+ if (!FIPS203)
252
+ msg = HASH256(msg); // NOTE: ML-KEM doesn't have this step!
253
+ else {
254
+ // FIPS-203 includes additional verification check for modulus
255
+ const eke = publicKey.subarray(0, 384 * opts.K);
256
+ const ek = KPKESecretCoder.encode(KPKESecretCoder.decode(eke.slice())); // Copy because of inplace encoding
257
+ // (Modulus check.) Perform the computation ek ← ByteEncode12(ByteDecode12(eke)).
258
+ // If ek = ̸ eke, the input is invalid. (See Section 4.2.1.)
259
+ if (!(0, utils_js_1.equalBytes)(ek, eke)) {
260
+ (0, utils_js_1.cleanBytes)(ek);
261
+ throw new Error('ML-KEM.encapsulate: wrong publicKey modulus');
262
+ }
263
+ (0, utils_js_1.cleanBytes)(ek);
264
+ }
265
+ const kr = HASH512.create().update(msg).update(HASH256(publicKey)).digest(); // derive randomness
266
+ const cipherText = KPKE.encrypt(publicKey, msg, kr.subarray(32, 64));
267
+ if (FIPS203)
268
+ return { cipherText, sharedSecret: kr.subarray(0, 32) };
269
+ const cipherTextHash = HASH256(cipherText);
270
+ const sharedSecret = KDF.create({})
271
+ .update(kr.subarray(0, 32))
272
+ .update(cipherTextHash)
273
+ .digest();
274
+ (0, utils_js_1.cleanBytes)(kr, cipherTextHash);
275
+ return { cipherText, sharedSecret };
276
+ },
277
+ decapsulate: (cipherText, secretKey) => {
278
+ (0, utils_js_1.ensureBytes)(secretKey, secretKeyLen); // 768*k + 96
279
+ (0, utils_js_1.ensureBytes)(cipherText, cipherTextLen); // 32(du*k + dv)
280
+ const [sk, publicKey, publicKeyHash, z] = secretCoder.decode(secretKey);
281
+ const msg = KPKE.decrypt(cipherText, sk);
282
+ const kr = HASH512.create().update(msg).update(publicKeyHash).digest(); // derive randomness, Khat, rHat = G(mHat || h)
283
+ const Khat = kr.subarray(0, 32);
284
+ const cipherText2 = KPKE.encrypt(publicKey, msg, kr.subarray(32, 64)); // re-encrypt using the derived randomness
285
+ const isValid = (0, utils_js_1.equalBytes)(cipherText, cipherText2); // if ciphertexts do not match, “implicitly reject”
286
+ if (FIPS203) {
287
+ const Kbar = KDF.create({ dkLen: 32 }).update(z).update(cipherText).digest();
288
+ (0, utils_js_1.cleanBytes)(msg, cipherText2, !isValid ? Khat : Kbar);
289
+ return isValid ? Khat : Kbar;
290
+ }
291
+ const cipherTextHash = HASH256(cipherText);
292
+ const sharedSecret = KDF.create({ dkLen: 32 })
293
+ .update(isValid ? Khat : z)
294
+ .update(cipherTextHash)
295
+ .digest();
296
+ (0, utils_js_1.cleanBytes)(msg, cipherTextHash, cipherText2, Khat, z);
297
+ return sharedSecret;
298
+ },
299
+ };
300
+ }
301
+ function PRF(l, key, nonce) {
302
+ const _nonce = new Uint8Array(16);
303
+ _nonce[0] = nonce;
304
+ return (0, aes_1.ctr)(key, _nonce).encrypt(new Uint8Array(l));
305
+ }
306
+ const opts90s = { HASH256: sha2_1.sha256, HASH512: sha2_1.sha512, KDF: sha2_1.sha256, XOF: _crystals_js_1.XOF_AES, PRF };
307
+ exports.kyber512_90s = createKyber({
308
+ ...opts90s,
309
+ ...exports.PARAMS[512],
310
+ });
311
+ exports.kyber768_90s = createKyber({
312
+ ...opts90s,
313
+ ...exports.PARAMS[768],
314
+ });
315
+ exports.kyber1024_90s = createKyber({
316
+ ...opts90s,
317
+ ...exports.PARAMS[1024],
318
+ });
319
+ function shakePRF(dkLen, key, nonce) {
320
+ return sha3_1.shake256
321
+ .create({ dkLen })
322
+ .update(key)
323
+ .update(new Uint8Array([nonce]))
324
+ .digest();
325
+ }
326
+ const opts = {
327
+ HASH256: sha3_1.sha3_256,
328
+ HASH512: sha3_1.sha3_512,
329
+ KDF: sha3_1.shake256,
330
+ XOF: _crystals_js_1.XOF128,
331
+ PRF: shakePRF,
332
+ };
333
+ exports.kyber512 = createKyber({
334
+ ...opts,
335
+ ...exports.PARAMS[512],
336
+ });
337
+ exports.kyber768 = createKyber({
338
+ ...opts,
339
+ ...exports.PARAMS[768],
340
+ });
341
+ exports.kyber1024 = createKyber({
342
+ ...opts,
343
+ ...exports.PARAMS[1024],
344
+ });
345
+ /**
346
+ * FIPS-203 (draft) ML-KEM.
347
+ * Unsafe: we can't cross-verify, because there are no test vectors or other implementations.
348
+ */
349
+ exports.ml_kem512 = createKyber({
350
+ ...opts,
351
+ ...exports.PARAMS[512],
352
+ FIPS203: true,
353
+ });
354
+ exports.ml_kem768 = createKyber({
355
+ ...opts,
356
+ ...exports.PARAMS[768],
357
+ FIPS203: true,
358
+ });
359
+ exports.ml_kem1024 = createKyber({
360
+ ...opts,
361
+ ...exports.PARAMS[1024],
362
+ FIPS203: true,
363
+ });
364
+ //# sourceMappingURL=ml-kem.js.map
package/ml-kem.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ml-kem.js","sourceRoot":"","sources":["src/ml-kem.ts"],"names":[],"mappings":";;;AAAA,4EAA4E;AAC5E,4CAAyC;AACzC,6CAAoD;AACpD,6CAAkE;AAClE,+CAAoF;AACpF,iDAAmE;AACnE,yCAQoB;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;EAyBE;AAEF,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,oFAAoF;AACnG,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,4BAA4B;AAC5C,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,gCAAgC;AAChD,MAAM,aAAa,GAAG,EAAE,CAAC,CAAC,uEAAuE;AACjG,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,IAAA,0BAAW,EAAC;IACpD,CAAC;IACD,CAAC;IACD,CAAC;IACD,aAAa;IACb,OAAO,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,W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