@protontech/openpgp 6.1.1-patch.4 → 6.2.1

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 (49) hide show
  1. package/README.md +13 -2
  2. package/dist/lightweight/argon2id.min.mjs +2 -2
  3. package/dist/lightweight/argon2id.min.mjs.map +1 -1
  4. package/dist/lightweight/argon2id.mjs +4 -4
  5. package/dist/lightweight/legacy_ciphers.min.mjs +1 -1
  6. package/dist/lightweight/legacy_ciphers.min.mjs.map +1 -1
  7. package/dist/lightweight/legacy_ciphers.mjs +10 -10
  8. package/dist/lightweight/nacl-fast.min.mjs +3 -0
  9. package/dist/lightweight/nacl-fast.min.mjs.map +1 -0
  10. package/dist/lightweight/nacl-fast.mjs +1382 -0
  11. package/dist/lightweight/noble_curves.min.mjs +11 -12
  12. package/dist/lightweight/noble_curves.min.mjs.map +1 -1
  13. package/dist/lightweight/noble_curves.mjs +2175 -1752
  14. package/dist/lightweight/noble_hashes.min.mjs +2 -2
  15. package/dist/lightweight/noble_hashes.min.mjs.map +1 -1
  16. package/dist/lightweight/noble_hashes.mjs +80 -51
  17. package/dist/lightweight/noble_post_quantum.min.mjs +3 -4
  18. package/dist/lightweight/noble_post_quantum.min.mjs.map +1 -1
  19. package/dist/lightweight/noble_post_quantum.mjs +352 -10
  20. package/dist/lightweight/openpgp.min.mjs +3 -4
  21. package/dist/lightweight/openpgp.min.mjs.map +1 -1
  22. package/dist/lightweight/openpgp.mjs +998 -2820
  23. package/dist/lightweight/seek-bzip.min.mjs +2 -2
  24. package/dist/lightweight/seek-bzip.min.mjs.map +1 -1
  25. package/dist/lightweight/seek-bzip.mjs +780 -746
  26. package/dist/lightweight/sha512.min.mjs +4 -2
  27. package/dist/lightweight/sha512.min.mjs.map +1 -1
  28. package/dist/lightweight/sha512.mjs +672 -130
  29. package/dist/node/openpgp.cjs +10685 -10141
  30. package/dist/node/openpgp.min.cjs +14 -17
  31. package/dist/node/openpgp.min.cjs.map +1 -1
  32. package/dist/node/openpgp.min.mjs +14 -17
  33. package/dist/node/openpgp.min.mjs.map +1 -1
  34. package/dist/node/openpgp.mjs +10685 -10140
  35. package/dist/openpgp.js +11728 -11188
  36. package/dist/openpgp.min.js +14 -17
  37. package/dist/openpgp.min.js.map +1 -1
  38. package/dist/openpgp.min.mjs +14 -17
  39. package/dist/openpgp.min.mjs.map +1 -1
  40. package/dist/openpgp.mjs +11728 -11188
  41. package/{src → dist/types}/config/config.d.ts +1 -21
  42. package/{openpgp.d.ts → dist/types/index.d.ts} +94 -76
  43. package/dist/types/packet/grammar.d.ts +33 -0
  44. package/package.json +40 -39
  45. package/dist/lightweight/sha3.min.mjs +0 -4
  46. package/dist/lightweight/sha3.min.mjs.map +0 -1
  47. package/dist/lightweight/sha3.mjs +0 -401
  48. /package/{src → dist/types}/config/index.d.ts +0 -0
  49. /package/{src → dist/types}/enums.d.ts +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@protontech/openpgp",
3
3
  "description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
4
- "version": "6.1.1-patch.4",
4
+ "version": "6.2.1",
5
5
  "license": "LGPL-3.0+",
6
6
  "homepage": "https://openpgpjs.org/",
7
7
  "engines": {
@@ -21,33 +21,32 @@
21
21
  },
22
22
  "exports": {
23
23
  ".": {
24
- "types": "./openpgp.d.ts",
24
+ "types": "./dist/types/index.d.ts",
25
25
  "browser": "./dist/openpgp.min.mjs",
26
26
  "import": "./dist/node/openpgp.mjs",
27
27
  "require": "./dist/node/openpgp.min.cjs"
28
28
  },
29
29
  "./lightweight": {
30
- "types": "./openpgp.d.ts",
30
+ "types": "./dist/types/index.d.ts",
31
31
  "browser": "./dist/lightweight/openpgp.min.mjs"
32
32
  }
33
33
  },
34
- "types": "openpgp.d.ts",
34
+ "types": "dist/types/index.d.ts",
35
35
  "type": "module",
36
36
  "directories": {
37
37
  "lib": "src"
38
38
  },
39
39
  "files": [
40
40
  "dist/",
41
- "lightweight/",
42
- "openpgp.d.ts",
43
- "**/*.d.ts"
41
+ "lightweight/"
44
42
  ],
45
43
  "scripts": {
46
44
  "build": "rollup --config",
47
- "build-test": "npm run build --build-only=test",
48
- "prepare": "npm run build",
45
+ "build-types": "rm -rf dist/types && tsc --project tsconfig.dist.json && cpy 'src/**/*.d.ts' dist/types",
46
+ "build-test": "npm run build -- --config-build-only=test",
47
+ "prepare": "npm run build && npm run build-types",
49
48
  "test": "mocha --timeout 120000 test/unittests.js",
50
- "test-type-definitions": "tsx test/typescript/definitions.ts",
49
+ "test-type-definitions": "npm run build-types && tsc --project test/typescript/tsconfig.test.json && tsx test/typescript/definitions.ts",
51
50
  "benchmark-time": "node test/benchmarks/time.js",
52
51
  "benchmark-memory-usage": "node test/benchmarks/memory_usage.js",
53
52
  "prebrowsertest": "npm run build-test",
@@ -60,61 +59,63 @@
60
59
  "docs": "jsdoc --configure .jsdocrc.cjs --destination docs --recurse README.md src && printf '%s' 'docs.openpgpjs.org' > docs/CNAME",
61
60
  "preversion": "rm -rf dist docs node_modules && npm ci && npm test",
62
61
  "version": "npm run docs && git add -A docs",
63
- "postversion": "git push && git push --tags && npm publish"
62
+ "postversion": "git push --follow-tags && npm publish"
64
63
  },
65
64
  "devDependencies": {
66
- "@noble/ciphers": "^1.0.0",
67
- "@noble/curves": "^1.7.0",
68
- "@noble/ed25519": "^1.7.3",
69
- "@noble/hashes": "^1.5.0",
65
+ "@noble/ciphers": "^1.3.0",
66
+ "@noble/curves": "^1.9.6",
67
+ "@noble/hashes": "^1.8.0",
70
68
  "@noble/post-quantum": "^0.2.1",
71
69
  "@openpgp/jsdoc": "^3.6.11",
72
70
  "@openpgp/seek-bzip": "^1.0.5-git",
73
- "@openpgp/tweetnacl": "^1.0.4-1",
71
+ "@openpgp/tweetnacl": "^1.0.4-2",
74
72
  "@openpgp/web-stream-tools": "~0.1.3",
73
+ "@protontech/eslint-plugin-enforce-uint8array-arraybuffer": "^1.0.0",
75
74
  "@rollup/plugin-alias": "^5.1.1",
76
- "@rollup/plugin-commonjs": "^25.0.8",
77
- "@rollup/plugin-node-resolve": "^15.3.0",
78
- "@rollup/plugin-replace": "^5.0.7",
75
+ "@rollup/plugin-commonjs": "^28.0.6",
76
+ "@rollup/plugin-node-resolve": "^16.0.1",
77
+ "@rollup/plugin-replace": "^6.0.2",
79
78
  "@rollup/plugin-terser": "^0.4.4",
80
- "@rollup/plugin-typescript": "^11.1.6",
79
+ "@rollup/plugin-typescript": "^12.1.4",
81
80
  "@rollup/plugin-wasm": "^6.2.2",
82
- "@types/chai": "^4.3.19",
83
- "@types/sinon": "^17.0.3",
81
+ "@types/chai": "^4.3.20",
82
+ "@types/node": "^22.18.0",
83
+ "@types/sinon": "^17.0.4",
84
84
  "@typescript-eslint/parser": "^7.18.0",
85
85
  "@web/test-runner": "^0.19.0",
86
- "@web/test-runner-browserstack": "^0.7.2",
86
+ "@web/test-runner-browserstack": "^0.8.0",
87
87
  "@web/test-runner-mocha": "^0.9.0",
88
- "@web/test-runner-playwright": "^0.11.0",
88
+ "@web/test-runner-playwright": "^0.11.1",
89
89
  "argon2id": "^1.0.1",
90
90
  "benchmark": "^2.1.4",
91
- "bn.js": "^5.2.1",
92
- "c8": "^8.0.1",
93
- "chai": "^4.4.1",
91
+ "bn.js": "^5.2.2",
92
+ "c8": "^10.1.3",
93
+ "chai": "^4.5.0",
94
94
  "chai-as-promised": "^7.1.2",
95
+ "cpy-cli": "^6.0.0",
95
96
  "eckey-utils": "^0.7.14",
96
97
  "eslint": "^8.57.1",
97
98
  "eslint-config-airbnb": "^19.0.4",
98
99
  "eslint-config-airbnb-base": "^15.0.0",
99
100
  "eslint-config-airbnb-typescript": "^18.0.0",
100
- "eslint-import-resolver-typescript": "^3.6.3",
101
+ "eslint-import-resolver-typescript": "^3.10.1",
101
102
  "eslint-plugin-chai-friendly": "^0.7.4",
102
- "eslint-plugin-import": "^2.31.0",
103
+ "eslint-plugin-import": "^2.32.0",
103
104
  "eslint-plugin-unicorn": "^48.0.1",
104
- "fflate": "^0.7.4",
105
- "mocha": "^10.7.3",
106
- "playwright": "^1.48.2",
107
- "rollup": "^4.24.2",
108
- "sinon": "^18.0.1",
105
+ "fflate": "^0.8.2",
106
+ "mocha": "^11.7.1",
107
+ "playwright": "^1.55.0",
108
+ "rollup": "^4.48.1",
109
+ "sinon": "^20.0.0",
109
110
  "ts-node": "^10.9.2",
110
- "tslib": "^2.8.0",
111
- "tsx": "^4.19.2",
112
- "typescript": "^5.6.3",
113
- "web-streams-polyfill": "^4.0.0"
111
+ "tslib": "^2.8.1",
112
+ "tsx": "^4.20.5",
113
+ "typescript": "^5.9.2",
114
+ "web-streams-polyfill": "^4.1.0"
114
115
  },
115
116
  "overrides": {
116
117
  "@web/dev-server-core": "npm:@openpgp/wtr-dev-server-core@0.7.3-patch.1",
117
- "@web/test-runner-core": "npm:@openpgp/wtr-test-runner-core@0.13.4-patch.0"
118
+ "@web/test-runner-core": "npm:@openpgp/wtr-test-runner-core@0.13.4-patch.2"
118
119
  },
119
120
  "repository": {
120
121
  "type": "git",
@@ -1,4 +0,0 @@
1
- /*! OpenPGP.js v6.1.1-patch.4 - 2025-07-14 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- const t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){if(!Number.isSafeInteger(t)||t<0)throw Error("positive integer expected, got "+t)}function n(t,...e){if(!((n=t)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw Error("Uint8Array expected");var n;if(e.length>0&&!e.includes(t.length))throw Error("Uint8Array expected of length "+e+", got length="+t.length)}function s(t){if("function"!=typeof t||"function"!=typeof t.create)throw Error("Hash should be wrapped by utils.wrapConstructor");e(t.outputLen),e(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 r(t,e){n(t);const s=e.outputLen;if(t.length<s)throw Error("digestInto() expects output buffer of length at least "+s)}const i="object"==typeof t&&"crypto"in t?t.crypto:void 0,h=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),a=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),f=(t,e)=>t<<32-e|t>>>e,u=(t,e)=>t<<e|t>>>32-e>>>0,c=/* @__PURE__ */(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();
3
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function l(t){for(let n=0;n<t.length;n++)t[n]=(e=t[n])<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var e}function d(t){if("string"!=typeof t)throw Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function p(t){return"string"==typeof t&&(t=d(t)),n(t),t}function g(...t){let e=0;for(let s=0;s<t.length;s++){const o=t[s];n(o),e+=o.length}const s=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const o=t[e];s.set(o,n),n+=o.length}return s}class y{clone(){return this._cloneInto()}}function w(t){const e=e=>t().update(p(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function b(t=32){if(i&&"function"==typeof i.getRandomValues)return i.getRandomValues(new Uint8Array(t));if(i&&"function"==typeof i.randomBytes)return i.randomBytes(t);throw Error("crypto.getRandomValues must be defined")}const L=/* @__PURE__ */BigInt(2**32-1),k=/* @__PURE__ */BigInt(32);function I(t,e=!1){return e?{h:Number(t&L),l:Number(t>>k&L)}:{h:0|Number(t>>k&L),l:0|Number(t&L)}}function B(t,e=!1){let n=new Uint32Array(t.length),s=new Uint32Array(t.length);for(let o=0;o<t.length;o++){const{h:r,l:i}=I(t[o],e);[n[o],s[o]]=[r,i]}return[n,s]}const A=(t,e,n)=>t<<n|e>>>32-n,m=(t,e,n)=>e<<n|t>>>32-n,O=(t,e,n)=>e<<n-32|t>>>64-n,U=(t,e,n)=>t<<n-32|e>>>64-n;const x={fromBig:I,split:B,toBig:(t,e)=>BigInt(t>>>0)<<k|BigInt(e>>>0),shrSH:(t,e,n)=>t>>>n,shrSL:(t,e,n)=>t<<32-n|e>>>n,rotrSH:(t,e,n)=>t>>>n|e<<32-n,rotrSL:(t,e,n)=>t<<32-n|e>>>n,rotrBH:(t,e,n)=>t<<64-n|e>>>n-32,rotrBL:(t,e,n)=>t>>>n-32|e<<64-n,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:A,rotlSL:m,rotlBH:O,rotlBL:U,add:function(t,e,n,s){const o=(e>>>0)+(s>>>0);return{h:t+n+(o/2**32|0)|0,l:0|o}},add3L:(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),add3H:(t,e,n,s)=>e+n+s+(t/2**32|0)|0,add4L:(t,e,n,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),add4H:(t,e,n,s,o)=>e+n+s+o+(t/2**32|0)|0,add5H:(t,e,n,s,o,r)=>e+n+s+o+r+(t/2**32|0)|0,add5L:(t,e,n,s,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0)+(o>>>0)},E=[],H=[],S=[],v=/* @__PURE__ */BigInt(0),F=/* @__PURE__ */BigInt(1),N=/* @__PURE__ */BigInt(2),V=/* @__PURE__ */BigInt(7),X=/* @__PURE__ */BigInt(256),M=/* @__PURE__ */BigInt(113);for(let t=0,e=F,n=1,s=0;t<24;t++){[n,s]=[s,(2*n+3*s)%5],E.push(2*(5*s+n)),H.push((t+1)*(t+2)/2%64);let o=v;for(let t=0;t<7;t++)e=(e<<F^(e>>V)*M)%X,e&N&&(o^=F<<(F<</* @__PURE__ */BigInt(t))-F);S.push(o)}const[R,j]=/* @__PURE__ */B(S,!0),T=(t,e,n)=>n>32?O(t,e,n):A(t,e,n),_=(t,e,n)=>n>32?U(t,e,n):m(t,e,n);class C extends y{constructor(t,n,s,o=!1,r=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=s,this.enableXOF=o,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,e(s),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=h(this.state)}keccak(){c||l(this.state32),function(t,e=24){const n=new Uint32Array(10);for(let s=24-e;s<24;s++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const s=(e+8)%10,o=(e+2)%10,r=n[o],i=n[o+1],h=T(r,i,1)^n[s],a=_(r,i,1)^n[s+1];for(let n=0;n<50;n+=10)t[e+n]^=h,t[e+n+1]^=a}let e=t[2],o=t[3];for(let n=0;n<24;n++){const s=H[n],r=T(e,o,s),i=_(e,o,s),h=E[n];e=t[h],o=t[h+1],t[h]=r,t[h+1]=i}for(let e=0;e<50;e+=10){for(let s=0;s<10;s++)n[s]=t[e+s];for(let s=0;s<10;s++)t[e+s]^=~n[(s+2)%10]&n[(s+4)%10]}t[0]^=R[s],t[1]^=j[s]}n.fill(0)}(this.state32,this.rounds),c||l(this.state32),this.posOut=0,this.pos=0}update(t){o(this);const{blockLen:e,state:n}=this,s=(t=p(t)).length;for(let o=0;o<s;){const r=Math.min(e-this.pos,s-o);for(let e=0;e<r;e++)n[this.pos++]^=t[o++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:s}=this;t[n]^=e,128&e&&n===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){o(this,!1),n(t),this.finish();const e=this.state,{blockLen:s}=this;for(let n=0,o=t.length;n<o;){this.posOut>=s&&this.keccak();const r=Math.min(s-this.posOut,o-n);t.set(e.subarray(this.posOut,this.posOut+r),n),this.posOut+=r,n+=r}return t}xofInto(t){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return e(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(r(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:n,outputLen:s,rounds:o,enableXOF:r}=this;return t||(t=new C(e,n,s,r,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=n,t.outputLen=s,t.enableXOF=r,t.destroyed=this.destroyed,t}}const D=(t,e,n)=>w((()=>new C(e,t,n))),q=/* @__PURE__ */D(6,136,32),z=/* @__PURE__ */D(6,72,64),G=(t,e,n)=>function(t){const e=(e,n)=>t(n).update(p(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e}(((s={})=>new C(e,t,void 0===s.dkLen?n:s.dkLen,!0))),J=/* @__PURE__ */G(31,168,16),K=/* @__PURE__ */G(31,136,32);export{y as H,s as a,o as b,n as c,g as d,u as e,q as f,z as g,a as h,r as i,f as j,x as k,J as l,h as m,b as r,K as s,p as t,d as u,w};
4
- //# sourceMappingURL=sha3.min.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sha3.min.mjs","sources":["../../node_modules/@noble/hashes/esm/_assert.js","../../node_modules/@noble/hashes/esm/crypto.js","../../node_modules/@noble/hashes/esm/utils.js","../../node_modules/@noble/hashes/esm/_u64.js","../../node_modules/@noble/hashes/esm/sha3.js"],"sourcesContent":["function anumber(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error('positive integer expected, got ' + n);\n}\n// copied from utils\nfunction isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\nfunction abytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\nfunction ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\nfunction 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}\nfunction aoutput(out, instance) {\n abytes(out);\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}\nexport { anumber, anumber as number, abytes, abytes as bytes, ahash, aexists, aoutput };\nconst assert = {\n number: anumber,\n bytes: abytes,\n hash: ahash,\n exists: aexists,\n output: aoutput,\n};\nexport default assert;\n//# sourceMappingURL=_assert.js.map","export const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;\n//# sourceMappingURL=crypto.js.map","/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\nimport { abytes } from './_assert.js';\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nexport function isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n// Cast array to different type\nexport const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexport const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n// Cast array to view\nexport const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n// The rotate right (circular right shift) operation for uint32\nexport const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);\n// The rotate left (circular left shift) operation for uint32\nexport const rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);\nexport const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n// The byte swap operation for uint32\nexport const byteSwap = (word) => ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff);\n// Conditionally byte swap if on a big-endian platform\nexport const byteSwapIfBE = isLE ? (n) => n : (n) => byteSwap(n);\n// In place byte swap for Uint32Array\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\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 * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\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 * @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 const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('padded 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// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nexport const nextTick = async () => { };\n// Returns control to thread each 'tick' ms to avoid blocking\nexport async function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick();\n ts += diff;\n }\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('utf8ToBytes expected string, got ' + typeof str);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\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}\n// For runtime check if class implements interface\nexport class Hash {\n // Safe version that clones internal state\n clone() {\n return this._cloneInto();\n }\n}\nexport function checkOpts(defaults, opts) {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\nexport function wrapConstructor(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\nexport function wrapConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport function wrapXOFConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nexport function randomBytes(bytesLength = 32) {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n//# sourceMappingURL=utils.js.map","const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);\nconst _32n = /* @__PURE__ */ BigInt(32);\n// BigUint64Array is too slow as per 2024, so we implement it using Uint32Array.\n// TODO: re-check https://issues.chromium.org/issues/42212588\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 let Ah = new Uint32Array(lst.length);\n let Al = new Uint32Array(lst.length);\n for (let i = 0; i < lst.length; 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 { fromBig, split, toBig, shrSH, shrSL, rotrSH, rotrSL, rotrBH, rotrBL, rotr32H, rotr32L, rotlSH, rotlSL, rotlBH, rotlBL, add, add3L, add3H, add4L, add4H, add5H, add5L, };\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","import { abytes, aexists, anumber, aoutput } from './_assert.js';\nimport { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.js';\nimport { Hash, u32, toBytes, wrapConstructor, wrapXOFConstructorWithOpts, isLE, byteSwap32, } from './utils.js';\n// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.\n// It's called a sponge function.\n// Various per round constants calculations\nconst SHA3_PI = [];\nconst SHA3_ROTL = [];\nconst _SHA3_IOTA = [];\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nconst _2n = /* @__PURE__ */ BigInt(2);\nconst _7n = /* @__PURE__ */ BigInt(7);\nconst _256n = /* @__PURE__ */ BigInt(256);\nconst _0x71n = /* @__PURE__ */ BigInt(0x71);\nfor (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {\n // Pi\n [x, y] = [y, (2 * x + 3 * y) % 5];\n SHA3_PI.push(2 * (5 * y + x));\n // Rotational\n SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);\n // Iota\n let t = _0n;\n for (let j = 0; j < 7; j++) {\n R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;\n if (R & _2n)\n t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);\n }\n _SHA3_IOTA.push(t);\n}\nconst [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);\n// Left rotation (without 0, 32, 64)\nconst rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));\nconst rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));\n// Same as keccakf1600, but allows to skip some rounds\nexport function keccakP(s, rounds = 24) {\n const B = new Uint32Array(5 * 2);\n // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)\n for (let round = 24 - rounds; round < 24; round++) {\n // Theta θ\n for (let x = 0; x < 10; x++)\n B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];\n for (let x = 0; x < 10; x += 2) {\n const idx1 = (x + 8) % 10;\n const idx0 = (x + 2) % 10;\n const B0 = B[idx0];\n const B1 = B[idx0 + 1];\n const Th = rotlH(B0, B1, 1) ^ B[idx1];\n const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];\n for (let y = 0; y < 50; y += 10) {\n s[x + y] ^= Th;\n s[x + y + 1] ^= Tl;\n }\n }\n // Rho (ρ) and Pi (π)\n let curH = s[2];\n let curL = s[3];\n for (let t = 0; t < 24; t++) {\n const shift = SHA3_ROTL[t];\n const Th = rotlH(curH, curL, shift);\n const Tl = rotlL(curH, curL, shift);\n const PI = SHA3_PI[t];\n curH = s[PI];\n curL = s[PI + 1];\n s[PI] = Th;\n s[PI + 1] = Tl;\n }\n // Chi (χ)\n for (let y = 0; y < 50; y += 10) {\n for (let x = 0; x < 10; x++)\n B[x] = s[y + x];\n for (let x = 0; x < 10; x++)\n s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];\n }\n // Iota (ι)\n s[0] ^= SHA3_IOTA_H[round];\n s[1] ^= SHA3_IOTA_L[round];\n }\n B.fill(0);\n}\nexport class Keccak extends Hash {\n // NOTE: we accept arguments in bytes instead of bits here.\n constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {\n super();\n this.blockLen = blockLen;\n this.suffix = suffix;\n this.outputLen = outputLen;\n this.enableXOF = enableXOF;\n this.rounds = rounds;\n this.pos = 0;\n this.posOut = 0;\n this.finished = false;\n this.destroyed = false;\n // Can be passed from user as dkLen\n anumber(outputLen);\n // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes\n if (0 >= this.blockLen || this.blockLen >= 200)\n throw new Error('Sha3 supports only keccak-f1600 function');\n this.state = new Uint8Array(200);\n this.state32 = u32(this.state);\n }\n keccak() {\n if (!isLE)\n byteSwap32(this.state32);\n keccakP(this.state32, this.rounds);\n if (!isLE)\n byteSwap32(this.state32);\n this.posOut = 0;\n this.pos = 0;\n }\n update(data) {\n aexists(this);\n const { blockLen, state } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n for (let i = 0; i < take; i++)\n state[this.pos++] ^= data[pos++];\n if (this.pos === blockLen)\n this.keccak();\n }\n return this;\n }\n finish() {\n if (this.finished)\n return;\n this.finished = true;\n const { state, suffix, pos, blockLen } = this;\n // Do the padding\n state[pos] ^= suffix;\n if ((suffix & 0x80) !== 0 && pos === blockLen - 1)\n this.keccak();\n state[blockLen - 1] ^= 0x80;\n this.keccak();\n }\n writeInto(out) {\n aexists(this, false);\n abytes(out);\n this.finish();\n const bufferOut = this.state;\n const { blockLen } = this;\n for (let pos = 0, len = out.length; pos < len;) {\n if (this.posOut >= blockLen)\n this.keccak();\n const take = Math.min(blockLen - this.posOut, len - pos);\n out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);\n this.posOut += take;\n pos += take;\n }\n return out;\n }\n xofInto(out) {\n // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF\n if (!this.enableXOF)\n throw new Error('XOF is not possible for this instance');\n return this.writeInto(out);\n }\n xof(bytes) {\n anumber(bytes);\n return this.xofInto(new Uint8Array(bytes));\n }\n digestInto(out) {\n aoutput(out, this);\n if (this.finished)\n throw new Error('digest() was already called');\n this.writeInto(out);\n this.destroy();\n return out;\n }\n digest() {\n return this.digestInto(new Uint8Array(this.outputLen));\n }\n destroy() {\n this.destroyed = true;\n this.state.fill(0);\n }\n _cloneInto(to) {\n const { blockLen, suffix, outputLen, rounds, enableXOF } = this;\n to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));\n to.state32.set(this.state32);\n to.pos = this.pos;\n to.posOut = this.posOut;\n to.finished = this.finished;\n to.rounds = rounds;\n // Suffix can change in cSHAKE\n to.suffix = suffix;\n to.outputLen = outputLen;\n to.enableXOF = enableXOF;\n to.destroyed = this.destroyed;\n return to;\n }\n}\nconst gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));\nexport const sha3_224 = /* @__PURE__ */ gen(0x06, 144, 224 / 8);\n/**\n * SHA3-256 hash function\n * @param message - that would be hashed\n */\nexport const sha3_256 = /* @__PURE__ */ gen(0x06, 136, 256 / 8);\nexport const sha3_384 = /* @__PURE__ */ gen(0x06, 104, 384 / 8);\nexport const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8);\nexport const keccak_224 = /* @__PURE__ */ gen(0x01, 144, 224 / 8);\n/**\n * keccak-256 hash function. Different from SHA3-256.\n * @param message - that would be hashed\n */\nexport const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);\nexport const keccak_384 = /* @__PURE__ */ gen(0x01, 104, 384 / 8);\nexport const keccak_512 = /* @__PURE__ */ gen(0x01, 72, 512 / 8);\nconst genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));\nexport const shake128 = /* @__PURE__ */ genShake(0x1f, 168, 128 / 8);\nexport const shake256 = /* @__PURE__ */ genShake(0x1f, 136, 256 / 8);\n//# sourceMappingURL=sha3.js.map"],"names":["anumber","n","Number","isSafeInteger","Error","abytes","b","lengths","a","Uint8Array","ArrayBuffer","isView","constructor","name","length","includes","ahash","h","create","outputLen","blockLen","aexists","instance","checkFinished","destroyed","finished","aoutput","out","min","crypto","globalThis","undefined","u32","arr","Uint32Array","buffer","byteOffset","Math","floor","byteLength","createView","DataView","rotr","word","shift","rotl","isLE","byteSwap32","i","utf8ToBytes","str","TextEncoder","encode","toBytes","data","concatBytes","arrays","sum","res","pad","set","Hash","clone","this","_cloneInto","wrapConstructor","hashCons","hashC","msg","update","digest","tmp","randomBytes","bytesLength","getRandomValues","U32_MASK64","BigInt","_32n","fromBig","le","l","split","lst","Ah","Al","rotlSH","s","rotlSL","rotlBH","rotlBL","u64","toBig","shrSH","_l","shrSL","rotrSH","rotrSL","rotrBH","rotrBL","rotr32H","_h","rotr32L","add","Bh","Bl","add3L","Cl","add3H","low","Ch","add4L","Dl","add4H","Dh","add5H","Eh","add5L","El","SHA3_PI","SHA3_ROTL","_SHA3_IOTA","_0n","_1n","_2n","_7n","_256n","_0x71n","round","R","x","y","push","t","j","SHA3_IOTA_H","SHA3_IOTA_L","rotlH","rotlL","Keccak","suffix","enableXOF","rounds","super","pos","posOut","state","state32","keccak","B","idx1","idx0","B0","B1","Th","Tl","curH","curL","PI","fill","keccakP","len","take","finish","writeInto","bufferOut","subarray","xofInto","xof","bytes","digestInto","destroy","to","gen","sha3_256","sha3_512","genShake","opts","wrapXOFConstructorWithOpts","dkLen","shake128","shake256"],"mappings":";6GAAA,SAASA,EAAQC,GACb,IAAKC,OAAOC,cAAcF,IAAMA,EAAI,EAChC,MAAUG,MAAM,kCAAoCH,EAC5D,CAKA,SAASI,EAAOC,KAAMC,GAClB,MAJaC,EAIAF,aAHOG,Y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AKvC,UACbmJ,CACf,EAEA,MAAMC,EAAM,CAACjC,EAAQvH,EAAUD,IAAc8C,GAAgB,IAAM,IAAIyE,EAAOtH,EAAUuH,EAAQxH,KAMnF0J,iBAA2BD,EAAI,EAAM,IAAK,IAE1CE,iBAA2BF,EAAI,EAAM,GAAI,IAShDG,EAAW,CAACpC,EAAQvH,EAAUD,IF3C7B,SAAoC+C,GACvC,MAAMC,EAAQ,CAACC,EAAK4G,IAAS9G,EAAS8G,GAAM3G,OAAOhB,EAAQe,IAAME,SAC3DC,EAAML,EAAS,IAIrB,OAHAC,EAAMhD,UAAYoD,EAAIpD,UACtBgD,EAAM/C,SAAWmD,EAAInD,SACrB+C,EAAMjD,OAAU8J,GAAS9G,EAAS8G,GAC3B7G,CACX,CEoCkD8G,EAA2B,CAACD,EAAO,CAAA,IAAO,IAAItC,EAAOtH,EAAUuH,OAAuB5G,IAAfiJ,EAAKE,MAAsB/J,EAAY6J,EAAKE,OAAO,KAC/JC,iBAA2BJ,EAAS,GAAM,IAAK,IAC/CK,iBAA2BL,EAAS,GAAM,IAAK","x_google_ignoreList":[0,1,2,3,4]}
@@ -1,401 +0,0 @@
1
- /*! OpenPGP.js v6.1.1-patch.4 - 2025-07-14 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3
-
4
- function anumber(n) {
5
- if (!Number.isSafeInteger(n) || n < 0)
6
- throw new Error('positive integer expected, got ' + n);
7
- }
8
- // copied from utils
9
- function isBytes(a) {
10
- return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
11
- }
12
- function abytes(b, ...lengths) {
13
- if (!isBytes(b))
14
- throw new Error('Uint8Array expected');
15
- if (lengths.length > 0 && !lengths.includes(b.length))
16
- throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
17
- }
18
- function ahash(h) {
19
- if (typeof h !== 'function' || typeof h.create !== 'function')
20
- throw new Error('Hash should be wrapped by utils.wrapConstructor');
21
- anumber(h.outputLen);
22
- anumber(h.blockLen);
23
- }
24
- function aexists(instance, checkFinished = true) {
25
- if (instance.destroyed)
26
- throw new Error('Hash instance has been destroyed');
27
- if (checkFinished && instance.finished)
28
- throw new Error('Hash#digest() has already been called');
29
- }
30
- function aoutput(out, instance) {
31
- abytes(out);
32
- const min = instance.outputLen;
33
- if (out.length < min) {
34
- throw new Error('digestInto() expects output buffer of length at least ' + min);
35
- }
36
- }
37
-
38
- const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
39
-
40
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
41
- // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
42
- // node.js versions earlier than v19 don't declare it in global scope.
43
- // For node.js, package.json#exports field mapping rewrites import
44
- // from `crypto` to `cryptoNode`, which imports native module.
45
- // Makes the utils un-importable in browsers without a bundler.
46
- // Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
47
- const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
48
- // Cast array to view
49
- const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
50
- // The rotate right (circular right shift) operation for uint32
51
- const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
52
- // The rotate left (circular left shift) operation for uint32
53
- const rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);
54
- const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
55
- // The byte swap operation for uint32
56
- const byteSwap = (word) => ((word << 24) & 0xff000000) |
57
- ((word << 8) & 0xff0000) |
58
- ((word >>> 8) & 0xff00) |
59
- ((word >>> 24) & 0xff);
60
- // In place byte swap for Uint32Array
61
- function byteSwap32(arr) {
62
- for (let i = 0; i < arr.length; i++) {
63
- arr[i] = byteSwap(arr[i]);
64
- }
65
- }
66
- /**
67
- * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
68
- */
69
- function utf8ToBytes(str) {
70
- if (typeof str !== 'string')
71
- throw new Error('utf8ToBytes expected string, got ' + typeof str);
72
- return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
73
- }
74
- /**
75
- * Normalizes (non-hex) string or Uint8Array to Uint8Array.
76
- * Warning: when Uint8Array is passed, it would NOT get copied.
77
- * Keep in mind for future mutable operations.
78
- */
79
- function toBytes(data) {
80
- if (typeof data === 'string')
81
- data = utf8ToBytes(data);
82
- abytes(data);
83
- return data;
84
- }
85
- /**
86
- * Copies several Uint8Arrays into one.
87
- */
88
- function concatBytes(...arrays) {
89
- let sum = 0;
90
- for (let i = 0; i < arrays.length; i++) {
91
- const a = arrays[i];
92
- abytes(a);
93
- sum += a.length;
94
- }
95
- const res = new Uint8Array(sum);
96
- for (let i = 0, pad = 0; i < arrays.length; i++) {
97
- const a = arrays[i];
98
- res.set(a, pad);
99
- pad += a.length;
100
- }
101
- return res;
102
- }
103
- // For runtime check if class implements interface
104
- class Hash {
105
- // Safe version that clones internal state
106
- clone() {
107
- return this._cloneInto();
108
- }
109
- }
110
- function wrapConstructor(hashCons) {
111
- const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
112
- const tmp = hashCons();
113
- hashC.outputLen = tmp.outputLen;
114
- hashC.blockLen = tmp.blockLen;
115
- hashC.create = () => hashCons();
116
- return hashC;
117
- }
118
- function wrapXOFConstructorWithOpts(hashCons) {
119
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
120
- const tmp = hashCons({});
121
- hashC.outputLen = tmp.outputLen;
122
- hashC.blockLen = tmp.blockLen;
123
- hashC.create = (opts) => hashCons(opts);
124
- return hashC;
125
- }
126
- /**
127
- * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.
128
- */
129
- function randomBytes(bytesLength = 32) {
130
- if (crypto && typeof crypto.getRandomValues === 'function') {
131
- return crypto.getRandomValues(new Uint8Array(bytesLength));
132
- }
133
- // Legacy Node.js compatibility
134
- if (crypto && typeof crypto.randomBytes === 'function') {
135
- return crypto.randomBytes(bytesLength);
136
- }
137
- throw new Error('crypto.getRandomValues must be defined');
138
- }
139
-
140
- const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
141
- const _32n = /* @__PURE__ */ BigInt(32);
142
- // BigUint64Array is too slow as per 2024, so we implement it using Uint32Array.
143
- // TODO: re-check https://issues.chromium.org/issues/42212588
144
- function fromBig(n, le = false) {
145
- if (le)
146
- return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
147
- return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
148
- }
149
- function split(lst, le = false) {
150
- let Ah = new Uint32Array(lst.length);
151
- let Al = new Uint32Array(lst.length);
152
- for (let i = 0; i < lst.length; i++) {
153
- const { h, l } = fromBig(lst[i], le);
154
- [Ah[i], Al[i]] = [h, l];
155
- }
156
- return [Ah, Al];
157
- }
158
- const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
159
- // for Shift in [0, 32)
160
- const shrSH = (h, _l, s) => h >>> s;
161
- const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
162
- // Right rotate for Shift in [1, 32)
163
- const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
164
- const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
165
- // Right rotate for Shift in (32, 64), NOTE: 32 is special case.
166
- const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
167
- const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
168
- // Right rotate for shift===32 (just swaps l&h)
169
- const rotr32H = (_h, l) => l;
170
- const rotr32L = (h, _l) => h;
171
- // Left rotate for Shift in [1, 32)
172
- const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
173
- const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
174
- // Left rotate for Shift in (32, 64), NOTE: 32 is special case.
175
- const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
176
- const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
177
- // JS uses 32-bit signed integers for bitwise operations which means we cannot
178
- // simple take carry out of low bit sum by shift, we need to use division.
179
- function add(Ah, Al, Bh, Bl) {
180
- const l = (Al >>> 0) + (Bl >>> 0);
181
- return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
182
- }
183
- // Addition with more than 2 elements
184
- const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
185
- const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
186
- const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
187
- const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
188
- const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
189
- const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
190
- // prettier-ignore
191
- const u64 = {
192
- fromBig, split, toBig,
193
- shrSH, shrSL,
194
- rotrSH, rotrSL, rotrBH, rotrBL,
195
- rotr32H, rotr32L,
196
- rotlSH, rotlSL, rotlBH, rotlBL,
197
- add, add3L, add3H, add4L, add4H, add5H, add5L,
198
- };
199
-
200
- // SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.
201
- // It's called a sponge function.
202
- // Various per round constants calculations
203
- const SHA3_PI = [];
204
- const SHA3_ROTL = [];
205
- const _SHA3_IOTA = [];
206
- const _0n = /* @__PURE__ */ BigInt(0);
207
- const _1n = /* @__PURE__ */ BigInt(1);
208
- const _2n = /* @__PURE__ */ BigInt(2);
209
- const _7n = /* @__PURE__ */ BigInt(7);
210
- const _256n = /* @__PURE__ */ BigInt(256);
211
- const _0x71n = /* @__PURE__ */ BigInt(0x71);
212
- for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
213
- // Pi
214
- [x, y] = [y, (2 * x + 3 * y) % 5];
215
- SHA3_PI.push(2 * (5 * y + x));
216
- // Rotational
217
- SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);
218
- // Iota
219
- let t = _0n;
220
- for (let j = 0; j < 7; j++) {
221
- R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;
222
- if (R & _2n)
223
- t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);
224
- }
225
- _SHA3_IOTA.push(t);
226
- }
227
- const [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);
228
- // Left rotation (without 0, 32, 64)
229
- const rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));
230
- const rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));
231
- // Same as keccakf1600, but allows to skip some rounds
232
- function keccakP(s, rounds = 24) {
233
- const B = new Uint32Array(5 * 2);
234
- // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)
235
- for (let round = 24 - rounds; round < 24; round++) {
236
- // Theta θ
237
- for (let x = 0; x < 10; x++)
238
- B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
239
- for (let x = 0; x < 10; x += 2) {
240
- const idx1 = (x + 8) % 10;
241
- const idx0 = (x + 2) % 10;
242
- const B0 = B[idx0];
243
- const B1 = B[idx0 + 1];
244
- const Th = rotlH(B0, B1, 1) ^ B[idx1];
245
- const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
246
- for (let y = 0; y < 50; y += 10) {
247
- s[x + y] ^= Th;
248
- s[x + y + 1] ^= Tl;
249
- }
250
- }
251
- // Rho (ρ) and Pi (π)
252
- let curH = s[2];
253
- let curL = s[3];
254
- for (let t = 0; t < 24; t++) {
255
- const shift = SHA3_ROTL[t];
256
- const Th = rotlH(curH, curL, shift);
257
- const Tl = rotlL(curH, curL, shift);
258
- const PI = SHA3_PI[t];
259
- curH = s[PI];
260
- curL = s[PI + 1];
261
- s[PI] = Th;
262
- s[PI + 1] = Tl;
263
- }
264
- // Chi (χ)
265
- for (let y = 0; y < 50; y += 10) {
266
- for (let x = 0; x < 10; x++)
267
- B[x] = s[y + x];
268
- for (let x = 0; x < 10; x++)
269
- s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
270
- }
271
- // Iota (ι)
272
- s[0] ^= SHA3_IOTA_H[round];
273
- s[1] ^= SHA3_IOTA_L[round];
274
- }
275
- B.fill(0);
276
- }
277
- class Keccak extends Hash {
278
- // NOTE: we accept arguments in bytes instead of bits here.
279
- constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
280
- super();
281
- this.blockLen = blockLen;
282
- this.suffix = suffix;
283
- this.outputLen = outputLen;
284
- this.enableXOF = enableXOF;
285
- this.rounds = rounds;
286
- this.pos = 0;
287
- this.posOut = 0;
288
- this.finished = false;
289
- this.destroyed = false;
290
- // Can be passed from user as dkLen
291
- anumber(outputLen);
292
- // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
293
- if (0 >= this.blockLen || this.blockLen >= 200)
294
- throw new Error('Sha3 supports only keccak-f1600 function');
295
- this.state = new Uint8Array(200);
296
- this.state32 = u32(this.state);
297
- }
298
- keccak() {
299
- if (!isLE)
300
- byteSwap32(this.state32);
301
- keccakP(this.state32, this.rounds);
302
- if (!isLE)
303
- byteSwap32(this.state32);
304
- this.posOut = 0;
305
- this.pos = 0;
306
- }
307
- update(data) {
308
- aexists(this);
309
- const { blockLen, state } = this;
310
- data = toBytes(data);
311
- const len = data.length;
312
- for (let pos = 0; pos < len;) {
313
- const take = Math.min(blockLen - this.pos, len - pos);
314
- for (let i = 0; i < take; i++)
315
- state[this.pos++] ^= data[pos++];
316
- if (this.pos === blockLen)
317
- this.keccak();
318
- }
319
- return this;
320
- }
321
- finish() {
322
- if (this.finished)
323
- return;
324
- this.finished = true;
325
- const { state, suffix, pos, blockLen } = this;
326
- // Do the padding
327
- state[pos] ^= suffix;
328
- if ((suffix & 0x80) !== 0 && pos === blockLen - 1)
329
- this.keccak();
330
- state[blockLen - 1] ^= 0x80;
331
- this.keccak();
332
- }
333
- writeInto(out) {
334
- aexists(this, false);
335
- abytes(out);
336
- this.finish();
337
- const bufferOut = this.state;
338
- const { blockLen } = this;
339
- for (let pos = 0, len = out.length; pos < len;) {
340
- if (this.posOut >= blockLen)
341
- this.keccak();
342
- const take = Math.min(blockLen - this.posOut, len - pos);
343
- out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
344
- this.posOut += take;
345
- pos += take;
346
- }
347
- return out;
348
- }
349
- xofInto(out) {
350
- // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF
351
- if (!this.enableXOF)
352
- throw new Error('XOF is not possible for this instance');
353
- return this.writeInto(out);
354
- }
355
- xof(bytes) {
356
- anumber(bytes);
357
- return this.xofInto(new Uint8Array(bytes));
358
- }
359
- digestInto(out) {
360
- aoutput(out, this);
361
- if (this.finished)
362
- throw new Error('digest() was already called');
363
- this.writeInto(out);
364
- this.destroy();
365
- return out;
366
- }
367
- digest() {
368
- return this.digestInto(new Uint8Array(this.outputLen));
369
- }
370
- destroy() {
371
- this.destroyed = true;
372
- this.state.fill(0);
373
- }
374
- _cloneInto(to) {
375
- const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
376
- to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
377
- to.state32.set(this.state32);
378
- to.pos = this.pos;
379
- to.posOut = this.posOut;
380
- to.finished = this.finished;
381
- to.rounds = rounds;
382
- // Suffix can change in cSHAKE
383
- to.suffix = suffix;
384
- to.outputLen = outputLen;
385
- to.enableXOF = enableXOF;
386
- to.destroyed = this.destroyed;
387
- return to;
388
- }
389
- }
390
- const gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));
391
- /**
392
- * SHA3-256 hash function
393
- * @param message - that would be hashed
394
- */
395
- const sha3_256 = /* @__PURE__ */ gen(0x06, 136, 256 / 8);
396
- const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8);
397
- const genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
398
- const shake128 = /* @__PURE__ */ genShake(0x1f, 168, 128 / 8);
399
- const shake256 = /* @__PURE__ */ genShake(0x1f, 136, 256 / 8);
400
-
401
- export { Hash as H, ahash as a, aexists as b, abytes as c, concatBytes as d, rotl as e, sha3_256 as f, sha3_512 as g, createView as h, aoutput as i, rotr as j, u64 as k, shake128 as l, u32 as m, randomBytes as r, shake256 as s, toBytes as t, utf8ToBytes as u, wrapConstructor as w };
File without changes
File without changes