@protontech/openpgp 6.0.0-beta.0.patch.0 → 6.0.0-beta.2

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 (42) hide show
  1. package/README.md +2 -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 +5 -28
  5. package/dist/lightweight/legacy_ciphers.min.mjs +2 -2
  6. package/dist/lightweight/legacy_ciphers.min.mjs.map +1 -1
  7. package/dist/lightweight/legacy_ciphers.mjs +6 -51
  8. package/dist/lightweight/noble_curves.min.mjs +11 -11
  9. package/dist/lightweight/noble_curves.min.mjs.map +1 -1
  10. package/dist/lightweight/noble_curves.mjs +477 -465
  11. package/dist/lightweight/noble_hashes.min.mjs +2 -2
  12. package/dist/lightweight/noble_hashes.min.mjs.map +1 -1
  13. package/dist/lightweight/noble_hashes.mjs +19 -31
  14. package/dist/lightweight/openpgp.min.mjs +3 -2
  15. package/dist/lightweight/openpgp.min.mjs.map +1 -1
  16. package/dist/lightweight/openpgp.mjs +1529 -552
  17. package/dist/lightweight/sha3.min.mjs +3 -3
  18. package/dist/lightweight/sha3.min.mjs.map +1 -1
  19. package/dist/lightweight/sha3.mjs +80 -80
  20. package/dist/node/openpgp.cjs +2199 -5545
  21. package/dist/node/openpgp.min.cjs +12 -12
  22. package/dist/node/openpgp.min.cjs.map +1 -1
  23. package/dist/node/openpgp.min.mjs +12 -12
  24. package/dist/node/openpgp.min.mjs.map +1 -1
  25. package/dist/node/openpgp.mjs +2198 -5545
  26. package/dist/openpgp.js +2188 -5542
  27. package/dist/openpgp.min.js +12 -12
  28. package/dist/openpgp.min.js.map +1 -1
  29. package/dist/openpgp.min.mjs +12 -12
  30. package/dist/openpgp.min.mjs.map +1 -1
  31. package/dist/openpgp.mjs +2188 -5542
  32. package/openpgp.d.ts +69 -61
  33. package/package.json +20 -13
  34. package/dist/lightweight/bn.interface.min.mjs +0 -3
  35. package/dist/lightweight/bn.interface.min.mjs.map +0 -1
  36. package/dist/lightweight/bn.interface.mjs +0 -3807
  37. package/dist/lightweight/interface.min.mjs +0 -3
  38. package/dist/lightweight/interface.min.mjs.map +0 -1
  39. package/dist/lightweight/interface.mjs +0 -16
  40. package/dist/lightweight/native.interface.min.mjs +0 -3
  41. package/dist/lightweight/native.interface.min.mjs.map +0 -1
  42. package/dist/lightweight/native.interface.mjs +0 -456
@@ -1,3 +0,0 @@
1
- /*! OpenPGP.js v6.0.0-beta.0.patch.0 - 2024-04-19 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- "undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;class e{static setImplementation(t,n=!1){if(e.Implementation&&!n)throw Error("Implementation already set");e.Implementation=t}static new(t){return new e.Implementation(t)}}export{e as B};
3
- //# sourceMappingURL=interface.min.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.min.mjs","sources":["../../node_modules/@openpgp/noble-hashes/esm/biginteger/interface.js"],"sourcesContent":["class BigInteger {\n static setImplementation(Implementation, replace = false) {\n if (BigInteger.Implementation && !replace) {\n throw new Error('Implementation already set');\n }\n BigInteger.Implementation = Implementation;\n }\n static new(n) {\n return new BigInteger.Implementation(n);\n }\n}\nexport { BigInteger, BigInteger as default };\n//# sourceMappingURL=interface.js.map"],"names":["BigInteger","setImplementation","Implementation","replace","Error","n"],"mappings":";mGAAA,MAAMA,EACF,wBAAOC,CAAkBC,EAAgBC,GAAU,GAC/C,GAAIH,EAAWE,iBAAmBC,EAC9B,MAAUC,MAAM,8BAEpBJ,EAAWE,eAAiBA,CAC/B,CACD,UAAO,CAAIG,GACP,OAAO,IAAIL,EAAWE,eAAeG,EACxC","x_google_ignoreList":[0]}
@@ -1,16 +0,0 @@
1
- /*! OpenPGP.js v6.0.0-beta.0.patch.0 - 2024-04-19 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3
-
4
- class BigInteger {
5
- static setImplementation(Implementation, replace = false) {
6
- if (BigInteger.Implementation && !replace) {
7
- throw new Error('Implementation already set');
8
- }
9
- BigInteger.Implementation = Implementation;
10
- }
11
- static new(n) {
12
- return new BigInteger.Implementation(n);
13
- }
14
- }
15
-
16
- export { BigInteger as B };
@@ -1,3 +0,0 @@
1
- /*! OpenPGP.js v6.0.0-beta.0.patch.0 - 2024-04-19 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- "undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;import{B as e}from"./interface.min.mjs";class t extends e{constructor(e){if(super(),void 0===e)throw Error("Invalid BigInteger input");if(e instanceof Uint8Array){const t="0123456789ABCDEF";let i="";e.forEach((e=>{i+=t[e>>4]+t[15&e]})),this.value=BigInt("0x0"+i)}else this.value=BigInt(e)}clone(){return new t(this.value)}iinc(){return this.value++,this}inc(){return this.clone().iinc()}idec(){return this.value--,this}dec(){return this.clone().idec()}iadd(e){return this.value+=e.value,this}add(e){return this.clone().iadd(e)}isub(e){return this.value-=e.value,this}sub(e){return this.clone().isub(e)}imul(e){return this.value*=e.value,this}mul(e){return this.clone().imul(e)}imod(e){return this.value%=e.value,this.isNegative()&&this.iadd(e),this}mod(e){return this.clone().imod(e)}modExp(e,i){if(i.isZero())throw Error("Modulo cannot be zero");if(i.isOne())return new t(0);if(e.isNegative())throw Error("Unsopported negative exponent");let n=e.value,r=this.value;r%=i.value;let s=BigInt(1);for(;n>BigInt(0);){const e=n&BigInt(1);n>>=BigInt(1);const t=s*r%i.value;s=e?t:s,r=r*r%i.value}return new t(s)}modInv(e){const{gcd:t,x:i}=this._egcd(e);if(!t.isOne())throw Error("Inverse does not exist");return i.add(e).mod(e)}idiv(e){return this.value/=e.value,this}div(e){return this.clone().idiv(e)}_egcd(e){let i=BigInt(0),n=BigInt(1),r=BigInt(1),s=BigInt(0),u=this.abs().value,l=e.abs().value;const a=this.isNegative(),o=e.isNegative();for(;l!==BigInt(0);){const e=u/l;let t=i;i=r-e*i,r=t,t=n,n=s-e*n,s=t,t=l,l=u%l,u=t}return{x:new t(a?-r:r),y:new t(o?-s:s),gcd:new t(u)}}gcd(e){let i=this.value,n=e.value;for(;n!==BigInt(0);){const e=n;n=i%n,i=e}return new t(i)}ileftShift(e){return this.value<<=e.value,this}leftShift(e){return this.clone().ileftShift(e)}irightShift(e){return this.value>>=e.value,this}rightShift(e){return this.clone().irightShift(e)}ixor(e){return this.value^=e.value,this}xor(e){return this.clone().ixor(e)}ibitwiseAnd(e){return this.value&=e.value,this}bitwiseAnd(e){return this.clone().ibitwiseAnd(e)}ibitwiseOr(e){return this.value|=e.value,this}equal(e){return this.value===e.value}lt(e){return this.value<e.value}lte(e){return this.value<=e.value}gt(e){return this.value>e.value}gte(e){return this.value>=e.value}isZero(){return this.value===BigInt(0)}isOne(){return this.value===BigInt(1)}isNegative(){return this.value<BigInt(0)}isEven(){return!(this.value&BigInt(1))}abs(){const e=this.clone();return this.isNegative()&&(e.value=-e.value),e}negate(){const e=this.clone();return e.value=-e.value,e}toString(){return this.value.toString()}toNumber(){const e=Number(this.value);if(e>Number.MAX_SAFE_INTEGER)throw Error("Number can only safely store up to 53 bits");return e}getBit(e){return(this.value>>BigInt(e)&BigInt(1))===BigInt(0)?0:1}bitLength(){const e=new t(0),i=new t(1),n=new t(-1),r=this.isNegative()?n:e;let s=1;const u=this.clone();for(;!u.irightShift(i).equal(r);)s++;return s}byteLength(){const e=new t(0),i=new t(-1),n=this.isNegative()?i:e,r=new t(8);let s=1;const u=this.clone();for(;!u.irightShift(r).equal(n);)s++;return s}toUint8Array(e="be",t){let i=this.value.toString(16);i.length%2==1&&(i="0"+i);const n=i.length/2,r=new Uint8Array(t||n),s=t?t-n:0;let u=0;for(;u<n;)r[u+s]=parseInt(i.slice(2*u,2*u+2),16),u++;return"be"!==e&&r.reverse(),r}}export{t as default};
3
- //# sourceMappingURL=native.interface.min.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"native.interface.min.mjs","sources":["../../node_modules/@openpgp/noble-hashes/esm/biginteger/native.interface.js"],"sourcesContent":["/**\n * @fileoverview\n * BigInteger implementation of basic operations\n * that wraps the native BigInt library.\n * Operations are not constant time,\n * but we try and limit timing leakage where we can\n * @module biginteger/native\n * @private\n */\nimport AbstractBigInteger from './interface.js';\n/**\n * @private\n */\nexport default class NativeBigInteger extends AbstractBigInteger {\n /**\n * Get a BigInteger (input must be big endian for strings and arrays)\n * @param {Number|String|Uint8Array} n - Value to convert\n * @throws {Error} on null or undefined input\n */\n constructor(n) {\n super(); // noop, needed for TS checks only\n if (n === undefined) {\n throw new Error('Invalid BigInteger input');\n }\n if (n instanceof Uint8Array) {\n const bytes = n;\n const hexAlphabet = '0123456789ABCDEF';\n let s = '';\n bytes.forEach((v) => {\n s += hexAlphabet[v >> 4] + hexAlphabet[v & 15];\n });\n this.value = BigInt('0x0' + s);\n }\n else {\n this.value = BigInt(n);\n }\n }\n clone() {\n return new NativeBigInteger(this.value);\n }\n /**\n * BigInteger increment in place\n */\n iinc() {\n this.value++;\n return this;\n }\n /**\n * BigInteger increment\n * @returns {BigInteger} this + 1.\n */\n inc() {\n return this.clone().iinc();\n }\n /**\n * BigInteger decrement in place\n */\n idec() {\n this.value--;\n return this;\n }\n /**\n * BigInteger decrement\n * @returns {BigInteger} this - 1.\n */\n dec() {\n return this.clone().idec();\n }\n /**\n * BigInteger addition in place\n * @param {BigInteger} x - Value to add\n */\n iadd(x) {\n this.value += x.value;\n return this;\n }\n /**\n * BigInteger addition\n * @param {BigInteger} x - Value to add\n * @returns {BigInteger} this + x.\n */\n add(x) {\n return this.clone().iadd(x);\n }\n /**\n * BigInteger subtraction in place\n * @param {BigInteger} x - Value to subtract\n */\n isub(x) {\n this.value -= x.value;\n return this;\n }\n /**\n * BigInteger subtraction\n * @param {BigInteger} x - Value to subtract\n * @returns {BigInteger} this - x.\n */\n sub(x) {\n return this.clone().isub(x);\n }\n /**\n * BigInteger multiplication in place\n * @param {BigInteger} x - Value to multiply\n */\n imul(x) {\n this.value *= x.value;\n return this;\n }\n /**\n * BigInteger multiplication\n * @param {BigInteger} x - Value to multiply\n * @returns {BigInteger} this * x.\n */\n mul(x) {\n return this.clone().imul(x);\n }\n /**\n * Compute value modulo m, in place\n * @param {BigInteger} m - Modulo\n */\n imod(m) {\n this.value %= m.value;\n if (this.isNegative()) {\n this.iadd(m);\n }\n return this;\n }\n /**\n * Compute value modulo m\n * @param {BigInteger} m - Modulo\n * @returns {BigInteger} this mod m.\n */\n mod(m) {\n return this.clone().imod(m);\n }\n /**\n * Compute modular exponentiation using square and multiply\n * @param {BigInteger} e - Exponent\n * @param {BigInteger} n - Modulo\n * @returns {BigInteger} this ** e mod n.\n */\n modExp(e, n) {\n if (n.isZero())\n throw Error('Modulo cannot be zero');\n if (n.isOne())\n return new NativeBigInteger(0);\n if (e.isNegative())\n throw Error('Unsopported negative exponent');\n let exp = e.value;\n let x = this.value;\n x %= n.value;\n let r = BigInt(1);\n while (exp > BigInt(0)) {\n const lsb = exp & BigInt(1);\n exp >>= BigInt(1); // e / 2\n // Always compute multiplication step, to reduce timing leakage\n const rx = (r * x) % n.value;\n // Update r only if lsb is 1 (odd exponent)\n r = lsb ? rx : r;\n x = (x * x) % n.value; // Square\n }\n return new NativeBigInteger(r);\n }\n /**\n * Compute the inverse of this value modulo n\n * Note: this and and n must be relatively prime\n * @param {BigInteger} n - Modulo\n * @returns {BigInteger} x such that this*x = 1 mod n\n * @throws {Error} if the inverse does not exist\n */\n modInv(n) {\n const { gcd, x } = this._egcd(n);\n if (!gcd.isOne()) {\n throw new Error('Inverse does not exist');\n }\n return x.add(n).mod(n);\n }\n /**\n * BigInteger division, in place\n * @param {BigInteger} n - Value to divide\n */\n idiv(n) {\n this.value /= n.value;\n return this;\n }\n /**\n * BigInteger division\n * @param {BigInteger} n - Value to divide\n * @returns {BigInteger} this divded by n.\n */\n div(n) {\n return this.clone().idiv(n);\n }\n /**\n * Extended Eucleadian algorithm (http://anh.cs.luc.edu/331/notes/xgcd.pdf)\n * Given a = this and b, compute (x, y) such that ax + by = gdc(a, b).\n * Negative numbers are also supported.\n * @param {BigInteger} b - Second operand\n * @returns {{ gcd, x, y: BigInteger }}\n */\n _egcd(bInput) {\n let x = BigInt(0);\n let y = BigInt(1);\n let xPrev = BigInt(1);\n let yPrev = BigInt(0);\n // Deal with negative numbers: run algo over absolute values,\n // and \"move\" the sign to the returned x and/or y.\n // See https://math.stackexchange.com/questions/37806/extended-euclidean-algorithm-with-negative-numbers\n let a = this.abs().value;\n let b = bInput.abs().value;\n const aNegated = this.isNegative();\n const bNegated = bInput.isNegative();\n while (b !== BigInt(0)) {\n const q = a / b;\n let tmp = x;\n x = xPrev - q * x;\n xPrev = tmp;\n tmp = y;\n y = yPrev - q * y;\n yPrev = tmp;\n tmp = b;\n b = a % b;\n a = tmp;\n }\n return {\n x: new NativeBigInteger(aNegated ? -xPrev : xPrev),\n y: new NativeBigInteger(bNegated ? -yPrev : yPrev),\n gcd: new NativeBigInteger(a),\n };\n }\n /**\n * Compute greatest common divisor between this and n\n * @param {BigInteger} b - Operand\n * @returns {BigInteger} gcd\n */\n gcd(bInput) {\n let a = this.value;\n let b = bInput.value;\n while (b !== BigInt(0)) {\n const tmp = b;\n b = a % b;\n a = tmp;\n }\n return new NativeBigInteger(a);\n }\n /**\n * Shift this to the left by x, in place\n * @param {BigInteger} x - Shift value\n */\n ileftShift(x) {\n this.value <<= x.value;\n return this;\n }\n /**\n * Shift this to the left by x\n * @param {BigInteger} x - Shift value\n * @returns {BigInteger} this << x.\n */\n leftShift(x) {\n return this.clone().ileftShift(x);\n }\n /**\n * Shift this to the right by x, in place\n * @param {BigInteger} x - Shift value\n */\n irightShift(x) {\n this.value >>= x.value;\n return this;\n }\n /**\n * Shift this to the right by x\n * @param {BigInteger} x - Shift value\n * @returns {BigInteger} this >> x.\n */\n rightShift(x) {\n return this.clone().irightShift(x);\n }\n ixor(x) {\n this.value ^= x.value;\n return this;\n }\n xor(x) {\n return this.clone().ixor(x);\n }\n ibitwiseAnd(x) {\n this.value &= x.value;\n return this;\n }\n bitwiseAnd(x) {\n return this.clone().ibitwiseAnd(x);\n }\n ibitwiseOr(x) {\n this.value |= x.value;\n return this;\n }\n /**\n * Whether this value is equal to x\n * @param {BigInteger} x\n * @returns {Boolean}\n */\n equal(x) {\n return this.value === x.value;\n }\n /**\n * Whether this value is less than x\n * @param {BigInteger} x\n * @returns {Boolean}\n */\n lt(x) {\n return this.value < x.value;\n }\n /**\n * Whether this value is less than or equal to x\n * @param {BigInteger} x\n * @returns {Boolean}\n */\n lte(x) {\n return this.value <= x.value;\n }\n /**\n * Whether this value is greater than x\n * @param {BigInteger} x\n * @returns {Boolean}\n */\n gt(x) {\n return this.value > x.value;\n }\n /**\n * Whether this value is greater than or equal to x\n * @param {BigInteger} x\n * @returns {Boolean}\n */\n gte(x) {\n return this.value >= x.value;\n }\n isZero() {\n return this.value === BigInt(0);\n }\n isOne() {\n return this.value === BigInt(1);\n }\n isNegative() {\n return this.value < BigInt(0);\n }\n isEven() {\n return !(this.value & BigInt(1));\n }\n abs() {\n const res = this.clone();\n if (this.isNegative()) {\n res.value = -res.value;\n }\n return res;\n }\n negate() {\n const res = this.clone();\n res.value = -res.value;\n return res;\n }\n /**\n * Get this value as a string\n * @returns {String} this value.\n */\n toString() {\n return this.value.toString();\n }\n /**\n * Get this value as an exact Number (max 53 bits)\n * Fails if this value is too large\n * @returns {Number}\n */\n toNumber() {\n const number = Number(this.value);\n if (number > Number.MAX_SAFE_INTEGER) {\n // We throw and error to conform with the bn.js implementation\n throw new Error('Number can only safely store up to 53 bits');\n }\n return number;\n }\n /**\n * Get value of i-th bit\n * @param {Number} i - Bit index\n * @returns {Number} Bit value.\n */\n getBit(i) {\n const bit = (this.value >> BigInt(i)) & BigInt(1);\n return bit === BigInt(0) ? 0 : 1;\n }\n /**\n * Compute bit length\n * @returns {Number} Bit length.\n */\n bitLength() {\n const zero = new NativeBigInteger(0);\n const one = new NativeBigInteger(1);\n const negOne = new NativeBigInteger(-1);\n // -1n >> -1n is -1n\n // 1n >> 1n is 0n\n const target = this.isNegative() ? negOne : zero;\n let bitlen = 1;\n const tmp = this.clone();\n while (!tmp.irightShift(one).equal(target)) {\n bitlen++;\n }\n return bitlen;\n }\n /**\n * Compute byte length\n * @returns {Number} Byte length.\n */\n byteLength() {\n const zero = new NativeBigInteger(0);\n const negOne = new NativeBigInteger(-1);\n const target = this.isNegative() ? negOne : zero;\n const eight = new NativeBigInteger(8);\n let len = 1;\n const tmp = this.clone();\n while (!tmp.irightShift(eight).equal(target)) {\n len++;\n }\n return len;\n }\n /**\n * Get Uint8Array representation of this number\n * @param {String} endian - Endianess of output array (defaults to 'be')\n * @param {Number} length - Of output array\n * @returns {Uint8Array}\n */\n toUint8Array(endian = 'be', length) {\n // we get and parse the hex string (https://coolaj86.com/articles/convert-js-bigints-to-typedarrays/)\n // this is faster than shift+mod iterations\n let hex = this.value.toString(16);\n if (hex.length % 2 === 1) {\n hex = '0' + hex;\n }\n const rawLength = hex.length / 2;\n const bytes = new Uint8Array(length || rawLength);\n // parse hex\n const offset = length ? length - rawLength : 0;\n let i = 0;\n while (i < rawLength) {\n bytes[i + offset] = parseInt(hex.slice(2 * i, 2 * i + 2), 16);\n i++;\n }\n if (endian !== 'be') {\n bytes.reverse();\n }\n return bytes;\n }\n}\n//# sourceMappingURL=native.interface.js.map"],"names":["NativeBigInteger","AbstractBigInteger","constructor","n","super","undefined","Error","Uint8Array","hexAlphabet","s","forEach","v","this","value","BigInt","clone","iinc","inc","idec","dec","iadd","x","add","isub","sub","imul","mul","imod","m","isNegative","mod","modExp","e","isZero","isOne","exp","r","lsb","rx","modInv","gcd","_egcd","idiv","div","bInput","y","xPrev","yPrev","a","abs","b","aNegated","bNegated","q","tmp","ileftShift","leftShift","irightShift","rightShift","ixor","xor","ibitwiseAnd","bitwiseAnd","ibitwiseOr","equal","lt","lte","gt","gte","isEven","res","negate","toString","toNumber","number","Number","MAX_SAFE_INTEGER","getBit","i","bitLength","zero","one","negOne","target","bitlen","byteLength","eight","len","toUint8Array","endian","length","hex","rawLength","bytes","offset","parseInt","slice","reverse"],"mappings":";2IAae,MAAMA,UAAyBC,EAM1C,WAAAC,CAAYC,GAER,GADAC,aACUC,IAANF,EACA,MAAUG,MAAM,4BAEpB,GAAIH,aAAaI,WAAY,CACzB,MACMC,EAAc,mBACpB,IAAIC,EAAI,GAFMN,EAGRO,SAASC,IACXF,GAAKD,EAAYG,GAAK,GAAKH,EAAgB,GAAJG,EAAO,IAElDC,KAAKC,MAAQC,OAAO,MAAQL,EAC/B,MAEGG,KAAKC,MAAQC,OAAOX,EAE3B,CACD,KAAAY,GACI,OAAO,IAAIf,EAAiBY,KAAKC,MACpC,CAID,IAAAG,GAEI,OADAJ,KAAKC,QACED,IACV,CAKD,GAAAK,GACI,OAAOL,KAAKG,QAAQC,MACvB,CAID,IAAAE,GAEI,OADAN,KAAKC,QACED,IACV,CAKD,GAAAO,GACI,OAAOP,KAAKG,QAAQG,MACvB,CAKD,IAAAE,CAAKC,GAED,OADAT,KAAKC,OAASQ,EAAER,MACTD,IACV,CAMD,GAAAU,CAAID,GACA,OAAOT,KAAKG,QAAQK,KAAKC,EAC5B,CAKD,IAAAE,CAAKF,GAED,OADAT,KAAKC,OAASQ,EAAER,MACTD,IACV,CAMD,GAAAY,CAAIH,GACA,OAAOT,KAAKG,QAAQQ,KAAKF,EAC5B,CAKD,IAAAI,CAAKJ,GAED,OADAT,KAAKC,OAASQ,EAAER,MACTD,IACV,CAMD,GAAAc,CAAIL,GACA,OAAOT,KAAKG,QAAQU,KAAKJ,EAC5B,CAKD,IAAAM,CAAKC,GAKD,OAJAhB,KAAKC,OAASe,EAAEf,MACZD,KAAKiB,cACLjB,KAAKQ,KAAKQ,GAEPhB,IACV,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IuF,EAAM,EACV,MAAMjC,EAAM1C,KAAKG,QACjB,MAAQuC,EAAIG,YAAY6B,GAAOtB,MAAMmB,IACjCI,IAEJ,OAAOA,CACV,CAOD,YAAAC,CAAaC,EAAS,KAAMC,GAGxB,IAAIC,EAAM/E,KAAKC,MAAM2D,SAAS,IAC1BmB,EAAID,OAAS,GAAM,IACnBC,EAAM,IAAMA,GAEhB,MAAMC,EAAYD,EAAID,OAAS,EACzBG,EAAQ,IAAItF,WAAWmF,GAAUE,GAEjCE,EAASJ,EAASA,EAASE,EAAY,EAC7C,IAAId,EAAI,EACR,KAAOA,EAAIc,GACPC,EAAMf,EAAIgB,GAAUC,SAASJ,EAAIK,MAAM,EAAIlB,EAAG,EAAIA,EAAI,GAAI,IAC1DA,IAKJ,MAHe,OAAXW,GACAI,EAAMI,UAEHJ,CACV","x_google_ignoreList":[0]}
@@ -1,456 +0,0 @@
1
- /*! OpenPGP.js v6.0.0-beta.0.patch.0 - 2024-04-19 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3
-
4
- import { B as BigInteger } from './interface.mjs';
5
-
6
- /**
7
- * @fileoverview
8
- * BigInteger implementation of basic operations
9
- * that wraps the native BigInt library.
10
- * Operations are not constant time,
11
- * but we try and limit timing leakage where we can
12
- * @module biginteger/native
13
- * @private
14
- */
15
- /**
16
- * @private
17
- */
18
- class NativeBigInteger extends BigInteger {
19
- /**
20
- * Get a BigInteger (input must be big endian for strings and arrays)
21
- * @param {Number|String|Uint8Array} n - Value to convert
22
- * @throws {Error} on null or undefined input
23
- */
24
- constructor(n) {
25
- super(); // noop, needed for TS checks only
26
- if (n === undefined) {
27
- throw new Error('Invalid BigInteger input');
28
- }
29
- if (n instanceof Uint8Array) {
30
- const bytes = n;
31
- const hexAlphabet = '0123456789ABCDEF';
32
- let s = '';
33
- bytes.forEach((v) => {
34
- s += hexAlphabet[v >> 4] + hexAlphabet[v & 15];
35
- });
36
- this.value = BigInt('0x0' + s);
37
- }
38
- else {
39
- this.value = BigInt(n);
40
- }
41
- }
42
- clone() {
43
- return new NativeBigInteger(this.value);
44
- }
45
- /**
46
- * BigInteger increment in place
47
- */
48
- iinc() {
49
- this.value++;
50
- return this;
51
- }
52
- /**
53
- * BigInteger increment
54
- * @returns {BigInteger} this + 1.
55
- */
56
- inc() {
57
- return this.clone().iinc();
58
- }
59
- /**
60
- * BigInteger decrement in place
61
- */
62
- idec() {
63
- this.value--;
64
- return this;
65
- }
66
- /**
67
- * BigInteger decrement
68
- * @returns {BigInteger} this - 1.
69
- */
70
- dec() {
71
- return this.clone().idec();
72
- }
73
- /**
74
- * BigInteger addition in place
75
- * @param {BigInteger} x - Value to add
76
- */
77
- iadd(x) {
78
- this.value += x.value;
79
- return this;
80
- }
81
- /**
82
- * BigInteger addition
83
- * @param {BigInteger} x - Value to add
84
- * @returns {BigInteger} this + x.
85
- */
86
- add(x) {
87
- return this.clone().iadd(x);
88
- }
89
- /**
90
- * BigInteger subtraction in place
91
- * @param {BigInteger} x - Value to subtract
92
- */
93
- isub(x) {
94
- this.value -= x.value;
95
- return this;
96
- }
97
- /**
98
- * BigInteger subtraction
99
- * @param {BigInteger} x - Value to subtract
100
- * @returns {BigInteger} this - x.
101
- */
102
- sub(x) {
103
- return this.clone().isub(x);
104
- }
105
- /**
106
- * BigInteger multiplication in place
107
- * @param {BigInteger} x - Value to multiply
108
- */
109
- imul(x) {
110
- this.value *= x.value;
111
- return this;
112
- }
113
- /**
114
- * BigInteger multiplication
115
- * @param {BigInteger} x - Value to multiply
116
- * @returns {BigInteger} this * x.
117
- */
118
- mul(x) {
119
- return this.clone().imul(x);
120
- }
121
- /**
122
- * Compute value modulo m, in place
123
- * @param {BigInteger} m - Modulo
124
- */
125
- imod(m) {
126
- this.value %= m.value;
127
- if (this.isNegative()) {
128
- this.iadd(m);
129
- }
130
- return this;
131
- }
132
- /**
133
- * Compute value modulo m
134
- * @param {BigInteger} m - Modulo
135
- * @returns {BigInteger} this mod m.
136
- */
137
- mod(m) {
138
- return this.clone().imod(m);
139
- }
140
- /**
141
- * Compute modular exponentiation using square and multiply
142
- * @param {BigInteger} e - Exponent
143
- * @param {BigInteger} n - Modulo
144
- * @returns {BigInteger} this ** e mod n.
145
- */
146
- modExp(e, n) {
147
- if (n.isZero())
148
- throw Error('Modulo cannot be zero');
149
- if (n.isOne())
150
- return new NativeBigInteger(0);
151
- if (e.isNegative())
152
- throw Error('Unsopported negative exponent');
153
- let exp = e.value;
154
- let x = this.value;
155
- x %= n.value;
156
- let r = BigInt(1);
157
- while (exp > BigInt(0)) {
158
- const lsb = exp & BigInt(1);
159
- exp >>= BigInt(1); // e / 2
160
- // Always compute multiplication step, to reduce timing leakage
161
- const rx = (r * x) % n.value;
162
- // Update r only if lsb is 1 (odd exponent)
163
- r = lsb ? rx : r;
164
- x = (x * x) % n.value; // Square
165
- }
166
- return new NativeBigInteger(r);
167
- }
168
- /**
169
- * Compute the inverse of this value modulo n
170
- * Note: this and and n must be relatively prime
171
- * @param {BigInteger} n - Modulo
172
- * @returns {BigInteger} x such that this*x = 1 mod n
173
- * @throws {Error} if the inverse does not exist
174
- */
175
- modInv(n) {
176
- const { gcd, x } = this._egcd(n);
177
- if (!gcd.isOne()) {
178
- throw new Error('Inverse does not exist');
179
- }
180
- return x.add(n).mod(n);
181
- }
182
- /**
183
- * BigInteger division, in place
184
- * @param {BigInteger} n - Value to divide
185
- */
186
- idiv(n) {
187
- this.value /= n.value;
188
- return this;
189
- }
190
- /**
191
- * BigInteger division
192
- * @param {BigInteger} n - Value to divide
193
- * @returns {BigInteger} this divded by n.
194
- */
195
- div(n) {
196
- return this.clone().idiv(n);
197
- }
198
- /**
199
- * Extended Eucleadian algorithm (http://anh.cs.luc.edu/331/notes/xgcd.pdf)
200
- * Given a = this and b, compute (x, y) such that ax + by = gdc(a, b).
201
- * Negative numbers are also supported.
202
- * @param {BigInteger} b - Second operand
203
- * @returns {{ gcd, x, y: BigInteger }}
204
- */
205
- _egcd(bInput) {
206
- let x = BigInt(0);
207
- let y = BigInt(1);
208
- let xPrev = BigInt(1);
209
- let yPrev = BigInt(0);
210
- // Deal with negative numbers: run algo over absolute values,
211
- // and "move" the sign to the returned x and/or y.
212
- // See https://math.stackexchange.com/questions/37806/extended-euclidean-algorithm-with-negative-numbers
213
- let a = this.abs().value;
214
- let b = bInput.abs().value;
215
- const aNegated = this.isNegative();
216
- const bNegated = bInput.isNegative();
217
- while (b !== BigInt(0)) {
218
- const q = a / b;
219
- let tmp = x;
220
- x = xPrev - q * x;
221
- xPrev = tmp;
222
- tmp = y;
223
- y = yPrev - q * y;
224
- yPrev = tmp;
225
- tmp = b;
226
- b = a % b;
227
- a = tmp;
228
- }
229
- return {
230
- x: new NativeBigInteger(aNegated ? -xPrev : xPrev),
231
- y: new NativeBigInteger(bNegated ? -yPrev : yPrev),
232
- gcd: new NativeBigInteger(a),
233
- };
234
- }
235
- /**
236
- * Compute greatest common divisor between this and n
237
- * @param {BigInteger} b - Operand
238
- * @returns {BigInteger} gcd
239
- */
240
- gcd(bInput) {
241
- let a = this.value;
242
- let b = bInput.value;
243
- while (b !== BigInt(0)) {
244
- const tmp = b;
245
- b = a % b;
246
- a = tmp;
247
- }
248
- return new NativeBigInteger(a);
249
- }
250
- /**
251
- * Shift this to the left by x, in place
252
- * @param {BigInteger} x - Shift value
253
- */
254
- ileftShift(x) {
255
- this.value <<= x.value;
256
- return this;
257
- }
258
- /**
259
- * Shift this to the left by x
260
- * @param {BigInteger} x - Shift value
261
- * @returns {BigInteger} this << x.
262
- */
263
- leftShift(x) {
264
- return this.clone().ileftShift(x);
265
- }
266
- /**
267
- * Shift this to the right by x, in place
268
- * @param {BigInteger} x - Shift value
269
- */
270
- irightShift(x) {
271
- this.value >>= x.value;
272
- return this;
273
- }
274
- /**
275
- * Shift this to the right by x
276
- * @param {BigInteger} x - Shift value
277
- * @returns {BigInteger} this >> x.
278
- */
279
- rightShift(x) {
280
- return this.clone().irightShift(x);
281
- }
282
- ixor(x) {
283
- this.value ^= x.value;
284
- return this;
285
- }
286
- xor(x) {
287
- return this.clone().ixor(x);
288
- }
289
- ibitwiseAnd(x) {
290
- this.value &= x.value;
291
- return this;
292
- }
293
- bitwiseAnd(x) {
294
- return this.clone().ibitwiseAnd(x);
295
- }
296
- ibitwiseOr(x) {
297
- this.value |= x.value;
298
- return this;
299
- }
300
- /**
301
- * Whether this value is equal to x
302
- * @param {BigInteger} x
303
- * @returns {Boolean}
304
- */
305
- equal(x) {
306
- return this.value === x.value;
307
- }
308
- /**
309
- * Whether this value is less than x
310
- * @param {BigInteger} x
311
- * @returns {Boolean}
312
- */
313
- lt(x) {
314
- return this.value < x.value;
315
- }
316
- /**
317
- * Whether this value is less than or equal to x
318
- * @param {BigInteger} x
319
- * @returns {Boolean}
320
- */
321
- lte(x) {
322
- return this.value <= x.value;
323
- }
324
- /**
325
- * Whether this value is greater than x
326
- * @param {BigInteger} x
327
- * @returns {Boolean}
328
- */
329
- gt(x) {
330
- return this.value > x.value;
331
- }
332
- /**
333
- * Whether this value is greater than or equal to x
334
- * @param {BigInteger} x
335
- * @returns {Boolean}
336
- */
337
- gte(x) {
338
- return this.value >= x.value;
339
- }
340
- isZero() {
341
- return this.value === BigInt(0);
342
- }
343
- isOne() {
344
- return this.value === BigInt(1);
345
- }
346
- isNegative() {
347
- return this.value < BigInt(0);
348
- }
349
- isEven() {
350
- return !(this.value & BigInt(1));
351
- }
352
- abs() {
353
- const res = this.clone();
354
- if (this.isNegative()) {
355
- res.value = -res.value;
356
- }
357
- return res;
358
- }
359
- negate() {
360
- const res = this.clone();
361
- res.value = -res.value;
362
- return res;
363
- }
364
- /**
365
- * Get this value as a string
366
- * @returns {String} this value.
367
- */
368
- toString() {
369
- return this.value.toString();
370
- }
371
- /**
372
- * Get this value as an exact Number (max 53 bits)
373
- * Fails if this value is too large
374
- * @returns {Number}
375
- */
376
- toNumber() {
377
- const number = Number(this.value);
378
- if (number > Number.MAX_SAFE_INTEGER) {
379
- // We throw and error to conform with the bn.js implementation
380
- throw new Error('Number can only safely store up to 53 bits');
381
- }
382
- return number;
383
- }
384
- /**
385
- * Get value of i-th bit
386
- * @param {Number} i - Bit index
387
- * @returns {Number} Bit value.
388
- */
389
- getBit(i) {
390
- const bit = (this.value >> BigInt(i)) & BigInt(1);
391
- return bit === BigInt(0) ? 0 : 1;
392
- }
393
- /**
394
- * Compute bit length
395
- * @returns {Number} Bit length.
396
- */
397
- bitLength() {
398
- const zero = new NativeBigInteger(0);
399
- const one = new NativeBigInteger(1);
400
- const negOne = new NativeBigInteger(-1);
401
- // -1n >> -1n is -1n
402
- // 1n >> 1n is 0n
403
- const target = this.isNegative() ? negOne : zero;
404
- let bitlen = 1;
405
- const tmp = this.clone();
406
- while (!tmp.irightShift(one).equal(target)) {
407
- bitlen++;
408
- }
409
- return bitlen;
410
- }
411
- /**
412
- * Compute byte length
413
- * @returns {Number} Byte length.
414
- */
415
- byteLength() {
416
- const zero = new NativeBigInteger(0);
417
- const negOne = new NativeBigInteger(-1);
418
- const target = this.isNegative() ? negOne : zero;
419
- const eight = new NativeBigInteger(8);
420
- let len = 1;
421
- const tmp = this.clone();
422
- while (!tmp.irightShift(eight).equal(target)) {
423
- len++;
424
- }
425
- return len;
426
- }
427
- /**
428
- * Get Uint8Array representation of this number
429
- * @param {String} endian - Endianess of output array (defaults to 'be')
430
- * @param {Number} length - Of output array
431
- * @returns {Uint8Array}
432
- */
433
- toUint8Array(endian = 'be', length) {
434
- // we get and parse the hex string (https://coolaj86.com/articles/convert-js-bigints-to-typedarrays/)
435
- // this is faster than shift+mod iterations
436
- let hex = this.value.toString(16);
437
- if (hex.length % 2 === 1) {
438
- hex = '0' + hex;
439
- }
440
- const rawLength = hex.length / 2;
441
- const bytes = new Uint8Array(length || rawLength);
442
- // parse hex
443
- const offset = length ? length - rawLength : 0;
444
- let i = 0;
445
- while (i < rawLength) {
446
- bytes[i + offset] = parseInt(hex.slice(2 * i, 2 * i + 2), 16);
447
- i++;
448
- }
449
- if (endian !== 'be') {
450
- bytes.reverse();
451
- }
452
- return bytes;
453
- }
454
- }
455
-
456
- export { NativeBigInteger as default };