@protontech/openpgp 6.0.0-alpha.1.patch.0 → 6.0.0-beta.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 +203 -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 +203 -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 +203 -83
  29. package/dist/openpgp.js +203 -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 +203 -83
  35. package/openpgp.d.ts +4 -3
  36. package/package.json +9 -9
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v6.0.0-alpha.1.patch.0 - 2024-03-01 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v6.0.0-beta.0 - 2024-04-18 - 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');
@@ -1577,11 +1577,6 @@ var config = {
1577
1577
  * @property {Boolean} passwordCollisionCheck
1578
1578
  */
1579
1579
  passwordCollisionCheck: false,
1580
- /**
1581
- * @memberof module:config
1582
- * @property {Boolean} revocationsExpire If true, expired revocation signatures are ignored
1583
- */
1584
- revocationsExpire: false,
1585
1580
  /**
1586
1581
  * Allow decryption using RSA keys without `encrypt` flag.
1587
1582
  * This setting is potentially insecure, but it is needed to get around an old openpgpjs bug
@@ -1657,7 +1652,7 @@ var config = {
1657
1652
  * @memberof module:config
1658
1653
  * @property {String} versionString A version string to be included in armored messages
1659
1654
  */
1660
- versionString: 'OpenPGP.js 6.0.0-alpha.1.patch.0',
1655
+ versionString: 'OpenPGP.js 6.0.0-beta.0',
1661
1656
  /**
1662
1657
  * @memberof module:config
1663
1658
  * @property {String} commentString A comment string to be included in armored messages
@@ -1677,6 +1672,14 @@ var config = {
1677
1672
  * @property {Array} knownNotations
1678
1673
  */
1679
1674
  knownNotations: [],
1675
+ /**
1676
+ * If true, a salt notation is used to randomize signatures generated by v4 and v5 keys (v6 signatures are always non-deterministic, by design).
1677
+ * This protects EdDSA signatures from potentially leaking the secret key in case of faults (i.e. bitflips) which, in principle, could occur
1678
+ * 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
1679
+ * weaknesses in the hash algo, potentially hindering e.g. some chosen-prefix attacks.
1680
+ * 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.
1681
+ */
1682
+ nonDeterministicSignaturesViaNotation: true,
1680
1683
  /**
1681
1684
  * Whether to use the the noble-curves library for curves (other than Curve25519) that are not supported by the available native crypto API.
1682
1685
  * When false, certain standard curves will not be supported (depending on the platform).
@@ -1707,14 +1710,7 @@ var config = {
1707
1710
  * @memberof module:config
1708
1711
  * @property {Set<String>} rejectCurves {@link module:enums.curve}
1709
1712
  */
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
1713
+ rejectCurves: new Set([enums.curve.secp256k1])
1718
1714
  };
1719
1715
 
1720
1716
  /**
@@ -2194,16 +2190,19 @@ const util = {
2194
2190
  },
2195
2191
 
2196
2192
  /**
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.
2193
+ * Test email format to ensure basic compliance:
2194
+ * - must include a single @
2195
+ * - no control or space unicode chars allowed
2196
+ * - no backslash and square brackets (as the latter can mess with the userID parsing)
2197
+ * - cannot end with a punctuation char
2198
+ * These checks are not meant to be exhaustive; applications are strongly encouraged to implement stricter validation,
2199
+ * e.g. based on the W3C HTML spec (https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email)).
2201
2200
  */
2202
2201
  isEmailAddress: function(data) {
2203
2202
  if (!util.isString(data)) {
2204
2203
  return false;
2205
2204
  }
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])?)*$/;
2205
+ const re = /^[^\p{C}\p{Z}@<>\\]+@[^\p{C}\p{Z}@<>\\]+[^\p{C}\p{Z}\p{P}]$/u;
2207
2206
  return re.test(data);
2208
2207
  },
2209
2208
 
@@ -2609,6 +2608,78 @@ function addheader(customComment, config) {
2609
2608
  return result;
2610
2609
  }
2611
2610
 
2611
+ /**
2612
+ * Calculates a checksum over the given data and returns it base64 encoded
2613
+ * @param {String | ReadableStream<String>} data - Data to create a CRC-24 checksum for
2614
+ * @returns {String | ReadableStream<String>} Base64 encoded checksum.
2615
+ * @private
2616
+ */
2617
+ function getCheckSum(data) {
2618
+ const crc = createcrc24(data);
2619
+ return encode$1(crc);
2620
+ }
2621
+
2622
+ // https://create.stephan-brumme.com/crc32/#slicing-by-8-overview
2623
+
2624
+ const crc_table = [
2625
+ new Array(0xFF),
2626
+ new Array(0xFF),
2627
+ new Array(0xFF),
2628
+ new Array(0xFF)
2629
+ ];
2630
+
2631
+ for (let i = 0; i <= 0xFF; i++) {
2632
+ let crc = i << 16;
2633
+ for (let j = 0; j < 8; j++) {
2634
+ crc = (crc << 1) ^ ((crc & 0x800000) !== 0 ? 0x864CFB : 0);
2635
+ }
2636
+ crc_table[0][i] =
2637
+ ((crc & 0xFF0000) >> 16) |
2638
+ (crc & 0x00FF00) |
2639
+ ((crc & 0x0000FF) << 16);
2640
+ }
2641
+ for (let i = 0; i <= 0xFF; i++) {
2642
+ crc_table[1][i] = (crc_table[0][i] >> 8) ^ crc_table[0][crc_table[0][i] & 0xFF];
2643
+ }
2644
+ for (let i = 0; i <= 0xFF; i++) {
2645
+ crc_table[2][i] = (crc_table[1][i] >> 8) ^ crc_table[0][crc_table[1][i] & 0xFF];
2646
+ }
2647
+ for (let i = 0; i <= 0xFF; i++) {
2648
+ crc_table[3][i] = (crc_table[2][i] >> 8) ^ crc_table[0][crc_table[2][i] & 0xFF];
2649
+ }
2650
+
2651
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView#Endianness
2652
+ const isLittleEndian = (function() {
2653
+ const buffer = new ArrayBuffer(2);
2654
+ new DataView(buffer).setInt16(0, 0xFF, true /* littleEndian */);
2655
+ // Int16Array uses the platform's endianness.
2656
+ return new Int16Array(buffer)[0] === 0xFF;
2657
+ }());
2658
+
2659
+ /**
2660
+ * Internal function to calculate a CRC-24 checksum over a given string (data)
2661
+ * @param {String | ReadableStream<String>} input - Data to create a CRC-24 checksum for
2662
+ * @returns {Uint8Array | ReadableStream<Uint8Array>} The CRC-24 checksum.
2663
+ * @private
2664
+ */
2665
+ function createcrc24(input) {
2666
+ let crc = 0xCE04B7;
2667
+ return transform(input, value => {
2668
+ const len32 = isLittleEndian ? Math.floor(value.length / 4) : 0;
2669
+ const arr32 = new Uint32Array(value.buffer, value.byteOffset, len32);
2670
+ for (let i = 0; i < len32; i++) {
2671
+ crc ^= arr32[i];
2672
+ crc =
2673
+ crc_table[0][(crc >> 24) & 0xFF] ^
2674
+ crc_table[1][(crc >> 16) & 0xFF] ^
2675
+ crc_table[2][(crc >> 8) & 0xFF] ^
2676
+ crc_table[3][(crc >> 0) & 0xFF];
2677
+ }
2678
+ for (let i = len32 * 4; i < value.length; i++) {
2679
+ crc = (crc >> 8) ^ crc_table[0][(crc & 0xFF) ^ value[i]];
2680
+ }
2681
+ }, () => new Uint8Array([crc, crc >> 8, crc >> 16]));
2682
+ }
2612
2683
 
2613
2684
  /**
2614
2685
  * Verify armored headers. crypto-refresh-06, section 6.2:
@@ -2764,10 +2835,13 @@ function unarmor(input) {
2764
2835
  * @param {Integer} [partIndex]
2765
2836
  * @param {Integer} [partTotal]
2766
2837
  * @param {String} [customComment] - Additional comment to add to the armored string
2838
+ * @param {Boolean} [emitChecksum] - Whether to compute and include the CRC checksum
2839
+ * (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)
2840
+ * @param {Object} [config] - Full configuration, defaults to openpgp.config
2767
2841
  * @returns {String | ReadableStream<String>} Armored text.
2768
2842
  * @static
2769
2843
  */
2770
- function armor(messageType, body, partIndex, partTotal, customComment, config$1 = config) {
2844
+ function armor(messageType, body, partIndex, partTotal, customComment, emitChecksum = false, config$1 = config) {
2771
2845
  let text;
2772
2846
  let hash;
2773
2847
  if (messageType === enums.armor.signed) {
@@ -2775,18 +2849,24 @@ function armor(messageType, body, partIndex, partTotal, customComment, config$1
2775
2849
  hash = body.hash;
2776
2850
  body = body.data;
2777
2851
  }
2852
+ // unless explicitly forbidden by the spec, we need to include the checksum to work around a GnuPG bug
2853
+ // where data fails to be decoded if the base64 ends with no padding chars (=) (see https://dev.gnupg.org/T7071)
2854
+ const maybeBodyClone = emitChecksum && passiveClone(body);
2855
+
2778
2856
  const result = [];
2779
2857
  switch (messageType) {
2780
2858
  case enums.armor.multipartSection:
2781
2859
  result.push('-----BEGIN PGP MESSAGE, PART ' + partIndex + '/' + partTotal + '-----\n');
2782
2860
  result.push(addheader(customComment, config$1));
2783
2861
  result.push(encode$1(body));
2862
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2784
2863
  result.push('-----END PGP MESSAGE, PART ' + partIndex + '/' + partTotal + '-----\n');
2785
2864
  break;
2786
2865
  case enums.armor.multipartLast:
2787
2866
  result.push('-----BEGIN PGP MESSAGE, PART ' + partIndex + '-----\n');
2788
2867
  result.push(addheader(customComment, config$1));
2789
2868
  result.push(encode$1(body));
2869
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2790
2870
  result.push('-----END PGP MESSAGE, PART ' + partIndex + '-----\n');
2791
2871
  break;
2792
2872
  case enums.armor.signed:
@@ -2796,30 +2876,35 @@ function armor(messageType, body, partIndex, partTotal, customComment, config$1
2796
2876
  result.push('\n-----BEGIN PGP SIGNATURE-----\n');
2797
2877
  result.push(addheader(customComment, config$1));
2798
2878
  result.push(encode$1(body));
2879
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2799
2880
  result.push('-----END PGP SIGNATURE-----\n');
2800
2881
  break;
2801
2882
  case enums.armor.message:
2802
2883
  result.push('-----BEGIN PGP MESSAGE-----\n');
2803
2884
  result.push(addheader(customComment, config$1));
2804
2885
  result.push(encode$1(body));
2886
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2805
2887
  result.push('-----END PGP MESSAGE-----\n');
2806
2888
  break;
2807
2889
  case enums.armor.publicKey:
2808
2890
  result.push('-----BEGIN PGP PUBLIC KEY BLOCK-----\n');
2809
2891
  result.push(addheader(customComment, config$1));
2810
2892
  result.push(encode$1(body));
2893
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2811
2894
  result.push('-----END PGP PUBLIC KEY BLOCK-----\n');
2812
2895
  break;
2813
2896
  case enums.armor.privateKey:
2814
2897
  result.push('-----BEGIN PGP PRIVATE KEY BLOCK-----\n');
2815
2898
  result.push(addheader(customComment, config$1));
2816
2899
  result.push(encode$1(body));
2900
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2817
2901
  result.push('-----END PGP PRIVATE KEY BLOCK-----\n');
2818
2902
  break;
2819
2903
  case enums.armor.signature:
2820
2904
  result.push('-----BEGIN PGP SIGNATURE-----\n');
2821
2905
  result.push(addheader(customComment, config$1));
2822
2906
  result.push(encode$1(body));
2907
+ maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone));
2823
2908
  result.push('-----END PGP SIGNATURE-----\n');
2824
2909
  break;
2825
2910
  }
@@ -9346,20 +9431,6 @@ async function sign$5(oid, hashAlgo, message, publicKey, privateKey, hashed) {
9346
9431
  }
9347
9432
  const secretKey = util.concatUint8Array([privateKey, publicKey.subarray(1)]);
9348
9433
  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
9434
  // EdDSA signature params are returned in little-endian format
9364
9435
  return {
9365
9436
  r: signature.subarray(0, 32),
@@ -9480,20 +9551,6 @@ async function sign$4(algo, hashAlgo, message, publicKey, privateKey, hashed) {
9480
9551
  case enums.publicKey.ed25519: {
9481
9552
  const secretKey = util.concatUint8Array([privateKey, publicKey]);
9482
9553
  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
9554
  return { RS: signature };
9498
9555
  }
9499
9556
  case enums.publicKey.ed448: {
@@ -11226,7 +11283,7 @@ class ECDHXSymmetricKey {
11226
11283
  * Encrypts data using specified algorithm and public key parameters.
11227
11284
  * See {@link https://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1} for public key algorithms.
11228
11285
  * @param {module:enums.publicKey} keyAlgo - Public key algorithm
11229
- * @param {module:enums.symmetric} symmetricAlgo - Cipher algorithm
11286
+ * @param {module:enums.symmetric|null} symmetricAlgo - Cipher algorithm (v3 only)
11230
11287
  * @param {Object} publicParams - Algorithm-specific public key parameters
11231
11288
  * @param {Object} privateParams - Algorithm-specific private key parameters
11232
11289
  * @param {Uint8Array} data - Data to be encrypted
@@ -11254,7 +11311,7 @@ async function publicKeyEncrypt(keyAlgo, symmetricAlgo, publicParams, privatePar
11254
11311
  }
11255
11312
  case enums.publicKey.x25519:
11256
11313
  case enums.publicKey.x448: {
11257
- if (!util.isAES(symmetricAlgo)) {
11314
+ if (symmetricAlgo && !util.isAES(symmetricAlgo)) {
11258
11315
  // see https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/276
11259
11316
  throw new Error('X25519 and X448 keys can only encrypt AES session keys');
11260
11317
  }
@@ -11886,9 +11943,26 @@ class Argon2OutOfMemoryError extends Error {
11886
11943
  let loadArgonWasmModule;
11887
11944
  let argon2Promise;
11888
11945
  // reload wasm module above this treshold, to deallocated used memory
11889
- const ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = 2 << 19;
11946
+ // (cannot be declared as a simple `static` field as its not supported by Safari 14)
11947
+ let ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = 2 << 19;
11890
11948
 
11891
11949
  class Argon2S2K {
11950
+ static get ARGON2_WASM_MEMORY_THRESHOLD_RELOAD() {
11951
+ return ARGON2_WASM_MEMORY_THRESHOLD_RELOAD;
11952
+ }
11953
+
11954
+ static set ARGON2_WASM_MEMORY_THRESHOLD_RELOAD(memoryThreshold) {
11955
+ ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = memoryThreshold;
11956
+ }
11957
+
11958
+ static reloadWasmModule() {
11959
+ if (!loadArgonWasmModule) return;
11960
+
11961
+ // it will be awaited if needed at the next `produceKey` invocation
11962
+ argon2Promise = loadArgonWasmModule();
11963
+ argon2Promise.catch(() => {});
11964
+ }
11965
+
11892
11966
  /**
11893
11967
  * @param {Object} [config] - Full configuration, defaults to openpgp.config
11894
11968
  */
@@ -11976,10 +12050,8 @@ class Argon2S2K {
11976
12050
  });
11977
12051
 
11978
12052
  // 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(() => {});
12053
+ if (decodedM > Argon2S2K.ARGON2_WASM_MEMORY_THRESHOLD_RELOAD) {
12054
+ Argon2S2K.reloadWasmModule();
11983
12055
  }
11984
12056
  return hash;
11985
12057
  } catch (e) {
@@ -14222,6 +14294,14 @@ class KeyID {
14222
14294
  // Symbol to store cryptographic validity of the signature, to avoid recomputing multiple times on verification.
14223
14295
  const verified = Symbol('verified');
14224
14296
 
14297
+ // A salt notation is used to randomize signatures.
14298
+ // This is to protect EdDSA signatures in particular, which are known to be vulnerable to fault attacks
14299
+ // leading to secret key extraction if two signatures over the same data can be collected (see https://github.com/jedisct1/libsodium/issues/170).
14300
+ // 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.
14301
+ // some chosen-prefix attacks.
14302
+ // v6 signatures do not need to rely on this notation, as they already include a separate, built-in salt.
14303
+ const SALT_NOTATION_NAME = 'salt@notations.openpgpjs.org';
14304
+
14225
14305
  // GPG puts the Issuer and Signature subpackets in the unhashed area.
14226
14306
  // Tampering with those invalidates the signature, so we still trust them and parse them.
14227
14307
  // All other unhashed subpackets are ignored.
@@ -14391,7 +14471,7 @@ class SignaturePacket {
14391
14471
  * @throws {Error} if signing failed
14392
14472
  * @async
14393
14473
  */
14394
- async sign(key, data, date = new Date(), detached = false) {
14474
+ async sign(key, data, date = new Date(), detached = false, config) {
14395
14475
  this.version = key.version;
14396
14476
 
14397
14477
  this.created = util.normalizeDate(date);
@@ -14401,6 +14481,31 @@ class SignaturePacket {
14401
14481
 
14402
14482
  const arr = [new Uint8Array([this.version, this.signatureType, this.publicKeyAlgorithm, this.hashAlgorithm])];
14403
14483
 
14484
+ // add randomness to the signature
14485
+ if (this.version === 6) {
14486
+ const saltLength = saltLengthForHash(this.hashAlgorithm);
14487
+ if (this.salt === null) {
14488
+ this.salt = mod.random.getRandomBytes(saltLength);
14489
+ } else if (saltLength !== this.salt.length) {
14490
+ throw new Error('Provided salt does not have the required length');
14491
+ }
14492
+ } else if (config.nonDeterministicSignaturesViaNotation) {
14493
+ const saltNotations = this.rawNotations.filter(({ name }) => (name === SALT_NOTATION_NAME));
14494
+ // since re-signing the same object is not supported, it's not expected to have multiple salt notations,
14495
+ // but we guard against it as a sanity check
14496
+ if (saltNotations.length === 0) {
14497
+ const saltValue = mod.random.getRandomBytes(saltLengthForHash(this.hashAlgorithm));
14498
+ this.rawNotations.push({
14499
+ name: SALT_NOTATION_NAME,
14500
+ value: saltValue,
14501
+ humanReadable: false,
14502
+ critical: false
14503
+ });
14504
+ } else {
14505
+ throw new Error('Unexpected existing salt notation');
14506
+ }
14507
+ }
14508
+
14404
14509
  // Add hashed subpackets
14405
14510
  arr.push(this.writeHashedSubPackets());
14406
14511
 
@@ -14411,14 +14516,6 @@ class SignaturePacket {
14411
14516
 
14412
14517
  this.signatureData = util.concat(arr);
14413
14518
 
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
14519
  const toHash = this.toHash(this.signatureType, data, detached);
14423
14520
  const hash = await this.hash(this.signatureType, data, toHash, detached);
14424
14521
 
@@ -16220,9 +16317,12 @@ class PublicKeyEncryptedSessionKeyPacket {
16220
16317
  }
16221
16318
  this.publicKeyAlgorithm = bytes[offset++];
16222
16319
  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);
16320
+ if (this.publicKeyAlgorithm === enums.publicKey.x25519 || this.publicKeyAlgorithm === enums.publicKey.x448) {
16321
+ if (this.version === 3) {
16322
+ this.sessionKeyAlgorithm = enums.write(enums.symmetric, this.encrypted.C.algorithm);
16323
+ } else if (this.encrypted.C.algorithm !== null) {
16324
+ throw new Error('Unexpected cleartext symmetric algorithm');
16325
+ }
16226
16326
  }
16227
16327
  }
16228
16328
 
@@ -16266,10 +16366,13 @@ class PublicKeyEncryptedSessionKeyPacket {
16266
16366
  */
16267
16367
  async encrypt(key) {
16268
16368
  const algo = enums.write(enums.publicKey, this.publicKeyAlgorithm);
16269
- const encoded = encodeSessionKey(this.version, algo, this.sessionKeyAlgorithm, this.sessionKey);
16369
+ // No symmetric encryption algorithm identifier is passed to the public-key algorithm for a
16370
+ // v6 PKESK packet, as it is included in the v2 SEIPD packet.
16371
+ const sessionKeyAlgorithm = this.version === 3 ? this.sessionKeyAlgorithm : null;
16372
+ const encoded = encodeSessionKey(this.version, algo, sessionKeyAlgorithm, this.sessionKey);
16270
16373
  const privateParams = algo === enums.publicKey.aead ? key.privateParams : null;
16271
16374
  this.encrypted = await mod.publicKeyEncrypt(
16272
- algo, this.sessionKeyAlgorithm, key.publicParams, privateParams, encoded, key.getFingerprintBytes());
16375
+ algo, sessionKeyAlgorithm, key.publicParams, privateParams, encoded, key.getFingerprintBytes());
16273
16376
  }
16274
16377
 
16275
16378
  /**
@@ -16368,6 +16471,7 @@ function decodeSessionKey(version, keyAlgo, decryptedData, randomSessionKey) {
16368
16471
  case enums.publicKey.x25519:
16369
16472
  case enums.publicKey.x448:
16370
16473
  return {
16474
+ sessionKeyAlgorithm: null,
16371
16475
  sessionKey: decryptedData
16372
16476
  };
16373
16477
  default:
@@ -18055,7 +18159,9 @@ class Signature {
18055
18159
  * @returns {ReadableStream<String>} ASCII armor.
18056
18160
  */
18057
18161
  armor(config$1 = config) {
18058
- return armor(enums.armor.signature, this.write(), undefined, undefined, undefined, config$1);
18162
+ // An ASCII-armored sequence of Signature packets that only includes v6 Signature packets MUST NOT contain a CRC24 footer.
18163
+ const emitChecksum = this.packets.some(packet => packet.constructor.tag === SignaturePacket.tag && packet.version !== 6);
18164
+ return armor(enums.armor.signature, this.write(), undefined, undefined, undefined, emitChecksum, config$1);
18059
18165
  }
18060
18166
 
18061
18167
  /**
@@ -18268,7 +18374,7 @@ async function getPreferredCompressionAlgo(keys = [], date = new Date(), userIDs
18268
18374
  async function getPreferredCipherSuite(keys = [], date = new Date(), userIDs = [], config$1 = config) {
18269
18375
  const selfSigs = await Promise.all(keys.map((key, i) => key.getPrimarySelfSignature(date, userIDs[i], config$1)));
18270
18376
  const withAEAD = keys.length ?
18271
- selfSigs.every(selfSig => selfSig.features[0] & enums.features.seipdv2) :
18377
+ selfSigs.every(selfSig => selfSig.features && (selfSig.features[0] & enums.features.seipdv2)) :
18272
18378
  config$1.aeadProtect;
18273
18379
 
18274
18380
  if (withAEAD) {
@@ -18315,8 +18421,8 @@ async function createSignaturePacket(dataToSign, privateKey, signingKeyPacket, s
18315
18421
  Object.assign(signaturePacket, signatureProperties);
18316
18422
  signaturePacket.publicKeyAlgorithm = signingKeyPacket.algorithm;
18317
18423
  signaturePacket.hashAlgorithm = await getPreferredHashAlgo(privateKey, signingKeyPacket, date, userID, config);
18318
- signaturePacket.rawNotations = notations;
18319
- await signaturePacket.sign(signingKeyPacket, dataToSign, date, detached);
18424
+ signaturePacket.rawNotations = [...notations];
18425
+ await signaturePacket.sign(signingKeyPacket, dataToSign, date, detached, config);
18320
18426
  return signaturePacket;
18321
18427
  }
18322
18428
 
@@ -18379,7 +18485,7 @@ async function isDataRevoked(primaryKey, signatureType, dataToVerify, revocation
18379
18485
  !signature || revocationSignature.issuerKeyID.equals(signature.issuerKeyID)
18380
18486
  ) {
18381
18487
  await revocationSignature.verify(
18382
- key, signatureType, dataToVerify, config.revocationsExpire ? date : null, false, config
18488
+ key, signatureType, dataToVerify, date, false, config
18383
18489
  );
18384
18490
 
18385
18491
  // TODO get an identifier of the revoked object instead
@@ -19649,7 +19755,9 @@ class Key {
19649
19755
  const revocationSignature = await getLatestValidSignature(this.revocationSignatures, this.keyPacket, enums.signature.keyRevocation, dataToVerify, date, config$1);
19650
19756
  const packetlist = new PacketList();
19651
19757
  packetlist.push(revocationSignature);
19652
- return armor(enums.armor.publicKey, packetlist.write(), null, null, 'This is a revocation certificate');
19758
+ // An ASCII-armored Transferable Public Key packet sequence of a v6 key MUST NOT contain a CRC24 footer.
19759
+ const emitChecksum = this.keyPacket.version !== 6;
19760
+ return armor(enums.armor.publicKey, packetlist.write(), null, null, 'This is a revocation certificate', emitChecksum, config$1);
19653
19761
  }
19654
19762
 
19655
19763
  /**
@@ -19839,7 +19947,9 @@ class PublicKey extends Key {
19839
19947
  * @returns {ReadableStream<String>} ASCII armor.
19840
19948
  */
19841
19949
  armor(config$1 = config) {
19842
- return armor(enums.armor.publicKey, this.toPacketList().write(), undefined, undefined, undefined, config$1);
19950
+ // An ASCII-armored Transferable Public Key packet sequence of a v6 key MUST NOT contain a CRC24 footer.
19951
+ const emitChecksum = this.keyPacket.version !== 6;
19952
+ return armor(enums.armor.publicKey, this.toPacketList().write(), undefined, undefined, undefined, emitChecksum, config$1);
19843
19953
  }
19844
19954
  }
19845
19955
 
@@ -19912,7 +20022,9 @@ class PrivateKey extends PublicKey {
19912
20022
  * @returns {ReadableStream<String>} ASCII armor.
19913
20023
  */
19914
20024
  armor(config$1 = config) {
19915
- return armor(enums.armor.privateKey, this.toPacketList().write(), undefined, undefined, undefined, config$1);
20025
+ // An ASCII-armored Transferable Public Key packet sequence of a v6 key MUST NOT contain a CRC24 footer.
20026
+ const emitChecksum = this.keyPacket.version !== 6;
20027
+ return armor(enums.armor.privateKey, this.toPacketList().write(), undefined, undefined, undefined, emitChecksum, config$1);
19916
20028
  }
19917
20029
 
19918
20030
  /**
@@ -21231,7 +21343,13 @@ class Message {
21231
21343
  * @returns {ReadableStream<String>} ASCII armor.
21232
21344
  */
21233
21345
  armor(config$1 = config) {
21234
- return armor(enums.armor.message, this.write(), null, null, null, config$1);
21346
+ const trailingPacket = this.packets[this.packets.length - 1];
21347
+ // An ASCII-armored Encrypted Message packet sequence that ends in an v2 SEIPD packet MUST NOT contain a CRC24 footer.
21348
+ // An ASCII-armored sequence of Signature packets that only includes v6 Signature packets MUST NOT contain a CRC24 footer.
21349
+ const emitChecksum = trailingPacket.constructor.tag === SymEncryptedIntegrityProtectedDataPacket.tag ?
21350
+ trailingPacket.version !== 2 :
21351
+ this.packets.some(packet => packet.constructor.tag === SignaturePacket.tag && packet.version !== 6);
21352
+ return armor(enums.armor.message, this.write(), null, null, null, emitChecksum, config$1);
21235
21353
  }
21236
21354
  }
21237
21355
 
@@ -21566,9 +21684,9 @@ class CleartextMessage {
21566
21684
  * @returns {String | ReadableStream<String>} ASCII armor.
21567
21685
  */
21568
21686
  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 ?
21687
+ // emit header and checksum if one of the signatures has a version not 6
21688
+ const emitHeaderAndChecksum = this.signature.packets.some(packet => packet.version !== 6);
21689
+ const hash = emitHeaderAndChecksum ?
21572
21690
  Array.from(new Set(this.signature.packets.map(
21573
21691
  packet => enums.read(enums.hash, packet.hashAlgorithm).toUpperCase()
21574
21692
  ))).join() :
@@ -21579,7 +21697,9 @@ class CleartextMessage {
21579
21697
  text: this.text,
21580
21698
  data: this.signature.packets.write()
21581
21699
  };
21582
- return armor(enums.armor.signed, body, undefined, undefined, undefined, config$1);
21700
+
21701
+ // An ASCII-armored sequence of Signature packets that only includes v6 Signature packets MUST NOT contain a CRC24 footer.
21702
+ return armor(enums.armor.signed, body, undefined, undefined, undefined, emitHeaderAndChecksum, config$1);
21583
21703
  }
21584
21704
  }
21585
21705
 
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v6.0.0-alpha.1.patch.0 - 2024-03-01 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v6.0.0-beta.0 - 2024-04-18 - 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