Astroport.ONE/www/crypto.mjs

1 line
66 KiB
JavaScript

import t from"tweetnacl";function a(t,r,n){var e=void 0===n?{}:n,o=e.N,i=void 0===o?16384:o,s=e.logN,f=e.r,a=void 0===f?8:f,c=e.p,u=void 0===c?1:c,l=e.dkLen,y=void 0===l?32:l,d=e.interruptStep,p=void 0===d?0:d,w=e.encoding;return new Promise((function(n,e){if(!s&&!i)return e(new Error("scrypt: missing N or logN parameter"));if(s||0===s){if(s<1||s>31)return e(new Error("scrypt: logN must be between 1 and 31"));i=1<<s>>>0}else{if(i<2||i>h)return e(new Error("scrypt: N is out of range"));if(0!=(i&i-1))return e(Error("scrypt: N is not a power of 2"))}return u<1?e(new Error("scrypt: invalid p")):a<1?e(new Error("scrypt: invalid r")):void function(t,r){var n,e,o,i,s=t.password,f=t.salt,a=t.N,c=t.r,u=t.p,l=t.dkLen,y=t.interruptStep,d=t.encoding;function p(t){var r=[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],n=1779033703,e=3144134277,o=1013904242,i=2773480762,s=1359893119,f=2600822924,h=528734635,a=1541459225,c=new Array(64);function u(t){for(var u=0,l=t.length;l>=64;){var y=n,d=e,p=o,w=i,g=s,v=f,b=h,A=a,E=void 0,m=void 0,x=void 0,_=void 0,B=void 0;for(m=0;m<16;m++)x=u+4*m,c[m]=(255&t[x])<<24|(255&t[x+1])<<16|(255&t[x+2])<<8|255&t[x+3];for(m=16;m<64;m++)_=((E=c[m-2])>>>17|E<<15)^(E>>>19|E<<13)^E>>>10,B=((E=c[m-15])>>>7|E<<25)^(E>>>18|E<<14)^E>>>3,c[m]=(_+c[m-7]|0)+(B+c[m-16]|0)|0;for(m=0;m<64;m++)_=(((g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&v^~g&b)|0)+(A+(r[m]+c[m]|0)|0)|0,B=((y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10))+(y&d^y&p^d&p)|0,A=b,b=v,v=g,g=w+_|0,w=p,p=d,d=y,y=_+B|0;n=n+y|0,e=e+d|0,o=o+p|0,i=i+w|0,s=s+g|0,f=f+v|0,h=h+b|0,a=a+A|0,u+=64,l-=64}}u(t);var l,y=t.length%64,d=t.length/536870912|0,p=t.length<<3,w=y<56?56:120,g=t.slice(t.length-y,t.length);for(g.push(128),l=y+1;l<w;l++)g.push(0);return g.push(d>>>24&255),g.push(d>>>16&255),g.push(d>>>8&255),g.push(d>>>0&255),g.push(p>>>24&255),g.push(p>>>16&255),g.push(p>>>8&255),g.push(p>>>0&255),u(g),[n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,e>>>24&255,e>>>16&255,e>>>8&255,e>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255,h>>>24&255,h>>>16&255,h>>>8&255,h>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255]}function w(t,r,n){t.length>64&&(t=p(t.push?t:function(){for(var t=0,r=0,n=arguments.length;r<n;r++)t+=arguments[r].length;var e=Array(t),o=0;for(r=0;r<n;r++)for(var i=arguments[r],s=0,f=i.length;s<f;s++,o++)e[o]=i[s];return e}(t)));var e,o=64+r.length+4,i=new Array(o),s=new Array(64),f=[];for(e=0;e<64;e++)i[e]=54;for(e=0;e<t.length;e++)i[e]^=t[e];for(e=0;e<r.length;e++)i[64+e]=r[e];for(e=o-4;e<o;e++)i[e]=0;for(e=0;e<64;e++)s[e]=92;for(e=0;e<t.length;e++)s[e]^=t[e];function h(){for(var t=o-1;t>=o-4;t--){if(i[t]++,i[t]<=255)return;i[t]=0}}for(;n>=32;)h(),f=f.concat(p(s.concat(p(i)))),n-=32;return n>0&&(h(),f=f.concat(p(s.concat(p(i))).slice(0,n))),f}function g(t,r,n,e){var o,i,s=t[0]^r[n++],f=t[1]^r[n++],h=t[2]^r[n++],a=t[3]^r[n++],c=t[4]^r[n++],u=t[5]^r[n++],l=t[6]^r[n++],y=t[7]^r[n++],d=t[8]^r[n++],p=t[9]^r[n++],w=t[10]^r[n++],g=t[11]^r[n++],v=t[12]^r[n++],b=t[13]^r[n++],A=t[14]^r[n++],E=t[15]^r[n++],m=s,x=f,_=h,B=a,U=c,S=u,P=l,k=y,M=d,I=p,T=w,R=g,z=v,N=b,L=A,K=E;for(i=0;i<8;i+=2)m^=(o=(z^=(o=(M^=(o=(U^=(o=m+z)<<7|o>>>25)+m)<<9|o>>>23)+U)<<13|o>>>19)+M)<<18|o>>>14,S^=(o=(x^=(o=(N^=(o=(I^=(o=S+x)<<7|o>>>25)+S)<<9|o>>>23)+I)<<13|o>>>19)+N)<<18|o>>>14,T^=(o=(P^=(o=(_^=(o=(L^=(o=T+P)<<7|o>>>25)+T)<<9|o>>>23)+L)<<13|o>>>19)+_)<<18|o>>>14,K^=(o=(R^=(o=(k^=(o=(B^=(o=K+R)<<7|o>>>25)+K)<<9|o>>>23)+B)<<13|o>>>19)+k)<<18|o>>>14,m^=(o=(B^=(o=(_^=(o=(x^=(o=m+B)<<7|o>>>25)+m)<<9|o>>>23)+x)<<13|o>>>19)+_)<<18|o>>>14,S^=(o=(U^=(o=(k^=(o=(P^=(o=S+U)<<7|o>>>25)+S)<<9|o>>>23)+P)<<13|o>>>19)+k)<<18|o>>>14,T^=(o=(I^=(o=(M^=(o=(R^=(o=T+I)<<7|o>>>25)+T)<<9|o>>>23)+R)<<13|o>>>19)+M)<<18|o>>>14,K^=(o=(L^=(o=(N^=(o=(z^=(o=K+L)<<7|o>>>25)+K)<<9|o>>>23)+z)<<13|o>>>19)+N)<<18|o>>>14;r[e++]=t[0]=m+s|0,r[e++]=t[1]=x+f|0,r[e++]=t[2]=_+h|0,r[e++]=t[3]=B+a|0,r[e++]=t[4]=U+c|0,r[e++]=t[5]=S+u|0,r[e++]=t[6]=P+l|0,r[e++]=t[7]=k+y|0,r[e++]=t[8]=M+d|0,r[e++]=t[9]=I+p|0,r[e++]=t[10]=T+w|0,r[e++]=t[11]=R+g|0,r[e++]=t[12]=z+v|0,r[e++]=t[13]=N+b|0,r[e++]=t[14]=L+A|0,r[e++]=t[15]=K+E|0}function v(t,r,n,e,o){for(;o--;)t[r++]=n[e++]}function b(t,r,n,e,o){for(;o--;)t[r++]^=n[e++]}function A(t,r,n,e,o){v(t,0,r,n+16*(2*o-1),16);for(var i=0;i<2*o;i+=2)g(t,r,n+16*i,e+8*i),g(t,r,n+16*i+16,e+8*i+16*o)}function E(t,r,n){return t[r+16*(2*n-1)]}function m(t){for(var r=[],n=0;n<t.length;n++){var e=t.charCodeAt(n);if(e<128)r.push(e);else if(e<2048)r.push(192|e>>6),r.push(128|63&e);else if(e<55296)r.push(224|e>>12),r.push(128|e>>6&63),r.push(128|63&e);else{if(n>=t.length-1)throw new Error("invalid string");n++,e=(1023&e)<<10,e|=1023&t.charCodeAt(n),e+=65536,r.push(240|e>>18),r.push(128|e>>12&63),r.push(128|e>>6&63),r.push(128|63&e)}}return r}if(c*u>=1<<30||c>h/128/u||c>h/256||a>h/128/c)throw new Error("scrypt: parameters are too large");"string"==typeof s&&(s=m(s)),"string"==typeof f&&(f=m(f)),"undefined"!=typeof Int32Array?(n=new Int32Array(64*c),e=new Int32Array(32*a*c),i=new Int32Array(16)):(n=[],e=[],i=new Array(16)),o=w(s,f,128*u*c);var x=32*c;function _(t){for(var r=0;r<32*c;r++){var e=t+4*r;n[0+r]=(255&o[e+3])<<24|(255&o[e+2])<<16|(255&o[e+1])<<8|(255&o[e+0])<<0}}function B(t,r){for(var o=t;o<r;o+=2)v(e,o*(32*c),n,0,32*c),A(i,n,0,x,c),v(e,(o+1)*(32*c),n,x,32*c),A(i,n,x,0,c)}function U(t,r){for(var o=t;o<r;o+=2){var s=E(n,0,c)&a-1;b(n,0,e,s*(32*c),32*c),A(i,n,0,x,c),s=E(n,x,c)&a-1,b(n,x,e,s*(32*c),32*c),A(i,n,x,0,c)}}function S(t){for(var r=0;r<32*c;r++){var e=n[0+r];o[t+4*r+0]=e>>>0&255,o[t+4*r+1]=e>>>8&255,o[t+4*r+2]=e>>>16&255,o[t+4*r+3]=e>>>24&255}}var P="undefined"!=typeof setImmediate?setImmediate:setTimeout;function k(t,r,n,e,o){!function i(){P((function(){e(t,t+n<r?t+n:r),(t+=n)<r?i():o()}))}()}function M(t){var r=w(s,o,l);return"base64"===t?function(t){for(var r,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),e=t.length,o=[],i=0;i<e;)r=((i<e?t[i++]:0)<<16)+((i<e?t[i++]:0)<<8)+(i<e?t[i++]:0),o.push(n[r>>>18&63]),o.push(n[r>>>12&63]),o.push(n[r>>>6&63]),o.push(n[r>>>0&63]);return e%3>0&&(o[o.length-1]="=",e%3==1&&(o[o.length-2]="=")),o.join("")}(r):"hex"===t?function(t){for(var r="0123456789abcdef".split(""),n=t.length,e=[],o=0;o<n;o++)e.push(r[t[o]>>>4&15]),e.push(r[t[o]>>>0&15]);return e.join("")}(r):"binary"===t?new Uint8Array(r):r}y<=0?function(){for(var t=0;t<u;t++)_(128*t*c),B(0,a),U(0,a),S(128*t*c);r(M(d))}():function t(n){_(128*n*c),k(0,a,2*y,B,(function(){k(0,a,2*y,U,(function(){S(128*n*c),n+1<u?P((function(){t(n+1)})):r(M(d))}))}))}(0)}({password:t,salt:r,N:i,r:a,p:u,dkLen:y,interruptStep:p,encoding:w},n)}))}var h=-1>>>0,c="input is invalid type";"object"==typeof process&&process.versions&&process.versions.node;var u="0123456789abcdef".split(""),l=[-2147483648,8388608,32768,128],y=[24,16,8,0],p=[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],d=["hex","array","digest","arrayBuffer"],w=[],g=function(t,r){return function(n){return new E(r,!0).update(n)[t]()}};function b(t){var r=g("hex",t);r.create=function(){return new E(t)},r.update=function(t){return r.create().update(t)};for(var n=0;n<d.length;++n){var e=d[n];r[e]=g(e,t)}return r}var v=function(t,r){return function(n,e){return new m(n,r,!0).update(e)[t]()}},A=function(t){var r=v("hex",t);r.create=function(r){return new m(r,t)},r.update=function(t,n){return r.create(t).update(n)};for(var n=0;n<d.length;++n){var e=d[n];r[e]=v(e,t)}return r};function E(t,r){r?(w[0]=w[16]=w[1]=w[2]=w[3]=w[4]=w[5]=w[6]=w[7]=w[8]=w[9]=w[10]=w[11]=w[12]=w[13]=w[14]=w[15]=0,this.blocks=w):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=t}function m(t,r,n){var e,o=typeof t;if("string"===o){var i,s=[],f=t.length,h=0;for(e=0;e<f;++e)(i=t.charCodeAt(e))<128?s[h++]=i:i<2048?(s[h++]=192|i>>6,s[h++]=128|63&i):i<55296||i>=57344?(s[h++]=224|i>>12,s[h++]=128|i>>6&63,s[h++]=128|63&i):(i=65536+((1023&i)<<10|1023&t.charCodeAt(++e)),s[h++]=240|i>>18,s[h++]=128|i>>12&63,s[h++]=128|i>>6&63,s[h++]=128|63&i);t=s}else{if("object"!==o)throw new Error(c);if(null===t)throw new Error(c);t=new Uint8Array(t)}t.length>64&&(t=new E(r,!0).update(t).array());var a=[],u=[];for(e=0;e<64;++e){var l=t[e]||0;a[e]=92^l,u[e]=54^l}E.call(this,r,n),this.update(u),this.oKeyPad=a,this.inner=!0,this.sharedMemory=n}E.prototype.update=function(t){if(!this.finalized){var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(c);if(null===t)throw new Error(c);t=new Uint8Array(t),r=!0}for(var e,o,i=0,s=t.length,f=this.blocks;i<s;){if(this.hashed&&(this.hashed=!1,f[0]=this.block,f[16]=f[1]=f[2]=f[3]=f[4]=f[5]=f[6]=f[7]=f[8]=f[9]=f[10]=f[11]=f[12]=f[13]=f[14]=f[15]=0),r)for(o=this.start;i<s&&o<64;++i)f[o>>2]|=t[i]<<y[3&o++];else for(o=this.start;i<s&&o<64;++i)(e=t.charCodeAt(i))<128?f[o>>2]|=e<<y[3&o++]:e<2048?(f[o>>2]|=(192|e>>6)<<y[3&o++],f[o>>2]|=(128|63&e)<<y[3&o++]):e<55296||e>=57344?(f[o>>2]|=(224|e>>12)<<y[3&o++],f[o>>2]|=(128|e>>6&63)<<y[3&o++],f[o>>2]|=(128|63&e)<<y[3&o++]):(e=65536+((1023&e)<<10|1023&t.charCodeAt(++i)),f[o>>2]|=(240|e>>18)<<y[3&o++],f[o>>2]|=(128|e>>12&63)<<y[3&o++],f[o>>2]|=(128|e>>6&63)<<y[3&o++],f[o>>2]|=(128|63&e)<<y[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.block=f[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},E.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[16]=this.block,t[r>>2]|=l[3&r],this.block=t[16],r>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},E.prototype.hash=function(){var t,r,n,e,o,i,s,f,h,a=this.h0,c=this.h1,u=this.h2,l=this.h3,y=this.h4,d=this.h5,w=this.h6,g=this.h7,v=this.blocks;for(t=16;t<64;++t)r=((o=v[t-15])>>>7|o<<25)^(o>>>18|o<<14)^o>>>3,n=((o=v[t-2])>>>17|o<<15)^(o>>>19|o<<13)^o>>>10,v[t]=v[t-16]+r+v[t-7]+n<<0;for(h=c&u,t=0;t<64;t+=4)this.first?(this.is224?(i=300032,g=(o=v[0]-1413257819)-150054599<<0,l=o+24177077<<0):(i=704751109,g=(o=v[0]-210244248)-1521486534<<0,l=o+143694565<<0),this.first=!1):(r=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),e=(i=a&c)^a&u^h,g=l+(o=g+(n=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7))+(y&d^~y&w)+p[t]+v[t])<<0,l=o+(r+e)<<0),r=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),e=(s=l&a)^l&c^i,w=u+(o=w+(n=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&y^~g&d)+p[t+1]+v[t+1])<<0,r=((u=o+(r+e)<<0)>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),e=(f=u&l)^u&a^s,d=c+(o=d+(n=(w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&g^~w&y)+p[t+2]+v[t+2])<<0,r=((c=o+(r+e)<<0)>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),e=(h=c&u)^c&l^f,y=a+(o=y+(n=(d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(d&w^~d&g)+p[t+3]+v[t+3])<<0,a=o+(r+e)<<0;this.h0=this.h0+a<<0,this.h1=this.h1+c<<0,this.h2=this.h2+u<<0,this.h3=this.h3+l<<0,this.h4=this.h4+y<<0,this.h5=this.h5+d<<0,this.h6=this.h6+w<<0,this.h7=this.h7+g<<0},E.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,n=this.h2,e=this.h3,o=this.h4,i=this.h5,s=this.h6,f=this.h7,h=u[t>>28&15]+u[t>>24&15]+u[t>>20&15]+u[t>>16&15]+u[t>>12&15]+u[t>>8&15]+u[t>>4&15]+u[15&t]+u[r>>28&15]+u[r>>24&15]+u[r>>20&15]+u[r>>16&15]+u[r>>12&15]+u[r>>8&15]+u[r>>4&15]+u[15&r]+u[n>>28&15]+u[n>>24&15]+u[n>>20&15]+u[n>>16&15]+u[n>>12&15]+u[n>>8&15]+u[n>>4&15]+u[15&n]+u[e>>28&15]+u[e>>24&15]+u[e>>20&15]+u[e>>16&15]+u[e>>12&15]+u[e>>8&15]+u[e>>4&15]+u[15&e]+u[o>>28&15]+u[o>>24&15]+u[o>>20&15]+u[o>>16&15]+u[o>>12&15]+u[o>>8&15]+u[o>>4&15]+u[15&o]+u[i>>28&15]+u[i>>24&15]+u[i>>20&15]+u[i>>16&15]+u[i>>12&15]+u[i>>8&15]+u[i>>4&15]+u[15&i]+u[s>>28&15]+u[s>>24&15]+u[s>>20&15]+u[s>>16&15]+u[s>>12&15]+u[s>>8&15]+u[s>>4&15]+u[15&s];return this.is224||(h+=u[f>>28&15]+u[f>>24&15]+u[f>>20&15]+u[f>>16&15]+u[f>>12&15]+u[f>>8&15]+u[f>>4&15]+u[15&f]),h},E.prototype.toString=E.prototype.hex,E.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,n=this.h2,e=this.h3,o=this.h4,i=this.h5,s=this.h6,f=this.h7,h=[t>>24&255,t>>16&255,t>>8&255,255&t,r>>24&255,r>>16&255,r>>8&255,255&r,n>>24&255,n>>16&255,n>>8&255,255&n,e>>24&255,e>>16&255,e>>8&255,255&e,o>>24&255,o>>16&255,o>>8&255,255&o,i>>24&255,i>>16&255,i>>8&255,255&i,s>>24&255,s>>16&255,s>>8&255,255&s];return this.is224||h.push(f>>24&255,f>>16&255,f>>8&255,255&f),h},E.prototype.array=E.prototype.digest,E.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),r=new DataView(t);return r.setUint32(0,this.h0),r.setUint32(4,this.h1),r.setUint32(8,this.h2),r.setUint32(12,this.h3),r.setUint32(16,this.h4),r.setUint32(20,this.h5),r.setUint32(24,this.h6),this.is224||r.setUint32(28,this.h7),t},m.prototype=new E,m.prototype.finalize=function(){if(E.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();E.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),E.prototype.finalize.call(this)}};const _=b();_.sha256=_,_.sha224=b(!0),_.sha256.hmac=A(),_.sha224.hmac=A(!0);var x={},U=function(t){var r,n=new Float64Array(16);if(t)for(r=0;r<t.length;r++)n[r]=t[r];return n},B=function(){throw new Error("no PRNG")},S=new Uint8Array(16),O=new Uint8Array(32);O[0]=9;var P=U(),k=U([1]),C=U([56129,1]),z=U([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),I=U([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),T=U([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),R=U([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),M=U([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function N(t,r,n,e){t[r]=n>>24&255,t[r+1]=n>>16&255,t[r+2]=n>>8&255,t[r+3]=255&n,t[r+4]=e>>24&255,t[r+5]=e>>16&255,t[r+6]=e>>8&255,t[r+7]=255&e}function L(t,r,n,e,o){var i,s=0;for(i=0;i<o;i++)s|=t[r+i]^n[e+i];return(1&s-1>>>8)-1}function K(t,r,n,e){return L(t,r,n,e,16)}function j(t,r,n,e){return L(t,r,n,e,32)}function D(t,r,n,e){!function(t,r,n,e){for(var o,i=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,f=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,a=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,c=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,u=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,l=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,y=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,d=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,w=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,g=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,v=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,b=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,A=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,E=i,m=s,x=f,_=h,B=a,U=c,S=u,P=l,k=y,M=d,I=p,T=w,R=g,z=v,N=b,L=A,K=0;K<20;K+=2)E^=(o=(R^=(o=(k^=(o=(B^=(o=E+R|0)<<7|o>>>25)+E|0)<<9|o>>>23)+B|0)<<13|o>>>19)+k|0)<<18|o>>>14,U^=(o=(m^=(o=(z^=(o=(M^=(o=U+m|0)<<7|o>>>25)+U|0)<<9|o>>>23)+M|0)<<13|o>>>19)+z|0)<<18|o>>>14,I^=(o=(S^=(o=(x^=(o=(N^=(o=I+S|0)<<7|o>>>25)+I|0)<<9|o>>>23)+N|0)<<13|o>>>19)+x|0)<<18|o>>>14,L^=(o=(T^=(o=(P^=(o=(_^=(o=L+T|0)<<7|o>>>25)+L|0)<<9|o>>>23)+_|0)<<13|o>>>19)+P|0)<<18|o>>>14,E^=(o=(_^=(o=(x^=(o=(m^=(o=E+_|0)<<7|o>>>25)+E|0)<<9|o>>>23)+m|0)<<13|o>>>19)+x|0)<<18|o>>>14,U^=(o=(B^=(o=(P^=(o=(S^=(o=U+B|0)<<7|o>>>25)+U|0)<<9|o>>>23)+S|0)<<13|o>>>19)+P|0)<<18|o>>>14,I^=(o=(M^=(o=(k^=(o=(T^=(o=I+M|0)<<7|o>>>25)+I|0)<<9|o>>>23)+T|0)<<13|o>>>19)+k|0)<<18|o>>>14,L^=(o=(N^=(o=(z^=(o=(R^=(o=L+N|0)<<7|o>>>25)+L|0)<<9|o>>>23)+R|0)<<13|o>>>19)+z|0)<<18|o>>>14;E=E+i|0,m=m+s|0,x=x+f|0,_=_+h|0,B=B+a|0,U=U+c|0,S=S+u|0,P=P+l|0,k=k+y|0,M=M+d|0,I=I+p|0,T=T+w|0,R=R+g|0,z=z+v|0,N=N+b|0,L=L+A|0,t[0]=E>>>0&255,t[1]=E>>>8&255,t[2]=E>>>16&255,t[3]=E>>>24&255,t[4]=m>>>0&255,t[5]=m>>>8&255,t[6]=m>>>16&255,t[7]=m>>>24&255,t[8]=x>>>0&255,t[9]=x>>>8&255,t[10]=x>>>16&255,t[11]=x>>>24&255,t[12]=_>>>0&255,t[13]=_>>>8&255,t[14]=_>>>16&255,t[15]=_>>>24&255,t[16]=B>>>0&255,t[17]=B>>>8&255,t[18]=B>>>16&255,t[19]=B>>>24&255,t[20]=U>>>0&255,t[21]=U>>>8&255,t[22]=U>>>16&255,t[23]=U>>>24&255,t[24]=S>>>0&255,t[25]=S>>>8&255,t[26]=S>>>16&255,t[27]=S>>>24&255,t[28]=P>>>0&255,t[29]=P>>>8&255,t[30]=P>>>16&255,t[31]=P>>>24&255,t[32]=k>>>0&255,t[33]=k>>>8&255,t[34]=k>>>16&255,t[35]=k>>>24&255,t[36]=M>>>0&255,t[37]=M>>>8&255,t[38]=M>>>16&255,t[39]=M>>>24&255,t[40]=I>>>0&255,t[41]=I>>>8&255,t[42]=I>>>16&255,t[43]=I>>>24&255,t[44]=T>>>0&255,t[45]=T>>>8&255,t[46]=T>>>16&255,t[47]=T>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=z>>>0&255,t[53]=z>>>8&255,t[54]=z>>>16&255,t[55]=z>>>24&255,t[56]=N>>>0&255,t[57]=N>>>8&255,t[58]=N>>>16&255,t[59]=N>>>24&255,t[60]=L>>>0&255,t[61]=L>>>8&255,t[62]=L>>>16&255,t[63]=L>>>24&255}(t,r,n,e)}function Z(t,r,n,e){!function(t,r,n,e){for(var o,i=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,f=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,a=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,c=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,u=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,l=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,y=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,d=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,w=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,g=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,v=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,b=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,A=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,E=0;E<20;E+=2)i^=(o=(g^=(o=(y^=(o=(a^=(o=i+g|0)<<7|o>>>25)+i|0)<<9|o>>>23)+a|0)<<13|o>>>19)+y|0)<<18|o>>>14,c^=(o=(s^=(o=(v^=(o=(d^=(o=c+s|0)<<7|o>>>25)+c|0)<<9|o>>>23)+d|0)<<13|o>>>19)+v|0)<<18|o>>>14,p^=(o=(u^=(o=(f^=(o=(b^=(o=p+u|0)<<7|o>>>25)+p|0)<<9|o>>>23)+b|0)<<13|o>>>19)+f|0)<<18|o>>>14,A^=(o=(w^=(o=(l^=(o=(h^=(o=A+w|0)<<7|o>>>25)+A|0)<<9|o>>>23)+h|0)<<13|o>>>19)+l|0)<<18|o>>>14,i^=(o=(h^=(o=(f^=(o=(s^=(o=i+h|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+f|0)<<18|o>>>14,c^=(o=(a^=(o=(l^=(o=(u^=(o=c+a|0)<<7|o>>>25)+c|0)<<9|o>>>23)+u|0)<<13|o>>>19)+l|0)<<18|o>>>14,p^=(o=(d^=(o=(y^=(o=(w^=(o=p+d|0)<<7|o>>>25)+p|0)<<9|o>>>23)+w|0)<<13|o>>>19)+y|0)<<18|o>>>14,A^=(o=(b^=(o=(v^=(o=(g^=(o=A+b|0)<<7|o>>>25)+A|0)<<9|o>>>23)+g|0)<<13|o>>>19)+v|0)<<18|o>>>14;t[0]=i>>>0&255,t[1]=i>>>8&255,t[2]=i>>>16&255,t[3]=i>>>24&255,t[4]=c>>>0&255,t[5]=c>>>8&255,t[6]=c>>>16&255,t[7]=c>>>24&255,t[8]=p>>>0&255,t[9]=p>>>8&255,t[10]=p>>>16&255,t[11]=p>>>24&255,t[12]=A>>>0&255,t[13]=A>>>8&255,t[14]=A>>>16&255,t[15]=A>>>24&255,t[16]=u>>>0&255,t[17]=u>>>8&255,t[18]=u>>>16&255,t[19]=u>>>24&255,t[20]=l>>>0&255,t[21]=l>>>8&255,t[22]=l>>>16&255,t[23]=l>>>24&255,t[24]=y>>>0&255,t[25]=y>>>8&255,t[26]=y>>>16&255,t[27]=y>>>24&255,t[28]=d>>>0&255,t[29]=d>>>8&255,t[30]=d>>>16&255,t[31]=d>>>24&255}(t,r,n,e)}var Y=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function H(t,r,n,e,o,i,s){var f,h,a=new Uint8Array(16),c=new Uint8Array(64);for(h=0;h<16;h++)a[h]=0;for(h=0;h<8;h++)a[h]=i[h];for(;o>=64;){for(D(c,a,s,Y),h=0;h<64;h++)t[r+h]=n[e+h]^c[h];for(f=1,h=8;h<16;h++)f=f+(255&a[h])|0,a[h]=255&f,f>>>=8;o-=64,r+=64,e+=64}if(o>0)for(D(c,a,s,Y),h=0;h<o;h++)t[r+h]=n[e+h]^c[h];return 0}function $(t,r,n,e,o){var i,s,f=new Uint8Array(16),h=new Uint8Array(64);for(s=0;s<16;s++)f[s]=0;for(s=0;s<8;s++)f[s]=e[s];for(;n>=64;){for(D(h,f,o,Y),s=0;s<64;s++)t[r+s]=h[s];for(i=1,s=8;s<16;s++)i=i+(255&f[s])|0,f[s]=255&i,i>>>=8;n-=64,r+=64}if(n>0)for(D(h,f,o,Y),s=0;s<n;s++)t[r+s]=h[s];return 0}function G(t,r,n,e,o){var i=new Uint8Array(32);Z(i,e,o,Y);for(var s=new Uint8Array(8),f=0;f<8;f++)s[f]=e[f+16];return $(t,r,n,s,i)}function V(t,r,n,e,o,i,s){var f=new Uint8Array(32);Z(f,i,s,Y);for(var h=new Uint8Array(8),a=0;a<8;a++)h[a]=i[a+16];return H(t,r,n,e,o,h,f)}var F=function(t){var r,n,e,o,i,s,f,h;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,r=255&t[0]|(255&t[1])<<8,this.r[0]=8191&r,n=255&t[2]|(255&t[3])<<8,this.r[1]=8191&(r>>>13|n<<3),e=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|e<<6),o=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(e>>>7|o<<9),i=255&t[8]|(255&t[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,s=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(i>>>14|s<<2),f=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(s>>>11|f<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(f>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function q(t,r,n,e,o,i){var s=new F(i);return s.update(n,e,o),s.finish(t,r),0}function W(t,r,n,e,o,i){var s=new Uint8Array(16);return q(s,0,n,e,o,i),K(t,r,s,0)}function J(t,r,n,e,o){var i;if(n<32)return-1;for(V(t,0,r,0,n,e,o),q(t,16,t,32,n-32,t),i=0;i<16;i++)t[i]=0;return 0}function X(t,r,n,e,o){var i,s=new Uint8Array(32);if(n<32)return-1;if(G(s,0,32,e,o),0!==W(r,16,r,32,n-32,s))return-1;for(V(t,0,r,0,n,e,o),i=0;i<32;i++)t[i]=0;return 0}function Q(t,r){var n;for(n=0;n<16;n++)t[n]=0|r[n]}function tt(t){var r,n,e=1;for(r=0;r<16;r++)n=t[r]+e+65535,e=Math.floor(n/65536),t[r]=n-65536*e;t[0]+=e-1+37*(e-1)}function rt(t,r,n){for(var e,o=~(n-1),i=0;i<16;i++)e=o&(t[i]^r[i]),t[i]^=e,r[i]^=e}function et(t,r){var n,e,o,i=U(),s=U();for(n=0;n<16;n++)s[n]=r[n];for(tt(s),tt(s),tt(s),e=0;e<2;e++){for(i[0]=s[0]-65517,n=1;n<15;n++)i[n]=s[n]-65535-(i[n-1]>>16&1),i[n-1]&=65535;i[15]=s[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,rt(s,i,1-o)}for(n=0;n<16;n++)t[2*n]=255&s[n],t[2*n+1]=s[n]>>8}function nt(t,r){var n=new Uint8Array(32),e=new Uint8Array(32);return et(n,t),et(e,r),j(n,0,e,0)}function ot(t){var r=new Uint8Array(32);return et(r,t),1&r[0]}function it(t,r){var n;for(n=0;n<16;n++)t[n]=r[2*n]+(r[2*n+1]<<8);t[15]&=32767}function st(t,r,n){for(var e=0;e<16;e++)t[e]=r[e]+n[e]}function ft(t,r,n){for(var e=0;e<16;e++)t[e]=r[e]-n[e]}function at(t,r,n){var e,o,i=0,s=0,f=0,h=0,a=0,c=0,u=0,l=0,y=0,d=0,p=0,w=0,g=0,v=0,b=0,A=0,E=0,m=0,x=0,_=0,B=0,U=0,S=0,P=0,k=0,M=0,I=0,T=0,R=0,z=0,N=0,L=n[0],K=n[1],O=n[2],Z=n[3],C=n[4],Y=n[5],H=n[6],F=n[7],D=n[8],G=n[9],V=n[10],q=n[11],j=n[12],W=n[13],$=n[14],J=n[15];i+=(e=r[0])*L,s+=e*K,f+=e*O,h+=e*Z,a+=e*C,c+=e*Y,u+=e*H,l+=e*F,y+=e*D,d+=e*G,p+=e*V,w+=e*q,g+=e*j,v+=e*W,b+=e*$,A+=e*J,s+=(e=r[1])*L,f+=e*K,h+=e*O,a+=e*Z,c+=e*C,u+=e*Y,l+=e*H,y+=e*F,d+=e*D,p+=e*G,w+=e*V,g+=e*q,v+=e*j,b+=e*W,A+=e*$,E+=e*J,f+=(e=r[2])*L,h+=e*K,a+=e*O,c+=e*Z,u+=e*C,l+=e*Y,y+=e*H,d+=e*F,p+=e*D,w+=e*G,g+=e*V,v+=e*q,b+=e*j,A+=e*W,E+=e*$,m+=e*J,h+=(e=r[3])*L,a+=e*K,c+=e*O,u+=e*Z,l+=e*C,y+=e*Y,d+=e*H,p+=e*F,w+=e*D,g+=e*G,v+=e*V,b+=e*q,A+=e*j,E+=e*W,m+=e*$,x+=e*J,a+=(e=r[4])*L,c+=e*K,u+=e*O,l+=e*Z,y+=e*C,d+=e*Y,p+=e*H,w+=e*F,g+=e*D,v+=e*G,b+=e*V,A+=e*q,E+=e*j,m+=e*W,x+=e*$,_+=e*J,c+=(e=r[5])*L,u+=e*K,l+=e*O,y+=e*Z,d+=e*C,p+=e*Y,w+=e*H,g+=e*F,v+=e*D,b+=e*G,A+=e*V,E+=e*q,m+=e*j,x+=e*W,_+=e*$,B+=e*J,u+=(e=r[6])*L,l+=e*K,y+=e*O,d+=e*Z,p+=e*C,w+=e*Y,g+=e*H,v+=e*F,b+=e*D,A+=e*G,E+=e*V,m+=e*q,x+=e*j,_+=e*W,B+=e*$,U+=e*J,l+=(e=r[7])*L,y+=e*K,d+=e*O,p+=e*Z,w+=e*C,g+=e*Y,v+=e*H,b+=e*F,A+=e*D,E+=e*G,m+=e*V,x+=e*q,_+=e*j,B+=e*W,U+=e*$,S+=e*J,y+=(e=r[8])*L,d+=e*K,p+=e*O,w+=e*Z,g+=e*C,v+=e*Y,b+=e*H,A+=e*F,E+=e*D,m+=e*G,x+=e*V,_+=e*q,B+=e*j,U+=e*W,S+=e*$,P+=e*J,d+=(e=r[9])*L,p+=e*K,w+=e*O,g+=e*Z,v+=e*C,b+=e*Y,A+=e*H,E+=e*F,m+=e*D,x+=e*G,_+=e*V,B+=e*q,U+=e*j,S+=e*W,P+=e*$,k+=e*J,p+=(e=r[10])*L,w+=e*K,g+=e*O,v+=e*Z,b+=e*C,A+=e*Y,E+=e*H,m+=e*F,x+=e*D,_+=e*G,B+=e*V,U+=e*q,S+=e*j,P+=e*W,k+=e*$,M+=e*J,w+=(e=r[11])*L,g+=e*K,v+=e*O,b+=e*Z,A+=e*C,E+=e*Y,m+=e*H,x+=e*F,_+=e*D,B+=e*G,U+=e*V,S+=e*q,P+=e*j,k+=e*W,M+=e*$,I+=e*J,g+=(e=r[12])*L,v+=e*K,b+=e*O,A+=e*Z,E+=e*C,m+=e*Y,x+=e*H,_+=e*F,B+=e*D,U+=e*G,S+=e*V,P+=e*q,k+=e*j,M+=e*W,I+=e*$,T+=e*J,v+=(e=r[13])*L,b+=e*K,A+=e*O,E+=e*Z,m+=e*C,x+=e*Y,_+=e*H,B+=e*F,U+=e*D,S+=e*G,P+=e*V,k+=e*q,M+=e*j,I+=e*W,T+=e*$,R+=e*J,b+=(e=r[14])*L,A+=e*K,E+=e*O,m+=e*Z,x+=e*C,_+=e*Y,B+=e*H,U+=e*F,S+=e*D,P+=e*G,k+=e*V,M+=e*q,I+=e*j,T+=e*W,R+=e*$,z+=e*J,A+=(e=r[15])*L,s+=38*(m+=e*O),f+=38*(x+=e*Z),h+=38*(_+=e*C),a+=38*(B+=e*Y),c+=38*(U+=e*H),u+=38*(S+=e*F),l+=38*(P+=e*D),y+=38*(k+=e*G),d+=38*(M+=e*V),p+=38*(I+=e*q),w+=38*(T+=e*j),g+=38*(R+=e*W),v+=38*(z+=e*$),b+=38*(N+=e*J),i=(e=(i+=38*(E+=e*K))+(o=1)+65535)-65536*(o=Math.floor(e/65536)),s=(e=s+o+65535)-65536*(o=Math.floor(e/65536)),f=(e=f+o+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)),c=(e=c+o+65535)-65536*(o=Math.floor(e/65536)),u=(e=u+o+65535)-65536*(o=Math.floor(e/65536)),l=(e=l+o+65535)-65536*(o=Math.floor(e/65536)),y=(e=y+o+65535)-65536*(o=Math.floor(e/65536)),d=(e=d+o+65535)-65536*(o=Math.floor(e/65536)),p=(e=p+o+65535)-65536*(o=Math.floor(e/65536)),w=(e=w+o+65535)-65536*(o=Math.floor(e/65536)),g=(e=g+o+65535)-65536*(o=Math.floor(e/65536)),v=(e=v+o+65535)-65536*(o=Math.floor(e/65536)),b=(e=b+o+65535)-65536*(o=Math.floor(e/65536)),A=(e=A+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)),s=(e=s+o+65535)-65536*(o=Math.floor(e/65536)),f=(e=f+o+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)),c=(e=c+o+65535)-65536*(o=Math.floor(e/65536)),u=(e=u+o+65535)-65536*(o=Math.floor(e/65536)),l=(e=l+o+65535)-65536*(o=Math.floor(e/65536)),y=(e=y+o+65535)-65536*(o=Math.floor(e/65536)),d=(e=d+o+65535)-65536*(o=Math.floor(e/65536)),p=(e=p+o+65535)-65536*(o=Math.floor(e/65536)),w=(e=w+o+65535)-65536*(o=Math.floor(e/65536)),g=(e=g+o+65535)-65536*(o=Math.floor(e/65536)),v=(e=v+o+65535)-65536*(o=Math.floor(e/65536)),b=(e=b+o+65535)-65536*(o=Math.floor(e/65536)),A=(e=A+o+65535)-65536*(o=Math.floor(e/65536)),i+=o-1+37*(o-1),t[0]=i,t[1]=s,t[2]=f,t[3]=h,t[4]=a,t[5]=c,t[6]=u,t[7]=l,t[8]=y,t[9]=d,t[10]=p,t[11]=w,t[12]=g,t[13]=v,t[14]=b,t[15]=A}function ht(t,r){at(t,r,r)}function ct(t,r){var n,e=U();for(n=0;n<16;n++)e[n]=r[n];for(n=253;n>=0;n--)ht(e,e),2!==n&&4!==n&&at(e,e,r);for(n=0;n<16;n++)t[n]=e[n]}function ut(t,r){var n,e=U();for(n=0;n<16;n++)e[n]=r[n];for(n=250;n>=0;n--)ht(e,e),1!==n&&at(e,e,r);for(n=0;n<16;n++)t[n]=e[n]}function lt(t,r,n){var e,o,i=new Uint8Array(32),s=new Float64Array(80),f=U(),h=U(),a=U(),c=U(),u=U(),l=U();for(o=0;o<31;o++)i[o]=r[o];for(i[31]=127&r[31]|64,i[0]&=248,it(s,n),o=0;o<16;o++)h[o]=s[o],c[o]=f[o]=a[o]=0;for(f[0]=c[0]=1,o=254;o>=0;--o)rt(f,h,e=i[o>>>3]>>>(7&o)&1),rt(a,c,e),st(u,f,a),ft(f,f,a),st(a,h,c),ft(h,h,c),ht(c,u),ht(l,f),at(f,a,f),at(a,h,u),st(u,f,a),ft(f,f,a),ht(h,f),ft(a,c,l),at(f,a,C),st(f,f,c),at(a,a,f),at(f,c,l),at(c,h,s),ht(h,u),rt(f,h,e),rt(a,c,e);for(o=0;o<16;o++)s[o+16]=f[o],s[o+32]=a[o],s[o+48]=h[o],s[o+64]=c[o];var y=s.subarray(32),d=s.subarray(16);return ct(y,y),at(d,d,y),et(t,d),0}function yt(t,r){return lt(t,r,O)}function pt(t,r){return B(r,32),yt(t,r)}function dt(t,r,n){var e=new Uint8Array(32);return lt(e,n,r),Z(t,S,e,Y)}F.prototype.blocks=function(t,r,n){for(var e,o,i,s,f,h,a,c,u,l,y,d,p,w,g,v,b,A,E,m=this.fin?0:2048,x=this.h[0],_=this.h[1],B=this.h[2],U=this.h[3],S=this.h[4],P=this.h[5],k=this.h[6],M=this.h[7],I=this.h[8],T=this.h[9],R=this.r[0],z=this.r[1],N=this.r[2],L=this.r[3],K=this.r[4],O=this.r[5],Z=this.r[6],C=this.r[7],Y=this.r[8],H=this.r[9];n>=16;)l=u=0,l+=(x+=8191&(e=255&t[r+0]|(255&t[r+1])<<8))*R,l+=(_+=8191&(e>>>13|(o=255&t[r+2]|(255&t[r+3])<<8)<<3))*(5*H),l+=(B+=8191&(o>>>10|(i=255&t[r+4]|(255&t[r+5])<<8)<<6))*(5*Y),l+=(U+=8191&(i>>>7|(s=255&t[r+6]|(255&t[r+7])<<8)<<9))*(5*C),u=(l+=(S+=8191&(s>>>4|(f=255&t[r+8]|(255&t[r+9])<<8)<<12))*(5*Z))>>>13,l&=8191,l+=(P+=f>>>1&8191)*(5*O),l+=(k+=8191&(f>>>14|(h=255&t[r+10]|(255&t[r+11])<<8)<<2))*(5*K),l+=(M+=8191&(h>>>11|(a=255&t[r+12]|(255&t[r+13])<<8)<<5))*(5*L),l+=(I+=8191&(a>>>8|(c=255&t[r+14]|(255&t[r+15])<<8)<<8))*(5*N),y=u+=(l+=(T+=c>>>5|m)*(5*z))>>>13,y+=x*z,y+=_*R,y+=B*(5*H),y+=U*(5*Y),u=(y+=S*(5*C))>>>13,y&=8191,y+=P*(5*Z),y+=k*(5*O),y+=M*(5*K),y+=I*(5*L),u+=(y+=T*(5*N))>>>13,y&=8191,d=u,d+=x*N,d+=_*z,d+=B*R,d+=U*(5*H),u=(d+=S*(5*Y))>>>13,d&=8191,d+=P*(5*C),d+=k*(5*Z),d+=M*(5*O),d+=I*(5*K),p=u+=(d+=T*(5*L))>>>13,p+=x*L,p+=_*N,p+=B*z,p+=U*R,u=(p+=S*(5*H))>>>13,p&=8191,p+=P*(5*Y),p+=k*(5*C),p+=M*(5*Z),p+=I*(5*O),w=u+=(p+=T*(5*K))>>>13,w+=x*K,w+=_*L,w+=B*N,w+=U*z,u=(w+=S*R)>>>13,w&=8191,w+=P*(5*H),w+=k*(5*Y),w+=M*(5*C),w+=I*(5*Z),g=u+=(w+=T*(5*O))>>>13,g+=x*O,g+=_*K,g+=B*L,g+=U*N,u=(g+=S*z)>>>13,g&=8191,g+=P*R,g+=k*(5*H),g+=M*(5*Y),g+=I*(5*C),v=u+=(g+=T*(5*Z))>>>13,v+=x*Z,v+=_*O,v+=B*K,v+=U*L,u=(v+=S*N)>>>13,v&=8191,v+=P*z,v+=k*R,v+=M*(5*H),v+=I*(5*Y),b=u+=(v+=T*(5*C))>>>13,b+=x*C,b+=_*Z,b+=B*O,b+=U*K,u=(b+=S*L)>>>13,b&=8191,b+=P*N,b+=k*z,b+=M*R,b+=I*(5*H),A=u+=(b+=T*(5*Y))>>>13,A+=x*Y,A+=_*C,A+=B*Z,A+=U*O,u=(A+=S*K)>>>13,A&=8191,A+=P*L,A+=k*N,A+=M*z,A+=I*R,E=u+=(A+=T*(5*H))>>>13,E+=x*H,E+=_*Y,E+=B*C,E+=U*Z,u=(E+=S*O)>>>13,E&=8191,E+=P*K,E+=k*L,E+=M*N,E+=I*z,x=l=8191&(u=(u=((u+=(E+=T*R)>>>13)<<2)+u|0)+(l&=8191)|0),_=y+=u>>>=13,B=d&=8191,U=p&=8191,S=w&=8191,P=g&=8191,k=v&=8191,M=b&=8191,I=A&=8191,T=E&=8191,r+=16,n-=16;this.h[0]=x,this.h[1]=_,this.h[2]=B,this.h[3]=U,this.h[4]=S,this.h[5]=P,this.h[6]=k,this.h[7]=M,this.h[8]=I,this.h[9]=T},F.prototype.finish=function(t,r){var n,e,o,i,s=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,s[0]=this.h[0]+5,n=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+n,n=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,e=(1^n)-1,i=0;i<10;i++)s[i]&=e;for(e=~e,i=0;i<10;i++)this.h[i]=this.h[i]&e|s[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;t[r+0]=this.h[0]>>>0&255,t[r+1]=this.h[0]>>>8&255,t[r+2]=this.h[1]>>>0&255,t[r+3]=this.h[1]>>>8&255,t[r+4]=this.h[2]>>>0&255,t[r+5]=this.h[2]>>>8&255,t[r+6]=this.h[3]>>>0&255,t[r+7]=this.h[3]>>>8&255,t[r+8]=this.h[4]>>>0&255,t[r+9]=this.h[4]>>>8&255,t[r+10]=this.h[5]>>>0&255,t[r+11]=this.h[5]>>>8&255,t[r+12]=this.h[6]>>>0&255,t[r+13]=this.h[6]>>>8&255,t[r+14]=this.h[7]>>>0&255,t[r+15]=this.h[7]>>>8&255},F.prototype.update=function(t,r,n){var e,o;if(this.leftover){for((o=16-this.leftover)>n&&(o=n),e=0;e<o;e++)this.buffer[this.leftover+e]=t[r+e];if(n-=o,r+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(n>=16&&(o=n-n%16,this.blocks(t,r,o),r+=o,n-=o),n){for(e=0;e<n;e++)this.buffer[this.leftover+e]=t[r+e];this.leftover+=n}};var wt=J,gt=X,bt=[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 vt(t,r,n,e){for(var o,i,s,f,h,a,c,u,l,y,d,p,w,g,v,b,A,E,m,x,_,B,U,S,P,k,M=new Int32Array(16),I=new Int32Array(16),T=t[0],R=t[1],z=t[2],N=t[3],L=t[4],K=t[5],O=t[6],Z=t[7],C=r[0],Y=r[1],H=r[2],F=r[3],D=r[4],G=r[5],V=r[6],q=r[7],j=0;e>=128;){for(m=0;m<16;m++)x=8*m+j,M[m]=n[x+0]<<24|n[x+1]<<16|n[x+2]<<8|n[x+3],I[m]=n[x+4]<<24|n[x+5]<<16|n[x+6]<<8|n[x+7];for(m=0;m<80;m++)if(o=T,i=R,s=z,f=N,h=L,a=K,c=O,l=C,y=Y,d=H,p=F,w=D,g=G,v=V,U=65535&(B=q),S=B>>>16,P=65535&(_=Z),k=_>>>16,U+=65535&(B=(D>>>14|L<<18)^(D>>>18|L<<14)^(L>>>9|D<<23)),S+=B>>>16,P+=65535&(_=(L>>>14|D<<18)^(L>>>18|D<<14)^(D>>>9|L<<23)),k+=_>>>16,U+=65535&(B=D&G^~D&V),S+=B>>>16,P+=65535&(_=L&K^~L&O),k+=_>>>16,U+=65535&(B=bt[2*m+1]),S+=B>>>16,P+=65535&(_=bt[2*m]),k+=_>>>16,_=M[m%16],S+=(B=I[m%16])>>>16,P+=65535&_,k+=_>>>16,P+=(S+=(U+=65535&B)>>>16)>>>16,U=65535&(B=E=65535&U|S<<16),S=B>>>16,P=65535&(_=A=65535&P|(k+=P>>>16)<<16),k=_>>>16,U+=65535&(B=(C>>>28|T<<4)^(T>>>2|C<<30)^(T>>>7|C<<25)),S+=B>>>16,P+=65535&(_=(T>>>28|C<<4)^(C>>>2|T<<30)^(C>>>7|T<<25)),k+=_>>>16,S+=(B=C&Y^C&H^Y&H)>>>16,P+=65535&(_=T&R^T&z^R&z),k+=_>>>16,u=65535&(P+=(S+=(U+=65535&B)>>>16)>>>16)|(k+=P>>>16)<<16,b=65535&U|S<<16,U=65535&(B=p),S=B>>>16,P=65535&(_=f),k=_>>>16,S+=(B=E)>>>16,P+=65535&(_=A),k+=_>>>16,R=o,z=i,N=s,L=f=65535&(P+=(S+=(U+=65535&B)>>>16)>>>16)|(k+=P>>>16)<<16,K=h,O=a,Z=c,T=u,Y=l,H=y,F=d,D=p=65535&U|S<<16,G=w,V=g,q=v,C=b,m%16==15)for(x=0;x<16;x++)_=M[x],U=65535&(B=I[x]),S=B>>>16,P=65535&_,k=_>>>16,_=M[(x+9)%16],U+=65535&(B=I[(x+9)%16]),S+=B>>>16,P+=65535&_,k+=_>>>16,A=M[(x+1)%16],U+=65535&(B=((E=I[(x+1)%16])>>>1|A<<31)^(E>>>8|A<<24)^(E>>>7|A<<25)),S+=B>>>16,P+=65535&(_=(A>>>1|E<<31)^(A>>>8|E<<24)^A>>>7),k+=_>>>16,A=M[(x+14)%16],S+=(B=((E=I[(x+14)%16])>>>19|A<<13)^(A>>>29|E<<3)^(E>>>6|A<<26))>>>16,P+=65535&(_=(A>>>19|E<<13)^(E>>>29|A<<3)^A>>>6),k+=_>>>16,k+=(P+=(S+=(U+=65535&B)>>>16)>>>16)>>>16,M[x]=65535&P|k<<16,I[x]=65535&U|S<<16;U=65535&(B=C),S=B>>>16,P=65535&(_=T),k=_>>>16,_=t[0],S+=(B=r[0])>>>16,P+=65535&_,k+=_>>>16,k+=(P+=(S+=(U+=65535&B)>>>16)>>>16)>>>16,t[0]=T=65535&P|k<<16,r[0]=C=65535&U|S<<16,U=65535&(B=Y),S=B>>>16,P=65535&(_=R),k=_>>>16,_=t[1],S+=(B=r[1])>>>16,P+=65535&_,k+=_>>>16,k+=(P+=(S+=(U+=65535&B)>>>16)>>>16)>>>16,t[1]=R=65535&P|k<<16,r[1]=Y=65535&U|S<<16,U=65535&(B=H),S=B>>>16,P=65535&(_=z),k=_>>>16,_=t[2],S+=(B=r[2])>>>16,P+=65535&_,k+=_>>>16,k+=(P+=(S+=(U+=65535&B)>>>16)>>>16)>>>16,t[2]=z=65535&P|k<<16,r[2]=H=65535&U|S<<16,U=65535&(B=F),S=B>>>16,P=65535&(_=N),k=_>>>16,_=t[3],S+=(B=r[3])>>>16,P+=65535&_,k+=_>>>16,k+=(P+=(S+=(U+=65535&B)>>>16)>>>16)>>>16,t[3]=N=65535&P|k<<16,r[3]=F=65535&U|S<<16,U=65535&(B=D),S=B>>>16,P=65535&(_=L),k=_>>>16,_=t[4],S+=(B=r[4])>>>16,P+=65535&_,k+=_>>>16,k+=(P+=(S+=(U+=65535&B)>>>16)>>>16)>>>16,t[4]=L=65535&P|k<<16,r[4]=D=65535&U|S<<16,U=65535&(B=G),S=B>>>16,P=65535&(_=K),k=_>>>16,_=t[5],S+=(B=r[5])>>>16,P+=65535&_,k+=_>>>16,k+=(P+=(S+=(U+=65535&B)>>>16)>>>16)>>>16,t[5]=K=65535&P|k<<16,r[5]=G=65535&U|S<<16,U=65535&(B=V),S=B>>>16,P=65535&(_=O),k=_>>>16,_=t[6],S+=(B=r[6])>>>16,P+=65535&_,k+=_>>>16,k+=(P+=(S+=(U+=65535&B)>>>16)>>>16)>>>16,t[6]=O=65535&P|k<<16,r[6]=V=65535&U|S<<16,U=65535&(B=q),S=B>>>16,P=65535&(_=Z),k=_>>>16,_=t[7],S+=(B=r[7])>>>16,P+=65535&_,k+=_>>>16,k+=(P+=(S+=(U+=65535&B)>>>16)>>>16)>>>16,t[7]=Z=65535&P|k<<16,r[7]=q=65535&U|S<<16,j+=128,e-=128}return e}function At(t,r,n){var e,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),f=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,vt(o,i,r,n),n%=128,e=0;e<n;e++)s[e]=r[f-n+e];for(s[n]=128,s[(n=256-128*(n<112?1:0))-9]=0,N(s,n-8,f/536870912|0,f<<3),vt(o,i,s,n),e=0;e<8;e++)N(t,8*e,o[e],i[e]);return 0}function Et(t,r){var n=U(),e=U(),o=U(),i=U(),s=U(),f=U(),h=U(),a=U(),c=U();ft(n,t[1],t[0]),ft(c,r[1],r[0]),at(n,n,c),st(e,t[0],t[1]),st(c,r[0],r[1]),at(e,e,c),at(o,t[3],r[3]),at(o,o,I),at(i,t[2],r[2]),st(i,i,i),ft(s,e,n),ft(f,i,o),st(h,i,o),st(a,e,n),at(t[0],s,f),at(t[1],a,h),at(t[2],h,f),at(t[3],s,a)}function mt(t,r,n){var e;for(e=0;e<4;e++)rt(t[e],r[e],n)}function _t(t,r){var n=U(),e=U(),o=U();ct(o,r[2]),at(n,r[0],o),at(e,r[1],o),et(t,e),t[31]^=ot(n)<<7}function xt(t,r,n){var e,o;for(Q(t[0],P),Q(t[1],k),Q(t[2],k),Q(t[3],P),o=255;o>=0;--o)mt(t,r,e=n[o/8|0]>>(7&o)&1),Et(r,t),Et(t,t),mt(t,r,e)}function Ut(t,r){var n=[U(),U(),U(),U()];Q(n[0],T),Q(n[1],R),Q(n[2],k),at(n[3],T,R),xt(t,n,r)}function Bt(t,r,n){var e,o=new Uint8Array(64),i=[U(),U(),U(),U()];for(n||B(r,32),At(o,r,32),o[0]&=248,o[31]&=127,o[31]|=64,Ut(i,o),_t(t,i),e=0;e<32;e++)r[e+32]=t[e];return 0}var St=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 Ot(t,r){var n,e,o,i;for(e=63;e>=32;--e){for(n=0,o=e-32,i=e-12;o<i;++o)r[o]+=n-16*r[e]*St[o-(e-32)],n=Math.floor((r[o]+128)/256),r[o]-=256*n;r[o]+=n,r[e]=0}for(n=0,o=0;o<32;o++)r[o]+=n-(r[31]>>4)*St[o],n=r[o]>>8,r[o]&=255;for(o=0;o<32;o++)r[o]-=n*St[o];for(e=0;e<32;e++)r[e+1]+=r[e]>>8,t[e]=255&r[e]}function Pt(t){var r,n=new Float64Array(64);for(r=0;r<64;r++)n[r]=t[r];for(r=0;r<64;r++)t[r]=0;Ot(t,n)}function kt(t,r,n,e){var o,i,s=new Uint8Array(64),f=new Uint8Array(64),h=new Uint8Array(64),a=new Float64Array(64),c=[U(),U(),U(),U()];At(s,e,32),s[0]&=248,s[31]&=127,s[31]|=64;var u=n+64;for(o=0;o<n;o++)t[64+o]=r[o];for(o=0;o<32;o++)t[32+o]=s[32+o];for(At(h,t.subarray(32),n+32),Pt(h),Ut(c,h),_t(t,c),o=32;o<64;o++)t[o]=e[o];for(At(f,t,n+64),Pt(f),o=0;o<64;o++)a[o]=0;for(o=0;o<32;o++)a[o]=h[o];for(o=0;o<32;o++)for(i=0;i<32;i++)a[o+i]+=f[o]*s[i];return Ot(t.subarray(32),a),u}function Ct(t,r,n,e){var o,i=new Uint8Array(32),s=new Uint8Array(64),f=[U(),U(),U(),U()],h=[U(),U(),U(),U()];if(n<64)return-1;if(function(t,r){var n=U(),e=U(),o=U(),i=U(),s=U(),f=U(),h=U();return Q(t[2],k),it(t[1],r),ht(o,t[1]),at(i,o,z),ft(o,o,t[2]),st(i,t[2],i),ht(s,i),ht(f,s),at(h,f,s),at(n,h,o),at(n,n,i),ut(n,n),at(n,n,o),at(n,n,i),at(n,n,i),at(t[0],n,i),ht(e,t[0]),at(e,e,i),nt(e,o)&&at(t[0],t[0],M),ht(e,t[0]),at(e,e,i),nt(e,o)?-1:(ot(t[0])===r[31]>>7&&ft(t[0],P,t[0]),at(t[3],t[0],t[1]),0)}(h,e))return-1;for(o=0;o<n;o++)t[o]=r[o];for(o=0;o<32;o++)t[o+32]=e[o];if(At(s,t,n),Pt(s),xt(f,h,s),Ut(h,r.subarray(32)),Et(f,h),_t(i,f),n-=64,j(r,0,i,0)){for(o=0;o<n;o++)t[o]=0;return-1}for(o=0;o<n;o++)t[o]=r[o+64];return n}function zt(t,r){if(32!==t.length)throw new Error("bad key size");if(24!==r.length)throw new Error("bad nonce size")}function It(){for(var t=0;t<arguments.length;t++)if(!(arguments[t]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Tt(t){for(var r=0;r<t.length;r++)t[r]=0}x.lowlevel={crypto_core_hsalsa20:Z,crypto_stream_xor:V,crypto_stream:G,crypto_stream_salsa20_xor:H,crypto_stream_salsa20:$,crypto_onetimeauth:q,crypto_onetimeauth_verify:W,crypto_verify_16:K,crypto_verify_32:j,crypto_secretbox:J,crypto_secretbox_open:X,crypto_scalarmult:lt,crypto_scalarmult_base:yt,crypto_box_beforenm:dt,crypto_box_afternm:wt,crypto_box:function(t,r,n,e,o,i){var s=new Uint8Array(32);return dt(s,o,i),wt(t,r,n,e,s)},crypto_box_open:function(t,r,n,e,o,i){var s=new Uint8Array(32);return dt(s,o,i),gt(t,r,n,e,s)},crypto_box_keypair:pt,crypto_hash:At,crypto_sign:kt,crypto_sign_keypair:Bt,crypto_sign_open:Ct,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:U,D:z,L:St,pack25519:et,unpack25519:it,M:at,A:st,S:ht,Z:ft,pow2523:ut,add:Et,set25519:Q,modL:Ot,scalarmult:xt,scalarbase:Ut},x.randomBytes=function(t){var r=new Uint8Array(t);return B(r,t),r},x.secretbox=function(t,r,n){It(t,r,n),zt(n,r);for(var e=new Uint8Array(32+t.length),o=new Uint8Array(e.length),i=0;i<t.length;i++)e[i+32]=t[i];return J(o,e,e.length,r,n),o.subarray(16)},x.secretbox.open=function(t,r,n){It(t,r,n),zt(n,r);for(var e=new Uint8Array(16+t.length),o=new Uint8Array(e.length),i=0;i<t.length;i++)e[i+16]=t[i];return e.length<32||0!==X(o,e,e.length,r,n)?null:o.subarray(32)},x.secretbox.keyLength=32,x.secretbox.nonceLength=24,x.secretbox.overheadLength=16,x.scalarMult=function(t,r){if(It(t,r),32!==t.length)throw new Error("bad n size");if(32!==r.length)throw new Error("bad p size");var n=new Uint8Array(32);return lt(n,t,r),n},x.scalarMult.base=function(t){if(It(t),32!==t.length)throw new Error("bad n size");var r=new Uint8Array(32);return yt(r,t),r},x.scalarMult.scalarLength=32,x.scalarMult.groupElementLength=32,x.box=function(t,r,n,e){var o=x.box.before(n,e);return x.secretbox(t,r,o)},x.box.before=function(t,r){It(t,r),function(t,r){if(32!==t.length)throw new Error("bad public key size");if(32!==r.length)throw new Error("bad secret key size")}(t,r);var n=new Uint8Array(32);return dt(n,t,r),n},x.box.after=x.secretbox,x.box.open=function(t,r,n,e){var o=x.box.before(n,e);return x.secretbox.open(t,r,o)},x.box.open.after=x.secretbox.open,x.box.keyPair=function(){var t=new Uint8Array(32),r=new Uint8Array(32);return pt(t,r),{publicKey:t,secretKey:r}},x.box.keyPair.fromSecretKey=function(t){if(It(t),32!==t.length)throw new Error("bad secret key size");var r=new Uint8Array(32);return yt(r,t),{publicKey:r,secretKey:new Uint8Array(t)}},x.box.publicKeyLength=32,x.box.secretKeyLength=32,x.box.sharedKeyLength=32,x.box.nonceLength=24,x.box.overheadLength=x.secretbox.overheadLength,x.sign=function(t,r){if(It(t,r),64!==r.length)throw new Error("bad secret key size");var n=new Uint8Array(64+t.length);return kt(n,t,t.length,r),n},x.sign.open=function(t,r){if(It(t,r),32!==r.length)throw new Error("bad public key size");var n=new Uint8Array(t.length),e=Ct(n,t,t.length,r);if(e<0)return null;for(var o=new Uint8Array(e),i=0;i<o.length;i++)o[i]=n[i];return o},x.sign.detached=function(t,r){for(var n=x.sign(t,r),e=new Uint8Array(64),o=0;o<e.length;o++)e[o]=n[o];return e},x.sign.detached.verify=function(t,r,n){if(It(t,r,n),64!==r.length)throw new Error("bad signature size");if(32!==n.length)throw new Error("bad public key size");var e,o=new Uint8Array(64+t.length),i=new Uint8Array(64+t.length);for(e=0;e<64;e++)o[e]=r[e];for(e=0;e<t.length;e++)o[e+64]=t[e];return Ct(i,o,o.length,n)>=0},x.sign.keyPair=function(){var t=new Uint8Array(32),r=new Uint8Array(64);return Bt(t,r),{publicKey:t,secretKey:r}},x.sign.keyPair.fromSecretKey=function(t){if(It(t),64!==t.length)throw new Error("bad secret key size");for(var r=new Uint8Array(32),n=0;n<r.length;n++)r[n]=t[32+n];return{publicKey:r,secretKey:new Uint8Array(t)}},x.sign.keyPair.fromSeed=function(t){if(It(t),32!==t.length)throw new Error("bad seed size");for(var r=new Uint8Array(32),n=new Uint8Array(64),e=0;e<32;e++)n[e]=t[e];return Bt(r,n,!0),{publicKey:r,secretKey:n}},x.sign.publicKeyLength=32,x.sign.secretKeyLength=64,x.sign.seedLength=32,x.sign.signatureLength=64,x.hash=function(t){It(t);var r=new Uint8Array(64);return At(r,t,t.length),r},x.hash.hashLength=64,x.verify=function(t,r){return It(t,r),0!==t.length&&0!==r.length&&t.length===r.length&&0===L(t,0,r,0,t.length)},x.setPRNG=function(t){B=t},function(){var t="undefined"!=typeof self?self.crypto||self.msCrypto:null;t&&t.getRandomValues?x.setPRNG((function(r,n){var e,o=new Uint8Array(n);for(e=0;e<n;e+=65536)t.getRandomValues(o.subarray(e,e+Math.min(n-e,65536)));for(e=0;e<n;e++)r[e]=o[e];Tt(o)})):"undefined"!=typeof require&&(t=require("crypto"))&&t.randomBytes&&x.setPRNG((function(r,n){var e,o=t.randomBytes(n);for(e=0;e<n;e++)r[e]=o[e];Tt(o)}))}();var Rt=function(t){var r,n=new Float64Array(16);if(t)for(r=0;r<t.length;r++)n[r]=t[r];return n},Mt=Rt(),Nt=Rt([1]),Lt=Rt([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),Kt=Rt([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function jt(t){var r,n;for(n=0;n<16;n++)t[n]+=65536,r=Math.floor(t[n]/65536),t[(n+1)*(n<15?1:0)]+=r-1+37*(r-1)*(15===n?1:0),t[n]-=65536*r}function Dt(t,r,n){for(var e,o=~(n-1),i=0;i<16;i++)e=o&(t[i]^r[i]),t[i]^=e,r[i]^=e}function Zt(t,r,n){var e;for(e=0;e<16;e++)t[e]=r[e]+n[e]|0}function Yt(t,r,n){var e;for(e=0;e<16;e++)t[e]=r[e]-n[e]|0}function Ht(t,r,n){var e,o,i=new Float64Array(31);for(e=0;e<31;e++)i[e]=0;for(e=0;e<16;e++)for(o=0;o<16;o++)i[e+o]+=r[e]*n[o];for(e=0;e<15;e++)i[e]+=38*i[e+16];for(e=0;e<16;e++)t[e]=i[e];jt(t),jt(t)}function $t(t,r){Ht(t,r,r)}function Gt(t,r){var n,e,o,i=Rt(),s=Rt();for(n=0;n<16;n++)s[n]=r[n];for(jt(s),jt(s),jt(s),e=0;e<2;e++){for(i[0]=s[0]-65517,n=1;n<15;n++)i[n]=s[n]-65535-(i[n-1]>>16&1),i[n-1]&=65535;i[15]=s[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,Dt(s,i,1-o)}for(n=0;n<16;n++)t[2*n]=255&s[n],t[2*n+1]=s[n]>>8}function Vt(t,r){var n=new Uint8Array(32),e=new Uint8Array(32);return Gt(n,t),Gt(e,r),function(t,r,n,e,o){var i,s=0;for(i=0;i<32;i++)s|=t[0+i]^n[0+i];return(1&s-1>>>8)-1}(n,0,e)}function Ft(t){var r=new Uint8Array(32),n=[Rt(),Rt(),Rt(),Rt()],e=Rt(),o=Rt();if(function(t,r){var n,e,o=Rt(),i=Rt(),s=Rt(),f=Rt(),h=Rt(),a=Rt(),c=Rt();return function(t,r){var n;for(n=0;n<16;n++)t[n]=0|r[n]}(t[2],Nt),function(t,r){var n;for(n=0;n<16;n++)t[n]=r[2*n]+(r[2*n+1]<<8);t[15]&=32767}(t[1],r),$t(s,t[1]),Ht(f,s,Lt),Yt(s,s,t[2]),Zt(f,t[2],f),$t(h,f),$t(a,h),Ht(c,a,h),Ht(o,c,s),Ht(o,o,f),function(t,r){var n,e=Rt();for(n=0;n<16;n++)e[n]=r[n];for(n=250;n>=0;n--)$t(e,e),1!==n&&Ht(e,e,r);for(n=0;n<16;n++)t[n]=e[n]}(o,o),Ht(o,o,s),Ht(o,o,f),Ht(o,o,f),Ht(t[0],o,f),$t(i,t[0]),Ht(i,i,f),Vt(i,s)&&Ht(t[0],t[0],Kt),$t(i,t[0]),Ht(i,i,f),Vt(i,s)?-1:(n=t[0],Gt(e=new Uint8Array(32),n),(1&e[0])==r[31]>>7&&Yt(t[0],Mt,t[0]),Ht(t[3],t[0],t[1]),0)}(n,t))return null;var i=n[1];return Zt(e,Nt,i),Yt(o,Nt,i),function(t,r){var n,e=Rt();for(n=0;n<16;n++)e[n]=r[n];for(n=253;n>=0;n--)$t(e,e),2!==n&&4!==n&&Ht(e,e,r);for(n=0;n<16;n++)t[n]=e[n]}(o,o),Ht(e,e,o),Gt(r,e),r}function qt(r){var n,e=new Uint8Array(64),o=new Uint8Array(32);for(t.lowlevel.crypto_hash(e,r,32),e[0]&=248,e[31]&=127,e[31]|=64,n=0;n<32;n++)o[n]=e[n];for(n=0;n<64;n++)e[n]=0;return o}const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=s("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),n=s("0123456789abcdef"),o=s(r),i={encode:t=>{const n="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t),e=3*Math.ceil(n.length/3),i=new Uint8Array(e);i.set(n);const s=o.encode(i).split(""),f=4*e/3;for(;s.length<f;)s.unshift(r[0]);for(let t=0;t<e-n.length;t++)s[s.length-1-t]="=";return s.join("")},decode:t=>{const r=o.decode(t.replace(/=/g,"A")),n=Math.ceil(3*t.length/4),e=(t.match(/=/g)||[]).length,i=r.length-n;return r.slice(i,r.length-e)}};function s(t){const r={ALPHABET_MAP:{},BASE:t.length,LEADER:t.charAt(0),ALPHABET:t};for(let t=0;t<r.ALPHABET.length;t++){const n=r.ALPHABET.charAt(t);if(void 0!==r.ALPHABET_MAP[n])throw new TypeError(n+" is ambiguous");r.ALPHABET_MAP[n]=t}return{encode:t=>function(t,r){if(0===t.length)return"";const n=[0];for(let e of t){for(let t=0;t<n.length;++t)e+=n[t]<<8,n[t]=e%r.BASE,e=e/r.BASE|0;for(;e>0;)n.push(e%r.BASE),e=e/r.BASE|0}let e="";for(let n=0;0===t[n]&&n<t.length-1;++n)e+=r.LEADER;for(let t=n.length-1;t>=0;--t)e+=r.ALPHABET[n[t]];return e}(t,r),decode:t=>function(t,r){const n=function(t,r){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array(0);const n=[0];for(const e of t){const t=r.ALPHABET_MAP[e];if(void 0===t)return;let o=t;for(let t=0;t<n.length;++t)o+=n[t]*r.BASE,n[t]=255&o,o>>=8;for(;o>0;)n.push(255&o),o>>=8}for(let e=0;t[e]===r.LEADER&&e<t.length-1;++e)n.push(0);return new Uint8Array(n.reverse())}(t,r);if(n)return n;throw new Error("Non-base"+r.BASE+" character")}(t,r)}}const Wt=BigInt(0),Jt=BigInt(1),Xt=BigInt(2),Qt=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),tr=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:Qt,n:Qt,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),rr=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),er=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742");const nr=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),or=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),ir=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),sr=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class fr{constructor(t,r,n,e){this.x=t,this.y=r,this.z=n,this.t=e}static fromAffine(t){if(!(t instanceof yr))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return t.equals(yr.ZERO)?fr.ZERO:new fr(t.x,t.y,Jt,xr(t.x*t.y))}static toAffineBatch(t){const r=function(t,r=tr.P){const n=new Array(t.length),e=Ur(t.reduce(((t,e,o)=>e===Wt?t:(n[o]=t,xr(t*e,r))),Jt),r);return t.reduceRight(((t,e,o)=>e===Wt?t:(n[o]=xr(t*n[o],r),xr(t*e,r))),e),n}(t.map((t=>t.z)));return t.map(((t,n)=>t.toAffine(r[n])))}static normalizeZ(t){return this.toAffineBatch(t).map(this.fromAffine)}equals(t){ar(t);const{x:r,y:n,z:e}=this,{x:o,y:i,z:s}=t,f=xr(r*s),h=xr(o*e),a=xr(n*s),c=xr(i*e);return f===h&&a===c}negate(){return new fr(xr(-this.x),this.y,this.z,xr(-this.t))}double(){const{x:t,y:r,z:n}=this,{a:e}=tr,o=xr(t*t),i=xr(r*r),s=xr(Xt*xr(n*n)),f=xr(e*o),h=t+r,a=xr(xr(h*h)-o-i),c=f+i,u=c-s,l=f-i,y=xr(a*u),d=xr(c*l),p=xr(a*l),w=xr(u*c);return new fr(y,d,w,p)}add(t){ar(t);const{x:r,y:n,z:e,t:o}=this,{x:i,y:s,z:f,t:h}=t,a=xr((n-r)*(s+i)),c=xr((n+r)*(s-i)),u=xr(c-a);if(u===Wt)return this.double();const l=xr(e*Xt*h),y=xr(o*Xt*f),d=y+l,p=c+a,w=y-l,g=xr(d*u),v=xr(p*w),b=xr(d*w),A=xr(u*p);return new fr(g,v,A,b)}subtract(t){return this.add(t.negate())}precomputeWindow(t){const r=1+256/t,n=[];let e=this,o=e;for(let i=0;i<r;i++){o=e,n.push(o);for(let r=1;r<2**(t-1);r++)o=o.add(e),n.push(o);e=o.double()}return n}wNAF(t,r){!r&&this.equals(fr.BASE)&&(r=yr.BASE);const n=r&&r._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let e=r&&lr.get(r);e||(e=this.precomputeWindow(n),r&&1!==n&&(e=fr.normalizeZ(e),lr.set(r,e)));let o=fr.ZERO,i=fr.ZERO;const s=1+256/n,f=2**(n-1),h=BigInt(2**n-1),a=2**n,c=BigInt(n);for(let r=0;r<s;r++){const n=r*f;let s=Number(t&h);if(t>>=c,s>f&&(s-=a,t+=Jt),0===s){let t=e[n];r%2&&(t=t.negate()),i=i.add(t)}else{let t=e[n+Math.abs(s)-1];s<0&&(t=t.negate()),o=o.add(t)}}return fr.normalizeZ([o,i])[0]}multiply(t,r){return this.wNAF(kr(t,tr.l),r)}multiplyUnsafe(t){let r=kr(t,tr.l,!1);const n=fr.BASE,e=fr.ZERO;if(r===Wt)return e;if(this.equals(e)||r===Jt)return this;if(this.equals(n))return this.wNAF(r);let o=e,i=this;for(;r>Wt;)r&Jt&&(o=o.add(i)),i=i.double(),r>>=Jt;return o}isSmallOrder(){return this.multiplyUnsafe(tr.h).equals(fr.ZERO)}isTorsionFree(){return this.multiplyUnsafe(tr.l).equals(fr.ZERO)}toAffine(t=Ur(this.z)){const{x:r,y:n,z:e}=this,o=xr(r*t),i=xr(n*t);if(xr(e*t)!==Jt)throw new Error("invZ was invalid");return new yr(o,i)}fromRistrettoBytes(){cr()}toRistrettoBytes(){cr()}fromRistrettoHash(){cr()}}function ar(t){if(!(t instanceof fr))throw new TypeError("ExtendedPoint expected")}function hr(t){if(!(t instanceof ur))throw new TypeError("RistrettoPoint expected")}function cr(){throw new Error("Legacy method: switch to RistrettoPoint")}fr.BASE=new fr(tr.Gx,tr.Gy,Jt,xr(tr.Gx*tr.Gy)),fr.ZERO=new fr(Wt,Jt,Jt,Wt);class ur{constructor(t){this.ep=t}static calcElligatorRistrettoMap(t){const{d:r}=tr,n=xr(er*t*t),e=xr((n+Jt)*ir);let o=BigInt(-1);const i=xr((o-r*n)*xr(n+r));let{isValid:s,value:f}=Sr(e,i),h=xr(f*t);Ar(h)||(h=xr(-h)),s||(f=h),s||(o=n);const a=xr(o*(n-Jt)*sr-i),c=f*f,u=xr((f+f)*i),l=xr(a*nr),y=xr(Jt-c),d=xr(Jt+c);return new fr(xr(u*d),xr(y*l),xr(l*d),xr(u*y))}static hashToCurve(t){const r=_r((t=Pr(t,64)).slice(0,32)),n=this.calcElligatorRistrettoMap(r),e=_r(t.slice(32,64)),o=this.calcElligatorRistrettoMap(e);return new ur(n.add(o))}static fromHex(t){t=Pr(t,32);const{a:r,d:n}=tr,e="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",o=_r(t);if(!function(t,r){if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n])return!1;return!0}(vr(o),t)||Ar(o))throw new Error(e);const i=xr(o*o),s=xr(Jt+r*i),f=xr(Jt-r*i),h=xr(s*s),a=xr(f*f),c=xr(r*n*h-a),{isValid:u,value:l}=Or(xr(c*a)),y=xr(l*f),d=xr(l*y*c);let p=xr((o+o)*y);Ar(p)&&(p=xr(-p));const w=xr(s*d),g=xr(p*w);if(!u||Ar(g)||w===Wt)throw new Error(e);return new ur(new fr(p,w,Jt,g))}toRawBytes(){let{x:t,y:r,z:n,t:e}=this.ep;const o=xr(xr(n+r)*xr(n-r)),i=xr(t*r),s=xr(i*i),{value:f}=Or(xr(o*s)),h=xr(f*o),a=xr(f*i),c=xr(h*a*e);let u;if(Ar(e*c)){let n=xr(r*er),e=xr(t*er);t=n,r=e,u=xr(h*or)}else u=a;Ar(t*c)&&(r=xr(-r));let l=xr((n-r)*u);return Ar(l)&&(l=xr(-l)),vr(l)}toHex(){return wr(this.toRawBytes())}toString(){return this.toHex()}equals(t){hr(t);const r=this.ep,n=t.ep,e=xr(r.x*n.y)===xr(r.y*n.x),o=xr(r.y*n.y)===xr(r.x*n.x);return e||o}add(t){return hr(t),new ur(this.ep.add(t.ep))}subtract(t){return hr(t),new ur(this.ep.subtract(t.ep))}multiply(t){return new ur(this.ep.multiply(t))}multiplyUnsafe(t){return new ur(this.ep.multiplyUnsafe(t))}}ur.BASE=new ur(fr.BASE),ur.ZERO=new ur(fr.ZERO);const lr=new WeakMap;class yr{constructor(t,r){this.x=t,this.y=r}_setWindowSize(t){this._WINDOW_SIZE=t,lr.delete(this)}static fromHex(t,r=!0){const{d:n,P:e}=tr,o=(t=Pr(t,32)).slice();o[31]=-129&t[31];const i=Er(o);if(r&&i>=e)throw new Error("Expected 0 < hex < P");if(!r&&i>=rr)throw new Error("Expected 0 < hex < 2**256");const s=xr(i*i),f=xr(s-Jt),h=xr(n*s+Jt);let{isValid:a,value:c}=Sr(f,h);if(!a)throw new Error("Point.fromHex: invalid y coordinate");const u=(c&Jt)===Jt;return 0!=(128&t[31])!==u&&(c=xr(-c)),new yr(c,i)}static async fromPrivateKey(t){return(await zr(t)).point}toRawBytes(){const t=vr(this.y);return t[31]|=this.x&Jt?128:0,t}toHex(){return wr(this.toRawBytes())}toX25519(){const{y:t}=this;return vr(xr((Jt+t)*Ur(Jt-t)))}isTorsionFree(){return fr.fromAffine(this).isTorsionFree()}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new yr(xr(-this.x),this.y)}add(t){return fr.fromAffine(this).add(fr.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return fr.fromAffine(this).multiply(t,this).toAffine()}}function pr(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Expected Uint8Array list");if(1===t.length)return t[0];const r=t.reduce(((t,r)=>t+r.length),0),n=new Uint8Array(r);for(let r=0,e=0;r<t.length;r++){const o=t[r];n.set(o,e),e+=o.length}return n}yr.BASE=new yr(tr.Gx,tr.Gy),yr.ZERO=new yr(Wt,Jt);const dr=Array.from({length:256},((t,r)=>r.toString(16).padStart(2,"0")));function wr(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let r="";for(let n=0;n<t.length;n++)r+=dr[t[n]];return r}function gr(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const r=new Uint8Array(t.length/2);for(let n=0;n<r.length;n++){const e=2*n,o=t.slice(e,e+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");r[n]=i}return r}function br(t){return gr(t.toString(16).padStart(64,"0"))}function vr(t){return br(t).reverse()}function Ar(t){return(xr(t)&Jt)===Jt}function Er(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+wr(Uint8Array.from(t).reverse()))}const mr=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function _r(t){return xr(Er(t)&mr)}function xr(t,r=tr.P){const n=t%r;return n>=Wt?n:r+n}function Ur(t,r=tr.P){if(t===Wt||r<=Wt)throw new Error(`invert: expected positive integers, got n=${t} mod=${r}`);let n=xr(t,r),e=r,o=Wt,i=Jt;for(;n!==Wt;){const t=e%n,r=o-i*(e/n);e=n,n=t,o=i,i=r}if(e!==Jt)throw new Error("invert: does not exist");return xr(o,r)}function Br(t,r){const{P:n}=tr;let e=t;for(;r-- >Wt;)e*=e,e%=n;return e}function Sr(t,r){const n=xr(r*r*r),e=function(t){const{P:r}=tr,n=BigInt(5),e=BigInt(10),o=BigInt(20),i=BigInt(40),s=BigInt(80),f=t*t%r*t%r,h=Br(f,Xt)*f%r,a=Br(h,Jt)*t%r,c=Br(a,n)*a%r,u=Br(c,e)*c%r,l=Br(u,o)*u%r,y=Br(l,i)*l%r,d=Br(y,s)*y%r,p=Br(d,s)*y%r,w=Br(p,e)*c%r;return{pow_p_5_8:Br(w,Xt)*t%r,b2:f}}(t*xr(n*n*r)).pow_p_5_8;let o=xr(t*n*e);const i=xr(r*o*o),s=o,f=xr(o*er),h=i===t,a=i===xr(-t),c=i===xr(-t*er);return h&&(o=s),(a||c)&&(o=f),Ar(o)&&(o=xr(-o)),{isValid:h||a,value:o}}function Or(t){return Sr(Jt,t)}function Pr(t,r){const n=t instanceof Uint8Array?Uint8Array.from(t):gr(t);if("number"==typeof r&&n.length!==r)throw new Error(`Expected ${r} bytes`);return n}function kr(t,r,n=!0){if(!r)throw new TypeError("Specify max value");if("number"==typeof t&&Number.isSafeInteger(t)&&(t=BigInt(t)),"bigint"==typeof t&&t<r)if(n){if(Wt<t)return t}else if(Wt<=t)return t;throw new TypeError("Expected valid scalar: 0 < scalar < max")}let Cr;async function zr(t){return function(t){const r=((n=t.slice(0,32))[0]&=248,n[31]&=127,n[31]|=64,n);var n;const e=t.slice(32,64),o=xr(Er(r),tr.l),i=yr.BASE.multiply(o),s=i.toRawBytes();return{head:r,prefix:e,scalar:o,point:i,pointBytes:s}}(await Tr.sha512(function(t){if(32!==(t="bigint"==typeof t||"number"==typeof t?br(kr(t,rr)):Pr(t)).length)throw new Error("Expected 32 bytes");return t}(t)))}yr.BASE._setWindowSize(8);const se={node:void 0,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},Tr={bytesToHex:wr,hexToBytes:gr,concatBytes:pr,getExtendedPublicKey:zr,mod:xr,invert:Ur,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:t=>{if((t=Pr(t)).length<40||t.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return xr(Er(t),tr.l-Jt)+Jt},randomBytes:(t=32)=>{if(se.web)return se.web.getRandomValues(new Uint8Array(t));throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Tr.randomBytes(32),sha512:async(...t)=>{const r=pr(...t);if(se.web){const t=await se.web.subtle.digest("SHA-512",r.buffer);return new Uint8Array(t)}throw new Error("The environment doesn't have sha512 function")},precompute(t=8,r=yr.BASE){const n=r.equals(yr.BASE)?r:new yr(r.x,r.y);return n._setWindowSize(t),n.multiply(Xt),n},sha512Sync:void 0};Object.defineProperties(Tr,{sha512Sync:{configurable:!1,get:()=>Cr,set(t){Cr||(Cr=t)}}}),x.setPRNG((async function(t,r){if(!t&&!r)return Math.random();r||"number"!=typeof t||(r=t,t=new Uint8Array(r));const n=r,e=new Uint8Array(r);for(let t=0;t<n;t+=65536)crypto.getRandomValues(e.subarray(t,t+Math.min(n-t,65536)));for(let r=0;r<n;r++)t[r]=e[r];return t}));const Mr=x.setPRNG,Nr=b(),Lr=x.sign.keyPair.fromSeed;async function Kr(t,r){const n=await Zr(t,r),e=Dr(n);return e.seed=n,e.pubKey=e.publicKey,e}function jr(t){const r={};for(const n in t)r[n]=e.encode(t[n]);return r}async function tn(t,r){const n=await Kr(t,r);return Object.assign(jr(n),{idSec:t,password:r})}function Dr(t){return Lr(t)}async function Zr(t,r){return a(r.normalize("NFKC"),t.normalize("NFKC"),{logN:12,r:16,p:1,encoding:"binary"})}function rn(t){return`${t.substr(0,4)}${t.substr(-4,4)}:${Yr(t)}`}function Yr(t,r=!1,n=!1,o=!0){const i=r?e.decode(t):$r(t);let s=Nr.digest(i);if(o&&(s=Nr.digest(s)),!n){const t=Hr(s);return e.encode(t).substr(0,3)}return e.encode(s).substr(0,3)}function Hr(t){let r=0;for(;0===t[r];)r++;return t.slice(r)}function $r(t){return"string"==typeof t?t.includes(":")?Gr(Fr(t)):Gr(t):t}function Gr(t){const r=new Uint8Array(32),n=e.decode(t);return r.set(n,32-n.length),r}function Vr(t){const r=new Uint8Array(64),n=e.decode(t);return r.set(n,64-n.length),r}function Fr(t){const r=t.split(":"),n=r[0],e=r[1];if(Yr(n)===e)return n;if(Yr(n,!0)===e)return n;if(Yr(n,!1,!0)===e)return n;if(Yr(n,!0,!0)===e)return n;if(Yr(n,!1,!1,!1)===e)return n;if(Yr(n,!0,!1,!1)===e)return n;if(Yr(n,!1,!0,!1)===e)return n;if(Yr(n,!0,!0,!1)===e)return n;throw new ie("bad_checksum","Bad checksum")}function nn(t){return/^[A-HJ-NP-Za-km-z1-9]{43,44}$/.test(t)&&e.decode(t).length<=32}function qr(t){if(t.length<43)throw new ie("too_short","Too short, see rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key for details.");if(t.length>44)throw new ie("too_long","Base58 string too long, see rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key for details.");if(!/^[A-HJ-NP-Za-km-z1-9]+$/.test(t))throw new ie("not_b58","Character out of base 58, see rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key for details.");if(e.decode(t).length>32)throw new ie("too_long","binary key too long, see rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key for details.");return!0}function Wr(t){const r=$r(t);try{yr.fromHex(r)}catch(t){throw new ie("bad_ed25519_point",`Invalid public key : not a valid ed25519 point RFC8032 5.1.3 https://www.rfc-editor.org/rfc/rfc8032#page-11 Internal:${t}`)}return!0}function en(t){try{return Wr(t)}catch(t){return!1}}function Jr(t,r=!0){if(!t)throw new ie("empty","Invalid public key : empty input.");let n;try{const r=$r(t);n="string"==typeof t?t:e.encode(r)}catch(t){if(t.message.match(/base58/))throw new ie("not_b58","Character out of base 58, see rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key for details.");if("RangeError"===t.name)throw new ie("too_long","Binary key too long, see rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key for details.");throw t}return!r||(qr(n),Wr(n),!0)}function on(t){try{return Jr(t)}catch(t){return!1}}async function sn(t,r){const n=await Xr(t.trim()+"\n",r);return`${t.trim()}\n${n}`}function Xr(t,r,n="b64"){const o=Qr((new TextEncoder).encode(t),Vr(r).slice(0,32));switch(n.toLocaleLowerCase()){case"raw":case"array":case"uint8array":return o;case"b64":return i.encode(o);case"b58":return e.encode(o);default:throw new Error(`OutputFormat ${n} not handled.`)}}function Qr(t,r){const n=Dr(r);return x.sign.detached(t,n.secretKey)}function te(t,r){return"string"==typeof t?r(t):t}function re(t){const r=new TextEncoder;return"string"==typeof t?r.encode(t):t}function fn(t){return te(t,i.decode)}function ee(t){return te(t,e.decode)}function ne(t){return(new TextDecoder).decode(t)}function oe(t){return ee(t).slice(0,32)}function hn(t,r,o,s=0,f=""){const h=f?e.decode(f):x.randomBytes(24);console.log("Défini : ",o);const a=Ft($r(o)),c=qt(oe(r)),u=t=>i.encode(x.box(re(t),h,a,c)),l=e.encode(Dr(oe(r)).publicKey),y=s||Math.trunc(Date.now()/1e3),d={nonce:e.encode(h),issuer:l,recipient:o,time:y,version:2};return t.title&&(d.title=u(t.title)),t.content&&(d.content=u(t.content)),d.hash=n.encode(Nr.digest(JSON.stringify(d))).toUpperCase(),d.signature=Xr(d.hash,r),d}function an(t,r){const n=e.decode(t.nonce),o=qt(oe(r)),s=Ft($r(t.issuer)),f=t=>ne(x.box.open(i.decode(t),n,s,o)),h={};return t.content&&(h.content=f(t.content)),t.title&&(h.title=f(t.title)),h}class ie extends Error{constructor(t,r){super(r),this.name=t}}export{e as b58,ee as b58orBin2bin,Gr as b58pubKey2bin,Vr as b58secretKey2bin,i as b64,fn as b64orBin2bin,ne as bin2str,qr as checkDuniterPubKey,Wr as checkEd25519PubKey,Jr as checkKey,tn as idSecPass2cleanKeys,Kr as idSecPass2rawAll,nn as isDuniterPubKey,en as isEd25519PubKey,on as isPubKey,Mr as mockRandom,Fr as onlyPubKey,$r as pubKey2bin,Yr as pubKey2checksum,rn as pubKey2shortKey,jr as raw2b58,Qr as rawSign,Zr as saltPass2seed,Dr as seed2keyPair,b as sha256,Xr as sign,sn as signDocument,Hr as sliceInitialsZero,re as strOrBin2bin,an as textDecrypt,hn as textEncrypt,te as typedStrOrBin2Bin};