@@ -5,210 +5,57 @@ import Maybe exposing (Just, Nothing)
55*/
66
77
8−// NOBLE/CURVES BUNDLE (https://github.com/paulmillr/noble-curves, MIT License)
9−// Embedded: @noble/curves 2.0.1 - secp256k1, ed25519, P-256
10−
11−var _Crypto_noble =(()=>{var te=Object.defineProperty;var _n=Object.getOwnPropertyDescriptor;var In=Object.getOwnPropertyNames;var An=Object.prototype.hasOwnProperty;var Rn=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},On=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of In(t))!An.call(e,o)&&o!==r&&te(e,o,{get:()=>t[o],enumerable:!(n=_n(t,o))||n.enumerable});return e};var Hn=e=>On(te({},"_"+"_esModule",{value:!0}),e);var lr={};Rn(lr,{bytesToHex:()=>et,ed25519:()=>vn,hexToBytes:()=>nt,p256:()=>Sn,secp256k1:()=>gn});function pt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ot(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function N(e,t,r=""){let n=pt(e),o=e?.length,f=t!==void 0;if(!n||f&&o!==t){let i=r&&`"${r}" `,c=f?` of length ${t}`:"",s=n?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+c+", got "+s)}return e}function Yt(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");ot(e.outputLen),ot(e.blockLen)}function St(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function qe(e,t){N(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function it(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function kt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function tt(e,t){return e<<32-t|e>>>t}var Ue=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Tn=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function et(e){if(N(e),Ue)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Tn[e[r]];return t}var st={_0:48,_9:57,A:65,F:70,a:97,f:102};function Le(e){if(e>=st._0&&e<=st._9)return e-st._0;if(e>=st.A&&e<=st.F)return e-(st.A-10);if(e>=st.a&&e<=st.f)return e-(st.a-10)}function nt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ue)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,f=0;o<r;o++,f+=2){let i=Le(e.charCodeAt(f)),c=Le(e.charCodeAt(f+1));if(i===void 0||c===void 0){let s=e[f]+e[f+1];throw new Error('hex string expected, got non-hex character "'+s+'" at index '+f)}n[o]=i*16+c}return n}function F(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];N(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let f=e[n];r.set(f,o),o+=f.length}return r}function ee(e,t={}){let r=(o,f)=>e(f).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function _t(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var ne=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Ne(e,t,r){return e&t^~e&r}function De(e,t,r){return e&t^e&r^t&r}var Lt=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=kt(this.buffer)}update(t){St(this),N(t);let{view:r,buffer:n,blockLen:o}=this,f=t.length;for(let i=0;i<f;){let c=Math.min(o-this.pos,f-i);if(c===o){let s=kt(t);for(;o<=f-i;i+=o)this.process(s,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){St(this),qe(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:f}=this,{pos:i}=this;r[i++]=128,it(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let h=i;h<o;h++)r[h]=0;n.setBigUint64(o-8,BigInt(this.length*8),f),this.process(n,0);let c=kt(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let l=s/4,m=this.get();if(l>m.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)c.setUint32(4*h,m[h],f)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:f,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=f,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},ct=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var P=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Xt=BigInt(4294967295),Ze=BigInt(32);function Ln(e,t=!1){return t?{h:Number(e&Xt),l:Number(e>>Ze&Xt)}:{h:Number(e>>Ze&Xt)|0,l:Number(e&Xt)|0}}function Ce(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let f=0;f<r;f++){let{h:i,l:c}=Ln(e[f],t);[n[f],o[f]]=[i,c]}return[n,o]}var re=(e,t,r)=>e>>>r,oe=(e,t,r)=>e<<32-r|t>>>r,gt=(e,t,r)=>e>>>r|t<<32-r,yt=(e,t,r)=>e<<32-r|t>>>r,qt=(e,t,r)=>e<<64-r|t>>>r-32,Ut=(e,t,r)=>e>>>r-32|t<<64-r;function ft(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Ve=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Me=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ye=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),ke=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Xe=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ge=(e,t,r,n,o,f)=>t+r+n+o+f+(e/2**32|0)|0;var Un=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ut=new Uint32Array(64),fe=class extends Lt{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:f,F:i,G:c,H:s}=this;return[t,r,n,o,f,i,c,s]}set(t,r,n,o,f,i,c,s){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=f|0,this.F=i|0,this.G=c|0,this.H=s|0}process(t,r){for(let h=0;h<16;h++,r+=4)ut[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){let B=ut[h-15],E=ut[h-2],g=tt(B,7)^tt(B,18)^B>>>3,L=tt(E,17)^tt(E,19)^E>>>10;ut[h]=L+ut[h-7]+g+ut[h-16]|0}let{A:n,B:o,C:f,D:i,E:c,F:s,G:l,H:m}=this;for(let h=0;h<64;h++){let B=tt(c,6)^tt(c,11)^tt(c,25),E=m+B+Ne(c,s,l)+Un[h]+ut[h]|0,L=(tt(n,2)^tt(n,13)^tt(n,22))+De(n,o,f)|0;m=l,l=s,s=c,c=i+E|0,i=f,f=o,o=n,n=E+L|0}n=n+this.A|0,o=o+this.B|0,f=f+this.C|0,i=i+this.D|0,c=c+this.E|0,s=s+this.F|0,l=l+this.G|0,m=m+this.H|0,this.set(n,o,f,i,c,s,l,m)}roundClean(){it(ut)}destroy(){this.set(0,0,0,0,0,0,0,0),it(this.buffer)}},se=class extends fe{A=ct[0]|0;B=ct[1]|0;C=ct[2]|0;D=ct[3]|0;E=ct[4]|0;F=ct[5]|0;G=ct[6]|0;H=ct[7]|0;constructor(){super(32)}};var Ke=Ce(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Nn=Ke[0],Dn=Ke[1],lt=new Uint32Array(80),ht=new Uint32Array(80),ie=class extends Lt{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:f,Cl:i,Dh:c,Dl:s,Eh:l,El:m,Fh:h,Fl:B,Gh:E,Gl:g,Hh:L,Hl:v}=this;return[t,r,n,o,f,i,c,s,l,m,h,B,E,g,L,v]}set(t,r,n,o,f,i,c,s,l,m,h,B,E,g,L,v){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=f|0,this.Cl=i|0,this.Dh=c|0,this.Dl=s|0,this.Eh=l|0,this.El=m|0,this.Fh=h|0,this.Fl=B|0,this.Gh=E|0,this.Gl=g|0,this.Hh=L|0,this.Hl=v|0}process(t,r){for(let p=0;p<16;p++,r+=4)lt[p]=t.getUint32(r),ht[p]=t.getUint32(r+=4);for(let p=16;p<80;p++){let T=lt[p-15]|0,Z=ht[p-15]|0,V=gt(T,Z,1)^gt(T,Z,8)^re(T,Z,7),M=yt(T,Z,1)^yt(T,Z,8)^oe(T,Z,7),w=lt[p-2]|0,b=ht[p-2]|0,q=gt(w,b,19)^qt(w,b,61)^re(w,b,6),D=yt(w,b,19)^Ut(w,b,61)^oe(w,b,6),R=Ye(M,D,ht[p-7],ht[p-16]),d=ke(R,V,q,lt[p-7],lt[p-16]);lt[p]=d|0,ht[p]=R|0}let{Ah:n,Al:o,Bh:f,Bl:i,Ch:c,Cl:s,Dh:l,Dl:m,Eh:h,El:B,Fh:E,Fl:g,Gh:L,Gl:v,Hh:x,Hl:I}=this;for(let p=0;p<80;p++){let T=gt(h,B,14)^gt(h,B,18)^qt(h,B,41),Z=yt(h,B,14)^yt(h,B,18)^Ut(h,B,41),V=h&E^~h&L,M=B&g^~B&v,w=Xe(I,Z,M,Dn[p],ht[p]),b=Ge(w,x,T,V,Nn[p],lt[p]),q=w|0,D=gt(n,o,28)^qt(n,o,34)^qt(n,o,39),R=yt(n,o,28)^Ut(n,o,34)^Ut(n,o,39),d=n&f^n&c^f&c,u=o&i^o&s^i&s;x=L|0,I=v|0,L=E|0,v=g|0,E=h|0,g=B|0,{h,l:B}=ft(l|0,m|0,b|0,q|0),l=c|0,m=s|0,c=f|0,s=i|0,f=n|0,i=o|0;let a=Ve(q,R,u);n=Me(a,b,D,d),o=a|0}({h:n,l:o}=ft(this.Ah|0,this.Al|0,n|0,o|0)),{h:f,l:i}=ft(this.Bh|0,this.Bl|0,f|0,i|0),{h:c,l:s}=ft(this.Ch|0,this.Cl|0,c|0,s|0),{h:l,l:m}=ft(this.Dh|0,this.Dl|0,l|0,m|0),{h,l:B}=ft(this.Eh|0,this.El|0,h|0,B|0),{h:E,l:g}=ft(this.Fh|0,this.Fl|0,E|0,g|0),{h:L,l:v}=ft(this.Gh|0,this.Gl|0,L|0,v|0),{h:x,l:I}=ft(this.Hh|0,this.Hl|0,x|0,I|0),this.set(n,o,f,i,c,s,l,m,h,B,E,g,L,v,x,I)}roundClean(){it(lt,ht)}destroy(){it(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ce=class extends ie{Ah=P[0]|0;Al=P[1]|0;Bh=P[2]|0;Bl=P[3]|0;Ch=P[4]|0;Cl=P[5]|0;Dh=P[6]|0;Dl=P[7]|0;Eh=P[8]|0;El=P[9]|0;Fh=P[10]|0;Fl=P[11]|0;Gh=P[12]|0;Gl=P[13]|0;Hh=P[14]|0;Hl=P[15]|0;constructor(){super(64)}};var Gt=ee(()=>new se,ne(1));var ae=ee(()=>new ce,ne(3));var ue=BigInt(0),de=BigInt(1);function at(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function je(e){if(typeof e=="bigint"){if(!Kt(e))throw new Error("positive bigint expected, got "+e)}else ot(e);return e}function Nt(e){let t=je(e).toString(16);return t.length&1?"0"+t:t}function We(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ue:BigInt("0x"+e)}function It(e){return We(et(e))}function wt(e){return We(et(Wt(N(e)).reverse()))}function jt(e,t){ot(t),e=je(e);let r=nt(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function le(e,t){return jt(e,t).reverse()}function Wt(e){return Uint8Array.from(e)}var Kt=e=>typeof e=="bigint"&&ue<=e;function Zn(e,t,r){return Kt(e)&&Kt(t)&&Kt(r)&&t<=e&&e<r}function Dt(e,t,r,n){if(!Zn(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function he(e){let t;for(t=0;e>ue;e>>=de,t+=1);return t}var Zt=e=>(de<<BigInt(e))-de;function ze(e,t,r){if(ot(e,"hashLen"),ot(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=v=>new Uint8Array(v),o=Uint8Array.of(),f=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,s=n(e),l=n(e),m=0,h=()=>{s.fill(1),l.fill(0),m=0},B=(...v)=>r(l,F(s,...v)),E=(v=o)=>{l=B(f,v),s=B(),v.length!==0&&(l=B(i,v),s=B())},g=()=>{if(m++>=c)throw new Error("drbg: tried max amount of iterations");let v=0,x=[];for(;v<t;){s=B();let I=s.slice();x.push(I),v+=s.length}return F(...x)};return(v,x)=>{h(),E(v);let I;for(;!(I=x(g()));)E();return h(),I}}function bt(e,t={},r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(f,i,c){let s=e[f];if(c&&s===void 0)return;let l=typeof s;if(l!==i||s===null)throw new Error(`param "${f}" is invalid: expected ${i}, got ${l}`)}let o=(f,i)=>Object.entries(f).forEach(([c,s])=>n(c,s,i));o(t,!1),o(r,!0)}function At(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let f=e(r,...n);return t.set(r,f),f}}var J=BigInt(0),W=BigInt(1),Et=BigInt(2),Qe=BigInt(3),Je=BigInt(4),Fe=BigInt(5),Cn=BigInt(7),tn=BigInt(8),Vn=BigInt(9),en=BigInt(16);function j(e,t){let r=e%t;return r>=J?r:t+r}function k(e,t,r){let n=e;for(;t-- >J;)n*=n,n%=r;return n}function $e(e,t){if(e===J)throw new Error("invert: expected non-zero number");if(t<=J)throw new Error("invert: expected positive modulus, got "+t);let r=j(e,t),n=t,o=J,f=W,i=W,c=J;for(;r!==J;){let l=n/r,m=n%r,h=o-i*l,B=f-c*l;n=r,r=m,o=i,f=c,i=h,c=B}if(n!==W)throw new Error("invert: does not exist");return j(o,t)}function xe(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function nn(e,t){let r=(e.ORDER+W)/Je,n=e.pow(t,r);return xe(e,n,t),n}function Mn(e,t){let r=(e.ORDER-Fe)/tn,n=e.mul(t,Et),o=e.pow(n,r),f=e.mul(t,o),i=e.mul(e.mul(f,Et),o),c=e.mul(f,e.sub(i,e.ONE));return xe(e,c,t),c}function Yn(e){let t=Rt(e),r=rn(e),n=r(t,t.neg(t.ONE)),o=r(t,n),f=r(t,t.neg(n)),i=(e+Cn)/en;return(c,s)=>{let l=c.pow(s,i),m=c.mul(l,n),h=c.mul(l,o),B=c.mul(l,f),E=c.eql(c.sqr(m),s),g=c.eql(c.sqr(h),s);l=c.cmov(l,m,E),m=c.cmov(B,h,g);let L=c.eql(c.sqr(m),s),v=c.cmov(l,m,L);return xe(c,v,s),v}}function rn(e){if(e<Qe)throw new Error("sqrt is not defined for small field");let t=e-W,r=0;for(;t%Et===J;)t/=Et,r++;let n=Et,o=Rt(e);for(;Pe(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return nn;let f=o.pow(n,t),i=(t+W)/Et;return function(s,l){if(s.is0(l))return l;if(Pe(s,l)!==1)throw new Error("Cannot find square root");let m=r,h=s.mul(s.ONE,f),B=s.pow(l,t),E=s.pow(l,i);for(;!s.eql(B,s.ONE);){if(s.is0(B))return s.ZERO;let g=1,L=s.sqr(B);for(;!s.eql(L,s.ONE);)if(g++,L=s.sqr(L),g===m)throw new Error("Cannot find square root");let v=W<<BigInt(m-g-1),x=s.pow(h,v);m=g,h=s.sqr(x),B=s.mul(B,h),E=s.mul(E,x)}return E}}function kn(e){return e%Je===Qe?nn:e%tn===Fe?Mn:e%en===Vn?Yn(e):rn(e)}var on=(e,t)=>(j(e,t)&W)===W,Xn=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function me(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Xn.reduce((n,o)=>(n[o]="function",n),t);return bt(e,r),e}function Gn(e,t,r){if(r<J)throw new Error("invalid exponent, negatives unsupported");if(r===J)return e.ONE;if(r===W)return t;let n=e.ONE,o=t;for(;r>J;)r&W&&(n=e.mul(n,o)),o=e.sqr(o),r>>=W;return n}function Ct(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((i,c,s)=>e.is0(c)?i:(n[s]=i,e.mul(i,c)),e.ONE),f=e.inv(o);return t.reduceRight((i,c,s)=>e.is0(c)?i:(n[s]=e.mul(i,n[s]),e.mul(i,c)),f),n}function Pe(e,t){let r=(e.ORDER-W)/Et,n=e.pow(t,r),o=e.eql(n,e.ONE),f=e.eql(n,e.ZERO),i=e.eql(n,e.neg(e.ONE));if(!o&&!f&&!i)throw new Error("invalid Legendre symbol result");return o?1:f?0:-1}function Kn(e,t){t!==void 0&&ot(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var be=class{ORDER;BITS;BYTES;isLE;ZERO=J;ONE=W;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=J)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:f}=Kn(t,n);if(f>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=f,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return j(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return J<=t&&t<this.ORDER}is0(t){return t===J}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&W)===W}neg(t){return j(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return j(t*t,this.ORDER)}add(t,r){return j(t+r,this.ORDER)}sub(t,r){return j(t-r,this.ORDER)}mul(t,r){return j(t*r,this.ORDER)}pow(t,r){return Gn(this,t,r)}div(t,r){return j(t*$e(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return $e(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=kn(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?le(t,this.BYTES):jt(t,this.BYTES)}fromBytes(t,r=!1){N(t);let{_lengths:n,BYTES:o,isLE:f,ORDER:i,_mod:c}=this;if(n){if(!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(o);l.set(t,f?0:l.length-t.length),t=l}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let s=f?wt(t):It(t);if(c&&(s=j(s,i)),!r&&!this.isValid(s))throw new Error("invalid field element: outside of range 0..ORDER");return s}invertBatch(t){return Ct(this,t)}cmov(t,r,n){return n?r:t}};function Rt(e,t={}){return new be(e,t)}function fn(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function pe(e){let t=fn(e);return t+Math.ceil(t/2)}function ge(e,t,r=!1){N(e);let n=e.length,o=fn(t),f=pe(t);if(n<16||n<f||n>1024)throw new Error("expected "+f+"-1024 bytes of input, got "+n);let i=r?wt(e):It(e),c=j(i,t-W)+W;return r?le(c,o):jt(c,o)}var Ot=BigInt(0),Bt=BigInt(1);function Vt(e,t){let r=t.negate();return e?r:t}function vt(e,t){let r=Ct(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function dn(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ye(e,t){dn(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,f=Zt(e),i=BigInt(e);return{windows:r,windowSize:n,mask:f,maxNumber:o,shiftBy:i}}function sn(e,t,r){let{windowSize:n,mask:o,maxNumber:f,shiftBy:i}=r,c=Number(e&o),s=e>>i;c>n&&(c-=f,s+=Bt);let l=t*n,m=l+Math.abs(c)-1,h=c===0,B=c<0,E=t%2!==0;return{nextN:s,offset:m,isZero:h,isNeg:B,isNegF:E,offsetF:l}}var we=new WeakMap,un=new WeakMap;function Ee(e){return un.get(e)||1}function cn(e){if(e!==Ot)throw new Error("invalid wNAF")}var Ht=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>Ot;)r&Bt&&(n=n.add(o)),o=o.double(),r>>=Bt;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=ye(r,this.bits),f=[],i=t,c=i;for(let s=0;s<n;s++){c=i,f.push(c);for(let l=1;l<o;l++)c=c.add(i),f.push(c);i=c.double()}return f}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,f=this.BASE,i=ye(t,this.bits);for(let c=0;c<i.windows;c++){let{nextN:s,offset:l,isZero:m,isNeg:h,isNegF:B,offsetF:E}=sn(n,c,i);n=s,m?f=f.add(Vt(B,r[E])):o=o.add(Vt(h,r[l]))}return cn(n),{p:o,f}}wNAFUnsafe(t,r,n,o=this.ZERO){let f=ye(t,this.bits);for(let i=0;i<f.windows&&n!==Ot;i++){let{nextN:c,offset:s,isZero:l,isNeg:m}=sn(n,i,f);if(n=c,!l){let h=r[s];o=o.add(m?h.negate():h)}}return cn(n),o}getPrecomputes(t,r,n){let o=we.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),we.set(r,o))),o}cached(t,r,n){let o=Ee(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let f=Ee(t);return f===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(f,this.getPrecomputes(f,t,n),r,o)}createCache(t,r){dn(r,this.bits),un.set(t,r),we.delete(t)}hasCache(t){return Ee(t)!==1}};function ln(e,t,r,n){let o=t,f=e.ZERO,i=e.ZERO;for(;r>Ot||n>Ot;)r&Bt&&(f=f.add(o)),n&Bt&&(i=i.add(o)),o=o.double(),r>>=Bt,n>>=Bt;return{p1:f,p2:i}}function an(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return me(t),t}else return Rt(e,{isLE:r})}function zt(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let s of["p","n","h"]){let l=t[s];if(!(typeof l=="bigint"&&l>Ot))throw new Error(`CURVE.${s} must be positive bigint`)}let o=an(t.p,r.Fp,n),f=an(t.n,r.Fn,n),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let s of c)if(!o.isValid(t[s]))throw new Error(`CURVE.${s} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:f}}function $t(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var Pt=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(Yt(t),N(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let f=0;f<o.length;f++)o[f]^=54;this.iHash.update(o),this.oHash=t.create();for(let f=0;f<o.length;f++)o[f]^=106;this.oHash.update(o),it(o)}update(t){return St(this),this.iHash.update(t),this}digestInto(t){St(this),N(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:f,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=f,t.blockLen=i,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Be=(e,t,r)=>new Pt(e,t).update(r).digest();Be.create=(e,t)=>new Pt(e,t);var hn=(e,t)=>(e+(e>=0?t:-t)/bn)/t;function jn(e,t,r){let[[n,o],[f,i]]=t,c=hn(i*e,r),s=hn(-o*e,r),l=e-c*n-s*f,m=-c*o-s*i,h=l<dt,B=m<dt;h&&(l=-l),B&&(m=-m);let E=Zt(Math.ceil(he(r)/2))+Tt;if(l<dt||l>=E||m<dt||m>=E)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:l,k2neg:B,k2:m}}function Se(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function ve(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return at(r.lowS,"lowS"),at(r.prehash,"prehash"),r.format!==void 0&&Se(r.format),r}var _e=class extends Error{constructor(t=""){super(t)}},xt={Err:_e,_tlv:{encode:(e,t)=>{let{Err:r}=xt;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Nt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let f=n>127?Nt(o.length/2|128):"";return Nt(e)+f+o+t},decode(e,t){let{Err:r}=xt,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],f=!!(o&128),i=0;if(!f)i=o;else{let s=o&127;if(!s)throw new r("tlv.decode(long): indefinite length not supported");if(s>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+s);if(l.length!==s)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let m of l)i=i<<8|m;if(n+=s,i<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=xt;if(e<dt)throw new t("integer: negative integers are not allowed");let r=Nt(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=xt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return It(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=xt,o=N(e,void 0,"signature"),{v:f,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:s}=n.decode(2,f),{v:l,l:m}=n.decode(2,s);if(m.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=xt,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),f=n+o;return t.encode(48,f)}},dt=BigInt(0),Tt=BigInt(1),bn=BigInt(2),Qt=BigInt(3),Wn=BigInt(4);function Jt(e,t={}){let r=zt("weierstrass",e,t),{Fp:n,Fn:o}=r,f=r.CURVE,{h:i,n:c}=f;bt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:s}=t;if(s&&(!n.is0(f.a)||typeof s.beta!="bigint"||!Array.isArray(s.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=mn(n,o);function m(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function h(R,d,u){let{x:a,y}=d.toAffine(),S=n.toBytes(a);if(at(u,"isCompressed"),u){m();let A=!n.isOdd(y);return F(xn(A),S)}else return F(Uint8Array.of(4),S,n.toBytes(y))}function B(R){N(R,void 0,"Point");let{publicKey:d,publicKeyUncompressed:u}=l,a=R.length,y=R[0],S=R.subarray(1);if(a===d&&(y===2||y===3)){let A=n.fromBytes(S);if(!n.isValid(A))throw new Error("bad point: is not on curve, wrong x");let O=L(A),_;try{_=n.sqrt(O)}catch(X){let Y=X instanceof Error?": "+X.message:"";throw new Error("bad point: is not on curve, sqrt error"+Y)}m();let H=n.isOdd(_);return(y&1)===1!==H&&(_=n.neg(_)),{x:A,y:_}}else if(a===u&&y===4){let A=n.BYTES,O=n.fromBytes(S.subarray(0,A)),_=n.fromBytes(S.subarray(A,A*2));if(!v(O,_))throw new Error("bad point: is not on curve");return{x:O,y:_}}else throw new Error(`bad point: got length ${a}, expected compressed=${d} or uncompressed=${u}`)}let E=t.toBytes||h,g=t.fromBytes||B;function L(R){let d=n.sqr(R),u=n.mul(d,R);return n.add(n.add(u,n.mul(R,f.a)),f.b)}function v(R,d){let u=n.sqr(d),a=L(R);return n.eql(u,a)}if(!v(f.Gx,f.Gy))throw new Error("bad curve params: generator point");let x=n.mul(n.pow(f.a,Qt),Wn),I=n.mul(n.sqr(f.b),BigInt(27));if(n.is0(n.add(x,I)))throw new Error("bad curve params: a or b");function p(R,d,u=!1){if(!n.isValid(d)||u&&n.is0(d))throw new Error(`bad point coordinate ${R}`);return d}function T(R){if(!(R instanceof b))throw new Error("Weierstrass Point expected")}function Z(R){if(!s||!s.basises)throw new Error("no endo");return jn(R,s.basises,o.ORDER)}let V=At((R,d)=>{let{X:u,Y:a,Z:y}=R;if(n.eql(y,n.ONE))return{x:u,y:a};let S=R.is0();d==null&&(d=S?n.ONE:n.inv(y));let A=n.mul(u,d),O=n.mul(a,d),_=n.mul(y,d);if(S)return{x:n.ZERO,y:n.ZERO};if(!n.eql(_,n.ONE))throw new Error("invZ was invalid");return{x:A,y:O}}),M=At(R=>{if(R.is0()){if(t.allowInfinityPoint&&!n.is0(R.Y))return;throw new Error("bad point: ZERO")}let{x:d,y:u}=R.toAffine();if(!n.isValid(d)||!n.isValid(u))throw new Error("bad point: x or y not field elements");if(!v(d,u))throw new Error("bad point: equation left != right");if(!R.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function w(R,d,u,a,y){return u=new b(n.mul(u.X,R),u.Y,u.Z),d=Vt(a,d),u=Vt(y,u),d.add(u)}class b{static BASE=new b(f.Gx,f.Gy,n.ONE);static ZERO=new b(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(d,u,a){this.X=p("x",d),this.Y=p("y",u,!0),this.Z=p("z",a),Object.freeze(this)}static CURVE(){return f}static fromAffine(d){let{x:u,y:a}=d||{};if(!d||!n.isValid(u)||!n.isValid(a))throw new Error("invalid affine point");if(d instanceof b)throw new Error("projective point not allowed");return n.is0(u)&&n.is0(a)?b.ZERO:new b(u,a,n.ONE)}static fromBytes(d){let u=b.fromAffine(g(N(d,void 0,"point")));return u.assertValidity(),u}static fromHex(d){return b.fromBytes(nt(d))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(d=8,u=!0){return D.createCache(this,d),u||this.multiply(Qt),this}assertValidity(){M(this)}hasEvenY(){let{y:d}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(d)}equals(d){T(d);let{X:u,Y:a,Z:y}=this,{X:S,Y:A,Z:O}=d,_=n.eql(n.mul(u,O),n.mul(S,y)),H=n.eql(n.mul(a,O),n.mul(A,y));return _&&H}negate(){return new b(this.X,n.neg(this.Y),this.Z)}double(){let{a:d,b:u}=f,a=n.mul(u,Qt),{X:y,Y:S,Z:A}=this,O=n.ZERO,_=n.ZERO,H=n.ZERO,U=n.mul(y,y),X=n.mul(S,S),Y=n.mul(A,A),C=n.mul(y,S);return C=n.add(C,C),H=n.mul(y,A),H=n.add(H,H),O=n.mul(d,H),_=n.mul(a,Y),_=n.add(O,_),O=n.sub(X,_),_=n.add(X,_),_=n.mul(O,_),O=n.mul(C,O),H=n.mul(a,H),Y=n.mul(d,Y),C=n.sub(U,Y),C=n.mul(d,C),C=n.add(C,H),H=n.add(U,U),U=n.add(H,U),U=n.add(U,Y),U=n.mul(U,C),_=n.add(_,U),Y=n.mul(S,A),Y=n.add(Y,Y),U=n.mul(Y,C),O=n.sub(O,U),H=n.mul(Y,X),H=n.add(H,H),H=n.add(H,H),new b(O,_,H)}add(d){T(d);let{X:u,Y:a,Z:y}=this,{X:S,Y:A,Z:O}=d,_=n.ZERO,H=n.ZERO,U=n.ZERO,X=f.a,Y=n.mul(f.b,Qt),C=n.mul(u,S),G=n.mul(a,A),$=n.mul(y,O),rt=n.add(u,a),K=n.add(S,A);rt=n.mul(rt,K),K=n.add(C,G),rt=n.sub(rt,K),K=n.add(u,y);let Q=n.add(S,O);return K=n.mul(K,Q),Q=n.add(C,$),K=n.sub(K,Q),Q=n.add(a,y),_=n.add(A,O),Q=n.mul(Q,_),_=n.add(G,$),Q=n.sub(Q,_),U=n.mul(X,K),_=n.mul(Y,$),U=n.add(_,U),_=n.sub(G,U),U=n.add(G,U),H=n.mul(_,U),G=n.add(C,C),G=n.add(G,C),$=n.mul(X,$),K=n.mul(Y,K),G=n.add(G,$),$=n.sub(C,$),$=n.mul(X,$),K=n.add(K,$),C=n.mul(G,K),H=n.add(H,C),C=n.mul(Q,K),_=n.mul(rt,_),_=n.sub(_,C),C=n.mul(rt,G),U=n.mul(Q,U),U=n.add(U,C),new b(_,H,U)}subtract(d){return this.add(d.negate())}is0(){return this.equals(b.ZERO)}multiply(d){let{endo:u}=t;if(!o.isValidNot0(d))throw new Error("invalid scalar: out of range");let a,y,S=A=>D.cached(this,A,O=>vt(b,O));if(u){let{k1neg:A,k1:O,k2neg:_,k2:H}=Z(d),{p:U,f:X}=S(O),{p:Y,f:C}=S(H);y=X.add(C),a=w(u.beta,U,Y,A,_)}else{let{p:A,f:O}=S(d);a=A,y=O}return vt(b,[a,y])[0]}multiplyUnsafe(d){let{endo:u}=t,a=this;if(!o.isValid(d))throw new Error("invalid scalar: out of range");if(d===dt||a.is0())return b.ZERO;if(d===Tt)return a;if(D.hasCache(this))return this.multiply(d);if(u){let{k1neg:y,k1:S,k2neg:A,k2:O}=Z(d),{p1:_,p2:H}=ln(b,a,S,O);return w(u.beta,_,H,y,A)}else return D.unsafe(a,d)}toAffine(d){return V(this,d)}isTorsionFree(){let{isTorsionFree:d}=t;return i===Tt?!0:d?d(b,this):D.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:d}=t;return i===Tt?this:d?d(b,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(d=!0){return at(d,"isCompressed"),this.assertValidity(),E(b,this,d)}toHex(d=!0){return et(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let q=o.BITS,D=new Ht(b,t.endo?Math.ceil(q/2):q);return b.BASE.precompute(8),b}function xn(e){return Uint8Array.of(e?2:3)}function mn(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function zn(e,t={}){let{Fn:r}=e,n=t.randomBytes||_t,o=Object.assign(mn(e.Fp,r),{seed:pe(r.ORDER)});function f(E){try{let g=r.fromBytes(E);return r.isValidNot0(g)}catch{return!1}}function i(E,g){let{publicKey:L,publicKeyUncompressed:v}=o;try{let x=E.length;return g===!0&&x!==L||g===!1&&x!==v?!1:!!e.fromBytes(E)}catch{return!1}}function c(E=n(o.seed)){return ge(N(E,o.seed,"seed"),r.ORDER)}function s(E,g=!0){return e.BASE.multiply(r.fromBytes(E)).toBytes(g)}function l(E){let{secretKey:g,publicKey:L,publicKeyUncompressed:v}=o;if(!pt(E)||"_lengths"in r&&r._lengths||g===L)return;let x=N(E,void 0,"key").length;return x===L||x===v}function m(E,g,L=!0){if(l(E)===!0)throw new Error("first arg must be private key");if(l(g)===!1)throw new Error("second arg must be public key");let v=r.fromBytes(E);return e.fromBytes(g).multiply(v).toBytes(L)}let h={isValidSecretKey:f,isValidPublicKey:i,randomSecretKey:c},B=$t(c,s);return Object.freeze({getPublicKey:s,getSharedSecret:m,keygen:B,Point:e,utils:h,lengths:o})}function Ft(e,t,r={}){Yt(t),bt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||_t,o=r.hmac||((u,a)=>Be(t,u,a)),{Fp:f,Fn:i}=e,{ORDER:c,BITS:s}=i,{keygen:l,getPublicKey:m,getSharedSecret:h,utils:B,lengths:E}=zn(e,r),g={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},L=c*bn<f.ORDER;function v(u){let a=c>>Tt;return u>a}function x(u,a){if(!i.isValidNot0(a))throw new Error(`invalid signature ${u}: out of range 1..Point.Fn.ORDER`);return a}function I(){if(L)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function p(u,a){Se(a);let y=E.signature,S=a==="compact"?y:a==="recovered"?y+1:void 0;return N(u,S)}class T{r;s;recovery;constructor(a,y,S){if(this.r=x("r",a),this.s=x("s",y),S!=null){if(I(),![0,1,2,3].includes(S))throw new Error("invalid recovery id");this.recovery=S}Object.freeze(this)}static fromBytes(a,y=g.format){p(a,y);let S;if(y==="der"){let{r:H,s:U}=xt.toSig(N(a));return new T(H,U)}y==="recovered"&&(S=a[0],y="compact",a=a.subarray(1));let A=E.signature/2,O=a.subarray(0,A),_=a.subarray(A,A*2);return new T(i.fromBytes(O),i.fromBytes(_),S)}static fromHex(a,y){return this.fromBytes(nt(a),y)}assertRecovery(){let{recovery:a}=this;if(a==null)throw new Error("invalid recovery id: must be present");return a}addRecoveryBit(a){return new T(this.r,this.s,a)}recoverPublicKey(a){let{r:y,s:S}=this,A=this.assertRecovery(),O=A===2||A===3?y+c:y;if(!f.isValid(O))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let _=f.toBytes(O),H=e.fromBytes(F(xn((A&1)===0),_)),U=i.inv(O),X=V(N(a,void 0,"msgHash")),Y=i.create(-X*U),C=i.create(S*U),G=e.BASE.multiplyUnsafe(Y).add(H.multiplyUnsafe(C));if(G.is0())throw new Error("invalid recovery: point at infinify");return G.assertValidity(),G}hasHighS(){return v(this.s)}toBytes(a=g.format){if(Se(a),a==="der")return nt(xt.hexFromSig(this));let{r:y,s:S}=this,A=i.toBytes(y),O=i.toBytes(S);return a==="recovered"?(I(),F(Uint8Array.of(this.assertRecovery()),A,O)):F(A,O)}toHex(a){return et(this.toBytes(a))}}let Z=r.bits2int||function(a){if(a.length>8192)throw new Error("input is too large");let y=It(a),S=a.length*8-s;return S>0?y>>BigInt(S):y},V=r.bits2int_modN||function(a){return i.create(Z(a))},M=Zt(s);function w(u){return Dt("num < 2^"+s,u,dt,M),i.toBytes(u)}function b(u,a){return N(u,void 0,"message"),a?N(t(u),void 0,"prehashed message"):u}function q(u,a,y){let{lowS:S,prehash:A,extraEntropy:O}=ve(y,g);u=b(u,A);let _=V(u),H=i.fromBytes(a);if(!i.isValidNot0(H))throw new Error("invalid private key");let U=[w(H),w(_)];if(O!=null&&O!==!1){let G=O===!0?n(E.secretKey):O;U.push(N(G,void 0,"extraEntropy"))}let X=F(...U),Y=_;function C(G){let $=Z(G);if(!i.isValidNot0($))return;let rt=i.inv($),K=e.BASE.multiply($).toAffine(),Q=i.create(K.x);if(Q===dt)return;let Mt=i.create(rt*i.create(Y+Q*H));if(Mt===dt)return;let He=(K.x===Q?0:2)|Number(K.y&Tt),Te=Mt;return S&&v(Mt)&&(Te=i.neg(Mt),He^=1),new T(Q,Te,L?void 0:He)}return{seed:X,k2sig:C}}function D(u,a,y={}){let{seed:S,k2sig:A}=q(u,a,y);return ze(t.outputLen,i.BYTES,o)(S,A).toBytes(y.format)}function R(u,a,y,S={}){let{lowS:A,prehash:O,format:_}=ve(S,g);if(y=N(y,void 0,"publicKey"),a=b(a,O),!pt(u)){let H=u instanceof T?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+H)}p(u,_);try{let H=T.fromBytes(u,_),U=e.fromBytes(y);if(A&&H.hasHighS())return!1;let{r:X,s:Y}=H,C=V(a),G=i.inv(Y),$=i.create(C*G),rt=i.create(X*G),K=e.BASE.multiplyUnsafe($).add(U.multiplyUnsafe(rt));return K.is0()?!1:i.create(K.x)===X}catch{return!1}}function d(u,a,y={}){let{prehash:S}=ve(y,g);return a=b(a,S),T.fromBytes(u,"recovered").recoverPublicKey(a).toBytes()}return Object.freeze({keygen:l,getPublicKey:m,getSharedSecret:h,utils:B,lengths:E,Point:e,sign:D,verify:R,recoverPublicKey:d,Signature:T,hash:t})}var Ae={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Pn={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var pn=BigInt(2);function Qn(e){let t=Ae.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),f=BigInt(22),i=BigInt(23),c=BigInt(44),s=BigInt(88),l=e*e*e%t,m=l*l*e%t,h=k(m,r,t)*m%t,B=k(h,r,t)*m%t,E=k(B,pn,t)*l%t,g=k(E,o,t)*E%t,L=k(g,f,t)*g%t,v=k(L,c,t)*L%t,x=k(v,s,t)*v%t,I=k(x,c,t)*L%t,p=k(I,r,t)*m%t,T=k(p,i,t)*g%t,Z=k(T,n,t)*l%t,V=k(Z,pn,t);if(!Ie.eql(Ie.sqr(V),e))throw new Error("Cannot find square root");return V}var Ie=Rt(Ae.p,{sqrt:Qn}),Jn=Jt(Ae,{Fp:Ie,endo:Pn}),gn=Ft(Jn,Gt);var mt=BigInt(0),z=BigInt(1),Re=BigInt(2),Fn=BigInt(8);function tr(e,t,r,n){let o=e.sqr(r),f=e.sqr(n),i=e.add(e.mul(t.a,o),f),c=e.add(e.ONE,e.mul(t.d,e.mul(o,f)));return e.eql(i,c)}function yn(e,t={}){let r=zt("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,f=r.CURVE,{h:i}=f;bt(t,{},{uvRatio:"function"});let c=Re<<BigInt(o.BYTES*8)-z,s=v=>n.create(v),l=t.uvRatio||((v,x)=>{try{return{isValid:!0,value:n.sqrt(n.div(v,x))}}catch{return{isValid:!1,value:mt}}});if(!tr(n,f,f.Gx,f.Gy))throw new Error("bad curve params: generator point");function m(v,x,I=!1){let p=I?z:mt;return Dt("coordinate "+v,x,p,c),x}function h(v){if(!(v instanceof g))throw new Error("EdwardsPoint expected")}let B=At((v,x)=>{let{X:I,Y:p,Z:T}=v,Z=v.is0();x==null&&(x=Z?Fn:n.inv(T));let V=s(I*x),M=s(p*x),w=n.mul(T,x);if(Z)return{x:mt,y:z};if(w!==z)throw new Error("invZ was invalid");return{x:V,y:M}}),E=At(v=>{let{a:x,d:I}=f;if(v.is0())throw new Error("bad point: ZERO");let{X:p,Y:T,Z,T:V}=v,M=s(p*p),w=s(T*T),b=s(Z*Z),q=s(b*b),D=s(M*x),R=s(b*s(D+w)),d=s(q+s(I*s(M*w)));if(R!==d)throw new Error("bad point: equation left != right (1)");let u=s(p*T),a=s(Z*V);if(u!==a)throw new Error("bad point: equation left != right (2)");return!0});class g{static BASE=new g(f.Gx,f.Gy,z,s(f.Gx*f.Gy));static ZERO=new g(mt,z,z,mt);static Fp=n;static Fn=o;X;Y;Z;T;constructor(x,I,p,T){this.X=m("x",x),this.Y=m("y",I),this.Z=m("z",p,!0),this.T=m("t",T),Object.freeze(this)}static CURVE(){return f}static fromAffine(x){if(x instanceof g)throw new Error("extended point not allowed");let{x:I,y:p}=x||{};return m("x",I),m("y",p),new g(I,p,z,s(I*p))}static fromBytes(x,I=!1){let p=n.BYTES,{a:T,d:Z}=f;x=Wt(N(x,p,"point")),at(I,"zip215");let V=Wt(x),M=x[p-1];V[p-1]=M&-129;let w=wt(V),b=I?c:n.ORDER;Dt("point.y",w,mt,b);let q=s(w*w),D=s(q-z),R=s(Z*q-T),{isValid:d,value:u}=l(D,R);if(!d)throw new Error("bad point: invalid y coordinate");let a=(u&z)===z,y=(M&128)!==0;if(!I&&u===mt&&y)throw new Error("bad point: x=0 and x_0=1");return y!==a&&(u=s(-u)),g.fromAffine({x:u,y:w})}static fromHex(x,I=!1){return g.fromBytes(nt(x),I)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,I=!0){return L.createCache(this,x),I||this.multiply(Re),this}assertValidity(){E(this)}equals(x){h(x);let{X:I,Y:p,Z:T}=this,{X:Z,Y:V,Z:M}=x,w=s(I*M),b=s(Z*T),q=s(p*M),D=s(V*T);return w===b&&q===D}is0(){return this.equals(g.ZERO)}negate(){return new g(s(-this.X),this.Y,this.Z,s(-this.T))}double(){let{a:x}=f,{X:I,Y:p,Z:T}=this,Z=s(I*I),V=s(p*p),M=s(Re*s(T*T)),w=s(x*Z),b=I+p,q=s(s(b*b)-Z-V),D=w+V,R=D-M,d=w-V,u=s(q*R),a=s(D*d),y=s(q*d),S=s(R*D);return new g(u,a,S,y)}add(x){h(x);let{a:I,d:p}=f,{X:T,Y:Z,Z:V,T:M}=this,{X:w,Y:b,Z:q,T:D}=x,R=s(T*w),d=s(Z*b),u=s(M*p*D),a=s(V*q),y=s((T+Z)*(w+b)-R-d),S=a-u,A=a+u,O=s(d-I*R),_=s(y*S),H=s(A*O),U=s(y*O),X=s(S*A);return new g(_,H,X,U)}subtract(x){return this.add(x.negate())}multiply(x){if(!o.isValidNot0(x))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:I,f:p}=L.cached(this,x,T=>vt(g,T));return vt(g,[I,p])[0]}multiplyUnsafe(x,I=g.ZERO){if(!o.isValid(x))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return x===mt?g.ZERO:this.is0()||x===z?this:L.unsafe(this,x,p=>vt(g,p),I)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return L.unsafe(this,f.n).is0()}toAffine(x){return B(this,x)}clearCofactor(){return i===z?this:this.multiplyUnsafe(i)}toBytes(){let{x,y:I}=this.toAffine(),p=n.toBytes(I);return p[p.length-1]|=x&z?128:0,p}toHex(){return et(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let L=new Ht(g,o.BITS);return g.BASE.precompute(8),g}function wn(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');bt(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:f,Fn:i}=e,c=r.randomBytes||_t,s=r.adjustScalarBytes||(w=>w),l=r.domain||((w,b,q)=>{if(at(q,"phflag"),b.length||q)throw new Error("Contexts/pre-hash are not supported");return w});function m(w){return i.create(wt(w))}function h(w){let b=p.secretKey;N(w,p.secretKey,"secretKey");let q=N(t(w),2*b,"hashedSecretKey"),D=s(q.slice(0,b)),R=q.slice(b,2*b),d=m(D);return{head:D,prefix:R,scalar:d}}function B(w){let{head:b,prefix:q,scalar:D}=h(w),R=o.multiply(D),d=R.toBytes();return{head:b,prefix:q,scalar:D,point:R,pointBytes:d}}function E(w){return B(w).pointBytes}function g(w=Uint8Array.of(),...b){let q=F(...b);return m(t(l(q,N(w,void 0,"context"),!!n)))}function L(w,b,q={}){w=N(w,void 0,"message"),n&&(w=n(w));let{prefix:D,scalar:R,pointBytes:d}=B(b),u=g(q.context,D,w),a=o.multiply(u).toBytes(),y=g(q.context,a,d,w),S=i.create(u+y*R);if(!i.isValid(S))throw new Error("sign failed: invalid s");let A=F(a,i.toBytes(S));return N(A,p.signature,"result")}let v={zip215:!0};function x(w,b,q,D=v){let{context:R,zip215:d}=D,u=p.signature;w=N(w,u,"signature"),b=N(b,void 0,"message"),q=N(q,p.publicKey,"publicKey"),d!==void 0&&at(d,"zip215"),n&&(b=n(b));let a=u/2,y=w.subarray(0,a),S=wt(w.subarray(a,u)),A,O,_;try{A=e.fromBytes(q,d),O=e.fromBytes(y,d),_=o.multiplyUnsafe(S)}catch{return!1}if(!d&&A.isSmallOrder())return!1;let H=g(R,O.toBytes(),A.toBytes(),b);return O.add(A.multiplyUnsafe(H)).subtract(_).clearCofactor().is0()}let I=f.BYTES,p={secretKey:I,publicKey:I,signature:2*I,seed:I};function T(w=c(p.seed)){return N(w,p.seed,"seed")}function Z(w){return pt(w)&&w.length===i.BYTES}function V(w,b){try{return!!e.fromBytes(w,b)}catch{return!1}}let M={getExtendedPublicKey:B,randomSecretKey:T,isValidSecretKey:Z,isValidPublicKey:V,toMontgomery(w){let{y:b}=e.fromBytes(w),q=p.publicKey,D=q===32;if(!D&&q!==57)throw new Error("only defined for 25519 and 448");let R=D?f.div(z+b,z-b):f.div(b-z,b+z);return f.toBytes(R)},toMontgomerySecret(w){let b=p.secretKey;N(w,b);let q=t(w.subarray(0,b));return s(q).subarray(0,b)}};return Object.freeze({keygen:$t(T,E),getPublicKey:E,sign:L,verify:x,utils:M,Point:e,lengths:p})}var er=BigInt(1),En=BigInt(2);var nr=BigInt(5),rr=BigInt(8),Oe=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),or={p:Oe,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:rr,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function fr(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),f=Oe,c=e*e%f*e%f,s=k(c,En,f)*c%f,l=k(s,er,f)*e%f,m=k(l,nr,f)*l%f,h=k(m,t,f)*m%f,B=k(h,r,f)*h%f,E=k(B,n,f)*B%f,g=k(E,o,f)*E%f,L=k(g,o,f)*E%f,v=k(L,t,f)*m%f;return{pow_p_5_8:k(v,En,f)*e%f,b2:c}}function sr(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Bn=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function ir(e,t){let r=Oe,n=j(t*t*t,r),o=j(n*n*t,r),f=fr(e*o).pow_p_5_8,i=j(e*n*f,r),c=j(t*i*i,r),s=i,l=j(i*Bn,r),m=c===e,h=c===j(-e,r),B=c===j(-e*Bn,r);return m&&(i=s),(h||B)&&(i=l),on(i,r)&&(i=j(-i,r)),{isValid:m||h,value:i}}var cr=yn(or,{uvRatio:ir});function ar(e){return wn(cr,ae,Object.assign({adjustScalarBytes:sr},e))}var vn=ar({});var dr={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var ur=Jt(dr),Sn=Ft(ur,Gt);return Hn(lr);})();
12−/*! Bundled license information:
13−
14−@noble/hashes/utils.js:
15− (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
16−
17−@noble/curves/utils.js:
18−@noble/curves/abstract/modular.js:
19−@noble/curves/abstract/curve.js:
20−@noble/curves/abstract/weierstrass.js:
21−@noble/curves/secp256k1.js:
22−@noble/curves/abstract/edwards.js:
23−@noble/curves/ed25519.js:
24−@noble/curves/nist.js:
25− (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26−*/
27−
28−
29−// UTILS
8+// TWEETNACL BUNDLE (https://github.com/nicolo-ribaudo/tweetnacl-js, Unlicense)
9+// Embedded: tweetnacl 1.0.3 - Ed25519, X25519, XSalsa20-Poly1305
3010
31−var _Crypto_toHex = _Crypto_noble.bytesToHex;
32−var _Crypto_fromHex = _Crypto_noble.hexToBytes;
11+var _Crypto_nacl={};(function(i){"use strict";var v=function(r){var t,n=new Float64Array(16);if(r)for(t=0;t<r.length;t++)n[t]=r[t];return n},h=function(){throw new Error("no PRNG")},o=new Uint8Array(16),n=new Uint8Array(32);n[0]=9;var s=v(),u=v([1]),p=v([56129,1]),c=v([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),y=v([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),e=v([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),a=v([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=v([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function f(r,t,n,e){r[t]=n>>24&255,r[t+1]=n>>16&255,r[t+2]=n>>8&255,r[t+3]=255&n,r[t+4]=e>>24&255,r[t+5]=e>>16&255,r[t+6]=e>>8&255,r[t+7]=255&e}function w(r,t,n,e,o){var i,h=0;for(i=0;i<o;i++)h|=r[t+i]^n[e+i];return(1&h-1>>>8)-1}function b(r,t,n,e){return w(r,t,n,e,16)}function g(r,t,n,e){return w(r,t,n,e,32)}function A(r,t,n,e){!function(r,t,n,e){for(var o,i=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,h=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,f=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,s=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,y=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,w=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,v=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,g=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,A=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,_=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,U=i,d=h,E=a,x=f,M=s,m=u,B=c,S=y,k=l,K=w,Y=v,L=p,T=b,z=g,R=A,P=_,N=0;N<20;N+=2)U^=(o=(T^=(o=(k^=(o=(M^=(o=U+T|0)<<7|o>>>25)+U|0)<<9|o>>>23)+M|0)<<13|o>>>19)+k|0)<<18|o>>>14,m^=(o=(d^=(o=(z^=(o=(K^=(o=m+d|0)<<7|o>>>25)+m|0)<<9|o>>>23)+K|0)<<13|o>>>19)+z|0)<<18|o>>>14,Y^=(o=(B^=(o=(E^=(o=(R^=(o=Y+B|0)<<7|o>>>25)+Y|0)<<9|o>>>23)+R|0)<<13|o>>>19)+E|0)<<18|o>>>14,P^=(o=(L^=(o=(S^=(o=(x^=(o=P+L|0)<<7|o>>>25)+P|0)<<9|o>>>23)+x|0)<<13|o>>>19)+S|0)<<18|o>>>14,U^=(o=(x^=(o=(E^=(o=(d^=(o=U+x|0)<<7|o>>>25)+U|0)<<9|o>>>23)+d|0)<<13|o>>>19)+E|0)<<18|o>>>14,m^=(o=(M^=(o=(S^=(o=(B^=(o=m+M|0)<<7|o>>>25)+m|0)<<9|o>>>23)+B|0)<<13|o>>>19)+S|0)<<18|o>>>14,Y^=(o=(K^=(o=(k^=(o=(L^=(o=Y+K|0)<<7|o>>>25)+Y|0)<<9|o>>>23)+L|0)<<13|o>>>19)+k|0)<<18|o>>>14,P^=(o=(R^=(o=(z^=(o=(T^=(o=P+R|0)<<7|o>>>25)+P|0)<<9|o>>>23)+T|0)<<13|o>>>19)+z|0)<<18|o>>>14;U=U+i|0,d=d+h|0,E=E+a|0,x=x+f|0,M=M+s|0,m=m+u|0,B=B+c|0,S=S+y|0,k=k+l|0,K=K+w|0,Y=Y+v|0,L=L+p|0,T=T+b|0,z=z+g|0,R=R+A|0,P=P+_|0,r[0]=U>>>0&255,r[1]=U>>>8&255,r[2]=U>>>16&255,r[3]=U>>>24&255,r[4]=d>>>0&255,r[5]=d>>>8&255,r[6]=d>>>16&255,r[7]=d>>>24&255,r[8]=E>>>0&255,r[9]=E>>>8&255,r[10]=E>>>16&255,r[11]=E>>>24&255,r[12]=x>>>0&255,r[13]=x>>>8&255,r[14]=x>>>16&255,r[15]=x>>>24&255,r[16]=M>>>0&255,r[17]=M>>>8&255,r[18]=M>>>16&255,r[19]=M>>>24&255,r[20]=m>>>0&255,r[21]=m>>>8&255,r[22]=m>>>16&255,r[23]=m>>>24&255,r[24]=B>>>0&255,r[25]=B>>>8&255,r[26]=B>>>16&255,r[27]=B>>>24&255,r[28]=S>>>0&255,r[29]=S>>>8&255,r[30]=S>>>16&255,r[31]=S>>>24&255,r[32]=k>>>0&255,r[33]=k>>>8&255,r[34]=k>>>16&255,r[35]=k>>>24&255,r[36]=K>>>0&255,r[37]=K>>>8&255,r[38]=K>>>16&255,r[39]=K>>>24&255,r[40]=Y>>>0&255,r[41]=Y>>>8&255,r[42]=Y>>>16&255,r[43]=Y>>>24&255,r[44]=L>>>0&255,r[45]=L>>>8&255,r[46]=L>>>16&255,r[47]=L>>>24&255,r[48]=T>>>0&255,r[49]=T>>>8&255,r[50]=T>>>16&255,r[51]=T>>>24&255,r[52]=z>>>0&255,r[53]=z>>>8&255,r[54]=z>>>16&255,r[55]=z>>>24&255,r[56]=R>>>0&255,r[57]=R>>>8&255,r[58]=R>>>16&255,r[59]=R>>>24&255,r[60]=P>>>0&255,r[61]=P>>>8&255,r[62]=P>>>16&255,r[63]=P>>>24&255}(r,t,n,e)}function _(r,t,n,e){!function(r,t,n,e){for(var o,i=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,h=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,f=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,s=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,y=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,w=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,v=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,g=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,A=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,_=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,U=0;U<20;U+=2)i^=(o=(b^=(o=(l^=(o=(s^=(o=i+b|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+l|0)<<18|o>>>14,u^=(o=(h^=(o=(g^=(o=(w^=(o=u+h|0)<<7|o>>>25)+u|0)<<9|o>>>23)+w|0)<<13|o>>>19)+g|0)<<18|o>>>14,v^=(o=(c^=(o=(a^=(o=(A^=(o=v+c|0)<<7|o>>>25)+v|0)<<9|o>>>23)+A|0)<<13|o>>>19)+a|0)<<18|o>>>14,_^=(o=(p^=(o=(y^=(o=(f^=(o=_+p|0)<<7|o>>>25)+_|0)<<9|o>>>23)+f|0)<<13|o>>>19)+y|0)<<18|o>>>14,i^=(o=(f^=(o=(a^=(o=(h^=(o=i+f|0)<<7|o>>>25)+i|0)<<9|o>>>23)+h|0)<<13|o>>>19)+a|0)<<18|o>>>14,u^=(o=(s^=(o=(y^=(o=(c^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+c|0)<<13|o>>>19)+y|0)<<18|o>>>14,v^=(o=(w^=(o=(l^=(o=(p^=(o=v+w|0)<<7|o>>>25)+v|0)<<9|o>>>23)+p|0)<<13|o>>>19)+l|0)<<18|o>>>14,_^=(o=(A^=(o=(g^=(o=(b^=(o=_+A|0)<<7|o>>>25)+_|0)<<9|o>>>23)+b|0)<<13|o>>>19)+g|0)<<18|o>>>14;r[0]=i>>>0&255,r[1]=i>>>8&255,r[2]=i>>>16&255,r[3]=i>>>24&255,r[4]=u>>>0&255,r[5]=u>>>8&255,r[6]=u>>>16&255,r[7]=u>>>24&255,r[8]=v>>>0&255,r[9]=v>>>8&255,r[10]=v>>>16&255,r[11]=v>>>24&255,r[12]=_>>>0&255,r[13]=_>>>8&255,r[14]=_>>>16&255,r[15]=_>>>24&255,r[16]=c>>>0&255,r[17]=c>>>8&255,r[18]=c>>>16&255,r[19]=c>>>24&255,r[20]=y>>>0&255,r[21]=y>>>8&255,r[22]=y>>>16&255,r[23]=y>>>24&255,r[24]=l>>>0&255,r[25]=l>>>8&255,r[26]=l>>>16&255,r[27]=l>>>24&255,r[28]=w>>>0&255,r[29]=w>>>8&255,r[30]=w>>>16&255,r[31]=w>>>24&255}(r,t,n,e)}var U=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function d(r,t,n,e,o,i,h){var a,f,s=new Uint8Array(16),u=new Uint8Array(64);for(f=0;f<16;f++)s[f]=0;for(f=0;f<8;f++)s[f]=i[f];for(;64<=o;){for(A(u,s,h,U),f=0;f<64;f++)r[t+f]=n[e+f]^u[f];for(a=1,f=8;f<16;f++)a=a+(255&s[f])|0,s[f]=255&a,a>>>=8;o-=64,t+=64,e+=64}if(0<o)for(A(u,s,h,U),f=0;f<o;f++)r[t+f]=n[e+f]^u[f];return 0}function E(r,t,n,e,o){var i,h,a=new Uint8Array(16),f=new Uint8Array(64);for(h=0;h<16;h++)a[h]=0;for(h=0;h<8;h++)a[h]=e[h];for(;64<=n;){for(A(f,a,o,U),h=0;h<64;h++)r[t+h]=f[h];for(i=1,h=8;h<16;h++)i=i+(255&a[h])|0,a[h]=255&i,i>>>=8;n-=64,t+=64}if(0<n)for(A(f,a,o,U),h=0;h<n;h++)r[t+h]=f[h];return 0}function x(r,t,n,e,o){var i=new Uint8Array(32);_(i,e,o,U);for(var h=new Uint8Array(8),a=0;a<8;a++)h[a]=e[a+16];return E(r,t,n,h,i)}function M(r,t,n,e,o,i,h){var a=new Uint8Array(32);_(a,i,h,U);for(var f=new Uint8Array(8),s=0;s<8;s++)f[s]=i[s+16];return d(r,t,n,e,o,f,a)}var m=function(r){var t,n,e,o,i,h,a,f;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,t=255&r[this.fin=0]|(255&r[1])<<8,this.r[0]=8191&t,n=255&r[2]|(255&r[3])<<8,this.r[1]=8191&(t>>>13|n<<3),e=255&r[4]|(255&r[5])<<8,this.r[2]=7939&(n>>>10|e<<6),o=255&r[6]|(255&r[7])<<8,this.r[3]=8191&(e>>>7|o<<9),i=255&r[8]|(255&r[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,h=255&r[10]|(255&r[11])<<8,this.r[6]=8191&(i>>>14|h<<2),a=255&r[12]|(255&r[13])<<8,this.r[7]=8065&(h>>>11|a<<5),f=255&r[14]|(255&r[15])<<8,this.r[8]=8191&(a>>>8|f<<8),this.r[9]=f>>>5&127,this.pad[0]=255&r[16]|(255&r[17])<<8,this.pad[1]=255&r[18]|(255&r[19])<<8,this.pad[2]=255&r[20]|(255&r[21])<<8,this.pad[3]=255&r[22]|(255&r[23])<<8,this.pad[4]=255&r[24]|(255&r[25])<<8,this.pad[5]=255&r[26]|(255&r[27])<<8,this.pad[6]=255&r[28]|(255&r[29])<<8,this.pad[7]=255&r[30]|(255&r[31])<<8};function B(r,t,n,e,o,i){var h=new m(i);return h.update(n,e,o),h.finish(r,t),0}function S(r,t,n,e,o,i){var h=new Uint8Array(16);return B(h,0,n,e,o,i),b(r,t,h,0)}function k(r,t,n,e,o){var i;if(n<32)return-1;for(M(r,0,t,0,n,e,o),B(r,16,r,32,n-32,r),i=0;i<16;i++)r[i]=0;return 0}function K(r,t,n,e,o){var i,h=new Uint8Array(32);if(n<32)return-1;if(x(h,0,32,e,o),0!==S(t,16,t,32,n-32,h))return-1;for(M(r,0,t,0,n,e,o),i=0;i<32;i++)r[i]=0;return 0}function Y(r,t){var n;for(n=0;n<16;n++)r[n]=0|t[n]}function L(r){var t,n,e=1;for(t=0;t<16;t++)n=r[t]+e+65535,e=Math.floor(n/65536),r[t]=n-65536*e;r[0]+=e-1+37*(e-1)}function T(r,t,n){for(var e,o=~(n-1),i=0;i<16;i++)e=o&(r[i]^t[i]),r[i]^=e,t[i]^=e}function z(r,t){var n,e,o,i=v(),h=v();for(n=0;n<16;n++)h[n]=t[n];for(L(h),L(h),L(h),e=0;e<2;e++){for(i[0]=h[0]-65517,n=1;n<15;n++)i[n]=h[n]-65535-(i[n-1]>>16&1),i[n-1]&=65535;i[15]=h[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,T(h,i,1-o)}for(n=0;n<16;n++)r[2*n]=255&h[n],r[2*n+1]=h[n]>>8}function R(r,t){var n=new Uint8Array(32),e=new Uint8Array(32);return z(n,r),z(e,t),g(n,0,e,0)}function P(r){var t=new Uint8Array(32);return z(t,r),1&t[0]}function N(r,t){var n;for(n=0;n<16;n++)r[n]=t[2*n]+(t[2*n+1]<<8);r[15]&=32767}function O(r,t,n){for(var e=0;e<16;e++)r[e]=t[e]+n[e]}function C(r,t,n){for(var e=0;e<16;e++)r[e]=t[e]-n[e]}function F(r,t,n){var e,o,i=0,h=0,a=0,f=0,s=0,u=0,c=0,y=0,l=0,w=0,v=0,p=0,b=0,g=0,A=0,_=0,U=0,d=0,E=0,x=0,M=0,m=0,B=0,S=0,k=0,K=0,Y=0,L=0,T=0,z=0,R=0,P=n[0],N=n[1],O=n[2],C=n[3],F=n[4],I=n[5],Z=n[6],G=n[7],q=n[8],D=n[9],V=n[10],X=n[11],j=n[12],H=n[13],J=n[14],Q=n[15];i+=(e=t[0])*P,h+=e*N,a+=e*O,f+=e*C,s+=e*F,u+=e*I,c+=e*Z,y+=e*G,l+=e*q,w+=e*D,v+=e*V,p+=e*X,b+=e*j,g+=e*H,A+=e*J,_+=e*Q,h+=(e=t[1])*P,a+=e*N,f+=e*O,s+=e*C,u+=e*F,c+=e*I,y+=e*Z,l+=e*G,w+=e*q,v+=e*D,p+=e*V,b+=e*X,g+=e*j,A+=e*H,_+=e*J,U+=e*Q,a+=(e=t[2])*P,f+=e*N,s+=e*O,u+=e*C,c+=e*F,y+=e*I,l+=e*Z,w+=e*G,v+=e*q,p+=e*D,b+=e*V,g+=e*X,A+=e*j,_+=e*H,U+=e*J,d+=e*Q,f+=(e=t[3])*P,s+=e*N,u+=e*O,c+=e*C,y+=e*F,l+=e*I,w+=e*Z,v+=e*G,p+=e*q,b+=e*D,g+=e*V,A+=e*X,_+=e*j,U+=e*H,d+=e*J,E+=e*Q,s+=(e=t[4])*P,u+=e*N,c+=e*O,y+=e*C,l+=e*F,w+=e*I,v+=e*Z,p+=e*G,b+=e*q,g+=e*D,A+=e*V,_+=e*X,U+=e*j,d+=e*H,E+=e*J,x+=e*Q,u+=(e=t[5])*P,c+=e*N,y+=e*O,l+=e*C,w+=e*F,v+=e*I,p+=e*Z,b+=e*G,g+=e*q,A+=e*D,_+=e*V,U+=e*X,d+=e*j,E+=e*H,x+=e*J,M+=e*Q,c+=(e=t[6])*P,y+=e*N,l+=e*O,w+=e*C,v+=e*F,p+=e*I,b+=e*Z,g+=e*G,A+=e*q,_+=e*D,U+=e*V,d+=e*X,E+=e*j,x+=e*H,M+=e*J,m+=e*Q,y+=(e=t[7])*P,l+=e*N,w+=e*O,v+=e*C,p+=e*F,b+=e*I,g+=e*Z,A+=e*G,_+=e*q,U+=e*D,d+=e*V,E+=e*X,x+=e*j,M+=e*H,m+=e*J,B+=e*Q,l+=(e=t[8])*P,w+=e*N,v+=e*O,p+=e*C,b+=e*F,g+=e*I,A+=e*Z,_+=e*G,U+=e*q,d+=e*D,E+=e*V,x+=e*X,M+=e*j,m+=e*H,B+=e*J,S+=e*Q,w+=(e=t[9])*P,v+=e*N,p+=e*O,b+=e*C,g+=e*F,A+=e*I,_+=e*Z,U+=e*G,d+=e*q,E+=e*D,x+=e*V,M+=e*X,m+=e*j,B+=e*H,S+=e*J,k+=e*Q,v+=(e=t[10])*P,p+=e*N,b+=e*O,g+=e*C,A+=e*F,_+=e*I,U+=e*Z,d+=e*G,E+=e*q,x+=e*D,M+=e*V,m+=e*X,B+=e*j,S+=e*H,k+=e*J,K+=e*Q,p+=(e=t[11])*P,b+=e*N,g+=e*O,A+=e*C,_+=e*F,U+=e*I,d+=e*Z,E+=e*G,x+=e*q,M+=e*D,m+=e*V,B+=e*X,S+=e*j,k+=e*H,K+=e*J,Y+=e*Q,b+=(e=t[12])*P,g+=e*N,A+=e*O,_+=e*C,U+=e*F,d+=e*I,E+=e*Z,x+=e*G,M+=e*q,m+=e*D,B+=e*V,S+=e*X,k+=e*j,K+=e*H,Y+=e*J,L+=e*Q,g+=(e=t[13])*P,A+=e*N,_+=e*O,U+=e*C,d+=e*F,E+=e*I,x+=e*Z,M+=e*G,m+=e*q,B+=e*D,S+=e*V,k+=e*X,K+=e*j,Y+=e*H,L+=e*J,T+=e*Q,A+=(e=t[14])*P,_+=e*N,U+=e*O,d+=e*C,E+=e*F,x+=e*I,M+=e*Z,m+=e*G,B+=e*q,S+=e*D,k+=e*V,K+=e*X,Y+=e*j,L+=e*H,T+=e*J,z+=e*Q,_+=(e=t[15])*P,h+=38*(d+=e*O),a+=38*(E+=e*C),f+=38*(x+=e*F),s+=38*(M+=e*I),u+=38*(m+=e*Z),c+=38*(B+=e*G),y+=38*(S+=e*q),l+=38*(k+=e*D),w+=38*(K+=e*V),v+=38*(Y+=e*X),p+=38*(L+=e*j),b+=38*(T+=e*H),g+=38*(z+=e*J),A+=38*(R+=e*Q),i=(e=(i+=38*(U+=e*N))+(o=1)+65535)-65536*(o=Math.floor(e/65536)),h=(e=h+o+65535)-65536*(o=Math.floor(e/65536)),a=(e=a+o+65535)-65536*(o=Math.floor(e/65536)),f=(e=f+o+65535)-65536*(o=Math.floor(e/65536)),s=(e=s+o+65535)-65536*(o=Math.floor(e/65536)),u=(e=u+o+65535)-65536*(o=Math.floor(e/65536)),c=(e=c+o+65535)-65536*(o=Math.floor(e/65536)),y=(e=y+o+65535)-65536*(o=Math.floor(e/65536)),l=(e=l+o+65535)-65536*(o=Math.floor(e/65536)),w=(e=w+o+65535)-65536*(o=Math.floor(e/65536)),v=(e=v+o+65535)-65536*(o=Math.floor(e/65536)),p=(e=p+o+65535)-65536*(o=Math.floor(e/65536)),b=(e=b+o+65535)-65536*(o=Math.floor(e/65536)),g=(e=g+o+65535)-65536*(o=Math.floor(e/65536)),A=(e=A+o+65535)-65536*(o=Math.floor(e/65536)),_=(e=_+o+65535)-65536*(o=Math.floor(e/65536)),i=(e=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(e/65536)),h=(e=h+o+65535)-65536*(o=Math.floor(e/65536)),a=(e=a+o+65535)-65536*(o=Math.floor(e/65536)),f=(e=f+o+65535)-65536*(o=Math.floor(e/65536)),s=(e=s+o+65535)-65536*(o=Math.floor(e/65536)),u=(e=u+o+65535)-65536*(o=Math.floor(e/65536)),c=(e=c+o+65535)-65536*(o=Math.floor(e/65536)),y=(e=y+o+65535)-65536*(o=Math.floor(e/65536)),l=(e=l+o+65535)-65536*(o=Math.floor(e/65536)),w=(e=w+o+65535)-65536*(o=Math.floor(e/65536)),v=(e=v+o+65535)-65536*(o=Math.floor(e/65536)),p=(e=p+o+65535)-65536*(o=Math.floor(e/65536)),b=(e=b+o+65535)-65536*(o=Math.floor(e/65536)),g=(e=g+o+65535)-65536*(o=Math.floor(e/65536)),A=(e=A+o+65535)-65536*(o=Math.floor(e/65536)),_=(e=_+o+65535)-65536*(o=Math.floor(e/65536)),i+=o-1+37*(o-1),r[0]=i,r[1]=h,r[2]=a,r[3]=f,r[4]=s,r[5]=u,r[6]=c,r[7]=y,r[8]=l,r[9]=w,r[10]=v,r[11]=p,r[12]=b,r[13]=g,r[14]=A,r[15]=_}function I(r,t){F(r,t,t)}function Z(r,t){var n,e=v();for(n=0;n<16;n++)e[n]=t[n];for(n=253;0<=n;n--)I(e,e),2!==n&&4!==n&&F(e,e,t);for(n=0;n<16;n++)r[n]=e[n]}function G(r,t){var n,e=v();for(n=0;n<16;n++)e[n]=t[n];for(n=250;0<=n;n--)I(e,e),1!==n&&F(e,e,t);for(n=0;n<16;n++)r[n]=e[n]}function q(r,t,n){var e,o,i=new Uint8Array(32),h=new Float64Array(80),a=v(),f=v(),s=v(),u=v(),c=v(),y=v();for(o=0;o<31;o++)i[o]=t[o];for(i[31]=127&t[31]|64,i[0]&=248,N(h,n),o=0;o<16;o++)f[o]=h[o],u[o]=a[o]=s[o]=0;for(a[0]=u[0]=1,o=254;0<=o;--o)T(a,f,e=i[o>>>3]>>>(7&o)&1),T(s,u,e),O(c,a,s),C(a,a,s),O(s,f,u),C(f,f,u),I(u,c),I(y,a),F(a,s,a),F(s,f,c),O(c,a,s),C(a,a,s),I(f,a),C(s,u,y),F(a,s,p),O(a,a,u),F(s,s,a),F(a,u,y),F(u,f,h),I(f,c),T(a,f,e),T(s,u,e);for(o=0;o<16;o++)h[o+16]=a[o],h[o+32]=s[o],h[o+48]=f[o],h[o+64]=u[o];var l=h.subarray(32),w=h.subarray(16);return Z(l,l),F(w,w,l),z(r,w),0}function D(r,t){return q(r,t,n)}function V(r,t){return h(t,32),D(r,t)}function X(r,t,n){var e=new Uint8Array(32);return q(e,n,t),_(r,o,e,U)}m.prototype.blocks=function(r,t,n){for(var e,o,i,h,a,f,s,u,c,y,l,w,v,p,b,g,A,_,U,d=this.fin?0:2048,E=this.h[0],x=this.h[1],M=this.h[2],m=this.h[3],B=this.h[4],S=this.h[5],k=this.h[6],K=this.h[7],Y=this.h[8],L=this.h[9],T=this.r[0],z=this.r[1],R=this.r[2],P=this.r[3],N=this.r[4],O=this.r[5],C=this.r[6],F=this.r[7],I=this.r[8],Z=this.r[9];16<=n;)y=c=0,y+=(E+=8191&(e=255&r[t+0]|(255&r[t+1])<<8))*T,y+=(x+=8191&(e>>>13|(o=255&r[t+2]|(255&r[t+3])<<8)<<3))*(5*Z),y+=(M+=8191&(o>>>10|(i=255&r[t+4]|(255&r[t+5])<<8)<<6))*(5*I),y+=(m+=8191&(i>>>7|(h=255&r[t+6]|(255&r[t+7])<<8)<<9))*(5*F),c=(y+=(B+=8191&(h>>>4|(a=255&r[t+8]|(255&r[t+9])<<8)<<12))*(5*C))>>>13,y&=8191,y+=(S+=a>>>1&8191)*(5*O),y+=(k+=8191&(a>>>14|(f=255&r[t+10]|(255&r[t+11])<<8)<<2))*(5*N),y+=(K+=8191&(f>>>11|(s=255&r[t+12]|(255&r[t+13])<<8)<<5))*(5*P),y+=(Y+=8191&(s>>>8|(u=255&r[t+14]|(255&r[t+15])<<8)<<8))*(5*R),l=c+=(y+=(L+=u>>>5|d)*(5*z))>>>13,l+=E*z,l+=x*T,l+=M*(5*Z),l+=m*(5*I),c=(l+=B*(5*F))>>>13,l&=8191,l+=S*(5*C),l+=k*(5*O),l+=K*(5*N),l+=Y*(5*P),c+=(l+=L*(5*R))>>>13,l&=8191,w=c,w+=E*R,w+=x*z,w+=M*T,w+=m*(5*Z),c=(w+=B*(5*I))>>>13,w&=8191,w+=S*(5*F),w+=k*(5*C),w+=K*(5*O),w+=Y*(5*N),v=c+=(w+=L*(5*P))>>>13,v+=E*P,v+=x*R,v+=M*z,v+=m*T,c=(v+=B*(5*Z))>>>13,v&=8191,v+=S*(5*I),v+=k*(5*F),v+=K*(5*C),v+=Y*(5*O),p=c+=(v+=L*(5*N))>>>13,p+=E*N,p+=x*P,p+=M*R,p+=m*z,c=(p+=B*T)>>>13,p&=8191,p+=S*(5*Z),p+=k*(5*I),p+=K*(5*F),p+=Y*(5*C),b=c+=(p+=L*(5*O))>>>13,b+=E*O,b+=x*N,b+=M*P,b+=m*R,c=(b+=B*z)>>>13,b&=8191,b+=S*T,b+=k*(5*Z),b+=K*(5*I),b+=Y*(5*F),g=c+=(b+=L*(5*C))>>>13,g+=E*C,g+=x*O,g+=M*N,g+=m*P,c=(g+=B*R)>>>13,g&=8191,g+=S*z,g+=k*T,g+=K*(5*Z),g+=Y*(5*I),A=c+=(g+=L*(5*F))>>>13,A+=E*F,A+=x*C,A+=M*O,A+=m*N,c=(A+=B*P)>>>13,A&=8191,A+=S*R,A+=k*z,A+=K*T,A+=Y*(5*Z),_=c+=(A+=L*(5*I))>>>13,_+=E*I,_+=x*F,_+=M*C,_+=m*O,c=(_+=B*N)>>>13,_&=8191,_+=S*P,_+=k*R,_+=K*z,_+=Y*T,U=c+=(_+=L*(5*Z))>>>13,U+=E*Z,U+=x*I,U+=M*F,U+=m*C,c=(U+=B*O)>>>13,U&=8191,U+=S*N,U+=k*P,U+=K*R,U+=Y*z,E=y=8191&(c=(c=((c+=(U+=L*T)>>>13)<<2)+c|0)+(y&=8191)|0),x=l+=c>>>=13,M=w&=8191,m=v&=8191,B=p&=8191,S=b&=8191,k=g&=8191,K=A&=8191,Y=_&=8191,L=U&=8191,t+=16,n-=16;this.h[0]=E,this.h[1]=x,this.h[2]=M,this.h[3]=m,this.h[4]=B,this.h[5]=S,this.h[6]=k,this.h[7]=K,this.h[8]=Y,this.h[9]=L},m.prototype.finish=function(r,t){var n,e,o,i,h=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=n,n=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,h[0]=this.h[0]+5,n=h[0]>>>13,h[0]&=8191,i=1;i<10;i++)h[i]=this.h[i]+n,n=h[i]>>>13,h[i]&=8191;for(h[9]-=8192,e=(1^n)-1,i=0;i<10;i++)h[i]&=e;for(e=~e,i=0;i<10;i++)this.h[i]=this.h[i]&e|h[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;r[t+0]=this.h[0]>>>0&255,r[t+1]=this.h[0]>>>8&255,r[t+2]=this.h[1]>>>0&255,r[t+3]=this.h[1]>>>8&255,r[t+4]=this.h[2]>>>0&255,r[t+5]=this.h[2]>>>8&255,r[t+6]=this.h[3]>>>0&255,r[t+7]=this.h[3]>>>8&255,r[t+8]=this.h[4]>>>0&255,r[t+9]=this.h[4]>>>8&255,r[t+10]=this.h[5]>>>0&255,r[t+11]=this.h[5]>>>8&255,r[t+12]=this.h[6]>>>0&255,r[t+13]=this.h[6]>>>8&255,r[t+14]=this.h[7]>>>0&255,r[t+15]=this.h[7]>>>8&255},m.prototype.update=function(r,t,n){var e,o;if(this.leftover){for(n<(o=16-this.leftover)&&(o=n),e=0;e<o;e++)this.buffer[this.leftover+e]=r[t+e];if(n-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(16<=n&&(o=n-n%16,this.blocks(r,t,o),t+=o,n-=o),n){for(e=0;e<n;e++)this.buffer[this.leftover+e]=r[t+e];this.leftover+=n}};var j=k,H=K;var J=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Q(r,t,n,e){for(var o,i,h,a,f,s,u,c,y,l,w,v,p,b,g,A,_,U,d,E,x,M,m,B,S=new Int32Array(16),k=new Int32Array(16),K=r[0],Y=r[1],L=r[2],T=r[3],z=r[4],R=r[5],P=r[6],N=r[7],O=t[0],C=t[1],F=t[2],I=t[3],Z=t[4],G=t[5],q=t[6],D=t[7],V=0;128<=e;){for(_=0;_<16;_++)U=8*_+V,S[_]=n[U+0]<<24|n[U+1]<<16|n[U+2]<<8|n[U+3],k[_]=n[U+4]<<24|n[U+5]<<16|n[U+6]<<8|n[U+7];for(_=0;_<80;_++)if(o=Y,i=L,h=T,c=C,y=F,l=I,x=65535&(E=D),M=E>>>16,m=65535&(d=N),B=d>>>16,x+=65535&(E=((w=Z)>>>14|(a=z)<<18)^(Z>>>18|z<<14)^(z>>>9|Z<<23)),M+=E>>>16,m+=65535&(d=(z>>>14|Z<<18)^(z>>>18|Z<<14)^(Z>>>9|z<<23)),B+=d>>>16,x+=65535&(E=Z&(v=G)^~Z&(p=q)),M+=E>>>16,m+=65535&(d=z&(f=R)^~z&(s=P)),B+=d>>>16,d=J[2*_],x+=65535&(E=J[2*_+1]),M+=E>>>16,m+=65535&d,B+=d>>>16,d=S[_%16],M+=(E=k[_%16])>>>16,m+=65535&d,B+=d>>>16,m+=(M+=(x+=65535&E)>>>16)>>>16,x=65535&(E=A=65535&x|M<<16),M=E>>>16,m=65535&(d=g=65535&m|(B+=m>>>16)<<16),B=d>>>16,x+=65535&(E=(O>>>28|K<<4)^(K>>>2|O<<30)^(K>>>7|O<<25)),M+=E>>>16,m+=65535&(d=(K>>>28|O<<4)^(O>>>2|K<<30)^(O>>>7|K<<25)),B+=d>>>16,M+=(E=O&C^O&F^C&F)>>>16,m+=65535&(d=K&Y^K&L^Y&L),B+=d>>>16,u=65535&(m+=(M+=(x+=65535&E)>>>16)>>>16)|(B+=m>>>16)<<16,b=65535&x|M<<16,x=65535&(E=l),M=E>>>16,m=65535&(d=h),B=d>>>16,M+=(E=A)>>>16,m+=65535&(d=g),B+=d>>>16,Y=K,L=o,T=i,z=h=65535&(m+=(M+=(x+=65535&E)>>>16)>>>16)|(B+=m>>>16)<<16,R=a,P=f,N=s,K=u,C=O,F=c,I=y,Z=l=65535&x|M<<16,G=w,q=v,D=p,O=b,_%16==15)for(U=0;U<16;U++)d=S[U],x=65535&(E=k[U]),M=E>>>16,m=65535&d,B=d>>>16,d=S[(U+9)%16],x+=65535&(E=k[(U+9)%16]),M+=E>>>16,m+=65535&d,B+=d>>>16,g=S[(U+1)%16],x+=65535&(E=((A=k[(U+1)%16])>>>1|g<<31)^(A>>>8|g<<24)^(A>>>7|g<<25)),M+=E>>>16,m+=65535&(d=(g>>>1|A<<31)^(g>>>8|A<<24)^g>>>7),B+=d>>>16,g=S[(U+14)%16],M+=(E=((A=k[(U+14)%16])>>>19|g<<13)^(g>>>29|A<<3)^(A>>>6|g<<26))>>>16,m+=65535&(d=(g>>>19|A<<13)^(A>>>29|g<<3)^g>>>6),B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,S[U]=65535&m|B<<16,k[U]=65535&x|M<<16;x=65535&(E=O),M=E>>>16,m=65535&(d=K),B=d>>>16,d=r[0],M+=(E=t[0])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[0]=K=65535&m|B<<16,t[0]=O=65535&x|M<<16,x=65535&(E=C),M=E>>>16,m=65535&(d=Y),B=d>>>16,d=r[1],M+=(E=t[1])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[1]=Y=65535&m|B<<16,t[1]=C=65535&x|M<<16,x=65535&(E=F),M=E>>>16,m=65535&(d=L),B=d>>>16,d=r[2],M+=(E=t[2])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[2]=L=65535&m|B<<16,t[2]=F=65535&x|M<<16,x=65535&(E=I),M=E>>>16,m=65535&(d=T),B=d>>>16,d=r[3],M+=(E=t[3])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[3]=T=65535&m|B<<16,t[3]=I=65535&x|M<<16,x=65535&(E=Z),M=E>>>16,m=65535&(d=z),B=d>>>16,d=r[4],M+=(E=t[4])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[4]=z=65535&m|B<<16,t[4]=Z=65535&x|M<<16,x=65535&(E=G),M=E>>>16,m=65535&(d=R),B=d>>>16,d=r[5],M+=(E=t[5])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[5]=R=65535&m|B<<16,t[5]=G=65535&x|M<<16,x=65535&(E=q),M=E>>>16,m=65535&(d=P),B=d>>>16,d=r[6],M+=(E=t[6])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[6]=P=65535&m|B<<16,t[6]=q=65535&x|M<<16,x=65535&(E=D),M=E>>>16,m=65535&(d=N),B=d>>>16,d=r[7],M+=(E=t[7])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[7]=N=65535&m|B<<16,t[7]=D=65535&x|M<<16,V+=128,e-=128}return e}function W(r,t,n){var e,o=new Int32Array(8),i=new Int32Array(8),h=new Uint8Array(256),a=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,Q(o,i,t,n),n%=128,e=0;e<n;e++)h[e]=t[a-n+e];for(h[n]=128,h[(n=256-128*(n<112?1:0))-9]=0,f(h,n-8,a/536870912|0,a<<3),Q(o,i,h,n),e=0;e<8;e++)f(r,8*e,o[e],i[e]);return 0}function $(r,t){var n=v(),e=v(),o=v(),i=v(),h=v(),a=v(),f=v(),s=v(),u=v();C(n,r[1],r[0]),C(u,t[1],t[0]),F(n,n,u),O(e,r[0],r[1]),O(u,t[0],t[1]),F(e,e,u),F(o,r[3],t[3]),F(o,o,y),F(i,r[2],t[2]),O(i,i,i),C(h,e,n),C(a,i,o),O(f,i,o),O(s,e,n),F(r[0],h,a),F(r[1],s,f),F(r[2],f,a),F(r[3],h,s)}function rr(r,t,n){var e;for(e=0;e<4;e++)T(r[e],t[e],n)}function tr(r,t){var n=v(),e=v(),o=v();Z(o,t[2]),F(n,t[0],o),F(e,t[1],o),z(r,e),r[31]^=P(n)<<7}function nr(r,t,n){var e,o;for(Y(r[0],s),Y(r[1],u),Y(r[2],u),Y(r[3],s),o=255;0<=o;--o)rr(r,t,e=n[o/8|0]>>(7&o)&1),$(t,r),$(r,r),rr(r,t,e)}function er(r,t){var n=[v(),v(),v(),v()];Y(n[0],e),Y(n[1],a),Y(n[2],u),F(n[3],e,a),nr(r,n,t)}function or(r,t,n){var e,o=new Uint8Array(64),i=[v(),v(),v(),v()];for(n||h(t,32),W(o,t,32),o[0]&=248,o[31]&=127,o[31]|=64,er(i,o),tr(r,i),e=0;e<32;e++)t[e+32]=r[e];return 0}var ir=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function hr(r,t){var n,e,o,i;for(e=63;32<=e;--e){for(n=0,o=e-32,i=e-12;o<i;++o)t[o]+=n-16*t[e]*ir[o-(e-32)],n=Math.floor((t[o]+128)/256),t[o]-=256*n;t[o]+=n,t[e]=0}for(o=n=0;o<32;o++)t[o]+=n-(t[31]>>4)*ir[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*ir[o];for(e=0;e<32;e++)t[e+1]+=t[e]>>8,r[e]=255&t[e]}function ar(r){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=r[t];for(t=0;t<64;t++)r[t]=0;hr(r,n)}function fr(r,t,n,e){var o,i,h=new Uint8Array(64),a=new Uint8Array(64),f=new Uint8Array(64),s=new Float64Array(64),u=[v(),v(),v(),v()];W(h,e,32),h[0]&=248,h[31]&=127,h[31]|=64;var c=n+64;for(o=0;o<n;o++)r[64+o]=t[o];for(o=0;o<32;o++)r[32+o]=h[32+o];for(W(f,r.subarray(32),n+32),ar(f),er(u,f),tr(r,u),o=32;o<64;o++)r[o]=e[o];for(W(a,r,n+64),ar(a),o=0;o<64;o++)s[o]=0;for(o=0;o<32;o++)s[o]=f[o];for(o=0;o<32;o++)for(i=0;i<32;i++)s[o+i]+=a[o]*h[i];return hr(r.subarray(32),s),c}function sr(r,t,n,e){var o,i=new Uint8Array(32),h=new Uint8Array(64),a=[v(),v(),v(),v()],f=[v(),v(),v(),v()];if(n<64)return-1;if(function(r,t){var n=v(),e=v(),o=v(),i=v(),h=v(),a=v(),f=v();if(Y(r[2],u),N(r[1],t),I(o,r[1]),F(i,o,c),C(o,o,r[2]),O(i,r[2],i),I(h,i),I(a,h),F(f,a,h),F(n,f,o),F(n,n,i),G(n,n),F(n,n,o),F(n,n,i),F(n,n,i),F(r[0],n,i),I(e,r[0]),F(e,e,i),R(e,o)&&F(r[0],r[0],l),I(e,r[0]),F(e,e,i),R(e,o))return 1;P(r[0])===t[31]>>7&&C(r[0],s,r[0]),F(r[3],r[0],r[1])}(f,e))return-1;for(o=0;o<n;o++)r[o]=t[o];for(o=0;o<32;o++)r[o+32]=e[o];if(W(h,r,n),ar(h),nr(a,f,h),er(f,t.subarray(32)),$(a,f),tr(i,a),n-=64,g(t,0,i,0)){for(o=0;o<n;o++)r[o]=0;return-1}for(o=0;o<n;o++)r[o]=t[o+64];return n}function ur(r,t){if(32!==r.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function cr(){for(var r=0;r<arguments.length;r++)if(!(arguments[r]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function yr(r){for(var t=0;t<r.length;t++)r[t]=0}i.lowlevel={crypto_core_hsalsa20:_,crypto_stream_xor:M,crypto_stream:x,crypto_stream_salsa20_xor:d,crypto_stream_salsa20:E,crypto_onetimeauth:B,crypto_onetimeauth_verify:S,crypto_verify_16:b,crypto_verify_32:g,crypto_secretbox:k,crypto_secretbox_open:K,crypto_scalarmult:q,crypto_scalarmult_base:D,crypto_box_beforenm:X,crypto_box_afternm:j,crypto_box:function(r,t,n,e,o,i){var h=new Uint8Array(32);return X(h,o,i),j(r,t,n,e,h)},crypto_box_open:function(r,t,n,e,o,i){var h=new Uint8Array(32);return X(h,o,i),H(r,t,n,e,h)},crypto_box_keypair:V,crypto_hash:W,crypto_sign:fr,crypto_sign_keypair:or,crypto_sign_open:sr,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:64,crypto_sign_PUBLICKEYBYTES:32,crypto_sign_SECRETKEYBYTES:64,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:v,D:c,L:ir,pack25519:z,unpack25519:N,M:F,A:O,S:I,Z:C,pow2523:G,add:$,set25519:Y,modL:hr,scalarmult:nr,scalarbase:er},i.randomBytes=function(r){var t=new Uint8Array(r);return h(t,r),t},i.secretbox=function(r,t,n){cr(r,t,n),ur(n,t);for(var e=new Uint8Array(32+r.length),o=new Uint8Array(e.length),i=0;i<r.length;i++)e[i+32]=r[i];return k(o,e,e.length,t,n),o.subarray(16)},i.secretbox.open=function(r,t,n){cr(r,t,n),ur(n,t);for(var e=new Uint8Array(16+r.length),o=new Uint8Array(e.length),i=0;i<r.length;i++)e[i+16]=r[i];return e.length<32||0!==K(o,e,e.length,t,n)?null:o.subarray(32)},i.secretbox.keyLength=32,i.secretbox.nonceLength=24,i.secretbox.overheadLength=16,i.scalarMult=function(r,t){if(cr(r,t),32!==r.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var n=new Uint8Array(32);return q(n,r,t),n},i.scalarMult.base=function(r){if(cr(r),32!==r.length)throw new Error("bad n size");var t=new Uint8Array(32);return D(t,r),t},i.scalarMult.scalarLength=32,i.scalarMult.groupElementLength=32,i.box=function(r,t,n,e){var o=i.box.before(n,e);return i.secretbox(r,t,o)},i.box.before=function(r,t){cr(r,t),function(r,t){if(32!==r.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(r,t);var n=new Uint8Array(32);return X(n,r,t),n},i.box.after=i.secretbox,i.box.open=function(r,t,n,e){var o=i.box.before(n,e);return i.secretbox.open(r,t,o)},i.box.open.after=i.secretbox.open,i.box.keyPair=function(){var r=new Uint8Array(32),t=new Uint8Array(32);return V(r,t),{publicKey:r,secretKey:t}},i.box.keyPair.fromSecretKey=function(r){if(cr(r),32!==r.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return D(t,r),{publicKey:t,secretKey:new Uint8Array(r)}},i.box.publicKeyLength=32,i.box.secretKeyLength=32,i.box.sharedKeyLength=32,i.box.nonceLength=24,i.box.overheadLength=i.secretbox.overheadLength,i.sign=function(r,t){if(cr(r,t),64!==t.length)throw new Error("bad secret key size");var n=new Uint8Array(64+r.length);return fr(n,r,r.length,t),n},i.sign.open=function(r,t){if(cr(r,t),32!==t.length)throw new Error("bad public key size");var n=new Uint8Array(r.length),e=sr(n,r,r.length,t);if(e<0)return null;for(var o=new Uint8Array(e),i=0;i<o.length;i++)o[i]=n[i];return o},i.sign.detached=function(r,t){for(var n=i.sign(r,t),e=new Uint8Array(64),o=0;o<e.length;o++)e[o]=n[o];return e},i.sign.detached.verify=function(r,t,n){if(cr(r,t,n),64!==t.length)throw new Error("bad signature size");if(32!==n.length)throw new Error("bad public key size");var e,o=new Uint8Array(64+r.length),i=new Uint8Array(64+r.length);for(e=0;e<64;e++)o[e]=t[e];for(e=0;e<r.length;e++)o[e+64]=r[e];return 0<=sr(i,o,o.length,n)},i.sign.keyPair=function(){var r=new Uint8Array(32),t=new Uint8Array(64);return or(r,t),{publicKey:r,secretKey:t}},i.sign.keyPair.fromSecretKey=function(r){if(cr(r),64!==r.length)throw new Error("bad secret key size");for(var t=new Uint8Array(32),n=0;n<t.length;n++)t[n]=r[32+n];return{publicKey:t,secretKey:new Uint8Array(r)}},i.sign.keyPair.fromSeed=function(r){if(cr(r),32!==r.length)throw new Error("bad seed size");for(var t=new Uint8Array(32),n=new Uint8Array(64),e=0;e<32;e++)n[e]=r[e];return or(t,n,!0),{publicKey:t,secretKey:n}},i.sign.publicKeyLength=32,i.sign.secretKeyLength=64,i.sign.seedLength=32,i.sign.signatureLength=64,i.hash=function(r){cr(r);var t=new Uint8Array(64);return W(t,r,r.length),t},i.hash.hashLength=64,i.verify=function(r,t){return cr(r,t),0!==r.length&&0!==t.length&&(r.length===t.length&&0===w(r,0,t,0,r.length))},i.setPRNG=function(r){h=r},function(){var o="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(o&&o.getRandomValues){i.setPRNG(function(r,t){var n,e=new Uint8Array(t);for(n=0;n<t;n+=65536)o.getRandomValues(e.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)r[n]=e[n];yr(e)})}else"undefined"!=typeof require&&(o=require("crypto"))&&o.randomBytes&&i.setPRNG(function(r,t){var n,e=o.randomBytes(t);for(n=0;n<t;n++)r[n]=e[n];yr(e)})}()})(_Crypto_nacl);
3312
13+// HEX UTILITIES
3414
35−// DER CODEC (for ECDSA signatures: secp256k1, P-256)
36−
37−function _Crypto_bigintToBytes(n, len)
38−{
39− var hex = n.toString(16);
40− if (hex.length % 2) { hex = '0' + hex; }
41− while (hex.length < len * 2) { hex = '00' + hex; }
42− return _Crypto_fromHex(hex);
43−}
15+var _Crypto_hexChars = '0123456789abcdef';
4416
45−function _Crypto_bytesToBigint(bytes)
17+function _Crypto_toHex(bytes)
4618{
47− return BigInt('0x' + _Crypto_toHex(bytes));
48−}
49−
50−function _Crypto_compactToDer(compactHex, byteLen)
51−{
52− var bytes = _Crypto_fromHex(compactHex);
53− var r = bytes.slice(0, byteLen);
54− var s = bytes.slice(byteLen);
55− function encodeInt(b) {
56− // Strip leading zeros, then add back if high bit set
57− var i = 0;
58− while (i < b.length - 1 && b[i] === 0) { i++; }
59− b = b.slice(i);
60− if (b[0] & 0x80) {
61− var padded = new Uint8Array(b.length + 1);
62− padded[0] = 0;
63− padded.set(b, 1);
64− b = padded;
65− }
66− return b;
67− }
68− var rEnc = encodeInt(r);
69− var sEnc = encodeInt(s);
70− var totalLen = 2 + rEnc.length + 2 + sEnc.length;
71− var der = new Uint8Array(2 + totalLen);
72− var pos = 0;
73− der[pos++] = 0x30;
74− der[pos++] = totalLen;
75− der[pos++] = 0x02;
76− der[pos++] = rEnc.length;
77− der.set(rEnc, pos); pos += rEnc.length;
78− der[pos++] = 0x02;
79− der[pos++] = sEnc.length;
80− der.set(sEnc, pos);
81− return _Crypto_toHex(der);
82−}
83−
84−function _Crypto_derToCompact(derHex, byteLen)
85−{
86− var der = _Crypto_fromHex(derHex);
87− if (der[0] !== 0x30) { return null; }
88− var pos = 2;
89− if (der[pos] !== 0x02) { return null; }
90− var rLen = der[pos + 1]; pos += 2;
91− var rBytes = der.slice(pos, pos + rLen); pos += rLen;
92− if (der[pos] !== 0x02) { return null; }
93− var sLen = der[pos + 1]; pos += 2;
94− var sBytes = der.slice(pos, pos + sLen);
95− // Remove leading zero padding
96− while (rBytes.length > byteLen) { rBytes = rBytes.slice(1); }
97− while (sBytes.length > byteLen) { sBytes = sBytes.slice(1); }
98− // Pad to fixed width
99− var r = new Uint8Array(byteLen);
100− var s = new Uint8Array(byteLen);
101− r.set(rBytes, byteLen - rBytes.length);
102− s.set(sBytes, byteLen - sBytes.length);
103− var compact = new Uint8Array(byteLen * 2);
104− compact.set(r, 0);
105− compact.set(s, byteLen);
106− return _Crypto_toHex(compact);
107−}
108−
109−
110−// SECP256K1
111−
112−function _Crypto_secp256k1PrivateKeyFromHex(hex)
113−{
114− try {
115− _Crypto_noble.secp256k1.getPublicKey(_Crypto_fromHex(hex));
116− return __Maybe_Just(hex);
117− } catch (e) {
118− return __Maybe_Nothing;
19+ var hex = '';
20+ for (var i = 0; i < bytes.length; i++)
21+ {
22+ hex += _Crypto_hexChars[bytes[i] >> 4];
23+ hex += _Crypto_hexChars[bytes[i] & 15];
11924 }
25+ return hex;
12026}
12127
122−function _Crypto_secp256k1PrivateKeyToHex(key)
123−{
124− return key;
125−}
126−
127−function _Crypto_secp256k1PublicKeyFromHex(hex)
28+function _Crypto_fromHex(hex)
12829{
129− try {
130− _Crypto_noble.secp256k1.Point.fromHex(hex);
131− return __Maybe_Just(hex);
132− } catch (e) {
133− return __Maybe_Nothing;
30+ if (hex.length % 2 !== 0) { return new Uint8Array(0); }
31+ var bytes = new Uint8Array(hex.length / 2);
32+ for (var i = 0; i < bytes.length; i++)
33+ {
34+ var hi = _Crypto_hexVal(hex.charCodeAt(i * 2));
35+ var lo = _Crypto_hexVal(hex.charCodeAt(i * 2 + 1));
36+ if (hi < 0 || lo < 0) { return new Uint8Array(0); }
37+ bytes[i] = (hi << 4) | lo;
13438 }
39+ return bytes;
13540}
13641
137−function _Crypto_secp256k1PublicKeyToHex(key)
42+function _Crypto_hexVal(charCode)
13843{
139− return key;
44+ if (charCode >= 48 && charCode <= 57) { return charCode - 48; }
45+ if (charCode >= 97 && charCode <= 102) { return charCode - 87; }
46+ if (charCode >= 65 && charCode <= 70) { return charCode - 55; }
47+ return -1;
14048}
14149
142−function _Crypto_secp256k1SignatureFromCompactHex(hex)
143−{
144− try {
145− var bytes = _Crypto_fromHex(hex);
146− if (bytes.length !== 64) { return __Maybe_Nothing; }
147− _Crypto_noble.secp256k1.Signature.fromHex(hex);
148− return __Maybe_Just(hex);
149− } catch (e) {
150− return __Maybe_Nothing;
151− }
152−}
153−
154−function _Crypto_secp256k1SignatureFromDerHex(hex)
155−{
156− try {
157− var compact = _Crypto_derToCompact(hex, 32);
158− if (!compact) { return __Maybe_Nothing; }
159− _Crypto_noble.secp256k1.Signature.fromHex(compact);
160− return __Maybe_Just(compact);
161− } catch (e) {
162− return __Maybe_Nothing;
163− }
164−}
165−
166−function _Crypto_secp256k1SignatureToCompactHex(sig)
167−{
168− return sig;
169−}
170−
171−function _Crypto_secp256k1SignatureToDerHex(compactHex)
172−{
173− return _Crypto_compactToDer(compactHex, 32);
174−}
175−
176−function _Crypto_secp256k1GetPublicKey(privKey)
177−{
178− return _Crypto_toHex(_Crypto_noble.secp256k1.getPublicKey(_Crypto_fromHex(privKey)));
179−}
180−
181−var _Crypto_secp256k1Sign = F2(function(msgHash, privKey)
182−{
183− var sig = _Crypto_noble.secp256k1.sign(_Crypto_fromHex(msgHash), _Crypto_fromHex(privKey));
184− return _Crypto_toHex(sig);
185−});
186−
187−var _Crypto_secp256k1Verify = F3(function(sig, msgHash, pubKey)
188−{
189− try {
190− return _Crypto_noble.secp256k1.verify(
191− _Crypto_fromHex(sig),
192− _Crypto_fromHex(msgHash),
193− _Crypto_fromHex(pubKey)
194− );
195− } catch (e) {
196− return false;
197− }
198−});
199−
200−var _Crypto_secp256k1GetSharedSecret = F2(function(privKey, pubKey)
201−{
202− return _Crypto_toHex(_Crypto_noble.secp256k1.getSharedSecret(_Crypto_fromHex(privKey), _Crypto_fromHex(pubKey)));
203−});
204−
20550
20651// ED25519
20752
20853function _Crypto_ed25519PrivateKeyFromHex(hex)
20954{
21055 try {
211− _Crypto_noble.ed25519.getPublicKey(_Crypto_fromHex(hex));
56+ var bytes = _Crypto_fromHex(hex);
57+ if (bytes.length !== 32) { return __Maybe_Nothing; }
58+ _Crypto_nacl.sign.keyPair.fromSeed(bytes);
21259 return __Maybe_Just(hex);
21360 } catch (e) {
21461 return __Maybe_Nothing;
@@ -223,7 +70,8 @@ function _Crypto_ed25519PrivateKeyToHex(key)
22370function _Crypto_ed25519PublicKeyFromHex(hex)
22471{
22572 try {
226− _Crypto_noble.ed25519.Point.fromHex(hex);
73+ var bytes = _Crypto_fromHex(hex);
74+ if (bytes.length !== 32) { return __Maybe_Nothing; }
22775 return __Maybe_Just(hex);
22876 } catch (e) {
22977 return __Maybe_Nothing;
@@ -253,20 +101,22 @@ function _Crypto_ed25519SignatureToHex(sig)
253101
254102function _Crypto_ed25519GetPublicKey(privKey)
255103{
256− return _Crypto_toHex(_Crypto_noble.ed25519.getPublicKey(_Crypto_fromHex(privKey)));
104+ var kp = _Crypto_nacl.sign.keyPair.fromSeed(_Crypto_fromHex(privKey));
105+ return _Crypto_toHex(kp.publicKey);
257106}
258107
259108var _Crypto_ed25519Sign = F2(function(msg, privKey)
260109{
261− return _Crypto_toHex(_Crypto_noble.ed25519.sign(_Crypto_fromHex(msg), _Crypto_fromHex(privKey)));
110+ var kp = _Crypto_nacl.sign.keyPair.fromSeed(_Crypto_fromHex(privKey));
111+ return _Crypto_toHex(_Crypto_nacl.sign.detached(_Crypto_fromHex(msg), kp.secretKey));
262112});
263113
264114var _Crypto_ed25519Verify = F3(function(sig, msg, pubKey)
265115{
266116 try {
267− return _Crypto_noble.ed25519.verify(
268− _Crypto_fromHex(sig),
117+ return _Crypto_nacl.sign.detached.verify(
269118 _Crypto_fromHex(msg),
119+ _Crypto_fromHex(sig),
270120 _Crypto_fromHex(pubKey)
271121 );
272122 } catch (e) {
@@ -275,114 +125,53 @@ var _Crypto_ed25519Verify = F3(function(sig, msg, pubKey)
275125});
276126
277127
278−// P-256 (secp256r1)
279−
280−function _Crypto_p256PrivateKeyFromHex(hex)
281−{
282− try {
283− _Crypto_noble.p256.getPublicKey(_Crypto_fromHex(hex));
284− return __Maybe_Just(hex);
285− } catch (e) {
286− return __Maybe_Nothing;
287− }
288−}
289−
290−function _Crypto_p256PrivateKeyToHex(key)
291−{
292− return key;
293−}
128+// X25519 (Diffie-Hellman)
294129
295−function _Crypto_p256PublicKeyFromHex(hex)
130+function _Crypto_x25519PrivateKeyFromHex(hex)
296131{
297132 try {
298− _Crypto_noble.p256.Point.fromHex(hex);
133+ var bytes = _Crypto_fromHex(hex);
134+ if (bytes.length !== 32) { return __Maybe_Nothing; }
135+ _Crypto_nacl.scalarMult.base(bytes);
299136 return __Maybe_Just(hex);
300137 } catch (e) {
301138 return __Maybe_Nothing;
302139 }
303140}
304141
305−function _Crypto_p256PublicKeyToHex(key)
142+function _Crypto_x25519PrivateKeyToHex(key)
306143{
307144 return key;
308145}
309146
310−function _Crypto_p256SignatureFromCompactHex(hex)
147+function _Crypto_x25519PublicKeyFromHex(hex)
311148{
312149 try {
313150 var bytes = _Crypto_fromHex(hex);
314− if (bytes.length !== 64) { return __Maybe_Nothing; }
315− _Crypto_noble.p256.Signature.fromHex(hex);
151+ if (bytes.length !== 32) { return __Maybe_Nothing; }
316152 return __Maybe_Just(hex);
317153 } catch (e) {
318154 return __Maybe_Nothing;
319155 }
320156}
321157
322−function _Crypto_p256SignatureFromDerHex(hex)
323−{
324− try {
325− var compact = _Crypto_derToCompact(hex, 32);
326− if (!compact) { return __Maybe_Nothing; }
327− _Crypto_noble.p256.Signature.fromHex(compact);
328− return __Maybe_Just(compact);
329− } catch (e) {
330− return __Maybe_Nothing;
331− }
332−}
333−
334−function _Crypto_p256SignatureToCompactHex(sig)
335−{
336− return sig;
337−}
338−
339−function _Crypto_p256SignatureToDerHex(compactHex)
158+function _Crypto_x25519PublicKeyToHex(key)
340159{
341− return _Crypto_compactToDer(compactHex, 32);
160+ return key;
342161}
343162
344−function _Crypto_p256GetPublicKey(privKey)
163+function _Crypto_x25519GetPublicKey(privKey)
345164{
346− return _Crypto_toHex(_Crypto_noble.p256.getPublicKey(_Crypto_fromHex(privKey)));
165+ return _Crypto_toHex(_Crypto_nacl.scalarMult.base(_Crypto_fromHex(privKey)));
347166}
348167
349−var _Crypto_p256Sign = F2(function(msgHash, privKey)
168+var _Crypto_x25519GetSharedSecret = F2(function(privKey, pubKey)
350169{
351− var sig = _Crypto_noble.p256.sign(_Crypto_fromHex(msgHash), _Crypto_fromHex(privKey));
352− return _Crypto_toHex(sig);
170+ return _Crypto_toHex(_Crypto_nacl.scalarMult(_Crypto_fromHex(privKey), _Crypto_fromHex(pubKey)));
353171});
354172
355−var _Crypto_p256Verify = F3(function(sig, msgHash, pubKey)
356−{
357− try {
358− return _Crypto_noble.p256.verify(
359− _Crypto_fromHex(sig),
360− _Crypto_fromHex(msgHash),
361− _Crypto_fromHex(pubKey)
362− );
363− } catch (e) {
364− return false;
365− }
366−});
367−
368−var _Crypto_p256GetSharedSecret = F2(function(privKey, pubKey)
369−{
370− return _Crypto_toHex(_Crypto_noble.p256.getSharedSecret(_Crypto_fromHex(privKey), _Crypto_fromHex(pubKey)));
371−});
372−
373−
374−// NOBLE/CIPHERS BUNDLE (https://github.com/paulmillr/noble-ciphers, MIT License)
375−// Embedded: @noble/ciphers - AES-GCM, ChaCha20-Poly1305, XChaCha20-Poly1305
376−
377−var _Crypto_ciphers =(()=>{var _t=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var xe=(e,t)=>{for(var n in t)_t(e,n,{get:t[n],enumerable:!0})},me=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of we(t))!be.call(e,o)&&o!==n&&_t(e,o,{get:()=>t[o],enumerable:!(r=de(t,o))||r.enumerable});return e};var Le=e=>me(_t({},"_"+"_esModule",{value:!0}),e);var Ge={};xe(Ge,{cbc:()=>ne,cfb:()=>re,chacha20poly1305:()=>pe,ctr:()=>Gt,ecb:()=>ee,gcm:()=>oe,managedNonce:()=>Vt,randomBytes:()=>xt,siv:()=>se,xchacha20poly1305:()=>ye});function Ee(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function yt(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function ht(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function E(e,t,n=""){let r=Ee(e),o=e?.length,s=t!==void 0;if(!r||s&&o!==t){let i=n&&`"${n}" `,c=s?` of length ${t}`:"",f=r?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+c+", got "+f)}return e}function et(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function gt(e,t){E(e,void 0,"output");let n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function dt(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function A(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function B(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function at(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var Ue=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function vt(e,t){return e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function pt(e,t){if(vt(e,t)&&e.byteOffset<t.byteOffset)throw new Error("complex overlap of input and output is not supported")}function Ct(...e){let t=0;for(let r=0;r<e.length;r++){let o=e[r];E(o),t+=o.length}let n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){let s=e[r];n.set(s,o),o+=s.length}return n}function jt(e,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(e,t)}function wt(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 n===0}var D=(e,t)=>{function n(r,...o){if(E(r,void 0,"key"),!Ue)throw new Error("Non little-endian hardware is not yet supported");if(e.nonceLength!==void 0){let h=o[0];E(h,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let s=e.tagLength;s&&o[1]!==void 0&&E(o[1],void 0,"AAD");let i=t(r,...o),c=(h,a)=>{if(a!==void 0){if(h!==2)throw new Error("cipher output not supported");E(a,void 0,"output")}},f=!1;return{encrypt(h,a){if(f)throw new Error("cannot encrypt() twice with same key + nonce");return f=!0,E(h),c(i.encrypt.length,a),i.encrypt(h,a)},decrypt(h,a){if(E(h),s&&h.length<s)throw new Error('"ciphertext" expected length bigger than tagLength='+s);return c(i.decrypt.length,a),i.decrypt(h,a)}}}return Object.assign(n,e),n};function Q(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw new Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(n&&!Z(t))throw new Error("invalid output, must be aligned");return t}function bt(e,t,n){yt(n);let r=new Uint8Array(16),o=at(r);return o.setBigUint64(0,BigInt(t),n),o.setBigUint64(8,BigInt(e),n),r}function Z(e){return e.byteOffset%4===0}function z(e){return Uint8Array.from(e)}function xt(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}function Vt(e,t=xt){let{nonceLength:n}=e;ht(n);let r=(o,s)=>{let i=Ct(o,s);return s.fill(0),i};return((o,...s)=>({encrypt(i){E(i);let c=t(n),f=e(o,c,...s).encrypt(i);return f instanceof Promise?f.then(l=>r(c,l)):r(c,f)},decrypt(i){E(i);let c=i.subarray(0,n),f=i.subarray(n);return e(o,c,...s).decrypt(f)}}))}var tt=16,Tt=new Uint8Array(16),G=A(Tt),Ae=225,Be=(e,t,n,r)=>{let o=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^Ae<<24&-(o&1)}},F=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function _e(e){e.reverse();let t=e[15]&1,n=0;for(let r=0;r<e.length;r++){let o=e[r];e[r]=o>>>1|n,n=(o&1)<<7}return e[0]^=-t&225,e}var ve=e=>e>64*1024?8:e>1024?4:2,mt=class{blockLen=tt;outputLen=tt;s0=0;s1=0;s2=0;s3=0;finished=!1;t;W;windowSize;constructor(t,n){E(t,16,"key"),t=z(t);let r=at(t),o=r.getUint32(0,!1),s=r.getUint32(4,!1),i=r.getUint32(8,!1),c=r.getUint32(12,!1),f=[];for(let u=0;u<128;u++)f.push({s0:F(o),s1:F(s),s2:F(i),s3:F(c)}),{s0:o,s1:s,s2:i,s3:c}=Be(o,s,i,c);let l=ve(n||1024);if(![1,2,4,8].includes(l))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=l;let a=128/l,p=this.windowSize=2**l,g=[];for(let u=0;u<a;u++)for(let y=0;y<p;y++){let d=0,w=0,b=0,U=0;for(let L=0;L<l;L++){if(!(y>>>l-L-1&1))continue;let{s0:v,s1:j,s2:V,s3:_}=f[l*u+L];d^=v,w^=j,b^=V,U^=_}g.push({s0:d,s1:w,s2:b,s3:U})}this.t=g}_updateBlock(t,n,r,o){t^=this.s0,n^=this.s1,r^=this.s2,o^=this.s3;let{W:s,t:i,windowSize:c}=this,f=0,l=0,h=0,a=0,p=(1<<s)-1,g=0;for(let u of[t,n,r,o])for(let y=0;y<4;y++){let d=u>>>8*y&255;for(let w=8/s-1;w>=0;w--){let b=d>>>s*w&p,{s0:U,s1:L,s2:C,s3:v}=i[g*c+b];f^=U,l^=L,h^=C,a^=v,g+=1}}this.s0=f,this.s1=l,this.s2=h,this.s3=a}update(t){et(this),E(t),t=z(t);let n=A(t),r=Math.floor(t.length/tt),o=t.length%tt;for(let s=0;s<r;s++)this._updateBlock(n[s*4+0],n[s*4+1],n[s*4+2],n[s*4+3]);return o&&(Tt.set(t.subarray(r*tt)),this._updateBlock(G[0],G[1],G[2],G[3]),B(G)),this}destroy(){let{t}=this;for(let n of t)n.s0=0,n.s1=0,n.s2=0,n.s3=0}digestInto(t){et(this),gt(t,this),this.finished=!0;let{s0:n,s1:r,s2:o,s3:s}=this,i=A(t);return i[0]=n,i[1]=r,i[2]=o,i[3]=s,t}digest(){let t=new Uint8Array(tt);return this.digestInto(t),this.destroy(),t}},St=class extends mt{constructor(t,n){E(t);let r=_e(z(t));super(r,n),B(r)}update(t){et(this),E(t),t=z(t);let n=A(t),r=t.length%tt,o=Math.floor(t.length/tt);for(let s=0;s<o;s++)this._updateBlock(F(n[s*4+3]),F(n[s*4+2]),F(n[s*4+1]),F(n[s*4+0]));return r&&(Tt.set(t.subarray(o*tt)),this._updateBlock(F(G[3]),F(G[2]),F(G[1]),F(G[0])),B(G)),this}digestInto(t){et(this),gt(t,this),this.finished=!0;let{s0:n,s1:r,s2:o,s3:s}=this,i=A(t);return i[0]=n,i[1]=r,i[2]=o,i[3]=s,t.reverse()}};function Ht(e){let t=(r,o)=>e(o,r.length).update(r).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(r,o)=>e(r,o),t}var It=Ht((e,t)=>new mt(e,t)),Ce=Ht((e,t)=>new St(e,t));var R=16,Nt=4,Lt=new Uint8Array(R);var Se=283;function $t(e){if(![16,24,32].includes(e.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+e.length)}function Mt(e){return e<<1^Se&-(e>>7)}function ut(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=Mt(e);return n}var Te=(e,t,n=1)=>{if(!Number.isSafeInteger(n))throw new Error("incBytes: wrong carry "+n);E(e);for(let r=0;r<e.length;r++){let o=t?r:e.length-1-r;n=n+(e[o]&255)|0,e[o]=n&255,n>>>=8}},kt=(()=>{let e=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=Mt(r))e[n]=r;let t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return B(e),t})(),Ie=kt.map((e,t)=>kt.indexOf(t)),Ke=e=>e<<24|e>>>8,Kt=e=>e<<8|e>>>24;function Zt(e,t){if(e.length!==256)throw new Error("Wrong sbox length");let n=new Uint32Array(256).map((l,h)=>t(e[h])),r=n.map(Kt),o=r.map(Kt),s=o.map(Kt),i=new Uint32Array(256*256),c=new Uint32Array(256*256),f=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let h=0;h<256;h++){let a=l*256+h;i[a]=n[l]^r[h],c[a]=o[l]^s[h],f[a]=e[l]<<8|e[h]}return{sbox:e,sbox2:f,T0:n,T1:r,T2:o,T3:s,T01:i,T23:c}}var Pt=Zt(kt,e=>ut(e,3)<<24|e<<16|e<<8|ut(e,2)),Ft=Zt(Ie,e=>ut(e,11)<<24|ut(e,13)<<16|ut(e,9)<<8|ut(e,14)),Oe=(()=>{let e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=Mt(n))e[t]=n;return e})();function rt(e){E(e);let t=e.length;$t(e);let{sbox2:n}=Pt,r=[];Z(e)||r.push(e=z(e));let o=A(e),s=o.length,i=f=>J(n,f,f,f,f),c=new Uint32Array(t+28);c.set(o);for(let f=s;f<c.length;f++){let l=c[f-1];f%s===0?l=i(Ke(l))^Oe[f/s-1]:s>6&&f%s===4&&(l=i(l)),c[f]=c[f-s]^l}return B(...r),c}function Yt(e){let t=rt(e),n=t.slice(),r=t.length,{sbox2:o}=Pt,{T0:s,T1:i,T2:c,T3:f}=Ft;for(let l=0;l<r;l+=4)for(let h=0;h<4;h++)n[l+h]=t[r-l-4+h];B(t);for(let l=4;l<r-4;l++){let h=n[l],a=J(o,h,h,h,h);n[l]=s[a&255]^i[a>>>8&255]^c[a>>>16&255]^f[a>>>24]}return n}function nt(e,t,n,r,o,s){return e[n<<8&65280|r>>>8&255]^t[o>>>8&65280|s>>>24&255]}function J(e,t,n,r,o){return e[t&255|n&65280]|e[r>>>16&255|o>>>16&65280]<<16}function Y(e,t,n,r,o){let{sbox2:s,T01:i,T23:c}=Pt,f=0;t^=e[f++],n^=e[f++],r^=e[f++],o^=e[f++];let l=e.length/4-2;for(let u=0;u<l;u++){let y=e[f++]^nt(i,c,t,n,r,o),d=e[f++]^nt(i,c,n,r,o,t),w=e[f++]^nt(i,c,r,o,t,n),b=e[f++]^nt(i,c,o,t,n,r);t=y,n=d,r=w,o=b}let h=e[f++]^J(s,t,n,r,o),a=e[f++]^J(s,n,r,o,t),p=e[f++]^J(s,r,o,t,n),g=e[f++]^J(s,o,t,n,r);return{s0:h,s1:a,s2:p,s3:g}}function Qt(e,t,n,r,o){let{sbox2:s,T01:i,T23:c}=Ft,f=0;t^=e[f++],n^=e[f++],r^=e[f++],o^=e[f++];let l=e.length/4-2;for(let u=0;u<l;u++){let y=e[f++]^nt(i,c,t,o,r,n),d=e[f++]^nt(i,c,n,t,o,r),w=e[f++]^nt(i,c,r,n,t,o),b=e[f++]^nt(i,c,o,r,n,t);t=y,n=d,r=w,o=b}let h=e[f++]^J(s,t,o,r,n),a=e[f++]^J(s,n,t,o,r),p=e[f++]^J(s,r,n,t,o),g=e[f++]^J(s,o,r,n,t);return{s0:h,s1:a,s2:p,s3:g}}function ke(e,t,n,r){E(t,R,"nonce"),E(n);let o=n.length;r=Q(o,r),pt(n,r);let s=t,i=A(s),{s0:c,s1:f,s2:l,s3:h}=Y(e,i[0],i[1],i[2],i[3]),a=A(n),p=A(r);for(let u=0;u+4<=a.length;u+=4)p[u+0]=a[u+0]^c,p[u+1]=a[u+1]^f,p[u+2]=a[u+2]^l,p[u+3]=a[u+3]^h,Te(s,!1,1),{s0:c,s1:f,s2:l,s3:h}=Y(e,i[0],i[1],i[2],i[3]);let g=R*Math.floor(a.length/Nt);if(g<o){let u=new Uint32Array([c,f,l,h]),y=dt(u);for(let d=g,w=0;d<o;d++,w++)r[d]=n[d]^y[w];B(u)}return r}function Et(e,t,n,r,o){E(n,R,"nonce"),E(r),o=Q(r.length,o);let s=n,i=A(s),c=at(s),f=A(r),l=A(o),h=t?0:12,a=r.length,p=c.getUint32(h,t),{s0:g,s1:u,s2:y,s3:d}=Y(e,i[0],i[1],i[2],i[3]);for(let b=0;b+4<=f.length;b+=4)l[b+0]=f[b+0]^g,l[b+1]=f[b+1]^u,l[b+2]=f[b+2]^y,l[b+3]=f[b+3]^d,p=p+1>>>0,c.setUint32(h,p,t),{s0:g,s1:u,s2:y,s3:d}=Y(e,i[0],i[1],i[2],i[3]);let w=R*Math.floor(f.length/Nt);if(w<a){let b=new Uint32Array([g,u,y,d]),U=dt(b);for(let L=w,C=0;L<a;L++,C++)o[L]=r[L]^U[C];B(b)}return o}var Gt=D({blockSize:16,nonceLength:16},function(t,n){function r(o,s){if(E(o),s!==void 0&&(E(s),!Z(s)))throw new Error("unaligned destination");let i=rt(t),c=z(n),f=[i,c];Z(o)||f.push(o=z(o));let l=ke(i,c,o,s);return B(...f),l}return{encrypt:(o,s)=>r(o,s),decrypt:(o,s)=>r(o,s)}});function Jt(e){if(E(e),e.length%R!==0)throw new Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size "+R)}function Xt(e,t,n){E(e);let r=e.length,o=r%R;if(!t&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");Z(e)||(e=z(e));let s=A(e);if(t){let c=R-o;c||(c=R),r=r+c}n=Q(r,n),pt(e,n);let i=A(n);return{b:s,o:i,out:n}}function Dt(e,t){if(!t)return e;let n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");let r=e[n-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");let o=e.subarray(0,-r);for(let s=0;s<r;s++)if(e[n-s-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}function te(e){let t=new Uint8Array(16),n=A(t);t.set(e);let r=R-e.length;for(let o=R-r;o<R;o++)t[o]=r;return n}var ee=D({blockSize:16},function(t,n={}){let r=!n.disablePadding;return{encrypt(o,s){let{b:i,o:c,out:f}=Xt(o,r,s),l=rt(t),h=0;for(;h+4<=i.length;){let{s0:a,s1:p,s2:g,s3:u}=Y(l,i[h+0],i[h+1],i[h+2],i[h+3]);c[h++]=a,c[h++]=p,c[h++]=g,c[h++]=u}if(r){let a=te(o.subarray(h*4)),{s0:p,s1:g,s2:u,s3:y}=Y(l,a[0],a[1],a[2],a[3]);c[h++]=p,c[h++]=g,c[h++]=u,c[h++]=y}return B(l),f},decrypt(o,s){Jt(o);let i=Yt(t);s=Q(o.length,s);let c=[i];Z(o)||c.push(o=z(o)),pt(o,s);let f=A(o),l=A(s);for(let h=0;h+4<=f.length;){let{s0:a,s1:p,s2:g,s3:u}=Qt(i,f[h+0],f[h+1],f[h+2],f[h+3]);l[h++]=a,l[h++]=p,l[h++]=g,l[h++]=u}return B(...c),Dt(s,r)}}}),ne=D({blockSize:16,nonceLength:16},function(t,n,r={}){let o=!r.disablePadding;return{encrypt(s,i){let c=rt(t),{b:f,o:l,out:h}=Xt(s,o,i),a=n,p=[c];Z(a)||p.push(a=z(a));let g=A(a),u=g[0],y=g[1],d=g[2],w=g[3],b=0;for(;b+4<=f.length;)u^=f[b+0],y^=f[b+1],d^=f[b+2],w^=f[b+3],{s0:u,s1:y,s2:d,s3:w}=Y(c,u,y,d,w),l[b++]=u,l[b++]=y,l[b++]=d,l[b++]=w;if(o){let U=te(s.subarray(b*4));u^=U[0],y^=U[1],d^=U[2],w^=U[3],{s0:u,s1:y,s2:d,s3:w}=Y(c,u,y,d,w),l[b++]=u,l[b++]=y,l[b++]=d,l[b++]=w}return B(...p),h},decrypt(s,i){Jt(s);let c=Yt(t),f=n,l=[c];Z(f)||l.push(f=z(f));let h=A(f);i=Q(s.length,i),Z(s)||l.push(s=z(s)),pt(s,i);let a=A(s),p=A(i),g=h[0],u=h[1],y=h[2],d=h[3];for(let w=0;w+4<=a.length;){let b=g,U=u,L=y,C=d;g=a[w+0],u=a[w+1],y=a[w+2],d=a[w+3];let{s0:v,s1:j,s2:V,s3:_}=Qt(c,g,u,y,d);p[w++]=v^b,p[w++]=j^U,p[w++]=V^L,p[w++]=_^C}return B(...l),Dt(i,o)}}}),re=D({blockSize:16,nonceLength:16},function(t,n){function r(o,s,i){E(o);let c=o.length;if(i=Q(c,i),vt(o,i))throw new Error("overlapping src and dst not supported.");let f=rt(t),l=n,h=[f];Z(l)||h.push(l=z(l)),Z(o)||h.push(o=z(o));let a=A(o),p=A(i),g=s?p:a,u=A(l),y=u[0],d=u[1],w=u[2],b=u[3];for(let L=0;L+4<=a.length;){let{s0:C,s1:v,s2:j,s3:V}=Y(f,y,d,w,b);p[L+0]=a[L+0]^C,p[L+1]=a[L+1]^v,p[L+2]=a[L+2]^j,p[L+3]=a[L+3]^V,y=g[L++],d=g[L++],w=g[L++],b=g[L++]}let U=R*Math.floor(a.length/Nt);if(U<c){({s0:y,s1:d,s2:w,s3:b}=Y(f,y,d,w,b));let L=dt(new Uint32Array([y,d,w,b]));for(let C=U,v=0;C<c;C++,v++)i[C]=o[C]^L[v];B(L)}return B(...h),i}return{encrypt:(o,s)=>r(o,!0,s),decrypt:(o,s)=>r(o,!1,s)}});function Ne(e,t,n,r,o){let s=o?o.length:0,i=e.create(n,r.length+s);o&&i.update(o);let c=bt(8*r.length,8*s,t);i.update(r),i.update(c);let f=i.digest();return B(c),f}var oe=D({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(t,n,r){if(n.length<8)throw new Error("aes/gcm: invalid nonce length");let o=16;function s(c,f,l){let h=Ne(It,!1,c,l,r);for(let a=0;a<f.length;a++)h[a]^=f[a];return h}function i(){let c=rt(t),f=Lt.slice(),l=Lt.slice();if(Et(c,!1,l,l,f),n.length===12)l.set(n);else{let a=Lt.slice();at(a).setBigUint64(8,BigInt(n.length*8),!1);let g=It.create(f).update(n).update(a);g.digestInto(l),g.destroy()}let h=Et(c,!1,l,Lt);return{xk:c,authKey:f,counter:l,tagMask:h}}return{encrypt(c){let{xk:f,authKey:l,counter:h,tagMask:a}=i(),p=new Uint8Array(c.length+o),g=[f,l,h,a];Z(c)||g.push(c=z(c)),Et(f,!1,h,c,p.subarray(0,c.length));let u=s(l,a,p.subarray(0,p.length-o));return g.push(u),p.set(u,c.length),B(...g),p},decrypt(c){let{xk:f,authKey:l,counter:h,tagMask:a}=i(),p=[f,l,a,h];Z(c)||p.push(c=z(c));let g=c.subarray(0,-o),u=c.subarray(-o),y=s(l,a,g);if(p.push(y),!wt(y,u))throw new Error("aes/gcm: invalid ghash tag");let d=Et(f,!1,h,g);return B(...p),d}}});function Me(e){return e instanceof Uint32Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint32Array"}function Ot(e,t){if(E(t,16,"block"),!Me(e))throw new Error("_encryptBlock accepts result of expandKeyLE");let n=A(t),{s0:r,s1:o,s2:s,s3:i}=Y(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=o,n[2]=s,n[3]=i,t}function qt(e){let t=0;for(let n=R-1;n>=0;n--){let r=(e[n]&128)>>>7;e[n]=e[n]<<1|t,t=r}return t&&(e[R-1]^=135),e}function Ut(e,t){if(e.length!==t.length)throw new Error("xorBlock: blocks must have same length");for(let n=0;n<e.length;n++)e[n]=e[n]^t[n];return e}var At=class{buffer;destroyed;k1;k2;xk;constructor(t){E(t),$t(t),this.xk=rt(t),this.buffer=new Uint8Array(0),this.destroyed=!1;let n=new Uint8Array(R);Ot(this.xk,n),this.k1=qt(n),this.k2=qt(new Uint8Array(this.k1))}update(t){let{destroyed:n,buffer:r}=this;if(n)throw new Error("CMAC instance was destroyed");E(t);let o=new Uint8Array(r.length+t.length);return o.set(r),o.set(t,r.length),this.buffer=o,this}digest(){if(this.destroyed)throw new Error("CMAC instance was destroyed");let{buffer:t}=this,n=t.length,r=Math.ceil(n/R),o;r===0?(r=1,o=!1):o=n%R===0;let s=(r-1)*R,i=t.subarray(s),c;if(o)c=Ut(new Uint8Array(i),this.k1);else{let l=new Uint8Array(R);l.set(i),l[i.length]=128,c=Ut(l,this.k2)}let f=new Uint8Array(R);for(let l=0;l<r-1;l++){let h=t.subarray(l*R,(l+1)*R);Ut(f,h),Ot(this.xk,f)}return Ut(f,c),Ot(this.xk,f),B(c),f}destroy(){let{buffer:t,destroyed:n,xk:r,k1:o,k2:s}=this;n||(this.destroyed=!0,B(t,r,o,s))}},Pe=(e,t)=>new At(e).update(t).digest();Pe.create=e=>new At(e);var se=()=>{throw new Error('"siv" from v1 is now "gcmsiv"')};var ie=e=>Uint8Array.from(e.split(""),t=>t.charCodeAt(0)),ze=ie("expand 16-byte k"),Re=ie("expand 32-byte k"),We=A(ze),je=A(Re);function x(e,t){return e<<t|e>>>32-t}function zt(e){return e.byteOffset%4===0}var Bt=64,Ve=16,fe=2**32-1,ce=Uint32Array.of();function He(e,t,n,r,o,s,i,c){let f=o.length,l=new Uint8Array(Bt),h=A(l),a=zt(o)&&zt(s),p=a?A(o):ce,g=a?A(s):ce;for(let u=0;u<f;i++){if(e(t,n,r,h,i,c),i>=fe)throw new Error("arx: counter overflow");let y=Math.min(Bt,f-u);if(a&&y===Bt){let d=u/4;if(u%4!==0)throw new Error("arx: invalid block position");for(let w=0,b;w<Ve;w++)b=d+w,g[b]=p[b]^h[w];u+=Bt;continue}for(let d=0,w;d<y;d++)w=u+d,s[w]=o[w]^l[d];u+=y}}function Rt(e,t){let{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:s,rounds:i}=jt({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!="function")throw new Error("core must be a function");return ht(o),ht(i),yt(s),yt(n),(c,f,l,h,a=0)=>{E(c,void 0,"key"),E(f,void 0,"nonce"),E(l,void 0,"data");let p=l.length;if(h===void 0&&(h=new Uint8Array(p)),E(h,void 0,"output"),ht(a),a<0||a>=fe)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);let g=[],u=c.length,y,d;if(u===32)g.push(y=z(c)),d=je;else if(u===16&&n)y=new Uint8Array(32),y.set(c),y.set(c,16),d=We,g.push(y);else throw E(c,32,"arx key"),new Error("invalid key size");zt(f)||g.push(f=z(f));let w=A(y);if(r){if(f.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(d,w,A(f.subarray(0,16)),w),f=f.subarray(16)}let b=16-o;if(b!==f.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(b!==12){let L=new Uint8Array(12);L.set(f,s?0:12-f.length),f=L,g.push(f)}let U=A(f);return He(e,d,w,U,l,h,a,i),B(...g),h}}function $(e,t){return e[t++]&255|(e[t++]&255)<<8}var Wt=class{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;constructor(t){t=z(E(t,32,"key"));let n=$(t,0),r=$(t,2),o=$(t,4),s=$(t,6),i=$(t,8),c=$(t,10),f=$(t,12),l=$(t,14);this.r[0]=n&8191,this.r[1]=(n>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|s<<9)&8191,this.r[4]=(s>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|c<<2)&8191,this.r[7]=(c>>>11|f<<5)&8065,this.r[8]=(f>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let h=0;h<8;h++)this.pad[h]=$(t,16+2*h)}process(t,n,r=!1){let o=r?0:2048,{h:s,r:i}=this,c=i[0],f=i[1],l=i[2],h=i[3],a=i[4],p=i[5],g=i[6],u=i[7],y=i[8],d=i[9],w=$(t,n+0),b=$(t,n+2),U=$(t,n+4),L=$(t,n+6),C=$(t,n+8),v=$(t,n+10),j=$(t,n+12),V=$(t,n+14),_=s[0]+(w&8191),S=s[1]+((w>>>13|b<<3)&8191),T=s[2]+((b>>>10|U<<6)&8191),I=s[3]+((U>>>7|L<<9)&8191),K=s[4]+((L>>>4|C<<12)&8191),O=s[5]+(C>>>1&8191),k=s[6]+((C>>>14|v<<2)&8191),N=s[7]+((v>>>11|j<<5)&8191),M=s[8]+((j>>>8|V<<8)&8191),P=s[9]+(V>>>5|o),m=0,H=m+_*c+S*(5*d)+T*(5*y)+I*(5*u)+K*(5*g);m=H>>>13,H&=8191,H+=O*(5*p)+k*(5*a)+N*(5*h)+M*(5*l)+P*(5*f),m+=H>>>13,H&=8191;let q=m+_*f+S*c+T*(5*d)+I*(5*y)+K*(5*u);m=q>>>13,q&=8191,q+=O*(5*g)+k*(5*p)+N*(5*a)+M*(5*h)+P*(5*l),m+=q>>>13,q&=8191;let W=m+_*l+S*f+T*c+I*(5*d)+K*(5*y);m=W>>>13,W&=8191,W+=O*(5*u)+k*(5*g)+N*(5*p)+M*(5*a)+P*(5*h),m+=W>>>13,W&=8191;let X=m+_*h+S*l+T*f+I*c+K*(5*d);m=X>>>13,X&=8191,X+=O*(5*y)+k*(5*u)+N*(5*g)+M*(5*p)+P*(5*a),m+=X>>>13,X&=8191;let ot=m+_*a+S*h+T*l+I*f+K*c;m=ot>>>13,ot&=8191,ot+=O*(5*d)+k*(5*y)+N*(5*u)+M*(5*g)+P*(5*p),m+=ot>>>13,ot&=8191;let st=m+_*p+S*a+T*h+I*l+K*f;m=st>>>13,st&=8191,st+=O*c+k*(5*d)+N*(5*y)+M*(5*u)+P*(5*g),m+=st>>>13,st&=8191;let ct=m+_*g+S*p+T*a+I*h+K*l;m=ct>>>13,ct&=8191,ct+=O*f+k*c+N*(5*d)+M*(5*y)+P*(5*u),m+=ct>>>13,ct&=8191;let it=m+_*u+S*g+T*p+I*a+K*h;m=it>>>13,it&=8191,it+=O*l+k*f+N*c+M*(5*d)+P*(5*y),m+=it>>>13,it&=8191;let ft=m+_*y+S*u+T*g+I*p+K*a;m=ft>>>13,ft&=8191,ft+=O*h+k*l+N*f+M*c+P*(5*d),m+=ft>>>13,ft&=8191;let lt=m+_*d+S*y+T*u+I*g+K*p;m=lt>>>13,lt&=8191,lt+=O*a+k*h+N*l+M*f+P*c,m+=lt>>>13,lt&=8191,m=(m<<2)+m|0,m=m+H|0,H=m&8191,m=m>>>13,q+=m,s[0]=H,s[1]=q,s[2]=W,s[3]=X,s[4]=ot,s[5]=st,s[6]=ct,s[7]=it,s[8]=ft,s[9]=lt}finalize(){let{h:t,pad:n}=this,r=new Uint16Array(10),o=t[1]>>>13;t[1]&=8191;for(let c=2;c<10;c++)t[c]+=o,o=t[c]>>>13,t[c]&=8191;t[0]+=o*5,o=t[0]>>>13,t[0]&=8191,t[1]+=o,o=t[1]>>>13,t[1]&=8191,t[2]+=o,r[0]=t[0]+5,o=r[0]>>>13,r[0]&=8191;for(let c=1;c<10;c++)r[c]=t[c]+o,o=r[c]>>>13,r[c]&=8191;r[9]-=8192;let s=(o^1)-1;for(let c=0;c<10;c++)r[c]&=s;s=~s;for(let c=0;c<10;c++)t[c]=t[c]&s|r[c];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let i=t[0]+n[0];t[0]=i&65535;for(let c=1;c<8;c++)i=(t[c]+n[c]|0)+(i>>>16)|0,t[c]=i&65535;B(r)}update(t){et(this),E(t),t=z(t);let{buffer:n,blockLen:r}=this,o=t.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);if(i===r){for(;r<=o-s;s+=r)this.process(t,s);continue}n.set(t.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===r&&(this.process(n,0,!1),this.pos=0)}return this}destroy(){B(this.h,this.r,this.buffer,this.pad)}digestInto(t){et(this),gt(t,this),this.finished=!0;let{buffer:n,h:r}=this,{pos:o}=this;if(o){for(n[o++]=1;o<16;o++)n[o]=0;this.process(n,0,!0)}this.finalize();let s=0;for(let i=0;i<8;i++)t[s++]=r[i]>>>0,t[s++]=r[i]>>>8;return t}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}};function qe(e){let t=(r,o)=>e(o).update(r).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}var le=qe(e=>new Wt(e));function ue(e,t,n,r,o,s=20){let i=e[0],c=e[1],f=e[2],l=e[3],h=t[0],a=t[1],p=t[2],g=t[3],u=t[4],y=t[5],d=t[6],w=t[7],b=o,U=n[0],L=n[1],C=n[2],v=i,j=c,V=f,_=l,S=h,T=a,I=p,K=g,O=u,k=y,N=d,M=w,P=b,m=U,H=L,q=C;for(let X=0;X<s;X+=2)v=v+S|0,P=x(P^v,16),O=O+P|0,S=x(S^O,12),v=v+S|0,P=x(P^v,8),O=O+P|0,S=x(S^O,7),j=j+T|0,m=x(m^j,16),k=k+m|0,T=x(T^k,12),j=j+T|0,m=x(m^j,8),k=k+m|0,T=x(T^k,7),V=V+I|0,H=x(H^V,16),N=N+H|0,I=x(I^N,12),V=V+I|0,H=x(H^V,8),N=N+H|0,I=x(I^N,7),_=_+K|0,q=x(q^_,16),M=M+q|0,K=x(K^M,12),_=_+K|0,q=x(q^_,8),M=M+q|0,K=x(K^M,7),v=v+T|0,q=x(q^v,16),N=N+q|0,T=x(T^N,12),v=v+T|0,q=x(q^v,8),N=N+q|0,T=x(T^N,7),j=j+I|0,P=x(P^j,16),M=M+P|0,I=x(I^M,12),j=j+I|0,P=x(P^j,8),M=M+P|0,I=x(I^M,7),V=V+K|0,m=x(m^V,16),O=O+m|0,K=x(K^O,12),V=V+K|0,m=x(m^V,8),O=O+m|0,K=x(K^O,7),_=_+S|0,H=x(H^_,16),k=k+H|0,S=x(S^k,12),_=_+S|0,H=x(H^_,8),k=k+H|0,S=x(S^k,7);let W=0;r[W++]=i+v|0,r[W++]=c+j|0,r[W++]=f+V|0,r[W++]=l+_|0,r[W++]=h+S|0,r[W++]=a+T|0,r[W++]=p+I|0,r[W++]=g+K|0,r[W++]=u+O|0,r[W++]=y+k|0,r[W++]=d+N|0,r[W++]=w+M|0,r[W++]=b+P|0,r[W++]=U+m|0,r[W++]=L+H|0,r[W++]=C+q|0}function $e(e,t,n,r){let o=e[0],s=e[1],i=e[2],c=e[3],f=t[0],l=t[1],h=t[2],a=t[3],p=t[4],g=t[5],u=t[6],y=t[7],d=n[0],w=n[1],b=n[2],U=n[3];for(let C=0;C<20;C+=2)o=o+f|0,d=x(d^o,16),p=p+d|0,f=x(f^p,12),o=o+f|0,d=x(d^o,8),p=p+d|0,f=x(f^p,7),s=s+l|0,w=x(w^s,16),g=g+w|0,l=x(l^g,12),s=s+l|0,w=x(w^s,8),g=g+w|0,l=x(l^g,7),i=i+h|0,b=x(b^i,16),u=u+b|0,h=x(h^u,12),i=i+h|0,b=x(b^i,8),u=u+b|0,h=x(h^u,7),c=c+a|0,U=x(U^c,16),y=y+U|0,a=x(a^y,12),c=c+a|0,U=x(U^c,8),y=y+U|0,a=x(a^y,7),o=o+l|0,U=x(U^o,16),u=u+U|0,l=x(l^u,12),o=o+l|0,U=x(U^o,8),u=u+U|0,l=x(l^u,7),s=s+h|0,d=x(d^s,16),y=y+d|0,h=x(h^y,12),s=s+h|0,d=x(d^s,8),y=y+d|0,h=x(h^y,7),i=i+a|0,w=x(w^i,16),p=p+w|0,a=x(a^p,12),i=i+a|0,w=x(w^i,8),p=p+w|0,a=x(a^p,7),c=c+f|0,b=x(b^c,16),g=g+b|0,f=x(f^g,12),c=c+f|0,b=x(b^c,8),g=g+b|0,f=x(f^g,7);let L=0;r[L++]=o,r[L++]=s,r[L++]=i,r[L++]=c,r[L++]=d,r[L++]=w,r[L++]=b,r[L++]=U}var Ze=Rt(ue,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Fe=Rt(ue,{counterRight:!1,counterLength:8,extendNonceFn:$e,allowShortKeys:!1});var Ye=new Uint8Array(16),he=(e,t)=>{e.update(t);let n=t.length%16;n&&e.update(Ye.subarray(n))},Qe=new Uint8Array(32);function ae(e,t,n,r,o){o!==void 0&&E(o,void 0,"AAD");let s=e(t,n,Qe),i=bt(r.length,o?o.length:0,!0),c=le.create(s);o&&he(c,o),he(c,r),c.update(i);let f=c.digest();return B(s,i),f}var ge=e=>(t,n,r)=>({encrypt(s,i){let c=s.length;i=Q(c+16,i,!1),i.set(s);let f=i.subarray(0,-16);e(t,n,f,f,1);let l=ae(e,t,n,f,r);return i.set(l,c),B(l),i},decrypt(s,i){i=Q(s.length-16,i,!1);let c=s.subarray(0,-16),f=s.subarray(-16),l=ae(e,t,n,c,r);if(!wt(f,l))throw new Error("invalid tag");return i.set(s.subarray(0,-16)),e(t,n,i,i,1),B(l),i}}),pe=D({blockSize:64,nonceLength:12,tagLength:16},ge(Ze)),ye=D({blockSize:64,nonceLength:24,tagLength:16},ge(Fe));return Le(Ge);})();
378−/*! Bundled license information:
379−
380−@noble/ciphers/utils.js:
381− (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
382−*/
383173
384−
385−// CIPHER FUNCTIONS
174+// CIPHER (XSalsa20-Poly1305 via secretbox)
386175
387176function _Crypto_cipherKeyFromHex(hex)
388177{
@@ -400,22 +189,6 @@ function _Crypto_cipherKeyToHex(key)
400189 return key;
401190}
402191
403−function _Crypto_cipherNonce12FromHex(hex)
404−{
405− try {
406− var bytes = _Crypto_fromHex(hex);
407− if (bytes.length !== 12) { return __Maybe_Nothing; }
408− return __Maybe_Just(hex);
409− } catch (e) {
410− return __Maybe_Nothing;
411− }
412−}
413−
414−function _Crypto_cipherNonce12ToHex(nonce)
415−{
416− return nonce;
417−}
418−
419192function _Crypto_cipherNonce24FromHex(hex)
420193{
421194 try {
@@ -432,58 +205,26 @@ function _Crypto_cipherNonce24ToHex(nonce)
432205 return nonce;
433206}
434207
435−
436−// AES-256-GCM
437−
438−var _Crypto_aesGcmEncrypt = F3(function(key, nonce, plaintext)
208+var _Crypto_encrypt = F3(function(key, nonce, plaintext)
439209{
440− var cipher = _Crypto_ciphers.gcm(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
441− return _Crypto_toHex(cipher.encrypt(_Crypto_fromHex(plaintext)));
210+ var result = _Crypto_nacl.secretbox(
211+ _Crypto_fromHex(plaintext),
212+ _Crypto_fromHex(nonce),
213+ _Crypto_fromHex(key)
214+ );
215+ return _Crypto_toHex(result);
442216});
443217
444−var _Crypto_aesGcmDecrypt = F3(function(key, nonce, ciphertext)
218+var _Crypto_decrypt = F3(function(key, nonce, ciphertext)
445219{
446220 try {
447− var cipher = _Crypto_ciphers.gcm(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
448− return __Maybe_Just(_Crypto_toHex(cipher.decrypt(_Crypto_fromHex(ciphertext))));
449− } catch (e) {
450− return __Maybe_Nothing;
451− }
452−});
453−
454−
455−// CHACHA20-POLY1305
456−
457−var _Crypto_chacha20Encrypt = F3(function(key, nonce, plaintext)
458−{
459− var cipher = _Crypto_ciphers.chacha20poly1305(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
460− return _Crypto_toHex(cipher.encrypt(_Crypto_fromHex(plaintext)));
461−});
462−
463−var _Crypto_chacha20Decrypt = F3(function(key, nonce, ciphertext)
464−{
465− try {
466− var cipher = _Crypto_ciphers.chacha20poly1305(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
467− return __Maybe_Just(_Crypto_toHex(cipher.decrypt(_Crypto_fromHex(ciphertext))));
468− } catch (e) {
469− return __Maybe_Nothing;
470− }
471−});
472−
473−
474−// XCHACHA20-POLY1305
475−
476−var _Crypto_xchacha20Encrypt = F3(function(key, nonce, plaintext)
477−{
478− var cipher = _Crypto_ciphers.xchacha20poly1305(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
479− return _Crypto_toHex(cipher.encrypt(_Crypto_fromHex(plaintext)));
480−});
481−
482−var _Crypto_xchacha20Decrypt = F3(function(key, nonce, ciphertext)
483−{
484− try {
485− var cipher = _Crypto_ciphers.xchacha20poly1305(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
486− return __Maybe_Just(_Crypto_toHex(cipher.decrypt(_Crypto_fromHex(ciphertext))));
221+ var result = _Crypto_nacl.secretbox.open(
222+ _Crypto_fromHex(ciphertext),
223+ _Crypto_fromHex(nonce),
224+ _Crypto_fromHex(key)
225+ );
226+ if (result === null) { return __Maybe_Nothing; }
227+ return __Maybe_Just(_Crypto_toHex(result));
487228 } catch (e) {
488229 return __Maybe_Nothing;
489230 }