@noble/post-quantum 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/esm/slh-dsa.js ADDED
@@ -0,0 +1,602 @@
1
+ /*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */
2
+ import { HMAC } from '@noble/hashes/hmac';
3
+ import { sha256, sha512 } from '@noble/hashes/sha2';
4
+ import { shake256 } from '@noble/hashes/sha3';
5
+ import { bytesToHex, hexToBytes, createView, concatBytes, u32 } from '@noble/hashes/utils';
6
+ import { cleanBytes, ensureBytes, equalBytes, getMask, randomBytes, splitCoder, vecCoder, } from './utils.js';
7
+ export const PARAMS = {
8
+ '128f': { W: 16, N: 16, H: 66, D: 22, K: 33, A: 6 },
9
+ '128s': { W: 16, N: 16, H: 63, D: 7, K: 14, A: 12 },
10
+ '192f': { W: 16, N: 24, H: 66, D: 22, K: 33, A: 8 },
11
+ '192s': { W: 16, N: 24, H: 63, D: 7, K: 17, A: 14 },
12
+ '256f': { W: 16, N: 32, H: 68, D: 17, K: 35, A: 9 },
13
+ '256s': { W: 16, N: 32, H: 64, D: 8, K: 22, A: 14 },
14
+ };
15
+ function hexToNumber(hex) {
16
+ if (typeof hex !== 'string')
17
+ throw new Error('hex string expected, got ' + typeof hex);
18
+ // Big Endian
19
+ return BigInt(hex === '' ? '0' : `0x${hex}`);
20
+ }
21
+ // BE: Big Endian, LE: Little Endian
22
+ function bytesToNumberBE(bytes) {
23
+ return hexToNumber(bytesToHex(bytes));
24
+ }
25
+ function numberToBytesBE(n, len) {
26
+ return hexToBytes(n.toString(16).padStart(len * 2, '0'));
27
+ }
28
+ // Same as bitsCoder.decode, but bits are BE instead of LE (so we cannot re-use it).
29
+ // NOTE: difference happens only if d < 8.
30
+ const base_2bBE = (N, d) => {
31
+ const mask = getMask(d);
32
+ return (bytes) => {
33
+ const r = new Uint32Array(N);
34
+ for (let i = 0, buf = 0, bufLen = 0, pos = 0; i < bytes.length; i++) {
35
+ buf |= bytes[i] << bufLen;
36
+ bufLen += 8;
37
+ for (; bufLen >= d; bufLen -= d)
38
+ r[pos++] = (buf >>> (bufLen - d)) & mask;
39
+ buf &= getMask(bufLen);
40
+ }
41
+ return r;
42
+ };
43
+ };
44
+ // Same as bitsCoder.decode, but maybe spec will change and unify with base2bBE.
45
+ const base_2bLE = (N, d) => {
46
+ const mask = getMask(d);
47
+ return (bytes) => {
48
+ const r = new Uint32Array(N);
49
+ for (let i = 0, buf = 0, bufLen = 0, pos = 0; i < bytes.length; i++) {
50
+ buf |= bytes[i] << bufLen;
51
+ bufLen += 8;
52
+ for (; bufLen >= d; bufLen -= d, buf >>= d)
53
+ r[pos++] = buf & mask;
54
+ }
55
+ return r;
56
+ };
57
+ };
58
+ function getMaskBig(bits) {
59
+ return (1n << BigInt(bits)) - 1n; // 4 -> 0b1111
60
+ }
61
+ function gen(opts, hashOpts) {
62
+ const { N, W, H, D, K, A } = opts;
63
+ const getContext = hashOpts.getContext(opts);
64
+ if (W !== 16)
65
+ throw new Error('Unsupported Winternitz parameter');
66
+ const WOTS_LOGW = 4;
67
+ const WOTS_LEN1 = Math.floor((8 * N) / WOTS_LOGW);
68
+ const WOTS_LEN2 = N <= 8 ? 2 : N <= 136 ? 3 : 4;
69
+ const TREE_HEIGHT = Math.floor(H / D);
70
+ const WOTS_LEN = WOTS_LEN1 + WOTS_LEN2;
71
+ let ADDR_BYTES = 22;
72
+ let OFFSET_LAYER = 0;
73
+ let OFFSET_TREE = 1;
74
+ let OFFSET_TYPE = 9;
75
+ let OFFSET_KP_ADDR2 = 12;
76
+ let OFFSET_KP_ADDR1 = 13;
77
+ let OFFSET_CHAIN_ADDR = 17;
78
+ let OFFSET_TREE_INDEX = 18;
79
+ let OFFSET_HASH_ADDR = 21;
80
+ if (!hashOpts.isCompressed) {
81
+ ADDR_BYTES = 32;
82
+ OFFSET_LAYER += 3;
83
+ OFFSET_TREE += 7;
84
+ OFFSET_TYPE += 10;
85
+ OFFSET_KP_ADDR2 += 10;
86
+ OFFSET_KP_ADDR1 += 10;
87
+ OFFSET_CHAIN_ADDR += 10;
88
+ OFFSET_TREE_INDEX += 10;
89
+ OFFSET_HASH_ADDR += 10;
90
+ }
91
+ const setAddr = (opts, addr = new Uint8Array(ADDR_BYTES)) => {
92
+ const { type, height, tree, layer, index, chain, hash, keypair } = opts;
93
+ const { subtreeAddr, keypairAddr } = opts;
94
+ const v = createView(addr);
95
+ if (height !== undefined)
96
+ addr[OFFSET_CHAIN_ADDR] = height;
97
+ if (layer !== undefined)
98
+ addr[OFFSET_LAYER] = layer;
99
+ if (type !== undefined)
100
+ addr[OFFSET_TYPE] = type;
101
+ if (chain !== undefined)
102
+ addr[OFFSET_CHAIN_ADDR] = chain;
103
+ if (hash !== undefined)
104
+ addr[OFFSET_HASH_ADDR] = hash;
105
+ if (index !== undefined)
106
+ v.setUint32(OFFSET_TREE_INDEX, index, false);
107
+ if (subtreeAddr)
108
+ addr.set(subtreeAddr.subarray(0, OFFSET_TREE + 8));
109
+ if (tree !== undefined)
110
+ v.setBigUint64(OFFSET_TREE, tree, false);
111
+ if (keypair !== undefined) {
112
+ addr[OFFSET_KP_ADDR1] = keypair;
113
+ if (TREE_HEIGHT > 8)
114
+ addr[OFFSET_KP_ADDR2] = keypair >>> 8;
115
+ }
116
+ if (keypairAddr) {
117
+ addr.set(keypairAddr.subarray(0, OFFSET_TREE + 8));
118
+ addr[OFFSET_KP_ADDR1] = keypairAddr[OFFSET_KP_ADDR1];
119
+ if (TREE_HEIGHT > 8)
120
+ addr[OFFSET_KP_ADDR2] = keypairAddr[OFFSET_KP_ADDR2];
121
+ }
122
+ return addr;
123
+ };
124
+ const chainCoder = base_2bBE(WOTS_LEN2, WOTS_LOGW);
125
+ const chainLengths = (msg) => {
126
+ const W1 = base_2bBE(WOTS_LEN1, WOTS_LOGW)(msg);
127
+ let csum = 0;
128
+ for (let i = 0; i < W1.length; i++)
129
+ csum += W - 1 - W1[i]; // ▷ Compute checksum
130
+ csum <<= (8 - ((WOTS_LEN2 * WOTS_LOGW) % 8)) % 8; // csum ← csum ≪ ((8 − ((len2 · lg(w)) mod 8)) mod 8
131
+ // Checksum to base(LOG_W)
132
+ const W2 = chainCoder(numberToBytesBE(csum, Math.ceil((WOTS_LEN2 * WOTS_LOGW) / 8)));
133
+ // W1 || W2 (concatBytes cannot concat TypedArrays)
134
+ const lengths = new Uint32Array(WOTS_LEN);
135
+ lengths.set(W1);
136
+ lengths.set(W2, W1.length);
137
+ return lengths;
138
+ };
139
+ // Hm, why BE vs LE?
140
+ const msgCoder = base_2bLE(K, A);
141
+ const messageToIndices = (msg) => msgCoder(msg);
142
+ const TREE_BITS = TREE_HEIGHT * (D - 1);
143
+ const LEAF_BITS = TREE_HEIGHT;
144
+ const hashMsgCoder = splitCoder(Math.ceil((A * K) / 8), Math.ceil(TREE_BITS / 8), Math.ceil(TREE_HEIGHT / 8));
145
+ const hashMessage = (R, pkSeed, msg, context) => {
146
+ const digest = context.Hmsg(R, pkSeed, msg, hashMsgCoder.bytesLen); // digest ← Hmsg(R, PK.seed, PK.root, M)
147
+ const [md, tmpIdxTree, tmpIdxLeaf] = hashMsgCoder.decode(digest);
148
+ const tree = bytesToNumberBE(tmpIdxTree) & getMaskBig(TREE_BITS);
149
+ const leafIdx = Number(bytesToNumberBE(tmpIdxLeaf)) & getMask(LEAF_BITS);
150
+ return { tree, leafIdx, md };
151
+ };
152
+ const treehash = (height, fn) => function treehash_i(context, leafIdx, idxOffset, treeAddr, info) {
153
+ const maxIdx = (1 << height) - 1;
154
+ const stack = new Uint8Array(height * N);
155
+ const authPath = new Uint8Array(height * N);
156
+ for (let idx = 0;; idx++) {
157
+ const current = new Uint8Array(2 * N);
158
+ const cur0 = current.subarray(0, N);
159
+ const cur1 = current.subarray(N);
160
+ const addrOffset = idx + idxOffset;
161
+ cur1.set(fn(leafIdx, addrOffset, context, info));
162
+ let h = 0;
163
+ for (let i = idx, o = idxOffset, l = leafIdx;; h++, i >>>= 1, l >>>= 1, o >>>= 1) {
164
+ if (h === height)
165
+ return { root: cur1, authPath }; // Returns from here
166
+ if ((i ^ l) === 1)
167
+ authPath.subarray(h * N).set(cur1); // authPath.push(cur1)
168
+ if ((i & 1) === 0 && idx < maxIdx)
169
+ break;
170
+ setAddr({ height: h + 1, index: (i >> 1) + (o >> 1) }, treeAddr);
171
+ cur0.set(stack.subarray(h * N).subarray(0, N));
172
+ cur1.set(context.thashN(2, current, treeAddr));
173
+ }
174
+ stack.subarray(h * N).set(cur1); // stack.push(cur1)
175
+ }
176
+ // @ts-ignore
177
+ throw new Error('Unreachable code path reached, report this error');
178
+ };
179
+ const wotsTreehash = treehash(TREE_HEIGHT, (leafIdx, addrOffset, context, info) => {
180
+ const wotsPk = new Uint8Array(WOTS_LEN * N);
181
+ const wotsKmask = addrOffset === leafIdx ? 0 : ~0 >>> 0;
182
+ setAddr({ keypair: addrOffset }, info.leafAddr);
183
+ setAddr({ keypair: addrOffset }, info.pkAddr);
184
+ for (let i = 0; i < WOTS_LEN; i++) {
185
+ const wotsK = info.wotsSteps[i] | wotsKmask;
186
+ const pk = wotsPk.subarray(i * N, (i + 1) * N);
187
+ setAddr({ chain: i, hash: 0, type: 5 /* AddressType.WOTSPRF */ }, info.leafAddr);
188
+ pk.set(context.PRFaddr(info.leafAddr));
189
+ setAddr({ type: 0 /* AddressType.WOTS */ }, info.leafAddr);
190
+ for (let k = 0;; k++) {
191
+ if (k === wotsK)
192
+ info.wotsSig.subarray(i * N).set(pk); //wotsSig.push()
193
+ if (k === W - 1)
194
+ break;
195
+ setAddr({ hash: k }, info.leafAddr);
196
+ pk.set(context.thash1(pk, info.leafAddr));
197
+ }
198
+ }
199
+ return context.thashN(WOTS_LEN, wotsPk, info.pkAddr);
200
+ });
201
+ const forsTreehash = treehash(A, (_, addrOffset, context, forsLeafAddr) => {
202
+ setAddr({ type: 6 /* AddressType.FORSPRF */, index: addrOffset }, forsLeafAddr);
203
+ const prf = context.PRFaddr(forsLeafAddr);
204
+ setAddr({ type: 3 /* AddressType.FORSTREE */ }, forsLeafAddr);
205
+ return context.thash1(prf, forsLeafAddr);
206
+ });
207
+ const merkleSign = (context, wotsAddr, treeAddr, leafIdx, prevRoot = new Uint8Array(N)) => {
208
+ setAddr({ type: 2 /* AddressType.HASHTREE */ }, treeAddr);
209
+ // State variables
210
+ const info = {
211
+ wotsSig: new Uint8Array(wotsCoder.bytesLen),
212
+ wotsSteps: chainLengths(prevRoot),
213
+ leafAddr: setAddr({ subtreeAddr: wotsAddr }),
214
+ pkAddr: setAddr({ type: 1 /* AddressType.WOTSPK */, subtreeAddr: wotsAddr }),
215
+ };
216
+ const { root, authPath } = wotsTreehash(context, leafIdx, 0, treeAddr, info);
217
+ return {
218
+ root,
219
+ sigWots: info.wotsSig.subarray(0, WOTS_LEN * N),
220
+ sigAuth: authPath,
221
+ };
222
+ };
223
+ const computeRoot = (leaf, leafIdx, idxOffset, authPath, treeHeight, context, addr) => {
224
+ const buffer = new Uint8Array(2 * N);
225
+ const b0 = buffer.subarray(0, N);
226
+ const b1 = buffer.subarray(N, 2 * N);
227
+ // First iter
228
+ if ((leafIdx & 1) !== 0) {
229
+ b1.set(leaf.subarray(0, N));
230
+ b0.set(authPath.subarray(0, N));
231
+ }
232
+ else {
233
+ b0.set(leaf.subarray(0, N));
234
+ b1.set(authPath.subarray(0, N));
235
+ }
236
+ leafIdx >>>= 1;
237
+ idxOffset >>>= 1;
238
+ // Rest
239
+ for (let i = 0; i < treeHeight - 1; i++, leafIdx >>= 1, idxOffset >>= 1) {
240
+ setAddr({ height: i + 1, index: leafIdx + idxOffset }, addr);
241
+ const a = authPath.subarray((i + 1) * N, (i + 2) * N);
242
+ if ((leafIdx & 1) !== 0) {
243
+ b1.set(context.thashN(2, buffer, addr));
244
+ b0.set(a);
245
+ }
246
+ else {
247
+ buffer.set(context.thashN(2, buffer, addr));
248
+ b1.set(a);
249
+ }
250
+ }
251
+ // Root
252
+ setAddr({ height: treeHeight, index: leafIdx + idxOffset }, addr);
253
+ return context.thashN(2, buffer, addr);
254
+ };
255
+ const seedCoder = splitCoder(N, N, N);
256
+ const publicCoder = splitCoder(N, N);
257
+ const secretCoder = splitCoder(N, N, publicCoder.bytesLen);
258
+ const forsCoder = vecCoder(splitCoder(N, N * A), K);
259
+ const wotsCoder = vecCoder(splitCoder(WOTS_LEN * N, TREE_HEIGHT * N), D);
260
+ const sigCoder = splitCoder(N, forsCoder, wotsCoder); // random || fors || wots
261
+ return {
262
+ seedLen: seedCoder.bytesLen,
263
+ signRandBytes: N,
264
+ keygen(seed = randomBytes(seedCoder.bytesLen)) {
265
+ // Set SK.seed, SK.prf, and PK.seed to random n-byte
266
+ const [secretSeed, secretPRF, publicSeed] = seedCoder.decode(seed);
267
+ const context = getContext(publicSeed, secretSeed);
268
+ // ADRS.setLayerAddress(d − 1)
269
+ const topTreeAddr = setAddr({ layer: D - 1 });
270
+ const wotsAddr = setAddr({ layer: D - 1 });
271
+ //PK.root ←_xmss node(SK.seed, 0, h′, PK.seed, ADRS)
272
+ const { root } = merkleSign(context, wotsAddr, topTreeAddr, ~0 >>> 0);
273
+ const publicKey = publicCoder.encode([publicSeed, root]);
274
+ const secretKey = secretCoder.encode([secretSeed, secretPRF, publicKey]);
275
+ context.clean();
276
+ cleanBytes(secretSeed, secretPRF, root, wotsAddr, topTreeAddr);
277
+ return { publicKey, secretKey };
278
+ },
279
+ sign: (sk, msg, random) => {
280
+ const [skSeed, skPRF, pk] = secretCoder.decode(sk); // todo: fix
281
+ const [pkSeed, _] = publicCoder.decode(pk);
282
+ // Set opt_rand to either PK.seed or to a random n-byte string
283
+ if (!random)
284
+ random = pkSeed.slice();
285
+ ensureBytes(random, N);
286
+ const context = getContext(pkSeed, skSeed);
287
+ // Generate randomizer
288
+ const R = context.PRFmsg(skPRF, random, msg); // R ← PRFmsg(SK.prf, opt_rand, M)
289
+ let { tree, leafIdx, md } = hashMessage(R, pk, msg, context);
290
+ // Create FORS signatures
291
+ const wotsAddr = setAddr({
292
+ type: 0 /* AddressType.WOTS */,
293
+ tree,
294
+ keypair: leafIdx,
295
+ });
296
+ const roots = [];
297
+ const forsLeaf = setAddr({ keypairAddr: wotsAddr });
298
+ const forsTreeAddr = setAddr({ keypairAddr: wotsAddr });
299
+ const indices = messageToIndices(md);
300
+ const fors = [];
301
+ for (let i = 0; i < indices.length; i++) {
302
+ const idxOffset = i << A;
303
+ setAddr({
304
+ type: 6 /* AddressType.FORSPRF */,
305
+ height: 0,
306
+ index: indices[i] + idxOffset,
307
+ }, forsTreeAddr);
308
+ const prf = context.PRFaddr(forsTreeAddr);
309
+ setAddr({ type: 3 /* AddressType.FORSTREE */ }, forsTreeAddr);
310
+ const { root, authPath } = forsTreehash(context, indices[i], idxOffset, forsTreeAddr, forsLeaf);
311
+ roots.push(root);
312
+ fors.push([prf, authPath]);
313
+ }
314
+ const forsPkAddr = setAddr({
315
+ type: 4 /* AddressType.FORSPK */,
316
+ keypairAddr: wotsAddr,
317
+ });
318
+ const root = context.thashN(K, concatBytes(...roots), forsPkAddr);
319
+ // WOTS signatures
320
+ const treeAddr = setAddr({ type: 2 /* AddressType.HASHTREE */ });
321
+ const wots = [];
322
+ for (let i = 0; i < D; i++, tree >>= BigInt(TREE_HEIGHT)) {
323
+ setAddr({ tree, layer: i }, treeAddr);
324
+ setAddr({ subtreeAddr: treeAddr, keypair: leafIdx }, wotsAddr);
325
+ const { sigWots, sigAuth, root: r, } = merkleSign(context, wotsAddr, treeAddr, leafIdx, root);
326
+ root.set(r);
327
+ r.fill(0);
328
+ wots.push([sigWots, sigAuth]);
329
+ leafIdx = Number(tree & getMaskBig(TREE_HEIGHT));
330
+ }
331
+ context.clean();
332
+ const SIG = sigCoder.encode([R, fors, wots]);
333
+ cleanBytes(R, random, treeAddr, wotsAddr, forsLeaf, forsTreeAddr, indices, roots);
334
+ return SIG;
335
+ },
336
+ verify: (publicKey, msg, sig) => {
337
+ const [pkSeed, pubRoot] = publicCoder.decode(publicKey);
338
+ const [random, forsVec, wotsVec] = sigCoder.decode(sig);
339
+ const pk = publicKey;
340
+ if (sig.length !== sigCoder.bytesLen)
341
+ return false;
342
+ const context = getContext(pkSeed);
343
+ let { tree, leafIdx, md } = hashMessage(random, pk, msg, context);
344
+ const wotsAddr = setAddr({
345
+ type: 0 /* AddressType.WOTS */,
346
+ tree,
347
+ keypair: leafIdx,
348
+ });
349
+ // FORS signature
350
+ const roots = [];
351
+ const forsTreeAddr = setAddr({
352
+ type: 3 /* AddressType.FORSTREE */,
353
+ keypairAddr: wotsAddr,
354
+ });
355
+ const indices = messageToIndices(md);
356
+ for (let i = 0; i < forsVec.length; i++) {
357
+ const [prf, authPath] = forsVec[i];
358
+ const idxOffset = i << A;
359
+ setAddr({ height: 0, index: indices[i] + idxOffset }, forsTreeAddr);
360
+ const leaf = context.thash1(prf, forsTreeAddr);
361
+ // Compute inplace, because we need all roots in same byte array
362
+ roots.push(computeRoot(leaf, indices[i], idxOffset, authPath, A, context, forsTreeAddr));
363
+ }
364
+ const forsPkAddr = setAddr({
365
+ type: 4 /* AddressType.FORSPK */,
366
+ keypairAddr: wotsAddr,
367
+ });
368
+ let root = context.thashN(K, concatBytes(...roots), forsPkAddr); // root = thash()
369
+ // WOTS signature
370
+ const treeAddr = setAddr({ type: 2 /* AddressType.HASHTREE */ });
371
+ const wotsPkAddr = setAddr({ type: 1 /* AddressType.WOTSPK */ });
372
+ const wotsPk = new Uint8Array(WOTS_LEN * N);
373
+ for (let i = 0; i < wotsVec.length; i++, tree >>= BigInt(TREE_HEIGHT)) {
374
+ const [wots, sigAuth] = wotsVec[i];
375
+ setAddr({ tree, layer: i }, treeAddr);
376
+ setAddr({ subtreeAddr: treeAddr, keypair: leafIdx }, wotsAddr);
377
+ setAddr({ keypairAddr: wotsAddr }, wotsPkAddr);
378
+ const lengths = chainLengths(root);
379
+ for (let i = 0; i < WOTS_LEN; i++) {
380
+ setAddr({ chain: i }, wotsAddr);
381
+ const steps = W - 1 - lengths[i];
382
+ const start = lengths[i];
383
+ const out = wotsPk.subarray(i * N);
384
+ out.set(wots.subarray(i * N, (i + 1) * N));
385
+ for (let j = start; j < start + steps && j < W; j++) {
386
+ setAddr({ hash: j }, wotsAddr);
387
+ out.set(context.thash1(out, wotsAddr));
388
+ }
389
+ }
390
+ const leaf = context.thashN(WOTS_LEN, wotsPk, wotsPkAddr);
391
+ root = computeRoot(leaf, leafIdx, 0, sigAuth, TREE_HEIGHT, context, treeAddr);
392
+ leafIdx = Number(tree & getMaskBig(TREE_HEIGHT));
393
+ }
394
+ return equalBytes(root, pubRoot);
395
+ },
396
+ };
397
+ }
398
+ const genShake = (robust) => (opts) => (pubSeed, skSeed) => {
399
+ const ADDR_BYTES = 32;
400
+ const { N } = opts;
401
+ const stats = { prf: 0, thash: 0, hmsg: 0, gen_message_random: 0 };
402
+ const h0 = shake256.create({}).update(pubSeed);
403
+ const h0tmp = h0.clone();
404
+ const thash_simple = (blocks, input, addr) => {
405
+ stats.thash++;
406
+ return h0
407
+ ._cloneInto(h0tmp)
408
+ .update(addr)
409
+ .update(input.subarray(0, blocks * N))
410
+ .xof(N);
411
+ };
412
+ const thash_robust = (blocks, input, addr) => {
413
+ stats.thash++;
414
+ const buf = new Uint8Array(ADDR_BYTES + (blocks + 1) * N);
415
+ buf.subarray(0, N).set(pubSeed);
416
+ buf.subarray(N, N + ADDR_BYTES).set(addr);
417
+ shake256
418
+ .create({})
419
+ .update(buf.subarray(0, N + ADDR_BYTES))
420
+ .xofInto(buf.subarray(N + ADDR_BYTES));
421
+ for (let i = 0; i < blocks * N; i++)
422
+ buf[N + ADDR_BYTES + i] ^= input[i];
423
+ return shake256.create({}).update(buf).xof(N);
424
+ };
425
+ const thash = robust ? thash_robust : thash_simple;
426
+ return {
427
+ PRFaddr: (addr) => {
428
+ if (!skSeed)
429
+ throw new Error('no sk seed');
430
+ stats.prf++;
431
+ return h0._cloneInto(h0tmp).update(addr).update(skSeed).xof(N);
432
+ },
433
+ PRFmsg: (skPRF, random, msg) => {
434
+ stats.gen_message_random++;
435
+ return shake256.create({}).update(skPRF).update(random).update(msg).digest().subarray(0, N);
436
+ },
437
+ Hmsg: (R, pk, m, outLen) => {
438
+ stats.hmsg++;
439
+ return shake256.create({}).update(R.subarray(0, N)).update(pk).update(m).xof(outLen);
440
+ },
441
+ thash1: thash.bind(null, 1),
442
+ thashN: thash,
443
+ clean: () => {
444
+ h0.destroy();
445
+ h0tmp.destroy();
446
+ //console.log(stats);
447
+ },
448
+ };
449
+ };
450
+ const SHAKE_SIMPLE = { getContext: genShake(false) };
451
+ const SHAKE_ROBUST = { getContext: genShake(true) };
452
+ export const sphincs_shake_128f_simple = /* @__PURE__ */ gen(PARAMS['128f'], SHAKE_SIMPLE);
453
+ export const sphincs_shake_128f_robust = /* @__PURE__ */ gen(PARAMS['128f'], SHAKE_ROBUST);
454
+ export const sphincs_shake_128s_simple = /* @__PURE__ */ gen(PARAMS['128s'], SHAKE_SIMPLE);
455
+ export const sphincs_shake_128s_robust = /* @__PURE__ */ gen(PARAMS['128s'], SHAKE_ROBUST);
456
+ export const sphincs_shake_192f_simple = /* @__PURE__ */ gen(PARAMS['192f'], SHAKE_SIMPLE);
457
+ export const sphincs_shake_192f_robust = /* @__PURE__ */ gen(PARAMS['192f'], SHAKE_ROBUST);
458
+ export const sphincs_shake_192s_simple = /* @__PURE__ */ gen(PARAMS['192s'], SHAKE_SIMPLE);
459
+ export const sphincs_shake_192s_robust = /* @__PURE__ */ gen(PARAMS['192s'], SHAKE_ROBUST);
460
+ export const sphincs_shake_256f_simple = /* @__PURE__ */ gen(PARAMS['256f'], SHAKE_SIMPLE);
461
+ export const sphincs_shake_256f_robust = /* @__PURE__ */ gen(PARAMS['256f'], SHAKE_ROBUST);
462
+ export const sphincs_shake_256s_simple = /* @__PURE__ */ gen(PARAMS['256s'], SHAKE_SIMPLE);
463
+ export const sphincs_shake_256s_robust = /* @__PURE__ */ gen(PARAMS['256s'], SHAKE_ROBUST);
464
+ // Only simple mode in SLH-DSA
465
+ export const slh_dsa_shake_128f = /* @__PURE__ */ gen(PARAMS['128f'], SHAKE_SIMPLE);
466
+ export const slh_dsa_shake_128s = /* @__PURE__ */ gen(PARAMS['128s'], SHAKE_SIMPLE);
467
+ export const slh_dsa_shake_192f = /* @__PURE__ */ gen(PARAMS['192f'], SHAKE_SIMPLE);
468
+ export const slh_dsa_shake_192s = /* @__PURE__ */ gen(PARAMS['192s'], SHAKE_SIMPLE);
469
+ export const slh_dsa_shake_256f = /* @__PURE__ */ gen(PARAMS['256f'], SHAKE_SIMPLE);
470
+ export const slh_dsa_shake_256s = /* @__PURE__ */ gen(PARAMS['256s'], SHAKE_SIMPLE);
471
+ const genSha = (h0, h1, robust) => (opts) => (pub_seed, sk_seed) => {
472
+ const { N } = opts;
473
+ /*
474
+ Perf debug stats, how much hashes we call?
475
+ 128f_simple: { prf: 8305, thash: 96_922, hmsg: 1, gen_message_random: 1, mgf1: 2 }
476
+ 256s_robust: { prf: 497_686, thash: 2_783_203, hmsg: 1, gen_message_random: 1, mgf1: 2_783_205}
477
+ 256f_simple: { prf: 36_179, thash: 309_693, hmsg: 1, gen_message_random: 1, mgf1: 2 }
478
+ */
479
+ const stats = { prf: 0, thash: 0, hmsg: 0, gen_message_random: 0, mgf1: 0 };
480
+ const counterB = new Uint8Array(4);
481
+ const counterV = createView(counterB);
482
+ const h0ps = h0
483
+ .create()
484
+ .update(pub_seed)
485
+ .update(new Uint8Array(h0.blockLen - N));
486
+ const h1ps = h1
487
+ .create()
488
+ .update(pub_seed)
489
+ .update(new Uint8Array(h1.blockLen - N));
490
+ const h0tmp = h0ps.clone();
491
+ const h1tmp = h1ps.clone();
492
+ function mgf1(seed, length, hash) {
493
+ stats.mgf1++;
494
+ const out = new Uint8Array(Math.ceil(length / hash.outputLen) * hash.outputLen);
495
+ if (length > 2 ** 32)
496
+ throw new Error('mask too long');
497
+ for (let counter = 0, o = out; o.length; counter++) {
498
+ counterV.setUint32(0, counter, false);
499
+ hash.create().update(seed).update(counterB).digestInto(o);
500
+ o = o.subarray(hash.outputLen);
501
+ }
502
+ out.subarray(length).fill(0);
503
+ return out.subarray(0, length);
504
+ }
505
+ const thash_simple = (_, h, hTmp) => (blocks, input, addr) => {
506
+ stats.thash++;
507
+ const d = h
508
+ ._cloneInto(hTmp)
509
+ .update(addr)
510
+ .update(input.subarray(0, blocks * N))
511
+ .digest();
512
+ return d.subarray(0, N);
513
+ };
514
+ const thash_robust = (sha, h, _) => (blocks, input, addr) => {
515
+ stats.thash++;
516
+ stats.mgf1++;
517
+ // inlined mgf1
518
+ const addr8 = addr;
519
+ const hh = sha.create().update(pub_seed).update(addr8);
520
+ let bitmask = new Uint8Array(Math.ceil((blocks * N) / sha.outputLen) * sha.outputLen);
521
+ for (let counter = 0, o = bitmask; o.length; counter++) {
522
+ counterV.setUint32(0, counter, false);
523
+ hh.clone().update(counterB).digestInto(o);
524
+ o = o.subarray(sha.outputLen);
525
+ }
526
+ bitmask = bitmask.subarray(0, blocks * N);
527
+ const ou32 = u32(input);
528
+ const bm32 = u32(bitmask);
529
+ for (let i = 0; i < bm32.length; i++)
530
+ bm32[i] ^= ou32[i];
531
+ const d = h.clone().update(addr8).update(bitmask).digest();
532
+ return d.subarray(0, N);
533
+ };
534
+ const thash = robust ? thash_robust : thash_simple;
535
+ return {
536
+ PRFaddr: (addr) => {
537
+ if (!sk_seed)
538
+ throw new Error('No sk seed');
539
+ stats.prf++;
540
+ return h0ps
541
+ ._cloneInto(h0tmp)
542
+ .update(addr)
543
+ .update(sk_seed)
544
+ .digest()
545
+ .subarray(0, N);
546
+ },
547
+ PRFmsg: (skPRF, random, msg) => {
548
+ stats.gen_message_random++;
549
+ return new HMAC(h1, skPRF).update(random).update(msg).digest().subarray(0, N);
550
+ },
551
+ Hmsg: (R, pk, m, outLen) => {
552
+ stats.hmsg++;
553
+ const seed = concatBytes(R.subarray(0, N), pk.subarray(0, N), h1.create().update(R.subarray(0, N)).update(pk).update(m).digest());
554
+ return mgf1(seed, outLen, h1);
555
+ },
556
+ thash1: thash(h0, h0ps, h0tmp).bind(null, 1),
557
+ thashN: thash(h1, h1ps, h1tmp),
558
+ clean: () => {
559
+ h0ps.destroy();
560
+ h1ps.destroy();
561
+ h0tmp.destroy();
562
+ h1tmp.destroy();
563
+ //console.log(stats);
564
+ },
565
+ };
566
+ };
567
+ const SHA256_SIMPLE = {
568
+ isCompressed: true,
569
+ getContext: genSha(sha256, sha256, false),
570
+ };
571
+ const SHA256_ROBUST = {
572
+ isCompressed: true,
573
+ getContext: genSha(sha256, sha256, true),
574
+ };
575
+ const SHA512_SIMPLE = {
576
+ isCompressed: true,
577
+ getContext: genSha(sha256, sha512, false),
578
+ };
579
+ const SHA512_ROBUST = {
580
+ isCompressed: true,
581
+ getContext: genSha(sha256, sha512, true),
582
+ };
583
+ export const sphincs_sha2_128f_simple = /* @__PURE__ */ gen(PARAMS['128f'], SHA256_SIMPLE);
584
+ export const sphincs_sha2_128f_robust = /* @__PURE__ */ gen(PARAMS['128f'], SHA256_ROBUST);
585
+ export const sphincs_sha2_128s_simple = /* @__PURE__ */ gen(PARAMS['128s'], SHA256_SIMPLE);
586
+ export const sphincs_sha2_128s_robust = /* @__PURE__ */ gen(PARAMS['128s'], SHA256_ROBUST);
587
+ export const sphincs_sha2_192f_simple = /* @__PURE__ */ gen(PARAMS['192f'], SHA512_SIMPLE);
588
+ export const sphincs_sha2_192f_robust = /* @__PURE__ */ gen(PARAMS['192f'], SHA512_ROBUST);
589
+ export const sphincs_sha2_192s_simple = /* @__PURE__ */ gen(PARAMS['192s'], SHA512_SIMPLE);
590
+ export const sphincs_sha2_192s_robust = /* @__PURE__ */ gen(PARAMS['192s'], SHA512_ROBUST);
591
+ export const sphincs_sha2_256f_simple = /* @__PURE__ */ gen(PARAMS['256f'], SHA512_SIMPLE);
592
+ export const sphincs_sha2_256f_robust = /* @__PURE__ */ gen(PARAMS['256f'], SHA512_ROBUST);
593
+ export const sphincs_sha2_256s_simple = /* @__PURE__ */ gen(PARAMS['256s'], SHA512_SIMPLE);
594
+ export const sphincs_sha2_256s_robust = /* @__PURE__ */ gen(PARAMS['256s'], SHA512_ROBUST);
595
+ // Only simple mode in SLH-DSA
596
+ export const slh_dsa_sha2_128f = /* @__PURE__ */ gen(PARAMS['128f'], SHA256_SIMPLE);
597
+ export const slh_dsa_sha2_128s = /* @__PURE__ */ gen(PARAMS['128s'], SHA256_SIMPLE);
598
+ export const slh_dsa_sha2_192f = /* @__PURE__ */ gen(PARAMS['192f'], SHA512_SIMPLE);
599
+ export const slh_dsa_sha2_192s = /* @__PURE__ */ gen(PARAMS['192s'], SHA512_SIMPLE);
600
+ export const slh_dsa_sha2_256f = /* @__PURE__ */ gen(PARAMS['256f'], SHA512_SIMPLE);
601
+ export const slh_dsa_sha2_256s = /* @__PURE__ */ gen(PARAMS['256s'], SHA512_SIMPLE);
602
+ //# sourceMappingURL=slh-dsa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slh-dsa.js","sourceRoot":"","sources":["../src/slh-dsa.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAEL,UAAU,EACV,WAAW,EACX,UAAU,EACV,OAAO,EACP,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,YAAY,CAAC;AAuDpB,MAAM,CAAC,MAAM,MAAM,GAAgC;IACjD,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE;IACnD,MAAM,EAAE,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