@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/src/slh-dsa.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { HMAC } from '@noble/hashes/hmac';
3
3
  import { sha256, sha512 } from '@noble/hashes/sha2';
4
4
  import { shake256 } from '@noble/hashes/sha3';
5
- import { bytesToHex, hexToBytes, createView, concatBytes, u32 } from '@noble/hashes/utils';
5
+ import { bytesToHex, hexToBytes, createView, concatBytes } from '@noble/hashes/utils';
6
6
  import {
7
7
  Signer,
8
8
  cleanBytes,
@@ -19,11 +19,6 @@ Hash-based digital signature algorithm. See [official site](https://sphincs.org)
19
19
  We implement spec v3.1 with latest FIPS-205 changes.
20
20
  It's compatible with the latest version in the [official repo](https://github.com/sphincs/sphincsplus).
21
21
 
22
- Three versions are provided:
23
-
24
- 1. SHAKE256-based
25
- 2. SHA2-based
26
- 3. SLH-DSA aka [FIPS-205](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.205.ipd.pdf)
27
22
  */
28
23
 
29
24
  /*
@@ -115,32 +110,20 @@ function numberToBytesBE(n: number | bigint, len: number): Uint8Array {
115
110
  return hexToBytes(n.toString(16).padStart(len * 2, '0'));
116
111
  }
117
112
 
118
- // Same as bitsCoder.decode, but bits are BE instead of LE (so we cannot re-use it).
119
- // NOTE: difference happens only if d < 8.
120
- const base_2bBE = (N: number, d: number) => {
121
- const mask = getMask(d);
122
- return (bytes: Uint8Array) => {
123
- const r = new Uint32Array(N);
124
- for (let i = 0, buf = 0, bufLen = 0, pos = 0; i < bytes.length; i++) {
125
- buf |= bytes[i] << bufLen;
126
- bufLen += 8;
127
- for (; bufLen >= d; bufLen -= d) r[pos++] = (buf >>> (bufLen - d)) & mask;
128
- buf &= getMask(bufLen);
129
- }
130
- return r;
131
- };
132
- };
133
113
  // Same as bitsCoder.decode, but maybe spec will change and unify with base2bBE.
134
- const base_2bLE = (N: number, d: number) => {
135
- const mask = getMask(d);
114
+ const base2b = (outLen: number, b: number) => {
115
+ const mask = getMask(b);
136
116
  return (bytes: Uint8Array) => {
137
- const r = new Uint32Array(N);
138
- for (let i = 0, buf = 0, bufLen = 0, pos = 0; i < bytes.length; i++) {
139
- buf |= bytes[i] << bufLen;
140
- bufLen += 8;
141
- for (; bufLen >= d; bufLen -= d, buf >>= d) r[pos++] = buf & mask;
117
+ const baseB = new Uint32Array(outLen);
118
+ for (let out = 0, pos = 0, bits = 0, total = 0; out < outLen; out++) {
119
+ while (bits < b) {
120
+ total = (total << 8) | bytes[pos++];
121
+ bits += 8;
122
+ }
123
+ bits -= b;
124
+ baseB[out] = (total >>> bits) & mask;
142
125
  }
143
- return r;
126
+ return baseB;
144
127
  };
145
128
  };
146
129
 
@@ -220,9 +203,9 @@ function gen(opts: SphincsOpts, hashOpts: SphincsHashOpts): SphincsSigner {
220
203
  return addr;
221
204
  };
222
205
 
223
- const chainCoder = base_2bBE(WOTS_LEN2, WOTS_LOGW);
206
+ const chainCoder = base2b(WOTS_LEN2, WOTS_LOGW);
224
207
  const chainLengths = (msg: Uint8Array) => {
225
- const W1 = base_2bBE(WOTS_LEN1, WOTS_LOGW)(msg);
208
+ const W1 = base2b(WOTS_LEN1, WOTS_LOGW)(msg);
226
209
  let csum = 0;
227
210
  for (let i = 0; i < W1.length; i++) csum += W - 1 - W1[i]; // ▷ Compute checksum
228
211
  csum <<= (8 - ((WOTS_LEN2 * WOTS_LOGW) % 8)) % 8; // csum ← csum ≪ ((8 − ((len2 · lg(w)) mod 8)) mod 8
@@ -234,9 +217,7 @@ function gen(opts: SphincsOpts, hashOpts: SphincsHashOpts): SphincsSigner {
234
217
  lengths.set(W2, W1.length);
235
218
  return lengths;
236
219
  };
237
- // Hm, why BE vs LE?
238
- const msgCoder = base_2bLE(K, A);
239
- const messageToIndices = (msg: Uint8Array) => msgCoder(msg);
220
+ const messageToIndices = base2b(K, A);
240
221
 
241
222
  const TREE_BITS = TREE_HEIGHT * (D - 1);
242
223
  const LEAF_BITS = TREE_HEIGHT;
@@ -542,15 +523,12 @@ function gen(opts: SphincsOpts, hashOpts: SphincsHashOpts): SphincsSigner {
542
523
  }
543
524
 
544
525
  const genShake =
545
- (robust: boolean): GetContext =>
546
- (opts: SphincsOpts) =>
547
- (pubSeed: Uint8Array, skSeed?: Uint8Array) => {
548
- const ADDR_BYTES = 32;
526
+ (): GetContext => (opts: SphincsOpts) => (pubSeed: Uint8Array, skSeed?: Uint8Array) => {
549
527
  const { N } = opts;
550
528
  const stats = { prf: 0, thash: 0, hmsg: 0, gen_message_random: 0 };
551
529
  const h0 = shake256.create({}).update(pubSeed);
552
530
  const h0tmp = h0.clone();
553
- const thash_simple = (blocks: number, input: Uint8Array, addr: ADRS) => {
531
+ const thash = (blocks: number, input: Uint8Array, addr: ADRS) => {
554
532
  stats.thash++;
555
533
  return h0
556
534
  ._cloneInto(h0tmp)
@@ -558,24 +536,12 @@ const genShake =
558
536
  .update(input.subarray(0, blocks * N))
559
537
  .xof(N);
560
538
  };
561
- const thash_robust = (blocks: number, input: Uint8Array, addr: ADRS) => {
562
- stats.thash++;
563
- const buf = new Uint8Array(ADDR_BYTES + (blocks + 1) * N);
564
- buf.subarray(0, N).set(pubSeed);
565
- buf.subarray(N, N + ADDR_BYTES).set(addr);
566
- shake256
567
- .create({})
568
- .update(buf.subarray(0, N + ADDR_BYTES))
569
- .xofInto(buf.subarray(N + ADDR_BYTES));
570
- for (let i = 0; i < blocks * N; i++) buf[N + ADDR_BYTES + i] ^= input[i];
571
- return shake256.create({}).update(buf).xof(N);
572
- };
573
- const thash = robust ? thash_robust : thash_simple;
574
539
  return {
575
540
  PRFaddr: (addr: ADRS) => {
576
541
  if (!skSeed) throw new Error('no sk seed');
577
542
  stats.prf++;
578
- return h0._cloneInto(h0tmp).update(addr).update(skSeed).xof(N);
543
+ const res = h0._cloneInto(h0tmp).update(addr).update(skSeed).xof(N);
544
+ return res;
579
545
  },
580
546
  PRFmsg: (skPRF: Uint8Array, random: Uint8Array, msg: Uint8Array) => {
581
547
  stats.gen_message_random++;
@@ -595,21 +561,7 @@ const genShake =
595
561
  };
596
562
  };
597
563
 
598
- const SHAKE_SIMPLE = { getContext: genShake(false) };
599
- const SHAKE_ROBUST = { getContext: genShake(true) };
600
-
601
- export const sphincs_shake_128f_simple = /* @__PURE__ */ gen(PARAMS['128f'], SHAKE_SIMPLE);
602
- export const sphincs_shake_128f_robust = /* @__PURE__ */ gen(PARAMS['128f'], SHAKE_ROBUST);
603
- export const sphincs_shake_128s_simple = /* @__PURE__ */ gen(PARAMS['128s'], SHAKE_SIMPLE);
604
- export const sphincs_shake_128s_robust = /* @__PURE__ */ gen(PARAMS['128s'], SHAKE_ROBUST);
605
- export const sphincs_shake_192f_simple = /* @__PURE__ */ gen(PARAMS['192f'], SHAKE_SIMPLE);
606
- export const sphincs_shake_192f_robust = /* @__PURE__ */ gen(PARAMS['192f'], SHAKE_ROBUST);
607
- export const sphincs_shake_192s_simple = /* @__PURE__ */ gen(PARAMS['192s'], SHAKE_SIMPLE);
608
- export const sphincs_shake_192s_robust = /* @__PURE__ */ gen(PARAMS['192s'], SHAKE_ROBUST);
609
- export const sphincs_shake_256f_simple = /* @__PURE__ */ gen(PARAMS['256f'], SHAKE_SIMPLE);
610
- export const sphincs_shake_256f_robust = /* @__PURE__ */ gen(PARAMS['256f'], SHAKE_ROBUST);
611
- export const sphincs_shake_256s_simple = /* @__PURE__ */ gen(PARAMS['256s'], SHAKE_SIMPLE);
612
- export const sphincs_shake_256s_robust = /* @__PURE__ */ gen(PARAMS['256s'], SHAKE_ROBUST);
564
+ const SHAKE_SIMPLE = { getContext: genShake() };
613
565
 
614
566
  // Only simple mode in SLH-DSA
615
567
  export const slh_dsa_shake_128f = /* @__PURE__ */ gen(PARAMS['128f'], SHAKE_SIMPLE);
@@ -621,7 +573,7 @@ export const slh_dsa_shake_256s = /* @__PURE__ */ gen(PARAMS['256s'], SHAKE_SIMP
621
573
 
622
574
  type ShaType = typeof sha256 | typeof sha512;
623
575
  const genSha =
624
- (h0: ShaType, h1: ShaType, robust: boolean): GetContext =>
576
+ (h0: ShaType, h1: ShaType): GetContext =>
625
577
  (opts) =>
626
578
  (pub_seed, sk_seed?) => {
627
579
  const { N } = opts;
@@ -660,7 +612,7 @@ const genSha =
660
612
  return out.subarray(0, length);
661
613
  }
662
614
 
663
- const thash_simple =
615
+ const thash =
664
616
  (_: ShaType, h: typeof h0ps, hTmp: typeof h0ps) =>
665
617
  (blocks: number, input: Uint8Array, addr: ADRS) => {
666
618
  stats.thash++;
@@ -671,40 +623,17 @@ const genSha =
671
623
  .digest();
672
624
  return d.subarray(0, N);
673
625
  };
674
-
675
- const thash_robust =
676
- (sha: ShaType, h: typeof h0ps, _: typeof h0ps) =>
677
- (blocks: number, input: Uint8Array, addr: ADRS) => {
678
- stats.thash++;
679
- stats.mgf1++;
680
- // inlined mgf1
681
- const addr8 = addr;
682
- const hh = sha.create().update(pub_seed).update(addr8);
683
- let bitmask = new Uint8Array(Math.ceil((blocks * N) / sha.outputLen) * sha.outputLen);
684
- for (let counter = 0, o = bitmask; o.length; counter++) {
685
- counterV.setUint32(0, counter, false);
686
- hh.clone().update(counterB).digestInto(o);
687
- o = o.subarray(sha.outputLen);
688
- }
689
- bitmask = bitmask.subarray(0, blocks * N);
690
- const ou32 = u32(input);
691
- const bm32 = u32(bitmask);
692
- for (let i = 0; i < bm32.length; i++) bm32[i] ^= ou32[i];
693
- const d = h.clone().update(addr8).update(bitmask).digest();
694
- return d.subarray(0, N);
695
- };
696
-
697
- const thash = robust ? thash_robust : thash_simple;
698
626
  return {
699
627
  PRFaddr: (addr: ADRS) => {
700
628
  if (!sk_seed) throw new Error('No sk seed');
701
629
  stats.prf++;
702
- return h0ps
630
+ const res = h0ps
703
631
  ._cloneInto(h0tmp as any)
704
632
  .update(addr)
705
633
  .update(sk_seed)
706
634
  .digest()
707
635
  .subarray(0, N);
636
+ return res;
708
637
  },
709
638
  PRFmsg: (skPRF: Uint8Array, random: Uint8Array, msg: Uint8Array) => {
710
639
  stats.gen_message_random++;
@@ -733,34 +662,12 @@ const genSha =
733
662
 
734
663
  const SHA256_SIMPLE = {
735
664
  isCompressed: true,
736
- getContext: genSha(sha256, sha256, false),
737
- };
738
- const SHA256_ROBUST = {
739
- isCompressed: true,
740
- getContext: genSha(sha256, sha256, true),
665
+ getContext: genSha(sha256, sha256),
741
666
  };
742
667
  const SHA512_SIMPLE = {
743
668
  isCompressed: true,
744
- getContext: genSha(sha256, sha512, false),
669
+ getContext: genSha(sha256, sha512),
745
670
  };
746
- const SHA512_ROBUST = {
747
- isCompressed: true,
748
- getContext: genSha(sha256, sha512, true),
749
- };
750
-
751
- export const sphincs_sha2_128f_simple = /* @__PURE__ */ gen(PARAMS['128f'], SHA256_SIMPLE);
752
- export const sphincs_sha2_128f_robust = /* @__PURE__ */ gen(PARAMS['128f'], SHA256_ROBUST);
753
- export const sphincs_sha2_128s_simple = /* @__PURE__ */ gen(PARAMS['128s'], SHA256_SIMPLE);
754
- export const sphincs_sha2_128s_robust = /* @__PURE__ */ gen(PARAMS['128s'], SHA256_ROBUST);
755
-
756
- export const sphincs_sha2_192f_simple = /* @__PURE__ */ gen(PARAMS['192f'], SHA512_SIMPLE);
757
- export const sphincs_sha2_192f_robust = /* @__PURE__ */ gen(PARAMS['192f'], SHA512_ROBUST);
758
- export const sphincs_sha2_192s_simple = /* @__PURE__ */ gen(PARAMS['192s'], SHA512_SIMPLE);
759
- export const sphincs_sha2_192s_robust = /* @__PURE__ */ gen(PARAMS['192s'], SHA512_ROBUST);
760
- export const sphincs_sha2_256f_simple = /* @__PURE__ */ gen(PARAMS['256f'], SHA512_SIMPLE);
761
- export const sphincs_sha2_256f_robust = /* @__PURE__ */ gen(PARAMS['256f'], SHA512_ROBUST);
762
- export const sphincs_sha2_256s_simple = /* @__PURE__ */ gen(PARAMS['256s'], SHA512_SIMPLE);
763
- export const sphincs_sha2_256s_robust = /* @__PURE__ */ gen(PARAMS['256s'], SHA512_ROBUST);
764
671
 
765
672
  // Only simple mode in SLH-DSA
766
673
  export const slh_dsa_sha2_128f = /* @__PURE__ */ gen(PARAMS['128f'], SHA256_SIMPLE);
package/utils.js CHANGED
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMask = exports.cleanBytes = exports.vecCoder = exports.splitCoder = exports.equalBytes = exports.randomBytes = exports.ensureBytes = void 0;
3
+ exports.randomBytes = exports.ensureBytes = void 0;
4
+ exports.equalBytes = equalBytes;
5
+ exports.splitCoder = splitCoder;
6
+ exports.vecCoder = vecCoder;
7
+ exports.cleanBytes = cleanBytes;
8
+ exports.getMask = getMask;
4
9
  /*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */
5
10
  const _assert_1 = require("@noble/hashes/_assert");
6
11
  const utils_1 = require("@noble/hashes/utils");
@@ -15,7 +20,6 @@ function equalBytes(a, b) {
15
20
  diff |= a[i] ^ b[i];
16
21
  return diff === 0;
17
22
  }
18
- exports.equalBytes = equalBytes;
19
23
  function splitCoder(...lengths) {
20
24
  const getLength = (c) => (typeof c === 'number' ? c : c.bytesLen);
21
25
  const bytesLen = lengths.reduce((sum, a) => sum + getLength(a), 0);
@@ -48,7 +52,6 @@ function splitCoder(...lengths) {
48
52
  },
49
53
  };
50
54
  }
51
- exports.splitCoder = splitCoder;
52
55
  // nano-packed.array (fixed size)
53
56
  function vecCoder(c, vecLen) {
54
57
  const bytesLen = vecLen * c.bytesLen;
@@ -75,7 +78,6 @@ function vecCoder(c, vecLen) {
75
78
  },
76
79
  };
77
80
  }
78
- exports.vecCoder = vecCoder;
79
81
  // cleanBytes(new Uint8Array(), [new Uint16Array(), new Uint32Array()])
80
82
  function cleanBytes(...list) {
81
83
  for (const t of list) {
@@ -86,9 +88,7 @@ function cleanBytes(...list) {
86
88
  t.fill(0);
87
89
  }
88
90
  }
89
- exports.cleanBytes = cleanBytes;
90
91
  function getMask(bits) {
91
92
  return (1 << bits) - 1; // 4 -> 0b1111
92
93
  }
93
- exports.getMask = getMask;
94
94
  //# sourceMappingURL=utils.js.map
package/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["src/utils.ts"],"names":[],"mappings":";;;AAAA,4EAA4E;AAC5E,mDAAwD;AACxD,+CAAuE;AAE1D,QAAA,WAAW,GAAG,eAAM,CAAC;AACrB,QAAA,WAAW,GAAG,mBAAK,CAAC;AAEjC,0CAA0C;AAC1C,SAAgB,UAAU,CAAC,CAAa,EAAE,CAAa;IACrD,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,KAAK,CAAC,CAAC;AACpB,CAAC;AALD,gCAKC;AA6BD,SAAgB,UAAU,CACxB,GAAG,OAAU;IAEb,MAAM,SAAS,GAAG,CAAC,CAA8B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC/F,MAAM,QAAQ,GAAW,OAAO,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnF,OAAO;QACL,QAAQ;QACR,MAAM,EAAE,CAAC,IAAO,EAAE,EAAE;YAClB,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;YACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,OA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