@substrate-system/keys 0.2.38 → 0.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -11
- package/dist/_base.min.js +2 -2
- package/dist/_base.min.js.map +3 -3
- package/dist/aes/index.cjs.map +1 -1
- package/dist/aes/index.d.ts.map +1 -1
- package/dist/aes/index.js.map +1 -1
- package/dist/aes/index.min.cjs.map +1 -1
- package/dist/aes/index.min.js +2 -2
- package/dist/aes/index.min.js.map +2 -2
- package/dist/browser/index.js +6 -1
- package/dist/browser/index.min.js +2 -2
- package/dist/crypto.cjs +6 -1
- package/dist/crypto.cjs.map +2 -2
- package/dist/crypto.d.ts +3 -5
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +6 -1
- package/dist/crypto.js.map +2 -2
- package/dist/crypto.min.cjs +2 -2
- package/dist/crypto.min.cjs.map +3 -3
- package/dist/crypto.min.js +2 -2
- package/dist/crypto.min.js.map +3 -3
- package/dist/ecc/index.min.js +2 -2
- package/dist/ecc/index.min.js.map +3 -3
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +3 -3
- package/dist/meta.json +8 -8
- package/dist/rsa/index.min.js +2 -2
- package/dist/rsa/index.min.js.map +3 -3
- package/dist/util.cjs.map +2 -2
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js.map +2 -2
- package/dist/util.min.cjs +1 -1
- package/dist/util.min.cjs.map +2 -2
- package/dist/util.min.js +1 -1
- package/dist/util.min.js.map +2 -2
- package/package.json +4 -4
package/dist/ecc/index.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var bf=Object.create;var Sr=Object.defineProperty;var mf=Object.getOwnPropertyDescriptor;var Af=Object.getOwnPropertyNames;var wf=Object.getPrototypeOf,Kf=Object.prototype.hasOwnProperty;var Ef=(n,r,f)=>r in n?Sr(n,r,{enumerable:!0,configurable:!0,writable:!0,value:f}):n[r]=f;var y=(n,r)=>Sr(n,"name",{value:r,configurable:!0}),Cn=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(r,f)=>(typeof require<"u"?require:r)[f]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Bn=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),Le=(n,r)=>{for(var f in r)Sr(n,f,{get:r[f],enumerable:!0})},Uf=(n,r,f,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let x of Af(r))!Kf.call(n,x)&&x!==f&&Sr(n,x,{get:()=>r[x],enumerable:!(s=mf(r,x))||s.enumerable});return n};var vf=(n,r,f)=>(f=n!=null?bf(wf(n)):{},Uf(r||!n||!n.__esModule?Sr(f,"default",{value:n,enumerable:!0}):f,n));var Y=(n,r,f)=>Ef(n,typeof r!="symbol"?r+"":r,f);var of=Bn(()=>{"use strict"});var af=Bn((ls,tt)=>{"use strict";(function(n){"use strict";var r=y(function(t){var o,i=new Float64Array(16);if(t)for(o=0;o<t.length;o++)i[o]=t[o];return i},"gf"),f=y(function(){throw new Error("no PRNG")},"randombytes"),s=new Uint8Array(16),x=new Uint8Array(32);x[0]=9;var d=r(),v=r([1]),M=r([56129,1]),$=r([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),le=r([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),ie=r([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),pe=r([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Pe=r([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Fe(t,o,i,e){t[o]=i>>24&255,t[o+1]=i>>16&255,t[o+2]=i>>8&255,t[o+3]=i&255,t[o+4]=e>>24&255,t[o+5]=e>>16&255,t[o+6]=e>>8&255,t[o+7]=e&255}y(Fe,"ts64");function W(t,o,i,e,a){var u,p=0;for(u=0;u<a;u++)p|=t[o+u]^i[e+u];return(1&p-1>>>8)-1}y(W,"vn");function fe(t,o,i,e){return W(t,o,i,e,16)}y(fe,"crypto_verify_16");function me(t,o,i,e){return W(t,o,i,e,32)}y(me,"crypto_verify_32");function we(t,o,i,e){for(var a=e[0]&255|(e[1]&255)<<8|(e[2]&255)<<16|(e[3]&255)<<24,u=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,p=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,b=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,K=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,T=e[4]&255|(e[5]&255)<<8|(e[6]&255)<<16|(e[7]&255)<<24,U=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,Q=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,_=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,L=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,N=e[8]&255|(e[9]&255)<<8|(e[10]&255)<<16|(e[11]&255)<<24,H=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,j=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,R=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,z=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,O=e[12]&255|(e[13]&255)<<8|(e[14]&255)<<16|(e[15]&255)<<24,C=a,D=u,S=p,B=b,P=K,E=T,h=U,l=Q,A=_,g=L,m=N,w=H,I=j,F=R,V=z,G=O,c,X=0;X<20;X+=2)c=C+I|0,P^=c<<7|c>>>25,c=P+C|0,A^=c<<9|c>>>23,c=A+P|0,I^=c<<13|c>>>19,c=I+A|0,C^=c<<18|c>>>14,c=E+D|0,g^=c<<7|c>>>25,c=g+E|0,F^=c<<9|c>>>23,c=F+g|0,D^=c<<13|c>>>19,c=D+F|0,E^=c<<18|c>>>14,c=m+h|0,V^=c<<7|c>>>25,c=V+m|0,S^=c<<9|c>>>23,c=S+V|0,h^=c<<13|c>>>19,c=h+S|0,m^=c<<18|c>>>14,c=G+w|0,B^=c<<7|c>>>25,c=B+G|0,l^=c<<9|c>>>23,c=l+B|0,w^=c<<13|c>>>19,c=w+l|0,G^=c<<18|c>>>14,c=C+B|0,D^=c<<7|c>>>25,c=D+C|0,S^=c<<9|c>>>23,c=S+D|0,B^=c<<13|c>>>19,c=B+S|0,C^=c<<18|c>>>14,c=E+P|0,h^=c<<7|c>>>25,c=h+E|0,l^=c<<9|c>>>23,c=l+h|0,P^=c<<13|c>>>19,c=P+l|0,E^=c<<18|c>>>14,c=m+g|0,w^=c<<7|c>>>25,c=w+m|0,A^=c<<9|c>>>23,c=A+w|0,g^=c<<13|c>>>19,c=g+A|0,m^=c<<18|c>>>14,c=G+V|0,I^=c<<7|c>>>25,c=I+G|0,F^=c<<9|c>>>23,c=F+I|0,V^=c<<13|c>>>19,c=V+F|0,G^=c<<18|c>>>14;C=C+a|0,D=D+u|0,S=S+p|0,B=B+b|0,P=P+K|0,E=E+T|0,h=h+U|0,l=l+Q|0,A=A+_|0,g=g+L|0,m=m+N|0,w=w+H|0,I=I+j|0,F=F+R|0,V=V+z|0,G=G+O|0,t[0]=C>>>0&255,t[1]=C>>>8&255,t[2]=C>>>16&255,t[3]=C>>>24&255,t[4]=D>>>0&255,t[5]=D>>>8&255,t[6]=D>>>16&255,t[7]=D>>>24&255,t[8]=S>>>0&255,t[9]=S>>>8&255,t[10]=S>>>16&255,t[11]=S>>>24&255,t[12]=B>>>0&255,t[13]=B>>>8&255,t[14]=B>>>16&255,t[15]=B>>>24&255,t[16]=P>>>0&255,t[17]=P>>>8&255,t[18]=P>>>16&255,t[19]=P>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=h>>>0&255,t[25]=h>>>8&255,t[26]=h>>>16&255,t[27]=h>>>24&255,t[28]=l>>>0&255,t[29]=l>>>8&255,t[30]=l>>>16&255,t[31]=l>>>24&255,t[32]=A>>>0&255,t[33]=A>>>8&255,t[34]=A>>>16&255,t[35]=A>>>24&255,t[36]=g>>>0&255,t[37]=g>>>8&255,t[38]=g>>>16&255,t[39]=g>>>24&255,t[40]=m>>>0&255,t[41]=m>>>8&255,t[42]=m>>>16&255,t[43]=m>>>24&255,t[44]=w>>>0&255,t[45]=w>>>8&255,t[46]=w>>>16&255,t[47]=w>>>24&255,t[48]=I>>>0&255,t[49]=I>>>8&255,t[50]=I>>>16&255,t[51]=I>>>24&255,t[52]=F>>>0&255,t[53]=F>>>8&255,t[54]=F>>>16&255,t[55]=F>>>24&255,t[56]=V>>>0&255,t[57]=V>>>8&255,t[58]=V>>>16&255,t[59]=V>>>24&255,t[60]=G>>>0&255,t[61]=G>>>8&255,t[62]=G>>>16&255,t[63]=G>>>24&255}y(we,"core_salsa20");function Ce(t,o,i,e){for(var a=e[0]&255|(e[1]&255)<<8|(e[2]&255)<<16|(e[3]&255)<<24,u=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,p=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,b=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,K=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,T=e[4]&255|(e[5]&255)<<8|(e[6]&255)<<16|(e[7]&255)<<24,U=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,Q=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,_=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,L=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,N=e[8]&255|(e[9]&255)<<8|(e[10]&255)<<16|(e[11]&255)<<24,H=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,j=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,R=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,z=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,O=e[12]&255|(e[13]&255)<<8|(e[14]&255)<<16|(e[15]&255)<<24,C=a,D=u,S=p,B=b,P=K,E=T,h=U,l=Q,A=_,g=L,m=N,w=H,I=j,F=R,V=z,G=O,c,X=0;X<20;X+=2)c=C+I|0,P^=c<<7|c>>>25,c=P+C|0,A^=c<<9|c>>>23,c=A+P|0,I^=c<<13|c>>>19,c=I+A|0,C^=c<<18|c>>>14,c=E+D|0,g^=c<<7|c>>>25,c=g+E|0,F^=c<<9|c>>>23,c=F+g|0,D^=c<<13|c>>>19,c=D+F|0,E^=c<<18|c>>>14,c=m+h|0,V^=c<<7|c>>>25,c=V+m|0,S^=c<<9|c>>>23,c=S+V|0,h^=c<<13|c>>>19,c=h+S|0,m^=c<<18|c>>>14,c=G+w|0,B^=c<<7|c>>>25,c=B+G|0,l^=c<<9|c>>>23,c=l+B|0,w^=c<<13|c>>>19,c=w+l|0,G^=c<<18|c>>>14,c=C+B|0,D^=c<<7|c>>>25,c=D+C|0,S^=c<<9|c>>>23,c=S+D|0,B^=c<<13|c>>>19,c=B+S|0,C^=c<<18|c>>>14,c=E+P|0,h^=c<<7|c>>>25,c=h+E|0,l^=c<<9|c>>>23,c=l+h|0,P^=c<<13|c>>>19,c=P+l|0,E^=c<<18|c>>>14,c=m+g|0,w^=c<<7|c>>>25,c=w+m|0,A^=c<<9|c>>>23,c=A+w|0,g^=c<<13|c>>>19,c=g+A|0,m^=c<<18|c>>>14,c=G+V|0,I^=c<<7|c>>>25,c=I+G|0,F^=c<<9|c>>>23,c=F+I|0,V^=c<<13|c>>>19,c=V+F|0,G^=c<<18|c>>>14;t[0]=C>>>0&255,t[1]=C>>>8&255,t[2]=C>>>16&255,t[3]=C>>>24&255,t[4]=E>>>0&255,t[5]=E>>>8&255,t[6]=E>>>16&255,t[7]=E>>>24&255,t[8]=m>>>0&255,t[9]=m>>>8&255,t[10]=m>>>16&255,t[11]=m>>>24&255,t[12]=G>>>0&255,t[13]=G>>>8&255,t[14]=G>>>16&255,t[15]=G>>>24&255,t[16]=h>>>0&255,t[17]=h>>>8&255,t[18]=h>>>16&255,t[19]=h>>>24&255,t[20]=l>>>0&255,t[21]=l>>>8&255,t[22]=l>>>16&255,t[23]=l>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=g>>>0&255,t[29]=g>>>8&255,t[30]=g>>>16&255,t[31]=g>>>24&255}y(Ce,"core_hsalsa20");function ye(t,o,i,e){we(t,o,i,e)}y(ye,"crypto_core_salsa20");function Ae(t,o,i,e){Ce(t,o,i,e)}y(Ae,"crypto_core_hsalsa20");var ge=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Re(t,o,i,e,a,u,p){var b=new Uint8Array(16),K=new Uint8Array(64),T,U;for(U=0;U<16;U++)b[U]=0;for(U=0;U<8;U++)b[U]=u[U];for(;a>=64;){for(ye(K,b,p,ge),U=0;U<64;U++)t[o+U]=i[e+U]^K[U];for(T=1,U=8;U<16;U++)T=T+(b[U]&255)|0,b[U]=T&255,T>>>=8;a-=64,o+=64,e+=64}if(a>0)for(ye(K,b,p,ge),U=0;U<a;U++)t[o+U]=i[e+U]^K[U];return 0}y(Re,"crypto_stream_salsa20_xor");function Be(t,o,i,e,a){var u=new Uint8Array(16),p=new Uint8Array(64),b,K;for(K=0;K<16;K++)u[K]=0;for(K=0;K<8;K++)u[K]=e[K];for(;i>=64;){for(ye(p,u,a,ge),K=0;K<64;K++)t[o+K]=p[K];for(b=1,K=8;K<16;K++)b=b+(u[K]&255)|0,u[K]=b&255,b>>>=8;i-=64,o+=64}if(i>0)for(ye(p,u,a,ge),K=0;K<i;K++)t[o+K]=p[K];return 0}y(Be,"crypto_stream_salsa20");function Ie(t,o,i,e,a){var u=new Uint8Array(32);Ae(u,e,a,ge);for(var p=new Uint8Array(8),b=0;b<8;b++)p[b]=e[b+16];return Be(t,o,i,p,u)}y(Ie,"crypto_stream");function Xe(t,o,i,e,a,u,p){var b=new Uint8Array(32);Ae(b,u,p,ge);for(var K=new Uint8Array(8),T=0;T<8;T++)K[T]=u[T+16];return Re(t,o,i,e,a,K,b)}y(Xe,"crypto_stream_xor");var Rr=y(function(t){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;var o,i,e,a,u,p,b,K;o=t[0]&255|(t[1]&255)<<8,this.r[0]=o&8191,i=t[2]&255|(t[3]&255)<<8,this.r[1]=(o>>>13|i<<3)&8191,e=t[4]&255|(t[5]&255)<<8,this.r[2]=(i>>>10|e<<6)&7939,a=t[6]&255|(t[7]&255)<<8,this.r[3]=(e>>>7|a<<9)&8191,u=t[8]&255|(t[9]&255)<<8,this.r[4]=(a>>>4|u<<12)&255,this.r[5]=u>>>1&8190,p=t[10]&255|(t[11]&255)<<8,this.r[6]=(u>>>14|p<<2)&8191,b=t[12]&255|(t[13]&255)<<8,this.r[7]=(p>>>11|b<<5)&8065,K=t[14]&255|(t[15]&255)<<8,this.r[8]=(b>>>8|K<<8)&8191,this.r[9]=K>>>5&127,this.pad[0]=t[16]&255|(t[17]&255)<<8,this.pad[1]=t[18]&255|(t[19]&255)<<8,this.pad[2]=t[20]&255|(t[21]&255)<<8,this.pad[3]=t[22]&255|(t[23]&255)<<8,this.pad[4]=t[24]&255|(t[25]&255)<<8,this.pad[5]=t[26]&255|(t[27]&255)<<8,this.pad[6]=t[28]&255|(t[29]&255)<<8,this.pad[7]=t[30]&255|(t[31]&255)<<8},"poly1305");Rr.prototype.blocks=function(t,o,i){for(var e=this.fin?0:2048,a,u,p,b,K,T,U,Q,_,L,N,H,j,R,z,O,C,D,S,B=this.h[0],P=this.h[1],E=this.h[2],h=this.h[3],l=this.h[4],A=this.h[5],g=this.h[6],m=this.h[7],w=this.h[8],I=this.h[9],F=this.r[0],V=this.r[1],G=this.r[2],c=this.r[3],X=this.r[4],ee=this.r[5],re=this.r[6],k=this.r[7],J=this.r[8],q=this.r[9];i>=16;)a=t[o+0]&255|(t[o+1]&255)<<8,B+=a&8191,u=t[o+2]&255|(t[o+3]&255)<<8,P+=(a>>>13|u<<3)&8191,p=t[o+4]&255|(t[o+5]&255)<<8,E+=(u>>>10|p<<6)&8191,b=t[o+6]&255|(t[o+7]&255)<<8,h+=(p>>>7|b<<9)&8191,K=t[o+8]&255|(t[o+9]&255)<<8,l+=(b>>>4|K<<12)&8191,A+=K>>>1&8191,T=t[o+10]&255|(t[o+11]&255)<<8,g+=(K>>>14|T<<2)&8191,U=t[o+12]&255|(t[o+13]&255)<<8,m+=(T>>>11|U<<5)&8191,Q=t[o+14]&255|(t[o+15]&255)<<8,w+=(U>>>8|Q<<8)&8191,I+=Q>>>5|e,_=0,L=_,L+=B*F,L+=P*(5*q),L+=E*(5*J),L+=h*(5*k),L+=l*(5*re),_=L>>>13,L&=8191,L+=A*(5*ee),L+=g*(5*X),L+=m*(5*c),L+=w*(5*G),L+=I*(5*V),_+=L>>>13,L&=8191,N=_,N+=B*V,N+=P*F,N+=E*(5*q),N+=h*(5*J),N+=l*(5*k),_=N>>>13,N&=8191,N+=A*(5*re),N+=g*(5*ee),N+=m*(5*X),N+=w*(5*c),N+=I*(5*G),_+=N>>>13,N&=8191,H=_,H+=B*G,H+=P*V,H+=E*F,H+=h*(5*q),H+=l*(5*J),_=H>>>13,H&=8191,H+=A*(5*k),H+=g*(5*re),H+=m*(5*ee),H+=w*(5*X),H+=I*(5*c),_+=H>>>13,H&=8191,j=_,j+=B*c,j+=P*G,j+=E*V,j+=h*F,j+=l*(5*q),_=j>>>13,j&=8191,j+=A*(5*J),j+=g*(5*k),j+=m*(5*re),j+=w*(5*ee),j+=I*(5*X),_+=j>>>13,j&=8191,R=_,R+=B*X,R+=P*c,R+=E*G,R+=h*V,R+=l*F,_=R>>>13,R&=8191,R+=A*(5*q),R+=g*(5*J),R+=m*(5*k),R+=w*(5*re),R+=I*(5*ee),_+=R>>>13,R&=8191,z=_,z+=B*ee,z+=P*X,z+=E*c,z+=h*G,z+=l*V,_=z>>>13,z&=8191,z+=A*F,z+=g*(5*q),z+=m*(5*J),z+=w*(5*k),z+=I*(5*re),_+=z>>>13,z&=8191,O=_,O+=B*re,O+=P*ee,O+=E*X,O+=h*c,O+=l*G,_=O>>>13,O&=8191,O+=A*V,O+=g*F,O+=m*(5*q),O+=w*(5*J),O+=I*(5*k),_+=O>>>13,O&=8191,C=_,C+=B*k,C+=P*re,C+=E*ee,C+=h*X,C+=l*c,_=C>>>13,C&=8191,C+=A*G,C+=g*V,C+=m*F,C+=w*(5*q),C+=I*(5*J),_+=C>>>13,C&=8191,D=_,D+=B*J,D+=P*k,D+=E*re,D+=h*ee,D+=l*X,_=D>>>13,D&=8191,D+=A*c,D+=g*G,D+=m*V,D+=w*F,D+=I*(5*q),_+=D>>>13,D&=8191,S=_,S+=B*q,S+=P*J,S+=E*k,S+=h*re,S+=l*ee,_=S>>>13,S&=8191,S+=A*X,S+=g*c,S+=m*G,S+=w*V,S+=I*F,_+=S>>>13,S&=8191,_=(_<<2)+_|0,_=_+L|0,L=_&8191,_=_>>>13,N+=_,B=L,P=N,E=H,h=j,l=R,A=z,g=O,m=C,w=D,I=S,o+=16,i-=16;this.h[0]=B,this.h[1]=P,this.h[2]=E,this.h[3]=h,this.h[4]=l,this.h[5]=A,this.h[6]=g,this.h[7]=m,this.h[8]=w,this.h[9]=I},Rr.prototype.finish=function(t,o){var i=new Uint16Array(10),e,a,u,p;if(this.leftover){for(p=this.leftover,this.buffer[p++]=1;p<16;p++)this.buffer[p]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(e=this.h[1]>>>13,this.h[1]&=8191,p=2;p<10;p++)this.h[p]+=e,e=this.h[p]>>>13,this.h[p]&=8191;for(this.h[0]+=e*5,e=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=e,e=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=e,i[0]=this.h[0]+5,e=i[0]>>>13,i[0]&=8191,p=1;p<10;p++)i[p]=this.h[p]+e,e=i[p]>>>13,i[p]&=8191;for(i[9]-=8192,a=(e^1)-1,p=0;p<10;p++)i[p]&=a;for(a=~a,p=0;p<10;p++)this.h[p]=this.h[p]&a|i[p];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,u=this.h[0]+this.pad[0],this.h[0]=u&65535,p=1;p<8;p++)u=(this.h[p]+this.pad[p]|0)+(u>>>16)|0,this.h[p]=u&65535;t[o+0]=this.h[0]>>>0&255,t[o+1]=this.h[0]>>>8&255,t[o+2]=this.h[1]>>>0&255,t[o+3]=this.h[1]>>>8&255,t[o+4]=this.h[2]>>>0&255,t[o+5]=this.h[2]>>>8&255,t[o+6]=this.h[3]>>>0&255,t[o+7]=this.h[3]>>>8&255,t[o+8]=this.h[4]>>>0&255,t[o+9]=this.h[4]>>>8&255,t[o+10]=this.h[5]>>>0&255,t[o+11]=this.h[5]>>>8&255,t[o+12]=this.h[6]>>>0&255,t[o+13]=this.h[6]>>>8&255,t[o+14]=this.h[7]>>>0&255,t[o+15]=this.h[7]>>>8&255},Rr.prototype.update=function(t,o,i){var e,a;if(this.leftover){for(a=16-this.leftover,a>i&&(a=i),e=0;e<a;e++)this.buffer[this.leftover+e]=t[o+e];if(i-=a,o+=a,this.leftover+=a,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(i>=16&&(a=i-i%16,this.blocks(t,o,a),o+=a,i-=a),i){for(e=0;e<i;e++)this.buffer[this.leftover+e]=t[o+e];this.leftover+=i}};function ot(t,o,i,e,a,u){var p=new Rr(u);return p.update(i,e,a),p.finish(t,o),0}y(ot,"crypto_onetimeauth");function hn(t,o,i,e,a,u){var p=new Uint8Array(16);return ot(p,0,i,e,a,u),fe(t,o,p,0)}y(hn,"crypto_onetimeauth_verify");function at(t,o,i,e,a){var u;if(i<32)return-1;for(Xe(t,0,o,0,i,e,a),ot(t,16,t,32,i-32,t),u=0;u<16;u++)t[u]=0;return 0}y(at,"crypto_secretbox");function st(t,o,i,e,a){var u,p=new Uint8Array(32);if(i<32||(Ie(p,0,32,e,a),hn(o,16,o,32,i-32,p)!==0))return-1;for(Xe(t,0,o,0,i,e,a),u=0;u<32;u++)t[u]=0;return 0}y(st,"crypto_secretbox_open");function Ge(t,o){var i;for(i=0;i<16;i++)t[i]=o[i]|0}y(Ge,"set25519");function ct(t){var o,i,e=1;for(o=0;o<16;o++)i=t[o]+e+65535,e=Math.floor(i/65536),t[o]=i-e*65536;t[0]+=e-1+37*(e-1)}y(ct,"car25519");function ir(t,o,i){for(var e,a=~(i-1),u=0;u<16;u++)e=a&(t[u]^o[u]),t[u]^=e,o[u]^=e}y(ir,"sel25519");function or(t,o){var i,e,a,u=r(),p=r();for(i=0;i<16;i++)p[i]=o[i];for(ct(p),ct(p),ct(p),e=0;e<2;e++){for(u[0]=p[0]-65517,i=1;i<15;i++)u[i]=p[i]-65535-(u[i-1]>>16&1),u[i-1]&=65535;u[15]=p[15]-32767-(u[14]>>16&1),a=u[15]>>16&1,u[14]&=65535,ir(p,u,1-a)}for(i=0;i<16;i++)t[2*i]=p[i]&255,t[2*i+1]=p[i]>>8}y(or,"pack25519");function ln(t,o){var i=new Uint8Array(32),e=new Uint8Array(32);return or(i,t),or(e,o),me(i,0,e,0)}y(ln,"neq25519");function dn(t){var o=new Uint8Array(32);return or(o,t),o[0]&1}y(dn,"par25519");function yt(t,o){var i;for(i=0;i<16;i++)t[i]=o[2*i]+(o[2*i+1]<<8);t[15]&=32767}y(yt,"unpack25519");function Oe(t,o,i){for(var e=0;e<16;e++)t[e]=o[e]+i[e]}y(Oe,"A");function ze(t,o,i){for(var e=0;e<16;e++)t[e]=o[e]-i[e]}y(ze,"Z");function Z(t,o,i){var e,a,u=0,p=0,b=0,K=0,T=0,U=0,Q=0,_=0,L=0,N=0,H=0,j=0,R=0,z=0,O=0,C=0,D=0,S=0,B=0,P=0,E=0,h=0,l=0,A=0,g=0,m=0,w=0,I=0,F=0,V=0,G=0,c=i[0],X=i[1],ee=i[2],re=i[3],k=i[4],J=i[5],q=i[6],xe=i[7],ne=i[8],oe=i[9],ae=i[10],se=i[11],de=i[12],Ke=i[13],Ee=i[14],Ue=i[15];e=o[0],u+=e*c,p+=e*X,b+=e*ee,K+=e*re,T+=e*k,U+=e*J,Q+=e*q,_+=e*xe,L+=e*ne,N+=e*oe,H+=e*ae,j+=e*se,R+=e*de,z+=e*Ke,O+=e*Ee,C+=e*Ue,e=o[1],p+=e*c,b+=e*X,K+=e*ee,T+=e*re,U+=e*k,Q+=e*J,_+=e*q,L+=e*xe,N+=e*ne,H+=e*oe,j+=e*ae,R+=e*se,z+=e*de,O+=e*Ke,C+=e*Ee,D+=e*Ue,e=o[2],b+=e*c,K+=e*X,T+=e*ee,U+=e*re,Q+=e*k,_+=e*J,L+=e*q,N+=e*xe,H+=e*ne,j+=e*oe,R+=e*ae,z+=e*se,O+=e*de,C+=e*Ke,D+=e*Ee,S+=e*Ue,e=o[3],K+=e*c,T+=e*X,U+=e*ee,Q+=e*re,_+=e*k,L+=e*J,N+=e*q,H+=e*xe,j+=e*ne,R+=e*oe,z+=e*ae,O+=e*se,C+=e*de,D+=e*Ke,S+=e*Ee,B+=e*Ue,e=o[4],T+=e*c,U+=e*X,Q+=e*ee,_+=e*re,L+=e*k,N+=e*J,H+=e*q,j+=e*xe,R+=e*ne,z+=e*oe,O+=e*ae,C+=e*se,D+=e*de,S+=e*Ke,B+=e*Ee,P+=e*Ue,e=o[5],U+=e*c,Q+=e*X,_+=e*ee,L+=e*re,N+=e*k,H+=e*J,j+=e*q,R+=e*xe,z+=e*ne,O+=e*oe,C+=e*ae,D+=e*se,S+=e*de,B+=e*Ke,P+=e*Ee,E+=e*Ue,e=o[6],Q+=e*c,_+=e*X,L+=e*ee,N+=e*re,H+=e*k,j+=e*J,R+=e*q,z+=e*xe,O+=e*ne,C+=e*oe,D+=e*ae,S+=e*se,B+=e*de,P+=e*Ke,E+=e*Ee,h+=e*Ue,e=o[7],_+=e*c,L+=e*X,N+=e*ee,H+=e*re,j+=e*k,R+=e*J,z+=e*q,O+=e*xe,C+=e*ne,D+=e*oe,S+=e*ae,B+=e*se,P+=e*de,E+=e*Ke,h+=e*Ee,l+=e*Ue,e=o[8],L+=e*c,N+=e*X,H+=e*ee,j+=e*re,R+=e*k,z+=e*J,O+=e*q,C+=e*xe,D+=e*ne,S+=e*oe,B+=e*ae,P+=e*se,E+=e*de,h+=e*Ke,l+=e*Ee,A+=e*Ue,e=o[9],N+=e*c,H+=e*X,j+=e*ee,R+=e*re,z+=e*k,O+=e*J,C+=e*q,D+=e*xe,S+=e*ne,B+=e*oe,P+=e*ae,E+=e*se,h+=e*de,l+=e*Ke,A+=e*Ee,g+=e*Ue,e=o[10],H+=e*c,j+=e*X,R+=e*ee,z+=e*re,O+=e*k,C+=e*J,D+=e*q,S+=e*xe,B+=e*ne,P+=e*oe,E+=e*ae,h+=e*se,l+=e*de,A+=e*Ke,g+=e*Ee,m+=e*Ue,e=o[11],j+=e*c,R+=e*X,z+=e*ee,O+=e*re,C+=e*k,D+=e*J,S+=e*q,B+=e*xe,P+=e*ne,E+=e*oe,h+=e*ae,l+=e*se,A+=e*de,g+=e*Ke,m+=e*Ee,w+=e*Ue,e=o[12],R+=e*c,z+=e*X,O+=e*ee,C+=e*re,D+=e*k,S+=e*J,B+=e*q,P+=e*xe,E+=e*ne,h+=e*oe,l+=e*ae,A+=e*se,g+=e*de,m+=e*Ke,w+=e*Ee,I+=e*Ue,e=o[13],z+=e*c,O+=e*X,C+=e*ee,D+=e*re,S+=e*k,B+=e*J,P+=e*q,E+=e*xe,h+=e*ne,l+=e*oe,A+=e*ae,g+=e*se,m+=e*de,w+=e*Ke,I+=e*Ee,F+=e*Ue,e=o[14],O+=e*c,C+=e*X,D+=e*ee,S+=e*re,B+=e*k,P+=e*J,E+=e*q,h+=e*xe,l+=e*ne,A+=e*oe,g+=e*ae,m+=e*se,w+=e*de,I+=e*Ke,F+=e*Ee,V+=e*Ue,e=o[15],C+=e*c,D+=e*X,S+=e*ee,B+=e*re,P+=e*k,E+=e*J,h+=e*q,l+=e*xe,A+=e*ne,g+=e*oe,m+=e*ae,w+=e*se,I+=e*de,F+=e*Ke,V+=e*Ee,G+=e*Ue,u+=38*D,p+=38*S,b+=38*B,K+=38*P,T+=38*E,U+=38*h,Q+=38*l,_+=38*A,L+=38*g,N+=38*m,H+=38*w,j+=38*I,R+=38*F,z+=38*V,O+=38*G,a=1,e=u+a+65535,a=Math.floor(e/65536),u=e-a*65536,e=p+a+65535,a=Math.floor(e/65536),p=e-a*65536,e=b+a+65535,a=Math.floor(e/65536),b=e-a*65536,e=K+a+65535,a=Math.floor(e/65536),K=e-a*65536,e=T+a+65535,a=Math.floor(e/65536),T=e-a*65536,e=U+a+65535,a=Math.floor(e/65536),U=e-a*65536,e=Q+a+65535,a=Math.floor(e/65536),Q=e-a*65536,e=_+a+65535,a=Math.floor(e/65536),_=e-a*65536,e=L+a+65535,a=Math.floor(e/65536),L=e-a*65536,e=N+a+65535,a=Math.floor(e/65536),N=e-a*65536,e=H+a+65535,a=Math.floor(e/65536),H=e-a*65536,e=j+a+65535,a=Math.floor(e/65536),j=e-a*65536,e=R+a+65535,a=Math.floor(e/65536),R=e-a*65536,e=z+a+65535,a=Math.floor(e/65536),z=e-a*65536,e=O+a+65535,a=Math.floor(e/65536),O=e-a*65536,e=C+a+65535,a=Math.floor(e/65536),C=e-a*65536,u+=a-1+37*(a-1),a=1,e=u+a+65535,a=Math.floor(e/65536),u=e-a*65536,e=p+a+65535,a=Math.floor(e/65536),p=e-a*65536,e=b+a+65535,a=Math.floor(e/65536),b=e-a*65536,e=K+a+65535,a=Math.floor(e/65536),K=e-a*65536,e=T+a+65535,a=Math.floor(e/65536),T=e-a*65536,e=U+a+65535,a=Math.floor(e/65536),U=e-a*65536,e=Q+a+65535,a=Math.floor(e/65536),Q=e-a*65536,e=_+a+65535,a=Math.floor(e/65536),_=e-a*65536,e=L+a+65535,a=Math.floor(e/65536),L=e-a*65536,e=N+a+65535,a=Math.floor(e/65536),N=e-a*65536,e=H+a+65535,a=Math.floor(e/65536),H=e-a*65536,e=j+a+65535,a=Math.floor(e/65536),j=e-a*65536,e=R+a+65535,a=Math.floor(e/65536),R=e-a*65536,e=z+a+65535,a=Math.floor(e/65536),z=e-a*65536,e=O+a+65535,a=Math.floor(e/65536),O=e-a*65536,e=C+a+65535,a=Math.floor(e/65536),C=e-a*65536,u+=a-1+37*(a-1),t[0]=u,t[1]=p,t[2]=b,t[3]=K,t[4]=T,t[5]=U,t[6]=Q,t[7]=_,t[8]=L,t[9]=N,t[10]=H,t[11]=j,t[12]=R,t[13]=z,t[14]=O,t[15]=C}y(Z,"M");function Me(t,o){Z(t,o,o)}y(Me,"S");function gn(t,o){var i=r(),e;for(e=0;e<16;e++)i[e]=o[e];for(e=253;e>=0;e--)Me(i,i),e!==2&&e!==4&&Z(i,i,o);for(e=0;e<16;e++)t[e]=i[e]}y(gn,"inv25519");function bn(t,o){var i=r(),e;for(e=0;e<16;e++)i[e]=o[e];for(e=250;e>=0;e--)Me(i,i),e!==1&&Z(i,i,o);for(e=0;e<16;e++)t[e]=i[e]}y(bn,"pow2523");function Or(t,o,i){var e=new Uint8Array(32),a=new Float64Array(80),u,p,b=r(),K=r(),T=r(),U=r(),Q=r(),_=r();for(p=0;p<31;p++)e[p]=o[p];for(e[31]=o[31]&127|64,e[0]&=248,yt(a,i),p=0;p<16;p++)K[p]=a[p],U[p]=b[p]=T[p]=0;for(b[0]=U[0]=1,p=254;p>=0;--p)u=e[p>>>3]>>>(p&7)&1,ir(b,K,u),ir(T,U,u),Oe(Q,b,T),ze(b,b,T),Oe(T,K,U),ze(K,K,U),Me(U,Q),Me(_,b),Z(b,T,b),Z(T,K,Q),Oe(Q,b,T),ze(b,b,T),Me(K,b),ze(T,U,_),Z(b,T,M),Oe(b,b,U),Z(T,T,b),Z(b,U,_),Z(U,K,a),Me(K,Q),ir(b,K,u),ir(T,U,u);for(p=0;p<16;p++)a[p+16]=b[p],a[p+32]=T[p],a[p+48]=K[p],a[p+64]=U[p];var L=a.subarray(32),N=a.subarray(16);return gn(L,L),Z(N,N,L),or(t,N),0}y(Or,"crypto_scalarmult");function zr(t,o){return Or(t,o,x)}y(zr,"crypto_scalarmult_base");function mn(t,o){return f(o,32),zr(t,o)}y(mn,"crypto_box_keypair");function Yr(t,o,i){var e=new Uint8Array(32);return Or(e,i,o),Ae(t,s,e,ge)}y(Yr,"crypto_box_beforenm");var An=at,xf=st;function uf(t,o,i,e,a,u){var p=new Uint8Array(32);return Yr(p,a,u),An(t,o,i,e,p)}y(uf,"crypto_box");function pf(t,o,i,e,a,u){var p=new Uint8Array(32);return Yr(p,a,u),xf(t,o,i,e,p)}y(pf,"crypto_box_open");var wn=[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 Kn(t,o,i,e){for(var a=new Int32Array(16),u=new Int32Array(16),p,b,K,T,U,Q,_,L,N,H,j,R,z,O,C,D,S,B,P,E,h,l,A,g,m,w,I=t[0],F=t[1],V=t[2],G=t[3],c=t[4],X=t[5],ee=t[6],re=t[7],k=o[0],J=o[1],q=o[2],xe=o[3],ne=o[4],oe=o[5],ae=o[6],se=o[7],de=0;e>=128;){for(P=0;P<16;P++)E=8*P+de,a[P]=i[E+0]<<24|i[E+1]<<16|i[E+2]<<8|i[E+3],u[P]=i[E+4]<<24|i[E+5]<<16|i[E+6]<<8|i[E+7];for(P=0;P<80;P++)if(p=I,b=F,K=V,T=G,U=c,Q=X,_=ee,L=re,N=k,H=J,j=q,R=xe,z=ne,O=oe,C=ae,D=se,h=re,l=se,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=(c>>>14|ne<<18)^(c>>>18|ne<<14)^(ne>>>9|c<<23),l=(ne>>>14|c<<18)^(ne>>>18|c<<14)^(c>>>9|ne<<23),A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,h=c&X^~c&ee,l=ne&oe^~ne&ae,A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,h=wn[P*2],l=wn[P*2+1],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,h=a[P%16],l=u[P%16],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,S=m&65535|w<<16,B=A&65535|g<<16,h=S,l=B,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=(I>>>28|k<<4)^(k>>>2|I<<30)^(k>>>7|I<<25),l=(k>>>28|I<<4)^(I>>>2|k<<30)^(I>>>7|k<<25),A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,h=I&F^I&V^F&V,l=k&J^k&q^J&q,A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,L=m&65535|w<<16,D=A&65535|g<<16,h=T,l=R,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=S,l=B,A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,T=m&65535|w<<16,R=A&65535|g<<16,F=p,V=b,G=K,c=T,X=U,ee=Q,re=_,I=L,J=N,q=H,xe=j,ne=R,oe=z,ae=O,se=C,k=D,P%16===15)for(E=0;E<16;E++)h=a[E],l=u[E],A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=a[(E+9)%16],l=u[(E+9)%16],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,S=a[(E+1)%16],B=u[(E+1)%16],h=(S>>>1|B<<31)^(S>>>8|B<<24)^S>>>7,l=(B>>>1|S<<31)^(B>>>8|S<<24)^(B>>>7|S<<25),A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,S=a[(E+14)%16],B=u[(E+14)%16],h=(S>>>19|B<<13)^(B>>>29|S<<3)^S>>>6,l=(B>>>19|S<<13)^(S>>>29|B<<3)^(B>>>6|S<<26),A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,a[E]=m&65535|w<<16,u[E]=A&65535|g<<16;h=I,l=k,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[0],l=o[0],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[0]=I=m&65535|w<<16,o[0]=k=A&65535|g<<16,h=F,l=J,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[1],l=o[1],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[1]=F=m&65535|w<<16,o[1]=J=A&65535|g<<16,h=V,l=q,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[2],l=o[2],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[2]=V=m&65535|w<<16,o[2]=q=A&65535|g<<16,h=G,l=xe,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[3],l=o[3],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[3]=G=m&65535|w<<16,o[3]=xe=A&65535|g<<16,h=c,l=ne,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[4],l=o[4],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[4]=c=m&65535|w<<16,o[4]=ne=A&65535|g<<16,h=X,l=oe,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[5],l=o[5],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[5]=X=m&65535|w<<16,o[5]=oe=A&65535|g<<16,h=ee,l=ae,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[6],l=o[6],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[6]=ee=m&65535|w<<16,o[6]=ae=A&65535|g<<16,h=re,l=se,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[7],l=o[7],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[7]=re=m&65535|w<<16,o[7]=se=A&65535|g<<16,de+=128,e-=128}return e}y(Kn,"crypto_hashblocks_hl");function Ze(t,o,i){var e=new Int32Array(8),a=new Int32Array(8),u=new Uint8Array(256),p,b=i;for(e[0]=1779033703,e[1]=3144134277,e[2]=1013904242,e[3]=2773480762,e[4]=1359893119,e[5]=2600822924,e[6]=528734635,e[7]=1541459225,a[0]=4089235720,a[1]=2227873595,a[2]=4271175723,a[3]=1595750129,a[4]=2917565137,a[5]=725511199,a[6]=4215389547,a[7]=327033209,Kn(e,a,o,i),i%=128,p=0;p<i;p++)u[p]=o[b-i+p];for(u[i]=128,i=256-128*(i<112?1:0),u[i-9]=0,Fe(u,i-8,b/536870912|0,b<<3),Kn(e,a,u,i),p=0;p<8;p++)Fe(t,8*p,e[p],a[p]);return 0}y(Ze,"crypto_hash");function jr(t,o){var i=r(),e=r(),a=r(),u=r(),p=r(),b=r(),K=r(),T=r(),U=r();ze(i,t[1],t[0]),ze(U,o[1],o[0]),Z(i,i,U),Oe(e,t[0],t[1]),Oe(U,o[0],o[1]),Z(e,e,U),Z(a,t[3],o[3]),Z(a,a,le),Z(u,t[2],o[2]),Oe(u,u,u),ze(p,e,i),ze(b,u,a),Oe(K,u,a),Oe(T,e,i),Z(t[0],p,b),Z(t[1],T,K),Z(t[2],K,b),Z(t[3],p,T)}y(jr,"add");function En(t,o,i){var e;for(e=0;e<4;e++)ir(t[e],o[e],i)}y(En,"cswap");function xt(t,o){var i=r(),e=r(),a=r();gn(a,o[2]),Z(i,o[0],a),Z(e,o[1],a),or(t,e),t[31]^=dn(i)<<7}y(xt,"pack");function ut(t,o,i){var e,a;for(Ge(t[0],d),Ge(t[1],v),Ge(t[2],v),Ge(t[3],d),a=255;a>=0;--a)e=i[a/8|0]>>(a&7)&1,En(t,o,e),jr(o,t),jr(t,t),En(t,o,e)}y(ut,"scalarmult");function Hr(t,o){var i=[r(),r(),r(),r()];Ge(i[0],ie),Ge(i[1],pe),Ge(i[2],v),Z(i[3],ie,pe),ut(t,i,o)}y(Hr,"scalarbase");function pt(t,o,i){var e=new Uint8Array(64),a=[r(),r(),r(),r()],u;for(i||f(o,32),Ze(e,o,32),e[0]&=248,e[31]&=127,e[31]|=64,Hr(a,e),xt(t,a),u=0;u<32;u++)o[u+32]=t[u];return 0}y(pt,"crypto_sign_keypair");var Fr=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 ht(t,o){var i,e,a,u;for(e=63;e>=32;--e){for(i=0,a=e-32,u=e-12;a<u;++a)o[a]+=i-16*o[e]*Fr[a-(e-32)],i=Math.floor((o[a]+128)/256),o[a]-=i*256;o[a]+=i,o[e]=0}for(i=0,a=0;a<32;a++)o[a]+=i-(o[31]>>4)*Fr[a],i=o[a]>>8,o[a]&=255;for(a=0;a<32;a++)o[a]-=i*Fr[a];for(e=0;e<32;e++)o[e+1]+=o[e]>>8,t[e]=o[e]&255}y(ht,"modL");function lt(t){var o=new Float64Array(64),i;for(i=0;i<64;i++)o[i]=t[i];for(i=0;i<64;i++)t[i]=0;ht(t,o)}y(lt,"reduce");function Un(t,o,i,e){var a=new Uint8Array(64),u=new Uint8Array(64),p=new Uint8Array(64),b,K,T=new Float64Array(64),U=[r(),r(),r(),r()];Ze(a,e,32),a[0]&=248,a[31]&=127,a[31]|=64;var Q=i+64;for(b=0;b<i;b++)t[64+b]=o[b];for(b=0;b<32;b++)t[32+b]=a[32+b];for(Ze(p,t.subarray(32),i+32),lt(p),Hr(U,p),xt(t,U),b=32;b<64;b++)t[b]=e[b];for(Ze(u,t,i+64),lt(u),b=0;b<64;b++)T[b]=0;for(b=0;b<32;b++)T[b]=p[b];for(b=0;b<32;b++)for(K=0;K<32;K++)T[b+K]+=u[b]*a[K];return ht(t.subarray(32),T),Q}y(Un,"crypto_sign");function hf(t,o){var i=r(),e=r(),a=r(),u=r(),p=r(),b=r(),K=r();return Ge(t[2],v),yt(t[1],o),Me(a,t[1]),Z(u,a,$),ze(a,a,t[2]),Oe(u,t[2],u),Me(p,u),Me(b,p),Z(K,b,p),Z(i,K,a),Z(i,i,u),bn(i,i),Z(i,i,a),Z(i,i,u),Z(i,i,u),Z(t[0],i,u),Me(e,t[0]),Z(e,e,u),ln(e,a)&&Z(t[0],t[0],Pe),Me(e,t[0]),Z(e,e,u),ln(e,a)?-1:(dn(t[0])===o[31]>>7&&ze(t[0],d,t[0]),Z(t[3],t[0],t[1]),0)}y(hf,"unpackneg");function dt(t,o,i,e){var a,u=new Uint8Array(32),p=new Uint8Array(64),b=[r(),r(),r(),r()],K=[r(),r(),r(),r()];if(i<64||hf(K,e))return-1;for(a=0;a<i;a++)t[a]=o[a];for(a=0;a<32;a++)t[a+32]=e[a];if(Ze(p,t,i),lt(p),ut(b,K,p),Hr(K,o.subarray(32)),jr(b,K),xt(u,b),i-=64,me(o,0,u,0)){for(a=0;a<i;a++)t[a]=0;return-1}for(a=0;a<i;a++)t[a]=o[a+64];return i}y(dt,"crypto_sign_open");var gt=32,Gr=24,Kr=32,ar=16,Er=32,Vr=32,Ur=32,vr=32,bt=32,vn=Gr,lf=Kr,df=ar,Ve=64,Je=32,sr=64,mt=32,At=64;n.lowlevel={crypto_core_hsalsa20:Ae,crypto_stream_xor:Xe,crypto_stream:Ie,crypto_stream_salsa20_xor:Re,crypto_stream_salsa20:Be,crypto_onetimeauth:ot,crypto_onetimeauth_verify:hn,crypto_verify_16:fe,crypto_verify_32:me,crypto_secretbox:at,crypto_secretbox_open:st,crypto_scalarmult:Or,crypto_scalarmult_base:zr,crypto_box_beforenm:Yr,crypto_box_afternm:An,crypto_box:uf,crypto_box_open:pf,crypto_box_keypair:mn,crypto_hash:Ze,crypto_sign:Un,crypto_sign_keypair:pt,crypto_sign_open:dt,crypto_secretbox_KEYBYTES:gt,crypto_secretbox_NONCEBYTES:Gr,crypto_secretbox_ZEROBYTES:Kr,crypto_secretbox_BOXZEROBYTES:ar,crypto_scalarmult_BYTES:Er,crypto_scalarmult_SCALARBYTES:Vr,crypto_box_PUBLICKEYBYTES:Ur,crypto_box_SECRETKEYBYTES:vr,crypto_box_BEFORENMBYTES:bt,crypto_box_NONCEBYTES:vn,crypto_box_ZEROBYTES:lf,crypto_box_BOXZEROBYTES:df,crypto_sign_BYTES:Ve,crypto_sign_PUBLICKEYBYTES:Je,crypto_sign_SECRETKEYBYTES:sr,crypto_sign_SEEDBYTES:mt,crypto_hash_BYTES:At,gf:r,D:$,L:Fr,pack25519:or,unpack25519:yt,M:Z,A:Oe,S:Me,Z:ze,pow2523:bn,add:jr,set25519:Ge,modL:ht,scalarmult:ut,scalarbase:Hr};function Sn(t,o){if(t.length!==gt)throw new Error("bad key size");if(o.length!==Gr)throw new Error("bad nonce size")}y(Sn,"checkLengths");function gf(t,o){if(t.length!==Ur)throw new Error("bad public key size");if(o.length!==vr)throw new Error("bad secret key size")}y(gf,"checkBoxLengths");function Te(){for(var t=0;t<arguments.length;t++)if(!(arguments[t]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}y(Te,"checkArrayTypes");function _n(t){for(var o=0;o<t.length;o++)t[o]=0}y(_n,"cleanup"),n.randomBytes=function(t){var o=new Uint8Array(t);return f(o,t),o},n.secretbox=function(t,o,i){Te(t,o,i),Sn(i,o);for(var e=new Uint8Array(Kr+t.length),a=new Uint8Array(e.length),u=0;u<t.length;u++)e[u+Kr]=t[u];return at(a,e,e.length,o,i),a.subarray(ar)},n.secretbox.open=function(t,o,i){Te(t,o,i),Sn(i,o);for(var e=new Uint8Array(ar+t.length),a=new Uint8Array(e.length),u=0;u<t.length;u++)e[u+ar]=t[u];return e.length<32||st(a,e,e.length,o,i)!==0?null:a.subarray(Kr)},n.secretbox.keyLength=gt,n.secretbox.nonceLength=Gr,n.secretbox.overheadLength=ar,n.scalarMult=function(t,o){if(Te(t,o),t.length!==Vr)throw new Error("bad n size");if(o.length!==Er)throw new Error("bad p size");var i=new Uint8Array(Er);return Or(i,t,o),i},n.scalarMult.base=function(t){if(Te(t),t.length!==Vr)throw new Error("bad n size");var o=new Uint8Array(Er);return zr(o,t),o},n.scalarMult.scalarLength=Vr,n.scalarMult.groupElementLength=Er,n.box=function(t,o,i,e){var a=n.box.before(i,e);return n.secretbox(t,o,a)},n.box.before=function(t,o){Te(t,o),gf(t,o);var i=new Uint8Array(bt);return Yr(i,t,o),i},n.box.after=n.secretbox,n.box.open=function(t,o,i,e){var a=n.box.before(i,e);return n.secretbox.open(t,o,a)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var t=new Uint8Array(Ur),o=new Uint8Array(vr);return mn(t,o),{publicKey:t,secretKey:o}},n.box.keyPair.fromSecretKey=function(t){if(Te(t),t.length!==vr)throw new Error("bad secret key size");var o=new Uint8Array(Ur);return zr(o,t),{publicKey:o,secretKey:new Uint8Array(t)}},n.box.publicKeyLength=Ur,n.box.secretKeyLength=vr,n.box.sharedKeyLength=bt,n.box.nonceLength=vn,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(t,o){if(Te(t,o),o.length!==sr)throw new Error("bad secret key size");var i=new Uint8Array(Ve+t.length);return Un(i,t,t.length,o),i},n.sign.open=function(t,o){if(Te(t,o),o.length!==Je)throw new Error("bad public key size");var i=new Uint8Array(t.length),e=dt(i,t,t.length,o);if(e<0)return null;for(var a=new Uint8Array(e),u=0;u<a.length;u++)a[u]=i[u];return a},n.sign.detached=function(t,o){for(var i=n.sign(t,o),e=new Uint8Array(Ve),a=0;a<e.length;a++)e[a]=i[a];return e},n.sign.detached.verify=function(t,o,i){if(Te(t,o,i),o.length!==Ve)throw new Error("bad signature size");if(i.length!==Je)throw new Error("bad public key size");var e=new Uint8Array(Ve+t.length),a=new Uint8Array(Ve+t.length),u;for(u=0;u<Ve;u++)e[u]=o[u];for(u=0;u<t.length;u++)e[u+Ve]=t[u];return dt(a,e,e.length,i)>=0},n.sign.keyPair=function(){var t=new Uint8Array(Je),o=new Uint8Array(sr);return pt(t,o),{publicKey:t,secretKey:o}},n.sign.keyPair.fromSecretKey=function(t){if(Te(t),t.length!==sr)throw new Error("bad secret key size");for(var o=new Uint8Array(Je),i=0;i<o.length;i++)o[i]=t[32+i];return{publicKey:o,secretKey:new Uint8Array(t)}},n.sign.keyPair.fromSeed=function(t){if(Te(t),t.length!==mt)throw new Error("bad seed size");for(var o=new Uint8Array(Je),i=new Uint8Array(sr),e=0;e<32;e++)i[e]=t[e];return pt(o,i,!0),{publicKey:o,secretKey:i}},n.sign.publicKeyLength=Je,n.sign.secretKeyLength=sr,n.sign.seedLength=mt,n.sign.signatureLength=Ve,n.hash=function(t){Te(t);var o=new Uint8Array(At);return Ze(o,t,t.length),o},n.hash.hashLength=At,n.verify=function(t,o){return Te(t,o),t.length===0||o.length===0||t.length!==o.length?!1:W(t,0,o,0,t.length)===0},n.setPRNG=function(t){f=t},(function(){var t=typeof self<"u"?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){var o=65536;n.setPRNG(function(i,e){var a,u=new Uint8Array(e);for(a=0;a<e;a+=o)t.getRandomValues(u.subarray(a,a+Math.min(e-a,o)));for(a=0;a<e;a++)i[a]=u[a];_n(u)})}else typeof Cn<"u"&&(t=of(),t&&t.randomBytes&&n.setPRNG(function(i,e){var a,u=t.randomBytes(e);for(a=0;a<e;a++)i[a]=u[a];_n(u)}))})()})(typeof tt<"u"&&tt.exports?tt.exports:self.nacl=self.nacl||{})});var Sf=globalThis||window||self,te=Sf.crypto;function _r(n=0){return new Uint8Array(n)}y(_r,"allocUnsafe");function wt(n,r){r==null&&(r=n.reduce((x,d)=>x+d.length,0));let f=_r(r),s=0;for(let x of n)f.set(x,s),s+=x.length;return f}y(wt,"concat");var Pt={};Le(Pt,{base10:()=>If});var Ao=new Uint8Array(0);function Pn(n,r){if(n===r)return!0;if(n.byteLength!==r.byteLength)return!1;for(let f=0;f<n.byteLength;f++)if(n[f]!==r[f])return!1;return!0}y(Pn,"equals");function ke(n){if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")}y(ke,"coerce");function Tn(n){return new TextEncoder().encode(n)}y(Tn,"fromString");function Dn(n){return new TextDecoder().decode(n)}y(Dn,"toString");function Cf(n,r){if(n.length>=255)throw new TypeError("Alphabet too long");for(var f=new Uint8Array(256),s=0;s<f.length;s++)f[s]=255;for(var x=0;x<n.length;x++){var d=n.charAt(x),v=d.charCodeAt(0);if(f[v]!==255)throw new TypeError(d+" is ambiguous");f[v]=x}var M=n.length,$=n.charAt(0),le=Math.log(M)/Math.log(256),ie=Math.log(256)/Math.log(M);function pe(W){if(W instanceof Uint8Array||(ArrayBuffer.isView(W)?W=new Uint8Array(W.buffer,W.byteOffset,W.byteLength):Array.isArray(W)&&(W=Uint8Array.from(W))),!(W instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(W.length===0)return"";for(var fe=0,me=0,we=0,Ce=W.length;we!==Ce&&W[we]===0;)we++,fe++;for(var ye=(Ce-we)*ie+1>>>0,Ae=new Uint8Array(ye);we!==Ce;){for(var ge=W[we],Re=0,Be=ye-1;(ge!==0||Re<me)&&Be!==-1;Be--,Re++)ge+=256*Ae[Be]>>>0,Ae[Be]=ge%M>>>0,ge=ge/M>>>0;if(ge!==0)throw new Error("Non-zero carry");me=Re,we++}for(var Ie=ye-me;Ie!==ye&&Ae[Ie]===0;)Ie++;for(var Xe=$.repeat(fe);Ie<ye;++Ie)Xe+=n.charAt(Ae[Ie]);return Xe}y(pe,"encode");function Pe(W){if(typeof W!="string")throw new TypeError("Expected String");if(W.length===0)return new Uint8Array;var fe=0;if(W[fe]!==" "){for(var me=0,we=0;W[fe]===$;)me++,fe++;for(var Ce=(W.length-fe)*le+1>>>0,ye=new Uint8Array(Ce);W[fe];){var Ae=f[W.charCodeAt(fe)];if(Ae===255)return;for(var ge=0,Re=Ce-1;(Ae!==0||ge<we)&&Re!==-1;Re--,ge++)Ae+=M*ye[Re]>>>0,ye[Re]=Ae%256>>>0,Ae=Ae/256>>>0;if(Ae!==0)throw new Error("Non-zero carry");we=ge,fe++}if(W[fe]!==" "){for(var Be=Ce-we;Be!==Ce&&ye[Be]===0;)Be++;for(var Ie=new Uint8Array(me+(Ce-Be)),Xe=me;Be!==Ce;)Ie[Xe++]=ye[Be++];return Ie}}}y(Pe,"decodeUnsafe");function Fe(W){var fe=Pe(W);if(fe)return fe;throw new Error(`Non-${r} character`)}return y(Fe,"decode"),{encode:pe,decodeUnsafe:Pe,decode:Fe}}y(Cf,"base");var Bf=Cf,Pf=Bf,Mn=Pf;var St=class St{constructor(r,f,s){Y(this,"name");Y(this,"prefix");Y(this,"baseEncode");this.name=r,this.prefix=f,this.baseEncode=s}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}};y(St,"Encoder");var Kt=St,_t=class _t{constructor(r,f,s){Y(this,"name");Y(this,"prefix");Y(this,"baseDecode");Y(this,"prefixCodePoint");this.name=r,this.prefix=f;let x=f.codePointAt(0);if(x===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=x,this.baseDecode=s}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return Ln(this,r)}};y(_t,"Decoder");var Et=_t,Ct=class Ct{constructor(r){Y(this,"decoders");this.decoders=r}or(r){return Ln(this,r)}decode(r){let f=r[0],s=this.decoders[f];if(s!=null)return s.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};y(Ct,"ComposedDecoder");var Ut=Ct;function Ln(n,r){return new Ut({...n.decoders??{[n.prefix]:n},...r.decoders??{[r.prefix]:r}})}y(Ln,"or");var Bt=class Bt{constructor(r,f,s,x){Y(this,"name");Y(this,"prefix");Y(this,"baseEncode");Y(this,"baseDecode");Y(this,"encoder");Y(this,"decoder");this.name=r,this.prefix=f,this.baseEncode=s,this.baseDecode=x,this.encoder=new Kt(r,f,s),this.decoder=new Et(r,f,x)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}};y(Bt,"Codec");var vt=Bt;function cr({name:n,prefix:r,encode:f,decode:s}){return new vt(n,r,f,s)}y(cr,"from");function We({name:n,prefix:r,alphabet:f}){let{encode:s,decode:x}=Mn(f,n);return cr({prefix:r,name:n,encode:s,decode:y(d=>ke(x(d)),"decode")})}y(We,"baseX");function Tf(n,r,f,s){let x={};for(let ie=0;ie<r.length;++ie)x[r[ie]]=ie;let d=n.length;for(;n[d-1]==="=";)--d;let v=new Uint8Array(d*f/8|0),M=0,$=0,le=0;for(let ie=0;ie<d;++ie){let pe=x[n[ie]];if(pe===void 0)throw new SyntaxError(`Non-${s} character`);$=$<<f|pe,M+=f,M>=8&&(M-=8,v[le++]=255&$>>M)}if(M>=f||(255&$<<8-M)!==0)throw new SyntaxError("Unexpected end of data");return v}y(Tf,"decode");function Df(n,r,f){let s=r[r.length-1]==="=",x=(1<<f)-1,d="",v=0,M=0;for(let $=0;$<n.length;++$)for(M=M<<8|n[$],v+=8;v>f;)v-=f,d+=r[x&M>>v];if(v!==0&&(d+=r[x&M<<f-v]),s)for(;(d.length*f&7)!==0;)d+="=";return d}y(Df,"encode");function ce({name:n,prefix:r,bitsPerChar:f,alphabet:s}){return cr({prefix:r,name:n,encode(x){return Df(x,s,f)},decode(x){return Tf(x,s,f,n)}})}y(ce,"rfc4648");var If=We({prefix:"9",name:"base10",alphabet:"0123456789"});var Tt={};Le(Tt,{base16:()=>Mf,base16upper:()=>Lf});var Mf=ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Lf=ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Dt={};Le(Dt,{base2:()=>Nf});var Nf=ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var It={};Le(It,{base256emoji:()=>jf});var Nn=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Rf=Nn.reduce((n,r,f)=>(n[f]=r,n),[]),Of=Nn.reduce((n,r,f)=>{let s=r.codePointAt(0);if(s==null)throw new Error(`Invalid character: ${r}`);return n[s]=f,n},[]);function zf(n){return n.reduce((r,f)=>(r+=Rf[f],r),"")}y(zf,"encode");function Yf(n){let r=[];for(let f of n){let s=f.codePointAt(0);if(s==null)throw new Error(`Invalid character: ${f}`);let x=Of[s];if(x==null)throw new Error(`Non-base256emoji character: ${f}`);r.push(x)}return new Uint8Array(r)}y(Yf,"decode");var jf=cr({prefix:"\u{1F680}",name:"base256emoji",encode:zf,decode:Yf});var Mt={};Le(Mt,{base32:()=>yr,base32hex:()=>Vf,base32hexpad:()=>Xf,base32hexpadupper:()=>Wf,base32hexupper:()=>kf,base32pad:()=>Ff,base32padupper:()=>Gf,base32upper:()=>Hf,base32z:()=>$f});var yr=ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Hf=ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ff=ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gf=ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vf=ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kf=ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xf=ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Wf=ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),$f=ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Lt={};Le(Lt,{base36:()=>Cr,base36upper:()=>Zf});var Cr=We({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zf=We({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Nt={};Le(Nt,{base58btc:()=>He,base58flickr:()=>Jf});var He=We({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Jf=We({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Rt={};Le(Rt,{base64:()=>qf,base64pad:()=>Qf,base64url:()=>ei,base64urlpad:()=>ri});var qf=ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qf=ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ei=ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ri=ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ot={};Le(Ot,{base8:()=>ti});var ti=ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zt={};Le(zt,{identity:()=>ni});var ni=cr({prefix:"\0",name:"identity",encode:y(n=>Dn(n),"encode"),decode:y(n=>Tn(n),"decode")});var jo=new TextEncoder,Ho=new TextDecoder;var Ht={};Le(Ht,{identity:()=>Si});var oi=zn,Rn=128,ai=127,si=~ai,ci=Math.pow(2,31);function zn(n,r,f){r=r||[],f=f||0;for(var s=f;n>=ci;)r[f++]=n&255|Rn,n/=128;for(;n&si;)r[f++]=n&255|Rn,n>>>=7;return r[f]=n|0,zn.bytes=f-s+1,r}y(zn,"encode");var yi=Yt,xi=128,On=127;function Yt(n,s){var f=0,s=s||0,x=0,d=s,v,M=n.length;do{if(d>=M)throw Yt.bytes=0,new RangeError("Could not decode varint");v=n[d++],f+=x<28?(v&On)<<x:(v&On)*Math.pow(2,x),x+=7}while(v>=xi);return Yt.bytes=d-s,f}y(Yt,"read");var ui=Math.pow(2,7),pi=Math.pow(2,14),hi=Math.pow(2,21),li=Math.pow(2,28),di=Math.pow(2,35),gi=Math.pow(2,42),bi=Math.pow(2,49),mi=Math.pow(2,56),Ai=Math.pow(2,63),wi=y(function(n){return n<ui?1:n<pi?2:n<hi?3:n<li?4:n<di?5:n<gi?6:n<bi?7:n<mi?8:n<Ai?9:10},"length"),Ki={encode:oi,decode:yi,encodingLength:wi},Ei=Ki,Br=Ei;function Pr(n,r=0){return[Br.decode(n,r),Br.decode.bytes]}y(Pr,"decode");function xr(n,r,f=0){return Br.encode(n,r,f),r}y(xr,"encodeTo");function ur(n){return Br.encodingLength(n)}y(ur,"encodingLength");function qe(n,r){let f=r.byteLength,s=ur(n),x=s+ur(f),d=new Uint8Array(x+f);return xr(n,d,0),xr(f,d,s),d.set(r,x),new pr(n,f,r,d)}y(qe,"create");function Yn(n){let r=ke(n),[f,s]=Pr(r),[x,d]=Pr(r.subarray(s)),v=r.subarray(s+d);if(v.byteLength!==x)throw new Error("Incorrect length");return new pr(f,x,v,r)}y(Yn,"decode");function jn(n,r){if(n===r)return!0;{let f=r;return n.code===f.code&&n.size===f.size&&f.bytes instanceof Uint8Array&&Pn(n.bytes,f.bytes)}}y(jn,"equals");var jt=class jt{constructor(r,f,s,x){Y(this,"code");Y(this,"size");Y(this,"digest");Y(this,"bytes");this.code=r,this.size=f,this.digest=s,this.bytes=x}};y(jt,"Digest");var pr=jt;var Hn=0,Ui="identity",Fn=ke;function vi(n){return qe(Hn,Fn(n))}y(vi,"digest");var Si={code:Hn,name:Ui,encode:Fn,digest:vi};var kt={};Le(kt,{sha256:()=>_i,sha512:()=>Ci});function Gt({name:n,code:r,encode:f}){return new Ft(n,r,f)}y(Gt,"from");var Vt=class Vt{constructor(r,f,s){Y(this,"name");Y(this,"code");Y(this,"encode");this.name=r,this.code=f,this.encode=s}digest(r){if(r instanceof Uint8Array){let f=this.encode(r);return f instanceof Uint8Array?qe(this.code,f):f.then(s=>qe(this.code,s))}else throw Error("Unknown type, must be binary type")}};y(Vt,"Hasher");var Ft=Vt;function Vn(n){return async r=>new Uint8Array(await crypto.subtle.digest(n,r))}y(Vn,"sha");var _i=Gt({name:"sha2-256",code:18,encode:Vn("SHA-256")}),Ci=Gt({name:"sha2-512",code:19,encode:Vn("SHA-512")});function kn(n,r){let{bytes:f,version:s}=n;switch(s){case 0:return Pi(f,Xt(n),r??He.encoder);default:return Ti(f,Xt(n),r??yr.encoder)}}y(kn,"format");var Xn=new WeakMap;function Xt(n){let r=Xn.get(n);if(r==null){let f=new Map;return Xn.set(n,f),f}return r}y(Xt,"baseCache");var $n,be=class be{constructor(r,f,s,x){Y(this,"code");Y(this,"version");Y(this,"multihash");Y(this,"bytes");Y(this,"/");Y(this,$n,"CID");this.code=f,this.version=r,this.multihash=s,this.bytes=x,this["/"]=x}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:r,multihash:f}=this;if(r!==Dr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(f.code!==Di)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return be.createV0(f)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:r,digest:f}=this.multihash,s=qe(r,f);return be.createV1(this.code,s)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(r){return be.equals(this,r)}static equals(r,f){let s=f;return s!=null&&r.code===s.code&&r.version===s.version&&jn(r.multihash,s.multihash)}toString(r){return kn(this,r)}toJSON(){return{"/":kn(this)}}link(){return this}[($n=Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"))](){return`CID(${this.toString()})`}static asCID(r){if(r==null)return null;let f=r;if(f instanceof be)return f;if(f["/"]!=null&&f["/"]===f.bytes||f.asCID===f){let{version:s,code:x,multihash:d,bytes:v}=f;return new be(s,x,d,v??Wn(s,x,d.bytes))}else if(f[Ii]===!0){let{version:s,multihash:x,code:d}=f,v=Yn(x);return be.create(s,d,v)}else return null}static create(r,f,s){if(typeof f!="number")throw new Error("String codecs are no longer supported");if(!(s.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(r){case 0:{if(f!==Dr)throw new Error(`Version 0 CID must use dag-pb (code: ${Dr}) block encoding`);return new be(r,f,s,s.bytes)}case 1:{let x=Wn(r,f,s.bytes);return new be(r,f,s,x)}default:throw new Error("Invalid version")}}static createV0(r){return be.create(0,Dr,r)}static createV1(r,f){return be.create(1,r,f)}static decode(r){let[f,s]=be.decodeFirst(r);if(s.length!==0)throw new Error("Incorrect length");return f}static decodeFirst(r){let f=be.inspectBytes(r),s=f.size-f.multihashSize,x=ke(r.subarray(s,s+f.multihashSize));if(x.byteLength!==f.multihashSize)throw new Error("Incorrect length");let d=x.subarray(f.multihashSize-f.digestSize),v=new pr(f.multihashCode,f.digestSize,d,x);return[f.version===0?be.createV0(v):be.createV1(f.codec,v),r.subarray(f.size)]}static inspectBytes(r){let f=0,s=y(()=>{let[pe,Pe]=Pr(r.subarray(f));return f+=Pe,pe},"next"),x=s(),d=Dr;if(x===18?(x=0,f=0):d=s(),x!==0&&x!==1)throw new RangeError(`Invalid CID version ${x}`);let v=f,M=s(),$=s(),le=f+$,ie=le-v;return{version:x,codec:d,multihashCode:M,digestSize:$,multihashSize:ie,size:le}}static parse(r,f){let[s,x]=Bi(r,f),d=be.decode(x);if(d.version===0&&r[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Xt(d).set(s,r),d}};y(be,"CID");var Xr=be;function Bi(n,r){switch(n[0]){case"Q":{let f=r??He;return[He.prefix,f.decode(`${He.prefix}${n}`)]}case He.prefix:{let f=r??He;return[He.prefix,f.decode(n)]}case yr.prefix:{let f=r??yr;return[yr.prefix,f.decode(n)]}case Cr.prefix:{let f=r??Cr;return[Cr.prefix,f.decode(n)]}default:{if(r==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[n[0],r.decode(n)]}}}y(Bi,"parseCIDtoBytes");function Pi(n,r,f){let{prefix:s}=f;if(s!==He.prefix)throw Error(`Cannot string encode V0 in ${f.name} encoding`);let x=r.get(s);if(x==null){let d=f.encode(n).slice(1);return r.set(s,d),d}else return x}y(Pi,"toStringV0");function Ti(n,r,f){let{prefix:s}=f,x=r.get(s);if(x==null){let d=f.encode(n);return r.set(s,d),d}else return x}y(Ti,"toStringV1");var Dr=112,Di=18;function Wn(n,r,f){let s=ur(n),x=s+ur(r),d=new Uint8Array(x+f.byteLength);return xr(n,d,0),xr(r,d,s),d.set(f,x),d}y(Wn,"encodeCID");var Ii=Symbol.for("@ipld/js-cid/CID");var Wt={...zt,...Dt,...Ot,...Pt,...Tt,...Mt,...Lt,...Nt,...Rt,...It},ma={...kt,...Ht};function Jn(n,r,f,s){return{name:n,prefix:r,encoder:{name:n,prefix:r,encode:f},decoder:{decode:s}}}y(Jn,"createCodec");var Zn=Jn("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>new TextEncoder().encode(n.substring(1))),$t=Jn("ascii","a",n=>{let r="a";for(let f=0;f<n.length;f++)r+=String.fromCharCode(n[f]);return r},n=>{n=n.substring(1);let r=_r(n.length);for(let f=0;f<n.length;f++)r[f]=n.charCodeAt(f);return r}),Mi={utf8:Zn,"utf-8":Zn,hex:Wt.base16,latin1:$t,ascii:$t,binary:$t,...Wt},Wr=Mi;function ve(n,r="utf8"){let f=Wr[r];if(f==null)throw new Error(`Unsupported encoding "${r}"`);return f.decoder.decode(`${f.prefix}${n}`)}y(ve,"fromString");function ue(n,r="utf8"){let f=Wr[r];if(f==null)throw new Error(`Unsupported encoding "${r}"`);return f.encoder.encode(n).substring(1)}y(ue,"toString");var Qe="did:key:z",hr="Ed25519",$r="X25519",Va="X25519",er=32;var lr="RSA-OAEP",dr="RSASSA-PKCS1-v1_5",Zt="SHA-256",Jt=new Uint8Array([0,245,2]),ka=2048,qt="SHA-256",gr=8,br="AES-GCM",Ne=br,rr=256,Ye=12,Qt=new Uint8Array([234,1]),en=new Uint8Array([237,1]),Zr={RSA:"rsa",Edwards:"ed25519",BLS:"bls12-381"};var Jr="ecc-exchange",qr="ecc-write",_e=16;var qn=new Error("Invalid key use. Please use 'encryption' or 'signing"),Ri=new Error("Max must be less than 256 and greater than 0");function he(n){return new Uint8Array(n).buffer}y(he,"toArrayBuffer");async function Qn(n){return new Uint8Array(await te.subtle.digest("sha-256",n.buffer))}y(Qn,"sha256");function je(n){let r=ve(n,"base64pad");return he(r)}y(je,"base64ToArrBuf");var Mr=y((n,r)=>{if(typeof n=="string")return r(n);if(typeof n=="object"&&n.byteLength!==void 0)return new Uint8Array(n).buffer;throw new Error("Improper value. Must be a string, ArrayBuffer, Uint8Array")},"normalizeToBuf");function Qr(n){return Mr(n,je)}y(Qr,"normalizeBase64ToBuf");var Oi=y(n=>Mr(n,r=>ef(r,8)),"normalizeUtf8ToBuf");function ef(n,r){let f=r===8?new Uint8Array(n.length):new Uint16Array(n.length);for(let s=0,x=n.length;s<x;s++)f[s]=n.charCodeAt(s);return f.buffer}y(ef,"strToArrBuf");var zi=y(n=>Mr(n,r=>ef(r,16)),"normalizeUtf16ToBuf");function mr(n,r){switch(r){case 8:return Oi(n);default:return zi(n)}}y(mr,"normalizeUnicodeToBuf");function rf(n){if(!n.startsWith(Qe))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let r=""+n.substring(Qe.length),f=ve(r,"base58btc"),{keyBuffer:s,type:x}=Yi(he(f));return{publicKey:new Uint8Array(s),type:x}}y(rf,"didToPublicKey");function Yi(n){if(Ir(n,he(Jt)))return{keyBuffer:n.slice(Jt.byteLength),type:Zr.RSA};if(Ir(n,he(en)))return{keyBuffer:n.slice(en.byteLength),type:Zr.Edwards};if(Ir(n,he(Qt)))return{keyBuffer:n.slice(Qt.byteLength),type:Zr.BLS};throw new Error("Unsupported key algorithm. Try using RSA.")}y(Yi,"parseMagicBytes");var ji={equal:y((n,r)=>{let f=new Uint8Array(n),s=new Uint8Array(r);if(f.length!==s.length)return!1;for(let x=0;x<f.length;x++)if(f[x]!==s[x])return!1;return!0},"equal")};function Ir(n,r){return ji.equal(r,n.slice(0,r.byteLength))}y(Ir,"hasPrefix");function De(n){return ue(n instanceof ArrayBuffer?new Uint8Array(n):n,"base64pad")}y(De,"toBase64");async function tn(n,r){let f=typeof n=="string"?je(n):he(n);return te.subtle.importKey("raw",f,{name:r?.alg||Ne,length:r?.length||rr},!0,["encrypt","decrypt"])}y(tn,"importKey");function tf(n,{max:r}={max:255}){if(r<1||r>255)throw Ri;let f=new Uint8Array(n);if(r===255)return te.getRandomValues(f),f.buffer;let s=0,x=r+1,d=Math.floor(256/x)*x,v=new Uint8Array(1);for(;s<f.length;)te.getRandomValues(v),v[0]<d&&(f[s]=v[0]%x,s++);return f.buffer}y(tf,"randomBuf");function et(n,r){let f=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(he(n)),s=r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(he(r)),x=new Uint8Array(f.length+s.length);return x.set(f),x.set(s,f.length),x.buffer}y(et,"joinBufs");var ns=new Error("Key does not exist. Make sure you properly instantiated the keystore."),fs=new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name."),is=new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name."),os=new Error("ECC is not enabled for this browser. Please use RSA instead."),as=new Error("Cryptosystem not supported. Please use ECC or RSA"),Hi=new Error("Invalid key use. Please use 'exchange' or 'write'"),ss=new Error("Max must be less than 256 and greater than 0");function nf(n){Fi(n,["exchange","write","signing"],Hi)}y(nf,"checkValidKeyUse");function Fi(n,r,f){if(!r.some(x=>x===n))throw f}y(Fi,"checkValid");function rt(n){return new Promise((r,f)=>{n.oncomplete=n.onsuccess=()=>r(n.result),n.onabort=n.onerror=()=>f(n.error)})}y(rt,"promisifyRequest");function Gi(n,r){let f,s=y(()=>{if(f)return f;let x=indexedDB.open(n);return x.onupgradeneeded=()=>x.result.createObjectStore(r),f=rt(x),f.then(d=>{d.onclose=()=>f=void 0},()=>{}),f},"getDB");return(x,d)=>s().then(v=>d(v.transaction(r,x).objectStore(r)))}y(Gi,"createStore");var nn;function fn(){return nn||(nn=Gi("keyval-store","keyval")),nn}y(fn,"defaultGetStore");function Lr(n,r=fn()){return r("readonly",f=>rt(f.get(n)))}y(Lr,"get");function on(n,r,f=fn()){return f("readwrite",s=>(s.put(r,n),rt(s.transaction)))}y(on,"set");function ff(n,r=fn()){return r("readwrite",f=>(n.forEach(s=>f.delete(s)),rt(f.transaction)))}y(ff,"delMany");var sf=vf(af(),1);var cn={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:y(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:ki},ed25519:{magicBytes:new Uint8Array([237,1]),verify:Vi}}};async function Vi({message:n,publicKey:r,signature:f}){let s=n;typeof n=="string"&&(s=ve(n,"utf8"));let x=f;typeof f=="string"&&(x=ve(f,"base64pad"));let d=r;if(typeof r=="string"&&(d=cf(r).publicKey),d.length!==32)throw new Error(`Invalid Ed25519 public key size: ${d.length} bytes, expected 32`);if(x.length!==64)throw new Error(`Invalid Ed25519 signature size: ${x.length} bytes, expected 64`);return sf.default.sign.detached.verify(s,x,d)}y(Vi,"ed25519Verify");async function ki({message:n,publicKey:r,signature:f}){let s=r;return typeof r=="string"&&(s=cf(r).publicKey),yn.verify(n,f,await te.subtle.importKey("spki",he(s),{name:dr,hash:Zt},!1,["verify"]),8)}y(ki,"rsaVerify");var yn={verify:y(async function(r,f,s,x=gr,d=qt){return te.subtle.verify({name:dr,saltLength:_e},typeof s=="string"?await an(s,d,"signing"):s,Qr(f),mr(r,x))},"rsaVerify"),sign:y(async function(r,f,s=gr){return te.subtle.sign({name:dr,saltLength:_e},f,mr(r,s))},"sign"),encrypt:y(async function(r,f,s=gr,x=qt){let d;return typeof f=="string"?d=await an(f,x,"exchange"):d=f instanceof Uint8Array?await an(he(f),x,"exchange"):f,te.subtle.encrypt({name:lr},d,mr(r,s))},"rsaEncrypt"),decrypt:y(async function(r,f){let s=nt(f)?f:await Zi(f,["decrypt"]),x;typeof r=="string"?x=ve(r,"base64pad"):x=r;let d=await te.subtle.decrypt({name:lr},s,x instanceof Uint8Array?he(x):x);return new Uint8Array(d)},"rsaDecrypt")};async function an(n,r,f){Xi(f);let s=f==="exchange"?lr:dr,x=f==="exchange"?["encrypt"]:["verify"],d=typeof n=="string"?je($i(n)):n;return te.subtle.importKey("spki",d,{name:s,hash:{name:r}},!0,x)}y(an,"rsaImportPublicKey");function Xi(n){Wi(n,["signing","exchange"],qn)}y(Xi,"checkValidKeyUse");function Wi(n,r,f){if(!r.some(x=>x===n))throw f}y(Wi,"checkValid");function $i(n){return n.replace(`-----BEGIN PUBLIC KEY-----
|
|
1
|
+
var bf=Object.create;var vr=Object.defineProperty;var mf=Object.getOwnPropertyDescriptor;var Af=Object.getOwnPropertyNames;var wf=Object.getPrototypeOf,Kf=Object.prototype.hasOwnProperty;var Ef=(n,r,f)=>r in n?vr(n,r,{enumerable:!0,configurable:!0,writable:!0,value:f}):n[r]=f;var y=(n,r)=>vr(n,"name",{value:r,configurable:!0}),Cn=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(r,f)=>(typeof require<"u"?require:r)[f]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Bn=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),Le=(n,r)=>{for(var f in r)vr(n,f,{get:r[f],enumerable:!0})},Uf=(n,r,f,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let x of Af(r))!Kf.call(n,x)&&x!==f&&vr(n,x,{get:()=>r[x],enumerable:!(s=mf(r,x))||s.enumerable});return n};var vf=(n,r,f)=>(f=n!=null?bf(wf(n)):{},Uf(r||!n||!n.__esModule?vr(f,"default",{value:n,enumerable:!0}):f,n));var Y=(n,r,f)=>Ef(n,typeof r!="symbol"?r+"":r,f);var of=Bn(()=>{"use strict"});var af=Bn((ls,tt)=>{"use strict";(function(n){"use strict";var r=y(function(t){var o,i=new Float64Array(16);if(t)for(o=0;o<t.length;o++)i[o]=t[o];return i},"gf"),f=y(function(){throw new Error("no PRNG")},"randombytes"),s=new Uint8Array(16),x=new Uint8Array(32);x[0]=9;var d=r(),E=r([1]),M=r([56129,1]),$=r([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),le=r([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),ie=r([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),pe=r([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Pe=r([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Fe(t,o,i,e){t[o]=i>>24&255,t[o+1]=i>>16&255,t[o+2]=i>>8&255,t[o+3]=i&255,t[o+4]=e>>24&255,t[o+5]=e>>16&255,t[o+6]=e>>8&255,t[o+7]=e&255}y(Fe,"ts64");function W(t,o,i,e,a){var u,p=0;for(u=0;u<a;u++)p|=t[o+u]^i[e+u];return(1&p-1>>>8)-1}y(W,"vn");function fe(t,o,i,e){return W(t,o,i,e,16)}y(fe,"crypto_verify_16");function me(t,o,i,e){return W(t,o,i,e,32)}y(me,"crypto_verify_32");function we(t,o,i,e){for(var a=e[0]&255|(e[1]&255)<<8|(e[2]&255)<<16|(e[3]&255)<<24,u=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,p=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,b=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,K=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,T=e[4]&255|(e[5]&255)<<8|(e[6]&255)<<16|(e[7]&255)<<24,v=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,Q=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,_=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,L=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,N=e[8]&255|(e[9]&255)<<8|(e[10]&255)<<16|(e[11]&255)<<24,H=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,j=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,R=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,z=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,O=e[12]&255|(e[13]&255)<<8|(e[14]&255)<<16|(e[15]&255)<<24,C=a,D=u,S=p,B=b,P=K,U=T,h=v,l=Q,A=_,g=L,m=N,w=H,I=j,F=R,V=z,G=O,c,X=0;X<20;X+=2)c=C+I|0,P^=c<<7|c>>>25,c=P+C|0,A^=c<<9|c>>>23,c=A+P|0,I^=c<<13|c>>>19,c=I+A|0,C^=c<<18|c>>>14,c=U+D|0,g^=c<<7|c>>>25,c=g+U|0,F^=c<<9|c>>>23,c=F+g|0,D^=c<<13|c>>>19,c=D+F|0,U^=c<<18|c>>>14,c=m+h|0,V^=c<<7|c>>>25,c=V+m|0,S^=c<<9|c>>>23,c=S+V|0,h^=c<<13|c>>>19,c=h+S|0,m^=c<<18|c>>>14,c=G+w|0,B^=c<<7|c>>>25,c=B+G|0,l^=c<<9|c>>>23,c=l+B|0,w^=c<<13|c>>>19,c=w+l|0,G^=c<<18|c>>>14,c=C+B|0,D^=c<<7|c>>>25,c=D+C|0,S^=c<<9|c>>>23,c=S+D|0,B^=c<<13|c>>>19,c=B+S|0,C^=c<<18|c>>>14,c=U+P|0,h^=c<<7|c>>>25,c=h+U|0,l^=c<<9|c>>>23,c=l+h|0,P^=c<<13|c>>>19,c=P+l|0,U^=c<<18|c>>>14,c=m+g|0,w^=c<<7|c>>>25,c=w+m|0,A^=c<<9|c>>>23,c=A+w|0,g^=c<<13|c>>>19,c=g+A|0,m^=c<<18|c>>>14,c=G+V|0,I^=c<<7|c>>>25,c=I+G|0,F^=c<<9|c>>>23,c=F+I|0,V^=c<<13|c>>>19,c=V+F|0,G^=c<<18|c>>>14;C=C+a|0,D=D+u|0,S=S+p|0,B=B+b|0,P=P+K|0,U=U+T|0,h=h+v|0,l=l+Q|0,A=A+_|0,g=g+L|0,m=m+N|0,w=w+H|0,I=I+j|0,F=F+R|0,V=V+z|0,G=G+O|0,t[0]=C>>>0&255,t[1]=C>>>8&255,t[2]=C>>>16&255,t[3]=C>>>24&255,t[4]=D>>>0&255,t[5]=D>>>8&255,t[6]=D>>>16&255,t[7]=D>>>24&255,t[8]=S>>>0&255,t[9]=S>>>8&255,t[10]=S>>>16&255,t[11]=S>>>24&255,t[12]=B>>>0&255,t[13]=B>>>8&255,t[14]=B>>>16&255,t[15]=B>>>24&255,t[16]=P>>>0&255,t[17]=P>>>8&255,t[18]=P>>>16&255,t[19]=P>>>24&255,t[20]=U>>>0&255,t[21]=U>>>8&255,t[22]=U>>>16&255,t[23]=U>>>24&255,t[24]=h>>>0&255,t[25]=h>>>8&255,t[26]=h>>>16&255,t[27]=h>>>24&255,t[28]=l>>>0&255,t[29]=l>>>8&255,t[30]=l>>>16&255,t[31]=l>>>24&255,t[32]=A>>>0&255,t[33]=A>>>8&255,t[34]=A>>>16&255,t[35]=A>>>24&255,t[36]=g>>>0&255,t[37]=g>>>8&255,t[38]=g>>>16&255,t[39]=g>>>24&255,t[40]=m>>>0&255,t[41]=m>>>8&255,t[42]=m>>>16&255,t[43]=m>>>24&255,t[44]=w>>>0&255,t[45]=w>>>8&255,t[46]=w>>>16&255,t[47]=w>>>24&255,t[48]=I>>>0&255,t[49]=I>>>8&255,t[50]=I>>>16&255,t[51]=I>>>24&255,t[52]=F>>>0&255,t[53]=F>>>8&255,t[54]=F>>>16&255,t[55]=F>>>24&255,t[56]=V>>>0&255,t[57]=V>>>8&255,t[58]=V>>>16&255,t[59]=V>>>24&255,t[60]=G>>>0&255,t[61]=G>>>8&255,t[62]=G>>>16&255,t[63]=G>>>24&255}y(we,"core_salsa20");function Ce(t,o,i,e){for(var a=e[0]&255|(e[1]&255)<<8|(e[2]&255)<<16|(e[3]&255)<<24,u=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,p=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,b=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,K=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,T=e[4]&255|(e[5]&255)<<8|(e[6]&255)<<16|(e[7]&255)<<24,v=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,Q=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,_=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,L=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,N=e[8]&255|(e[9]&255)<<8|(e[10]&255)<<16|(e[11]&255)<<24,H=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,j=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,R=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,z=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,O=e[12]&255|(e[13]&255)<<8|(e[14]&255)<<16|(e[15]&255)<<24,C=a,D=u,S=p,B=b,P=K,U=T,h=v,l=Q,A=_,g=L,m=N,w=H,I=j,F=R,V=z,G=O,c,X=0;X<20;X+=2)c=C+I|0,P^=c<<7|c>>>25,c=P+C|0,A^=c<<9|c>>>23,c=A+P|0,I^=c<<13|c>>>19,c=I+A|0,C^=c<<18|c>>>14,c=U+D|0,g^=c<<7|c>>>25,c=g+U|0,F^=c<<9|c>>>23,c=F+g|0,D^=c<<13|c>>>19,c=D+F|0,U^=c<<18|c>>>14,c=m+h|0,V^=c<<7|c>>>25,c=V+m|0,S^=c<<9|c>>>23,c=S+V|0,h^=c<<13|c>>>19,c=h+S|0,m^=c<<18|c>>>14,c=G+w|0,B^=c<<7|c>>>25,c=B+G|0,l^=c<<9|c>>>23,c=l+B|0,w^=c<<13|c>>>19,c=w+l|0,G^=c<<18|c>>>14,c=C+B|0,D^=c<<7|c>>>25,c=D+C|0,S^=c<<9|c>>>23,c=S+D|0,B^=c<<13|c>>>19,c=B+S|0,C^=c<<18|c>>>14,c=U+P|0,h^=c<<7|c>>>25,c=h+U|0,l^=c<<9|c>>>23,c=l+h|0,P^=c<<13|c>>>19,c=P+l|0,U^=c<<18|c>>>14,c=m+g|0,w^=c<<7|c>>>25,c=w+m|0,A^=c<<9|c>>>23,c=A+w|0,g^=c<<13|c>>>19,c=g+A|0,m^=c<<18|c>>>14,c=G+V|0,I^=c<<7|c>>>25,c=I+G|0,F^=c<<9|c>>>23,c=F+I|0,V^=c<<13|c>>>19,c=V+F|0,G^=c<<18|c>>>14;t[0]=C>>>0&255,t[1]=C>>>8&255,t[2]=C>>>16&255,t[3]=C>>>24&255,t[4]=U>>>0&255,t[5]=U>>>8&255,t[6]=U>>>16&255,t[7]=U>>>24&255,t[8]=m>>>0&255,t[9]=m>>>8&255,t[10]=m>>>16&255,t[11]=m>>>24&255,t[12]=G>>>0&255,t[13]=G>>>8&255,t[14]=G>>>16&255,t[15]=G>>>24&255,t[16]=h>>>0&255,t[17]=h>>>8&255,t[18]=h>>>16&255,t[19]=h>>>24&255,t[20]=l>>>0&255,t[21]=l>>>8&255,t[22]=l>>>16&255,t[23]=l>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=g>>>0&255,t[29]=g>>>8&255,t[30]=g>>>16&255,t[31]=g>>>24&255}y(Ce,"core_hsalsa20");function ye(t,o,i,e){we(t,o,i,e)}y(ye,"crypto_core_salsa20");function Ae(t,o,i,e){Ce(t,o,i,e)}y(Ae,"crypto_core_hsalsa20");var ge=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Re(t,o,i,e,a,u,p){var b=new Uint8Array(16),K=new Uint8Array(64),T,v;for(v=0;v<16;v++)b[v]=0;for(v=0;v<8;v++)b[v]=u[v];for(;a>=64;){for(ye(K,b,p,ge),v=0;v<64;v++)t[o+v]=i[e+v]^K[v];for(T=1,v=8;v<16;v++)T=T+(b[v]&255)|0,b[v]=T&255,T>>>=8;a-=64,o+=64,e+=64}if(a>0)for(ye(K,b,p,ge),v=0;v<a;v++)t[o+v]=i[e+v]^K[v];return 0}y(Re,"crypto_stream_salsa20_xor");function Be(t,o,i,e,a){var u=new Uint8Array(16),p=new Uint8Array(64),b,K;for(K=0;K<16;K++)u[K]=0;for(K=0;K<8;K++)u[K]=e[K];for(;i>=64;){for(ye(p,u,a,ge),K=0;K<64;K++)t[o+K]=p[K];for(b=1,K=8;K<16;K++)b=b+(u[K]&255)|0,u[K]=b&255,b>>>=8;i-=64,o+=64}if(i>0)for(ye(p,u,a,ge),K=0;K<i;K++)t[o+K]=p[K];return 0}y(Be,"crypto_stream_salsa20");function Ie(t,o,i,e,a){var u=new Uint8Array(32);Ae(u,e,a,ge);for(var p=new Uint8Array(8),b=0;b<8;b++)p[b]=e[b+16];return Be(t,o,i,p,u)}y(Ie,"crypto_stream");function Xe(t,o,i,e,a,u,p){var b=new Uint8Array(32);Ae(b,u,p,ge);for(var K=new Uint8Array(8),T=0;T<8;T++)K[T]=u[T+16];return Re(t,o,i,e,a,K,b)}y(Xe,"crypto_stream_xor");var Rr=y(function(t){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;var o,i,e,a,u,p,b,K;o=t[0]&255|(t[1]&255)<<8,this.r[0]=o&8191,i=t[2]&255|(t[3]&255)<<8,this.r[1]=(o>>>13|i<<3)&8191,e=t[4]&255|(t[5]&255)<<8,this.r[2]=(i>>>10|e<<6)&7939,a=t[6]&255|(t[7]&255)<<8,this.r[3]=(e>>>7|a<<9)&8191,u=t[8]&255|(t[9]&255)<<8,this.r[4]=(a>>>4|u<<12)&255,this.r[5]=u>>>1&8190,p=t[10]&255|(t[11]&255)<<8,this.r[6]=(u>>>14|p<<2)&8191,b=t[12]&255|(t[13]&255)<<8,this.r[7]=(p>>>11|b<<5)&8065,K=t[14]&255|(t[15]&255)<<8,this.r[8]=(b>>>8|K<<8)&8191,this.r[9]=K>>>5&127,this.pad[0]=t[16]&255|(t[17]&255)<<8,this.pad[1]=t[18]&255|(t[19]&255)<<8,this.pad[2]=t[20]&255|(t[21]&255)<<8,this.pad[3]=t[22]&255|(t[23]&255)<<8,this.pad[4]=t[24]&255|(t[25]&255)<<8,this.pad[5]=t[26]&255|(t[27]&255)<<8,this.pad[6]=t[28]&255|(t[29]&255)<<8,this.pad[7]=t[30]&255|(t[31]&255)<<8},"poly1305");Rr.prototype.blocks=function(t,o,i){for(var e=this.fin?0:2048,a,u,p,b,K,T,v,Q,_,L,N,H,j,R,z,O,C,D,S,B=this.h[0],P=this.h[1],U=this.h[2],h=this.h[3],l=this.h[4],A=this.h[5],g=this.h[6],m=this.h[7],w=this.h[8],I=this.h[9],F=this.r[0],V=this.r[1],G=this.r[2],c=this.r[3],X=this.r[4],ee=this.r[5],re=this.r[6],k=this.r[7],J=this.r[8],q=this.r[9];i>=16;)a=t[o+0]&255|(t[o+1]&255)<<8,B+=a&8191,u=t[o+2]&255|(t[o+3]&255)<<8,P+=(a>>>13|u<<3)&8191,p=t[o+4]&255|(t[o+5]&255)<<8,U+=(u>>>10|p<<6)&8191,b=t[o+6]&255|(t[o+7]&255)<<8,h+=(p>>>7|b<<9)&8191,K=t[o+8]&255|(t[o+9]&255)<<8,l+=(b>>>4|K<<12)&8191,A+=K>>>1&8191,T=t[o+10]&255|(t[o+11]&255)<<8,g+=(K>>>14|T<<2)&8191,v=t[o+12]&255|(t[o+13]&255)<<8,m+=(T>>>11|v<<5)&8191,Q=t[o+14]&255|(t[o+15]&255)<<8,w+=(v>>>8|Q<<8)&8191,I+=Q>>>5|e,_=0,L=_,L+=B*F,L+=P*(5*q),L+=U*(5*J),L+=h*(5*k),L+=l*(5*re),_=L>>>13,L&=8191,L+=A*(5*ee),L+=g*(5*X),L+=m*(5*c),L+=w*(5*G),L+=I*(5*V),_+=L>>>13,L&=8191,N=_,N+=B*V,N+=P*F,N+=U*(5*q),N+=h*(5*J),N+=l*(5*k),_=N>>>13,N&=8191,N+=A*(5*re),N+=g*(5*ee),N+=m*(5*X),N+=w*(5*c),N+=I*(5*G),_+=N>>>13,N&=8191,H=_,H+=B*G,H+=P*V,H+=U*F,H+=h*(5*q),H+=l*(5*J),_=H>>>13,H&=8191,H+=A*(5*k),H+=g*(5*re),H+=m*(5*ee),H+=w*(5*X),H+=I*(5*c),_+=H>>>13,H&=8191,j=_,j+=B*c,j+=P*G,j+=U*V,j+=h*F,j+=l*(5*q),_=j>>>13,j&=8191,j+=A*(5*J),j+=g*(5*k),j+=m*(5*re),j+=w*(5*ee),j+=I*(5*X),_+=j>>>13,j&=8191,R=_,R+=B*X,R+=P*c,R+=U*G,R+=h*V,R+=l*F,_=R>>>13,R&=8191,R+=A*(5*q),R+=g*(5*J),R+=m*(5*k),R+=w*(5*re),R+=I*(5*ee),_+=R>>>13,R&=8191,z=_,z+=B*ee,z+=P*X,z+=U*c,z+=h*G,z+=l*V,_=z>>>13,z&=8191,z+=A*F,z+=g*(5*q),z+=m*(5*J),z+=w*(5*k),z+=I*(5*re),_+=z>>>13,z&=8191,O=_,O+=B*re,O+=P*ee,O+=U*X,O+=h*c,O+=l*G,_=O>>>13,O&=8191,O+=A*V,O+=g*F,O+=m*(5*q),O+=w*(5*J),O+=I*(5*k),_+=O>>>13,O&=8191,C=_,C+=B*k,C+=P*re,C+=U*ee,C+=h*X,C+=l*c,_=C>>>13,C&=8191,C+=A*G,C+=g*V,C+=m*F,C+=w*(5*q),C+=I*(5*J),_+=C>>>13,C&=8191,D=_,D+=B*J,D+=P*k,D+=U*re,D+=h*ee,D+=l*X,_=D>>>13,D&=8191,D+=A*c,D+=g*G,D+=m*V,D+=w*F,D+=I*(5*q),_+=D>>>13,D&=8191,S=_,S+=B*q,S+=P*J,S+=U*k,S+=h*re,S+=l*ee,_=S>>>13,S&=8191,S+=A*X,S+=g*c,S+=m*G,S+=w*V,S+=I*F,_+=S>>>13,S&=8191,_=(_<<2)+_|0,_=_+L|0,L=_&8191,_=_>>>13,N+=_,B=L,P=N,U=H,h=j,l=R,A=z,g=O,m=C,w=D,I=S,o+=16,i-=16;this.h[0]=B,this.h[1]=P,this.h[2]=U,this.h[3]=h,this.h[4]=l,this.h[5]=A,this.h[6]=g,this.h[7]=m,this.h[8]=w,this.h[9]=I},Rr.prototype.finish=function(t,o){var i=new Uint16Array(10),e,a,u,p;if(this.leftover){for(p=this.leftover,this.buffer[p++]=1;p<16;p++)this.buffer[p]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(e=this.h[1]>>>13,this.h[1]&=8191,p=2;p<10;p++)this.h[p]+=e,e=this.h[p]>>>13,this.h[p]&=8191;for(this.h[0]+=e*5,e=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=e,e=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=e,i[0]=this.h[0]+5,e=i[0]>>>13,i[0]&=8191,p=1;p<10;p++)i[p]=this.h[p]+e,e=i[p]>>>13,i[p]&=8191;for(i[9]-=8192,a=(e^1)-1,p=0;p<10;p++)i[p]&=a;for(a=~a,p=0;p<10;p++)this.h[p]=this.h[p]&a|i[p];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,u=this.h[0]+this.pad[0],this.h[0]=u&65535,p=1;p<8;p++)u=(this.h[p]+this.pad[p]|0)+(u>>>16)|0,this.h[p]=u&65535;t[o+0]=this.h[0]>>>0&255,t[o+1]=this.h[0]>>>8&255,t[o+2]=this.h[1]>>>0&255,t[o+3]=this.h[1]>>>8&255,t[o+4]=this.h[2]>>>0&255,t[o+5]=this.h[2]>>>8&255,t[o+6]=this.h[3]>>>0&255,t[o+7]=this.h[3]>>>8&255,t[o+8]=this.h[4]>>>0&255,t[o+9]=this.h[4]>>>8&255,t[o+10]=this.h[5]>>>0&255,t[o+11]=this.h[5]>>>8&255,t[o+12]=this.h[6]>>>0&255,t[o+13]=this.h[6]>>>8&255,t[o+14]=this.h[7]>>>0&255,t[o+15]=this.h[7]>>>8&255},Rr.prototype.update=function(t,o,i){var e,a;if(this.leftover){for(a=16-this.leftover,a>i&&(a=i),e=0;e<a;e++)this.buffer[this.leftover+e]=t[o+e];if(i-=a,o+=a,this.leftover+=a,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(i>=16&&(a=i-i%16,this.blocks(t,o,a),o+=a,i-=a),i){for(e=0;e<i;e++)this.buffer[this.leftover+e]=t[o+e];this.leftover+=i}};function ot(t,o,i,e,a,u){var p=new Rr(u);return p.update(i,e,a),p.finish(t,o),0}y(ot,"crypto_onetimeauth");function hn(t,o,i,e,a,u){var p=new Uint8Array(16);return ot(p,0,i,e,a,u),fe(t,o,p,0)}y(hn,"crypto_onetimeauth_verify");function at(t,o,i,e,a){var u;if(i<32)return-1;for(Xe(t,0,o,0,i,e,a),ot(t,16,t,32,i-32,t),u=0;u<16;u++)t[u]=0;return 0}y(at,"crypto_secretbox");function st(t,o,i,e,a){var u,p=new Uint8Array(32);if(i<32||(Ie(p,0,32,e,a),hn(o,16,o,32,i-32,p)!==0))return-1;for(Xe(t,0,o,0,i,e,a),u=0;u<32;u++)t[u]=0;return 0}y(st,"crypto_secretbox_open");function Ge(t,o){var i;for(i=0;i<16;i++)t[i]=o[i]|0}y(Ge,"set25519");function ct(t){var o,i,e=1;for(o=0;o<16;o++)i=t[o]+e+65535,e=Math.floor(i/65536),t[o]=i-e*65536;t[0]+=e-1+37*(e-1)}y(ct,"car25519");function ir(t,o,i){for(var e,a=~(i-1),u=0;u<16;u++)e=a&(t[u]^o[u]),t[u]^=e,o[u]^=e}y(ir,"sel25519");function or(t,o){var i,e,a,u=r(),p=r();for(i=0;i<16;i++)p[i]=o[i];for(ct(p),ct(p),ct(p),e=0;e<2;e++){for(u[0]=p[0]-65517,i=1;i<15;i++)u[i]=p[i]-65535-(u[i-1]>>16&1),u[i-1]&=65535;u[15]=p[15]-32767-(u[14]>>16&1),a=u[15]>>16&1,u[14]&=65535,ir(p,u,1-a)}for(i=0;i<16;i++)t[2*i]=p[i]&255,t[2*i+1]=p[i]>>8}y(or,"pack25519");function ln(t,o){var i=new Uint8Array(32),e=new Uint8Array(32);return or(i,t),or(e,o),me(i,0,e,0)}y(ln,"neq25519");function dn(t){var o=new Uint8Array(32);return or(o,t),o[0]&1}y(dn,"par25519");function yt(t,o){var i;for(i=0;i<16;i++)t[i]=o[2*i]+(o[2*i+1]<<8);t[15]&=32767}y(yt,"unpack25519");function Oe(t,o,i){for(var e=0;e<16;e++)t[e]=o[e]+i[e]}y(Oe,"A");function ze(t,o,i){for(var e=0;e<16;e++)t[e]=o[e]-i[e]}y(ze,"Z");function Z(t,o,i){var e,a,u=0,p=0,b=0,K=0,T=0,v=0,Q=0,_=0,L=0,N=0,H=0,j=0,R=0,z=0,O=0,C=0,D=0,S=0,B=0,P=0,U=0,h=0,l=0,A=0,g=0,m=0,w=0,I=0,F=0,V=0,G=0,c=i[0],X=i[1],ee=i[2],re=i[3],k=i[4],J=i[5],q=i[6],xe=i[7],ne=i[8],oe=i[9],ae=i[10],se=i[11],de=i[12],Ke=i[13],Ee=i[14],Ue=i[15];e=o[0],u+=e*c,p+=e*X,b+=e*ee,K+=e*re,T+=e*k,v+=e*J,Q+=e*q,_+=e*xe,L+=e*ne,N+=e*oe,H+=e*ae,j+=e*se,R+=e*de,z+=e*Ke,O+=e*Ee,C+=e*Ue,e=o[1],p+=e*c,b+=e*X,K+=e*ee,T+=e*re,v+=e*k,Q+=e*J,_+=e*q,L+=e*xe,N+=e*ne,H+=e*oe,j+=e*ae,R+=e*se,z+=e*de,O+=e*Ke,C+=e*Ee,D+=e*Ue,e=o[2],b+=e*c,K+=e*X,T+=e*ee,v+=e*re,Q+=e*k,_+=e*J,L+=e*q,N+=e*xe,H+=e*ne,j+=e*oe,R+=e*ae,z+=e*se,O+=e*de,C+=e*Ke,D+=e*Ee,S+=e*Ue,e=o[3],K+=e*c,T+=e*X,v+=e*ee,Q+=e*re,_+=e*k,L+=e*J,N+=e*q,H+=e*xe,j+=e*ne,R+=e*oe,z+=e*ae,O+=e*se,C+=e*de,D+=e*Ke,S+=e*Ee,B+=e*Ue,e=o[4],T+=e*c,v+=e*X,Q+=e*ee,_+=e*re,L+=e*k,N+=e*J,H+=e*q,j+=e*xe,R+=e*ne,z+=e*oe,O+=e*ae,C+=e*se,D+=e*de,S+=e*Ke,B+=e*Ee,P+=e*Ue,e=o[5],v+=e*c,Q+=e*X,_+=e*ee,L+=e*re,N+=e*k,H+=e*J,j+=e*q,R+=e*xe,z+=e*ne,O+=e*oe,C+=e*ae,D+=e*se,S+=e*de,B+=e*Ke,P+=e*Ee,U+=e*Ue,e=o[6],Q+=e*c,_+=e*X,L+=e*ee,N+=e*re,H+=e*k,j+=e*J,R+=e*q,z+=e*xe,O+=e*ne,C+=e*oe,D+=e*ae,S+=e*se,B+=e*de,P+=e*Ke,U+=e*Ee,h+=e*Ue,e=o[7],_+=e*c,L+=e*X,N+=e*ee,H+=e*re,j+=e*k,R+=e*J,z+=e*q,O+=e*xe,C+=e*ne,D+=e*oe,S+=e*ae,B+=e*se,P+=e*de,U+=e*Ke,h+=e*Ee,l+=e*Ue,e=o[8],L+=e*c,N+=e*X,H+=e*ee,j+=e*re,R+=e*k,z+=e*J,O+=e*q,C+=e*xe,D+=e*ne,S+=e*oe,B+=e*ae,P+=e*se,U+=e*de,h+=e*Ke,l+=e*Ee,A+=e*Ue,e=o[9],N+=e*c,H+=e*X,j+=e*ee,R+=e*re,z+=e*k,O+=e*J,C+=e*q,D+=e*xe,S+=e*ne,B+=e*oe,P+=e*ae,U+=e*se,h+=e*de,l+=e*Ke,A+=e*Ee,g+=e*Ue,e=o[10],H+=e*c,j+=e*X,R+=e*ee,z+=e*re,O+=e*k,C+=e*J,D+=e*q,S+=e*xe,B+=e*ne,P+=e*oe,U+=e*ae,h+=e*se,l+=e*de,A+=e*Ke,g+=e*Ee,m+=e*Ue,e=o[11],j+=e*c,R+=e*X,z+=e*ee,O+=e*re,C+=e*k,D+=e*J,S+=e*q,B+=e*xe,P+=e*ne,U+=e*oe,h+=e*ae,l+=e*se,A+=e*de,g+=e*Ke,m+=e*Ee,w+=e*Ue,e=o[12],R+=e*c,z+=e*X,O+=e*ee,C+=e*re,D+=e*k,S+=e*J,B+=e*q,P+=e*xe,U+=e*ne,h+=e*oe,l+=e*ae,A+=e*se,g+=e*de,m+=e*Ke,w+=e*Ee,I+=e*Ue,e=o[13],z+=e*c,O+=e*X,C+=e*ee,D+=e*re,S+=e*k,B+=e*J,P+=e*q,U+=e*xe,h+=e*ne,l+=e*oe,A+=e*ae,g+=e*se,m+=e*de,w+=e*Ke,I+=e*Ee,F+=e*Ue,e=o[14],O+=e*c,C+=e*X,D+=e*ee,S+=e*re,B+=e*k,P+=e*J,U+=e*q,h+=e*xe,l+=e*ne,A+=e*oe,g+=e*ae,m+=e*se,w+=e*de,I+=e*Ke,F+=e*Ee,V+=e*Ue,e=o[15],C+=e*c,D+=e*X,S+=e*ee,B+=e*re,P+=e*k,U+=e*J,h+=e*q,l+=e*xe,A+=e*ne,g+=e*oe,m+=e*ae,w+=e*se,I+=e*de,F+=e*Ke,V+=e*Ee,G+=e*Ue,u+=38*D,p+=38*S,b+=38*B,K+=38*P,T+=38*U,v+=38*h,Q+=38*l,_+=38*A,L+=38*g,N+=38*m,H+=38*w,j+=38*I,R+=38*F,z+=38*V,O+=38*G,a=1,e=u+a+65535,a=Math.floor(e/65536),u=e-a*65536,e=p+a+65535,a=Math.floor(e/65536),p=e-a*65536,e=b+a+65535,a=Math.floor(e/65536),b=e-a*65536,e=K+a+65535,a=Math.floor(e/65536),K=e-a*65536,e=T+a+65535,a=Math.floor(e/65536),T=e-a*65536,e=v+a+65535,a=Math.floor(e/65536),v=e-a*65536,e=Q+a+65535,a=Math.floor(e/65536),Q=e-a*65536,e=_+a+65535,a=Math.floor(e/65536),_=e-a*65536,e=L+a+65535,a=Math.floor(e/65536),L=e-a*65536,e=N+a+65535,a=Math.floor(e/65536),N=e-a*65536,e=H+a+65535,a=Math.floor(e/65536),H=e-a*65536,e=j+a+65535,a=Math.floor(e/65536),j=e-a*65536,e=R+a+65535,a=Math.floor(e/65536),R=e-a*65536,e=z+a+65535,a=Math.floor(e/65536),z=e-a*65536,e=O+a+65535,a=Math.floor(e/65536),O=e-a*65536,e=C+a+65535,a=Math.floor(e/65536),C=e-a*65536,u+=a-1+37*(a-1),a=1,e=u+a+65535,a=Math.floor(e/65536),u=e-a*65536,e=p+a+65535,a=Math.floor(e/65536),p=e-a*65536,e=b+a+65535,a=Math.floor(e/65536),b=e-a*65536,e=K+a+65535,a=Math.floor(e/65536),K=e-a*65536,e=T+a+65535,a=Math.floor(e/65536),T=e-a*65536,e=v+a+65535,a=Math.floor(e/65536),v=e-a*65536,e=Q+a+65535,a=Math.floor(e/65536),Q=e-a*65536,e=_+a+65535,a=Math.floor(e/65536),_=e-a*65536,e=L+a+65535,a=Math.floor(e/65536),L=e-a*65536,e=N+a+65535,a=Math.floor(e/65536),N=e-a*65536,e=H+a+65535,a=Math.floor(e/65536),H=e-a*65536,e=j+a+65535,a=Math.floor(e/65536),j=e-a*65536,e=R+a+65535,a=Math.floor(e/65536),R=e-a*65536,e=z+a+65535,a=Math.floor(e/65536),z=e-a*65536,e=O+a+65535,a=Math.floor(e/65536),O=e-a*65536,e=C+a+65535,a=Math.floor(e/65536),C=e-a*65536,u+=a-1+37*(a-1),t[0]=u,t[1]=p,t[2]=b,t[3]=K,t[4]=T,t[5]=v,t[6]=Q,t[7]=_,t[8]=L,t[9]=N,t[10]=H,t[11]=j,t[12]=R,t[13]=z,t[14]=O,t[15]=C}y(Z,"M");function Me(t,o){Z(t,o,o)}y(Me,"S");function gn(t,o){var i=r(),e;for(e=0;e<16;e++)i[e]=o[e];for(e=253;e>=0;e--)Me(i,i),e!==2&&e!==4&&Z(i,i,o);for(e=0;e<16;e++)t[e]=i[e]}y(gn,"inv25519");function bn(t,o){var i=r(),e;for(e=0;e<16;e++)i[e]=o[e];for(e=250;e>=0;e--)Me(i,i),e!==1&&Z(i,i,o);for(e=0;e<16;e++)t[e]=i[e]}y(bn,"pow2523");function Or(t,o,i){var e=new Uint8Array(32),a=new Float64Array(80),u,p,b=r(),K=r(),T=r(),v=r(),Q=r(),_=r();for(p=0;p<31;p++)e[p]=o[p];for(e[31]=o[31]&127|64,e[0]&=248,yt(a,i),p=0;p<16;p++)K[p]=a[p],v[p]=b[p]=T[p]=0;for(b[0]=v[0]=1,p=254;p>=0;--p)u=e[p>>>3]>>>(p&7)&1,ir(b,K,u),ir(T,v,u),Oe(Q,b,T),ze(b,b,T),Oe(T,K,v),ze(K,K,v),Me(v,Q),Me(_,b),Z(b,T,b),Z(T,K,Q),Oe(Q,b,T),ze(b,b,T),Me(K,b),ze(T,v,_),Z(b,T,M),Oe(b,b,v),Z(T,T,b),Z(b,v,_),Z(v,K,a),Me(K,Q),ir(b,K,u),ir(T,v,u);for(p=0;p<16;p++)a[p+16]=b[p],a[p+32]=T[p],a[p+48]=K[p],a[p+64]=v[p];var L=a.subarray(32),N=a.subarray(16);return gn(L,L),Z(N,N,L),or(t,N),0}y(Or,"crypto_scalarmult");function zr(t,o){return Or(t,o,x)}y(zr,"crypto_scalarmult_base");function mn(t,o){return f(o,32),zr(t,o)}y(mn,"crypto_box_keypair");function Yr(t,o,i){var e=new Uint8Array(32);return Or(e,i,o),Ae(t,s,e,ge)}y(Yr,"crypto_box_beforenm");var An=at,xf=st;function uf(t,o,i,e,a,u){var p=new Uint8Array(32);return Yr(p,a,u),An(t,o,i,e,p)}y(uf,"crypto_box");function pf(t,o,i,e,a,u){var p=new Uint8Array(32);return Yr(p,a,u),xf(t,o,i,e,p)}y(pf,"crypto_box_open");var wn=[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 Kn(t,o,i,e){for(var a=new Int32Array(16),u=new Int32Array(16),p,b,K,T,v,Q,_,L,N,H,j,R,z,O,C,D,S,B,P,U,h,l,A,g,m,w,I=t[0],F=t[1],V=t[2],G=t[3],c=t[4],X=t[5],ee=t[6],re=t[7],k=o[0],J=o[1],q=o[2],xe=o[3],ne=o[4],oe=o[5],ae=o[6],se=o[7],de=0;e>=128;){for(P=0;P<16;P++)U=8*P+de,a[P]=i[U+0]<<24|i[U+1]<<16|i[U+2]<<8|i[U+3],u[P]=i[U+4]<<24|i[U+5]<<16|i[U+6]<<8|i[U+7];for(P=0;P<80;P++)if(p=I,b=F,K=V,T=G,v=c,Q=X,_=ee,L=re,N=k,H=J,j=q,R=xe,z=ne,O=oe,C=ae,D=se,h=re,l=se,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=(c>>>14|ne<<18)^(c>>>18|ne<<14)^(ne>>>9|c<<23),l=(ne>>>14|c<<18)^(ne>>>18|c<<14)^(c>>>9|ne<<23),A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,h=c&X^~c&ee,l=ne&oe^~ne&ae,A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,h=wn[P*2],l=wn[P*2+1],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,h=a[P%16],l=u[P%16],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,S=m&65535|w<<16,B=A&65535|g<<16,h=S,l=B,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=(I>>>28|k<<4)^(k>>>2|I<<30)^(k>>>7|I<<25),l=(k>>>28|I<<4)^(I>>>2|k<<30)^(I>>>7|k<<25),A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,h=I&F^I&V^F&V,l=k&J^k&q^J&q,A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,L=m&65535|w<<16,D=A&65535|g<<16,h=T,l=R,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=S,l=B,A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,T=m&65535|w<<16,R=A&65535|g<<16,F=p,V=b,G=K,c=T,X=v,ee=Q,re=_,I=L,J=N,q=H,xe=j,ne=R,oe=z,ae=O,se=C,k=D,P%16===15)for(U=0;U<16;U++)h=a[U],l=u[U],A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=a[(U+9)%16],l=u[(U+9)%16],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,S=a[(U+1)%16],B=u[(U+1)%16],h=(S>>>1|B<<31)^(S>>>8|B<<24)^S>>>7,l=(B>>>1|S<<31)^(B>>>8|S<<24)^(B>>>7|S<<25),A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,S=a[(U+14)%16],B=u[(U+14)%16],h=(S>>>19|B<<13)^(B>>>29|S<<3)^S>>>6,l=(B>>>19|S<<13)^(S>>>29|B<<3)^(B>>>6|S<<26),A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,a[U]=m&65535|w<<16,u[U]=A&65535|g<<16;h=I,l=k,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[0],l=o[0],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[0]=I=m&65535|w<<16,o[0]=k=A&65535|g<<16,h=F,l=J,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[1],l=o[1],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[1]=F=m&65535|w<<16,o[1]=J=A&65535|g<<16,h=V,l=q,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[2],l=o[2],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[2]=V=m&65535|w<<16,o[2]=q=A&65535|g<<16,h=G,l=xe,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[3],l=o[3],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[3]=G=m&65535|w<<16,o[3]=xe=A&65535|g<<16,h=c,l=ne,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[4],l=o[4],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[4]=c=m&65535|w<<16,o[4]=ne=A&65535|g<<16,h=X,l=oe,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[5],l=o[5],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[5]=X=m&65535|w<<16,o[5]=oe=A&65535|g<<16,h=ee,l=ae,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[6],l=o[6],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[6]=ee=m&65535|w<<16,o[6]=ae=A&65535|g<<16,h=re,l=se,A=l&65535,g=l>>>16,m=h&65535,w=h>>>16,h=t[7],l=o[7],A+=l&65535,g+=l>>>16,m+=h&65535,w+=h>>>16,g+=A>>>16,m+=g>>>16,w+=m>>>16,t[7]=re=m&65535|w<<16,o[7]=se=A&65535|g<<16,de+=128,e-=128}return e}y(Kn,"crypto_hashblocks_hl");function Ze(t,o,i){var e=new Int32Array(8),a=new Int32Array(8),u=new Uint8Array(256),p,b=i;for(e[0]=1779033703,e[1]=3144134277,e[2]=1013904242,e[3]=2773480762,e[4]=1359893119,e[5]=2600822924,e[6]=528734635,e[7]=1541459225,a[0]=4089235720,a[1]=2227873595,a[2]=4271175723,a[3]=1595750129,a[4]=2917565137,a[5]=725511199,a[6]=4215389547,a[7]=327033209,Kn(e,a,o,i),i%=128,p=0;p<i;p++)u[p]=o[b-i+p];for(u[i]=128,i=256-128*(i<112?1:0),u[i-9]=0,Fe(u,i-8,b/536870912|0,b<<3),Kn(e,a,u,i),p=0;p<8;p++)Fe(t,8*p,e[p],a[p]);return 0}y(Ze,"crypto_hash");function jr(t,o){var i=r(),e=r(),a=r(),u=r(),p=r(),b=r(),K=r(),T=r(),v=r();ze(i,t[1],t[0]),ze(v,o[1],o[0]),Z(i,i,v),Oe(e,t[0],t[1]),Oe(v,o[0],o[1]),Z(e,e,v),Z(a,t[3],o[3]),Z(a,a,le),Z(u,t[2],o[2]),Oe(u,u,u),ze(p,e,i),ze(b,u,a),Oe(K,u,a),Oe(T,e,i),Z(t[0],p,b),Z(t[1],T,K),Z(t[2],K,b),Z(t[3],p,T)}y(jr,"add");function En(t,o,i){var e;for(e=0;e<4;e++)ir(t[e],o[e],i)}y(En,"cswap");function xt(t,o){var i=r(),e=r(),a=r();gn(a,o[2]),Z(i,o[0],a),Z(e,o[1],a),or(t,e),t[31]^=dn(i)<<7}y(xt,"pack");function ut(t,o,i){var e,a;for(Ge(t[0],d),Ge(t[1],E),Ge(t[2],E),Ge(t[3],d),a=255;a>=0;--a)e=i[a/8|0]>>(a&7)&1,En(t,o,e),jr(o,t),jr(t,t),En(t,o,e)}y(ut,"scalarmult");function Hr(t,o){var i=[r(),r(),r(),r()];Ge(i[0],ie),Ge(i[1],pe),Ge(i[2],E),Z(i[3],ie,pe),ut(t,i,o)}y(Hr,"scalarbase");function pt(t,o,i){var e=new Uint8Array(64),a=[r(),r(),r(),r()],u;for(i||f(o,32),Ze(e,o,32),e[0]&=248,e[31]&=127,e[31]|=64,Hr(a,e),xt(t,a),u=0;u<32;u++)o[u+32]=t[u];return 0}y(pt,"crypto_sign_keypair");var Fr=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 ht(t,o){var i,e,a,u;for(e=63;e>=32;--e){for(i=0,a=e-32,u=e-12;a<u;++a)o[a]+=i-16*o[e]*Fr[a-(e-32)],i=Math.floor((o[a]+128)/256),o[a]-=i*256;o[a]+=i,o[e]=0}for(i=0,a=0;a<32;a++)o[a]+=i-(o[31]>>4)*Fr[a],i=o[a]>>8,o[a]&=255;for(a=0;a<32;a++)o[a]-=i*Fr[a];for(e=0;e<32;e++)o[e+1]+=o[e]>>8,t[e]=o[e]&255}y(ht,"modL");function lt(t){var o=new Float64Array(64),i;for(i=0;i<64;i++)o[i]=t[i];for(i=0;i<64;i++)t[i]=0;ht(t,o)}y(lt,"reduce");function Un(t,o,i,e){var a=new Uint8Array(64),u=new Uint8Array(64),p=new Uint8Array(64),b,K,T=new Float64Array(64),v=[r(),r(),r(),r()];Ze(a,e,32),a[0]&=248,a[31]&=127,a[31]|=64;var Q=i+64;for(b=0;b<i;b++)t[64+b]=o[b];for(b=0;b<32;b++)t[32+b]=a[32+b];for(Ze(p,t.subarray(32),i+32),lt(p),Hr(v,p),xt(t,v),b=32;b<64;b++)t[b]=e[b];for(Ze(u,t,i+64),lt(u),b=0;b<64;b++)T[b]=0;for(b=0;b<32;b++)T[b]=p[b];for(b=0;b<32;b++)for(K=0;K<32;K++)T[b+K]+=u[b]*a[K];return ht(t.subarray(32),T),Q}y(Un,"crypto_sign");function hf(t,o){var i=r(),e=r(),a=r(),u=r(),p=r(),b=r(),K=r();return Ge(t[2],E),yt(t[1],o),Me(a,t[1]),Z(u,a,$),ze(a,a,t[2]),Oe(u,t[2],u),Me(p,u),Me(b,p),Z(K,b,p),Z(i,K,a),Z(i,i,u),bn(i,i),Z(i,i,a),Z(i,i,u),Z(i,i,u),Z(t[0],i,u),Me(e,t[0]),Z(e,e,u),ln(e,a)&&Z(t[0],t[0],Pe),Me(e,t[0]),Z(e,e,u),ln(e,a)?-1:(dn(t[0])===o[31]>>7&&ze(t[0],d,t[0]),Z(t[3],t[0],t[1]),0)}y(hf,"unpackneg");function dt(t,o,i,e){var a,u=new Uint8Array(32),p=new Uint8Array(64),b=[r(),r(),r(),r()],K=[r(),r(),r(),r()];if(i<64||hf(K,e))return-1;for(a=0;a<i;a++)t[a]=o[a];for(a=0;a<32;a++)t[a+32]=e[a];if(Ze(p,t,i),lt(p),ut(b,K,p),Hr(K,o.subarray(32)),jr(b,K),xt(u,b),i-=64,me(o,0,u,0)){for(a=0;a<i;a++)t[a]=0;return-1}for(a=0;a<i;a++)t[a]=o[a+64];return i}y(dt,"crypto_sign_open");var gt=32,Gr=24,wr=32,ar=16,Kr=32,Vr=32,Er=32,Ur=32,bt=32,vn=Gr,lf=wr,df=ar,Ve=64,Je=32,sr=64,mt=32,At=64;n.lowlevel={crypto_core_hsalsa20:Ae,crypto_stream_xor:Xe,crypto_stream:Ie,crypto_stream_salsa20_xor:Re,crypto_stream_salsa20:Be,crypto_onetimeauth:ot,crypto_onetimeauth_verify:hn,crypto_verify_16:fe,crypto_verify_32:me,crypto_secretbox:at,crypto_secretbox_open:st,crypto_scalarmult:Or,crypto_scalarmult_base:zr,crypto_box_beforenm:Yr,crypto_box_afternm:An,crypto_box:uf,crypto_box_open:pf,crypto_box_keypair:mn,crypto_hash:Ze,crypto_sign:Un,crypto_sign_keypair:pt,crypto_sign_open:dt,crypto_secretbox_KEYBYTES:gt,crypto_secretbox_NONCEBYTES:Gr,crypto_secretbox_ZEROBYTES:wr,crypto_secretbox_BOXZEROBYTES:ar,crypto_scalarmult_BYTES:Kr,crypto_scalarmult_SCALARBYTES:Vr,crypto_box_PUBLICKEYBYTES:Er,crypto_box_SECRETKEYBYTES:Ur,crypto_box_BEFORENMBYTES:bt,crypto_box_NONCEBYTES:vn,crypto_box_ZEROBYTES:lf,crypto_box_BOXZEROBYTES:df,crypto_sign_BYTES:Ve,crypto_sign_PUBLICKEYBYTES:Je,crypto_sign_SECRETKEYBYTES:sr,crypto_sign_SEEDBYTES:mt,crypto_hash_BYTES:At,gf:r,D:$,L:Fr,pack25519:or,unpack25519:yt,M:Z,A:Oe,S:Me,Z:ze,pow2523:bn,add:jr,set25519:Ge,modL:ht,scalarmult:ut,scalarbase:Hr};function Sn(t,o){if(t.length!==gt)throw new Error("bad key size");if(o.length!==Gr)throw new Error("bad nonce size")}y(Sn,"checkLengths");function gf(t,o){if(t.length!==Er)throw new Error("bad public key size");if(o.length!==Ur)throw new Error("bad secret key size")}y(gf,"checkBoxLengths");function Te(){for(var t=0;t<arguments.length;t++)if(!(arguments[t]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}y(Te,"checkArrayTypes");function _n(t){for(var o=0;o<t.length;o++)t[o]=0}y(_n,"cleanup"),n.randomBytes=function(t){var o=new Uint8Array(t);return f(o,t),o},n.secretbox=function(t,o,i){Te(t,o,i),Sn(i,o);for(var e=new Uint8Array(wr+t.length),a=new Uint8Array(e.length),u=0;u<t.length;u++)e[u+wr]=t[u];return at(a,e,e.length,o,i),a.subarray(ar)},n.secretbox.open=function(t,o,i){Te(t,o,i),Sn(i,o);for(var e=new Uint8Array(ar+t.length),a=new Uint8Array(e.length),u=0;u<t.length;u++)e[u+ar]=t[u];return e.length<32||st(a,e,e.length,o,i)!==0?null:a.subarray(wr)},n.secretbox.keyLength=gt,n.secretbox.nonceLength=Gr,n.secretbox.overheadLength=ar,n.scalarMult=function(t,o){if(Te(t,o),t.length!==Vr)throw new Error("bad n size");if(o.length!==Kr)throw new Error("bad p size");var i=new Uint8Array(Kr);return Or(i,t,o),i},n.scalarMult.base=function(t){if(Te(t),t.length!==Vr)throw new Error("bad n size");var o=new Uint8Array(Kr);return zr(o,t),o},n.scalarMult.scalarLength=Vr,n.scalarMult.groupElementLength=Kr,n.box=function(t,o,i,e){var a=n.box.before(i,e);return n.secretbox(t,o,a)},n.box.before=function(t,o){Te(t,o),gf(t,o);var i=new Uint8Array(bt);return Yr(i,t,o),i},n.box.after=n.secretbox,n.box.open=function(t,o,i,e){var a=n.box.before(i,e);return n.secretbox.open(t,o,a)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var t=new Uint8Array(Er),o=new Uint8Array(Ur);return mn(t,o),{publicKey:t,secretKey:o}},n.box.keyPair.fromSecretKey=function(t){if(Te(t),t.length!==Ur)throw new Error("bad secret key size");var o=new Uint8Array(Er);return zr(o,t),{publicKey:o,secretKey:new Uint8Array(t)}},n.box.publicKeyLength=Er,n.box.secretKeyLength=Ur,n.box.sharedKeyLength=bt,n.box.nonceLength=vn,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(t,o){if(Te(t,o),o.length!==sr)throw new Error("bad secret key size");var i=new Uint8Array(Ve+t.length);return Un(i,t,t.length,o),i},n.sign.open=function(t,o){if(Te(t,o),o.length!==Je)throw new Error("bad public key size");var i=new Uint8Array(t.length),e=dt(i,t,t.length,o);if(e<0)return null;for(var a=new Uint8Array(e),u=0;u<a.length;u++)a[u]=i[u];return a},n.sign.detached=function(t,o){for(var i=n.sign(t,o),e=new Uint8Array(Ve),a=0;a<e.length;a++)e[a]=i[a];return e},n.sign.detached.verify=function(t,o,i){if(Te(t,o,i),o.length!==Ve)throw new Error("bad signature size");if(i.length!==Je)throw new Error("bad public key size");var e=new Uint8Array(Ve+t.length),a=new Uint8Array(Ve+t.length),u;for(u=0;u<Ve;u++)e[u]=o[u];for(u=0;u<t.length;u++)e[u+Ve]=t[u];return dt(a,e,e.length,i)>=0},n.sign.keyPair=function(){var t=new Uint8Array(Je),o=new Uint8Array(sr);return pt(t,o),{publicKey:t,secretKey:o}},n.sign.keyPair.fromSecretKey=function(t){if(Te(t),t.length!==sr)throw new Error("bad secret key size");for(var o=new Uint8Array(Je),i=0;i<o.length;i++)o[i]=t[32+i];return{publicKey:o,secretKey:new Uint8Array(t)}},n.sign.keyPair.fromSeed=function(t){if(Te(t),t.length!==mt)throw new Error("bad seed size");for(var o=new Uint8Array(Je),i=new Uint8Array(sr),e=0;e<32;e++)i[e]=t[e];return pt(o,i,!0),{publicKey:o,secretKey:i}},n.sign.publicKeyLength=Je,n.sign.secretKeyLength=sr,n.sign.seedLength=mt,n.sign.signatureLength=Ve,n.hash=function(t){Te(t);var o=new Uint8Array(At);return Ze(o,t,t.length),o},n.hash.hashLength=At,n.verify=function(t,o){return Te(t,o),t.length===0||o.length===0||t.length!==o.length?!1:W(t,0,o,0,t.length)===0},n.setPRNG=function(t){f=t},(function(){var t=typeof self<"u"?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){var o=65536;n.setPRNG(function(i,e){var a,u=new Uint8Array(e);for(a=0;a<e;a+=o)t.getRandomValues(u.subarray(a,a+Math.min(e-a,o)));for(a=0;a<e;a++)i[a]=u[a];_n(u)})}else typeof Cn<"u"&&(t=of(),t&&t.randomBytes&&n.setPRNG(function(i,e){var a,u=t.randomBytes(e);for(a=0;a<e;a++)i[a]=u[a];_n(u)}))})()})(typeof tt<"u"&&tt.exports?tt.exports:self.nacl=self.nacl||{})});var Sf=globalThis||window||self,te=Sf.crypto;function Sr(n=0){return new Uint8Array(n)}y(Sr,"allocUnsafe");function wt(n,r){r==null&&(r=n.reduce((x,d)=>x+d.length,0));let f=Sr(r),s=0;for(let x of n)f.set(x,s),s+=x.length;return f}y(wt,"concat");var Pt={};Le(Pt,{base10:()=>If});var Ao=new Uint8Array(0);function Pn(n,r){if(n===r)return!0;if(n.byteLength!==r.byteLength)return!1;for(let f=0;f<n.byteLength;f++)if(n[f]!==r[f])return!1;return!0}y(Pn,"equals");function ke(n){if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")}y(ke,"coerce");function Tn(n){return new TextEncoder().encode(n)}y(Tn,"fromString");function Dn(n){return new TextDecoder().decode(n)}y(Dn,"toString");function Cf(n,r){if(n.length>=255)throw new TypeError("Alphabet too long");for(var f=new Uint8Array(256),s=0;s<f.length;s++)f[s]=255;for(var x=0;x<n.length;x++){var d=n.charAt(x),E=d.charCodeAt(0);if(f[E]!==255)throw new TypeError(d+" is ambiguous");f[E]=x}var M=n.length,$=n.charAt(0),le=Math.log(M)/Math.log(256),ie=Math.log(256)/Math.log(M);function pe(W){if(W instanceof Uint8Array||(ArrayBuffer.isView(W)?W=new Uint8Array(W.buffer,W.byteOffset,W.byteLength):Array.isArray(W)&&(W=Uint8Array.from(W))),!(W instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(W.length===0)return"";for(var fe=0,me=0,we=0,Ce=W.length;we!==Ce&&W[we]===0;)we++,fe++;for(var ye=(Ce-we)*ie+1>>>0,Ae=new Uint8Array(ye);we!==Ce;){for(var ge=W[we],Re=0,Be=ye-1;(ge!==0||Re<me)&&Be!==-1;Be--,Re++)ge+=256*Ae[Be]>>>0,Ae[Be]=ge%M>>>0,ge=ge/M>>>0;if(ge!==0)throw new Error("Non-zero carry");me=Re,we++}for(var Ie=ye-me;Ie!==ye&&Ae[Ie]===0;)Ie++;for(var Xe=$.repeat(fe);Ie<ye;++Ie)Xe+=n.charAt(Ae[Ie]);return Xe}y(pe,"encode");function Pe(W){if(typeof W!="string")throw new TypeError("Expected String");if(W.length===0)return new Uint8Array;var fe=0;if(W[fe]!==" "){for(var me=0,we=0;W[fe]===$;)me++,fe++;for(var Ce=(W.length-fe)*le+1>>>0,ye=new Uint8Array(Ce);W[fe];){var Ae=f[W.charCodeAt(fe)];if(Ae===255)return;for(var ge=0,Re=Ce-1;(Ae!==0||ge<we)&&Re!==-1;Re--,ge++)Ae+=M*ye[Re]>>>0,ye[Re]=Ae%256>>>0,Ae=Ae/256>>>0;if(Ae!==0)throw new Error("Non-zero carry");we=ge,fe++}if(W[fe]!==" "){for(var Be=Ce-we;Be!==Ce&&ye[Be]===0;)Be++;for(var Ie=new Uint8Array(me+(Ce-Be)),Xe=me;Be!==Ce;)Ie[Xe++]=ye[Be++];return Ie}}}y(Pe,"decodeUnsafe");function Fe(W){var fe=Pe(W);if(fe)return fe;throw new Error(`Non-${r} character`)}return y(Fe,"decode"),{encode:pe,decodeUnsafe:Pe,decode:Fe}}y(Cf,"base");var Bf=Cf,Pf=Bf,Mn=Pf;var St=class St{constructor(r,f,s){Y(this,"name");Y(this,"prefix");Y(this,"baseEncode");this.name=r,this.prefix=f,this.baseEncode=s}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}};y(St,"Encoder");var Kt=St,_t=class _t{constructor(r,f,s){Y(this,"name");Y(this,"prefix");Y(this,"baseDecode");Y(this,"prefixCodePoint");this.name=r,this.prefix=f;let x=f.codePointAt(0);if(x===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=x,this.baseDecode=s}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return Ln(this,r)}};y(_t,"Decoder");var Et=_t,Ct=class Ct{constructor(r){Y(this,"decoders");this.decoders=r}or(r){return Ln(this,r)}decode(r){let f=r[0],s=this.decoders[f];if(s!=null)return s.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};y(Ct,"ComposedDecoder");var Ut=Ct;function Ln(n,r){return new Ut({...n.decoders??{[n.prefix]:n},...r.decoders??{[r.prefix]:r}})}y(Ln,"or");var Bt=class Bt{constructor(r,f,s,x){Y(this,"name");Y(this,"prefix");Y(this,"baseEncode");Y(this,"baseDecode");Y(this,"encoder");Y(this,"decoder");this.name=r,this.prefix=f,this.baseEncode=s,this.baseDecode=x,this.encoder=new Kt(r,f,s),this.decoder=new Et(r,f,x)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}};y(Bt,"Codec");var vt=Bt;function cr({name:n,prefix:r,encode:f,decode:s}){return new vt(n,r,f,s)}y(cr,"from");function We({name:n,prefix:r,alphabet:f}){let{encode:s,decode:x}=Mn(f,n);return cr({prefix:r,name:n,encode:s,decode:y(d=>ke(x(d)),"decode")})}y(We,"baseX");function Tf(n,r,f,s){let x={};for(let ie=0;ie<r.length;++ie)x[r[ie]]=ie;let d=n.length;for(;n[d-1]==="=";)--d;let E=new Uint8Array(d*f/8|0),M=0,$=0,le=0;for(let ie=0;ie<d;++ie){let pe=x[n[ie]];if(pe===void 0)throw new SyntaxError(`Non-${s} character`);$=$<<f|pe,M+=f,M>=8&&(M-=8,E[le++]=255&$>>M)}if(M>=f||(255&$<<8-M)!==0)throw new SyntaxError("Unexpected end of data");return E}y(Tf,"decode");function Df(n,r,f){let s=r[r.length-1]==="=",x=(1<<f)-1,d="",E=0,M=0;for(let $=0;$<n.length;++$)for(M=M<<8|n[$],E+=8;E>f;)E-=f,d+=r[x&M>>E];if(E!==0&&(d+=r[x&M<<f-E]),s)for(;(d.length*f&7)!==0;)d+="=";return d}y(Df,"encode");function ce({name:n,prefix:r,bitsPerChar:f,alphabet:s}){return cr({prefix:r,name:n,encode(x){return Df(x,s,f)},decode(x){return Tf(x,s,f,n)}})}y(ce,"rfc4648");var If=We({prefix:"9",name:"base10",alphabet:"0123456789"});var Tt={};Le(Tt,{base16:()=>Mf,base16upper:()=>Lf});var Mf=ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Lf=ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Dt={};Le(Dt,{base2:()=>Nf});var Nf=ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var It={};Le(It,{base256emoji:()=>jf});var Nn=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Rf=Nn.reduce((n,r,f)=>(n[f]=r,n),[]),Of=Nn.reduce((n,r,f)=>{let s=r.codePointAt(0);if(s==null)throw new Error(`Invalid character: ${r}`);return n[s]=f,n},[]);function zf(n){return n.reduce((r,f)=>(r+=Rf[f],r),"")}y(zf,"encode");function Yf(n){let r=[];for(let f of n){let s=f.codePointAt(0);if(s==null)throw new Error(`Invalid character: ${f}`);let x=Of[s];if(x==null)throw new Error(`Non-base256emoji character: ${f}`);r.push(x)}return new Uint8Array(r)}y(Yf,"decode");var jf=cr({prefix:"\u{1F680}",name:"base256emoji",encode:zf,decode:Yf});var Mt={};Le(Mt,{base32:()=>yr,base32hex:()=>Vf,base32hexpad:()=>Xf,base32hexpadupper:()=>Wf,base32hexupper:()=>kf,base32pad:()=>Ff,base32padupper:()=>Gf,base32upper:()=>Hf,base32z:()=>$f});var yr=ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Hf=ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ff=ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gf=ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vf=ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kf=ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xf=ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Wf=ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),$f=ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Lt={};Le(Lt,{base36:()=>_r,base36upper:()=>Zf});var _r=We({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zf=We({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Nt={};Le(Nt,{base58btc:()=>He,base58flickr:()=>Jf});var He=We({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Jf=We({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Rt={};Le(Rt,{base64:()=>qf,base64pad:()=>Qf,base64url:()=>ei,base64urlpad:()=>ri});var qf=ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qf=ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ei=ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ri=ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ot={};Le(Ot,{base8:()=>ti});var ti=ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zt={};Le(zt,{identity:()=>ni});var ni=cr({prefix:"\0",name:"identity",encode:y(n=>Dn(n),"encode"),decode:y(n=>Tn(n),"decode")});var jo=new TextEncoder,Ho=new TextDecoder;var Ht={};Le(Ht,{identity:()=>Si});var oi=zn,Rn=128,ai=127,si=~ai,ci=Math.pow(2,31);function zn(n,r,f){r=r||[],f=f||0;for(var s=f;n>=ci;)r[f++]=n&255|Rn,n/=128;for(;n&si;)r[f++]=n&255|Rn,n>>>=7;return r[f]=n|0,zn.bytes=f-s+1,r}y(zn,"encode");var yi=Yt,xi=128,On=127;function Yt(n,s){var f=0,s=s||0,x=0,d=s,E,M=n.length;do{if(d>=M)throw Yt.bytes=0,new RangeError("Could not decode varint");E=n[d++],f+=x<28?(E&On)<<x:(E&On)*Math.pow(2,x),x+=7}while(E>=xi);return Yt.bytes=d-s,f}y(Yt,"read");var ui=Math.pow(2,7),pi=Math.pow(2,14),hi=Math.pow(2,21),li=Math.pow(2,28),di=Math.pow(2,35),gi=Math.pow(2,42),bi=Math.pow(2,49),mi=Math.pow(2,56),Ai=Math.pow(2,63),wi=y(function(n){return n<ui?1:n<pi?2:n<hi?3:n<li?4:n<di?5:n<gi?6:n<bi?7:n<mi?8:n<Ai?9:10},"length"),Ki={encode:oi,decode:yi,encodingLength:wi},Ei=Ki,Cr=Ei;function Br(n,r=0){return[Cr.decode(n,r),Cr.decode.bytes]}y(Br,"decode");function xr(n,r,f=0){return Cr.encode(n,r,f),r}y(xr,"encodeTo");function ur(n){return Cr.encodingLength(n)}y(ur,"encodingLength");function qe(n,r){let f=r.byteLength,s=ur(n),x=s+ur(f),d=new Uint8Array(x+f);return xr(n,d,0),xr(f,d,s),d.set(r,x),new pr(n,f,r,d)}y(qe,"create");function Yn(n){let r=ke(n),[f,s]=Br(r),[x,d]=Br(r.subarray(s)),E=r.subarray(s+d);if(E.byteLength!==x)throw new Error("Incorrect length");return new pr(f,x,E,r)}y(Yn,"decode");function jn(n,r){if(n===r)return!0;{let f=r;return n.code===f.code&&n.size===f.size&&f.bytes instanceof Uint8Array&&Pn(n.bytes,f.bytes)}}y(jn,"equals");var jt=class jt{constructor(r,f,s,x){Y(this,"code");Y(this,"size");Y(this,"digest");Y(this,"bytes");this.code=r,this.size=f,this.digest=s,this.bytes=x}};y(jt,"Digest");var pr=jt;var Hn=0,Ui="identity",Fn=ke;function vi(n){return qe(Hn,Fn(n))}y(vi,"digest");var Si={code:Hn,name:Ui,encode:Fn,digest:vi};var kt={};Le(kt,{sha256:()=>_i,sha512:()=>Ci});function Gt({name:n,code:r,encode:f}){return new Ft(n,r,f)}y(Gt,"from");var Vt=class Vt{constructor(r,f,s){Y(this,"name");Y(this,"code");Y(this,"encode");this.name=r,this.code=f,this.encode=s}digest(r){if(r instanceof Uint8Array){let f=this.encode(r);return f instanceof Uint8Array?qe(this.code,f):f.then(s=>qe(this.code,s))}else throw Error("Unknown type, must be binary type")}};y(Vt,"Hasher");var Ft=Vt;function Vn(n){return async r=>new Uint8Array(await crypto.subtle.digest(n,r))}y(Vn,"sha");var _i=Gt({name:"sha2-256",code:18,encode:Vn("SHA-256")}),Ci=Gt({name:"sha2-512",code:19,encode:Vn("SHA-512")});function kn(n,r){let{bytes:f,version:s}=n;switch(s){case 0:return Pi(f,Xt(n),r??He.encoder);default:return Ti(f,Xt(n),r??yr.encoder)}}y(kn,"format");var Xn=new WeakMap;function Xt(n){let r=Xn.get(n);if(r==null){let f=new Map;return Xn.set(n,f),f}return r}y(Xt,"baseCache");var $n,be=class be{constructor(r,f,s,x){Y(this,"code");Y(this,"version");Y(this,"multihash");Y(this,"bytes");Y(this,"/");Y(this,$n,"CID");this.code=f,this.version=r,this.multihash=s,this.bytes=x,this["/"]=x}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:r,multihash:f}=this;if(r!==Tr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(f.code!==Di)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return be.createV0(f)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:r,digest:f}=this.multihash,s=qe(r,f);return be.createV1(this.code,s)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(r){return be.equals(this,r)}static equals(r,f){let s=f;return s!=null&&r.code===s.code&&r.version===s.version&&jn(r.multihash,s.multihash)}toString(r){return kn(this,r)}toJSON(){return{"/":kn(this)}}link(){return this}[($n=Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"))](){return`CID(${this.toString()})`}static asCID(r){if(r==null)return null;let f=r;if(f instanceof be)return f;if(f["/"]!=null&&f["/"]===f.bytes||f.asCID===f){let{version:s,code:x,multihash:d,bytes:E}=f;return new be(s,x,d,E??Wn(s,x,d.bytes))}else if(f[Ii]===!0){let{version:s,multihash:x,code:d}=f,E=Yn(x);return be.create(s,d,E)}else return null}static create(r,f,s){if(typeof f!="number")throw new Error("String codecs are no longer supported");if(!(s.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(r){case 0:{if(f!==Tr)throw new Error(`Version 0 CID must use dag-pb (code: ${Tr}) block encoding`);return new be(r,f,s,s.bytes)}case 1:{let x=Wn(r,f,s.bytes);return new be(r,f,s,x)}default:throw new Error("Invalid version")}}static createV0(r){return be.create(0,Tr,r)}static createV1(r,f){return be.create(1,r,f)}static decode(r){let[f,s]=be.decodeFirst(r);if(s.length!==0)throw new Error("Incorrect length");return f}static decodeFirst(r){let f=be.inspectBytes(r),s=f.size-f.multihashSize,x=ke(r.subarray(s,s+f.multihashSize));if(x.byteLength!==f.multihashSize)throw new Error("Incorrect length");let d=x.subarray(f.multihashSize-f.digestSize),E=new pr(f.multihashCode,f.digestSize,d,x);return[f.version===0?be.createV0(E):be.createV1(f.codec,E),r.subarray(f.size)]}static inspectBytes(r){let f=0,s=y(()=>{let[pe,Pe]=Br(r.subarray(f));return f+=Pe,pe},"next"),x=s(),d=Tr;if(x===18?(x=0,f=0):d=s(),x!==0&&x!==1)throw new RangeError(`Invalid CID version ${x}`);let E=f,M=s(),$=s(),le=f+$,ie=le-E;return{version:x,codec:d,multihashCode:M,digestSize:$,multihashSize:ie,size:le}}static parse(r,f){let[s,x]=Bi(r,f),d=be.decode(x);if(d.version===0&&r[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Xt(d).set(s,r),d}};y(be,"CID");var Xr=be;function Bi(n,r){switch(n[0]){case"Q":{let f=r??He;return[He.prefix,f.decode(`${He.prefix}${n}`)]}case He.prefix:{let f=r??He;return[He.prefix,f.decode(n)]}case yr.prefix:{let f=r??yr;return[yr.prefix,f.decode(n)]}case _r.prefix:{let f=r??_r;return[_r.prefix,f.decode(n)]}default:{if(r==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[n[0],r.decode(n)]}}}y(Bi,"parseCIDtoBytes");function Pi(n,r,f){let{prefix:s}=f;if(s!==He.prefix)throw Error(`Cannot string encode V0 in ${f.name} encoding`);let x=r.get(s);if(x==null){let d=f.encode(n).slice(1);return r.set(s,d),d}else return x}y(Pi,"toStringV0");function Ti(n,r,f){let{prefix:s}=f,x=r.get(s);if(x==null){let d=f.encode(n);return r.set(s,d),d}else return x}y(Ti,"toStringV1");var Tr=112,Di=18;function Wn(n,r,f){let s=ur(n),x=s+ur(r),d=new Uint8Array(x+f.byteLength);return xr(n,d,0),xr(r,d,s),d.set(f,x),d}y(Wn,"encodeCID");var Ii=Symbol.for("@ipld/js-cid/CID");var Wt={...zt,...Dt,...Ot,...Pt,...Tt,...Mt,...Lt,...Nt,...Rt,...It},ma={...kt,...Ht};function Jn(n,r,f,s){return{name:n,prefix:r,encoder:{name:n,prefix:r,encode:f},decoder:{decode:s}}}y(Jn,"createCodec");var Zn=Jn("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>new TextEncoder().encode(n.substring(1))),$t=Jn("ascii","a",n=>{let r="a";for(let f=0;f<n.length;f++)r+=String.fromCharCode(n[f]);return r},n=>{n=n.substring(1);let r=Sr(n.length);for(let f=0;f<n.length;f++)r[f]=n.charCodeAt(f);return r}),Mi={utf8:Zn,"utf-8":Zn,hex:Wt.base16,latin1:$t,ascii:$t,binary:$t,...Wt},Wr=Mi;function ve(n,r="utf8"){let f=Wr[r];if(f==null)throw new Error(`Unsupported encoding "${r}"`);return f.decoder.decode(`${f.prefix}${n}`)}y(ve,"fromString");function ue(n,r="utf8"){let f=Wr[r];if(f==null)throw new Error(`Unsupported encoding "${r}"`);return f.encoder.encode(n).substring(1)}y(ue,"toString");var Qe="did:key:z",hr="Ed25519",$r="X25519",Va="X25519",er=32;var lr="RSA-OAEP",dr="RSASSA-PKCS1-v1_5",Zt="SHA-256",Jt=new Uint8Array([0,245,2]),ka=2048,qt="SHA-256",gr=8,br="AES-GCM",Ne=br,rr=256,Ye=12,Qt=new Uint8Array([234,1]),en=new Uint8Array([237,1]),Zr={RSA:"rsa",Edwards:"ed25519",BLS:"bls12-381"};var Jr="ecc-exchange",qr="ecc-write",_e=16;var qn=new Error("Invalid key use. Please use 'encryption' or 'signing"),Ri=new Error("Max must be less than 256 and greater than 0");function he(n){return new Uint8Array(n).buffer}y(he,"toArrayBuffer");async function Qn(n){return new Uint8Array(await te.subtle.digest("sha-256",n.buffer))}y(Qn,"sha256");function je(n){let r=ve(n,"base64pad");return he(r)}y(je,"base64ToArrBuf");var Ir=y((n,r)=>{if(typeof n=="string")return r(n);if(typeof n=="object"&&n.byteLength!==void 0)return new Uint8Array(n).buffer;throw new Error("Improper value. Must be a string, ArrayBuffer, Uint8Array")},"normalizeToBuf");function Qr(n){return Ir(n,je)}y(Qr,"normalizeBase64ToBuf");var Oi=y(n=>Ir(n,r=>ef(r,8)),"normalizeUtf8ToBuf");function ef(n,r){let f=r===8?new Uint8Array(n.length):new Uint16Array(n.length);for(let s=0,x=n.length;s<x;s++)f[s]=n.charCodeAt(s);return f.buffer}y(ef,"strToArrBuf");var zi=y(n=>Ir(n,r=>ef(r,16)),"normalizeUtf16ToBuf");function mr(n,r){switch(r){case 8:return Oi(n);default:return zi(n)}}y(mr,"normalizeUnicodeToBuf");function rf(n){if(!n.startsWith(Qe))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let r=""+n.substring(Qe.length),f=ve(r,"base58btc"),{keyBuffer:s,type:x}=Yi(he(f));return{publicKey:new Uint8Array(s),type:x}}y(rf,"didToPublicKey");function Yi(n){if(Dr(n,he(Jt)))return{keyBuffer:n.slice(Jt.byteLength),type:Zr.RSA};if(Dr(n,he(en)))return{keyBuffer:n.slice(en.byteLength),type:Zr.Edwards};if(Dr(n,he(Qt)))return{keyBuffer:n.slice(Qt.byteLength),type:Zr.BLS};throw new Error("Unsupported key algorithm. Try using RSA.")}y(Yi,"parseMagicBytes");var ji={equal:y((n,r)=>{let f=new Uint8Array(n),s=new Uint8Array(r);if(f.length!==s.length)return!1;for(let x=0;x<f.length;x++)if(f[x]!==s[x])return!1;return!0},"equal")};function Dr(n,r){return ji.equal(r,n.slice(0,r.byteLength))}y(Dr,"hasPrefix");function De(n){return ue(n instanceof ArrayBuffer?new Uint8Array(n):n,"base64pad")}y(De,"toBase64");async function tn(n,r){let f=typeof n=="string"?je(n):he(n);return te.subtle.importKey("raw",f,{name:r?.alg||Ne,length:r?.length||rr},!0,["encrypt","decrypt"])}y(tn,"importKey");function tf(n,{max:r}={max:255}){if(r<1||r>255)throw Ri;let f=new Uint8Array(n);if(r===255)return te.getRandomValues(f),f.buffer;let s=0,x=r+1,d=Math.floor(256/x)*x,E=new Uint8Array(1);for(;s<f.length;)te.getRandomValues(E),E[0]<d&&(f[s]=E[0]%x,s++);return f.buffer}y(tf,"randomBuf");function et(n,r){let f=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(he(n)),s=r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(he(r)),x=new Uint8Array(f.length+s.length);return x.set(f),x.set(s,f.length),x.buffer}y(et,"joinBufs");var ns=new Error("Key does not exist. Make sure you properly instantiated the keystore."),fs=new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name."),is=new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name."),os=new Error("ECC is not enabled for this browser. Please use RSA instead."),as=new Error("Cryptosystem not supported. Please use ECC or RSA"),Hi=new Error("Invalid key use. Please use 'exchange' or 'write'"),ss=new Error("Max must be less than 256 and greater than 0");function nf(n){Fi(n,["exchange","write","signing"],Hi)}y(nf,"checkValidKeyUse");function Fi(n,r,f){if(!r.some(x=>x===n))throw f}y(Fi,"checkValid");function rt(n){return new Promise((r,f)=>{n.oncomplete=n.onsuccess=()=>r(n.result),n.onabort=n.onerror=()=>f(n.error)})}y(rt,"promisifyRequest");function Gi(n,r){let f,s=y(()=>{if(f)return f;let x=indexedDB.open(n);return x.onupgradeneeded=()=>x.result.createObjectStore(r),f=rt(x),f.then(d=>{d.onclose=()=>f=void 0},()=>{}),f},"getDB");return(x,d)=>s().then(E=>d(E.transaction(r,x).objectStore(r)))}y(Gi,"createStore");var nn;function fn(){return nn||(nn=Gi("keyval-store","keyval")),nn}y(fn,"defaultGetStore");function Mr(n,r=fn()){return r("readonly",f=>rt(f.get(n)))}y(Mr,"get");function on(n,r,f=fn()){return f("readwrite",s=>(s.put(r,n),rt(s.transaction)))}y(on,"set");function ff(n,r=fn()){return r("readwrite",f=>(n.forEach(s=>f.delete(s)),rt(f.transaction)))}y(ff,"delMany");var sf=vf(af(),1);var cn={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:y(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:ki},ed25519:{magicBytes:new Uint8Array([237,1]),verify:Vi}}};async function Vi({message:n,publicKey:r,signature:f}){let s=n;typeof n=="string"&&(s=ve(n,"utf8"));let x=f;typeof f=="string"&&(x=ve(f,"base64pad"));let d=r;if(typeof r=="string"&&(d=cf(r).publicKey),d.length!==32)throw new Error(`Invalid Ed25519 public key size: ${d.length} bytes, expected 32`);if(x.length!==64)throw new Error(`Invalid Ed25519 signature size: ${x.length} bytes, expected 64`);return sf.default.sign.detached.verify(s,x,d)}y(Vi,"ed25519Verify");async function ki({message:n,publicKey:r,signature:f}){let s=r;return typeof r=="string"&&(s=cf(r).publicKey),yn.verify(n,f,await te.subtle.importKey("spki",he(s),{name:dr,hash:Zt},!1,["verify"]),8)}y(ki,"rsaVerify");var yn={verify:y(async function(r,f,s,x=gr,d=qt){return te.subtle.verify({name:dr,saltLength:_e},typeof s=="string"?await an(s,d,"signing"):s,Qr(f),mr(r,x))},"rsaVerify"),sign:y(async function(r,f,s=gr){return te.subtle.sign({name:dr,saltLength:_e},f,mr(r,s))},"sign"),encrypt:y(async function(r,f,s=gr,x=qt){let d;return typeof f=="string"?d=await an(f,x,"exchange"):d=f instanceof Uint8Array?await an(he(f),x,"exchange"):f,te.subtle.encrypt({name:lr},d,mr(r,s))},"rsaEncrypt"),decrypt:y(async function(r,f){let s=nt(f)?f:await Zi(f,["decrypt"]),x;typeof r=="string"?x=ve(r,"base64pad"):x=r;let d=await te.subtle.decrypt({name:lr},s,x instanceof Uint8Array?he(x):x);return new Uint8Array(d)},"rsaDecrypt")};async function an(n,r,f){Xi(f);let s=f==="exchange"?lr:dr,x=f==="exchange"?["encrypt"]:["verify"],d=typeof n=="string"?je($i(n)):n;return te.subtle.importKey("spki",d,{name:s,hash:{name:r}},!0,x)}y(an,"rsaImportPublicKey");function Xi(n){Wi(n,["signing","exchange"],qn)}y(Xi,"checkValidKeyUse");function Wi(n,r,f){if(!r.some(x=>x===n))throw f}y(Wi,"checkValid");function $i(n){return n.replace(`-----BEGIN PUBLIC KEY-----
|
|
2
2
|
`,"").replace(`
|
|
3
|
-
-----END PUBLIC KEY-----`,"")}y($i,"stripKeyHeader");function nt(n){return sn(n,"algorithm")&&sn(n,"extractable")&&sn(n,"type")}y(nt,"isCryptoKey");function sn(n,r){return typeof n=="object"&&n!=null&&r in n}y(sn,"hasProp");function Zi(n,r){return te.subtle.importKey("spki",n instanceof Uint8Array?he(n):n,{name:lr,hash:Zt},!1,r)}y(Zi,"importRsaKey");async function xn(n,r="rsa"){let f=n instanceof CryptoKey?new Uint8Array(await Ar(n)):n;n instanceof CryptoKey&&(r=n.algorithm.name.includes("RSA")?"rsa":"ed25519");let s=cn.keyTypes[r]?.magicBytes;if(!s)throw new Error(`Key type '${r}' not supported, available types: ${Object.keys(cn.keyTypes).join(", ")}`);let x=wt([s,f]);return Qe+ue(x,"base58btc")}y(xn,"publicKeyToDid");async function Ar(n){return n instanceof CryptoKey?await te.subtle.exportKey("spki",n):await te.subtle.exportKey("spki",n.publicKey)}y(Ar,"getPublicKeyAsArrayBuffer");function cf(n){if(!n.startsWith(Qe))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let r=n.substring(Qe.length),f=ve(r,"base58btc"),s=Object.entries(cn.keyTypes).find(([d,v])=>Ir(f.buffer,v.magicBytes.buffer));if(!s)throw new Error("Unsupported key algorithm.");let x=f.slice(s[1].magicBytes.length);return s[0]==="ed25519"&&x.length===44?{publicKey:x.slice(-32),type:s[0]}:{publicKey:x,type:s[0]}}y(cf,"didToPublicKey");var tr={create(n={alg:Ne,length:rr}){let r=n.length||rr,f=n.alg||Ne;return te.subtle.generateKey({name:f,length:r},!0,["encrypt","decrypt"])},export:Object.assign(async n=>{let r=await te.subtle.exportKey("raw",n);return new Uint8Array(r)},{asString:y(async(n,r)=>{let f=await tr.export(n);return r?ue(f,r):De(f)},"asString")}),import(n){return un(typeof n=="string"?je(n):n)},async exportAsString(n){let r=await tr.export(n);return De(r)},encrypt:Ji,async decrypt(n,r,f){let s=nt(r)?r:await un(r),x=f?await te.subtle.decrypt({name:br,iv:he(f)},s,typeof n=="string"?he(ve(n)):n instanceof Uint8Array?he(n):n):await Qi(n,s);return new Uint8Array(x)}};function un(n,r){return te.subtle.importKey("raw",n instanceof Uint8Array?he(n):n,{name:br,length:r||256},!0,["encrypt","decrypt"])}y(un,"importAesKey");async function Ji(n,r,f,s){let x=nt(r)?r:await un(r),d=s?await te.subtle.encrypt({name:br,iv:he(s)},x,n instanceof ArrayBuffer?n:he(typeof n=="string"?ve(n):n)):await qi(n,x);return f&&f==="arraybuffer"?d:new Uint8Array(d)}y(Ji,"encrypt");async function qi(n,r,f){let s=mr(n,f?.charsize??gr),x=typeof r=="string"?await tn(r,f):r,d=f?.iv||tf(Ye),v=await te.subtle.encrypt({name:br,iv:d},x,s);return et(d,v)}y(qi,"encryptBytes");async function Qi(n,r,f){let s=Qr(n),x=typeof r=="string"?await tn(r,f):r,d=s.slice(0,Ye),v=s.slice(Ye);return await te.subtle.decrypt({name:Ne,iv:d},x,v)}y(Qi,"decryptBytes");var $e=class $e{constructor(r){Y(this,"DID");Y(this,"exchangeKey");Y(this,"writeKey");Y(this,"hasPersisted");Y(this,"isSessionOnly");let{keys:f}=r;this.DID=r.did,this.exchangeKey=f.exchange,this.writeKey=f.write,this.hasPersisted=r.hasPersisted,this.isSessionOnly=!!r.isSessionOnly}publicExchangeKeyAsString(r){return this.publicExchangeKey.asString(r)}publicWriteKeyAsString(r){return this.publicWriteKey.asString(r)}get publicWriteKey(){let r=this.writeKey.publicKey;return Object.assign(r,{asString:y(async f=>{let s=await Ar(this.writeKey),x=new Uint8Array(s);return f?ue(x,f):De(x)},"asString")})}get publicExchangeKey(){let r=this.exchangeKey.publicKey;return Object.assign(r,{asString:y(async f=>{let s=await Ar(this.exchangeKey),x=new Uint8Array(s);return f?ue(x,f):De(x)},"asString")})}get privateWriteKey(){return this.writeKey.privateKey}get privateExchangeKey(){return this.exchangeKey.privateKey}get deviceName(){return $e.deviceName(this.DID)}static deviceName(r){return eo(r)}async persist(){if(this.isSessionOnly)return;let r=this.constructor.EXCHANGE_KEY_NAME,f=this.constructor.WRITE_KEY_NAME;await Promise.all([on(r,this.exchangeKey),on(f,this.writeKey)]),this.hasPersisted=!0}async delete(){await ff([this.constructor.EXCHANGE_KEY_NAME,this.constructor.WRITE_KEY_NAME]),this.hasPersisted=!1}async getDeviceName(){return $e.deviceName(this.DID)}static _createExchangeKeys(r){throw new Error("The child should implement this")}static _createWriteKeys(r){throw new Error("The child should implement this")}static async create(r,f,s){let x=s?.exchangeKeys||await this._createExchangeKeys(f),d=s?.writeKeys||await this._createWriteKeys(f),v=await Ar(d),M=await xn(new Uint8Array(v),this.TYPE==="ecc"?"ed25519":"rsa"),$=new this({keys:{exchange:x,write:d},did:M,hasPersisted:!1,isSessionOnly:!!r});return this._instance=$,$}static async exist(r={}){let f=await Lr(r.writeKeyName||this.WRITE_KEY_NAME),s=await Lr(r.encryptionKeyName||this.EXCHANGE_KEY_NAME);return!(!f||!s)}static async load(r={session:!1}){if(this._instance)return this._instance;let f=!0,s=await Lr(r.encryptionKeyName||this.EXCHANGE_KEY_NAME),x=await Lr(r.writeKeyName||this.WRITE_KEY_NAME);s||(f=!1,s=await this._createExchangeKeys(r.extractable)),x||(f=!1,x=await this._createWriteKeys(r.extractable));let d=await Ar(x),v=await xn(new Uint8Array(d),this.TYPE==="ecc"?"ed25519":"rsa"),M=new this({keys:{exchange:s,write:x},did:v,hasPersisted:f,isSessionOnly:!!r.session});return this._instance=M,M}};y($e,"AbstractKeys"),Y($e,"EXCHANGE_KEY_NAME"),Y($e,"WRITE_KEY_NAME"),Y($e,"_instance");var ft=$e;async function yf(n,r){let{content:f,publicKey:s}=n,x=r||await tr.create(),d=await tr.encrypt(typeof f=="string"?ve(f):f,typeof x=="string"?await tr.import(x):x),v=await pn({key:x,publicKey:s});return et(v,d)}y(yf,"encryptTo");yf.asString=async function(n,r){let f=await yf(n,r);return ue(new Uint8Array(f),"base64pad")};async function pn({key:n,publicKey:r},f){let s;n instanceof CryptoKey?s=await tr.export(n):s=n;let x=await yn.encrypt(s,r);return f&&f==="arraybuffer"?x:new Uint8Array(x)}y(pn,"encryptKeyTo");pn.asString=async function({key:n,publicKey:r},f){let s=await pn({key:n,publicKey:r});return f?ue(s,f):De(s)};async function eo(n){let r=await Qn(new TextEncoder().encode(n.normalize("NFD")));return ue(r,"base32").slice(0,32)}y(eo,"getDeviceName");function nr(n){return new Uint8Array(n).buffer}y(nr,"toArrayBuffer");var Se=class Se extends ft{static async create(r,f,s){return await super.create(r,f,s)}constructor(r){super(r),Se.EXCHANGE_KEY_NAME=r.exchangeKeyName||Jr,Se.WRITE_KEY_NAME=r.writeKeyName||qr}get publicExchangeKey(){let r=this.exchangeKey.publicKey;return Object.assign(r,{asString:y(async f=>{let s=await Nr(this.exchangeKey),x=new Uint8Array(s);return f?ue(x,f):De(s)},"asString")})}get publicWriteKey(){let r=this.writeKey.publicKey;return Object.assign(r,{asString:y(async f=>{let s=await Nr(this.writeKey),x=new Uint8Array(s);return f?ue(x,f):De(s)},"asString")})}static async _createExchangeKeys(r=!1){return await te.subtle.generateKey({name:$r},r,["deriveKey","deriveBits"])}static async _createWriteKeys(r=!1){return await te.subtle.generateKey({name:hr},r,["sign","verify"])}static async load(r={session:!1}){if(this._instance)return this._instance;let f=r.encryptionKeyName||Jr,s=r.writeKeyName||qr;return super.load({...r,encryptionKeyName:f,writeKeyName:s})}async toJson(r){let f=this.DID,s=await Nr(this.exchangeKey);return{publicExchangeKey:r?ue(new Uint8Array(s),r):De(s),DID:f}}async wrap(r,f,s){let x=await Se._createExchangeKeys(!0),d=crypto.getRandomValues(new Uint8Array(_e)),v=await wr(x.privateKey,f,d,s||"key-wrap"),M;if(r instanceof CryptoKey){let me=await crypto.subtle.exportKey("raw",r);M=new Uint8Array(me)}else typeof r=="string"?M=ve(r,"base64pad"):M=r;let $=crypto.getRandomValues(new Uint8Array(Ye)),le=await crypto.subtle.encrypt({name:Ne,iv:$},v,nr(M)),ie=await Nr(x),pe=new Uint8Array(d),Pe=new Uint8Array($),Fe=new Uint8Array(le),W=pe.length+Pe.length+Fe.length,fe=new Uint8Array(W);return fe.set(pe,0),fe.set(Pe,pe.length),fe.set(Fe,pe.length+Pe.length),{enc:De(new Uint8Array(ie)),wrappedKey:De(fe)}}async unwrap(r,f,s){let x=await it(r,"X25519","exchange"),d=new Uint8Array(je(f)),v=d.slice(0,_e),M=d.slice(_e,_e+Ye),$=d.slice(_e+Ye),le=await wr(this.exchangeKey.privateKey,x,v,s||"key-wrap"),ie=await crypto.subtle.decrypt({name:Ne,iv:M},le,nr($));return await crypto.subtle.importKey("raw",ie,{name:Ne},!0,["encrypt","decrypt"])}async encrypt(r,f,s,x,d){let v=crypto.getRandomValues(new Uint8Array(_e)),M=f||this.exchangeKey.publicKey,$;typeof M=="string"?$=await it(M,"X25519","exchange"):$=M;let le=await Se._createExchangeKeys(!0),ie=x||await wr(le.privateKey,$,v,s||Se.INFO,d);ie instanceof CryptoKey||(ie=await wr(le.privateKey,$,v,s||Se.INFO));let pe=crypto.getRandomValues(new Uint8Array(Ye)),Pe=typeof r=="string"?new TextEncoder().encode(r):r,Fe=await crypto.subtle.encrypt({name:Ne,iv:pe},ie,nr(Pe)),W=new Uint8Array(await Nr(le)),fe=new Uint8Array(v),me=new Uint8Array(pe),we=new Uint8Array(Fe),Ce=W.length+fe.length+me.length+we.length,ye=new Uint8Array(Ce);return ye.set(W,0),ye.set(fe,W.length),ye.set(me,W.length+fe.length),ye.set(we,W.length+fe.length+me.length),ye}async encryptAsString(r,f,s,x,d){let v=await this.encrypt(r,f,s||Se.INFO,x,d);return ue(new Uint8Array(v),"base64pad")}async decrypt(r,f,s){let x=Mr(r,je),d=x.slice(0,er),v=await te.subtle.importKey("raw",d,{name:$r},!0,[]),M=x.slice(er,er+_e),$=x.slice(er+_e,er+_e+Ye),le=x.slice(er+_e+Ye),{privateKey:ie}=this.exchangeKey,pe=await wr(ie,v,M,s||Se.INFO);return await crypto.subtle.decrypt({name:f||Ne,iv:$},pe,le)}async decryptAsString(r,f,s){let x=await this.decrypt(r,f,s);return ue(new Uint8Array(x))}async getAesKey(r,f){r||(r=this.publicExchangeKey);let s;typeof r=="string"?s=await it(r,"X25519","exchange"):s=r;let x=crypto.getRandomValues(new Uint8Array(_e));return await wr(this.exchangeKey.privateKey,s,x,f||Se.INFO)}async sign(r,f){let s=new TextEncoder,x;typeof r=="string"?x=s.encode(r):r instanceof ArrayBuffer?x=new Uint8Array(r):x=r;let d=await te.subtle.sign({name:hr},this.writeKey.privateKey,nr(x));return new Uint8Array(d)}async signAsString(r,f){let s=await this.sign(r,f);return ue(s,"base64pad")}};y(Se,"EccKeys"),Y(Se,"TYPE","ecc"),Y(Se,"EXCHANGE_KEY_NAME",Jr),Y(Se,"WRITE_KEY_NAME",qr),Y(Se,"INFO","keys");var fr=Se;Object.assign(fr.prototype.sign,{asString:y(async function(n,r){let f=await this.sign(n,r);return ue(f,"base64pad")},"asString")});async function Nr(n,r="raw"){return await crypto.subtle.exportKey(r,n.publicKey)}y(Nr,"exportPublicKey");async function it(n,r,f){nf(f);let s=f==="exchange"?$r:hr,x=f==="exchange"?[]:["verify"],d=je(n),v=r==="X25519"?{name:s}:{name:s,namedCurve:r};return te.subtle.importKey("raw",d,v,!0,x)}y(it,"importPublicKey");var Zs={EccKeys:fr,importPublicKey:it};Object.assign(fr.prototype.encrypt,{asString:y(async function(n,r,f,s,x){return this.encryptAsString(n,r,f,s,x)},"asString")});Object.assign(fr.prototype.decrypt,{asString:y(async function(n,r){return this.decryptAsString(n,r)},"asString")});Object.assign(fr.prototype.sign,{asString:y(async function(n,r){return this.signAsString(n,r)},"asString")});async function Js(n,r,f){try{let s=rf(f);if(s.type!=="ed25519")throw new Error(`Expected Ed25519 key for ECC verification, got ${s.type}`);let x=s.publicKey.slice(-32),d=await te.subtle.importKey("raw",x,{name:hr},!0,["verify"]),v=new TextEncoder,M;typeof n=="string"?M=v.encode(n):n instanceof ArrayBuffer?M=new Uint8Array(n):M=n;let $;return typeof r=="string"?$=new Uint8Array(je(r)):$=r,await te.subtle.verify({name:hr},d,nr($),nr(M))}catch{return!1}}y(Js,"verify");async function wr(n,r,f,s,x){let d=new TextEncoder,v=await crypto.subtle.deriveBits({name:"X25519",public:r},n,256),M=await crypto.subtle.importKey("raw",v,"HKDF",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:f instanceof Uint8Array?nr(f):f,info:d.encode(s)},M,{name:"AES-GCM",length:x||rr},!1,["encrypt","decrypt"])}y(wr,"deriveKey");export{fr as EccKeys,Zs as default,Nr as exportPublicKey,it as importPublicKey,Js as verify};
|
|
3
|
+
-----END PUBLIC KEY-----`,"")}y($i,"stripKeyHeader");function nt(n){return sn(n,"algorithm")&&sn(n,"extractable")&&sn(n,"type")}y(nt,"isCryptoKey");function sn(n,r){return typeof n=="object"&&n!=null&&r in n}y(sn,"hasProp");function Zi(n,r){return te.subtle.importKey("spki",n instanceof Uint8Array?he(n):n,{name:lr,hash:Zt},!1,r)}y(Zi,"importRsaKey");async function xn(n,r="rsa"){let f;if(n instanceof CryptoKey){r=n.algorithm.name.includes("RSA")?"rsa":"ed25519";let d=r==="ed25519"?"raw":"spki",E=await te.subtle.exportKey(d,n);f=new Uint8Array(E)}else f=n;let s=cn.keyTypes[r]?.magicBytes;if(!s)throw new Error(`Key type '${r}' not supported, available types: ${Object.keys(cn.keyTypes).join(", ")}`);let x=wt([s,f]);return Qe+ue(x,"base58btc")}y(xn,"publicKeyToDid");async function Lr(n){return n instanceof CryptoKey?await te.subtle.exportKey("spki",n):await te.subtle.exportKey("spki",n.publicKey)}y(Lr,"getPublicKeyAsArrayBuffer");function cf(n){if(!n.startsWith(Qe))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let r=n.substring(Qe.length),f=ve(r,"base58btc"),s=Object.entries(cn.keyTypes).find(([d,E])=>Dr(f.buffer,E.magicBytes.buffer));if(!s)throw new Error("Unsupported key algorithm.");let x=f.slice(s[1].magicBytes.length);return s[0]==="ed25519"&&x.length===44?{publicKey:x.slice(-32),type:s[0]}:{publicKey:x,type:s[0]}}y(cf,"didToPublicKey");var tr={create(n={alg:Ne,length:rr}){let r=n.length||rr,f=n.alg||Ne;return te.subtle.generateKey({name:f,length:r},!0,["encrypt","decrypt"])},export:Object.assign(async n=>{let r=await te.subtle.exportKey("raw",n);return new Uint8Array(r)},{asString:y(async(n,r)=>{let f=await tr.export(n);return r?ue(f,r):De(f)},"asString")}),import(n){return un(typeof n=="string"?je(n):n)},async exportAsString(n){let r=await tr.export(n);return De(r)},encrypt:Ji,async decrypt(n,r,f){let s=nt(r)?r:await un(r),x=f?await te.subtle.decrypt({name:br,iv:he(f)},s,typeof n=="string"?he(ve(n)):n instanceof Uint8Array?he(n):n):await Qi(n,s);return new Uint8Array(x)}};function un(n,r){return te.subtle.importKey("raw",n instanceof Uint8Array?he(n):n,{name:br,length:r||256},!0,["encrypt","decrypt"])}y(un,"importAesKey");async function Ji(n,r,f,s){let x=nt(r)?r:await un(r),d=s?await te.subtle.encrypt({name:br,iv:he(s)},x,n instanceof ArrayBuffer?n:he(typeof n=="string"?ve(n):n)):await qi(n,x);return f&&f==="arraybuffer"?d:new Uint8Array(d)}y(Ji,"encrypt");async function qi(n,r,f){let s=mr(n,f?.charsize??gr),x=typeof r=="string"?await tn(r,f):r,d=f?.iv||tf(Ye),E=await te.subtle.encrypt({name:br,iv:d},x,s);return et(d,E)}y(qi,"encryptBytes");async function Qi(n,r,f){let s=Qr(n),x=typeof r=="string"?await tn(r,f):r,d=s.slice(0,Ye),E=s.slice(Ye);return await te.subtle.decrypt({name:Ne,iv:d},x,E)}y(Qi,"decryptBytes");var $e=class $e{constructor(r){Y(this,"DID");Y(this,"exchangeKey");Y(this,"writeKey");Y(this,"hasPersisted");Y(this,"isSessionOnly");let{keys:f}=r;this.DID=r.did,this.exchangeKey=f.exchange,this.writeKey=f.write,this.hasPersisted=r.hasPersisted,this.isSessionOnly=!!r.isSessionOnly}publicExchangeKeyAsString(r){return this.publicExchangeKey.asString(r)}publicWriteKeyAsString(r){return this.publicWriteKey.asString(r)}get publicWriteKey(){let r=this.writeKey.publicKey;return Object.assign(r,{asString:y(async f=>{let s=await Lr(this.writeKey),x=new Uint8Array(s);return f?ue(x,f):De(x)},"asString")})}get publicExchangeKey(){let r=this.exchangeKey.publicKey;return Object.assign(r,{asString:y(async f=>{let s=await Lr(this.exchangeKey),x=new Uint8Array(s);return f?ue(x,f):De(x)},"asString")})}get privateWriteKey(){return this.writeKey.privateKey}get privateExchangeKey(){return this.exchangeKey.privateKey}get deviceName(){return $e.deviceName(this.DID)}static deviceName(r){return eo(r)}async persist(){if(this.isSessionOnly)return;let r=this.constructor.EXCHANGE_KEY_NAME,f=this.constructor.WRITE_KEY_NAME;await Promise.all([on(r,this.exchangeKey),on(f,this.writeKey)]),this.hasPersisted=!0}async delete(){await ff([this.constructor.EXCHANGE_KEY_NAME,this.constructor.WRITE_KEY_NAME]),this.hasPersisted=!1}async getDeviceName(){return $e.deviceName(this.DID)}static _createExchangeKeys(r){throw new Error("The child should implement this")}static _createWriteKeys(r){throw new Error("The child should implement this")}static async create(r,f,s){let x=s?.exchangeKeys||await this._createExchangeKeys(f),d=s?.writeKeys||await this._createWriteKeys(f),E=await Lr(d),M=await xn(new Uint8Array(E),this.TYPE==="ecc"?"ed25519":"rsa"),$=new this({keys:{exchange:x,write:d},did:M,hasPersisted:!1,isSessionOnly:!!r});return this._instance=$,$}static async exist(r={}){let f=await Mr(r.writeKeyName||this.WRITE_KEY_NAME),s=await Mr(r.encryptionKeyName||this.EXCHANGE_KEY_NAME);return!(!f||!s)}static async load(r={session:!1}){if(this._instance)return this._instance;let f=!0,s=await Mr(r.encryptionKeyName||this.EXCHANGE_KEY_NAME),x=await Mr(r.writeKeyName||this.WRITE_KEY_NAME);s||(f=!1,s=await this._createExchangeKeys(r.extractable)),x||(f=!1,x=await this._createWriteKeys(r.extractable));let d=await Lr(x),E=await xn(new Uint8Array(d),this.TYPE==="ecc"?"ed25519":"rsa"),M=new this({keys:{exchange:s,write:x},did:E,hasPersisted:f,isSessionOnly:!!r.session});return this._instance=M,M}};y($e,"AbstractKeys"),Y($e,"EXCHANGE_KEY_NAME"),Y($e,"WRITE_KEY_NAME"),Y($e,"_instance");var ft=$e;async function yf(n,r){let{content:f,publicKey:s}=n,x=r||await tr.create(),d=await tr.encrypt(typeof f=="string"?ve(f):f,typeof x=="string"?await tr.import(x):x),E=await pn({key:x,publicKey:s});return et(E,d)}y(yf,"encryptTo");yf.asString=async function(n,r){let f=await yf(n,r);return ue(new Uint8Array(f),"base64pad")};async function pn({key:n,publicKey:r},f){let s;n instanceof CryptoKey?s=await tr.export(n):s=n;let x=await yn.encrypt(s,r);return f&&f==="arraybuffer"?x:new Uint8Array(x)}y(pn,"encryptKeyTo");pn.asString=async function({key:n,publicKey:r},f){let s=await pn({key:n,publicKey:r});return f?ue(s,f):De(s)};async function eo(n){let r=await Qn(new TextEncoder().encode(n.normalize("NFD")));return ue(r,"base32").slice(0,32)}y(eo,"getDeviceName");function nr(n){return new Uint8Array(n).buffer}y(nr,"toArrayBuffer");var Se=class Se extends ft{static async create(r,f,s){return await super.create(r,f,s)}constructor(r){super(r),Se.EXCHANGE_KEY_NAME=r.exchangeKeyName||Jr,Se.WRITE_KEY_NAME=r.writeKeyName||qr}get publicExchangeKey(){let r=this.exchangeKey.publicKey;return Object.assign(r,{asString:y(async f=>{let s=await Nr(this.exchangeKey),x=new Uint8Array(s);return f?ue(x,f):De(s)},"asString")})}get publicWriteKey(){let r=this.writeKey.publicKey;return Object.assign(r,{asString:y(async f=>{let s=await Nr(this.writeKey),x=new Uint8Array(s);return f?ue(x,f):De(s)},"asString")})}static async _createExchangeKeys(r=!1){return await te.subtle.generateKey({name:$r},r,["deriveKey","deriveBits"])}static async _createWriteKeys(r=!1){return await te.subtle.generateKey({name:hr},r,["sign","verify"])}static async load(r={session:!1}){if(this._instance)return this._instance;let f=r.encryptionKeyName||Jr,s=r.writeKeyName||qr;return super.load({...r,encryptionKeyName:f,writeKeyName:s})}async toJson(r){let f=this.DID,s=await Nr(this.exchangeKey);return{publicExchangeKey:r?ue(new Uint8Array(s),r):De(s),DID:f}}async wrap(r,f,s){let x=await Se._createExchangeKeys(!0),d=crypto.getRandomValues(new Uint8Array(_e)),E=await Ar(x.privateKey,f,d,s||"key-wrap"),M;if(r instanceof CryptoKey){let me=await crypto.subtle.exportKey("raw",r);M=new Uint8Array(me)}else typeof r=="string"?M=ve(r,"base64pad"):M=r;let $=crypto.getRandomValues(new Uint8Array(Ye)),le=await crypto.subtle.encrypt({name:Ne,iv:$},E,nr(M)),ie=await Nr(x),pe=new Uint8Array(d),Pe=new Uint8Array($),Fe=new Uint8Array(le),W=pe.length+Pe.length+Fe.length,fe=new Uint8Array(W);return fe.set(pe,0),fe.set(Pe,pe.length),fe.set(Fe,pe.length+Pe.length),{enc:De(new Uint8Array(ie)),wrappedKey:De(fe)}}async unwrap(r,f,s){let x=await it(r,"X25519","exchange"),d=new Uint8Array(je(f)),E=d.slice(0,_e),M=d.slice(_e,_e+Ye),$=d.slice(_e+Ye),le=await Ar(this.exchangeKey.privateKey,x,E,s||"key-wrap"),ie=await crypto.subtle.decrypt({name:Ne,iv:M},le,nr($));return await crypto.subtle.importKey("raw",ie,{name:Ne},!0,["encrypt","decrypt"])}async encrypt(r,f,s,x,d){let E=crypto.getRandomValues(new Uint8Array(_e)),M=f||this.exchangeKey.publicKey,$;typeof M=="string"?$=await it(M,"X25519","exchange"):$=M;let le=await Se._createExchangeKeys(!0),ie=x||await Ar(le.privateKey,$,E,s||Se.INFO,d);ie instanceof CryptoKey||(ie=await Ar(le.privateKey,$,E,s||Se.INFO));let pe=crypto.getRandomValues(new Uint8Array(Ye)),Pe=typeof r=="string"?new TextEncoder().encode(r):r,Fe=await crypto.subtle.encrypt({name:Ne,iv:pe},ie,nr(Pe)),W=new Uint8Array(await Nr(le)),fe=new Uint8Array(E),me=new Uint8Array(pe),we=new Uint8Array(Fe),Ce=W.length+fe.length+me.length+we.length,ye=new Uint8Array(Ce);return ye.set(W,0),ye.set(fe,W.length),ye.set(me,W.length+fe.length),ye.set(we,W.length+fe.length+me.length),ye}async encryptAsString(r,f,s,x,d){let E=await this.encrypt(r,f,s||Se.INFO,x,d);return ue(new Uint8Array(E),"base64pad")}async decrypt(r,f,s){let x=Ir(r,je),d=x.slice(0,er),E=await te.subtle.importKey("raw",d,{name:$r},!0,[]),M=x.slice(er,er+_e),$=x.slice(er+_e,er+_e+Ye),le=x.slice(er+_e+Ye),{privateKey:ie}=this.exchangeKey,pe=await Ar(ie,E,M,s||Se.INFO);return await crypto.subtle.decrypt({name:f||Ne,iv:$},pe,le)}async decryptAsString(r,f,s){let x=await this.decrypt(r,f,s);return ue(new Uint8Array(x))}async getAesKey(r,f){r||(r=this.publicExchangeKey);let s;typeof r=="string"?s=await it(r,"X25519","exchange"):s=r;let x=crypto.getRandomValues(new Uint8Array(_e));return await Ar(this.exchangeKey.privateKey,s,x,f||Se.INFO)}async sign(r,f){let s=new TextEncoder,x;typeof r=="string"?x=s.encode(r):r instanceof ArrayBuffer?x=new Uint8Array(r):x=r;let d=await te.subtle.sign({name:hr},this.writeKey.privateKey,nr(x));return new Uint8Array(d)}async signAsString(r,f){let s=await this.sign(r,f);return ue(s,"base64pad")}};y(Se,"EccKeys"),Y(Se,"TYPE","ecc"),Y(Se,"EXCHANGE_KEY_NAME",Jr),Y(Se,"WRITE_KEY_NAME",qr),Y(Se,"INFO","keys");var fr=Se;Object.assign(fr.prototype.sign,{asString:y(async function(n,r){let f=await this.sign(n,r);return ue(f,"base64pad")},"asString")});async function Nr(n,r="raw"){return await crypto.subtle.exportKey(r,n.publicKey)}y(Nr,"exportPublicKey");async function it(n,r,f){nf(f);let s=f==="exchange"?$r:hr,x=f==="exchange"?[]:["verify"],d=je(n),E=r==="X25519"?{name:s}:{name:s,namedCurve:r};return te.subtle.importKey("raw",d,E,!0,x)}y(it,"importPublicKey");var Zs={EccKeys:fr,importPublicKey:it};Object.assign(fr.prototype.encrypt,{asString:y(async function(n,r,f,s,x){return this.encryptAsString(n,r,f,s,x)},"asString")});Object.assign(fr.prototype.decrypt,{asString:y(async function(n,r){return this.decryptAsString(n,r)},"asString")});Object.assign(fr.prototype.sign,{asString:y(async function(n,r){return this.signAsString(n,r)},"asString")});async function Js(n,r,f){try{let s=rf(f);if(s.type!=="ed25519")throw new Error(`Expected Ed25519 key for ECC verification, got ${s.type}`);let x=s.publicKey.slice(-32),d=await te.subtle.importKey("raw",x,{name:hr},!0,["verify"]),E=new TextEncoder,M;typeof n=="string"?M=E.encode(n):n instanceof ArrayBuffer?M=new Uint8Array(n):M=n;let $;return typeof r=="string"?$=new Uint8Array(je(r)):$=r,await te.subtle.verify({name:hr},d,nr($),nr(M))}catch{return!1}}y(Js,"verify");async function Ar(n,r,f,s,x){let d=new TextEncoder,E=await crypto.subtle.deriveBits({name:"X25519",public:r},n,256),M=await crypto.subtle.importKey("raw",E,"HKDF",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:f instanceof Uint8Array?nr(f):f,info:d.encode(s)},M,{name:"AES-GCM",length:x||rr},!1,["encrypt","decrypt"])}y(Ar,"deriveKey");export{fr as EccKeys,Zs as default,Nr as exportPublicKey,it as importPublicKey,Js as verify};
|
|
4
4
|
//# sourceMappingURL=index.min.js.map
|