zattera-js 0.1.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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +694 -0
  3. package/dist/browser/index.js +2466 -0
  4. package/dist/browser/index.js.map +1 -0
  5. package/dist/node/auth/index.js +188 -0
  6. package/dist/node/auth/index.js.map +1 -0
  7. package/dist/node/auth/keys.js +264 -0
  8. package/dist/node/auth/keys.js.map +1 -0
  9. package/dist/node/auth/memo.js +79 -0
  10. package/dist/node/auth/memo.js.map +1 -0
  11. package/dist/node/auth/serializer.js +162 -0
  12. package/dist/node/auth/serializer.js.map +1 -0
  13. package/dist/node/client/index.js +838 -0
  14. package/dist/node/client/index.js.map +1 -0
  15. package/dist/node/index.js +30 -0
  16. package/dist/node/index.js.map +1 -0
  17. package/dist/node/node_modules/@noble/ciphers/aes.js +254 -0
  18. package/dist/node/node_modules/@noble/ciphers/aes.js.map +1 -0
  19. package/dist/node/node_modules/@noble/ciphers/utils.js +113 -0
  20. package/dist/node/node_modules/@noble/ciphers/utils.js.map +1 -0
  21. package/dist/node/node_modules/@noble/hashes/esm/_md.js +146 -0
  22. package/dist/node/node_modules/@noble/hashes/esm/_md.js.map +1 -0
  23. package/dist/node/node_modules/@noble/hashes/esm/_u64.js +51 -0
  24. package/dist/node/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
  25. package/dist/node/node_modules/@noble/hashes/esm/legacy.js +123 -0
  26. package/dist/node/node_modules/@noble/hashes/esm/legacy.js.map +1 -0
  27. package/dist/node/node_modules/@noble/hashes/esm/sha2.js +346 -0
  28. package/dist/node/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
  29. package/dist/node/node_modules/@noble/hashes/esm/utils.js +73 -0
  30. package/dist/node/node_modules/@noble/hashes/esm/utils.js.map +1 -0
  31. package/dist/node/node_modules/@noble/secp256k1/index.js +578 -0
  32. package/dist/node/node_modules/@noble/secp256k1/index.js.map +1 -0
  33. package/dist/node/node_modules/bs58/node_modules/base-x/src/esm/index.js +132 -0
  34. package/dist/node/node_modules/bs58/node_modules/base-x/src/esm/index.js.map +1 -0
  35. package/dist/node/node_modules/bs58/src/esm/index.js +7 -0
  36. package/dist/node/node_modules/bs58/src/esm/index.js.map +1 -0
  37. package/dist/node/types/index.js +48 -0
  38. package/dist/node/types/index.js.map +1 -0
  39. package/dist/node/utils/chain-id.js +9 -0
  40. package/dist/node/utils/chain-id.js.map +1 -0
  41. package/dist/types/auth/index.d.ts +134 -0
  42. package/dist/types/auth/index.d.ts.map +1 -0
  43. package/dist/types/auth/keys.d.ts +112 -0
  44. package/dist/types/auth/keys.d.ts.map +1 -0
  45. package/dist/types/auth/memo.d.ts +51 -0
  46. package/dist/types/auth/memo.d.ts.map +1 -0
  47. package/dist/types/auth/serializer.d.ts +57 -0
  48. package/dist/types/auth/serializer.d.ts.map +1 -0
  49. package/dist/types/client/index.d.ts +360 -0
  50. package/dist/types/client/index.d.ts.map +1 -0
  51. package/dist/types/index.d.ts +16 -0
  52. package/dist/types/index.d.ts.map +1 -0
  53. package/dist/types/types/index.d.ts +593 -0
  54. package/dist/types/types/index.d.ts.map +1 -0
  55. package/dist/types/utils/chain-id.d.ts +10 -0
  56. package/dist/types/utils/chain-id.d.ts.map +1 -0
  57. package/package.json +63 -0
@@ -0,0 +1,113 @@
1
+ /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
2
+ function isBytes(a) {
3
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
4
+ }
5
+ function abytes(value, length, title = "") {
6
+ const bytes = isBytes(value);
7
+ const len = value?.length;
8
+ const needsLen = length !== void 0;
9
+ if (!bytes || needsLen && len !== length) {
10
+ const prefix = title && `"${title}" `;
11
+ const ofLen = needsLen ? ` of length ${length}` : "";
12
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
13
+ throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
14
+ }
15
+ return value;
16
+ }
17
+ function u32(arr) {
18
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
19
+ }
20
+ function clean(...arrays) {
21
+ for (let i = 0; i < arrays.length; i++) {
22
+ arrays[i].fill(0);
23
+ }
24
+ }
25
+ const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
26
+ function overlapBytes(a, b) {
27
+ return a.buffer === b.buffer && // best we can do, may fail with an obscure Proxy
28
+ a.byteOffset < b.byteOffset + b.byteLength && // a starts before b end
29
+ b.byteOffset < a.byteOffset + a.byteLength;
30
+ }
31
+ function complexOverlapBytes(input, output) {
32
+ if (overlapBytes(input, output) && input.byteOffset < output.byteOffset)
33
+ throw new Error("complex overlap of input and output is not supported");
34
+ }
35
+ const wrapCipher = /* @__NO_SIDE_EFFECTS__ */ (params, constructor) => {
36
+ function wrappedCipher(key, ...args) {
37
+ abytes(key, void 0, "key");
38
+ if (!isLE)
39
+ throw new Error("Non little-endian hardware is not yet supported");
40
+ if (params.nonceLength !== void 0) {
41
+ const nonce = args[0];
42
+ abytes(nonce, params.varSizeNonce ? void 0 : params.nonceLength, "nonce");
43
+ }
44
+ const tagl = params.tagLength;
45
+ if (tagl && args[1] !== void 0)
46
+ abytes(args[1], void 0, "AAD");
47
+ const cipher = constructor(key, ...args);
48
+ const checkOutput = (fnLength, output) => {
49
+ if (output !== void 0) {
50
+ if (fnLength !== 2)
51
+ throw new Error("cipher output not supported");
52
+ abytes(output, void 0, "output");
53
+ }
54
+ };
55
+ let called = false;
56
+ const wrCipher = {
57
+ encrypt(data, output) {
58
+ if (called)
59
+ throw new Error("cannot encrypt() twice with same key + nonce");
60
+ called = true;
61
+ abytes(data);
62
+ checkOutput(cipher.encrypt.length, output);
63
+ return cipher.encrypt(data, output);
64
+ },
65
+ decrypt(data, output) {
66
+ abytes(data);
67
+ if (tagl && data.length < tagl)
68
+ throw new Error('"ciphertext" expected length bigger than tagLength=' + tagl);
69
+ checkOutput(cipher.decrypt.length, output);
70
+ return cipher.decrypt(data, output);
71
+ }
72
+ };
73
+ return wrCipher;
74
+ }
75
+ Object.assign(wrappedCipher, params);
76
+ return wrappedCipher;
77
+ };
78
+ function getOutput(expectedLength, out, onlyAligned = true) {
79
+ if (out === void 0)
80
+ return new Uint8Array(expectedLength);
81
+ if (out.length !== expectedLength)
82
+ throw new Error('"output" expected Uint8Array of length ' + expectedLength + ", got: " + out.length);
83
+ if (onlyAligned && !isAligned32(out))
84
+ throw new Error("invalid output, must be aligned");
85
+ return out;
86
+ }
87
+ function isAligned32(bytes) {
88
+ return bytes.byteOffset % 4 === 0;
89
+ }
90
+ function copyBytes(bytes) {
91
+ return Uint8Array.from(bytes);
92
+ }
93
+ function randomBytes(bytesLength = 32) {
94
+ const cr = typeof globalThis === "object" ? globalThis.crypto : null;
95
+ if (typeof cr?.getRandomValues !== "function")
96
+ throw new Error("crypto.getRandomValues must be defined");
97
+ return cr.getRandomValues(new Uint8Array(bytesLength));
98
+ }
99
+ export {
100
+ abytes,
101
+ clean,
102
+ complexOverlapBytes,
103
+ copyBytes,
104
+ getOutput,
105
+ isAligned32,
106
+ isBytes,
107
+ isLE,
108
+ overlapBytes,
109
+ randomBytes,
110
+ u32,
111
+ wrapCipher
112
+ };
113
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../../node_modules/@noble/ciphers/utils.js"],"sourcesContent":["/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */\n/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */\nexport function isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n/** Asserts something is boolean. */\nexport function abool(b) {\n if (typeof b !== 'boolean')\n throw new Error(`boolean expected, not ${b}`);\n}\n/** Asserts something is positive integer. */\nexport function anumber(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error('positive integer expected, got ' + n);\n}\n/** Asserts something is Uint8Array. */\nexport function abytes(value, length, title = '') {\n const bytes = isBytes(value);\n const len = value?.length;\n const needsLen = length !== undefined;\n if (!bytes || (needsLen && len !== length)) {\n const prefix = title && `\"${title}\" `;\n const ofLen = needsLen ? ` of length ${length}` : '';\n const got = bytes ? `length=${len}` : `type=${typeof value}`;\n throw new Error(prefix + 'expected Uint8Array' + ofLen + ', got ' + got);\n }\n return value;\n}\n/** Asserts a hash instance has not been destroyed / finished */\nexport function aexists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\n/** Asserts output is properly-sized byte array */\nexport function aoutput(out, instance) {\n abytes(out, undefined, 'output');\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n/** Cast u8 / u16 / u32 to u8. */\nexport function u8(arr) {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** Cast u8 / u16 / u32 to u32. */\nexport function u32(arr) {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n/** Zeroize a byte array. Warning: JS provides no guarantees. */\nexport function clean(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/** Create DataView of an array for easy byte-level manipulation. */\nexport function createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexport const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin = /* @__PURE__ */ (() => \n// @ts-ignore\ntypeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * Convert byte array to hex string. Uses built-in function, when available.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin)\n return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };\nfunction asciiToBase16(ch) {\n if (ch >= asciis._0 && ch <= asciis._9)\n return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F)\n return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f)\n return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n // @ts-ignore\n if (hasHexBuiltin)\n return Uint8Array.fromHex(hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n// Used in micro\nexport function hexToNumber(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n return BigInt(hex === '' ? '0' : '0x' + hex); // Big Endian\n}\n// Used in ff1\n// BE: Big Endian, LE: Little Endian\nexport function bytesToNumberBE(bytes) {\n return hexToNumber(bytesToHex(bytes));\n}\n// Used in micro, ff1\nexport function numberToBytesBE(n, len) {\n return hexToBytes(n.toString(16).padStart(len * 2, '0'));\n}\n/**\n * Converts string to bytes using UTF8 encoding.\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Converts bytes to string using UTF8 encoding.\n * @example bytesToUtf8(new Uint8Array([97, 98, 99])) // 'abc'\n */\nexport function bytesToUtf8(bytes) {\n return new TextDecoder().decode(bytes);\n}\n/**\n * Checks if two U8A use same underlying buffer and overlaps.\n * This is invalid and can corrupt data.\n */\nexport function overlapBytes(a, b) {\n return (a.buffer === b.buffer && // best we can do, may fail with an obscure Proxy\n a.byteOffset < b.byteOffset + b.byteLength && // a starts before b end\n b.byteOffset < a.byteOffset + a.byteLength // b starts before a end\n );\n}\n/**\n * If input and output overlap and input starts before output, we will overwrite end of input before\n * we start processing it, so this is not supported for most ciphers (except chacha/salse, which designed with this)\n */\nexport function complexOverlapBytes(input, output) {\n // This is very cursed. It works somehow, but I'm completely unsure,\n // reasoning about overlapping aligned windows is very hard.\n if (overlapBytes(input, output) && input.byteOffset < output.byteOffset)\n throw new Error('complex overlap of input and output is not supported');\n}\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\nexport function checkOpts(defaults, opts) {\n if (opts == null || typeof opts !== 'object')\n throw new Error('options must be defined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\n/** Compares 2 uint8array-s in kinda constant time. */\nexport function equalBytes(a, b) {\n if (a.length !== b.length)\n return false;\n let diff = 0;\n for (let i = 0; i < a.length; i++)\n diff |= a[i] ^ b[i];\n return diff === 0;\n}\n/**\n * Wraps a cipher: validates args, ensures encrypt() can only be called once.\n * @__NO_SIDE_EFFECTS__\n */\nexport const wrapCipher = (params, constructor) => {\n function wrappedCipher(key, ...args) {\n // Validate key\n abytes(key, undefined, 'key');\n // Big-Endian hardware is rare. Just in case someone still decides to run ciphers:\n if (!isLE)\n throw new Error('Non little-endian hardware is not yet supported');\n // Validate nonce if nonceLength is present\n if (params.nonceLength !== undefined) {\n const nonce = args[0];\n abytes(nonce, params.varSizeNonce ? undefined : params.nonceLength, 'nonce');\n }\n // Validate AAD if tagLength present\n const tagl = params.tagLength;\n if (tagl && args[1] !== undefined)\n abytes(args[1], undefined, 'AAD');\n const cipher = constructor(key, ...args);\n const checkOutput = (fnLength, output) => {\n if (output !== undefined) {\n if (fnLength !== 2)\n throw new Error('cipher output not supported');\n abytes(output, undefined, 'output');\n }\n };\n // Create wrapped cipher with validation and single-use encryption\n let called = false;\n const wrCipher = {\n encrypt(data, output) {\n if (called)\n throw new Error('cannot encrypt() twice with same key + nonce');\n called = true;\n abytes(data);\n checkOutput(cipher.encrypt.length, output);\n return cipher.encrypt(data, output);\n },\n decrypt(data, output) {\n abytes(data);\n if (tagl && data.length < tagl)\n throw new Error('\"ciphertext\" expected length bigger than tagLength=' + tagl);\n checkOutput(cipher.decrypt.length, output);\n return cipher.decrypt(data, output);\n },\n };\n return wrCipher;\n }\n Object.assign(wrappedCipher, params);\n return wrappedCipher;\n};\n/**\n * By default, returns u8a of length.\n * When out is available, it checks it for validity and uses it.\n */\nexport function getOutput(expectedLength, out, onlyAligned = true) {\n if (out === undefined)\n return new Uint8Array(expectedLength);\n if (out.length !== expectedLength)\n throw new Error('\"output\" expected Uint8Array of length ' + expectedLength + ', got: ' + out.length);\n if (onlyAligned && !isAligned32(out))\n throw new Error('invalid output, must be aligned');\n return out;\n}\nexport function u64Lengths(dataLength, aadLength, isLE) {\n abool(isLE);\n const num = new Uint8Array(16);\n const view = createView(num);\n view.setBigUint64(0, BigInt(aadLength), isLE);\n view.setBigUint64(8, BigInt(dataLength), isLE);\n return num;\n}\n// Is byte array aligned to 4 byte offset (u32)?\nexport function isAligned32(bytes) {\n return bytes.byteOffset % 4 === 0;\n}\n// copy bytes to new u8a (aligned). Because Buffer.slice is broken.\nexport function copyBytes(bytes) {\n return Uint8Array.from(bytes);\n}\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nexport function randomBytes(bytesLength = 32) {\n const cr = typeof globalThis === 'object' ? globalThis.crypto : null;\n if (typeof cr?.getRandomValues !== 'function')\n throw new Error('crypto.getRandomValues must be defined');\n return cr.getRandomValues(new Uint8Array(bytesLength));\n}\n/**\n * Uses CSPRG for nonce, nonce injected in ciphertext.\n * For `encrypt`, a `nonceBytes`-length buffer is fetched from CSPRNG and\n * prepended to encrypted ciphertext. For `decrypt`, first `nonceBytes` of ciphertext\n * are treated as nonce.\n *\n * NOTE: Under the same key, using random nonces (e.g. `managedNonce`) with AES-GCM and ChaCha\n * should be limited to `2**23` (8M) messages to get a collision chance of `2**-50`. Stretching to * `2**32` (4B) messages, chance would become `2**-33` - still negligible, but creeping up.\n * @example\n * const gcm = managedNonce(aes.gcm);\n * const ciphr = gcm(key).encrypt(data);\n * const plain = gcm(key).decrypt(ciph);\n */\nexport function managedNonce(fn, randomBytes_ = randomBytes) {\n const { nonceLength } = fn;\n anumber(nonceLength);\n const addNonce = (nonce, ciphertext) => {\n const out = concatBytes(nonce, ciphertext);\n ciphertext.fill(0);\n return out;\n };\n // NOTE: we cannot support DST here, it would be mistake:\n // - we don't know how much dst length cipher requires\n // - nonce may unalign dst and break everything\n // - we create new u8a anyway (concatBytes)\n // - previously we passed all args to cipher, but that was mistake!\n return ((key, ...args) => ({\n encrypt(plaintext) {\n abytes(plaintext);\n const nonce = randomBytes_(nonceLength);\n const encrypted = fn(key, nonce, ...args).encrypt(plaintext);\n // @ts-ignore\n if (encrypted instanceof Promise)\n return encrypted.then((ct) => addNonce(nonce, ct));\n return addNonce(nonce, encrypted);\n },\n decrypt(ciphertext) {\n abytes(ciphertext);\n const nonce = ciphertext.subarray(0, nonceLength);\n const decrypted = ciphertext.subarray(nonceLength);\n return fn(key, nonce, ...args).decrypt(decrypted);\n },\n }));\n}\n//# sourceMappingURL=utils.js.map"],"names":[],"mappings":"AAIA;AAEO,SAAS,QAAQ,GAAG;AACvB,SAAO,aAAa,cAAe,YAAY,OAAO,CAAC,KAAK,EAAE,YAAY,SAAS;AACvF;AAYO,SAAS,OAAO,OAAO,QAAQ,QAAQ,IAAI;AAC9C,QAAM,QAAQ,QAAQ,KAAK;AAC3B,QAAM,MAAM,OAAO;AACnB,QAAM,WAAW,WAAW;AAC5B,MAAI,CAAC,SAAU,YAAY,QAAQ,QAAS;AACxC,UAAM,SAAS,SAAS,IAAI,KAAK;AACjC,UAAM,QAAQ,WAAW,cAAc,MAAM,KAAK;AAClD,UAAM,MAAM,QAAQ,UAAU,GAAG,KAAK,QAAQ,OAAO,KAAK;AAC1D,UAAM,IAAI,MAAM,SAAS,wBAAwB,QAAQ,WAAW,GAAG;AAAA,EAC3E;AACA,SAAO;AACX;AAqBO,SAAS,IAAI,KAAK;AACrB,SAAO,IAAI,YAAY,IAAI,QAAQ,IAAI,YAAY,KAAK,MAAM,IAAI,aAAa,CAAC,CAAC;AACrF;AAEO,SAAS,SAAS,QAAQ;AAC7B,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACpC,WAAO,CAAC,EAAE,KAAK,CAAC;AAAA,EACpB;AACJ;AAMY,MAAC,OAAwB,uBAAM,IAAI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AI;AACX,YAAI,QAAQ,KAAK,SAAS;AACtB,gBAAM,IAAI,MAAM,wDAAwD,IAAI;AAChF,oBAAY,OAAO,QAAQ,QAAQ,MAAM;AACzC,eAAO,OAAO,QAAQ,MAAM,MAAM;AAAA,MACtC;AAAA,IACZ;AACQ,WAAO;AAAA,EACX;AACA,SAAO,OAAO,eAAe,MAAM;AACnC,SAAO;AACX;AAKO,SAAS,UAAU,gBAAgB,KAAK,cAAc,MAAM;AAC/D,MAAI,QAAQ;AACR,WAAO,IAAI,WAAW,cAAc;AACxC,MAAI,IAAI,WAAW;AACf,UAAM,IAAI,MAAM,4CAA4C,iBAAiB,YAAY,IAAI,MAAM;AACvG,MAAI,eAAe,CAAC,YAAY,GAAG;AAC/B,UAAM,IAAI,MAAM,iCAAiC;AACrD,SAAO;AACX;AAUO,SAAS,YAAY,OAAO;AAC/B,SAAO,MAAM,aAAa,MAAM;AACpC;AAEO,SAAS,UAAU,OAAO;AAC7B,SAAO,WAAW,KAAK,KAAK;AAChC;AAEO,SAAS,YAAY,cAAc,IAAI;AAC1C,QAAM,KAAK,OAAO,eAAe,WAAW,WAAW,SAAS;AAChE,MAAI,OAAO,IAAI,oBAAoB;AAC/B,UAAM,IAAI,MAAM,wCAAwC;AAC5D,SAAO,GAAG,gBAAgB,IAAI,WAAW,WAAW,CAAC;AACzD;","x_google_ignoreList":[0]}
@@ -0,0 +1,146 @@
1
+ import { Hash, createView, aexists, toBytes, abytes, aoutput, clean } from "./utils.js";
2
+ function setBigUint64(view, byteOffset, value, isLE) {
3
+ if (typeof view.setBigUint64 === "function")
4
+ return view.setBigUint64(byteOffset, value, isLE);
5
+ const _32n = BigInt(32);
6
+ const _u32_max = BigInt(4294967295);
7
+ const wh = Number(value >> _32n & _u32_max);
8
+ const wl = Number(value & _u32_max);
9
+ const h = isLE ? 4 : 0;
10
+ const l = isLE ? 0 : 4;
11
+ view.setUint32(byteOffset + h, wh, isLE);
12
+ view.setUint32(byteOffset + l, wl, isLE);
13
+ }
14
+ function Chi(a, b, c) {
15
+ return a & b ^ ~a & c;
16
+ }
17
+ function Maj(a, b, c) {
18
+ return a & b ^ a & c ^ b & c;
19
+ }
20
+ class HashMD extends Hash {
21
+ constructor(blockLen, outputLen, padOffset, isLE) {
22
+ super();
23
+ this.finished = false;
24
+ this.length = 0;
25
+ this.pos = 0;
26
+ this.destroyed = false;
27
+ this.blockLen = blockLen;
28
+ this.outputLen = outputLen;
29
+ this.padOffset = padOffset;
30
+ this.isLE = isLE;
31
+ this.buffer = new Uint8Array(blockLen);
32
+ this.view = createView(this.buffer);
33
+ }
34
+ update(data) {
35
+ aexists(this);
36
+ data = toBytes(data);
37
+ abytes(data);
38
+ const { view, buffer, blockLen } = this;
39
+ const len = data.length;
40
+ for (let pos = 0; pos < len; ) {
41
+ const take = Math.min(blockLen - this.pos, len - pos);
42
+ if (take === blockLen) {
43
+ const dataView = createView(data);
44
+ for (; blockLen <= len - pos; pos += blockLen)
45
+ this.process(dataView, pos);
46
+ continue;
47
+ }
48
+ buffer.set(data.subarray(pos, pos + take), this.pos);
49
+ this.pos += take;
50
+ pos += take;
51
+ if (this.pos === blockLen) {
52
+ this.process(view, 0);
53
+ this.pos = 0;
54
+ }
55
+ }
56
+ this.length += data.length;
57
+ this.roundClean();
58
+ return this;
59
+ }
60
+ digestInto(out) {
61
+ aexists(this);
62
+ aoutput(out, this);
63
+ this.finished = true;
64
+ const { buffer, view, blockLen, isLE } = this;
65
+ let { pos } = this;
66
+ buffer[pos++] = 128;
67
+ clean(this.buffer.subarray(pos));
68
+ if (this.padOffset > blockLen - pos) {
69
+ this.process(view, 0);
70
+ pos = 0;
71
+ }
72
+ for (let i = pos; i < blockLen; i++)
73
+ buffer[i] = 0;
74
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
75
+ this.process(view, 0);
76
+ const oview = createView(out);
77
+ const len = this.outputLen;
78
+ if (len % 4)
79
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
80
+ const outLen = len / 4;
81
+ const state = this.get();
82
+ if (outLen > state.length)
83
+ throw new Error("_sha2: outputLen bigger than state");
84
+ for (let i = 0; i < outLen; i++)
85
+ oview.setUint32(4 * i, state[i], isLE);
86
+ }
87
+ digest() {
88
+ const { buffer, outputLen } = this;
89
+ this.digestInto(buffer);
90
+ const res = buffer.slice(0, outputLen);
91
+ this.destroy();
92
+ return res;
93
+ }
94
+ _cloneInto(to) {
95
+ to || (to = new this.constructor());
96
+ to.set(...this.get());
97
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
98
+ to.destroyed = destroyed;
99
+ to.finished = finished;
100
+ to.length = length;
101
+ to.pos = pos;
102
+ if (length % blockLen)
103
+ to.buffer.set(buffer);
104
+ return to;
105
+ }
106
+ clone() {
107
+ return this._cloneInto();
108
+ }
109
+ }
110
+ const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
111
+ 1779033703,
112
+ 3144134277,
113
+ 1013904242,
114
+ 2773480762,
115
+ 1359893119,
116
+ 2600822924,
117
+ 528734635,
118
+ 1541459225
119
+ ]);
120
+ const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
121
+ 1779033703,
122
+ 4089235720,
123
+ 3144134277,
124
+ 2227873595,
125
+ 1013904242,
126
+ 4271175723,
127
+ 2773480762,
128
+ 1595750129,
129
+ 1359893119,
130
+ 2917565137,
131
+ 2600822924,
132
+ 725511199,
133
+ 528734635,
134
+ 4215389547,
135
+ 1541459225,
136
+ 327033209
137
+ ]);
138
+ export {
139
+ Chi,
140
+ HashMD,
141
+ Maj,
142
+ SHA256_IV,
143
+ SHA512_IV,
144
+ setBigUint64
145
+ };
146
+ //# sourceMappingURL=_md.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_md.js","sources":["../../../../../../node_modules/@noble/hashes/esm/_md.js"],"sourcesContent":["/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\nimport { Hash, abytes, aexists, aoutput, clean, createView, toBytes } from \"./utils.js\";\n/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */\nexport function setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/** Choice: a ? b : c */\nexport function Chi(a, b, c) {\n return (a & b) ^ (~a & c);\n}\n/** Majority function, true if any two inputs is true. */\nexport function Maj(a, b, c) {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport class HashMD extends Hash {\n constructor(blockLen, outputLen, padOffset, isLE) {\n super();\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data) {\n aexists(this);\n data = toBytes(data);\n abytes(data);\n const { view, buffer, blockLen } = this;\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n clean(this.buffer.subarray(pos));\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.destroyed = destroyed;\n to.finished = finished;\n to.length = length;\n to.pos = pos;\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n clone() {\n return this._cloneInto();\n }\n}\n/**\n * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.\n * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.\n */\n/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */\nexport const SHA256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */\nexport const SHA224_IV = /* @__PURE__ */ Uint32Array.from([\n 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,\n]);\n/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */\nexport const SHA384_IV = /* @__PURE__ */ Uint32Array.from([\n 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939,\n 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4,\n]);\n/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */\nexport const SHA512_IV = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,\n 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,\n]);\n//# sourceMappingURL=_md.js.map"],"names":[],"mappings":";AAMO,SAAS,aAAa,MAAM,YAAY,OAAO,MAAM;AACxD,MAAI,OAAO,KAAK,iBAAiB;AAC7B,WAAO,KAAK,aAAa,YAAY,OAAO,IAAI;AACpD,QAAM,OAAO,OAAO,EAAE;AACtB,QAAM,WAAW,OAAO,UAAU;AAClC,QAAM,KAAK,OAAQ,SAAS,OAAQ,QAAQ;AAC5C,QAAM,KAAK,OAAO,QAAQ,QAAQ;AAClC,QAAM,IAAI,OAAO,IAAI;AACrB,QAAM,IAAI,OAAO,IAAI;AACrB,OAAK,UAAU,aAAa,GAAG,IAAI,IAAI;AACvC,OAAK,UAAU,aAAa,GAAG,IAAI,IAAI;AAC3C;AAEO,SAAS,IAAI,GAAG,GAAG,GAAG;AACzB,SAAQ,IAAI,IAAM,CAAC,IAAI;AAC3B;AAEO,S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AA,EAAY;AAAA,EAAY;AAAA,EAAY;AACxF,CAAC;AAWW,MAAC,YAA4B,4BAAY,KAAK;AAAA,EACtD;AAAA,EAAY;AAAA,EAAY;AAAA,EAAY;AAAA,EAAY;AAAA,EAAY;AAAA,EAAY;AAAA,EAAY;AAAA,EACpF;AAAA,EAAY;AAAA,EAAY;AAAA,EAAY;AAAA,EAAY;AAAA,EAAY;AAAA,EAAY;AAAA,EAAY;AACxF,CAAC;","x_google_ignoreList":[0]}
@@ -0,0 +1,51 @@
1
+ const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
2
+ const _32n = /* @__PURE__ */ BigInt(32);
3
+ function fromBig(n, le = false) {
4
+ if (le)
5
+ return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
6
+ return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
7
+ }
8
+ function split(lst, le = false) {
9
+ const len = lst.length;
10
+ let Ah = new Uint32Array(len);
11
+ let Al = new Uint32Array(len);
12
+ for (let i = 0; i < len; i++) {
13
+ const { h, l } = fromBig(lst[i], le);
14
+ [Ah[i], Al[i]] = [h, l];
15
+ }
16
+ return [Ah, Al];
17
+ }
18
+ const shrSH = (h, _l, s) => h >>> s;
19
+ const shrSL = (h, l, s) => h << 32 - s | l >>> s;
20
+ const rotrSH = (h, l, s) => h >>> s | l << 32 - s;
21
+ const rotrSL = (h, l, s) => h << 32 - s | l >>> s;
22
+ const rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
23
+ const rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
24
+ function add(Ah, Al, Bh, Bl) {
25
+ const l = (Al >>> 0) + (Bl >>> 0);
26
+ return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
27
+ }
28
+ const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
29
+ const add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
30
+ const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
31
+ const add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
32
+ const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
33
+ const add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
34
+ export {
35
+ add,
36
+ add3H,
37
+ add3L,
38
+ add4H,
39
+ add4L,
40
+ add5H,
41
+ add5L,
42
+ fromBig,
43
+ rotrBH,
44
+ rotrBL,
45
+ rotrSH,
46
+ rotrSL,
47
+ shrSH,
48
+ shrSL,
49
+ split
50
+ };
51
+ //# sourceMappingURL=_u64.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_u64.js","sources":["../../../../../../node_modules/@noble/hashes/esm/_u64.js"],"sourcesContent":["/**\n * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.\n * @todo re-check https://issues.chromium.org/issues/42212588\n * @module\n */\nconst U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);\nconst _32n = /* @__PURE__ */ BigInt(32);\nfunction fromBig(n, le = false) {\n if (le)\n return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };\n return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };\n}\nfunction split(lst, le = false) {\n const len = lst.length;\n let Ah = new Uint32Array(len);\n let Al = new Uint32Array(len);\n for (let i = 0; i < len; i++) {\n const { h, l } = fromBig(lst[i], le);\n [Ah[i], Al[i]] = [h, l];\n }\n return [Ah, Al];\n}\nconst toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);\n// for Shift in [0, 32)\nconst shrSH = (h, _l, s) => h >>> s;\nconst shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in [1, 32)\nconst rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));\nconst rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));\nconst rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));\n// Right rotate for shift===32 (just swaps l&h)\nconst rotr32H = (_h, l) => l;\nconst rotr32L = (h, _l) => h;\n// Left rotate for Shift in [1, 32)\nconst rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));\nconst rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));\n// Left rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));\nconst rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));\n// JS uses 32-bit signed integers for bitwise operations which means we cannot\n// simple take carry out of low bit sum by shift, we need to use division.\nfunction add(Ah, Al, Bh, Bl) {\n const l = (Al >>> 0) + (Bl >>> 0);\n return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };\n}\n// Addition with more than 2 elements\nconst add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);\nconst add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;\nconst add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);\nconst add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;\nconst add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);\nconst add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;\n// prettier-ignore\nexport { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig };\n// prettier-ignore\nconst u64 = {\n fromBig, split, toBig,\n shrSH, shrSL,\n rotrSH, rotrSL, rotrBH, rotrBL,\n rotr32H, rotr32L,\n rotlSH, rotlSL, rotlBH, rotlBL,\n add, add3L, add3H, add4L, add4H, add5H, add5L,\n};\nexport default u64;\n//# sourceMappingURL=_u64.js.map"],"names":[],"mappings":"AAKA,MAAM,aAA6B,uBAAO,KAAK,KAAK,CAAC;AACrD,MAAM,OAAuB,uBAAO,EAAE;AACtC,SAAS,QAAQ,GAAG,KAAK,OAAO;AAC5B,MAAI;AACA,WAAO,EAAE,GAAG,OAAO,IAAI,UAAU,GAAG,GAAG,OAAQ,KAAK,OAAQ,UAAU,EAAC;AAC3E,SAAO,EAAE,GAAG,OAAQ,KAAK,OAAQ,UAAU,IAAI,GAAG,GAAG,OAAO,IAAI,UAAU,IAAI,EAAC;AACnF;AACA,SAAS,MAAM,KAAK,KAAK,OAAO;AAC5B,QAAM,MAAM,IAAI;AAChB,MAAI,KAAK,IAAI,YAAY,GAAG;AAC5B,MAAI,KAAK,IAAI,YAAY,GAAG;AAC5B,WAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC1B,UAAM,EAAE,GAAG,EAAC,IAAK,QAAQ,IAAI,CAAC,GAAG,EAAE;AACnC,KAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;AAAA,EAC1B;AACA,SAAO,CAAC,IAAI,EAAE;AAClB;AAGK,MAAC,QAAQ,CAAC,GAAG,IAAI,MAAM,MAAM;AAC7B,MAAC,QAAQ,CAAC,GAAG,GAAG,MAAO,KAAM,KAAK,IAAO,MAAM;AAE/C,MAA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+ 15,
11
+ 3,
12
+ 12,
13
+ 0,
14
+ 9,
15
+ 5,
16
+ 2,
17
+ 14,
18
+ 11,
19
+ 8
20
+ ]);
21
+ const Id160 = /* @__PURE__ */ (() => Uint8Array.from(new Array(16).fill(0).map((_, i) => i)))();
22
+ const Pi160 = /* @__PURE__ */ (() => Id160.map((i) => (9 * i + 5) % 16))();
23
+ const idxLR = /* @__PURE__ */ (() => {
24
+ const L = [Id160];
25
+ const R = [Pi160];
26
+ const res = [L, R];
27
+ for (let i = 0; i < 4; i++)
28
+ for (let j of res)
29
+ j.push(j[i].map((k) => Rho160[k]));
30
+ return res;
31
+ })();
32
+ const idxL = /* @__PURE__ */ (() => idxLR[0])();
33
+ const idxR = /* @__PURE__ */ (() => idxLR[1])();
34
+ const shifts160 = /* @__PURE__ */ [
35
+ [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
36
+ [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
37
+ [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
38
+ [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
39
+ [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
40
+ ].map((i) => Uint8Array.from(i));
41
+ const shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j]));
42
+ const shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j]));
43
+ const Kl160 = /* @__PURE__ */ Uint32Array.from([
44
+ 0,
45
+ 1518500249,
46
+ 1859775393,
47
+ 2400959708,
48
+ 2840853838
49
+ ]);
50
+ const Kr160 = /* @__PURE__ */ Uint32Array.from([
51
+ 1352829926,
52
+ 1548603684,
53
+ 1836072691,
54
+ 2053994217,
55
+ 0
56
+ ]);
57
+ function ripemd_f(group, x, y, z) {
58
+ if (group === 0)
59
+ return x ^ y ^ z;
60
+ if (group === 1)
61
+ return x & y | ~x & z;
62
+ if (group === 2)
63
+ return (x | ~y) ^ z;
64
+ if (group === 3)
65
+ return x & z | y & ~z;
66
+ return x ^ (y | ~z);
67
+ }
68
+ const BUF_160 = /* @__PURE__ */ new Uint32Array(16);
69
+ class RIPEMD160 extends HashMD {
70
+ constructor() {
71
+ super(64, 20, 8, true);
72
+ this.h0 = 1732584193 | 0;
73
+ this.h1 = 4023233417 | 0;
74
+ this.h2 = 2562383102 | 0;
75
+ this.h3 = 271733878 | 0;
76
+ this.h4 = 3285377520 | 0;
77
+ }
78
+ get() {
79
+ const { h0, h1, h2, h3, h4 } = this;
80
+ return [h0, h1, h2, h3, h4];
81
+ }
82
+ set(h0, h1, h2, h3, h4) {
83
+ this.h0 = h0 | 0;
84
+ this.h1 = h1 | 0;
85
+ this.h2 = h2 | 0;
86
+ this.h3 = h3 | 0;
87
+ this.h4 = h4 | 0;
88
+ }
89
+ process(view, offset) {
90
+ for (let i = 0; i < 16; i++, offset += 4)
91
+ BUF_160[i] = view.getUint32(offset, true);
92
+ let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el;
93
+ for (let group = 0; group < 5; group++) {
94
+ const rGroup = 4 - group;
95
+ const hbl = Kl160[group], hbr = Kr160[group];
96
+ const rl = idxL[group], rr = idxR[group];
97
+ const sl = shiftsL160[group], sr = shiftsR160[group];
98
+ for (let i = 0; i < 16; i++) {
99
+ const tl = rotl(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el | 0;
100
+ al = el, el = dl, dl = rotl(cl, 10) | 0, cl = bl, bl = tl;
101
+ }
102
+ for (let i = 0; i < 16; i++) {
103
+ const tr = rotl(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er | 0;
104
+ ar = er, er = dr, dr = rotl(cr, 10) | 0, cr = br, br = tr;
105
+ }
106
+ }
107
+ this.set(this.h1 + cl + dr | 0, this.h2 + dl + er | 0, this.h3 + el + ar | 0, this.h4 + al + br | 0, this.h0 + bl + cr | 0);
108
+ }
109
+ roundClean() {
110
+ clean(BUF_160);
111
+ }
112
+ destroy() {
113
+ this.destroyed = true;
114
+ clean(this.buffer);
115
+ this.set(0, 0, 0, 0, 0);
116
+ }
117
+ }
118
+ const ripemd160 = /* @__PURE__ */ createHasher(() => new RIPEMD160());
119
+ export {
120
+ RIPEMD160,
121
+ ripemd160
122
+ };
123
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.js","sources":["../../../../../../node_modules/@noble/hashes/esm/legacy.js"],"sourcesContent":["/**\n\nSHA1 (RFC 3174), MD5 (RFC 1321) and RIPEMD160 (RFC 2286) legacy, weak hash functions.\nDon't use them in a new protocol. What \"weak\" means:\n\n- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160.\n- No practical pre-image attacks (only theoretical, 2^123.4)\n- HMAC seems kinda ok: https://datatracker.ietf.org/doc/html/rfc6151\n * @module\n */\nimport { Chi, HashMD, Maj } from \"./_md.js\";\nimport { clean, createHasher, rotl } from \"./utils.js\";\n/** Initial SHA1 state */\nconst SHA1_IV = /* @__PURE__ */ Uint32Array.from([\n 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0,\n]);\n// Reusable temporary buffer\nconst SHA1_W = /* @__PURE__ */ new Uint32Array(80);\n/** SHA1 legacy hash class. */\nexport class SHA1 extends HashMD {\n constructor() {\n super(64, 20, 8, false);\n this.A = SHA1_IV[0] | 0;\n this.B = SHA1_IV[1] | 0;\n this.C = SHA1_IV[2] | 0;\n this.D = SHA1_IV[3] | 0;\n this.E = SHA1_IV[4] | 0;\n }\n get() {\n const { A, B, C, D, E } = this;\n return [A, B, C, D, E];\n }\n set(A, B, C, D, E) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n }\n process(view, offset) {\n for (let i = 0; i < 16; i++, offset += 4)\n SHA1_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 80; i++)\n SHA1_W[i] = rotl(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1);\n // Compression function main loop, 80 rounds\n let { A, B, C, D, E } = this;\n for (let i = 0; i < 80; i++) {\n let F, K;\n if (i < 20) {\n F = Chi(B, C, D);\n K = 0x5a827999;\n }\n else if (i < 40) {\n F = B ^ C ^ D;\n K = 0x6ed9eba1;\n }\n else if (i < 60) {\n F = Maj(B, C, D);\n K = 0x8f1bbcdc;\n }\n else {\n F = B ^ C ^ D;\n K = 0xca62c1d6;\n }\n const T = (rotl(A, 5) + F + E + K + SHA1_W[i]) | 0;\n E = D;\n D = C;\n C = rotl(B, 30);\n B = A;\n A = T;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n this.set(A, B, C, D, E);\n }\n roundClean() {\n clean(SHA1_W);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0);\n clean(this.buffer);\n }\n}\n/** SHA1 (RFC 3174) legacy hash function. It was cryptographically broken. */\nexport const sha1 = /* @__PURE__ */ createHasher(() => new SHA1());\n/** Per-round constants */\nconst p32 = /* @__PURE__ */ Math.pow(2, 32);\nconst K = /* @__PURE__ */ Array.from({ length: 64 }, (_, i) => Math.floor(p32 * Math.abs(Math.sin(i + 1))));\n/** md5 initial state: same as sha1, but 4 u32 instead of 5. */\nconst MD5_IV = /* @__PURE__ */ SHA1_IV.slice(0, 4);\n// Reusable temporary buffer\nconst MD5_W = /* @__PURE__ */ new Uint32Array(16);\n/** MD5 legacy hash class. */\nexport class MD5 extends HashMD {\n constructor() {\n super(64, 16, 8, true);\n this.A = MD5_IV[0] | 0;\n this.B = MD5_IV[1] | 0;\n this.C = MD5_IV[2] | 0;\n this.D = MD5_IV[3] | 0;\n }\n get() {\n const { A, B, C, D } = this;\n return [A, B, C, D];\n }\n set(A, B, C, D) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n }\n process(view, offset) {\n for (let i = 0; i < 16; i++, offset += 4)\n MD5_W[i] = view.getUint32(offset, true);\n // Compression function main loop, 64 rounds\n let { A, B, C, D } = this;\n for (let i = 0; i < 64; i++) {\n let F, g, s;\n if (i < 16) {\n F = Chi(B, C, D);\n g = i;\n s = [7, 12, 17, 22];\n }\n else if (i < 32) {\n F = Chi(D, B, C);\n g = (5 * i + 1) % 16;\n s = [5, 9, 14, 20];\n }\n else if (i < 48) {\n F = B ^ C ^ D;\n g = (3 * i + 5) % 16;\n s = [4, 11, 16, 23];\n }\n else {\n F = C ^ (B | ~D);\n g = (7 * i) % 16;\n s = [6, 10, 15, 21];\n }\n F = F + A + K[i] + MD5_W[g];\n A = D;\n D = C;\n C = B;\n B = B + rotl(F, s[i % 4]);\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n this.set(A, B, C, D);\n }\n roundClean() {\n clean(MD5_W);\n }\n destroy() {\n this.set(0, 0, 0, 0);\n clean(this.buffer);\n }\n}\n/**\n * MD5 (RFC 1321) legacy hash function. It was cryptographically broken.\n * MD5 architecture is similar to SHA1, with some differences:\n * - Reduced output length: 16 bytes (128 bit) instead of 20\n * - 64 rounds, instead of 80\n * - Little-endian: could be faster, but will require more code\n * - Non-linear index selection: huge speed-up for unroll\n * - Per round constants: more memory accesses, additional speed-up for unroll\n */\nexport const md5 = /* @__PURE__ */ createHasher(() => new MD5());\n// RIPEMD-160\nconst Rho160 = /* @__PURE__ */ Uint8Array.from([\n 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,\n]);\nconst Id160 = /* @__PURE__ */ (() => Uint8Array.from(new Array(16).fill(0).map((_, i) => i)))();\nconst Pi160 = /* @__PURE__ */ (() => Id160.map((i) => (9 * i + 5) % 16))();\nconst idxLR = /* @__PURE__ */ (() => {\n const L = [Id160];\n const R = [Pi160];\n const res = [L, R];\n for (let i = 0; i < 4; i++)\n for (let j of res)\n j.push(j[i].map((k) => Rho160[k]));\n return res;\n})();\nconst idxL = /* @__PURE__ */ (() => idxLR[0])();\nconst idxR = /* @__PURE__ */ (() => idxLR[1])();\n// const [idxL, idxR] = idxLR;\nconst shifts160 = /* @__PURE__ */ [\n [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],\n [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],\n [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],\n [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],\n [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5],\n].map((i) => Uint8Array.from(i));\nconst shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j]));\nconst shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j]));\nconst Kl160 = /* @__PURE__ */ Uint32Array.from([\n 0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e,\n]);\nconst Kr160 = /* @__PURE__ */ Uint32Array.from([\n 0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000,\n]);\n// It's called f() in spec.\nfunction ripemd_f(group, x, y, z) {\n if (group === 0)\n return x ^ y ^ z;\n if (group === 1)\n return (x & y) | (~x & z);\n if (group === 2)\n return (x | ~y) ^ z;\n if (group === 3)\n return (x & z) | (y & ~z);\n return x ^ (y | ~z);\n}\n// Reusable temporary buffer\nconst BUF_160 = /* @__PURE__ */ new Uint32Array(16);\nexport class RIPEMD160 extends HashMD {\n constructor() {\n super(64, 20, 8, true);\n this.h0 = 0x67452301 | 0;\n this.h1 = 0xefcdab89 | 0;\n this.h2 = 0x98badcfe | 0;\n this.h3 = 0x10325476 | 0;\n this.h4 = 0xc3d2e1f0 | 0;\n }\n get() {\n const { h0, h1, h2, h3, h4 } = this;\n return [h0, h1, h2, h3, h4];\n }\n set(h0, h1, h2, h3, h4) {\n this.h0 = h0 | 0;\n this.h1 = h1 | 0;\n this.h2 = h2 | 0;\n this.h3 = h3 | 0;\n this.h4 = h4 | 0;\n }\n process(view, offset) {\n for (let i = 0; i < 16; i++, offset += 4)\n BUF_160[i] = view.getUint32(offset, true);\n // prettier-ignore\n let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el;\n // Instead of iterating 0 to 80, we split it into 5 groups\n // And use the groups in constants, functions, etc. Much simpler\n for (let group = 0; group < 5; group++) {\n const rGroup = 4 - group;\n const hbl = Kl160[group], hbr = Kr160[group]; // prettier-ignore\n const rl = idxL[group], rr = idxR[group]; // prettier-ignore\n const sl = shiftsL160[group], sr = shiftsR160[group]; // prettier-ignore\n for (let i = 0; i < 16; i++) {\n const tl = (rotl(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el) | 0;\n al = el, el = dl, dl = rotl(cl, 10) | 0, cl = bl, bl = tl; // prettier-ignore\n }\n // 2 loops are 10% faster\n for (let i = 0; i < 16; i++) {\n const tr = (rotl(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er) | 0;\n ar = er, er = dr, dr = rotl(cr, 10) | 0, cr = br, br = tr; // prettier-ignore\n }\n }\n // Add the compressed chunk to the current hash value\n this.set((this.h1 + cl + dr) | 0, (this.h2 + dl + er) | 0, (this.h3 + el + ar) | 0, (this.h4 + al + br) | 0, (this.h0 + bl + cr) | 0);\n }\n roundClean() {\n clean(BUF_160);\n }\n destroy() {\n this.destroyed = true;\n clean(this.buffer);\n this.set(0, 0, 0, 0, 0);\n }\n}\n/**\n * RIPEMD-160 - a legacy hash function from 1990s.\n * * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html\n * * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf\n */\nexport const ripemd160 = /* @__PURE__ */ createHasher(() => new RIPEMD160());\n//# sourceMappingURL=legacy.js.map"],"names":[],"mappings":";;AA8KA,MAAM,SAAyB,2BAAW,KAAK;AAAA,EAC3C;AAAA,EAAG;AAAA,EAAG;AAAA,EAAI;AAAA,EAAG;AAAA,EAAI;AAAA,EAAG;AAAA,EAAI;AAAA,EAAG;AAAA,EAAI;AAAA,EAAG;AAAA,EAAG;AAAA,EAAG;AAAA,EAAG;AAAA,EAAI;AAAA,EAAI;AACvD,CAAC;AACD,MAAM,QAAyB,uBAAM,WAAW,KAAK,IAAI,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,GAAC;AAC5F,MAAM,QAAyB,uBAAM,MAAM,IAAI,CAAC,OAAO,IAAI,IAAI,KAAK,EAAE,GAAC;AACvE,MAAM,QAAyB,uBAAM;AACjC,QAAM,IAAI,CAAC,KAAK;AAChB,QAAM,IAAI,CAAC,KAAK;AAChB,QAAM,MAAM,CAAC,GAAG,CAAC;AACjB,WAAS,IAAI,GAAG,IAAI,GAAG;AACnB,aAAS,KAAK;AACV,QAAE,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC;AACzC,SAAO;AACX,GAAC;AACD,MAAM,OAAwB,uBAAM,MAAM,CAAC,GAAC;AAC5C,MAAM,OAAwB,uBAAM,MAAM,CAAC,GAAC;AAE5C,MAAM,YAA4B;AAAA,EAC9B,CAAC,IAAI,IAAI,IAAI,IAAI,GAAG,G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