@protontech/openpgp 6.0.0-alpha.1.patch.1 → 6.0.0-beta.0.patch.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lightweight/argon2id.min.mjs +1 -1
- package/dist/lightweight/argon2id.mjs +1 -1
- package/dist/lightweight/bn.interface.min.mjs +2 -2
- package/dist/lightweight/bn.interface.min.mjs.map +1 -1
- package/dist/lightweight/bn.interface.mjs +1 -1
- package/dist/lightweight/interface.min.mjs +1 -1
- package/dist/lightweight/interface.mjs +1 -1
- package/dist/lightweight/legacy_ciphers.min.mjs +1 -1
- package/dist/lightweight/legacy_ciphers.mjs +1 -1
- package/dist/lightweight/native.interface.min.mjs +1 -1
- package/dist/lightweight/native.interface.mjs +1 -1
- package/dist/lightweight/noble_curves.min.mjs +3 -3
- package/dist/lightweight/noble_curves.min.mjs.map +1 -1
- package/dist/lightweight/noble_curves.mjs +1 -1
- package/dist/lightweight/noble_hashes.min.mjs +1 -1
- package/dist/lightweight/noble_hashes.mjs +1 -1
- package/dist/lightweight/openpgp.min.mjs +2 -2
- package/dist/lightweight/openpgp.min.mjs.map +1 -1
- package/dist/lightweight/openpgp.mjs +211 -83
- package/dist/lightweight/sha3.min.mjs +2 -2
- package/dist/lightweight/sha3.min.mjs.map +1 -1
- package/dist/lightweight/sha3.mjs +1 -1
- package/dist/node/openpgp.cjs +211 -83
- package/dist/node/openpgp.min.cjs +11 -11
- package/dist/node/openpgp.min.cjs.map +1 -1
- package/dist/node/openpgp.min.mjs +11 -11
- package/dist/node/openpgp.min.mjs.map +1 -1
- package/dist/node/openpgp.mjs +211 -83
- package/dist/openpgp.js +211 -83
- package/dist/openpgp.min.js +11 -11
- package/dist/openpgp.min.js.map +1 -1
- package/dist/openpgp.min.mjs +11 -11
- package/dist/openpgp.min.mjs.map +1 -1
- package/dist/openpgp.mjs +211 -83
- package/openpgp.d.ts +5 -3
- package/package.json +9 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.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
2
|
const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3
3
|
|
|
4
4
|
import { B as BigInteger } from './interface.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.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
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
3
|
//# sourceMappingURL=interface.min.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.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
2
|
const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3
3
|
|
|
4
4
|
class BigInteger {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.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
2
|
"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;import{enums as t}from"./openpgp.min.mjs";function i(t,i,e,n,s,r){const o=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],h=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],c=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],a=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],l=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],f=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],u=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],y=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];let p,k,g,m,S,b,z,d,w,A,B,N,_,x,E=0,K=i.length;const O=32===t.length?3:9;d=3===O?e?[0,32,2]:[30,-2,-2]:e?[0,32,2,62,30,-2,64,96,2]:[94,62,-2,32,64,2,30,-2,-2],e&&(i=function(t,i){const e=8-t.length%8;let n;if(2===i&&e<8)n=32;else if(1===i)n=e;else{if(i||!(e<8)){if(8===e)return t;throw Error("des: invalid padding")}n=0}const s=new Uint8Array(t.length+e);for(let i=0;i<t.length;i++)s[i]=t[i];for(let i=0;i<e;i++)s[t.length+i]=n;return s}(i,r),K=i.length);let C=new Uint8Array(K),I=0;for(1===n&&(w=s[E++]<<24|s[E++]<<16|s[E++]<<8|s[E++],B=s[E++]<<24|s[E++]<<16|s[E++]<<8|s[E++],E=0);E<K;){for(b=i[E++]<<24|i[E++]<<16|i[E++]<<8|i[E++],z=i[E++]<<24|i[E++]<<16|i[E++]<<8|i[E++],1===n&&(e?(b^=w,z^=B):(A=w,N=B,w=b,B=z)),g=252645135&(b>>>4^z),z^=g,b^=g<<4,g=65535&(b>>>16^z),z^=g,b^=g<<16,g=858993459&(z>>>2^b),b^=g,z^=g<<2,g=16711935&(z>>>8^b),b^=g,z^=g<<8,g=1431655765&(b>>>1^z),z^=g,b^=g<<1,b=b<<1|b>>>31,z=z<<1|z>>>31,k=0;k<O;k+=3){for(_=d[k+1],x=d[k+2],p=d[k];p!==_;p+=x)m=z^t[p],S=(z>>>4|z<<28)^t[p+1],g=b,b=z,z=g^(h[m>>>24&63]|a[m>>>16&63]|f[m>>>8&63]|y[63&m]|o[S>>>24&63]|c[S>>>16&63]|l[S>>>8&63]|u[63&S]);g=b,b=z,z=g}b=b>>>1|b<<31,z=z>>>1|z<<31,g=1431655765&(b>>>1^z),z^=g,b^=g<<1,g=16711935&(z>>>8^b),b^=g,z^=g<<8,g=858993459&(z>>>2^b),b^=g,z^=g<<2,g=65535&(b>>>16^z),z^=g,b^=g<<16,g=252645135&(b>>>4^z),z^=g,b^=g<<4,1===n&&(e?(w=b,B=z):(b^=A,z^=N)),C[I++]=b>>>24,C[I++]=b>>>16&255,C[I++]=b>>>8&255,C[I++]=255&b,C[I++]=z>>>24,C[I++]=z>>>16&255,C[I++]=z>>>8&255,C[I++]=255&z}return e||(C=function(t,i){let e,n=null;if(2===i)e=32;else if(1===i)n=t[t.length-1];else{if(i)throw Error("des: invalid padding");e=0}if(!n){for(n=1;t[t.length-n]===e;)n++;n--}return t.subarray(0,t.length-n)}(C,r)),C}function e(t){const i=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],e=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],s=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],r=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],o=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],h=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],a=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],l=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],u=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],y=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],p=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],k=t.length>8?3:1,g=Array(32*k),m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0];let S,b,z,d=0,w=0;for(let A=0;A<k;A++){let k=t[d++]<<24|t[d++]<<16|t[d++]<<8|t[d++],A=t[d++]<<24|t[d++]<<16|t[d++]<<8|t[d++];z=252645135&(k>>>4^A),A^=z,k^=z<<4,z=65535&(A>>>-16^k),k^=z,A^=z<<-16,z=858993459&(k>>>2^A),A^=z,k^=z<<2,z=65535&(A>>>-16^k),k^=z,A^=z<<-16,z=1431655765&(k>>>1^A),A^=z,k^=z<<1,z=16711935&(A>>>8^k),k^=z,A^=z<<8,z=1431655765&(k>>>1^A),A^=z,k^=z<<1,z=k<<8|A>>>20&240,k=A<<24|A<<8&16711680|A>>>8&65280|A>>>24&240,A=z;for(let t=0;t<16;t++)m[t]?(k=k<<2|k>>>26,A=A<<2|A>>>26):(k=k<<1|k>>>27,A=A<<1|A>>>27),k&=-15,A&=-15,S=i[k>>>28]|e[k>>>24&15]|n[k>>>20&15]|s[k>>>16&15]|r[k>>>12&15]|o[k>>>8&15]|h[k>>>4&15],b=c[A>>>28]|a[A>>>24&15]|l[A>>>20&15]|f[A>>>16&15]|u[A>>>12&15]|y[A>>>8&15]|p[A>>>4&15],z=65535&(b>>>16^S),g[w++]=S^z,g[w++]=b^z<<16}return g}function n(t){this.key=[];for(let i=0;i<3;i++)this.key.push(new Uint8Array(t.subarray(8*i,8*i+8)));this.encrypt=function(t){return i(e(this.key[2]),i(e(this.key[1]),i(e(this.key[0]),t,!0,0,null,null),!1,0,null,null),!0,0,null,null)}}function s(){this.BlockSize=8,this.KeySize=16,this.setKey=function(t){if(this.masking=Array(16),this.rotate=Array(16),this.reset(),t.length!==this.KeySize)throw Error("CAST-128: keys must be 16 bytes");return this.keySchedule(t),!0},this.reset=function(){for(let t=0;t<16;t++)this.masking[t]=0,this.rotate[t]=0},this.getBlockSize=function(){return this.BlockSize},this.encrypt=function(t){const i=Array(t.length);for(let r=0;r<t.length;r+=8){let o,h=t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3],c=t[r+4]<<24|t[r+5]<<16|t[r+6]<<8|t[r+7];o=c,c=h^e(c,this.masking[0],this.rotate[0]),h=o,o=c,c=h^n(c,this.masking[1],this.rotate[1]),h=o,o=c,c=h^s(c,this.masking[2],this.rotate[2]),h=o,o=c,c=h^e(c,this.masking[3],this.rotate[3]),h=o,o=c,c=h^n(c,this.masking[4],this.rotate[4]),h=o,o=c,c=h^s(c,this.masking[5],this.rotate[5]),h=o,o=c,c=h^e(c,this.masking[6],this.rotate[6]),h=o,o=c,c=h^n(c,this.masking[7],this.rotate[7]),h=o,o=c,c=h^s(c,this.masking[8],this.rotate[8]),h=o,o=c,c=h^e(c,this.masking[9],this.rotate[9]),h=o,o=c,c=h^n(c,this.masking[10],this.rotate[10]),h=o,o=c,c=h^s(c,this.masking[11],this.rotate[11]),h=o,o=c,c=h^e(c,this.masking[12],this.rotate[12]),h=o,o=c,c=h^n(c,this.masking[13],this.rotate[13]),h=o,o=c,c=h^s(c,this.masking[14],this.rotate[14]),h=o,o=c,c=h^e(c,this.masking[15],this.rotate[15]),h=o,i[r]=c>>>24&255,i[r+1]=c>>>16&255,i[r+2]=c>>>8&255,i[r+3]=255&c,i[r+4]=h>>>24&255,i[r+5]=h>>>16&255,i[r+6]=h>>>8&255,i[r+7]=255&h}return i},this.decrypt=function(t){const i=Array(t.length);for(let r=0;r<t.length;r+=8){let o,h=t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3],c=t[r+4]<<24|t[r+5]<<16|t[r+6]<<8|t[r+7];o=c,c=h^e(c,this.masking[15],this.rotate[15]),h=o,o=c,c=h^s(c,this.masking[14],this.rotate[14]),h=o,o=c,c=h^n(c,this.masking[13],this.rotate[13]),h=o,o=c,c=h^e(c,this.masking[12],this.rotate[12]),h=o,o=c,c=h^s(c,this.masking[11],this.rotate[11]),h=o,o=c,c=h^n(c,this.masking[10],this.rotate[10]),h=o,o=c,c=h^e(c,this.masking[9],this.rotate[9]),h=o,o=c,c=h^s(c,this.masking[8],this.rotate[8]),h=o,o=c,c=h^n(c,this.masking[7],this.rotate[7]),h=o,o=c,c=h^e(c,this.masking[6],this.rotate[6]),h=o,o=c,c=h^s(c,this.masking[5],this.rotate[5]),h=o,o=c,c=h^n(c,this.masking[4],this.rotate[4]),h=o,o=c,c=h^e(c,this.masking[3],this.rotate[3]),h=o,o=c,c=h^s(c,this.masking[2],this.rotate[2]),h=o,o=c,c=h^n(c,this.masking[1],this.rotate[1]),h=o,o=c,c=h^e(c,this.masking[0],this.rotate[0]),h=o,i[r]=c>>>24&255,i[r+1]=c>>>16&255,i[r+2]=c>>>8&255,i[r+3]=255&c,i[r+4]=h>>>24&255,i[r+5]=h>>16&255,i[r+6]=h>>8&255,i[r+7]=255&h}return i};const t=[,,,,];t[0]=[,,,,],t[0][0]=[4,0,13,15,12,14,8],t[0][1]=[5,2,16,18,17,19,10],t[0][2]=[6,3,23,22,21,20,9],t[0][3]=[7,1,26,25,27,24,11],t[1]=[,,,,],t[1][0]=[0,6,21,23,20,22,16],t[1][1]=[1,4,0,2,1,3,18],t[1][2]=[2,5,7,6,5,4,17],t[1][3]=[3,7,10,9,11,8,19],t[2]=[,,,,],t[2][0]=[4,0,13,15,12,14,8],t[2][1]=[5,2,16,18,17,19,10],t[2][2]=[6,3,23,22,21,20,9],t[2][3]=[7,1,26,25,27,24,11],t[3]=[,,,,],t[3][0]=[0,6,21,23,20,22,16],t[3][1]=[1,4,0,2,1,3,18],t[3][2]=[2,5,7,6,5,4,17],t[3][3]=[3,7,10,9,11,8,19];const i=[,,,,];function e(t,i,e){const n=i+t,s=n<<e|n>>>32-e;return(r[0][s>>>24]^r[1][s>>>16&255])-r[2][s>>>8&255]+r[3][255&s]}function n(t,i,e){const n=i^t,s=n<<e|n>>>32-e;return r[0][s>>>24]-r[1][s>>>16&255]+r[2][s>>>8&255]^r[3][255&s]}function s(t,i,e){const n=i-t,s=n<<e|n>>>32-e;return(r[0][s>>>24]+r[1][s>>>16&255]^r[2][s>>>8&255])-r[3][255&s]}i[0]=[,,,,],i[0][0]=[24,25,23,22,18],i[0][1]=[26,27,21,20,22],i[0][2]=[28,29,19,18,25],i[0][3]=[30,31,17,16,28],i[1]=[,,,,],i[1][0]=[3,2,12,13,8],i[1][1]=[1,0,14,15,13],i[1][2]=[7,6,8,9,3],i[1][3]=[5,4,10,11,7],i[2]=[,,,,],i[2][0]=[19,18,28,29,25],i[2][1]=[17,16,30,31,28],i[2][2]=[23,22,24,25,18],i[2][3]=[21,20,26,27,22],i[3]=[,,,,],i[3][0]=[8,9,7,6,3],i[3][1]=[10,11,5,4,7],i[3][2]=[12,13,3,2,8],i[3][3]=[14,15,1,0,13],this.keySchedule=function(e){const n=[,,,,,,,,],s=Array(32);let o;for(let t=0;t<4;t++)o=4*t,n[t]=e[o]<<24|e[o+1]<<16|e[o+2]<<8|e[o+3];const h=[6,7,4,5];let c,a=0;for(let e=0;e<2;e++)for(let e=0;e<4;e++){for(o=0;o<4;o++){const i=t[e][o];c=n[i[1]],c^=r[4][n[i[2]>>>2]>>>24-8*(3&i[2])&255],c^=r[5][n[i[3]>>>2]>>>24-8*(3&i[3])&255],c^=r[6][n[i[4]>>>2]>>>24-8*(3&i[4])&255],c^=r[7][n[i[5]>>>2]>>>24-8*(3&i[5])&255],c^=r[h[o]][n[i[6]>>>2]>>>24-8*(3&i[6])&255],n[i[0]]=c}for(o=0;o<4;o++){const t=i[e][o];c=r[4][n[t[0]>>>2]>>>24-8*(3&t[0])&255],c^=r[5][n[t[1]>>>2]>>>24-8*(3&t[1])&255],c^=r[6][n[t[2]>>>2]>>>24-8*(3&t[2])&255],c^=r[7][n[t[3]>>>2]>>>24-8*(3&t[3])&255],c^=r[4+o][n[t[4]>>>2]>>>24-8*(3&t[4])&255],s[a]=c,a++}}for(let t=0;t<16;t++)this.masking[t]=s[t],this.rotate[t]=31&s[16+t]};const r=[,,,,,,,,];r[0]=[821772500,2678128395,1810681135,1059425402,505495343,2617265619,1610868032,3483355465,3218386727,2294005173,3791863952,2563806837,1852023008,365126098,3269944861,584384398,677919599,3229601881,4280515016,2002735330,1136869587,3744433750,2289869850,2731719981,2714362070,879511577,1639411079,575934255,717107937,2857637483,576097850,2731753936,1725645e3,2810460463,5111599,767152862,2543075244,1251459544,1383482551,3052681127,3089939183,3612463449,1878520045,1510570527,2189125840,2431448366,582008916,3163445557,1265446783,1354458274,3529918736,3202711853,3073581712,3912963487,3029263377,1275016285,4249207360,2905708351,3304509486,1442611557,3585198765,2712415662,2731849581,3248163920,2283946226,208555832,2766454743,1331405426,1447828783,3315356441,3108627284,2957404670,2981538698,3339933917,1669711173,286233437,1465092821,1782121619,3862771680,710211251,980974943,1651941557,430374111,2051154026,704238805,4128970897,3144820574,2857402727,948965521,3333752299,2227686284,718756367,2269778983,2731643755,718440111,2857816721,3616097120,1113355533,2478022182,410092745,1811985197,1944238868,2696854588,1415722873,1682284203,1060277122,1998114690,1503841958,82706478,2315155686,1068173648,845149890,2167947013,1768146376,1993038550,3566826697,3390574031,940016341,3355073782,2328040721,904371731,1205506512,4094660742,2816623006,825647681,85914773,2857843460,1249926541,1417871568,3287612,3211054559,3126306446,1975924523,1353700161,2814456437,2438597621,1800716203,722146342,2873936343,1151126914,4160483941,2877670899,458611604,2866078500,3483680063,770352098,2652916994,3367839148,3940505011,3585973912,3809620402,718646636,2504206814,2914927912,3631288169,2857486607,2860018678,575749918,2857478043,718488780,2069512688,3548183469,453416197,1106044049,3032691430,52586708,3378514636,3459808877,3211506028,1785789304,218356169,3571399134,3759170522,1194783844,1523787992,3007827094,1975193539,2555452411,1341901877,3045838698,3776907964,3217423946,2802510864,2889438986,1057244207,1636348243,3761863214,1462225785,2632663439,481089165,718503062,24497053,3332243209,3344655856,3655024856,3960371065,1195698900,2971415156,3710176158,2115785917,4027663609,3525578417,2524296189,2745972565,3564906415,1372086093,1452307862,2780501478,1476592880,3389271281,18495466,2378148571,901398090,891748256,3279637769,3157290713,2560960102,1447622437,4284372637,216884176,2086908623,1879786977,3588903153,2242455666,2938092967,3559082096,2810645491,758861177,1121993112,215018983,642190776,4169236812,1196255959,2081185372,3508738393,941322904,4124243163,2877523539,1848581667,2205260958,3180453958,2589345134,3694731276,550028657,2519456284,3789985535,2973870856,2093648313,443148163,46942275,2734146937,1117713533,1115362972,1523183689,3717140224,1551984063],r[1]=[522195092,4010518363,1776537470,960447360,4267822970,4005896314,1435016340,1929119313,2913464185,1310552629,3579470798,3724818106,2579771631,1594623892,417127293,2715217907,2696228731,1508390405,3994398868,3925858569,3695444102,4019471449,3129199795,3770928635,3520741761,990456497,4187484609,2783367035,21106139,3840405339,631373633,3783325702,532942976,396095098,3548038825,4267192484,2564721535,2011709262,2039648873,620404603,3776170075,2898526339,3612357925,4159332703,1645490516,223693667,1567101217,3362177881,1029951347,3470931136,3570957959,1550265121,119497089,972513919,907948164,3840628539,1613718692,3594177948,465323573,2659255085,654439692,2575596212,2699288441,3127702412,277098644,624404830,4100943870,2717858591,546110314,2403699828,3655377447,1321679412,4236791657,1045293279,4010672264,895050893,2319792268,494945126,1914543101,2777056443,3894764339,2219737618,311263384,4275257268,3458730721,669096869,3584475730,3835122877,3319158237,3949359204,2005142349,2713102337,2228954793,3769984788,569394103,3855636576,1425027204,108000370,2736431443,3671869269,3043122623,1750473702,2211081108,762237499,3972989403,2798899386,3061857628,2943854345,867476300,964413654,1591880597,1594774276,2179821409,552026980,3026064248,3726140315,2283577634,3110545105,2152310760,582474363,1582640421,1383256631,2043843868,3322775884,1217180674,463797851,2763038571,480777679,2718707717,2289164131,3118346187,214354409,200212307,3810608407,3025414197,2674075964,3997296425,1847405948,1342460550,510035443,4080271814,815934613,833030224,1620250387,1945732119,2703661145,3966000196,1388869545,3456054182,2687178561,2092620194,562037615,1356438536,3409922145,3261847397,1688467115,2150901366,631725691,3840332284,549916902,3455104640,394546491,837744717,2114462948,751520235,2221554606,2415360136,3999097078,2063029875,803036379,2702586305,821456707,3019566164,360699898,4018502092,3511869016,3677355358,2402471449,812317050,49299192,2570164949,3259169295,2816732080,3331213574,3101303564,2156015656,3705598920,3546263921,143268808,3200304480,1638124008,3165189453,3341807610,578956953,2193977524,3638120073,2333881532,807278310,658237817,2969561766,1641658566,11683945,3086995007,148645947,1138423386,4158756760,1981396783,2401016740,3699783584,380097457,2680394679,2803068651,3334260286,441530178,4016580796,1375954390,761952171,891809099,2183123478,157052462,3683840763,1592404427,341349109,2438483839,1417898363,644327628,2233032776,2353769706,2201510100,220455161,1815641738,182899273,2995019788,3627381533,3702638151,2890684138,1052606899,588164016,1681439879,4038439418,2405343923,4229449282,167996282,1336969661,1688053129,2739224926,1543734051,1046297529,1138201970,2121126012,115334942,1819067631,1902159161,1941945968,2206692869,1159982321],r[2]=[2381300288,637164959,3952098751,3893414151,1197506559,916448331,2350892612,2932787856,3199334847,4009478890,3905886544,1373570990,2450425862,4037870920,3778841987,2456817877,286293407,124026297,3001279700,1028597854,3115296800,4208886496,2691114635,2188540206,1430237888,1218109995,3572471700,308166588,570424558,2187009021,2455094765,307733056,1310360322,3135275007,1384269543,2388071438,863238079,2359263624,2801553128,3380786597,2831162807,1470087780,1728663345,4072488799,1090516929,532123132,2389430977,1132193179,2578464191,3051079243,1670234342,1434557849,2711078940,1241591150,3314043432,3435360113,3091448339,1812415473,2198440252,267246943,796911696,3619716990,38830015,1526438404,2806502096,374413614,2943401790,1489179520,1603809326,1920779204,168801282,260042626,2358705581,1563175598,2397674057,1356499128,2217211040,514611088,2037363785,2186468373,4022173083,2792511869,2913485016,1173701892,4200428547,3896427269,1334932762,2455136706,602925377,2835607854,1613172210,41346230,2499634548,2457437618,2188827595,41386358,4172255629,1313404830,2405527007,3801973774,2217704835,873260488,2528884354,2478092616,4012915883,2555359016,2006953883,2463913485,575479328,2218240648,2099895446,660001756,2341502190,3038761536,3888151779,3848713377,3286851934,1022894237,1620365795,3449594689,1551255054,15374395,3570825345,4249311020,4151111129,3181912732,310226346,1133119310,530038928,136043402,2476768958,3107506709,2544909567,1036173560,2367337196,1681395281,1758231547,3641649032,306774401,1575354324,3716085866,1990386196,3114533736,2455606671,1262092282,3124342505,2768229131,4210529083,1833535011,423410938,660763973,2187129978,1639812e3,3508421329,3467445492,310289298,272797111,2188552562,2456863912,310240523,677093832,1013118031,901835429,3892695601,1116285435,3036471170,1337354835,243122523,520626091,277223598,4244441197,4194248841,1766575121,594173102,316590669,742362309,3536858622,4176435350,3838792410,2501204839,1229605004,3115755532,1552908988,2312334149,979407927,3959474601,1148277331,176638793,3614686272,2083809052,40992502,1340822838,2731552767,3535757508,3560899520,1354035053,122129617,7215240,2732932949,3118912700,2718203926,2539075635,3609230695,3725561661,1928887091,2882293555,1988674909,2063640240,2491088897,1459647954,4189817080,2302804382,1113892351,2237858528,1927010603,4002880361,1856122846,1594404395,2944033133,3855189863,3474975698,1643104450,4054590833,3431086530,1730235576,2984608721,3084664418,2131803598,4178205752,267404349,1617849798,1616132681,1462223176,736725533,2327058232,551665188,2945899023,1749386277,2575514597,1611482493,674206544,2201269090,3642560800,728599968,1680547377,2620414464,1388111496,453204106,4156223445,1094905244,2754698257,2201108165,3757000246,2704524545,3922940700,3996465027],r[3]=[2645754912,532081118,2814278639,3530793624,1246723035,1689095255,2236679235,4194438865,2116582143,3859789411,157234593,2045505824,4245003587,1687664561,4083425123,605965023,672431967,1336064205,3376611392,214114848,4258466608,3232053071,489488601,605322005,3998028058,264917351,1912574028,756637694,436560991,202637054,135989450,85393697,2152923392,3896401662,2895836408,2145855233,3535335007,115294817,3147733898,1922296357,3464822751,4117858305,1037454084,2725193275,2127856640,1417604070,1148013728,1827919605,642362335,2929772533,909348033,1346338451,3547799649,297154785,1917849091,4161712827,2883604526,3968694238,1469521537,3780077382,3375584256,1763717519,136166297,4290970789,1295325189,2134727907,2798151366,1566297257,3672928234,2677174161,2672173615,965822077,2780786062,289653839,1133871874,3491843819,35685304,1068898316,418943774,672553190,642281022,2346158704,1954014401,3037126780,4079815205,2030668546,3840588673,672283427,1776201016,359975446,3750173538,555499703,2769985273,1324923,69110472,152125443,3176785106,3822147285,1340634837,798073664,1434183902,15393959,216384236,1303690150,3881221631,3711134124,3960975413,106373927,2578434224,1455997841,1801814300,1578393881,1854262133,3188178946,3258078583,2302670060,1539295533,3505142565,3078625975,2372746020,549938159,3278284284,2620926080,181285381,2865321098,3970029511,68876850,488006234,1728155692,2608167508,836007927,2435231793,919367643,3339422534,3655756360,1457871481,40520939,1380155135,797931188,234455205,2255801827,3990488299,397000196,739833055,3077865373,2871719860,4022553888,772369276,390177364,3853951029,557662966,740064294,1640166671,1699928825,3535942136,622006121,3625353122,68743880,1742502,219489963,1664179233,1577743084,1236991741,410585305,2366487942,823226535,1050371084,3426619607,3586839478,212779912,4147118561,1819446015,1911218849,530248558,3486241071,3252585495,2886188651,3410272728,2342195030,20547779,2982490058,3032363469,3631753222,312714466,1870521650,1493008054,3491686656,615382978,4103671749,2534517445,1932181,2196105170,278426614,6369430,3274544417,2913018367,697336853,2143000447,2946413531,701099306,1558357093,2805003052,3500818408,2321334417,3567135975,216290473,3591032198,23009561,1996984579,3735042806,2024298078,3739440863,569400510,2339758983,3016033873,3097871343,3639523026,3844324983,3256173865,795471839,2951117563,4101031090,4091603803,3603732598,971261452,534414648,428311343,3389027175,2844869880,694888862,1227866773,2456207019,3043454569,2614353370,3749578031,3676663836,459166190,4132644070,1794958188,51825668,2252611902,3084671440,2036672799,3436641603,1099053433,2469121526,3059204941,1323291266,2061838604,1018778475,2233344254,2553501054,334295216,3556750194,1065731521,183467730],r[4]=[2127105028,745436345,2601412319,2788391185,3093987327,500390133,1155374404,389092991,150729210,3891597772,3523549952,1935325696,716645080,946045387,2901812282,1774124410,3869435775,4039581901,3293136918,3438657920,948246080,363898952,3867875531,1286266623,1598556673,68334250,630723836,1104211938,1312863373,613332731,2377784574,1101634306,441780740,3129959883,1917973735,2510624549,3238456535,2544211978,3308894634,1299840618,4076074851,1756332096,3977027158,297047435,3790297736,2265573040,3621810518,1311375015,1667687725,47300608,3299642885,2474112369,201668394,1468347890,576830978,3594690761,3742605952,1958042578,1747032512,3558991340,1408974056,3366841779,682131401,1033214337,1545599232,4265137049,206503691,103024618,2855227313,1337551222,2428998917,2963842932,4015366655,3852247746,2796956967,3865723491,3747938335,247794022,3755824572,702416469,2434691994,397379957,851939612,2314769512,218229120,1380406772,62274761,214451378,3170103466,2276210409,3845813286,28563499,446592073,1693330814,3453727194,29968656,3093872512,220656637,2470637031,77972100,1667708854,1358280214,4064765667,2395616961,325977563,4277240721,4220025399,3605526484,3355147721,811859167,3069544926,3962126810,652502677,3075892249,4132761541,3498924215,1217549313,3250244479,3858715919,3053989961,1538642152,2279026266,2875879137,574252750,3324769229,2651358713,1758150215,141295887,2719868960,3515574750,4093007735,4194485238,1082055363,3417560400,395511885,2966884026,179534037,3646028556,3738688086,1092926436,2496269142,257381841,3772900718,1636087230,1477059743,2499234752,3811018894,2675660129,3285975680,90732309,1684827095,1150307763,1723134115,3237045386,1769919919,1240018934,815675215,750138730,2239792499,1234303040,1995484674,138143821,675421338,1145607174,1936608440,3238603024,2345230278,2105974004,323969391,779555213,3004902369,2861610098,1017501463,2098600890,2628620304,2940611490,2682542546,1171473753,3656571411,3687208071,4091869518,393037935,159126506,1662887367,1147106178,391545844,3452332695,1891500680,3016609650,1851642611,546529401,1167818917,3194020571,2848076033,3953471836,575554290,475796850,4134673196,450035699,2351251534,844027695,1080539133,86184846,1554234488,3692025454,1972511363,2018339607,1491841390,1141460869,1061690759,4244549243,2008416118,2351104703,2868147542,1598468138,722020353,1027143159,212344630,1387219594,1725294528,3745187956,2500153616,458938280,4129215917,1828119673,544571780,3503225445,2297937496,1241802790,267843827,2694610800,1397140384,1558801448,3782667683,1806446719,929573330,2234912681,400817706,616011623,4121520928,3603768725,1761550015,1968522284,4053731006,4192232858,4005120285,872482584,3140537016,3894607381,2287405443,1963876937,3663887957,1584857e3,2975024454,1833426440,4025083860],r[5]=[4143615901,749497569,1285769319,3795025788,2514159847,23610292,3974978748,844452780,3214870880,3751928557,2213566365,1676510905,448177848,3730751033,4086298418,2307502392,871450977,3222878141,4110862042,3831651966,2735270553,1310974780,2043402188,1218528103,2736035353,4274605013,2702448458,3936360550,2693061421,162023535,2827510090,687910808,23484817,3784910947,3371371616,779677500,3503626546,3473927188,4157212626,3500679282,4248902014,2466621104,3899384794,1958663117,925738300,1283408968,3669349440,1840910019,137959847,2679828185,1239142320,1315376211,1547541505,1690155329,739140458,3128809933,3933172616,3876308834,905091803,1548541325,4040461708,3095483362,144808038,451078856,676114313,2861728291,2469707347,993665471,373509091,2599041286,4025009006,4170239449,2149739950,3275793571,3749616649,2794760199,1534877388,572371878,2590613551,1753320020,3467782511,1405125690,4270405205,633333386,3026356924,3475123903,632057672,2846462855,1404951397,3882875879,3915906424,195638627,2385783745,3902872553,1233155085,3355999740,2380578713,2702246304,2144565621,3663341248,3894384975,2502479241,4248018925,3094885567,1594115437,572884632,3385116731,767645374,1331858858,1475698373,3793881790,3532746431,1321687957,619889600,1121017241,3440213920,2070816767,2833025776,1933951238,4095615791,890643334,3874130214,859025556,360630002,925594799,1764062180,3920222280,4078305929,979562269,2810700344,4087740022,1949714515,546639971,1165388173,3069891591,1495988560,922170659,1291546247,2107952832,1813327274,3406010024,3306028637,4241950635,153207855,2313154747,1608695416,1150242611,1967526857,721801357,1220138373,3691287617,3356069787,2112743302,3281662835,1111556101,1778980689,250857638,2298507990,673216130,2846488510,3207751581,3562756981,3008625920,3417367384,2198807050,529510932,3547516680,3426503187,2364944742,102533054,2294910856,1617093527,1204784762,3066581635,1019391227,1069574518,1317995090,1691889997,3661132003,510022745,3238594800,1362108837,1817929911,2184153760,805817662,1953603311,3699844737,120799444,2118332377,207536705,2282301548,4120041617,145305846,2508124933,3086745533,3261524335,1877257368,2977164480,3160454186,2503252186,4221677074,759945014,254147243,2767453419,3801518371,629083197,2471014217,907280572,3900796746,940896768,2751021123,2625262786,3161476951,3661752313,3260732218,1425318020,2977912069,1496677566,3988592072,2140652971,3126511541,3069632175,977771578,1392695845,1698528874,1411812681,1369733098,1343739227,3620887944,1142123638,67414216,3102056737,3088749194,1626167401,2546293654,3941374235,697522451,33404913,143560186,2595682037,994885535,1247667115,3859094837,2699155541,3547024625,4114935275,2968073508,3199963069,2732024527,1237921620,951448369,1898488916,1211705605,2790989240,2233243581,3598044975],r[6]=[2246066201,858518887,1714274303,3485882003,713916271,2879113490,3730835617,539548191,36158695,1298409750,419087104,1358007170,749914897,2989680476,1261868530,2995193822,2690628854,3443622377,3780124940,3796824509,2976433025,4259637129,1551479e3,512490819,1296650241,951993153,2436689437,2460458047,144139966,3136204276,310820559,3068840729,643875328,1969602020,1680088954,2185813161,3283332454,672358534,198762408,896343282,276269502,3014846926,84060815,197145886,376173866,3943890818,3813173521,3545068822,1316698879,1598252827,2633424951,1233235075,859989710,2358460855,3503838400,3409603720,1203513385,1193654839,2792018475,2060853022,207403770,1144516871,3068631394,1121114134,177607304,3785736302,326409831,1929119770,2983279095,4183308101,3474579288,3200513878,3228482096,119610148,1170376745,3378393471,3163473169,951863017,3337026068,3135789130,2907618374,1183797387,2015970143,4045674555,2182986399,2952138740,3928772205,384012900,2454997643,10178499,2879818989,2596892536,111523738,2995089006,451689641,3196290696,235406569,1441906262,3890558523,3013735005,4158569349,1644036924,376726067,1006849064,3664579700,2041234796,1021632941,1374734338,2566452058,371631263,4007144233,490221539,206551450,3140638584,1053219195,1853335209,3412429660,3562156231,735133835,1623211703,3104214392,2738312436,4096837757,3366392578,3110964274,3956598718,3196820781,2038037254,3877786376,2339753847,300912036,3766732888,2372630639,1516443558,4200396704,1574567987,4069441456,4122592016,2699739776,146372218,2748961456,2043888151,35287437,2596680554,655490400,1132482787,110692520,1031794116,2188192751,1324057718,1217253157,919197030,686247489,3261139658,1028237775,3135486431,3059715558,2460921700,986174950,2661811465,4062904701,2752986992,3709736643,367056889,1353824391,731860949,1650113154,1778481506,784341916,357075625,3608602432,1074092588,2480052770,3811426202,92751289,877911070,3600361838,1231880047,480201094,3756190983,3094495953,434011822,87971354,363687820,1717726236,1901380172,3926403882,2481662265,400339184,1490350766,2661455099,1389319756,2558787174,784598401,1983468483,30828846,3550527752,2716276238,3841122214,1765724805,1955612312,1277890269,1333098070,1564029816,2704417615,1026694237,3287671188,1260819201,3349086767,1016692350,1582273796,1073413053,1995943182,694588404,1025494639,3323872702,3551898420,4146854327,453260480,1316140391,1435673405,3038941953,3486689407,1622062951,403978347,817677117,950059133,4246079218,3278066075,1486738320,1417279718,481875527,2549965225,3933690356,760697757,1452955855,3897451437,1177426808,1702951038,4085348628,2447005172,1084371187,3516436277,3068336338,1073369276,1027665953,3284188590,1230553676,1368340146,2226246512,267243139,2274220762,4070734279,2497715176,2423353163,2504755875],r[7]=[3793104909,3151888380,2817252029,895778965,2005530807,3871412763,237245952,86829237,296341424,3851759377,3974600970,2475086196,709006108,1994621201,2972577594,937287164,3734691505,168608556,3189338153,2225080640,3139713551,3033610191,3025041904,77524477,185966941,1208824168,2344345178,1721625922,3354191921,1066374631,1927223579,1971335949,2483503697,1551748602,2881383779,2856329572,3003241482,48746954,1398218158,2050065058,313056748,4255789917,393167848,1912293076,940740642,3465845460,3091687853,2522601570,2197016661,1727764327,364383054,492521376,1291706479,3264136376,1474851438,1685747964,2575719748,1619776915,1814040067,970743798,1561002147,2925768690,2123093554,1880132620,3151188041,697884420,2550985770,2607674513,2659114323,110200136,1489731079,997519150,1378877361,3527870668,478029773,2766872923,1022481122,431258168,1112503832,897933369,2635587303,669726182,3383752315,918222264,163866573,3246985393,3776823163,114105080,1903216136,761148244,3571337562,1690750982,3166750252,1037045171,1888456500,2010454850,642736655,616092351,365016990,1185228132,4174898510,1043824992,2023083429,2241598885,3863320456,3279669087,3674716684,108438443,2132974366,830746235,606445527,4173263986,2204105912,1844756978,2532684181,4245352700,2969441100,3796921661,1335562986,4061524517,2720232303,2679424040,634407289,885462008,3294724487,3933892248,2094100220,339117932,4048830727,3202280980,1458155303,2689246273,1022871705,2464987878,3714515309,353796843,2822958815,4256850100,4052777845,551748367,618185374,3778635579,4020649912,1904685140,3069366075,2670879810,3407193292,2954511620,4058283405,2219449317,3135758300,1120655984,3447565834,1474845562,3577699062,550456716,3466908712,2043752612,881257467,869518812,2005220179,938474677,3305539448,3850417126,1315485940,3318264702,226533026,965733244,321539988,1136104718,804158748,573969341,3708209826,937399083,3290727049,2901666755,1461057207,4013193437,4066861423,3242773476,2421326174,1581322155,3028952165,786071460,3900391652,3918438532,1485433313,4023619836,3708277595,3678951060,953673138,1467089153,1930354364,1533292819,2492563023,1346121658,1685000834,1965281866,3765933717,4190206607,2052792609,3515332758,690371149,3125873887,2180283551,2903598061,3933952357,436236910,289419410,14314871,1242357089,2904507907,1616633776,2666382180,585885352,3471299210,2699507360,1432659641,277164553,3354103607,770115018,2303809295,3741942315,3177781868,2853364978,2269453327,3774259834,987383833,1290892879,225909803,1741533526,890078084,1496906255,1111072499,916028167,243534141,1252605537,2204162171,531204876,290011180,3916834213,102027703,237315147,209093447,1486785922,220223953,2758195998,4175039106,82940208,3127791296,2569425252,518464269,1353887104,3941492737,2377294467,3935040926]}function r(t){this.cast5=new s,this.cast5.setKey(t),this.encrypt=function(t){return this.cast5.encrypt(t)}}n.keySize=n.prototype.keySize=24,n.blockSize=n.prototype.blockSize=8,r.blockSize=r.prototype.blockSize=8,r.keySize=r.prototype.keySize=16;const o=4294967295;function h(t,i){return(t<<i|t>>>32-i)&o}function c(t,i){return t[i]|t[i+1]<<8|t[i+2]<<16|t[i+3]<<24}function a(t,i,e){t.splice(i,4,255&e,e>>>8&255,e>>>16&255,e>>>24&255)}function l(t,i){return t>>>8*i&255}function f(t){this.tf=function(){let t=null,i=null,e=-1,n=[],s=[[],[],[],[]];function r(t){return s[0][l(t,0)]^s[1][l(t,1)]^s[2][l(t,2)]^s[3][l(t,3)]}function f(t){return s[0][l(t,3)]^s[1][l(t,0)]^s[2][l(t,1)]^s[3][l(t,2)]}function u(t,i){let e=r(i[0]),s=f(i[1]);i[2]=h(i[2]^e+s+n[4*t+8]&o,31),i[3]=h(i[3],1)^e+2*s+n[4*t+9]&o,e=r(i[2]),s=f(i[3]),i[0]=h(i[0]^e+s+n[4*t+10]&o,31),i[1]=h(i[1],1)^e+2*s+n[4*t+11]&o}function y(t,i){let e=r(i[0]),s=f(i[1]);i[2]=h(i[2],1)^e+s+n[4*t+10]&o,i[3]=h(i[3]^e+2*s+n[4*t+11]&o,31),e=r(i[2]),s=f(i[3]),i[0]=h(i[0],1)^e+s+n[4*t+8]&o,i[1]=h(i[1]^e+2*s+n[4*t+9]&o,31)}return{name:"twofish",blocksize:16,open:function(i){let e,r,a,f,u;t=i;const y=[],p=[],k=[];let g;const m=[];let S,b,z;const d=[[8,1,7,13,6,15,3,2,0,11,5,9,14,12,10,4],[2,8,11,13,15,7,6,14,3,1,9,4,0,10,12,5]],w=[[14,12,11,8,1,2,3,5,15,4,10,6,7,0,9,13],[1,14,2,11,4,12,3,7,6,13,10,5,15,9,0,8]],A=[[11,10,5,14,6,13,9,0,12,8,15,3,2,4,7,1],[4,12,7,5,1,6,9,10,0,14,13,8,2,11,3,15]],B=[[13,7,15,4,1,2,6,14,9,11,3,0,8,5,12,10],[11,9,5,1,12,3,13,14,6,4,7,15,2,0,8,10]],N=[0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15],_=[0,9,2,11,4,13,6,15,8,1,10,3,12,5,14,7],x=[[],[]],E=[[],[],[],[]];function K(t){return t^t>>2^[0,90,180,238][3&t]}function O(t){return t^t>>1^t>>2^[0,238,180,90][3&t]}function C(t,i){let e,n,s;for(e=0;e<8;e++)n=i>>>24,i=i<<8&o|t>>>24,t=t<<8&o,s=n<<1,128&n&&(s^=333),i^=n^s<<16,s^=n>>>1,1&n&&(s^=166),i^=s<<24|s<<8;return i}function I(t,i){const e=i>>4,n=15&i,s=d[t][e^n],r=w[t][N[n]^_[e]];return B[t][N[r]^_[s]]<<4|A[t][s^r]}function L(t,i){let e=l(t,0),n=l(t,1),s=l(t,2),r=l(t,3);switch(g){case 4:e=x[1][e]^l(i[3],0),n=x[0][n]^l(i[3],1),s=x[0][s]^l(i[3],2),r=x[1][r]^l(i[3],3);case 3:e=x[1][e]^l(i[2],0),n=x[1][n]^l(i[2],1),s=x[0][s]^l(i[2],2),r=x[0][r]^l(i[2],3);case 2:e=x[0][x[0][e]^l(i[1],0)]^l(i[0],0),n=x[0][x[1][n]^l(i[1],1)]^l(i[0],1),s=x[1][x[0][s]^l(i[1],2)]^l(i[0],2),r=x[1][x[1][r]^l(i[1],3)]^l(i[0],3)}return E[0][e]^E[1][n]^E[2][s]^E[3][r]}for(t=t.slice(0,32),e=t.length;16!==e&&24!==e&&32!==e;)t[e++]=0;for(e=0;e<t.length;e+=4)k[e>>2]=c(t,e);for(e=0;e<256;e++)x[0][e]=I(0,e),x[1][e]=I(1,e);for(e=0;e<256;e++)S=x[1][e],b=K(S),z=O(S),E[0][e]=S+(b<<8)+(z<<16)+(z<<24),E[2][e]=b+(z<<8)+(S<<16)+(z<<24),S=x[0][e],b=K(S),z=O(S),E[1][e]=z+(z<<8)+(b<<16)+(S<<24),E[3][e]=b+(S<<8)+(z<<16)+(b<<24);for(g=k.length/2,e=0;e<g;e++)r=k[e+e],y[e]=r,a=k[e+e+1],p[e]=a,m[g-e-1]=C(r,a);for(e=0;e<40;e+=2)r=16843009*e,a=r+16843009,r=L(r,y),a=h(L(a,p),8),n[e]=r+a&o,n[e+1]=h(r+2*a,9);for(e=0;e<256;e++)switch(r=a=f=u=e,g){case 4:r=x[1][r]^l(m[3],0),a=x[0][a]^l(m[3],1),f=x[0][f]^l(m[3],2),u=x[1][u]^l(m[3],3);case 3:r=x[1][r]^l(m[2],0),a=x[1][a]^l(m[2],1),f=x[0][f]^l(m[2],2),u=x[0][u]^l(m[2],3);case 2:s[0][e]=E[0][x[0][x[0][r]^l(m[1],0)]^l(m[0],0)],s[1][e]=E[1][x[0][x[1][a]^l(m[1],1)]^l(m[0],1)],s[2][e]=E[2][x[1][x[0][f]^l(m[1],2)]^l(m[0],2)],s[3][e]=E[3][x[1][x[1][u]^l(m[1],3)]^l(m[0],3)]}},close:function(){n=[],s=[[],[],[],[]]},encrypt:function(t,s){i=t,e=s;const r=[c(i,e)^n[0],c(i,e+4)^n[1],c(i,e+8)^n[2],c(i,e+12)^n[3]];for(let t=0;t<8;t++)u(t,r);return a(i,e,r[2]^n[4]),a(i,e+4,r[3]^n[5]),a(i,e+8,r[0]^n[6]),a(i,e+12,r[1]^n[7]),e+=16,i},decrypt:function(t,s){i=t,e=s;const r=[c(i,e)^n[4],c(i,e+4)^n[5],c(i,e+8)^n[6],c(i,e+12)^n[7]];for(let t=7;t>=0;t--)y(t,r);a(i,e,r[2]^n[0]),a(i,e+4,r[3]^n[1]),a(i,e+8,r[0]^n[2]),a(i,e+12,r[1]^n[3]),e+=16},finalize:function(){return i}}}(),this.tf.open(Array.from(t),0),this.encrypt=function(t){return this.tf.encrypt(Array.from(t),0)}}function u(){}function y(t){this.bf=new u,this.bf.init(t),this.encrypt=function(t){return this.bf.encryptBlock(t)}}f.keySize=f.prototype.keySize=32,f.blockSize=f.prototype.blockSize=16,u.prototype.BLOCKSIZE=8,u.prototype.SBOXES=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]],u.prototype.PARRAY=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],u.prototype.NN=16,u.prototype._clean=function(t){if(t<0){t=(2147483647&t)+2147483648}return t},u.prototype._F=function(t){let i;const e=255&t,n=255&(t>>>=8),s=255&(t>>>=8),r=255&(t>>>=8);return i=this.sboxes[0][r]+this.sboxes[1][s],i^=this.sboxes[2][n],i+=this.sboxes[3][e],i},u.prototype._encryptBlock=function(t){let i,e=t[0],n=t[1];for(i=0;i<this.NN;++i){e^=this.parray[i],n=this._F(e)^n;const t=e;e=n,n=t}e^=this.parray[this.NN+0],n^=this.parray[this.NN+1],t[0]=this._clean(n),t[1]=this._clean(e)},u.prototype.encryptBlock=function(t){let i;const e=[0,0],n=this.BLOCKSIZE/2;for(i=0;i<this.BLOCKSIZE/2;++i)e[0]=e[0]<<8|255&t[i+0],e[1]=e[1]<<8|255&t[i+n];this._encryptBlock(e);const s=[];for(i=0;i<this.BLOCKSIZE/2;++i)s[i+0]=e[0]>>>24-8*i&255,s[i+n]=e[1]>>>24-8*i&255;return s},u.prototype._decryptBlock=function(t){let i,e=t[0],n=t[1];for(i=this.NN+1;i>1;--i){e^=this.parray[i],n=this._F(e)^n;const t=e;e=n,n=t}e^=this.parray[1],n^=this.parray[0],t[0]=this._clean(n),t[1]=this._clean(e)},u.prototype.init=function(t){let i,e=0;for(this.parray=[],i=0;i<this.NN+2;++i){let n=0;for(let i=0;i<4;++i)n=n<<8|255&t[e],++e>=t.length&&(e=0);this.parray[i]=this.PARRAY[i]^n}for(this.sboxes=[],i=0;i<4;++i)for(this.sboxes[i]=[],e=0;e<256;++e)this.sboxes[i][e]=this.SBOXES[i][e];const n=[0,0];for(i=0;i<this.NN+2;i+=2)this._encryptBlock(n),this.parray[i+0]=n[0],this.parray[i+1]=n[1];for(i=0;i<4;++i)for(e=0;e<256;e+=2)this._encryptBlock(n),this.sboxes[i][e+0]=n[0],this.sboxes[i][e+1]=n[1]},y.keySize=y.prototype.keySize=16,y.blockSize=y.prototype.blockSize=8;const p=new Map([[t.symmetric.tripledes,n],[t.symmetric.cast5,r],[t.symmetric.blowfish,y],[t.symmetric.twofish,f]]);export{p as legacyCiphers};
|
|
3
3
|
//# sourceMappingURL=legacy_ciphers.min.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.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
2
|
const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3
3
|
|
|
4
4
|
import { enums } from './openpgp.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.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
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
3
|
//# sourceMappingURL=native.interface.min.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.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
2
|
const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3
3
|
|
|
4
4
|
import { B as BigInteger } from './interface.mjs';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.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
2
|
"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;import{H as e,h as t,t as n,e as r,b as f,c as i,r as o,s,a,d as c,w as u,u as d,f as l}from"./sha3.min.mjs";import{B as h}from"./interface.min.mjs";import"./native.interface.min.mjs";import"./bn.interface.min.mjs";class b extends e{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,t(e);const f=n(r);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(f.length>i?e.create().update(f).digest():f);for(let e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),o.fill(0)}update(e){return r(this),this.iHash.update(e),this}digestInto(e){r(this),f(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:f,blockLen:i,outputLen:o}=this;return e.finished=r,e.destroyed=f,e.blockLen=i,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const m=(e,t,n)=>new b(e,t).update(n).digest();m.create=(e,t)=>new b(e,t)
|
|
3
3
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const w=Object.freeze(h.new(2));function y(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}const p=/* @__PURE__ */Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function g(e){if(!y(e))throw Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=p[e[n]];return t}function E(e){const t=e instanceof h?g(e.toUint8Array()):e.toString(16);return 1&t.length?"0"+t:t}const x={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function B(e){return e>=x._0&&e<=x._9?e-x._0:e>=x._A&&e<=x._F?e-(x._A-10):e>=x._a&&e<=x._f?e-(x._a-10):void 0}function S(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,f=0;t<n;t++,f+=2){const n=B(e.charCodeAt(f)),i=B(e.charCodeAt(f+1));if(void 0===n||void 0===i){const t=e[f]+e[f+1];throw Error('hex string expected, got non-hex character "'+t+'" at index '+f)}r[t]=16*n+i}return r}function v(e){return h.new(e)}function O(e){if(!y(e))throw Error("Uint8Array expected");return h.new(e.slice().reverse())}function A(e,t){return e.toUint8Array("be",t)}function z(e,t){return e.toUint8Array("le",t)}function q(e,t,n){let r;if("string"==typeof t)try{r=S(t)}catch(n){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!y(t))throw Error(e+" must be hex string or Uint8Array");r=new Uint8Array(t)}const f=r.length;if("number"==typeof n&&f!==n)throw Error(`${e} expected ${n} bytes, got ${f}`);return r}function R(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(!y(r))throw Error("Uint8Array expected");t+=r.length}let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++){const f=e[t];n.set(f,r),r+=f.length}return n}const j=e=>w.leftShift(h.new(e-1)).idec(),N=e=>new Uint8Array(e),P=e=>Uint8Array.from(e);function I(e,t,n){if("number"!=typeof e||e<2)throw Error("hashLen must be a number");if("number"!=typeof t||t<2)throw Error("qByteLen must be a number");if("function"!=typeof n)throw Error("hmacFn must be a function");let r=N(e),f=N(e),i=0;const o=()=>{r.fill(1),f.fill(0),i=0},s=(...e)=>n(f,r,...e),a=(e=N())=>{f=s(P([0]),e),r=s(),0!==e.length&&(f=s(P([1]),e),r=s())},c=()=>{if(i++>=1e3)throw Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=s();const t=r.slice();n.push(t),e+=r.length}return R(...n)};return(e,t)=>{let n;for(o(),a(e);!(n=t(c()));)a();return o(),n}}const L={BigInteger:e=>e instanceof h,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||y(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function Z(e,t,n={}){const r=(t,n,r)=>{const f=L[n];if("function"!=typeof f)throw Error(`Invalid validator "${n}", expected function`);const i=e[t];if(!(r&&void 0===i||f(i,e)))throw Error(`Invalid param ${t+""}=${i} (${typeof i}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var H=/*#__PURE__*/Object.freeze({__proto__:null,bitGet:(e,t)=>e.getBit(t),bitLen:function(e){return e.bitLength()},bitMask:j,bitSet:(e,t,n)=>{throw Error("unsupported bitSet")},bytesToHex:g,bytesToNumberBE:v,bytesToNumberLE:O,concatBytes:R,createHmacDrbg:I,ensureBytes:q,equalBytes:function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},hexToBytes:S,hexToNumber:function(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);return h.new(""===e?"0":"0x"+e)},isBytes:y,numberToBytesBE:A,numberToBytesLE:z,numberToHexUnpadded:E,numberToVarBytesBE:function(e){return S(E(e))},utf8ToBytes:function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},validateObject:Z});
|
|
4
4
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const T=Object.freeze(h.new(0)),U=Object.freeze(h.new(1)),F=Object.freeze(h.new(2)),_=Object.freeze(h.new(3)),G=Object.freeze(h.new(4)),k=Object.freeze(h.new(5)),C=Object.freeze(h.new(8)),$=Object.freeze(h.new(9)),V=Object.freeze(h.new(16));function K(e,t){return e.mod(t)}function D(e,t,n){return e.modExp(t,n)}function Y(e,t,n){return e.modExp(F.leftShift(t.dec()),n)}function W(e,t){return e.modInv(t)}function M(e){if(e.mod(G).equal(_)){const t=e.add(U).irightShift(F);return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error("Cannot find square root");return r}}if(e.mod(C).equal(k)){const t=e.sub(k).irightShift(_);return function(e,n){const r=e.mul(n,F),f=e.pow(r,t),i=e.mul(n,f),o=e.mul(e.mul(i,F),f),s=e.mul(i,e.sub(o,e.ONE));if(!e.eql(e.sqr(s),n))throw Error("Cannot find square root");return s}}return e.mod(V).equal($),function(e){const t=e.dec().rightShift(U);let n=e.dec(),r=h.new(0);for(;n.isEven();)n.irightShift(U),r.iinc();let f=h.new(2);const i=e.dec();for(;f.lt(e)&&!D(f,t,e).equal(i);)f.iinc();if(r.isOne()){const t=e.inc().irightShift(F);return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error("Cannot find square root");return r}}const o=n.inc().irightShift(U);return function(e,i){if(e.eql(e.pow(i,t),e.neg(e.ONE)))throw Error("Cannot find square root");let s=r,a=e.pow(e.mul(e.ONE,f),n),c=e.pow(i,o),u=e.pow(i,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=h.new(1);for(let n=e.sqr(u);t.lt(s)&&!e.eql(n,e.ONE);t.iinc())n=e.sqr(n);const n=e.pow(a,U.leftShift(s.sub(t).idec()));a=e.sqr(n),c=e.mul(c,n),u=e.mul(u,a),s=t}return c}}(e)}const J=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Q(e,t){const n=void 0!==t?t:e.bitLength();return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function X(e,t,n=!1,r={}){if(e.lte(T))throw Error("Expected Field ORDER > 0, got "+e);const{nBitLength:f,nByteLength:i}=Q(e,t);if(i>2048)throw Error("Field lengths over 2048 bytes are not supported");const o=M(e),s=Object.freeze({ORDER:e,BITS:f,BYTES:i,MASK:j(f),ZERO:T,ONE:U,create:t=>K(t,e),isValid:t=>{if(!(t instanceof h))throw Error("Invalid field element: expected bigint, got "+typeof t);return T.lte(t)&&t.lt(e)},is0:e=>e.isZero(),isOdd:e=>!e.isEven(),neg:t=>K(t.negate(),e),eql:(e,t)=>e.equal(t),sqr:t=>K(t.mul(t),e),add:(t,n)=>K(t.add(n),e),sub:(t,n)=>K(t.sub(n),e),mul:(t,n)=>K(t.mul(n),e),pow:(e,t)=>function(e,t,n){if(n.isNegative())throw Error("Expected power > 0");if(n.isZero())return e.ONE;if(n.isOne())return t;let r=e.ONE,f=t;for(;n.gt(T);)n.isEven()||(r=e.mul(r,f)),f=e.sqr(f),n=n.rightShift(U);return r}(s,e,t),div:(t,n)=>K(t.mul(W(n,e)),e),sqrN:e=>e.mul(e),addN:(e,t)=>e.add(t),subN:(e,t)=>e.sub(t),mulN:(e,t)=>e.mul(t),inv:t=>W(t,e),sqrt:r.sqrt||(e=>o(s,e)),invertBatch:e=>function(e,t){const n=Array(t.length),r=t.reduce(((t,r,f)=>e.is0(r)?t:(n[f]=t,e.mul(t,r))),e.ONE),f=e.inv(r);return t.reduceRight(((t,r,f)=>e.is0(r)?t:(n[f]=e.mul(t,n[f]),e.mul(t,r))),f),n}(s,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?z(e,i):A(e,i),fromBytes:e=>{if(e.length!==i)throw Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?O(e):v(e)}});return Object.freeze(s)}function ee(e){if(!(e instanceof h))throw Error("field order must be bigint");return e.byteLength()}function te(e){const t=ee(e);return t+Math.ceil(t/2)}
|
|
5
5
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
6
6
|
const ne=Object.freeze(h.new(0)),re=Object.freeze(h.new(1));function fe(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){const r=n.clone();let f=e.ZERO,i=t;for(;r.gt(ne);)r.isEven()||(f=f.add(i)),i=i.double(),r.irightShift(re);return f},precomputeWindow(e,t){const{windows:n,windowSize:f}=r(t),i=[];let o=e,s=o;for(let e=0;e<n;e++){s=o,i.push(s);for(let e=1;e<f;e++)s=s.add(o),i.push(s);o=s.double()}return i},wNAF(t,f,i){const o=i.clone(),{windows:s,windowSize:a}=r(t);let c=e.ZERO,u=e.BASE;const d=h.new(2**t-1),l=2**t,b=h.new(t);for(let e=0;e<s;e++){const t=e*a;let r=o.bitwiseAnd(d).toNumber();o.irightShift(b),r>a&&(r-=l,o.iinc());const i=t,s=t+Math.abs(r)-1,h=e%2!=0,m=r<0;0===r?u=u.add(n(h,f[i])):c=c.add(n(m,f[s]))}return{p:c,f:u}},wNAFCached(e,t,n,r){const f=e._WINDOW_SIZE||1;let i=t.get(e);return i||(i=this.precomputeWindow(e,f),1!==f&&t.set(e,r(i))),this.wNAF(f,i,n)}}}function ie(e){return Z(e.Fp,J.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"BigInteger",MASK:"BigInteger",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Z(e,{n:"BigInteger",h:"BigInteger",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Q(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
|
|
7
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:oe,hexToBytes:se}=H,ae={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=ae;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:oe(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=ae,n="string"==typeof e?se(e):e;if(!y(n))throw Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:f,l:i}=ae._parseInt(n.subarray(2)),{d:o,l:s}=ae._parseInt(i);if(s.length)throw new t("Invalid signature: left bytes after parsing");return{r:f,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e instanceof h?g(e.toUint8Array()):e.toString(16);return 1&t.length?"0"+t:t},r=t(n(e.s)),f=t(n(e.r)),i=r.length/2,o=f.length/2,s=n(i),a=n(o);return`30${n(o+i+4)}02${a}${f}02${s}${r}`}},ce=Object.freeze(h.new(0)),ue=Object.freeze(h.new(1));Object.freeze(h.new(2));const de=Object.freeze(h.new(3));function le(e){const t=function(e){const t=ie(e);Z(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:f}=t;if(n){if(!r.eql(f,r.ZERO))throw Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||!(n.beta instanceof h)||"function"!=typeof n.splitScalar)throw Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const f=t.toAffine();return R(Uint8Array.from([4]),n.toBytes(f.x),n.toBytes(f.y))}),f=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function i(e){const{a:r,b:f}=t,i=n.sqr(e),o=n.mul(i,e);return n.add(n.add(o,n.mul(e,r)),f)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw Error("bad generator point: equation left != right");function o(e){return e instanceof h&&ce.lt(e)&&e.lt(t.n)}function s(e){if(!o(e))throw Error("Expected valid bigint: 0 < bigint < curve.n")}function a(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:f,n:i}=t;if(n&&!(e instanceof h)){if(y(e)&&(e=g(e)),"string"!=typeof e||!n.includes(e.length))throw Error("Invalid key");e=e.padStart(2*r,"0")}let o;try{o=e instanceof h?e:v(q("private key",e,r))}catch(t){throw Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return f&&(o=K(o,i)),s(o),o}const c=new Map;function u(e){if(!(e instanceof d))throw Error("ProjectivePoint expected")}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw Error("x required");if(null==t||!n.isValid(t))throw Error("y required");if(null==r||!n.isValid(r))throw Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw Error("invalid affine point");if(e instanceof d)throw Error("projective point not allowed");const f=e=>n.eql(e,n.ZERO);return f(t)&&f(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(f(q("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(a(e))}_setWindowSize(e){this._WINDOW_SIZE=e,c.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw Error("bad point: x or y not FE");const f=n.sqr(r),o=i(e);if(!n.eql(f,o))throw Error("bad point: equation left != right");if(!this.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw Error("Field doesn't support isOdd")}equals(e){u(e);const{px:t,py:r,pz:f}=this,{px:i,py:o,pz:s}=e,a=n.eql(n.mul(t,s),n.mul(i,f)),c=n.eql(n.mul(r,s),n.mul(o,f));return a&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,f=n.mul(r,de),{px:i,py:o,pz:s}=this;let a=n.ZERO,c=n.ZERO,u=n.ZERO,l=n.mul(i,i),h=n.mul(o,o),b=n.mul(s,s),m=n.mul(i,o);return m=n.add(m,m),u=n.mul(i,s),u=n.add(u,u),a=n.mul(e,u),c=n.mul(f,b),c=n.add(a,c),a=n.sub(h,c),c=n.add(h,c),c=n.mul(a,c),a=n.mul(m,a),u=n.mul(f,u),b=n.mul(e,b),m=n.sub(l,b),m=n.mul(e,m),m=n.add(m,u),u=n.add(l,l),l=n.add(u,l),l=n.add(l,b),l=n.mul(l,m),c=n.add(c,l),b=n.mul(o,s),b=n.add(b,b),l=n.mul(b,m),a=n.sub(a,l),u=n.mul(b,h),u=n.add(u,u),u=n.add(u,u),new d(a,c,u)}add(e){u(e);const{px:r,py:f,pz:i}=this,{px:o,py:s,pz:a}=e;let c=n.ZERO,l=n.ZERO,h=n.ZERO;const b=t.a,m=n.mul(t.b,de);let w=n.mul(r,o),y=n.mul(f,s),p=n.mul(i,a),g=n.add(r,f),E=n.add(o,s);g=n.mul(g,E),E=n.add(w,y),g=n.sub(g,E),E=n.add(r,i);let x=n.add(o,a);return E=n.mul(E,x),x=n.add(w,p),E=n.sub(E,x),x=n.add(f,i),c=n.add(s,a),x=n.mul(x,c),c=n.add(y,p),x=n.sub(x,c),h=n.mul(b,E),c=n.mul(m,p),h=n.add(c,h),c=n.sub(y,h),h=n.add(y,h),l=n.mul(c,h),y=n.add(w,w),y=n.add(y,w),p=n.mul(b,p),E=n.mul(m,E),y=n.add(y,p),p=n.sub(w,p),p=n.mul(b,p),E=n.add(E,p),w=n.mul(y,E),l=n.add(l,w),w=n.mul(x,E),c=n.mul(g,c),c=n.sub(c,w),w=n.mul(g,y),h=n.mul(x,h),h=n.add(h,w),new d(c,l,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return b.wNAFCached(this,c,e,(e=>{const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(d.fromAffine)}))}multiplyUnsafe(e){const r=d.ZERO;if(e.isZero())return r;if(s(e),e.isOne())return this;const{endo:f}=t;if(!f)return b.unsafeLadder(this,e);let{k1neg:i,k1:o,k2neg:a,k2:c}=f.splitScalar(e),u=r,l=r,h=this;for(;o.gt(ce)||c.gt(ce);)o.isEven()||(u=u.add(h)),c.isEven()||(l=l.add(h)),h=h.double(),o=o.rightShift(ue),c=c.rightShift(ue);return i&&(u=u.negate()),a&&(l=l.negate()),l=new d(n.mul(l.px,f.beta),l.py,l.pz),u.add(l)}multiply(e){s(e);let r,f,i=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:s,k2:a}=o.splitScalar(i);let{p:c,f:u}=this.wNAF(t),{p:l,f:h}=this.wNAF(a);c=b.constTimeNegate(e,c),l=b.constTimeNegate(s,l),l=new d(n.mul(l.px,o.beta),l.py,l.pz),r=c.add(l),f=u.add(h)}else{const{p:e,f:t}=this.wNAF(i);r=e,f=t}return d.normalizeZ([r,f])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,f=(e,t)=>t.isZero()||t.isOne()||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),i=f(this,t).add(f(e,n));return i.is0()?void 0:i}toAffine(e){const{px:t,py:r,pz:f}=this,i=this.is0();null==e&&(e=i?n.ONE:n.inv(f));const o=n.mul(t,e),s=n.mul(r,e),a=n.mul(f,e);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(a,n.ONE))throw Error("invZ was invalid");return{x:o,y:s}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e.isOne())return!0;if(n)return n(d,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e.isOne()?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return g(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const l=t.nBitLength,b=fe(d,t.endo?Math.ceil(l/2):l);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:o}}function he(e){const t=function(e){const t=ie(e);return Z(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r}=t,f=n.BYTES+1,i=2*n.BYTES+1;function o(e){return K(e,r)}function s(e){return W(e,r)}const{ProjectivePoint:a,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=le({...t,toBytes(e,t,r){const f=t.toAffine(),i=n.toBytes(f.x),o=R;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),i):o(Uint8Array.from([4]),i,n.toBytes(f.y))},fromBytes(e){const t=e.length,r=e[0],o=e.subarray(1);if(t!==f||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw Error(`Point of length ${t} was invalid. Expected ${f} compressed bytes or ${i} uncompressed bytes`)}{const e=v(o);if(s=e,!ce.lt(s)||!s.lt(n.ORDER))throw Error("Point is not on curve");const t=u(e);let f=n.sqrt(t);return 1==(1&r)!==!f.isEven()&&(f=n.neg(f)),{x:e,y:f}}var s}}),l=e=>g(A(e,t.nByteLength));function b(e){const t=r.rightShift(ue);return e.gt(t)}const m=(e,t,n)=>v(e.slice(t,n));class w{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=q("compactSignature",e,2*n),new w(m(e,0,n),m(e,n,2*n))}static fromDER(e){const{r:t,s:n}=ae.toSig(q("DER",e));return new w(t,n)}assertValidity(){if(!d(this.r))throw Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(e){const{r,s:f,recovery:i}=this,c=B(q("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw Error("recovery id invalid");const u=2===i||3===i?r.add(t.n):r;if(u.gte(n.ORDER))throw Error("recovery id 2 or 3 invalid");const d=0==(1&i)?"02":"03",h=a.fromHex(d+l(u)),b=s(u),m=o(c.negate().imul(b)),w=o(f.mul(b)),y=a.BASE.multiplyAndAddUnsafe(h,m,w);if(!y)throw Error("point at infinify");return y.assertValidity(),y}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,o(this.s.negate()),this.recovery):this}toDERRawBytes(){return S(this.toDERHex())}toDERHex(){return ae.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return S(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}const p={isValidPrivateKey(e){try{return c(e),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const e=te(t.n);return function(e,t,n=!1){const r=e.length,f=ee(t),i=te(t);if(r<16||r<i||r>1024)throw Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=K(n?v(e):O(e),t.dec()).inc();return n?z(o,f):A(o,f)}(t.randomBytes(e),t.n)},precompute:(e=8,t=a.BASE)=>(t._setWindowSize(e),t.multiply(h.new(3)),t)};function E(e){const t=y(e),n="string"==typeof e,r=(t||n)&&e.length;return t?r===f||r===i:n?r===2*f||r===2*i:e instanceof a}const x=t.bits2int||function(e){const n=v(e),r=8*e.length-t.nBitLength;return r>0?n.rightShift(h.new(r)):n},B=t.bits2int_modN||function(e){return o(x(e))},N=j(t.nBitLength);function P(e){if(!(e instanceof h))throw Error("bigint expected");if(!ce.lte(e)||!e.lt(N))throw Error("bigint expected < 2^"+t.nBitLength);return A(e,t.nByteLength)}function L(e,r,f=H){if(["recovered","canonical"].some((e=>e in f)))throw Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=t;let{lowS:l,prehash:h,extraEntropy:m}=f;null==l&&(l=!0),e=q("msgHash",e),h&&(e=q("prehashed msgHash",i(e)));const y=B(e),p=c(r),g=[P(p),P(y)];if(null!=m){const e=!0===m?u(n.BYTES):m;g.push(q("extraEntropy",e))}const E=R(...g),S=y;return{seed:E,k2sig:function(e){const t=x(e);if(!d(t))return;const n=s(t),r=a.BASE.multiply(t).toAffine(),f=o(r.x);if(f.isZero())return;const i=o(n.mul(o(S.add(f.mul(p)))));if(i.isZero())return;let c=(r.x.equal(f)?0:2)|r.y.getBit(0),u=i;return l&&b(i)&&(u=function(e){return b(e)?o(e.negate()):e}(i),c^=1),new w(f,u,c)}}}const H={lowS:t.lowS,prehash:!1},T={lowS:t.lowS,prehash:!1};return a.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return a.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(E(e))throw Error("first arg must be private key");if(!E(t))throw Error("second arg must be public key");return a.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,r=H){const{seed:f,k2sig:i}=L(e,n,r),o=t;return I(o.hash.outputLen,o.nByteLength,o.hmac)(f,i)},verify:function(e,n,r,f=T){const i=e;if(n=q("msgHash",n),r=q("publicKey",r),"strict"in f)throw Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=f;let d,l;try{if("string"==typeof i||y(i))try{d=w.fromDER(i)}catch(e){if(!(e instanceof ae.Err))throw e;d=w.fromCompact(i)}else{if(!("object"==typeof i&&i.r instanceof h&&i.s instanceof h))throw Error("PARSE");{const{r:e,s:t}=i;d=new w(e,t)}}l=a.fromHex(r)}catch(e){if("PARSE"===e.message)throw Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:b,s:m}=d,p=B(n),g=s(m),E=o(p.mul(g)),x=o(b.mul(g)),S=a.BASE.multiplyAndAddUnsafe(l,E,x)?.toAffine();return!!S&&o(S.x).equal(b)},ProjectivePoint:a,Signature:w,utils:p}}
|
|
7
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:oe,hexToBytes:se}=H,ae={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=ae;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:oe(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=ae,n="string"==typeof e?se(e):e;if(!y(n))throw Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:f,l:i}=ae._parseInt(n.subarray(2)),{d:o,l:s}=ae._parseInt(i);if(s.length)throw new t("Invalid signature: left bytes after parsing");return{r:f,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e instanceof h?g(e.toUint8Array()):e.toString(16);return 1&t.length?"0"+t:t},r=t(n(e.s)),f=t(n(e.r)),i=r.length/2,o=f.length/2,s=n(i),a=n(o);return`30${n(o+i+4)}02${a}${f}02${s}${r}`}},ce=Object.freeze(h.new(0)),ue=Object.freeze(h.new(1));Object.freeze(h.new(2));const de=Object.freeze(h.new(3));function le(e){const t=function(e){const t=ie(e);Z(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:f}=t;if(n){if(!r.eql(f,r.ZERO))throw Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||!(n.beta instanceof h)||"function"!=typeof n.splitScalar)throw Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const f=t.toAffine();return R(Uint8Array.from([4]),n.toBytes(f.x),n.toBytes(f.y))}),f=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function i(e){const{a:r,b:f}=t,i=n.sqr(e),o=n.mul(i,e);return n.add(n.add(o,n.mul(e,r)),f)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw Error("bad generator point: equation left != right");function o(e){return e instanceof h&&ce.lt(e)&&e.lt(t.n)}function s(e){if(!o(e))throw Error("Expected valid bigint: 0 < bigint < curve.n")}function a(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:f,n:i}=t;if(n&&!(e instanceof h)){if(y(e)&&(e=g(e)),"string"!=typeof e||!n.includes(e.length))throw Error("Invalid key");e=e.padStart(2*r,"0")}let o;try{o=e instanceof h?e:v(q("private key",e,r))}catch(t){throw Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return f&&(o=K(o,i)),s(o),o}const c=new Map;function u(e){if(!(e instanceof d))throw Error("ProjectivePoint expected")}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw Error("x required");if(null==t||!n.isValid(t))throw Error("y required");if(null==r||!n.isValid(r))throw Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw Error("invalid affine point");if(e instanceof d)throw Error("projective point not allowed");const f=e=>n.eql(e,n.ZERO);return f(t)&&f(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(f(q("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(a(e))}_setWindowSize(e){this._WINDOW_SIZE=e,c.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw Error("bad point: x or y not FE");const f=n.sqr(r),o=i(e);if(!n.eql(f,o))throw Error("bad point: equation left != right");if(!this.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw Error("Field doesn't support isOdd")}equals(e){u(e);const{px:t,py:r,pz:f}=this,{px:i,py:o,pz:s}=e,a=n.eql(n.mul(t,s),n.mul(i,f)),c=n.eql(n.mul(r,s),n.mul(o,f));return a&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,f=n.mul(r,de),{px:i,py:o,pz:s}=this;let a=n.ZERO,c=n.ZERO,u=n.ZERO,l=n.mul(i,i),h=n.mul(o,o),b=n.mul(s,s),m=n.mul(i,o);return m=n.add(m,m),u=n.mul(i,s),u=n.add(u,u),a=n.mul(e,u),c=n.mul(f,b),c=n.add(a,c),a=n.sub(h,c),c=n.add(h,c),c=n.mul(a,c),a=n.mul(m,a),u=n.mul(f,u),b=n.mul(e,b),m=n.sub(l,b),m=n.mul(e,m),m=n.add(m,u),u=n.add(l,l),l=n.add(u,l),l=n.add(l,b),l=n.mul(l,m),c=n.add(c,l),b=n.mul(o,s),b=n.add(b,b),l=n.mul(b,m),a=n.sub(a,l),u=n.mul(b,h),u=n.add(u,u),u=n.add(u,u),new d(a,c,u)}add(e){u(e);const{px:r,py:f,pz:i}=this,{px:o,py:s,pz:a}=e;let c=n.ZERO,l=n.ZERO,h=n.ZERO;const b=t.a,m=n.mul(t.b,de);let w=n.mul(r,o),y=n.mul(f,s),p=n.mul(i,a),g=n.add(r,f),E=n.add(o,s);g=n.mul(g,E),E=n.add(w,y),g=n.sub(g,E),E=n.add(r,i);let x=n.add(o,a);return E=n.mul(E,x),x=n.add(w,p),E=n.sub(E,x),x=n.add(f,i),c=n.add(s,a),x=n.mul(x,c),c=n.add(y,p),x=n.sub(x,c),h=n.mul(b,E),c=n.mul(m,p),h=n.add(c,h),c=n.sub(y,h),h=n.add(y,h),l=n.mul(c,h),y=n.add(w,w),y=n.add(y,w),p=n.mul(b,p),E=n.mul(m,E),y=n.add(y,p),p=n.sub(w,p),p=n.mul(b,p),E=n.add(E,p),w=n.mul(y,E),l=n.add(l,w),w=n.mul(x,E),c=n.mul(g,c),c=n.sub(c,w),w=n.mul(g,y),h=n.mul(x,h),h=n.add(h,w),new d(c,l,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return b.wNAFCached(this,c,e,(e=>{const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(d.fromAffine)}))}multiplyUnsafe(e){const r=d.ZERO;if(e.isZero())return r;if(s(e),e.isOne())return this;const{endo:f}=t;if(!f)return b.unsafeLadder(this,e);let{k1neg:i,k1:o,k2neg:a,k2:c}=f.splitScalar(e),u=r,l=r,h=this;for(;o.gt(ce)||c.gt(ce);)o.isEven()||(u=u.add(h)),c.isEven()||(l=l.add(h)),h=h.double(),o=o.rightShift(ue),c=c.rightShift(ue);return i&&(u=u.negate()),a&&(l=l.negate()),l=new d(n.mul(l.px,f.beta),l.py,l.pz),u.add(l)}multiply(e){s(e);let r,f,i=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:s,k2:a}=o.splitScalar(i);let{p:c,f:u}=this.wNAF(t),{p:l,f:h}=this.wNAF(a);c=b.constTimeNegate(e,c),l=b.constTimeNegate(s,l),l=new d(n.mul(l.px,o.beta),l.py,l.pz),r=c.add(l),f=u.add(h)}else{const{p:e,f:t}=this.wNAF(i);r=e,f=t}return d.normalizeZ([r,f])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,f=(e,t)=>t.isZero()||t.isOne()||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),i=f(this,t).add(f(e,n));return i.is0()?void 0:i}toAffine(e){const{px:t,py:r,pz:f}=this,i=this.is0();null==e&&(e=i?n.ONE:n.inv(f));const o=n.mul(t,e),s=n.mul(r,e),a=n.mul(f,e);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(a,n.ONE))throw Error("invZ was invalid");return{x:o,y:s}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e.isOne())return!0;if(n)return n(d,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e.isOne()?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return g(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const l=t.nBitLength,b=fe(d,t.endo?Math.ceil(l/2):l);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:o}}function he(e){const t=function(e){const t=ie(e);return Z(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r}=t,f=n.BYTES+1,i=2*n.BYTES+1;function o(e){return K(e,r)}function s(e){return W(e,r)}const{ProjectivePoint:a,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=le({...t,toBytes(e,t,r){const f=t.toAffine(),i=n.toBytes(f.x),o=R;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),i):o(Uint8Array.from([4]),i,n.toBytes(f.y))},fromBytes(e){const t=e.length,r=e[0],o=e.subarray(1);if(t!==f||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw Error(`Point of length ${t} was invalid. Expected ${f} compressed bytes or ${i} uncompressed bytes`)}{const e=v(o);if(s=e,!ce.lt(s)||!s.lt(n.ORDER))throw Error("Point is not on curve");const t=u(e);let f=n.sqrt(t);return!(1&~r)!==!f.isEven()&&(f=n.neg(f)),{x:e,y:f}}var s}}),l=e=>g(A(e,t.nByteLength));function b(e){const t=r.rightShift(ue);return e.gt(t)}const m=(e,t,n)=>v(e.slice(t,n));class w{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=q("compactSignature",e,2*n),new w(m(e,0,n),m(e,n,2*n))}static fromDER(e){const{r:t,s:n}=ae.toSig(q("DER",e));return new w(t,n)}assertValidity(){if(!d(this.r))throw Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(e){const{r,s:f,recovery:i}=this,c=B(q("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw Error("recovery id invalid");const u=2===i||3===i?r.add(t.n):r;if(u.gte(n.ORDER))throw Error("recovery id 2 or 3 invalid");const d=1&i?"03":"02",h=a.fromHex(d+l(u)),b=s(u),m=o(c.negate().imul(b)),w=o(f.mul(b)),y=a.BASE.multiplyAndAddUnsafe(h,m,w);if(!y)throw Error("point at infinify");return y.assertValidity(),y}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,o(this.s.negate()),this.recovery):this}toDERRawBytes(){return S(this.toDERHex())}toDERHex(){return ae.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return S(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}const p={isValidPrivateKey(e){try{return c(e),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const e=te(t.n);return function(e,t,n=!1){const r=e.length,f=ee(t),i=te(t);if(r<16||r<i||r>1024)throw Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=K(n?v(e):O(e),t.dec()).inc();return n?z(o,f):A(o,f)}(t.randomBytes(e),t.n)},precompute:(e=8,t=a.BASE)=>(t._setWindowSize(e),t.multiply(h.new(3)),t)};function E(e){const t=y(e),n="string"==typeof e,r=(t||n)&&e.length;return t?r===f||r===i:n?r===2*f||r===2*i:e instanceof a}const x=t.bits2int||function(e){const n=v(e),r=8*e.length-t.nBitLength;return r>0?n.rightShift(h.new(r)):n},B=t.bits2int_modN||function(e){return o(x(e))},N=j(t.nBitLength);function P(e){if(!(e instanceof h))throw Error("bigint expected");if(!ce.lte(e)||!e.lt(N))throw Error("bigint expected < 2^"+t.nBitLength);return A(e,t.nByteLength)}function L(e,r,f=H){if(["recovered","canonical"].some((e=>e in f)))throw Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=t;let{lowS:l,prehash:h,extraEntropy:m}=f;null==l&&(l=!0),e=q("msgHash",e),h&&(e=q("prehashed msgHash",i(e)));const y=B(e),p=c(r),g=[P(p),P(y)];if(null!=m){const e=!0===m?u(n.BYTES):m;g.push(q("extraEntropy",e))}const E=R(...g),S=y;return{seed:E,k2sig:function(e){const t=x(e);if(!d(t))return;const n=s(t),r=a.BASE.multiply(t).toAffine(),f=o(r.x);if(f.isZero())return;const i=o(n.mul(o(S.add(f.mul(p)))));if(i.isZero())return;let c=(r.x.equal(f)?0:2)|r.y.getBit(0),u=i;return l&&b(i)&&(u=function(e){return b(e)?o(e.negate()):e}(i),c^=1),new w(f,u,c)}}}const H={lowS:t.lowS,prehash:!1},T={lowS:t.lowS,prehash:!1};return a.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return a.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(E(e))throw Error("first arg must be private key");if(!E(t))throw Error("second arg must be public key");return a.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,r=H){const{seed:f,k2sig:i}=L(e,n,r),o=t;return I(o.hash.outputLen,o.nByteLength,o.hmac)(f,i)},verify:function(e,n,r,f=T){const i=e;if(n=q("msgHash",n),r=q("publicKey",r),"strict"in f)throw Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=f;let d,l;try{if("string"==typeof i||y(i))try{d=w.fromDER(i)}catch(e){if(!(e instanceof ae.Err))throw e;d=w.fromCompact(i)}else{if(!("object"==typeof i&&i.r instanceof h&&i.s instanceof h))throw Error("PARSE");{const{r:e,s:t}=i;d=new w(e,t)}}l=a.fromHex(r)}catch(e){if("PARSE"===e.message)throw Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:b,s:m}=d,p=B(n),g=s(m),E=o(p.mul(g)),x=o(b.mul(g)),S=a.BASE.multiplyAndAddUnsafe(l,E,x)?.toAffine();return!!S&&o(S.x).equal(b)},ProjectivePoint:a,Signature:w,utils:p}}
|
|
8
8
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function be(e){return{hash:e,hmac:(t,...n)=>m(e,t,i(...n)),randomBytes:o}}function me(e,t){const n=t=>he({...e,...be(t)});return Object.freeze({...n(t),create:n})}
|
|
9
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.freeze(h.new(4));const we=X(h.new("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),ye=me({a:we.create(h.new("-3")),b:h.new("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:we,n:h.new("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:h.new("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:h.new("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:h.new(1),lowS:!1},s),pe=X(h.new("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),ge=me({a:pe.create(h.new("-3")),b:h.new("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Fp:pe,n:h.new("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:h.new("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:h.new("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:h.new(1),lowS:!1},a),Ee=X(h.new("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),xe={a:Ee.create(h.new("-3")),b:h.new("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Fp:Ee,n:h.new("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:h.new("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:h.new("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:h.new(1)},Be=me({a:xe.a,b:xe.b,Fp:Ee,n:xe.n,Gx:xe.Gx,Gy:xe.Gy,h:xe.h,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},c),Se=X(h.new("0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377")),ve=me({a:Se.create(h.new("0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9")),b:h.new("0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6"),Fp:Se,n:h.new("0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7"),Gx:h.new("0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262"),Gy:h.new("0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997"),h:h.new(1),lowS:!1},s),Oe=X(h.new("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53")),Ae=me({a:Oe.create(h.new("0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826")),b:h.new("0x04a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11"),Fp:Oe,n:h.new("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565"),Gx:h.new("0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e"),Gy:h.new("0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315"),h:h.new(1),lowS:!1},a),ze=X(h.new("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3")),qe=me({a:ze.create(h.new("0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94ca")),b:h.new("0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723"),Fp:ze,n:h.new("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069"),Gx:h.new("0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098eff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822"),Gy:h.new("0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892"),h:h.new(1),lowS:!1},c),Re=Object.freeze(h.new(0)),je=Object.freeze(h.new(1)),Ne=Object.freeze(h.new(2)),Pe=Object.freeze(h.new(3)),Ie=Object.freeze(h.new(8)),Le={zip215:!0};function Ze(e){const t=function(e){const t=ie(e);return Z(e,{hash:"function",a:"BigInteger",d:"BigInteger",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:n,n:r,prehash:f,hash:i,randomBytes:o,nByteLength:s,h:a}=t,c=Ne.leftShift(h.new(8*s).idec()),u=n.create,d=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:n.sqrt(e.mul(n.inv(t)))}}catch(e){return{isValid:!1,value:Re}}}),l=t.adjustScalarBytes||(e=>e),b=t.domain||((e,t,n)=>{if(t.length||n)throw Error("Contexts/pre-hash are not supported");return e}),m=e=>e instanceof h&&e.gt(Re),w=(e,t)=>m(e)&&m(t)&&e.lt(t),y=e=>e.isZero()||w(e,c);function p(e,t){if(w(e,t))return e;throw Error(`Expected valid scalar < ${t}, got ${typeof e} ${e}`)}function E(e){return e.isZero()?e:p(e,r)}const x=new Map;function B(e){if(!(e instanceof S))throw Error("ExtendedPoint expected")}class S{constructor(e,t,n,r){if(this.ex=e,this.ey=t,this.ez=n,this.et=r,!y(e))throw Error("x required");if(!y(t))throw Error("y required");if(!y(n))throw Error("z required");if(!y(r))throw Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof S)throw Error("extended point not allowed");const{x:t,y:n}=e||{};if(!y(t)||!y(n))throw Error("invalid affine point");return new S(t,n,je,u(t.mul(n)))}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.ez)));return e.map(((e,n)=>e.toAffine(t[n]))).map(S.fromAffine)}_setWindowSize(e){this._WINDOW_SIZE=e,x.delete(this)}assertValidity(){const{a:e,d:n}=t;if(this.is0())throw Error("bad point: ZERO");const{ex:r,ey:f,ez:i,et:o}=this,s=u(r.mul(r)),a=u(f.mul(f)),c=u(i.mul(i)),d=u(c.mul(c)),l=u(s.mul(e)),h=u(c.mul(u(l.add(a)))),b=u(d.add(u(n.mul(u(s.mul(a))))));if(!h.equal(b))throw Error("bad point: equation left != right (1)");const m=u(r.mul(f)),w=u(i.mul(o));if(!m.equal(w))throw Error("bad point: equation left != right (2)")}equals(e){B(e);const{ex:t,ey:n,ez:r}=this,{ex:f,ey:i,ez:o}=e,s=u(t.mul(o)),a=u(f.mul(r)),c=u(n.mul(o)),d=u(i.mul(r));return s.equal(a)&&c.equal(d)}is0(){return this.equals(S.ZERO)}negate(){return new S(u(this.ex.negate()),this.ey,this.ez,u(this.et.negate()))}double(){const{a:e}=t,{ex:n,ey:r,ez:f}=this,i=u(n.mul(n)),o=u(r.mul(r)),s=u(Ne.mul(u(f.mul(f)))),a=u(e.mul(i)),c=n.add(r),d=u(u(c.mul(c)).sub(i).isub(o)),l=a.add(o),h=l.sub(s),b=a.sub(o),m=u(d.mul(h)),w=u(l.mul(b)),y=u(d.mul(b)),p=u(h.mul(l));return new S(m,w,p,y)}add(e){B(e);const{a:n,d:r}=t,{ex:f,ey:i,ez:o,et:s}=this,{ex:a,ey:c,ez:d,et:l}=e;if(n.equal(h.new(-1))){const e=u(i.sub(f).imul(c.add(a))),t=u(i.add(f).imul(c.sub(a))),n=u(t.sub(e));if(n.isZero())return this.double();const r=u(o.mul(Ne).imul(l)),h=u(s.mul(Ne).imul(d)),b=h.add(r),m=t.add(e),w=h.sub(r),y=u(b.mul(n)),p=u(m.mul(w)),g=u(b.mul(w)),E=u(n.mul(m));return new S(y,p,E,g)}const b=u(f.mul(a)),m=u(i.mul(c)),w=u(s.mul(r).imul(l)),y=u(o.mul(d)),p=u(f.add(i).imul(a.add(c)).isub(b).isub(m)),g=y.sub(w),E=y.add(w),x=u(m.sub(n.mul(b))),v=u(p.mul(g)),O=u(E.mul(x)),A=u(p.mul(x)),z=u(g.mul(E));return new S(v,O,z,A)}subtract(e){return this.add(e.negate())}wNAF(e){return z.wNAFCached(this,x,e,S.normalizeZ)}multiply(e){const{p:t,f:n}=this.wNAF(p(e,r));return S.normalizeZ([t,n])[0]}multiplyUnsafe(e){let t=E(e);return t.isZero()?A:this.equals(A)||t.isOne()?this:this.equals(v)?this.wNAF(t).p:z.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return z.unsafeLadder(this,r).is0()}toAffine(e){const{ex:t,ey:r,ez:f}=this,i=this.is0();null==e&&(e=i?Ie:n.inv(f));const o=u(t.mul(e)),s=u(r.mul(e)),a=u(f.mul(e));if(i)return{x:Re.clone(),y:je.clone()};if(!a.isOne())throw Error("invZ was invalid");return{x:o,y:s}}clearCofactor(){const{h:e}=t;return e.isOne()?this:this.multiplyUnsafe(e)}static fromHex(e,r=!1){const{d:f,a:i}=t,o=n.BYTES,s=(e=q("pointHex",e,o)).slice(),a=e[o-1];s[o-1]=-129&a;const l=O(s);l.isZero()||p(l,r?c:n.ORDER);const h=u(l.mul(l)),b=u(h.dec()),m=u(f.mul(h).isub(i));let{isValid:w,value:y}=d(b,m);if(!w)throw Error("Point.fromHex: invalid y coordinate");const g=!y.isEven(),E=0!=(128&a);if(!r&&y.isZero()&&E)throw Error("Point.fromHex: x=0 and x_0=1");return E!==g&&(y=u(y.negate())),S.fromAffine({x:y,y:l})}static fromPrivateKey(e){return P(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),r=t.toUint8Array("le",n.BYTES);return r[r.length-1]|=e.isEven()?0:128,r}toHex(){return g(this.toRawBytes())}}S.BASE=new S(t.Gx,t.Gy,je,u(t.Gx.mul(t.Gy))),S.ZERO=new S(Re,je,je,Re);const{BASE:v,ZERO:A}=S,z=fe(S,8*s);function j(e){return K(e,r)}function N(e){return j(O(e))}function P(e){const t=s;e=q("private key",e,t);const n=q("hashed private key",i(e),2*t),r=l(n.slice(0,t)),f=n.slice(t,2*t),o=N(r),a=v.multiply(o),c=a.toRawBytes();return{head:r,prefix:f,scalar:o,point:a,pointBytes:c}}function I(e=new Uint8Array,...t){const n=R(...t);return N(i(b(n,q("context",e),!!f)))}const L=Le;v._setWindowSize(8);return{CURVE:t,getPublicKey:function(e){return P(e).pointBytes},sign:function(e,t,r={}){e=q("message",e),f&&(e=f(e));const{prefix:i,scalar:o,pointBytes:a}=P(t),c=I(r.context,i,e),u=v.multiply(c).toRawBytes(),d=I(r.context,u,a,e),l=j(c.add(d.mul(o)));return E(l),q("result",R(u,l.toUint8Array("le",n.BYTES)),2*s)},verify:function(e,t,r,i=L){const{context:o,zip215:s}=i,a=n.BYTES;e=q("signature",e,2*a),t=q("message",t),f&&(t=f(t));const c=O(e.slice(a,2*a));let u,d,l;try{u=S.fromHex(r,s),d=S.fromHex(e.slice(0,a),s),l=v.multiplyUnsafe(c)}catch(e){return!1}if(!s&&u.isSmallOrder())return!1;const h=I(o,d.toRawBytes(),u.toRawBytes(),t);return d.add(u.multiplyUnsafe(h)).subtract(l).clearCofactor().equals(S.ZERO)},ExtendedPoint:S,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>o(n.BYTES),precompute:(e=8,t=S.BASE)=>(t._setWindowSize(e),t.multiply(Pe),t)}}}
|
|
9
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.freeze(h.new(4));const we=X(h.new("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),ye=me({a:we.create(h.new("-3")),b:h.new("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:we,n:h.new("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:h.new("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:h.new("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:h.new(1),lowS:!1},s),pe=X(h.new("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),ge=me({a:pe.create(h.new("-3")),b:h.new("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Fp:pe,n:h.new("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:h.new("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:h.new("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:h.new(1),lowS:!1},a),Ee=X(h.new("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),xe={a:Ee.create(h.new("-3")),b:h.new("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Fp:Ee,n:h.new("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:h.new("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:h.new("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:h.new(1)},Be=me({a:xe.a,b:xe.b,Fp:Ee,n:xe.n,Gx:xe.Gx,Gy:xe.Gy,h:xe.h,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},c),Se=X(h.new("0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377")),ve=me({a:Se.create(h.new("0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9")),b:h.new("0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6"),Fp:Se,n:h.new("0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7"),Gx:h.new("0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262"),Gy:h.new("0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997"),h:h.new(1),lowS:!1},s),Oe=X(h.new("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53")),Ae=me({a:Oe.create(h.new("0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826")),b:h.new("0x04a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11"),Fp:Oe,n:h.new("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565"),Gx:h.new("0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e"),Gy:h.new("0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315"),h:h.new(1),lowS:!1},a),ze=X(h.new("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3")),qe=me({a:ze.create(h.new("0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94ca")),b:h.new("0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723"),Fp:ze,n:h.new("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069"),Gx:h.new("0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098eff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822"),Gy:h.new("0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892"),h:h.new(1),lowS:!1},c),Re=Object.freeze(h.new(0)),je=Object.freeze(h.new(1)),Ne=Object.freeze(h.new(2)),Pe=Object.freeze(h.new(3)),Ie=Object.freeze(h.new(8)),Le={zip215:!0};function Ze(e){const t=function(e){const t=ie(e);return Z(e,{hash:"function",a:"BigInteger",d:"BigInteger",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:n,n:r,prehash:f,hash:i,randomBytes:o,nByteLength:s,h:a}=t,c=Ne.leftShift(h.new(8*s).idec()),u=n.create,d=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:n.sqrt(e.mul(n.inv(t)))}}catch(e){return{isValid:!1,value:Re}}}),l=t.adjustScalarBytes||(e=>e),b=t.domain||((e,t,n)=>{if(t.length||n)throw Error("Contexts/pre-hash are not supported");return e}),m=e=>e instanceof h&&e.gt(Re),w=(e,t)=>m(e)&&m(t)&&e.lt(t),y=e=>e.isZero()||w(e,c);function p(e,t){if(w(e,t))return e;throw Error(`Expected valid scalar < ${t}, got ${typeof e} ${e}`)}function E(e){return e.isZero()?e:p(e,r)}const x=new Map;function B(e){if(!(e instanceof S))throw Error("ExtendedPoint expected")}class S{constructor(e,t,n,r){if(this.ex=e,this.ey=t,this.ez=n,this.et=r,!y(e))throw Error("x required");if(!y(t))throw Error("y required");if(!y(n))throw Error("z required");if(!y(r))throw Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof S)throw Error("extended point not allowed");const{x:t,y:n}=e||{};if(!y(t)||!y(n))throw Error("invalid affine point");return new S(t,n,je,u(t.mul(n)))}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.ez)));return e.map(((e,n)=>e.toAffine(t[n]))).map(S.fromAffine)}_setWindowSize(e){this._WINDOW_SIZE=e,x.delete(this)}assertValidity(){const{a:e,d:n}=t;if(this.is0())throw Error("bad point: ZERO");const{ex:r,ey:f,ez:i,et:o}=this,s=u(r.mul(r)),a=u(f.mul(f)),c=u(i.mul(i)),d=u(c.mul(c)),l=u(s.mul(e)),h=u(c.mul(u(l.add(a)))),b=u(d.add(u(n.mul(u(s.mul(a))))));if(!h.equal(b))throw Error("bad point: equation left != right (1)");const m=u(r.mul(f)),w=u(i.mul(o));if(!m.equal(w))throw Error("bad point: equation left != right (2)")}equals(e){B(e);const{ex:t,ey:n,ez:r}=this,{ex:f,ey:i,ez:o}=e,s=u(t.mul(o)),a=u(f.mul(r)),c=u(n.mul(o)),d=u(i.mul(r));return s.equal(a)&&c.equal(d)}is0(){return this.equals(S.ZERO)}negate(){return new S(u(this.ex.negate()),this.ey,this.ez,u(this.et.negate()))}double(){const{a:e}=t,{ex:n,ey:r,ez:f}=this,i=u(n.mul(n)),o=u(r.mul(r)),s=u(Ne.mul(u(f.mul(f)))),a=u(e.mul(i)),c=n.add(r),d=u(u(c.mul(c)).sub(i).isub(o)),l=a.add(o),h=l.sub(s),b=a.sub(o),m=u(d.mul(h)),w=u(l.mul(b)),y=u(d.mul(b)),p=u(h.mul(l));return new S(m,w,p,y)}add(e){B(e);const{a:n,d:r}=t,{ex:f,ey:i,ez:o,et:s}=this,{ex:a,ey:c,ez:d,et:l}=e;if(n.equal(h.new(-1))){const e=u(i.sub(f).imul(c.add(a))),t=u(i.add(f).imul(c.sub(a))),n=u(t.sub(e));if(n.isZero())return this.double();const r=u(o.mul(Ne).imul(l)),h=u(s.mul(Ne).imul(d)),b=h.add(r),m=t.add(e),w=h.sub(r),y=u(b.mul(n)),p=u(m.mul(w)),g=u(b.mul(w)),E=u(n.mul(m));return new S(y,p,E,g)}const b=u(f.mul(a)),m=u(i.mul(c)),w=u(s.mul(r).imul(l)),y=u(o.mul(d)),p=u(f.add(i).imul(a.add(c)).isub(b).isub(m)),g=y.sub(w),E=y.add(w),x=u(m.sub(n.mul(b))),v=u(p.mul(g)),O=u(E.mul(x)),A=u(p.mul(x)),z=u(g.mul(E));return new S(v,O,z,A)}subtract(e){return this.add(e.negate())}wNAF(e){return z.wNAFCached(this,x,e,S.normalizeZ)}multiply(e){const{p:t,f:n}=this.wNAF(p(e,r));return S.normalizeZ([t,n])[0]}multiplyUnsafe(e){let t=E(e);return t.isZero()?A:this.equals(A)||t.isOne()?this:this.equals(v)?this.wNAF(t).p:z.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return z.unsafeLadder(this,r).is0()}toAffine(e){const{ex:t,ey:r,ez:f}=this,i=this.is0();null==e&&(e=i?Ie:n.inv(f));const o=u(t.mul(e)),s=u(r.mul(e)),a=u(f.mul(e));if(i)return{x:Re.clone(),y:je.clone()};if(!a.isOne())throw Error("invZ was invalid");return{x:o,y:s}}clearCofactor(){const{h:e}=t;return e.isOne()?this:this.multiplyUnsafe(e)}static fromHex(e,r=!1){const{d:f,a:i}=t,o=n.BYTES,s=(e=q("pointHex",e,o)).slice(),a=e[o-1];s[o-1]=-129&a;const l=O(s);l.isZero()||p(l,r?c:n.ORDER);const h=u(l.mul(l)),b=u(h.dec()),m=u(f.mul(h).isub(i));let{isValid:w,value:y}=d(b,m);if(!w)throw Error("Point.fromHex: invalid y coordinate");const g=!y.isEven(),E=!!(128&a);if(!r&&y.isZero()&&E)throw Error("Point.fromHex: x=0 and x_0=1");return E!==g&&(y=u(y.negate())),S.fromAffine({x:y,y:l})}static fromPrivateKey(e){return P(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),r=t.toUint8Array("le",n.BYTES);return r[r.length-1]|=e.isEven()?0:128,r}toHex(){return g(this.toRawBytes())}}S.BASE=new S(t.Gx,t.Gy,je,u(t.Gx.mul(t.Gy))),S.ZERO=new S(Re,je,je,Re);const{BASE:v,ZERO:A}=S,z=fe(S,8*s);function j(e){return K(e,r)}function N(e){return j(O(e))}function P(e){const t=s;e=q("private key",e,t);const n=q("hashed private key",i(e),2*t),r=l(n.slice(0,t)),f=n.slice(t,2*t),o=N(r),a=v.multiply(o),c=a.toRawBytes();return{head:r,prefix:f,scalar:o,point:a,pointBytes:c}}function I(e=new Uint8Array,...t){const n=R(...t);return N(i(b(n,q("context",e),!!f)))}const L=Le;v._setWindowSize(8);return{CURVE:t,getPublicKey:function(e){return P(e).pointBytes},sign:function(e,t,r={}){e=q("message",e),f&&(e=f(e));const{prefix:i,scalar:o,pointBytes:a}=P(t),c=I(r.context,i,e),u=v.multiply(c).toRawBytes(),d=I(r.context,u,a,e),l=j(c.add(d.mul(o)));return E(l),q("result",R(u,l.toUint8Array("le",n.BYTES)),2*s)},verify:function(e,t,r,i=L){const{context:o,zip215:s}=i,a=n.BYTES;e=q("signature",e,2*a),t=q("message",t),f&&(t=f(t));const c=O(e.slice(a,2*a));let u,d,l;try{u=S.fromHex(r,s),d=S.fromHex(e.slice(0,a),s),l=v.multiplyUnsafe(c)}catch(e){return!1}if(!s&&u.isSmallOrder())return!1;const h=I(o,d.toRawBytes(),u.toRawBytes(),t);return d.add(u.multiplyUnsafe(h)).subtract(l).clearCofactor().equals(S.ZERO)},ExtendedPoint:S,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>o(n.BYTES),precompute:(e=8,t=S.BASE)=>(t._setWindowSize(e),t.multiply(Pe),t)}}}
|
|
10
10
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const He=Object.freeze(h.new(0)),Te=Object.freeze(h.new(1)),Ue=Object.freeze(h.new(2));function Fe(e){const t=(Z(n=e,{a:"BigInteger"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"BigInteger"}),Object.freeze({...n}));var n;const{P:r}=t,f=e=>K(e,r),i=t.montgomeryBits,o=Math.ceil(i/8),s=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>D(e,r.sub(Ue),r));function u(e,t,n){const r=f(e.mul(t.sub(n)));return[t=f(t.sub(r)),n=f(n.add(r))]}function d(e){if(e instanceof h&&!e.isNegative()&&e.lt(r))return e;throw Error("Expected valid scalar 0 < scalar < CURVE.P")}const l=t.a.sub(Ue).irightShift(Ue);function b(e){return z(f(e),o)}function m(e,t){const n=function(e){const t=q("u coordinate",e,o);return 32===s&&(t[31]&=127),O(t)}(t),r=function(e){const t=q("scalar",e),n=t.length;if(n!==o&&n!==s)throw Error(`Expected ${o} or ${s} bytes, got ${n}`);return O(a(t))}(e),m=function(e,t){const n=d(e),r=d(t),o=n;let s,a=Te,b=He,m=n,w=Te,y=He.clone();for(let e=h.new(i-1);!e.isNegative();e.idec()){const t=h.new(r.rightShift(e).getBit(0));y.ixor(t),s=u(y,a,m),a=s[0],m=s[1],s=u(y,b,w),b=s[0],w=s[1],y=t;const n=a.add(b),i=f(n.mul(n)),c=a.sub(b),d=f(c.mul(c)),p=i.sub(d),g=m.add(w),E=m.sub(w),x=f(E.mul(n)),B=f(g.mul(c)),S=x.add(B),v=x.sub(B);m=f(S.mul(S)),w=f(o.mul(f(v.mul(v)))),a=f(i.mul(d)),b=f(p.mul(i.add(f(l.mul(p)))))}s=u(y,a,m),a=s[0],m=s[1],s=u(y,b,w),b=s[0],w=s[1];const p=c(b);return f(a.mul(p))}(n,r);if(m.isZero())throw Error("Invalid private or public key received");return b(m)}const w=b(t.Gu);function y(e){return m(e,w)}return{scalarMult:m,scalarMultBase:y,getSharedSecret:(e,t)=>m(e,t),getPublicKey:e=>y(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:w}}
|
|
11
11
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _e=u((()=>l.create({dkLen:114}))),Ge=(u((()=>l.create({dkLen:64}))),h.new("726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018365439")),ke=h.new(1),Ce=h.new(2),$e=h.new(3),Ve=h.new(11),Ke=h.new(22),De=h.new(44),Ye=h.new(88),We=h.new(223);function Me(e){const t=Ge,n=e.modExp($e,t),r=n.mul(n).imul(e).imod(t),f=Y(r,$e,t).imul(r).imod(t),i=Y(f,$e,t).imul(r).imod(t),o=Y(i,Ce,t).imul(n).imod(t),s=Y(o,Ve,t).imul(o).imod(t),a=Y(s,Ke,t).imul(s).imod(t),c=Y(a,De,t).imul(a).imod(t),u=Y(c,Ye,t).imul(c).imod(t),d=Y(u,De,t).imul(a).imod(t),l=Y(d,Ce,t).imul(n).imod(t),h=Y(l,ke,t).imul(e).imod(t);return Y(h,We,t).imul(l).imod(t)}function Je(e){return e[0]&=252,e[55]|=128,e[56]=0,e}const Qe=X(Ge,456,!0),Xe={a:h.new(1),d:h.new("726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018326358"),Fp:Qe,n:h.new("181709681073901722637330951972001133588410340171829515070372549795146003961539585716195755291692375963310293709091662304773755859649779"),nBitLength:456,h:h.new(4),Gx:h.new("224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710"),Gy:h.new("298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660"),hash:_e,randomBytes:o,adjustScalarBytes:Je,domain:(e,t,n)=>{if(t.length>255)throw Error("Context is too big: "+t.length);return i(d("SigEd448"),new Uint8Array([n?1:0,t.length]),t,e)},uvRatio:function(e,t){const n=Ge,r=K(e.mul(e).imul(t),n),f=K(r.mul(e),n),i=Me(K(f.mul(r).imul(t),n)),o=K(f.mul(i),n),s=K(o.mul(o),n);return{isValid:K(s.mul(t),n).equal(e),value:o}}},et=/* @__PURE__ */Ze(Xe),tt=/* @__PURE__ */(()=>Fe({a:h.new(156326),montgomeryBits:448,nByteLength:56,P:Ge,Gu:h.new(5),powPminus2:e=>{const t=Ge;return K(Y(Me(e),h.new(2),t).mul(e),t)},adjustScalarBytes:Je,randomBytes:o}))();Object.freeze(h.new(4)),Qe.ORDER.sub($e).irightShift(Ce),h.new(156326),h.new("39082"),h.new("78163"),h.new("98944233647732219769177004876929019128417576295529901074099889598043702116001257856802131563896515373927712232092845883226922417596214"),h.new("315019913931389607337177038330951043522456072897266928557328499619017160722351061360252776265186336876723201881398623946864393857820716"),h.new("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
12
12
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|