@protontech/openpgp 6.0.0-alpha.1.patch.1 → 6.0.0-beta.0.patch.0

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.
Files changed (36) hide show
  1. package/dist/lightweight/argon2id.min.mjs +1 -1
  2. package/dist/lightweight/argon2id.mjs +1 -1
  3. package/dist/lightweight/bn.interface.min.mjs +2 -2
  4. package/dist/lightweight/bn.interface.min.mjs.map +1 -1
  5. package/dist/lightweight/bn.interface.mjs +1 -1
  6. package/dist/lightweight/interface.min.mjs +1 -1
  7. package/dist/lightweight/interface.mjs +1 -1
  8. package/dist/lightweight/legacy_ciphers.min.mjs +1 -1
  9. package/dist/lightweight/legacy_ciphers.mjs +1 -1
  10. package/dist/lightweight/native.interface.min.mjs +1 -1
  11. package/dist/lightweight/native.interface.mjs +1 -1
  12. package/dist/lightweight/noble_curves.min.mjs +3 -3
  13. package/dist/lightweight/noble_curves.min.mjs.map +1 -1
  14. package/dist/lightweight/noble_curves.mjs +1 -1
  15. package/dist/lightweight/noble_hashes.min.mjs +1 -1
  16. package/dist/lightweight/noble_hashes.mjs +1 -1
  17. package/dist/lightweight/openpgp.min.mjs +2 -2
  18. package/dist/lightweight/openpgp.min.mjs.map +1 -1
  19. package/dist/lightweight/openpgp.mjs +211 -83
  20. package/dist/lightweight/sha3.min.mjs +2 -2
  21. package/dist/lightweight/sha3.min.mjs.map +1 -1
  22. package/dist/lightweight/sha3.mjs +1 -1
  23. package/dist/node/openpgp.cjs +211 -83
  24. package/dist/node/openpgp.min.cjs +11 -11
  25. package/dist/node/openpgp.min.cjs.map +1 -1
  26. package/dist/node/openpgp.min.mjs +11 -11
  27. package/dist/node/openpgp.min.mjs.map +1 -1
  28. package/dist/node/openpgp.mjs +211 -83
  29. package/dist/openpgp.js +211 -83
  30. package/dist/openpgp.min.js +11 -11
  31. package/dist/openpgp.min.js.map +1 -1
  32. package/dist/openpgp.min.mjs +11 -11
  33. package/dist/openpgp.min.mjs.map +1 -1
  34. package/dist/openpgp.mjs +211 -83
  35. package/openpgp.d.ts +5 -3
  36. package/package.json +9 -9
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v6.0.0-alpha.1.patch.1 - 2024-03-11 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v6.0.0-beta.0.patch.0 - 2024-04-19 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
2
  const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3
3
 
4
4
  const doneWritingPromise = Symbol('doneWritingPromise');
@@ -1465,6 +1465,14 @@ var config = {
1465
1465
  * @property {Boolean} aeadProtect
1466
1466
  */
1467
1467
  aeadProtect: false,
1468
+ /**
1469
+ * Whether to disable encrypton using SEIPDv2 even if the encryption keys include the SEIPDv2 feature flag.
1470
+ * If true, SEIPDv1 (i.e. no AEAD) packets are always used instead.
1471
+ * SEIPDv2 is a more secure and faster choice, but it is not necessarily compatible with other libs and our mobile apps.
1472
+ * @memberof module:config
1473
+ * @property {Boolean} ignoreSEIPDv2FeatureFlag
1474
+ */
1475
+ ignoreSEIPDv2FeatureFlag: false,
1468
1476
  /**
1469
1477
  * When reading OpenPGP v4 private keys (e.g. those generated in OpenPGP.js when not setting `config.v5Keys = true`)
1470
1478
  * which were encrypted by OpenPGP.js v5 (or older) using `config.aeadProtect = true`,
@@ -1577,11 +1585,6 @@ var config = {
1577
1585
  * @property {Boolean} passwordCollisionCheck
1578
1586
  */
1579
1587
  passwordCollisionCheck: false,
1580
- /**
1581
- * @memberof module:config
1582
- * @property {Boolean} revocationsExpire If true, expired revocation signatures are ignored
1583
- */
1584
- revocationsExpire: false,
1585
1588
  /**
1586
1589
  * Allow decryption using RSA keys without `encrypt` flag.
1587
1590
  * This setting is potentially insecure, but it is needed to get around an old openpgpjs bug
@@ -1657,7 +1660,7 @@ var config = {
1657
1660
  * @memberof module:config
1658
1661
  * @property {String} versionString A version string to be included in armored messages
1659
1662
  */
1660
- versionString: 'OpenPGP.js 6.0.0-alpha.1.patch.1',
1663
+ versionString: 'OpenPGP.js 6.0.0-beta.0.patch.0',
1661
1664
  /**
1662
1665
  * @memberof module:config
1663
1666
  * @property {String} commentString A comment string to be included in armored messages
@@ -1677,6 +1680,14 @@ var config = {
1677
1680
  * @property {Array} knownNotations
1678
1681
  */
1679
1682
  knownNotations: [],
1683
+ /**
1684
+ * If true, a salt notation is used to randomize signatures generated by v4 and v5 keys (v6 signatures are always non-deterministic, by design).
1685
+ * This protects EdDSA signatures from potentially leaking the secret key in case of faults (i.e. bitflips) which, in principle, could occur
1686
+ * during the signing computation. It is added to signatures of any algo for simplicity, and as it may also serve as protection in case of
1687
+ * weaknesses in the hash algo, potentially hindering e.g. some chosen-prefix attacks.
1688
+ * NOTE: the notation is interoperable, but will reveal that the signature has been generated using OpenPGP.js, which may not be desirable in some cases.
1689
+ */
1690
+ nonDeterministicSignaturesViaNotation: true,
1680
1691
  /**
1681
1692
  * Whether to use the the noble-curves library for curves (other than Curve25519) that are not supported by the available native crypto API.
1682
1693
  * When false, certain standard curves will not be supported (depending on the platform).
@@ -1707,14 +1718,7 @@ var config = {
1707
1718
  * @memberof module:config
1708
1719
  * @property {Set<String>} rejectCurves {@link module:enums.curve}
1709
1720
  */
1710
- rejectCurves: new Set([enums.curve.secp256k1]),
1711
- /**
1712
- * Whether to validate generated EdDSA signatures before returning them, to ensure they are not faulty signatures.
1713
- * This check will make signing 2-3 times slower.
1714
- * Faulty signatures may be generated (in principle) if random bitflips occur at specific points in the signature
1715
- * computation, and could be used to recover the signer's secret key given a second signature over the same data.
1716
- */
1717
- checkEdDSAFaultySignatures: true
1721
+ rejectCurves: new Set([enums.curve.secp256k1])
1718
1722
  };
1719
1723
 
1720
1724
  /**
@@ -2194,16 +2198,19 @@ const util = {
2194
2198
  },
2195
2199
 
2196
2200
  /**
2197
- * Test email format based on W3C HTML5 specification.
2198
- * This check is not exaustive, and does not match RFC 5322 exactly
2199
- * (see https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email)),
2200
- * but is commonly used for email address validation.
2201
+ * Test email format to ensure basic compliance:
2202
+ * - must include a single @
2203
+ * - no control or space unicode chars allowed
2204
+ * - no backslash and square brackets (as the latter can mess with the userID parsing)
2205
+ * - cannot end with a punctuation char
2206
+ * These checks are not meant to be exhaustive; applications are strongly encouraged to implement stricter validation,
2207
+ * e.g. based on the W3C HTML spec (https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email)).
2201
2208
  */
2202
2209
  isEmailAddress: function(data) {
2203
2210
  if (!util.isString(data)) {
2204
2211
  return false;
2205
2212
  }
2206
- const re = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
2213
+ const re = /^[^\p{C}\p{Z}@<>\\]+@[^\p{C}\p{Z}@<>\\]+[^\p{C}\p{Z}\p{P}]$/u;
2207
2214
  return re.test(data);
2208
2215
  },
2209
2216
 
@@ -2609,6 +2616,78 @@ function addheader(customComment, config) {
2609
2616
  return result;
2610
2617
  }
2611
2618
 
2619
+ /**
2620
+ * Calculates a checksum over the given data and returns it base64 encoded
2621
+ * @param {String | ReadableStream<String>} data - Data to create a CRC-24 checksum for
2622
+ * @returns {String | ReadableStream<String>} Base64 encoded checksum.
2623
+ * @private
2624
+ */
2625
+ function getCheckSum(data) {
2626
+ const crc = createcrc24(data);
2627
+ return encode$1(crc);
2628
+ }
2629
+
2630
+ // https://create.stephan-brumme.com/crc32/#slicing-by-8-overview
2631
+
2632
+ const crc_table = [
2633
+ new Array(0xFF),
2634
+ new Array(0xFF),
2635
+ new Array(0xFF),
2636
+ new Array(0xFF)
2637
+ ];
2638
+
2639
+ for (let i = 0; i <= 0xFF; i++) {
2640
+ let crc = i << 16;
2641
+ for (let j = 0; j < 8; j++) {
2642
+ crc = (crc << 1) ^ ((crc & 0x800000) !== 0 ? 0x864CFB : 0);
2643
+ }
2644
+ crc_table[0][i] =
2645
+ ((crc & 0xFF0000) >> 16) |
2646
+ (crc & 0x00FF00) |
2647
+ ((crc & 0x0000FF) << 16);
2648
+ }
2649
+ for (let i = 0; i <= 0xFF; i++) {
2650
+ crc_table[1][i] = (crc_table[0][i] >> 8) ^ crc_table[0][crc_table[0][i] & 0xFF];
2651
+ }
2652
+ for (let i = 0; i <= 0xFF; i++) {
2653
+ crc_table[2][i] = (crc_table[1][i] >> 8) ^ crc_table[0][crc_table[1][i] & 0xFF];
2654
+ }
2655
+ for (let i = 0; i <= 0xFF; i++) {
2656
+ crc_table[3][i] = (crc_table[2][i] >> 8) ^ crc_table[0][crc_table[2][i] & 0xFF];
2657
+ }
2658
+
2659
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView#Endianness
2660
+ const isLittleEndian = (function() {
2661
+ const buffer = new ArrayBuffer(2);
2662
+ new DataView(buffer).setInt16(0, 0xFF, true /* littleEndian */);
2663
+ // Int16Array uses the platform's endianness.
2664
+ return new Int16Array(buffer)[0] === 0xFF;
2665
+ }());
2666
+
2667
+ /**
2668
+ * Internal function to calculate a CRC-24 checksum over a given string (data)
2669
+ * @param {String | ReadableStream<String>} input - Data to create a CRC-24 checksum for
2670
+ * @returns {Uint8Array | ReadableStream<Uint8Array>} The CRC-24 checksum.
2671
+ * @private
2672
+ */
2673
+ function createcrc24(input) {
2674
+ let crc = 0xCE04B7;
2675
+ return transform(input, value => {
2676
+ const len32 = isLittleEndian ? Math.floor(value.length / 4) : 0;
2677
+ const arr32 = new Uint32Array(value.buffer, value.byteOffset, len32);
2678
+ for (let i = 0; i < len32; i++) {
2679
+ crc ^= arr32[i];
2680
+ crc =
2681
+ crc_table[0][(crc >> 24) & 0xFF] ^
2682
+ crc_table[1][(crc >> 16) & 0xFF] ^
2683
+ crc_table[2][(crc >> 8) & 0xFF] ^
2684
+ crc_table[3][(crc >> 0) & 0xFF];
2685
+ }
2686
+ for (let i = len32 * 4; i < value.length; i++) {
2687
+ crc = (crc >> 8) ^ crc_table[0][(crc & 0xFF) ^ value[i]];
2688
+ }
2689
+ }, () => new Uint8Array([crc, crc >> 8, crc >> 16]));
2690
+ }
2612
2691
 
2613
2692
  /**
2614
2693
  * Verify armored headers. crypto-refresh-06, section 6.2:
@@ -2764,10 +2843,13 @@ function unarmor(input) {
2764
2843
  * @param {Integer} [partIndex]
2765
2844
  * @param {Integer} [partTotal]
2766
2845
  * @param {String} [customComment] - Additional comment to add to the armored string
2846
+ * @param {Boolean} [emitChecksum] - Whether to compute and include the CRC checksum
2847
+ * (NB: some types of data must not include it, but compliance is left as responsibility of the caller: this function does not carry out any checks)
2848
+ * @param {Object} [config] - Full configuration, defaults to openpgp.config
2767
2849
  * @returns {String | ReadableStream<String>} Armored text.
2768
2850
  * @static
2769
2851
  */
2770
- function armor(messageType, body, partIndex, partTotal, customComment, config$1 = config) {
2852
+ function armor(messageType, body, partIndex, partTotal, customComment, emitChecksum = false, config$1 = config) {
2771
2853
  let text;
2772
2854
  let hash;
2773
2855
  if (messageType === enums.armor.signed) {
@@ -2775,18 +2857,24 @@ function armor(messageType, body, partIndex, partTotal, customComment, config$1
2775
2857
  hash = body.hash;
2776
2858
  body = body.data;
2777
2859
  }
2860
+ // unless explicitly forbidden by the spec, we need to include the checksum to work around a GnuPG bug
2861
+ // where data fails to be decoded if the base64 ends with no padding chars (=) (see https://dev.gnupg.org/T7071)
2862
+ const maybeBodyClone = emitChecksum && passiveClone(body);
2863
+
2778
2864
  const result = [];
2779
2865
  switch (messageType) {
2780
2866
  case enums.armor.multipartSection:
2781
2867
  result.push('-----BEGIN PGP MESSAGE, PART ' + partIndex + '/' + partTotal + '-----\n');
2782
2868
  result.push(addheader(customComment, config$1));
2783
2869
  result.push(encode$1(body));
2870
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2784
2871
  result.push('-----END PGP MESSAGE, PART ' + partIndex + '/' + partTotal + '-----\n');
2785
2872
  break;
2786
2873
  case enums.armor.multipartLast:
2787
2874
  result.push('-----BEGIN PGP MESSAGE, PART ' + partIndex + '-----\n');
2788
2875
  result.push(addheader(customComment, config$1));
2789
2876
  result.push(encode$1(body));
2877
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2790
2878
  result.push('-----END PGP MESSAGE, PART ' + partIndex + '-----\n');
2791
2879
  break;
2792
2880
  case enums.armor.signed:
@@ -2796,30 +2884,35 @@ function armor(messageType, body, partIndex, partTotal, customComment, config$1
2796
2884
  result.push('\n-----BEGIN PGP SIGNATURE-----\n');
2797
2885
  result.push(addheader(customComment, config$1));
2798
2886
  result.push(encode$1(body));
2887
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2799
2888
  result.push('-----END PGP SIGNATURE-----\n');
2800
2889
  break;
2801
2890
  case enums.armor.message:
2802
2891
  result.push('-----BEGIN PGP MESSAGE-----\n');
2803
2892
  result.push(addheader(customComment, config$1));
2804
2893
  result.push(encode$1(body));
2894
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2805
2895
  result.push('-----END PGP MESSAGE-----\n');
2806
2896
  break;
2807
2897
  case enums.armor.publicKey:
2808
2898
  result.push('-----BEGIN PGP PUBLIC KEY BLOCK-----\n');
2809
2899
  result.push(addheader(customComment, config$1));
2810
2900
  result.push(encode$1(body));
2901
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2811
2902
  result.push('-----END PGP PUBLIC KEY BLOCK-----\n');
2812
2903
  break;
2813
2904
  case enums.armor.privateKey:
2814
2905
  result.push('-----BEGIN PGP PRIVATE KEY BLOCK-----\n');
2815
2906
  result.push(addheader(customComment, config$1));
2816
2907
  result.push(encode$1(body));
2908
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2817
2909
  result.push('-----END PGP PRIVATE KEY BLOCK-----\n');
2818
2910
  break;
2819
2911
  case enums.armor.signature:
2820
2912
  result.push('-----BEGIN PGP SIGNATURE-----\n');
2821
2913
  result.push(addheader(customComment, config$1));
2822
2914
  result.push(encode$1(body));
2915
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2823
2916
  result.push('-----END PGP SIGNATURE-----\n');
2824
2917
  break;
2825
2918
  }
@@ -9346,20 +9439,6 @@ async function sign$5(oid, hashAlgo, message, publicKey, privateKey, hashed) {
9346
9439
  }
9347
9440
  const secretKey = util.concatUint8Array([privateKey, publicKey.subarray(1)]);
9348
9441
  const signature = nacl.sign.detached(hashed, secretKey);
9349
- if (config.checkEdDSAFaultySignatures && !nacl.sign.detached.verify(hashed, signature, publicKey.subarray(1))) {
9350
- /**
9351
- * Detect faulty signatures caused by random bitflips during `crypto_sign` which could lead to private key extraction
9352
- * if two signatures over the same message are obtained.
9353
- * See https://github.com/jedisct1/libsodium/issues/170.
9354
- * If the input data is not deterministic, e.g. thanks to the random salt in v6 OpenPGP signatures (not yet implemented),
9355
- * then the generated signature is always safe, and the verification step is skipped.
9356
- * Otherwise, we need to verify the generated to ensure that no bitflip occured:
9357
- * - in M between the computation of `r` and `h`.
9358
- * - in the public key before computing `h`
9359
- * The verification step is almost 2-3 times as slow as signing, but it's faster than re-signing + re-deriving the public key for separate checks.
9360
- */
9361
- throw new Error('Transient signing failure');
9362
- }
9363
9442
  // EdDSA signature params are returned in little-endian format
9364
9443
  return {
9365
9444
  r: signature.subarray(0, 32),
@@ -9480,20 +9559,6 @@ async function sign$4(algo, hashAlgo, message, publicKey, privateKey, hashed) {
9480
9559
  case enums.publicKey.ed25519: {
9481
9560
  const secretKey = util.concatUint8Array([privateKey, publicKey]);
9482
9561
  const signature = nacl.sign.detached(hashed, secretKey);
9483
- if (config.checkEdDSAFaultySignatures && !nacl.sign.detached.verify(hashed, signature, publicKey)) {
9484
- /**
9485
- * Detect faulty signatures caused by random bitflips during `crypto_sign` which could lead to private key extraction
9486
- * if two signatures over the same message are obtained.
9487
- * See https://github.com/jedisct1/libsodium/issues/170.
9488
- * If the input data is not deterministic, e.g. thanks to the random salt in v6 OpenPGP signatures (not yet implemented),
9489
- * then the generated signature is always safe, and the verification step is skipped.
9490
- * Otherwise, we need to verify the generated to ensure that no bitflip occured:
9491
- * - in M between the computation of `r` and `h`.
9492
- * - in the public key before computing `h`
9493
- * The verification step is almost 2-3 times as slow as signing, but it's faster than re-signing + re-deriving the public key for separate checks.
9494
- */
9495
- throw new Error('Transient signing failure');
9496
- }
9497
9562
  return { RS: signature };
9498
9563
  }
9499
9564
  case enums.publicKey.ed448: {
@@ -11226,7 +11291,7 @@ class ECDHXSymmetricKey {
11226
11291
  * Encrypts data using specified algorithm and public key parameters.
11227
11292
  * See {@link https://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1} for public key algorithms.
11228
11293
  * @param {module:enums.publicKey} keyAlgo - Public key algorithm
11229
- * @param {module:enums.symmetric} symmetricAlgo - Cipher algorithm
11294
+ * @param {module:enums.symmetric|null} symmetricAlgo - Cipher algorithm (v3 only)
11230
11295
  * @param {Object} publicParams - Algorithm-specific public key parameters
11231
11296
  * @param {Object} privateParams - Algorithm-specific private key parameters
11232
11297
  * @param {Uint8Array} data - Data to be encrypted
@@ -11254,7 +11319,7 @@ async function publicKeyEncrypt(keyAlgo, symmetricAlgo, publicParams, privatePar
11254
11319
  }
11255
11320
  case enums.publicKey.x25519:
11256
11321
  case enums.publicKey.x448: {
11257
- if (!util.isAES(symmetricAlgo)) {
11322
+ if (symmetricAlgo && !util.isAES(symmetricAlgo)) {
11258
11323
  // see https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/276
11259
11324
  throw new Error('X25519 and X448 keys can only encrypt AES session keys');
11260
11325
  }
@@ -11886,9 +11951,26 @@ class Argon2OutOfMemoryError extends Error {
11886
11951
  let loadArgonWasmModule;
11887
11952
  let argon2Promise;
11888
11953
  // reload wasm module above this treshold, to deallocated used memory
11889
- const ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = 2 << 19;
11954
+ // (cannot be declared as a simple `static` field as its not supported by Safari 14)
11955
+ let ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = 2 << 19;
11890
11956
 
11891
11957
  class Argon2S2K {
11958
+ static get ARGON2_WASM_MEMORY_THRESHOLD_RELOAD() {
11959
+ return ARGON2_WASM_MEMORY_THRESHOLD_RELOAD;
11960
+ }
11961
+
11962
+ static set ARGON2_WASM_MEMORY_THRESHOLD_RELOAD(memoryThreshold) {
11963
+ ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = memoryThreshold;
11964
+ }
11965
+
11966
+ static reloadWasmModule() {
11967
+ if (!loadArgonWasmModule) return;
11968
+
11969
+ // it will be awaited if needed at the next `produceKey` invocation
11970
+ argon2Promise = loadArgonWasmModule();
11971
+ argon2Promise.catch(() => {});
11972
+ }
11973
+
11892
11974
  /**
11893
11975
  * @param {Object} [config] - Full configuration, defaults to openpgp.config
11894
11976
  */
@@ -11976,10 +12058,8 @@ class Argon2S2K {
11976
12058
  });
11977
12059
 
11978
12060
  // a lot of memory was used, reload to deallocate
11979
- if (decodedM > ARGON2_WASM_MEMORY_THRESHOLD_RELOAD) {
11980
- // it will be awaited if needed at the next `produceKey` invocation
11981
- argon2Promise = loadArgonWasmModule();
11982
- argon2Promise.catch(() => {});
12061
+ if (decodedM > Argon2S2K.ARGON2_WASM_MEMORY_THRESHOLD_RELOAD) {
12062
+ Argon2S2K.reloadWasmModule();
11983
12063
  }
11984
12064
  return hash;
11985
12065
  } catch (e) {
@@ -14222,6 +14302,14 @@ class KeyID {
14222
14302
  // Symbol to store cryptographic validity of the signature, to avoid recomputing multiple times on verification.
14223
14303
  const verified = Symbol('verified');
14224
14304
 
14305
+ // A salt notation is used to randomize signatures.
14306
+ // This is to protect EdDSA signatures in particular, which are known to be vulnerable to fault attacks
14307
+ // leading to secret key extraction if two signatures over the same data can be collected (see https://github.com/jedisct1/libsodium/issues/170).
14308
+ // For simplicity, we add the salt to all algos, as it may also serve as protection in case of weaknesses in the hash algo, potentially hindering e.g.
14309
+ // some chosen-prefix attacks.
14310
+ // v6 signatures do not need to rely on this notation, as they already include a separate, built-in salt.
14311
+ const SALT_NOTATION_NAME = 'salt@notations.openpgpjs.org';
14312
+
14225
14313
  // GPG puts the Issuer and Signature subpackets in the unhashed area.
14226
14314
  // Tampering with those invalidates the signature, so we still trust them and parse them.
14227
14315
  // All other unhashed subpackets are ignored.
@@ -14391,7 +14479,7 @@ class SignaturePacket {
14391
14479
  * @throws {Error} if signing failed
14392
14480
  * @async
14393
14481
  */
14394
- async sign(key, data, date = new Date(), detached = false) {
14482
+ async sign(key, data, date = new Date(), detached = false, config) {
14395
14483
  this.version = key.version;
14396
14484
 
14397
14485
  this.created = util.normalizeDate(date);
@@ -14401,6 +14489,31 @@ class SignaturePacket {
14401
14489
 
14402
14490
  const arr = [new Uint8Array([this.version, this.signatureType, this.publicKeyAlgorithm, this.hashAlgorithm])];
14403
14491
 
14492
+ // add randomness to the signature
14493
+ if (this.version === 6) {
14494
+ const saltLength = saltLengthForHash(this.hashAlgorithm);
14495
+ if (this.salt === null) {
14496
+ this.salt = mod.random.getRandomBytes(saltLength);
14497
+ } else if (saltLength !== this.salt.length) {
14498
+ throw new Error('Provided salt does not have the required length');
14499
+ }
14500
+ } else if (config.nonDeterministicSignaturesViaNotation) {
14501
+ const saltNotations = this.rawNotations.filter(({ name }) => (name === SALT_NOTATION_NAME));
14502
+ // since re-signing the same object is not supported, it's not expected to have multiple salt notations,
14503
+ // but we guard against it as a sanity check
14504
+ if (saltNotations.length === 0) {
14505
+ const saltValue = mod.random.getRandomBytes(saltLengthForHash(this.hashAlgorithm));
14506
+ this.rawNotations.push({
14507
+ name: SALT_NOTATION_NAME,
14508
+ value: saltValue,
14509
+ humanReadable: false,
14510
+ critical: false
14511
+ });
14512
+ } else {
14513
+ throw new Error('Unexpected existing salt notation');
14514
+ }
14515
+ }
14516
+
14404
14517
  // Add hashed subpackets
14405
14518
  arr.push(this.writeHashedSubPackets());
14406
14519
 
@@ -14411,14 +14524,6 @@ class SignaturePacket {
14411
14524
 
14412
14525
  this.signatureData = util.concat(arr);
14413
14526
 
14414
- if (this.version === 6) {
14415
- const saltLength = saltLengthForHash(this.hashAlgorithm);
14416
- if (this.salt === null) {
14417
- this.salt = mod.random.getRandomBytes(saltLength);
14418
- } else if (saltLength !== this.salt.length) {
14419
- throw new Error('Provided salt does not have the required length');
14420
- }
14421
- }
14422
14527
  const toHash = this.toHash(this.signatureType, data, detached);
14423
14528
  const hash = await this.hash(this.signatureType, data, toHash, detached);
14424
14529
 
@@ -16220,9 +16325,12 @@ class PublicKeyEncryptedSessionKeyPacket {
16220
16325
  }
16221
16326
  this.publicKeyAlgorithm = bytes[offset++];
16222
16327
  this.encrypted = mod.parseEncSessionKeyParams(this.publicKeyAlgorithm, bytes.subarray(offset));
16223
- if (this.version === 3 && (
16224
- this.publicKeyAlgorithm === enums.publicKey.x25519 || this.publicKeyAlgorithm === enums.publicKey.x448)) {
16225
- this.sessionKeyAlgorithm = enums.write(enums.symmetric, this.encrypted.C.algorithm);
16328
+ if (this.publicKeyAlgorithm === enums.publicKey.x25519 || this.publicKeyAlgorithm === enums.publicKey.x448) {
16329
+ if (this.version === 3) {
16330
+ this.sessionKeyAlgorithm = enums.write(enums.symmetric, this.encrypted.C.algorithm);
16331
+ } else if (this.encrypted.C.algorithm !== null) {
16332
+ throw new Error('Unexpected cleartext symmetric algorithm');
16333
+ }
16226
16334
  }
16227
16335
  }
16228
16336
 
@@ -16266,10 +16374,13 @@ class PublicKeyEncryptedSessionKeyPacket {
16266
16374
  */
16267
16375
  async encrypt(key) {
16268
16376
  const algo = enums.write(enums.publicKey, this.publicKeyAlgorithm);
16269
- const encoded = encodeSessionKey(this.version, algo, this.sessionKeyAlgorithm, this.sessionKey);
16377
+ // No symmetric encryption algorithm identifier is passed to the public-key algorithm for a
16378
+ // v6 PKESK packet, as it is included in the v2 SEIPD packet.
16379
+ const sessionKeyAlgorithm = this.version === 3 ? this.sessionKeyAlgorithm : null;
16380
+ const encoded = encodeSessionKey(this.version, algo, sessionKeyAlgorithm, this.sessionKey);
16270
16381
  const privateParams = algo === enums.publicKey.aead ? key.privateParams : null;
16271
16382
  this.encrypted = await mod.publicKeyEncrypt(
16272
- algo, this.sessionKeyAlgorithm, key.publicParams, privateParams, encoded, key.getFingerprintBytes());
16383
+ algo, sessionKeyAlgorithm, key.publicParams, privateParams, encoded, key.getFingerprintBytes());
16273
16384
  }
16274
16385
 
16275
16386
  /**
@@ -16368,6 +16479,7 @@ function decodeSessionKey(version, keyAlgo, decryptedData, randomSessionKey) {
16368
16479
  case enums.publicKey.x25519:
16369
16480
  case enums.publicKey.x448:
16370
16481
  return {
16482
+ sessionKeyAlgorithm: null,
16371
16483
  sessionKey: decryptedData
16372
16484
  };
16373
16485
  default:
@@ -18055,7 +18167,9 @@ class Signature {
18055
18167
  * @returns {ReadableStream<String>} ASCII armor.
18056
18168
  */
18057
18169
  armor(config$1 = config) {
18058
- return armor(enums.armor.signature, this.write(), undefined, undefined, undefined, config$1);
18170
+ // An ASCII-armored sequence of Signature packets that only includes v6 Signature packets MUST NOT contain a CRC24 footer.
18171
+ const emitChecksum = this.packets.some(packet => packet.constructor.tag === SignaturePacket.tag && packet.version !== 6);
18172
+ return armor(enums.armor.signature, this.write(), undefined, undefined, undefined, emitChecksum, config$1);
18059
18173
  }
18060
18174
 
18061
18175
  /**
@@ -18268,7 +18382,7 @@ async function getPreferredCompressionAlgo(keys = [], date = new Date(), userIDs
18268
18382
  async function getPreferredCipherSuite(keys = [], date = new Date(), userIDs = [], config$1 = config) {
18269
18383
  const selfSigs = await Promise.all(keys.map((key, i) => key.getPrimarySelfSignature(date, userIDs[i], config$1)));
18270
18384
  const withAEAD = keys.length ?
18271
- selfSigs.every(selfSig => selfSig.features[0] & enums.features.seipdv2) :
18385
+ !config$1.ignoreSEIPDv2FeatureFlag && selfSigs.every(selfSig => selfSig.features && (selfSig.features[0] & enums.features.seipdv2)) :
18272
18386
  config$1.aeadProtect;
18273
18387
 
18274
18388
  if (withAEAD) {
@@ -18315,8 +18429,8 @@ async function createSignaturePacket(dataToSign, privateKey, signingKeyPacket, s
18315
18429
  Object.assign(signaturePacket, signatureProperties);
18316
18430
  signaturePacket.publicKeyAlgorithm = signingKeyPacket.algorithm;
18317
18431
  signaturePacket.hashAlgorithm = await getPreferredHashAlgo(privateKey, signingKeyPacket, date, userID, config);
18318
- signaturePacket.rawNotations = notations;
18319
- await signaturePacket.sign(signingKeyPacket, dataToSign, date, detached);
18432
+ signaturePacket.rawNotations = [...notations];
18433
+ await signaturePacket.sign(signingKeyPacket, dataToSign, date, detached, config);
18320
18434
  return signaturePacket;
18321
18435
  }
18322
18436
 
@@ -18379,7 +18493,7 @@ async function isDataRevoked(primaryKey, signatureType, dataToVerify, revocation
18379
18493
  !signature || revocationSignature.issuerKeyID.equals(signature.issuerKeyID)
18380
18494
  ) {
18381
18495
  await revocationSignature.verify(
18382
- key, signatureType, dataToVerify, config.revocationsExpire ? date : null, false, config
18496
+ key, signatureType, dataToVerify, date, false, config
18383
18497
  );
18384
18498
 
18385
18499
  // TODO get an identifier of the revoked object instead
@@ -19649,7 +19763,9 @@ class Key {
19649
19763
  const revocationSignature = await getLatestValidSignature(this.revocationSignatures, this.keyPacket, enums.signature.keyRevocation, dataToVerify, date, config$1);
19650
19764
  const packetlist = new PacketList();
19651
19765
  packetlist.push(revocationSignature);
19652
- return armor(enums.armor.publicKey, packetlist.write(), null, null, 'This is a revocation certificate');
19766
+ // An ASCII-armored Transferable Public Key packet sequence of a v6 key MUST NOT contain a CRC24 footer.
19767
+ const emitChecksum = this.keyPacket.version !== 6;
19768
+ return armor(enums.armor.publicKey, packetlist.write(), null, null, 'This is a revocation certificate', emitChecksum, config$1);
19653
19769
  }
19654
19770
 
19655
19771
  /**
@@ -19839,7 +19955,9 @@ class PublicKey extends Key {
19839
19955
  * @returns {ReadableStream<String>} ASCII armor.
19840
19956
  */
19841
19957
  armor(config$1 = config) {
19842
- return armor(enums.armor.publicKey, this.toPacketList().write(), undefined, undefined, undefined, config$1);
19958
+ // An ASCII-armored Transferable Public Key packet sequence of a v6 key MUST NOT contain a CRC24 footer.
19959
+ const emitChecksum = this.keyPacket.version !== 6;
19960
+ return armor(enums.armor.publicKey, this.toPacketList().write(), undefined, undefined, undefined, emitChecksum, config$1);
19843
19961
  }
19844
19962
  }
19845
19963
 
@@ -19912,7 +20030,9 @@ class PrivateKey extends PublicKey {
19912
20030
  * @returns {ReadableStream<String>} ASCII armor.
19913
20031
  */
19914
20032
  armor(config$1 = config) {
19915
- return armor(enums.armor.privateKey, this.toPacketList().write(), undefined, undefined, undefined, config$1);
20033
+ // An ASCII-armored Transferable Public Key packet sequence of a v6 key MUST NOT contain a CRC24 footer.
20034
+ const emitChecksum = this.keyPacket.version !== 6;
20035
+ return armor(enums.armor.privateKey, this.toPacketList().write(), undefined, undefined, undefined, emitChecksum, config$1);
19916
20036
  }
19917
20037
 
19918
20038
  /**
@@ -21231,7 +21351,13 @@ class Message {
21231
21351
  * @returns {ReadableStream<String>} ASCII armor.
21232
21352
  */
21233
21353
  armor(config$1 = config) {
21234
- return armor(enums.armor.message, this.write(), null, null, null, config$1);
21354
+ const trailingPacket = this.packets[this.packets.length - 1];
21355
+ // An ASCII-armored Encrypted Message packet sequence that ends in an v2 SEIPD packet MUST NOT contain a CRC24 footer.
21356
+ // An ASCII-armored sequence of Signature packets that only includes v6 Signature packets MUST NOT contain a CRC24 footer.
21357
+ const emitChecksum = trailingPacket.constructor.tag === SymEncryptedIntegrityProtectedDataPacket.tag ?
21358
+ trailingPacket.version !== 2 :
21359
+ this.packets.some(packet => packet.constructor.tag === SignaturePacket.tag && packet.version !== 6);
21360
+ return armor(enums.armor.message, this.write(), null, null, null, emitChecksum, config$1);
21235
21361
  }
21236
21362
  }
21237
21363
 
@@ -21566,9 +21692,9 @@ class CleartextMessage {
21566
21692
  * @returns {String | ReadableStream<String>} ASCII armor.
21567
21693
  */
21568
21694
  armor(config$1 = config) {
21569
- // emit header if one of the signatures has a version not 6
21570
- const emitHeader = this.signature.packets.some(packet => packet.version !== 6);
21571
- const hash = emitHeader ?
21695
+ // emit header and checksum if one of the signatures has a version not 6
21696
+ const emitHeaderAndChecksum = this.signature.packets.some(packet => packet.version !== 6);
21697
+ const hash = emitHeaderAndChecksum ?
21572
21698
  Array.from(new Set(this.signature.packets.map(
21573
21699
  packet => enums.read(enums.hash, packet.hashAlgorithm).toUpperCase()
21574
21700
  ))).join() :
@@ -21579,7 +21705,9 @@ class CleartextMessage {
21579
21705
  text: this.text,
21580
21706
  data: this.signature.packets.write()
21581
21707
  };
21582
- return armor(enums.armor.signed, body, undefined, undefined, undefined, config$1);
21708
+
21709
+ // An ASCII-armored sequence of Signature packets that only includes v6 Signature packets MUST NOT contain a CRC24 footer.
21710
+ return armor(enums.armor.signed, body, undefined, undefined, undefined, emitHeaderAndChecksum, config$1);
21583
21711
  }
21584
21712
  }
21585
21713
 
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v6.0.0-alpha.1.patch.1 - 2024-03-11 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v6.0.0-beta.0.patch.0 - 2024-04-19 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
2
  const t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};import{B as e}from"./interface.min.mjs";import s from"./native.interface.min.mjs";import i from"./bn.interface.min.mjs";function r(t){if(!Number.isSafeInteger(t)||t<0)throw Error("Wrong positive integer: "+t)}function n(t,...e){if(!((s=t)instanceof Uint8Array||null!=s&&"object"==typeof s&&"Uint8Array"===s.constructor.name))throw Error("Expected Uint8Array");var s;if(e.length>0&&!e.includes(t.length))throw Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function h(t){if("function"!=typeof t||"function"!=typeof t.create)throw Error("Hash should be wrapped by utils.wrapConstructor");r(t.outputLen),r(t.blockLen)}function o(t,e=!0){if(t.destroyed)throw Error("Hash instance has been destroyed");if(e&&t.finished)throw Error("Hash#digest() has already been called")}function f(t,e){n(t);const s=e.outputLen;if(t.length<s)throw Error("digestInto() expects output buffer of length at least "+s)}const c="object"==typeof t&&"crypto"in t?t.crypto:void 0;
3
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function a(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}const d=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),l=(t,e)=>t<<32-e|t>>>e;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw Error("Non little-endian hardware is not supported");function b(t){if("string"!=typeof t)throw Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function u(t){if("string"==typeof t&&(t=b(t)),!a(t))throw Error("expected Uint8Array, got "+typeof t);return t}function p(...t){let e=0;for(let s=0;s<t.length;s++){const i=t[s];if(!a(i))throw Error("Uint8Array expected");e+=i.length}const s=new Uint8Array(e);for(let e=0,i=0;e<t.length;e++){const r=t[e];s.set(r,i),i+=r.length}return s}class x{clone(){return this._cloneInto()}}function w(t){const e=e=>t().update(u(e)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function g(t=32){if(c&&"function"==typeof c.getRandomValues)return c.getRandomValues(new Uint8Array(t));throw Error("crypto.getRandomValues must be defined")}e.setImplementation("undefined"!=typeof BigInt?s:i);class y extends x{constructor(t,e,s,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=d(this.buffer)}update(t){o(this);const{view:e,buffer:s,blockLen:i}=this,r=(t=u(t)).length;for(let n=0;n<r;){const h=Math.min(i-this.pos,r-n);if(h!==i)s.set(t.subarray(n,n+h),this.pos),this.pos+=h,n+=h,this.pos===i&&(this.process(e,0),this.pos=0);else{const e=d(t);for(;i<=r-n;n+=i)this.process(e,n)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){o(this),f(t,this),this.finished=!0;const{buffer:s,view:i,blockLen:r,isLE:n}=this;let{pos:h}=this;s[h++]=128,this.buffer.subarray(h).fill(0),this.padOffset>r-h&&(this.process(i,0),h=0);for(let t=h;t<r;t++)s[t]=0;!function(t,s,i,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(s,BigInt(i.toString()),r);const n=Object.freeze(e.new(32)),h=Object.freeze(e.new(4294967295)),o=i.rightShift(n).bitwiseAnd(h).toNumber(),f=i.bitwiseAnd(h).toNumber(),c=r?4:0,a=r?0:4;t.setUint32(s+c,o,r),t.setUint32(s+a,f,r)}(i,r-8,e.new(8*this.length),n),this.process(i,0);const c=d(t),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,b=this.get();if(l>b.length)throw Error("_sha2: outputLen bigger than state");for(let t=0;t<l;t++)c.setUint32(4*t,b[t],n)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const s=t.slice(0,e);return this.destroy(),s}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:s,length:i,finished:r,destroyed:n,pos:h}=this;return t.length=i,t.pos=h,t.finished=r,t.destroyed=n,i%e&&t.buffer.set(s),t}}const L=(t,e,s)=>t&e^t&s^e&s,A=/* @__PURE__ */new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),H=/* @__PURE__ */new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),E=/* @__PURE__ */new Uint32Array(64);class B extends y{constructor(){super(64,32,8,!1),this.A=0|H[0],this.B=0|H[1],this.C=0|H[2],this.D=0|H[3],this.E=0|H[4],this.F=0|H[5],this.G=0|H[6],this.H=0|H[7]}get(){const{A:t,B:e,C:s,D:i,E:r,F:n,G:h,H:o}=this;return[t,e,s,i,r,n,h,o]}set(t,e,s,i,r,n,h,o){this.A=0|t,this.B=0|e,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|h,this.H=0|o}process(t,e){for(let s=0;s<16;s++,e+=4)E[s]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=E[t-15],s=E[t-2],i=l(e,7)^l(e,18)^e>>>3,r=l(s,17)^l(s,19)^s>>>10;E[t]=r+E[t-7]+i+E[t-16]|0}let{A:s,B:i,C:r,D:n,E:h,F:o,G:f,H:c}=this;for(let t=0;t<64;t++){const e=c+(l(h,6)^l(h,11)^l(h,25))+((a=h)&o^~a&f)+A[t]+E[t]|0,d=(l(s,2)^l(s,13)^l(s,22))+L(s,i,r)|0;c=f,f=o,o=h,h=n+e|0,n=r,r=i,i=s,s=e+d|0}var a;s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,h=h+this.E|0,o=o+this.F|0,f=f+this.G|0,c=c+this.H|0,this.set(s,i,r,n,h,o,f,c)}roundClean(){E.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class m extends B{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const S=/* @__PURE__ */w((()=>new B)),U=/* @__PURE__ */w((()=>new m)),k=Object.freeze(e.new(2**32-1)),O=Object.freeze(e.new(32));function F(t,e=!1){return e?{h:t.bitwiseAnd(k).toNumber(),l:t.rightShift(O).bitwiseAnd(k).toNumber()}:{h:0|t.rightShift(O).bitwiseAnd(k).toNumber(),l:0|t.bitwiseAnd(k).toNumber()}}function C(t,e=!1){let s=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let r=0;r<t.length;r++){const{h:n,l:h}=F(t[r],e);[s[r],i[r]]=[n,h]}return[s,i]}const D=(t,e,s)=>t<<s|e>>>32-s,G=(t,e,s)=>e<<s|t>>>32-s,j=(t,e,s)=>e<<s-32|t>>>64-s,I=(t,e,s)=>t<<s-32|e>>>64-s;const v={fromBig:F,split:C,toBig:(t,s)=>e.new(t>>>0).ileftShift(O).ibitwiseOr(e.new(s>>>0)),shrSH:(t,e,s)=>t>>>s,shrSL:(t,e,s)=>t<<32-s|e>>>s,rotrSH:(t,e,s)=>t>>>s|e<<32-s,rotrSL:(t,e,s)=>t<<32-s|e>>>s,rotrBH:(t,e,s)=>t<<64-s|e>>>s-32,rotrBL:(t,e,s)=>t>>>s-32|e<<64-s,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:D,rotlSL:G,rotlBH:j,rotlBL:I,add:function(t,e,s,i){const r=(e>>>0)+(i>>>0);return{h:t+s+(r/2**32|0)|0,l:0|r}},add3L:(t,e,s)=>(t>>>0)+(e>>>0)+(s>>>0),add3H:(t,e,s,i)=>e+s+i+(t/2**32|0)|0,add4L:(t,e,s,i)=>(t>>>0)+(e>>>0)+(s>>>0)+(i>>>0),add4H:(t,e,s,i,r)=>e+s+i+r+(t/2**32|0)|0,add5H:(t,e,s,i,r,n)=>e+s+i+r+n+(t/2**32|0)|0,add5L:(t,e,s,i,r)=>(t>>>0)+(e>>>0)+(s>>>0)+(i>>>0)+(r>>>0)},[z,N]=/* @__PURE__ */(()=>v.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((t=>e.new(t)))))(),X=/* @__PURE__ */new Uint32Array(80),_=/* @__PURE__ */new Uint32Array(80);class M extends y{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:s,Bl:i,Ch:r,Cl:n,Dh:h,Dl:o,Eh:f,El:c,Fh:a,Fl:d,Gh:l,Gl:b,Hh:u,Hl:p}=this;return[t,e,s,i,r,n,h,o,f,c,a,d,l,b,u,p]}set(t,e,s,i,r,n,h,o,f,c,a,d,l,b,u,p){this.Ah=0|t,this.Al=0|e,this.Bh=0|s,this.Bl=0|i,this.Ch=0|r,this.Cl=0|n,this.Dh=0|h,this.Dl=0|o,this.Eh=0|f,this.El=0|c,this.Fh=0|a,this.Fl=0|d,this.Gh=0|l,this.Gl=0|b,this.Hh=0|u,this.Hl=0|p}process(t,e){for(let s=0;s<16;s++,e+=4)X[s]=t.getUint32(e),_[s]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|X[t-15],s=0|_[t-15],i=v.rotrSH(e,s,1)^v.rotrSH(e,s,8)^v.shrSH(e,s,7),r=v.rotrSL(e,s,1)^v.rotrSL(e,s,8)^v.shrSL(e,s,7),n=0|X[t-2],h=0|_[t-2],o=v.rotrSH(n,h,19)^v.rotrBH(n,h,61)^v.shrSH(n,h,6),f=v.rotrSL(n,h,19)^v.rotrBL(n,h,61)^v.shrSL(n,h,6),c=v.add4L(r,f,_[t-7],_[t-16]),a=v.add4H(c,i,o,X[t-7],X[t-16]);X[t]=0|a,_[t]=0|c}let{Ah:s,Al:i,Bh:r,Bl:n,Ch:h,Cl:o,Dh:f,Dl:c,Eh:a,El:d,Fh:l,Fl:b,Gh:u,Gl:p,Hh:x,Hl:w}=this;for(let t=0;t<80;t++){const e=v.rotrSH(a,d,14)^v.rotrSH(a,d,18)^v.rotrBH(a,d,41),g=v.rotrSL(a,d,14)^v.rotrSL(a,d,18)^v.rotrBL(a,d,41),y=a&l^~a&u,L=d&b^~d&p,A=v.add5L(w,g,L,N[t],_[t]),H=v.add5H(A,x,e,y,z[t],X[t]),E=0|A,B=v.rotrSH(s,i,28)^v.rotrBH(s,i,34)^v.rotrBH(s,i,39),m=v.rotrSL(s,i,28)^v.rotrBL(s,i,34)^v.rotrBL(s,i,39),S=s&r^s&h^r&h,U=i&n^i&o^n&o;x=0|u,w=0|p,u=0|l,p=0|b,l=0|a,b=0|d,({h:a,l:d}=v.add(0|f,0|c,0|H,0|E)),f=0|h,c=0|o,h=0|r,o=0|n,r=0|s,n=0|i;const k=v.add3L(E,m,U);s=v.add3H(k,H,B,S),i=0|k}({h:s,l:i}=v.add(0|this.Ah,0|this.Al,0|s,0|i)),({h:r,l:n}=v.add(0|this.Bh,0|this.Bl,0|r,0|n)),({h,l:o}=v.add(0|this.Ch,0|this.Cl,0|h,0|o)),({h:f,l:c}=v.add(0|this.Dh,0|this.Dl,0|f,0|c)),({h:a,l:d}=v.add(0|this.Eh,0|this.El,0|a,0|d)),({h:l,l:b}=v.add(0|this.Fh,0|this.Fl,0|l,0|b)),({h:u,l:p}=v.add(0|this.Gh,0|this.Gl,0|u,0|p)),({h:x,l:w}=v.add(0|this.Hh,0|this.Hl,0|x,0|w)),this.set(s,i,r,n,h,o,f,c,a,d,l,b,u,p,x,w)}roundClean(){X.fill(0),_.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class V extends M{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const R=/* @__PURE__ */w((()=>new M)),T=/* @__PURE__ */w((()=>new V)),[$,W,Z]=[[],[],[]],q=/* @__PURE__ */Object.freeze(e.new(0)),J=/* @__PURE__ */Object.freeze(e.new(1)),K=/* @__PURE__ */Object.freeze(e.new(2)),P=/* @__PURE__ */Object.freeze(e.new(7)),Q=/* @__PURE__ */Object.freeze(e.new(256)),Y=/* @__PURE__ */Object.freeze(e.new(113));for(let t=0,s=J,i=1,r=0;t<24;t++){[i,r]=[r,(2*i+3*r)%5],$.push(2*(5*r+i)),W.push((t+1)*(t+2)/2%64);const n=q.clone();for(let t=0;t<7;t++)s=s.leftShift(J).ixor(s.rightShift(P).imul(Y)).imod(Q),s.bitwiseAnd(K).isZero()||n.ixor(J.leftShift(J.leftShift(/* @__PURE__ */e.new(t)).idec()));Z.push(n)}const[tt,et]=/* @__PURE__ */C(Z,!0),st=(t,e,s)=>s>32?j(t,e,s):D(t,e,s),it=(t,e,s)=>s>32?I(t,e,s):G(t,e,s);class rt extends x{constructor(t,e,s,i=!1,n=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=s,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,r(s),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");var h;this.state=new Uint8Array(200),this.state32=(h=this.state,new Uint32Array(h.buffer,h.byteOffset,Math.floor(h.byteLength/4)))}keccak(){!function(t,e=24){const s=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let e=0;e<10;e++)s[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const i=(e+8)%10,r=(e+2)%10,n=s[r],h=s[r+1],o=st(n,h,1)^s[i],f=it(n,h,1)^s[i+1];for(let s=0;s<50;s+=10)t[e+s]^=o,t[e+s+1]^=f}let e=t[2],r=t[3];for(let s=0;s<24;s++){const i=W[s],n=st(e,r,i),h=it(e,r,i),o=$[s];e=t[o],r=t[o+1],t[o]=n,t[o+1]=h}for(let e=0;e<50;e+=10){for(let i=0;i<10;i++)s[i]=t[e+i];for(let i=0;i<10;i++)t[e+i]^=~s[(i+2)%10]&s[(i+4)%10]}t[0]^=tt[i],t[1]^=et[i]}s.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){o(this);const{blockLen:e,state:s}=this,i=(t=u(t)).length;for(let r=0;r<i;){const n=Math.min(e-this.pos,i-r);for(let e=0;e<n;e++)s[this.pos++]^=t[r++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:s,blockLen:i}=this;t[s]^=e,0!=(128&e)&&s===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){o(this,!1),n(t),this.finish();const e=this.state,{blockLen:s}=this;for(let i=0,r=t.length;i<r;){this.posOut>=s&&this.keccak();const n=Math.min(s-this.posOut,r-i);t.set(e.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return t}xofInto(t){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return r(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(f(t,this),this.finished)throw Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return t||(t=new rt(e,s,i,n,r)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=r,t.suffix=s,t.outputLen=i,t.enableXOF=n,t.destroyed=this.destroyed,t}}const nt=(t,e,s)=>w((()=>new rt(e,t,s))),ht=/* @__PURE__ */nt(6,136,32),ot=/* @__PURE__ */nt(6,72,64),ft=/* @__PURE__ */((t,e,s)=>function(t){const e=(e,s)=>t(s).update(u(e)).digest(),s=t({});return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=e=>t(e),e}(((i={})=>new rt(e,t,void 0===i.dkLen?s:i.dkLen,!0))))(31,136,32);export{x as H,y as S,T as a,n as b,p as c,R as d,o as e,ft as f,U as g,h,ht as i,ot as j,g as r,S as s,u as t,b as u,w};
3
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function a(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}const d=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),l=(t,e)=>t<<32-e|t>>>e;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw Error("Non little-endian hardware is not supported");function b(t){if("string"!=typeof t)throw Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function u(t){if("string"==typeof t&&(t=b(t)),!a(t))throw Error("expected Uint8Array, got "+typeof t);return t}function p(...t){let e=0;for(let s=0;s<t.length;s++){const i=t[s];if(!a(i))throw Error("Uint8Array expected");e+=i.length}const s=new Uint8Array(e);for(let e=0,i=0;e<t.length;e++){const r=t[e];s.set(r,i),i+=r.length}return s}class x{clone(){return this._cloneInto()}}function w(t){const e=e=>t().update(u(e)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function g(t=32){if(c&&"function"==typeof c.getRandomValues)return c.getRandomValues(new Uint8Array(t));throw Error("crypto.getRandomValues must be defined")}e.setImplementation("undefined"!=typeof BigInt?s:i);class y extends x{constructor(t,e,s,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=d(this.buffer)}update(t){o(this);const{view:e,buffer:s,blockLen:i}=this,r=(t=u(t)).length;for(let n=0;n<r;){const h=Math.min(i-this.pos,r-n);if(h!==i)s.set(t.subarray(n,n+h),this.pos),this.pos+=h,n+=h,this.pos===i&&(this.process(e,0),this.pos=0);else{const e=d(t);for(;i<=r-n;n+=i)this.process(e,n)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){o(this),f(t,this),this.finished=!0;const{buffer:s,view:i,blockLen:r,isLE:n}=this;let{pos:h}=this;s[h++]=128,this.buffer.subarray(h).fill(0),this.padOffset>r-h&&(this.process(i,0),h=0);for(let t=h;t<r;t++)s[t]=0;!function(t,s,i,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(s,BigInt(i.toString()),r);const n=Object.freeze(e.new(32)),h=Object.freeze(e.new(4294967295)),o=i.rightShift(n).bitwiseAnd(h).toNumber(),f=i.bitwiseAnd(h).toNumber(),c=r?4:0,a=r?0:4;t.setUint32(s+c,o,r),t.setUint32(s+a,f,r)}(i,r-8,e.new(8*this.length),n),this.process(i,0);const c=d(t),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,b=this.get();if(l>b.length)throw Error("_sha2: outputLen bigger than state");for(let t=0;t<l;t++)c.setUint32(4*t,b[t],n)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const s=t.slice(0,e);return this.destroy(),s}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:s,length:i,finished:r,destroyed:n,pos:h}=this;return t.length=i,t.pos=h,t.finished=r,t.destroyed=n,i%e&&t.buffer.set(s),t}}const L=(t,e,s)=>t&e^t&s^e&s,A=/* @__PURE__ */new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),H=/* @__PURE__ */new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),E=/* @__PURE__ */new Uint32Array(64);class B extends y{constructor(){super(64,32,8,!1),this.A=0|H[0],this.B=0|H[1],this.C=0|H[2],this.D=0|H[3],this.E=0|H[4],this.F=0|H[5],this.G=0|H[6],this.H=0|H[7]}get(){const{A:t,B:e,C:s,D:i,E:r,F:n,G:h,H:o}=this;return[t,e,s,i,r,n,h,o]}set(t,e,s,i,r,n,h,o){this.A=0|t,this.B=0|e,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|h,this.H=0|o}process(t,e){for(let s=0;s<16;s++,e+=4)E[s]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=E[t-15],s=E[t-2],i=l(e,7)^l(e,18)^e>>>3,r=l(s,17)^l(s,19)^s>>>10;E[t]=r+E[t-7]+i+E[t-16]|0}let{A:s,B:i,C:r,D:n,E:h,F:o,G:f,H:c}=this;for(let t=0;t<64;t++){const e=c+(l(h,6)^l(h,11)^l(h,25))+((a=h)&o^~a&f)+A[t]+E[t]|0,d=(l(s,2)^l(s,13)^l(s,22))+L(s,i,r)|0;c=f,f=o,o=h,h=n+e|0,n=r,r=i,i=s,s=e+d|0}var a;s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,h=h+this.E|0,o=o+this.F|0,f=f+this.G|0,c=c+this.H|0,this.set(s,i,r,n,h,o,f,c)}roundClean(){E.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class m extends B{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const S=/* @__PURE__ */w((()=>new B)),U=/* @__PURE__ */w((()=>new m)),k=Object.freeze(e.new(2**32-1)),O=Object.freeze(e.new(32));function F(t,e=!1){return e?{h:t.bitwiseAnd(k).toNumber(),l:t.rightShift(O).bitwiseAnd(k).toNumber()}:{h:0|t.rightShift(O).bitwiseAnd(k).toNumber(),l:0|t.bitwiseAnd(k).toNumber()}}function C(t,e=!1){let s=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let r=0;r<t.length;r++){const{h:n,l:h}=F(t[r],e);[s[r],i[r]]=[n,h]}return[s,i]}const D=(t,e,s)=>t<<s|e>>>32-s,G=(t,e,s)=>e<<s|t>>>32-s,j=(t,e,s)=>e<<s-32|t>>>64-s,I=(t,e,s)=>t<<s-32|e>>>64-s;const v={fromBig:F,split:C,toBig:(t,s)=>e.new(t>>>0).ileftShift(O).ibitwiseOr(e.new(s>>>0)),shrSH:(t,e,s)=>t>>>s,shrSL:(t,e,s)=>t<<32-s|e>>>s,rotrSH:(t,e,s)=>t>>>s|e<<32-s,rotrSL:(t,e,s)=>t<<32-s|e>>>s,rotrBH:(t,e,s)=>t<<64-s|e>>>s-32,rotrBL:(t,e,s)=>t>>>s-32|e<<64-s,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:D,rotlSL:G,rotlBH:j,rotlBL:I,add:function(t,e,s,i){const r=(e>>>0)+(i>>>0);return{h:t+s+(r/2**32|0)|0,l:0|r}},add3L:(t,e,s)=>(t>>>0)+(e>>>0)+(s>>>0),add3H:(t,e,s,i)=>e+s+i+(t/2**32|0)|0,add4L:(t,e,s,i)=>(t>>>0)+(e>>>0)+(s>>>0)+(i>>>0),add4H:(t,e,s,i,r)=>e+s+i+r+(t/2**32|0)|0,add5H:(t,e,s,i,r,n)=>e+s+i+r+n+(t/2**32|0)|0,add5L:(t,e,s,i,r)=>(t>>>0)+(e>>>0)+(s>>>0)+(i>>>0)+(r>>>0)},[z,N]=/* @__PURE__ */(()=>v.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((t=>e.new(t)))))(),X=/* @__PURE__ */new Uint32Array(80),_=/* @__PURE__ */new Uint32Array(80);class M extends y{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:s,Bl:i,Ch:r,Cl:n,Dh:h,Dl:o,Eh:f,El:c,Fh:a,Fl:d,Gh:l,Gl:b,Hh:u,Hl:p}=this;return[t,e,s,i,r,n,h,o,f,c,a,d,l,b,u,p]}set(t,e,s,i,r,n,h,o,f,c,a,d,l,b,u,p){this.Ah=0|t,this.Al=0|e,this.Bh=0|s,this.Bl=0|i,this.Ch=0|r,this.Cl=0|n,this.Dh=0|h,this.Dl=0|o,this.Eh=0|f,this.El=0|c,this.Fh=0|a,this.Fl=0|d,this.Gh=0|l,this.Gl=0|b,this.Hh=0|u,this.Hl=0|p}process(t,e){for(let s=0;s<16;s++,e+=4)X[s]=t.getUint32(e),_[s]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|X[t-15],s=0|_[t-15],i=v.rotrSH(e,s,1)^v.rotrSH(e,s,8)^v.shrSH(e,s,7),r=v.rotrSL(e,s,1)^v.rotrSL(e,s,8)^v.shrSL(e,s,7),n=0|X[t-2],h=0|_[t-2],o=v.rotrSH(n,h,19)^v.rotrBH(n,h,61)^v.shrSH(n,h,6),f=v.rotrSL(n,h,19)^v.rotrBL(n,h,61)^v.shrSL(n,h,6),c=v.add4L(r,f,_[t-7],_[t-16]),a=v.add4H(c,i,o,X[t-7],X[t-16]);X[t]=0|a,_[t]=0|c}let{Ah:s,Al:i,Bh:r,Bl:n,Ch:h,Cl:o,Dh:f,Dl:c,Eh:a,El:d,Fh:l,Fl:b,Gh:u,Gl:p,Hh:x,Hl:w}=this;for(let t=0;t<80;t++){const e=v.rotrSH(a,d,14)^v.rotrSH(a,d,18)^v.rotrBH(a,d,41),g=v.rotrSL(a,d,14)^v.rotrSL(a,d,18)^v.rotrBL(a,d,41),y=a&l^~a&u,L=d&b^~d&p,A=v.add5L(w,g,L,N[t],_[t]),H=v.add5H(A,x,e,y,z[t],X[t]),E=0|A,B=v.rotrSH(s,i,28)^v.rotrBH(s,i,34)^v.rotrBH(s,i,39),m=v.rotrSL(s,i,28)^v.rotrBL(s,i,34)^v.rotrBL(s,i,39),S=s&r^s&h^r&h,U=i&n^i&o^n&o;x=0|u,w=0|p,u=0|l,p=0|b,l=0|a,b=0|d,({h:a,l:d}=v.add(0|f,0|c,0|H,0|E)),f=0|h,c=0|o,h=0|r,o=0|n,r=0|s,n=0|i;const k=v.add3L(E,m,U);s=v.add3H(k,H,B,S),i=0|k}({h:s,l:i}=v.add(0|this.Ah,0|this.Al,0|s,0|i)),({h:r,l:n}=v.add(0|this.Bh,0|this.Bl,0|r,0|n)),({h,l:o}=v.add(0|this.Ch,0|this.Cl,0|h,0|o)),({h:f,l:c}=v.add(0|this.Dh,0|this.Dl,0|f,0|c)),({h:a,l:d}=v.add(0|this.Eh,0|this.El,0|a,0|d)),({h:l,l:b}=v.add(0|this.Fh,0|this.Fl,0|l,0|b)),({h:u,l:p}=v.add(0|this.Gh,0|this.Gl,0|u,0|p)),({h:x,l:w}=v.add(0|this.Hh,0|this.Hl,0|x,0|w)),this.set(s,i,r,n,h,o,f,c,a,d,l,b,u,p,x,w)}roundClean(){X.fill(0),_.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class V extends M{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const R=/* @__PURE__ */w((()=>new M)),T=/* @__PURE__ */w((()=>new V)),[$,W,Z]=[[],[],[]],q=/* @__PURE__ */Object.freeze(e.new(0)),J=/* @__PURE__ */Object.freeze(e.new(1)),K=/* @__PURE__ */Object.freeze(e.new(2)),P=/* @__PURE__ */Object.freeze(e.new(7)),Q=/* @__PURE__ */Object.freeze(e.new(256)),Y=/* @__PURE__ */Object.freeze(e.new(113));for(let t=0,s=J,i=1,r=0;t<24;t++){[i,r]=[r,(2*i+3*r)%5],$.push(2*(5*r+i)),W.push((t+1)*(t+2)/2%64);const n=q.clone();for(let t=0;t<7;t++)s=s.leftShift(J).ixor(s.rightShift(P).imul(Y)).imod(Q),s.bitwiseAnd(K).isZero()||n.ixor(J.leftShift(J.leftShift(/* @__PURE__ */e.new(t)).idec()));Z.push(n)}const[tt,et]=/* @__PURE__ */C(Z,!0),st=(t,e,s)=>s>32?j(t,e,s):D(t,e,s),it=(t,e,s)=>s>32?I(t,e,s):G(t,e,s);class rt extends x{constructor(t,e,s,i=!1,n=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=s,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,r(s),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");var h;this.state=new Uint8Array(200),this.state32=(h=this.state,new Uint32Array(h.buffer,h.byteOffset,Math.floor(h.byteLength/4)))}keccak(){!function(t,e=24){const s=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let e=0;e<10;e++)s[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const i=(e+8)%10,r=(e+2)%10,n=s[r],h=s[r+1],o=st(n,h,1)^s[i],f=it(n,h,1)^s[i+1];for(let s=0;s<50;s+=10)t[e+s]^=o,t[e+s+1]^=f}let e=t[2],r=t[3];for(let s=0;s<24;s++){const i=W[s],n=st(e,r,i),h=it(e,r,i),o=$[s];e=t[o],r=t[o+1],t[o]=n,t[o+1]=h}for(let e=0;e<50;e+=10){for(let i=0;i<10;i++)s[i]=t[e+i];for(let i=0;i<10;i++)t[e+i]^=~s[(i+2)%10]&s[(i+4)%10]}t[0]^=tt[i],t[1]^=et[i]}s.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){o(this);const{blockLen:e,state:s}=this,i=(t=u(t)).length;for(let r=0;r<i;){const n=Math.min(e-this.pos,i-r);for(let e=0;e<n;e++)s[this.pos++]^=t[r++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:s,blockLen:i}=this;t[s]^=e,128&e&&s===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){o(this,!1),n(t),this.finish();const e=this.state,{blockLen:s}=this;for(let i=0,r=t.length;i<r;){this.posOut>=s&&this.keccak();const n=Math.min(s-this.posOut,r-i);t.set(e.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return t}xofInto(t){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return r(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(f(t,this),this.finished)throw Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return t||(t=new rt(e,s,i,n,r)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=r,t.suffix=s,t.outputLen=i,t.enableXOF=n,t.destroyed=this.destroyed,t}}const nt=(t,e,s)=>w((()=>new rt(e,t,s))),ht=/* @__PURE__ */nt(6,136,32),ot=/* @__PURE__ */nt(6,72,64),ft=/* @__PURE__ */((t,e,s)=>function(t){const e=(e,s)=>t(s).update(u(e)).digest(),s=t({});return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=e=>t(e),e}(((i={})=>new rt(e,t,void 0===i.dkLen?s:i.dkLen,!0))))(31,136,32);export{x as H,y as S,T as a,n as b,p as c,R as d,o as e,ft as f,U as g,h,ht as i,ot as j,g as r,S as s,u as t,b as u,w};
4
4
  //# sourceMappingURL=sha3.min.mjs.map