@substrate-system/keys 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_base.min.js.map +2 -2
- package/dist/aes/index.cjs +1 -0
- package/dist/aes/index.cjs.map +2 -2
- package/dist/aes/index.d.ts +15 -0
- package/dist/aes/index.d.ts.map +1 -1
- package/dist/aes/index.js +1 -0
- package/dist/aes/index.js.map +2 -2
- package/dist/aes/index.min.cjs +1 -1
- package/dist/aes/index.min.cjs.map +3 -3
- package/dist/aes/index.min.js +1 -1
- package/dist/aes/index.min.js.map +2 -2
- package/dist/browser/index.js +5063 -0
- package/dist/browser/index.min.js +3 -0
- package/dist/ecc/index.min.js.map +2 -2
- package/dist/index.js +11 -5062
- package/dist/index.min.js +3 -2
- package/dist/index.min.js.map +3 -3
- package/dist/meta.json +4 -3
- package/dist/rsa/index.min.js.map +2 -2
- package/package.json +5 -3
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var Si=Object.create;var Qe=Object.defineProperty;var vi=Object.getOwnPropertyDescriptor;var _i=Object.getOwnPropertyNames;var Ci=Object.getPrototypeOf,Pi=Object.prototype.hasOwnProperty;var x=(t,e)=>Qe(t,"name",{value:e,configurable:!0}),Dn=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Mn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Er=(t,e)=>{for(var i in e)Qe(t,i,{get:e[i],enumerable:!0})},Bi=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let y of _i(e))!Pi.call(t,y)&&y!==i&&Qe(t,y,{get:()=>e[y],enumerable:!(s=vi(e,y))||s.enumerable});return t};var Ti=(t,e,i)=>(i=t!=null?Si(Ci(t)):{},Bi(e||!t||!t.__esModule?Qe(i,"default",{value:t,enumerable:!0}):i,t));var ii=Mn(()=>{});var fi=Mn((ns,nt)=>{(function(t){"use strict";var e=x(function(n){var o,f=new Float64Array(16);if(n)for(o=0;o<n.length;o++)f[o]=n[o];return f},"gf"),i=x(function(){throw new Error("no PRNG")},"randombytes"),s=new Uint8Array(16),y=new Uint8Array(32);y[0]=9;var g=e(),E=e([1]),I=e([56129,1]),er=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),fr=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),ir=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),lr=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Dr=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function se(n,o,f,r){n[o]=f>>24&255,n[o+1]=f>>16&255,n[o+2]=f>>8&255,n[o+3]=f&255,n[o+4]=r>>24&255,n[o+5]=r>>16&255,n[o+6]=r>>8&255,n[o+7]=r&255}x(se,"ts64");function $(n,o,f,r,a){var u,p=0;for(u=0;u<a;u++)p|=n[o+u]^f[r+u];return(1&p-1>>>8)-1}x($,"vn");function yr(n,o,f,r){return $(n,o,f,r,16)}x(yr,"crypto_verify_16");function Sr(n,o,f,r){return $(n,o,f,r,32)}x(Sr,"crypto_verify_32");function wr(n,o,f,r){for(var a=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,u=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,p=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,b=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,K=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,T=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,S=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,J=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=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,j=f[16]&255|(f[17]&255)<<8|(f[18]&255)<<16|(f[19]&255)<<24,Y=f[20]&255|(f[21]&255)<<8|(f[22]&255)<<16|(f[23]&255)<<24,R=f[24]&255|(f[25]&255)<<8|(f[26]&255)<<16|(f[27]&255)<<24,O=f[28]&255|(f[29]&255)<<8|(f[30]&255)<<16|(f[31]&255)<<24,z=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,C=a,D=u,v=p,P=b,B=K,U=T,h=S,d=J,m=_,l=L,A=N,w=j,M=Y,H=R,G=O,F=z,c,X=0;X<20;X+=2)c=C+M|0,B^=c<<7|c>>>25,c=B+C|0,m^=c<<9|c>>>23,c=m+B|0,M^=c<<13|c>>>19,c=M+m|0,C^=c<<18|c>>>14,c=U+D|0,l^=c<<7|c>>>25,c=l+U|0,H^=c<<9|c>>>23,c=H+l|0,D^=c<<13|c>>>19,c=D+H|0,U^=c<<18|c>>>14,c=A+h|0,G^=c<<7|c>>>25,c=G+A|0,v^=c<<9|c>>>23,c=v+G|0,h^=c<<13|c>>>19,c=h+v|0,A^=c<<18|c>>>14,c=F+w|0,P^=c<<7|c>>>25,c=P+F|0,d^=c<<9|c>>>23,c=d+P|0,w^=c<<13|c>>>19,c=w+d|0,F^=c<<18|c>>>14,c=C+P|0,D^=c<<7|c>>>25,c=D+C|0,v^=c<<9|c>>>23,c=v+D|0,P^=c<<13|c>>>19,c=P+v|0,C^=c<<18|c>>>14,c=U+B|0,h^=c<<7|c>>>25,c=h+U|0,d^=c<<9|c>>>23,c=d+h|0,B^=c<<13|c>>>19,c=B+d|0,U^=c<<18|c>>>14,c=A+l|0,w^=c<<7|c>>>25,c=w+A|0,m^=c<<9|c>>>23,c=m+w|0,l^=c<<13|c>>>19,c=l+m|0,A^=c<<18|c>>>14,c=F+G|0,M^=c<<7|c>>>25,c=M+F|0,H^=c<<9|c>>>23,c=H+M|0,G^=c<<13|c>>>19,c=G+H|0,F^=c<<18|c>>>14;C=C+a|0,D=D+u|0,v=v+p|0,P=P+b|0,B=B+K|0,U=U+T|0,h=h+S|0,d=d+J|0,m=m+_|0,l=l+L|0,A=A+N|0,w=w+j|0,M=M+Y|0,H=H+R|0,G=G+O|0,F=F+z|0,n[0]=C>>>0&255,n[1]=C>>>8&255,n[2]=C>>>16&255,n[3]=C>>>24&255,n[4]=D>>>0&255,n[5]=D>>>8&255,n[6]=D>>>16&255,n[7]=D>>>24&255,n[8]=v>>>0&255,n[9]=v>>>8&255,n[10]=v>>>16&255,n[11]=v>>>24&255,n[12]=P>>>0&255,n[13]=P>>>8&255,n[14]=P>>>16&255,n[15]=P>>>24&255,n[16]=B>>>0&255,n[17]=B>>>8&255,n[18]=B>>>16&255,n[19]=B>>>24&255,n[20]=U>>>0&255,n[21]=U>>>8&255,n[22]=U>>>16&255,n[23]=U>>>24&255,n[24]=h>>>0&255,n[25]=h>>>8&255,n[26]=h>>>16&255,n[27]=h>>>24&255,n[28]=d>>>0&255,n[29]=d>>>8&255,n[30]=d>>>16&255,n[31]=d>>>24&255,n[32]=m>>>0&255,n[33]=m>>>8&255,n[34]=m>>>16&255,n[35]=m>>>24&255,n[36]=l>>>0&255,n[37]=l>>>8&255,n[38]=l>>>16&255,n[39]=l>>>24&255,n[40]=A>>>0&255,n[41]=A>>>8&255,n[42]=A>>>16&255,n[43]=A>>>24&255,n[44]=w>>>0&255,n[45]=w>>>8&255,n[46]=w>>>16&255,n[47]=w>>>24&255,n[48]=M>>>0&255,n[49]=M>>>8&255,n[50]=M>>>16&255,n[51]=M>>>24&255,n[52]=H>>>0&255,n[53]=H>>>8&255,n[54]=H>>>16&255,n[55]=H>>>24&255,n[56]=G>>>0&255,n[57]=G>>>8&255,n[58]=G>>>16&255,n[59]=G>>>24&255,n[60]=F>>>0&255,n[61]=F>>>8&255,n[62]=F>>>16&255,n[63]=F>>>24&255}x(wr,"core_salsa20");function dr(n,o,f,r){for(var a=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,u=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,p=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,b=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,K=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,T=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,S=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,J=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=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,j=f[16]&255|(f[17]&255)<<8|(f[18]&255)<<16|(f[19]&255)<<24,Y=f[20]&255|(f[21]&255)<<8|(f[22]&255)<<16|(f[23]&255)<<24,R=f[24]&255|(f[25]&255)<<8|(f[26]&255)<<16|(f[27]&255)<<24,O=f[28]&255|(f[29]&255)<<8|(f[30]&255)<<16|(f[31]&255)<<24,z=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,C=a,D=u,v=p,P=b,B=K,U=T,h=S,d=J,m=_,l=L,A=N,w=j,M=Y,H=R,G=O,F=z,c,X=0;X<20;X+=2)c=C+M|0,B^=c<<7|c>>>25,c=B+C|0,m^=c<<9|c>>>23,c=m+B|0,M^=c<<13|c>>>19,c=M+m|0,C^=c<<18|c>>>14,c=U+D|0,l^=c<<7|c>>>25,c=l+U|0,H^=c<<9|c>>>23,c=H+l|0,D^=c<<13|c>>>19,c=D+H|0,U^=c<<18|c>>>14,c=A+h|0,G^=c<<7|c>>>25,c=G+A|0,v^=c<<9|c>>>23,c=v+G|0,h^=c<<13|c>>>19,c=h+v|0,A^=c<<18|c>>>14,c=F+w|0,P^=c<<7|c>>>25,c=P+F|0,d^=c<<9|c>>>23,c=d+P|0,w^=c<<13|c>>>19,c=w+d|0,F^=c<<18|c>>>14,c=C+P|0,D^=c<<7|c>>>25,c=D+C|0,v^=c<<9|c>>>23,c=v+D|0,P^=c<<13|c>>>19,c=P+v|0,C^=c<<18|c>>>14,c=U+B|0,h^=c<<7|c>>>25,c=h+U|0,d^=c<<9|c>>>23,c=d+h|0,B^=c<<13|c>>>19,c=B+d|0,U^=c<<18|c>>>14,c=A+l|0,w^=c<<7|c>>>25,c=w+A|0,m^=c<<9|c>>>23,c=m+w|0,l^=c<<13|c>>>19,c=l+m|0,A^=c<<18|c>>>14,c=F+G|0,M^=c<<7|c>>>25,c=M+F|0,H^=c<<9|c>>>23,c=H+M|0,G^=c<<13|c>>>19,c=G+H|0,F^=c<<18|c>>>14;n[0]=C>>>0&255,n[1]=C>>>8&255,n[2]=C>>>16&255,n[3]=C>>>24&255,n[4]=U>>>0&255,n[5]=U>>>8&255,n[6]=U>>>16&255,n[7]=U>>>24&255,n[8]=A>>>0&255,n[9]=A>>>8&255,n[10]=A>>>16&255,n[11]=A>>>24&255,n[12]=F>>>0&255,n[13]=F>>>8&255,n[14]=F>>>16&255,n[15]=F>>>24&255,n[16]=h>>>0&255,n[17]=h>>>8&255,n[18]=h>>>16&255,n[19]=h>>>24&255,n[20]=d>>>0&255,n[21]=d>>>8&255,n[22]=d>>>16&255,n[23]=d>>>24&255,n[24]=m>>>0&255,n[25]=m>>>8&255,n[26]=m>>>16&255,n[27]=m>>>24&255,n[28]=l>>>0&255,n[29]=l>>>8&255,n[30]=l>>>16&255,n[31]=l>>>24&255}x(dr,"core_hsalsa20");function Kr(n,o,f,r){wr(n,o,f,r)}x(Kr,"crypto_core_salsa20");function gr(n,o,f,r){dr(n,o,f,r)}x(gr,"crypto_core_hsalsa20");var hr=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Mr(n,o,f,r,a,u,p){var b=new Uint8Array(16),K=new Uint8Array(64),T,S;for(S=0;S<16;S++)b[S]=0;for(S=0;S<8;S++)b[S]=u[S];for(;a>=64;){for(Kr(K,b,p,hr),S=0;S<64;S++)n[o+S]=f[r+S]^K[S];for(T=1,S=8;S<16;S++)T=T+(b[S]&255)|0,b[S]=T&255,T>>>=8;a-=64,o+=64,r+=64}if(a>0)for(Kr(K,b,p,hr),S=0;S<a;S++)n[o+S]=f[r+S]^K[S];return 0}x(Mr,"crypto_stream_salsa20_xor");function vr(n,o,f,r,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]=r[K];for(;f>=64;){for(Kr(p,u,a,hr),K=0;K<64;K++)n[o+K]=p[K];for(b=1,K=8;K<16;K++)b=b+(u[K]&255)|0,u[K]=b&255,b>>>=8;f-=64,o+=64}if(f>0)for(Kr(p,u,a,hr),K=0;K<f;K++)n[o+K]=p[K];return 0}x(vr,"crypto_stream_salsa20");function Pr(n,o,f,r,a){var u=new Uint8Array(32);gr(u,r,a,hr);for(var p=new Uint8Array(8),b=0;b<8;b++)p[b]=r[b+16];return vr(n,o,f,p,u)}x(Pr,"crypto_stream");function Zr(n,o,f,r,a,u,p){var b=new Uint8Array(32);gr(b,u,p,hr);for(var K=new Uint8Array(8),T=0;T<8;T++)K[T]=u[T+16];return Mr(n,o,f,r,a,K,b)}x(Zr,"crypto_stream_xor");var Ge=x(function(n){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,f,r,a,u,p,b,K;o=n[0]&255|(n[1]&255)<<8,this.r[0]=o&8191,f=n[2]&255|(n[3]&255)<<8,this.r[1]=(o>>>13|f<<3)&8191,r=n[4]&255|(n[5]&255)<<8,this.r[2]=(f>>>10|r<<6)&7939,a=n[6]&255|(n[7]&255)<<8,this.r[3]=(r>>>7|a<<9)&8191,u=n[8]&255|(n[9]&255)<<8,this.r[4]=(a>>>4|u<<12)&255,this.r[5]=u>>>1&8190,p=n[10]&255|(n[11]&255)<<8,this.r[6]=(u>>>14|p<<2)&8191,b=n[12]&255|(n[13]&255)<<8,this.r[7]=(p>>>11|b<<5)&8065,K=n[14]&255|(n[15]&255)<<8,this.r[8]=(b>>>8|K<<8)&8191,this.r[9]=K>>>5&127,this.pad[0]=n[16]&255|(n[17]&255)<<8,this.pad[1]=n[18]&255|(n[19]&255)<<8,this.pad[2]=n[20]&255|(n[21]&255)<<8,this.pad[3]=n[22]&255|(n[23]&255)<<8,this.pad[4]=n[24]&255|(n[25]&255)<<8,this.pad[5]=n[26]&255|(n[27]&255)<<8,this.pad[6]=n[28]&255|(n[29]&255)<<8,this.pad[7]=n[30]&255|(n[31]&255)<<8},"poly1305");Ge.prototype.blocks=function(n,o,f){for(var r=this.fin?0:2048,a,u,p,b,K,T,S,J,_,L,N,j,Y,R,O,z,C,D,v,P=this.h[0],B=this.h[1],U=this.h[2],h=this.h[3],d=this.h[4],m=this.h[5],l=this.h[6],A=this.h[7],w=this.h[8],M=this.h[9],H=this.r[0],G=this.r[1],F=this.r[2],c=this.r[3],X=this.r[4],Q=this.r[5],rr=this.r[6],V=this.r[7],Z=this.r[8],q=this.r[9];f>=16;)a=n[o+0]&255|(n[o+1]&255)<<8,P+=a&8191,u=n[o+2]&255|(n[o+3]&255)<<8,B+=(a>>>13|u<<3)&8191,p=n[o+4]&255|(n[o+5]&255)<<8,U+=(u>>>10|p<<6)&8191,b=n[o+6]&255|(n[o+7]&255)<<8,h+=(p>>>7|b<<9)&8191,K=n[o+8]&255|(n[o+9]&255)<<8,d+=(b>>>4|K<<12)&8191,m+=K>>>1&8191,T=n[o+10]&255|(n[o+11]&255)<<8,l+=(K>>>14|T<<2)&8191,S=n[o+12]&255|(n[o+13]&255)<<8,A+=(T>>>11|S<<5)&8191,J=n[o+14]&255|(n[o+15]&255)<<8,w+=(S>>>8|J<<8)&8191,M+=J>>>5|r,_=0,L=_,L+=P*H,L+=B*(5*q),L+=U*(5*Z),L+=h*(5*V),L+=d*(5*rr),_=L>>>13,L&=8191,L+=m*(5*Q),L+=l*(5*X),L+=A*(5*c),L+=w*(5*F),L+=M*(5*G),_+=L>>>13,L&=8191,N=_,N+=P*G,N+=B*H,N+=U*(5*q),N+=h*(5*Z),N+=d*(5*V),_=N>>>13,N&=8191,N+=m*(5*rr),N+=l*(5*Q),N+=A*(5*X),N+=w*(5*c),N+=M*(5*F),_+=N>>>13,N&=8191,j=_,j+=P*F,j+=B*G,j+=U*H,j+=h*(5*q),j+=d*(5*Z),_=j>>>13,j&=8191,j+=m*(5*V),j+=l*(5*rr),j+=A*(5*Q),j+=w*(5*X),j+=M*(5*c),_+=j>>>13,j&=8191,Y=_,Y+=P*c,Y+=B*F,Y+=U*G,Y+=h*H,Y+=d*(5*q),_=Y>>>13,Y&=8191,Y+=m*(5*Z),Y+=l*(5*V),Y+=A*(5*rr),Y+=w*(5*Q),Y+=M*(5*X),_+=Y>>>13,Y&=8191,R=_,R+=P*X,R+=B*c,R+=U*F,R+=h*G,R+=d*H,_=R>>>13,R&=8191,R+=m*(5*q),R+=l*(5*Z),R+=A*(5*V),R+=w*(5*rr),R+=M*(5*Q),_+=R>>>13,R&=8191,O=_,O+=P*Q,O+=B*X,O+=U*c,O+=h*F,O+=d*G,_=O>>>13,O&=8191,O+=m*H,O+=l*(5*q),O+=A*(5*Z),O+=w*(5*V),O+=M*(5*rr),_+=O>>>13,O&=8191,z=_,z+=P*rr,z+=B*Q,z+=U*X,z+=h*c,z+=d*F,_=z>>>13,z&=8191,z+=m*G,z+=l*H,z+=A*(5*q),z+=w*(5*Z),z+=M*(5*V),_+=z>>>13,z&=8191,C=_,C+=P*V,C+=B*rr,C+=U*Q,C+=h*X,C+=d*c,_=C>>>13,C&=8191,C+=m*F,C+=l*G,C+=A*H,C+=w*(5*q),C+=M*(5*Z),_+=C>>>13,C&=8191,D=_,D+=P*Z,D+=B*V,D+=U*rr,D+=h*Q,D+=d*X,_=D>>>13,D&=8191,D+=m*c,D+=l*F,D+=A*G,D+=w*H,D+=M*(5*q),_+=D>>>13,D&=8191,v=_,v+=P*q,v+=B*Z,v+=U*V,v+=h*rr,v+=d*Q,_=v>>>13,v&=8191,v+=m*X,v+=l*c,v+=A*F,v+=w*G,v+=M*H,_+=v>>>13,v&=8191,_=(_<<2)+_|0,_=_+L|0,L=_&8191,_=_>>>13,N+=_,P=L,B=N,U=j,h=Y,d=R,m=O,l=z,A=C,w=D,M=v,o+=16,f-=16;this.h[0]=P,this.h[1]=B,this.h[2]=U,this.h[3]=h,this.h[4]=d,this.h[5]=m,this.h[6]=l,this.h[7]=A,this.h[8]=w,this.h[9]=M},Ge.prototype.finish=function(n,o){var f=new Uint16Array(10),r,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(r=this.h[1]>>>13,this.h[1]&=8191,p=2;p<10;p++)this.h[p]+=r,r=this.h[p]>>>13,this.h[p]&=8191;for(this.h[0]+=r*5,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,f[0]=this.h[0]+5,r=f[0]>>>13,f[0]&=8191,p=1;p<10;p++)f[p]=this.h[p]+r,r=f[p]>>>13,f[p]&=8191;for(f[9]-=8192,a=(r^1)-1,p=0;p<10;p++)f[p]&=a;for(a=~a,p=0;p<10;p++)this.h[p]=this.h[p]&a|f[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;n[o+0]=this.h[0]>>>0&255,n[o+1]=this.h[0]>>>8&255,n[o+2]=this.h[1]>>>0&255,n[o+3]=this.h[1]>>>8&255,n[o+4]=this.h[2]>>>0&255,n[o+5]=this.h[2]>>>8&255,n[o+6]=this.h[3]>>>0&255,n[o+7]=this.h[3]>>>8&255,n[o+8]=this.h[4]>>>0&255,n[o+9]=this.h[4]>>>8&255,n[o+10]=this.h[5]>>>0&255,n[o+11]=this.h[5]>>>8&255,n[o+12]=this.h[6]>>>0&255,n[o+13]=this.h[6]>>>8&255,n[o+14]=this.h[7]>>>0&255,n[o+15]=this.h[7]>>>8&255},Ge.prototype.update=function(n,o,f){var r,a;if(this.leftover){for(a=16-this.leftover,a>f&&(a=f),r=0;r<a;r++)this.buffer[this.leftover+r]=n[o+r];if(f-=a,o+=a,this.leftover+=a,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(f>=16&&(a=f-f%16,this.blocks(n,o,a),o+=a,f-=a),f){for(r=0;r<f;r++)this.buffer[this.leftover+r]=n[o+r];this.leftover+=f}};function gt(n,o,f,r,a,u){var p=new Ge(u);return p.update(f,r,a),p.finish(n,o),0}x(gt,"crypto_onetimeauth");function bn(n,o,f,r,a,u){var p=new Uint8Array(16);return gt(p,0,f,r,a,u),yr(n,o,p,0)}x(bn,"crypto_onetimeauth_verify");function lt(n,o,f,r,a){var u;if(f<32)return-1;for(Zr(n,0,o,0,f,r,a),gt(n,16,n,32,f-32,n),u=0;u<16;u++)n[u]=0;return 0}x(lt,"crypto_secretbox");function bt(n,o,f,r,a){var u,p=new Uint8Array(32);if(f<32||(Pr(p,0,32,r,a),bn(o,16,o,32,f-32,p)!==0))return-1;for(Zr(n,0,o,0,f,r,a),u=0;u<32;u++)n[u]=0;return 0}x(bt,"crypto_secretbox_open");function Gr(n,o){var f;for(f=0;f<16;f++)n[f]=o[f]|0}x(Gr,"set25519");function At(n){var o,f,r=1;for(o=0;o<16;o++)f=n[o]+r+65535,r=Math.floor(f/65536),n[o]=f-r*65536;n[0]+=r-1+37*(r-1)}x(At,"car25519");function ce(n,o,f){for(var r,a=~(f-1),u=0;u<16;u++)r=a&(n[u]^o[u]),n[u]^=r,o[u]^=r}x(ce,"sel25519");function ye(n,o){var f,r,a,u=e(),p=e();for(f=0;f<16;f++)p[f]=o[f];for(At(p),At(p),At(p),r=0;r<2;r++){for(u[0]=p[0]-65517,f=1;f<15;f++)u[f]=p[f]-65535-(u[f-1]>>16&1),u[f-1]&=65535;u[15]=p[15]-32767-(u[14]>>16&1),a=u[15]>>16&1,u[14]&=65535,ce(p,u,1-a)}for(f=0;f<16;f++)n[2*f]=p[f]&255,n[2*f+1]=p[f]>>8}x(ye,"pack25519");function An(n,o){var f=new Uint8Array(32),r=new Uint8Array(32);return ye(f,n),ye(r,o),Sr(f,0,r,0)}x(An,"neq25519");function mn(n){var o=new Uint8Array(32);return ye(o,n),o[0]&1}x(mn,"par25519");function mt(n,o){var f;for(f=0;f<16;f++)n[f]=o[2*f]+(o[2*f+1]<<8);n[15]&=32767}x(mt,"unpack25519");function Ir(n,o,f){for(var r=0;r<16;r++)n[r]=o[r]+f[r]}x(Ir,"A");function Lr(n,o,f){for(var r=0;r<16;r++)n[r]=o[r]-f[r]}x(Lr,"Z");function k(n,o,f){var r,a,u=0,p=0,b=0,K=0,T=0,S=0,J=0,_=0,L=0,N=0,j=0,Y=0,R=0,O=0,z=0,C=0,D=0,v=0,P=0,B=0,U=0,h=0,d=0,m=0,l=0,A=0,w=0,M=0,H=0,G=0,F=0,c=f[0],X=f[1],Q=f[2],rr=f[3],V=f[4],Z=f[5],q=f[6],xr=f[7],tr=f[8],or=f[9],ar=f[10],sr=f[11],pr=f[12],br=f[13],Ar=f[14],mr=f[15];r=o[0],u+=r*c,p+=r*X,b+=r*Q,K+=r*rr,T+=r*V,S+=r*Z,J+=r*q,_+=r*xr,L+=r*tr,N+=r*or,j+=r*ar,Y+=r*sr,R+=r*pr,O+=r*br,z+=r*Ar,C+=r*mr,r=o[1],p+=r*c,b+=r*X,K+=r*Q,T+=r*rr,S+=r*V,J+=r*Z,_+=r*q,L+=r*xr,N+=r*tr,j+=r*or,Y+=r*ar,R+=r*sr,O+=r*pr,z+=r*br,C+=r*Ar,D+=r*mr,r=o[2],b+=r*c,K+=r*X,T+=r*Q,S+=r*rr,J+=r*V,_+=r*Z,L+=r*q,N+=r*xr,j+=r*tr,Y+=r*or,R+=r*ar,O+=r*sr,z+=r*pr,C+=r*br,D+=r*Ar,v+=r*mr,r=o[3],K+=r*c,T+=r*X,S+=r*Q,J+=r*rr,_+=r*V,L+=r*Z,N+=r*q,j+=r*xr,Y+=r*tr,R+=r*or,O+=r*ar,z+=r*sr,C+=r*pr,D+=r*br,v+=r*Ar,P+=r*mr,r=o[4],T+=r*c,S+=r*X,J+=r*Q,_+=r*rr,L+=r*V,N+=r*Z,j+=r*q,Y+=r*xr,R+=r*tr,O+=r*or,z+=r*ar,C+=r*sr,D+=r*pr,v+=r*br,P+=r*Ar,B+=r*mr,r=o[5],S+=r*c,J+=r*X,_+=r*Q,L+=r*rr,N+=r*V,j+=r*Z,Y+=r*q,R+=r*xr,O+=r*tr,z+=r*or,C+=r*ar,D+=r*sr,v+=r*pr,P+=r*br,B+=r*Ar,U+=r*mr,r=o[6],J+=r*c,_+=r*X,L+=r*Q,N+=r*rr,j+=r*V,Y+=r*Z,R+=r*q,O+=r*xr,z+=r*tr,C+=r*or,D+=r*ar,v+=r*sr,P+=r*pr,B+=r*br,U+=r*Ar,h+=r*mr,r=o[7],_+=r*c,L+=r*X,N+=r*Q,j+=r*rr,Y+=r*V,R+=r*Z,O+=r*q,z+=r*xr,C+=r*tr,D+=r*or,v+=r*ar,P+=r*sr,B+=r*pr,U+=r*br,h+=r*Ar,d+=r*mr,r=o[8],L+=r*c,N+=r*X,j+=r*Q,Y+=r*rr,R+=r*V,O+=r*Z,z+=r*q,C+=r*xr,D+=r*tr,v+=r*or,P+=r*ar,B+=r*sr,U+=r*pr,h+=r*br,d+=r*Ar,m+=r*mr,r=o[9],N+=r*c,j+=r*X,Y+=r*Q,R+=r*rr,O+=r*V,z+=r*Z,C+=r*q,D+=r*xr,v+=r*tr,P+=r*or,B+=r*ar,U+=r*sr,h+=r*pr,d+=r*br,m+=r*Ar,l+=r*mr,r=o[10],j+=r*c,Y+=r*X,R+=r*Q,O+=r*rr,z+=r*V,C+=r*Z,D+=r*q,v+=r*xr,P+=r*tr,B+=r*or,U+=r*ar,h+=r*sr,d+=r*pr,m+=r*br,l+=r*Ar,A+=r*mr,r=o[11],Y+=r*c,R+=r*X,O+=r*Q,z+=r*rr,C+=r*V,D+=r*Z,v+=r*q,P+=r*xr,B+=r*tr,U+=r*or,h+=r*ar,d+=r*sr,m+=r*pr,l+=r*br,A+=r*Ar,w+=r*mr,r=o[12],R+=r*c,O+=r*X,z+=r*Q,C+=r*rr,D+=r*V,v+=r*Z,P+=r*q,B+=r*xr,U+=r*tr,h+=r*or,d+=r*ar,m+=r*sr,l+=r*pr,A+=r*br,w+=r*Ar,M+=r*mr,r=o[13],O+=r*c,z+=r*X,C+=r*Q,D+=r*rr,v+=r*V,P+=r*Z,B+=r*q,U+=r*xr,h+=r*tr,d+=r*or,m+=r*ar,l+=r*sr,A+=r*pr,w+=r*br,M+=r*Ar,H+=r*mr,r=o[14],z+=r*c,C+=r*X,D+=r*Q,v+=r*rr,P+=r*V,B+=r*Z,U+=r*q,h+=r*xr,d+=r*tr,m+=r*or,l+=r*ar,A+=r*sr,w+=r*pr,M+=r*br,H+=r*Ar,G+=r*mr,r=o[15],C+=r*c,D+=r*X,v+=r*Q,P+=r*rr,B+=r*V,U+=r*Z,h+=r*q,d+=r*xr,m+=r*tr,l+=r*or,A+=r*ar,w+=r*sr,M+=r*pr,H+=r*br,G+=r*Ar,F+=r*mr,u+=38*D,p+=38*v,b+=38*P,K+=38*B,T+=38*U,S+=38*h,J+=38*d,_+=38*m,L+=38*l,N+=38*A,j+=38*w,Y+=38*M,R+=38*H,O+=38*G,z+=38*F,a=1,r=u+a+65535,a=Math.floor(r/65536),u=r-a*65536,r=p+a+65535,a=Math.floor(r/65536),p=r-a*65536,r=b+a+65535,a=Math.floor(r/65536),b=r-a*65536,r=K+a+65535,a=Math.floor(r/65536),K=r-a*65536,r=T+a+65535,a=Math.floor(r/65536),T=r-a*65536,r=S+a+65535,a=Math.floor(r/65536),S=r-a*65536,r=J+a+65535,a=Math.floor(r/65536),J=r-a*65536,r=_+a+65535,a=Math.floor(r/65536),_=r-a*65536,r=L+a+65535,a=Math.floor(r/65536),L=r-a*65536,r=N+a+65535,a=Math.floor(r/65536),N=r-a*65536,r=j+a+65535,a=Math.floor(r/65536),j=r-a*65536,r=Y+a+65535,a=Math.floor(r/65536),Y=r-a*65536,r=R+a+65535,a=Math.floor(r/65536),R=r-a*65536,r=O+a+65535,a=Math.floor(r/65536),O=r-a*65536,r=z+a+65535,a=Math.floor(r/65536),z=r-a*65536,r=C+a+65535,a=Math.floor(r/65536),C=r-a*65536,u+=a-1+37*(a-1),a=1,r=u+a+65535,a=Math.floor(r/65536),u=r-a*65536,r=p+a+65535,a=Math.floor(r/65536),p=r-a*65536,r=b+a+65535,a=Math.floor(r/65536),b=r-a*65536,r=K+a+65535,a=Math.floor(r/65536),K=r-a*65536,r=T+a+65535,a=Math.floor(r/65536),T=r-a*65536,r=S+a+65535,a=Math.floor(r/65536),S=r-a*65536,r=J+a+65535,a=Math.floor(r/65536),J=r-a*65536,r=_+a+65535,a=Math.floor(r/65536),_=r-a*65536,r=L+a+65535,a=Math.floor(r/65536),L=r-a*65536,r=N+a+65535,a=Math.floor(r/65536),N=r-a*65536,r=j+a+65535,a=Math.floor(r/65536),j=r-a*65536,r=Y+a+65535,a=Math.floor(r/65536),Y=r-a*65536,r=R+a+65535,a=Math.floor(r/65536),R=r-a*65536,r=O+a+65535,a=Math.floor(r/65536),O=r-a*65536,r=z+a+65535,a=Math.floor(r/65536),z=r-a*65536,r=C+a+65535,a=Math.floor(r/65536),C=r-a*65536,u+=a-1+37*(a-1),n[0]=u,n[1]=p,n[2]=b,n[3]=K,n[4]=T,n[5]=S,n[6]=J,n[7]=_,n[8]=L,n[9]=N,n[10]=j,n[11]=Y,n[12]=R,n[13]=O,n[14]=z,n[15]=C}x(k,"M");function Br(n,o){k(n,o,o)}x(Br,"S");function wn(n,o){var f=e(),r;for(r=0;r<16;r++)f[r]=o[r];for(r=253;r>=0;r--)Br(f,f),r!==2&&r!==4&&k(f,f,o);for(r=0;r<16;r++)n[r]=f[r]}x(wn,"inv25519");function Kn(n,o){var f=e(),r;for(r=0;r<16;r++)f[r]=o[r];for(r=250;r>=0;r--)Br(f,f),r!==1&&k(f,f,o);for(r=0;r<16;r++)n[r]=f[r]}x(Kn,"pow2523");function Ve(n,o,f){var r=new Uint8Array(32),a=new Float64Array(80),u,p,b=e(),K=e(),T=e(),S=e(),J=e(),_=e();for(p=0;p<31;p++)r[p]=o[p];for(r[31]=o[31]&127|64,r[0]&=248,mt(a,f),p=0;p<16;p++)K[p]=a[p],S[p]=b[p]=T[p]=0;for(b[0]=S[0]=1,p=254;p>=0;--p)u=r[p>>>3]>>>(p&7)&1,ce(b,K,u),ce(T,S,u),Ir(J,b,T),Lr(b,b,T),Ir(T,K,S),Lr(K,K,S),Br(S,J),Br(_,b),k(b,T,b),k(T,K,J),Ir(J,b,T),Lr(b,b,T),Br(K,b),Lr(T,S,_),k(b,T,I),Ir(b,b,S),k(T,T,b),k(b,S,_),k(S,K,a),Br(K,J),ce(b,K,u),ce(T,S,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]=S[p];var L=a.subarray(32),N=a.subarray(16);return wn(L,L),k(N,N,L),ye(n,N),0}x(Ve,"crypto_scalarmult");function Xe(n,o){return Ve(n,o,y)}x(Xe,"crypto_scalarmult_base");function En(n,o){return i(o,32),Xe(n,o)}x(En,"crypto_box_keypair");function ke(n,o,f){var r=new Uint8Array(32);return Ve(r,f,o),gr(n,s,r,hr)}x(ke,"crypto_box_beforenm");var Un=lt,bi=bt;function Ai(n,o,f,r,a,u){var p=new Uint8Array(32);return ke(p,a,u),Un(n,o,f,r,p)}x(Ai,"crypto_box");function mi(n,o,f,r,a,u){var p=new Uint8Array(32);return ke(p,a,u),bi(n,o,f,r,p)}x(mi,"crypto_box_open");var Sn=[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 vn(n,o,f,r){for(var a=new Int32Array(16),u=new Int32Array(16),p,b,K,T,S,J,_,L,N,j,Y,R,O,z,C,D,v,P,B,U,h,d,m,l,A,w,M=n[0],H=n[1],G=n[2],F=n[3],c=n[4],X=n[5],Q=n[6],rr=n[7],V=o[0],Z=o[1],q=o[2],xr=o[3],tr=o[4],or=o[5],ar=o[6],sr=o[7],pr=0;r>=128;){for(B=0;B<16;B++)U=8*B+pr,a[B]=f[U+0]<<24|f[U+1]<<16|f[U+2]<<8|f[U+3],u[B]=f[U+4]<<24|f[U+5]<<16|f[U+6]<<8|f[U+7];for(B=0;B<80;B++)if(p=M,b=H,K=G,T=F,S=c,J=X,_=Q,L=rr,N=V,j=Z,Y=q,R=xr,O=tr,z=or,C=ar,D=sr,h=rr,d=sr,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=(c>>>14|tr<<18)^(c>>>18|tr<<14)^(tr>>>9|c<<23),d=(tr>>>14|c<<18)^(tr>>>18|c<<14)^(c>>>9|tr<<23),m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,h=c&X^~c&Q,d=tr&or^~tr&ar,m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,h=Sn[B*2],d=Sn[B*2+1],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,h=a[B%16],d=u[B%16],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,v=A&65535|w<<16,P=m&65535|l<<16,h=v,d=P,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=(M>>>28|V<<4)^(V>>>2|M<<30)^(V>>>7|M<<25),d=(V>>>28|M<<4)^(M>>>2|V<<30)^(M>>>7|V<<25),m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,h=M&H^M&G^H&G,d=V&Z^V&q^Z&q,m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,L=A&65535|w<<16,D=m&65535|l<<16,h=T,d=R,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=v,d=P,m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,T=A&65535|w<<16,R=m&65535|l<<16,H=p,G=b,F=K,c=T,X=S,Q=J,rr=_,M=L,Z=N,q=j,xr=Y,tr=R,or=O,ar=z,sr=C,V=D,B%16===15)for(U=0;U<16;U++)h=a[U],d=u[U],m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=a[(U+9)%16],d=u[(U+9)%16],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,v=a[(U+1)%16],P=u[(U+1)%16],h=(v>>>1|P<<31)^(v>>>8|P<<24)^v>>>7,d=(P>>>1|v<<31)^(P>>>8|v<<24)^(P>>>7|v<<25),m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,v=a[(U+14)%16],P=u[(U+14)%16],h=(v>>>19|P<<13)^(P>>>29|v<<3)^v>>>6,d=(P>>>19|v<<13)^(v>>>29|P<<3)^(P>>>6|v<<26),m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,a[U]=A&65535|w<<16,u[U]=m&65535|l<<16;h=M,d=V,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=n[0],d=o[0],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,n[0]=M=A&65535|w<<16,o[0]=V=m&65535|l<<16,h=H,d=Z,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=n[1],d=o[1],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,n[1]=H=A&65535|w<<16,o[1]=Z=m&65535|l<<16,h=G,d=q,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=n[2],d=o[2],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,n[2]=G=A&65535|w<<16,o[2]=q=m&65535|l<<16,h=F,d=xr,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=n[3],d=o[3],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,n[3]=F=A&65535|w<<16,o[3]=xr=m&65535|l<<16,h=c,d=tr,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=n[4],d=o[4],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,n[4]=c=A&65535|w<<16,o[4]=tr=m&65535|l<<16,h=X,d=or,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=n[5],d=o[5],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,n[5]=X=A&65535|w<<16,o[5]=or=m&65535|l<<16,h=Q,d=ar,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=n[6],d=o[6],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,n[6]=Q=A&65535|w<<16,o[6]=ar=m&65535|l<<16,h=rr,d=sr,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=n[7],d=o[7],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,n[7]=rr=A&65535|w<<16,o[7]=sr=m&65535|l<<16,pr+=128,r-=128}return r}x(vn,"crypto_hashblocks_hl");function Qr(n,o,f){var r=new Int32Array(8),a=new Int32Array(8),u=new Uint8Array(256),p,b=f;for(r[0]=1779033703,r[1]=3144134277,r[2]=1013904242,r[3]=2773480762,r[4]=1359893119,r[5]=2600822924,r[6]=528734635,r[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,vn(r,a,o,f),f%=128,p=0;p<f;p++)u[p]=o[b-f+p];for(u[f]=128,f=256-128*(f<112?1:0),u[f-9]=0,se(u,f-8,b/536870912|0,b<<3),vn(r,a,u,f),p=0;p<8;p++)se(n,8*p,r[p],a[p]);return 0}x(Qr,"crypto_hash");function We(n,o){var f=e(),r=e(),a=e(),u=e(),p=e(),b=e(),K=e(),T=e(),S=e();Lr(f,n[1],n[0]),Lr(S,o[1],o[0]),k(f,f,S),Ir(r,n[0],n[1]),Ir(S,o[0],o[1]),k(r,r,S),k(a,n[3],o[3]),k(a,a,fr),k(u,n[2],o[2]),Ir(u,u,u),Lr(p,r,f),Lr(b,u,a),Ir(K,u,a),Ir(T,r,f),k(n[0],p,b),k(n[1],T,K),k(n[2],K,b),k(n[3],p,T)}x(We,"add");function _n(n,o,f){var r;for(r=0;r<4;r++)ce(n[r],o[r],f)}x(_n,"cswap");function wt(n,o){var f=e(),r=e(),a=e();wn(a,o[2]),k(f,o[0],a),k(r,o[1],a),ye(n,r),n[31]^=mn(f)<<7}x(wt,"pack");function Kt(n,o,f){var r,a;for(Gr(n[0],g),Gr(n[1],E),Gr(n[2],E),Gr(n[3],g),a=255;a>=0;--a)r=f[a/8|0]>>(a&7)&1,_n(n,o,r),We(o,n),We(n,n),_n(n,o,r)}x(Kt,"scalarmult");function $e(n,o){var f=[e(),e(),e(),e()];Gr(f[0],ir),Gr(f[1],lr),Gr(f[2],E),k(f[3],ir,lr),Kt(n,f,o)}x($e,"scalarbase");function Et(n,o,f){var r=new Uint8Array(64),a=[e(),e(),e(),e()],u;for(f||i(o,32),Qr(r,o,32),r[0]&=248,r[31]&=127,r[31]|=64,$e(a,r),wt(n,a),u=0;u<32;u++)o[u+32]=n[u];return 0}x(Et,"crypto_sign_keypair");var Ze=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 Ut(n,o){var f,r,a,u;for(r=63;r>=32;--r){for(f=0,a=r-32,u=r-12;a<u;++a)o[a]+=f-16*o[r]*Ze[a-(r-32)],f=Math.floor((o[a]+128)/256),o[a]-=f*256;o[a]+=f,o[r]=0}for(f=0,a=0;a<32;a++)o[a]+=f-(o[31]>>4)*Ze[a],f=o[a]>>8,o[a]&=255;for(a=0;a<32;a++)o[a]-=f*Ze[a];for(r=0;r<32;r++)o[r+1]+=o[r]>>8,n[r]=o[r]&255}x(Ut,"modL");function St(n){var o=new Float64Array(64),f;for(f=0;f<64;f++)o[f]=n[f];for(f=0;f<64;f++)n[f]=0;Ut(n,o)}x(St,"reduce");function Cn(n,o,f,r){var a=new Uint8Array(64),u=new Uint8Array(64),p=new Uint8Array(64),b,K,T=new Float64Array(64),S=[e(),e(),e(),e()];Qr(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64;var J=f+64;for(b=0;b<f;b++)n[64+b]=o[b];for(b=0;b<32;b++)n[32+b]=a[32+b];for(Qr(p,n.subarray(32),f+32),St(p),$e(S,p),wt(n,S),b=32;b<64;b++)n[b]=r[b];for(Qr(u,n,f+64),St(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 Ut(n.subarray(32),T),J}x(Cn,"crypto_sign");function wi(n,o){var f=e(),r=e(),a=e(),u=e(),p=e(),b=e(),K=e();return Gr(n[2],E),mt(n[1],o),Br(a,n[1]),k(u,a,er),Lr(a,a,n[2]),Ir(u,n[2],u),Br(p,u),Br(b,p),k(K,b,p),k(f,K,a),k(f,f,u),Kn(f,f),k(f,f,a),k(f,f,u),k(f,f,u),k(n[0],f,u),Br(r,n[0]),k(r,r,u),An(r,a)&&k(n[0],n[0],Dr),Br(r,n[0]),k(r,r,u),An(r,a)?-1:(mn(n[0])===o[31]>>7&&Lr(n[0],g,n[0]),k(n[3],n[0],n[1]),0)}x(wi,"unpackneg");function vt(n,o,f,r){var a,u=new Uint8Array(32),p=new Uint8Array(64),b=[e(),e(),e(),e()],K=[e(),e(),e(),e()];if(f<64||wi(K,r))return-1;for(a=0;a<f;a++)n[a]=o[a];for(a=0;a<32;a++)n[a+32]=r[a];if(Qr(p,n,f),St(p),Kt(b,K,p),$e(K,o.subarray(32)),We(b,K),wt(u,b),f-=64,Sr(o,0,u,0)){for(a=0;a<f;a++)n[a]=0;return-1}for(a=0;a<f;a++)n[a]=o[a+64];return f}x(vt,"crypto_sign_open");var _t=32,qe=24,Se=32,xe=16,ve=32,Je=32,_e=32,Ce=32,Ct=32,Pn=qe,Ki=Se,Ei=xe,Vr=64,re=32,ue=64,Pt=32,Bt=64;t.lowlevel={crypto_core_hsalsa20:gr,crypto_stream_xor:Zr,crypto_stream:Pr,crypto_stream_salsa20_xor:Mr,crypto_stream_salsa20:vr,crypto_onetimeauth:gt,crypto_onetimeauth_verify:bn,crypto_verify_16:yr,crypto_verify_32:Sr,crypto_secretbox:lt,crypto_secretbox_open:bt,crypto_scalarmult:Ve,crypto_scalarmult_base:Xe,crypto_box_beforenm:ke,crypto_box_afternm:Un,crypto_box:Ai,crypto_box_open:mi,crypto_box_keypair:En,crypto_hash:Qr,crypto_sign:Cn,crypto_sign_keypair:Et,crypto_sign_open:vt,crypto_secretbox_KEYBYTES:_t,crypto_secretbox_NONCEBYTES:qe,crypto_secretbox_ZEROBYTES:Se,crypto_secretbox_BOXZEROBYTES:xe,crypto_scalarmult_BYTES:ve,crypto_scalarmult_SCALARBYTES:Je,crypto_box_PUBLICKEYBYTES:_e,crypto_box_SECRETKEYBYTES:Ce,crypto_box_BEFORENMBYTES:Ct,crypto_box_NONCEBYTES:Pn,crypto_box_ZEROBYTES:Ki,crypto_box_BOXZEROBYTES:Ei,crypto_sign_BYTES:Vr,crypto_sign_PUBLICKEYBYTES:re,crypto_sign_SECRETKEYBYTES:ue,crypto_sign_SEEDBYTES:Pt,crypto_hash_BYTES:Bt,gf:e,D:er,L:Ze,pack25519:ye,unpack25519:mt,M:k,A:Ir,S:Br,Z:Lr,pow2523:Kn,add:We,set25519:Gr,modL:Ut,scalarmult:Kt,scalarbase:$e};function Bn(n,o){if(n.length!==_t)throw new Error("bad key size");if(o.length!==qe)throw new Error("bad nonce size")}x(Bn,"checkLengths");function Ui(n,o){if(n.length!==_e)throw new Error("bad public key size");if(o.length!==Ce)throw new Error("bad secret key size")}x(Ui,"checkBoxLengths");function _r(){for(var n=0;n<arguments.length;n++)if(!(arguments[n]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}x(_r,"checkArrayTypes");function Tn(n){for(var o=0;o<n.length;o++)n[o]=0}x(Tn,"cleanup"),t.randomBytes=function(n){var o=new Uint8Array(n);return i(o,n),o},t.secretbox=function(n,o,f){_r(n,o,f),Bn(f,o);for(var r=new Uint8Array(Se+n.length),a=new Uint8Array(r.length),u=0;u<n.length;u++)r[u+Se]=n[u];return lt(a,r,r.length,o,f),a.subarray(xe)},t.secretbox.open=function(n,o,f){_r(n,o,f),Bn(f,o);for(var r=new Uint8Array(xe+n.length),a=new Uint8Array(r.length),u=0;u<n.length;u++)r[u+xe]=n[u];return r.length<32||bt(a,r,r.length,o,f)!==0?null:a.subarray(Se)},t.secretbox.keyLength=_t,t.secretbox.nonceLength=qe,t.secretbox.overheadLength=xe,t.scalarMult=function(n,o){if(_r(n,o),n.length!==Je)throw new Error("bad n size");if(o.length!==ve)throw new Error("bad p size");var f=new Uint8Array(ve);return Ve(f,n,o),f},t.scalarMult.base=function(n){if(_r(n),n.length!==Je)throw new Error("bad n size");var o=new Uint8Array(ve);return Xe(o,n),o},t.scalarMult.scalarLength=Je,t.scalarMult.groupElementLength=ve,t.box=function(n,o,f,r){var a=t.box.before(f,r);return t.secretbox(n,o,a)},t.box.before=function(n,o){_r(n,o),Ui(n,o);var f=new Uint8Array(Ct);return ke(f,n,o),f},t.box.after=t.secretbox,t.box.open=function(n,o,f,r){var a=t.box.before(f,r);return t.secretbox.open(n,o,a)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var n=new Uint8Array(_e),o=new Uint8Array(Ce);return En(n,o),{publicKey:n,secretKey:o}},t.box.keyPair.fromSecretKey=function(n){if(_r(n),n.length!==Ce)throw new Error("bad secret key size");var o=new Uint8Array(_e);return Xe(o,n),{publicKey:o,secretKey:new Uint8Array(n)}},t.box.publicKeyLength=_e,t.box.secretKeyLength=Ce,t.box.sharedKeyLength=Ct,t.box.nonceLength=Pn,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(n,o){if(_r(n,o),o.length!==ue)throw new Error("bad secret key size");var f=new Uint8Array(Vr+n.length);return Cn(f,n,n.length,o),f},t.sign.open=function(n,o){if(_r(n,o),o.length!==re)throw new Error("bad public key size");var f=new Uint8Array(n.length),r=vt(f,n,n.length,o);if(r<0)return null;for(var a=new Uint8Array(r),u=0;u<a.length;u++)a[u]=f[u];return a},t.sign.detached=function(n,o){for(var f=t.sign(n,o),r=new Uint8Array(Vr),a=0;a<r.length;a++)r[a]=f[a];return r},t.sign.detached.verify=function(n,o,f){if(_r(n,o,f),o.length!==Vr)throw new Error("bad signature size");if(f.length!==re)throw new Error("bad public key size");var r=new Uint8Array(Vr+n.length),a=new Uint8Array(Vr+n.length),u;for(u=0;u<Vr;u++)r[u]=o[u];for(u=0;u<n.length;u++)r[u+Vr]=n[u];return vt(a,r,r.length,f)>=0},t.sign.keyPair=function(){var n=new Uint8Array(re),o=new Uint8Array(ue);return Et(n,o),{publicKey:n,secretKey:o}},t.sign.keyPair.fromSecretKey=function(n){if(_r(n),n.length!==ue)throw new Error("bad secret key size");for(var o=new Uint8Array(re),f=0;f<o.length;f++)o[f]=n[32+f];return{publicKey:o,secretKey:new Uint8Array(n)}},t.sign.keyPair.fromSeed=function(n){if(_r(n),n.length!==Pt)throw new Error("bad seed size");for(var o=new Uint8Array(re),f=new Uint8Array(ue),r=0;r<32;r++)f[r]=n[r];return Et(o,f,!0),{publicKey:o,secretKey:f}},t.sign.publicKeyLength=re,t.sign.secretKeyLength=ue,t.sign.seedLength=Pt,t.sign.signatureLength=Vr,t.hash=function(n){_r(n);var o=new Uint8Array(Bt);return Qr(o,n,n.length),o},t.hash.hashLength=Bt,t.verify=function(n,o){return _r(n,o),n.length===0||o.length===0||n.length!==o.length?!1:$(n,0,o,0,n.length)===0},t.setPRNG=function(n){i=n},function(){var n=typeof self<"u"?self.crypto||self.msCrypto:null;if(n&&n.getRandomValues){var o=65536;t.setPRNG(function(f,r){var a,u=new Uint8Array(r);for(a=0;a<r;a+=o)n.getRandomValues(u.subarray(a,a+Math.min(r-a,o)));for(a=0;a<r;a++)f[a]=u[a];Tn(u)})}else typeof Dn<"u"&&(n=ii(),n&&n.randomBytes&&t.setPRNG(function(f,r){var a,u=n.randomBytes(r);for(a=0;a<r;a++)f[a]=u[a];Tn(u)}))}()})(typeof nt<"u"&&nt.exports?nt.exports:self.nacl=self.nacl||{})});var In=(s=>(s[s.B1024=1024]="B1024",s[s.B2048=2048]="B2048",s[s.B4096=4096]="B4096",s))(In||{}),Ln=(s=>(s[s.B128=128]="B128",s[s.B192=192]="B192",s[s.B256=256]="B256",s))(Ln||{}),Nn=(i=>(i.ECC="ecc",i.RSA="rsa",i))(Nn||{}),Tt=(y=>(y.SHA_1="SHA-1",y.SHA_256="SHA-256",y.SHA_384="SHA-384",y.SHA_512="SHA-512",y))(Tt||{}),Dt=(y=>(y.P_256="P-256",y.P_384="P-384",y.P_521="P-521",y.X25519="X25519",y))(Dt||{}),pe=(s=>(s.Sign="signing",s.Exchange="exchange",s.Write="write",s))(pe||{}),Mt=(i=>(i[i.B8=8]="B8",i[i.B16=16]="B16",i))(Mt||{});var di={};Er(di,{AES_GCM:()=>jr,BASE58_DID_PREFIX:()=>Le,BLS_DID_PREFIX:()=>at,DEFAULT_CHAR_SIZE:()=>Yr,DEFAULT_ECC_EXCHANGE:()=>Re,DEFAULT_ECC_EXCHANGE_CURVE:()=>Hf,DEFAULT_ECC_WRITE:()=>ze,DEFAULT_HASH_ALGORITHM:()=>ie,DEFAULT_RSA_EXCHANGE:()=>ct,DEFAULT_RSA_SIZE:()=>ot,DEFAULT_RSA_WRITE:()=>yt,DEFAULT_SYMM_ALGORITHM:()=>Hr,DEFAULT_SYMM_LENGTH:()=>Fr,ECC_EXCHANGE_ALG:()=>nn,ECC_EXCHANGE_NAME:()=>on,ECC_WRITE_ALG:()=>Ae,ECC_WRITE_NAME:()=>fn,EDWARDS_DID_PREFIX:()=>st,IV_LENGTH:()=>Nr,KEY_TYPE:()=>Ne,KEY_USE:()=>oi,RSA_ALGORITHM:()=>te,RSA_DID_PREFIX:()=>ft,RSA_HASHING_ALGORITHM:()=>it,RSA_SIGN_ALGORITHM:()=>ne,RsaKeys:()=>ae,SALT_LENGTH:()=>Rr,encrypt:()=>so,encryptKeyTo:()=>Ue,encryptTo:()=>hi,getPublicKeyAsArrayBuffer:()=>Wr,getPublicKeyAsUint8Array:()=>yn,publicKeyToDid:()=>Ye,verify:()=>ao});var Di=globalThis||window||self,W=Di.crypto;function Pe(t=0){return new Uint8Array(t)}x(Pe,"allocUnsafe");function It(t,e){e==null&&(e=t.reduce((y,g)=>y+g.length,0));let i=Pe(e),s=0;for(let y of t)i.set(y,s),s+=y.length;return i}x(It,"concat");var Ot={};Er(Ot,{base10:()=>Oi});var Io=new Uint8Array(0);function Rn(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let i=0;i<t.byteLength;i++)if(t[i]!==e[i])return!1;return!0}x(Rn,"equals");function Xr(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}x(Xr,"coerce");function zn(t){return new TextEncoder().encode(t)}x(zn,"fromString");function On(t){return new TextDecoder().decode(t)}x(On,"toString");function Ii(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var i=new Uint8Array(256),s=0;s<i.length;s++)i[s]=255;for(var y=0;y<t.length;y++){var g=t.charAt(y),E=g.charCodeAt(0);if(i[E]!==255)throw new TypeError(g+" is ambiguous");i[E]=y}var I=t.length,er=t.charAt(0),fr=Math.log(I)/Math.log(256),ir=Math.log(256)/Math.log(I);function lr($){if($ instanceof Uint8Array||(ArrayBuffer.isView($)?$=new Uint8Array($.buffer,$.byteOffset,$.byteLength):Array.isArray($)&&($=Uint8Array.from($))),!($ instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if($.length===0)return"";for(var yr=0,Sr=0,wr=0,dr=$.length;wr!==dr&&$[wr]===0;)wr++,yr++;for(var Kr=(dr-wr)*ir+1>>>0,gr=new Uint8Array(Kr);wr!==dr;){for(var hr=$[wr],Mr=0,vr=Kr-1;(hr!==0||Mr<Sr)&&vr!==-1;vr--,Mr++)hr+=256*gr[vr]>>>0,gr[vr]=hr%I>>>0,hr=hr/I>>>0;if(hr!==0)throw new Error("Non-zero carry");Sr=Mr,wr++}for(var Pr=Kr-Sr;Pr!==Kr&&gr[Pr]===0;)Pr++;for(var Zr=er.repeat(yr);Pr<Kr;++Pr)Zr+=t.charAt(gr[Pr]);return Zr}x(lr,"encode");function Dr($){if(typeof $!="string")throw new TypeError("Expected String");if($.length===0)return new Uint8Array;var yr=0;if($[yr]!==" "){for(var Sr=0,wr=0;$[yr]===er;)Sr++,yr++;for(var dr=($.length-yr)*fr+1>>>0,Kr=new Uint8Array(dr);$[yr];){var gr=i[$.charCodeAt(yr)];if(gr===255)return;for(var hr=0,Mr=dr-1;(gr!==0||hr<wr)&&Mr!==-1;Mr--,hr++)gr+=I*Kr[Mr]>>>0,Kr[Mr]=gr%256>>>0,gr=gr/256>>>0;if(gr!==0)throw new Error("Non-zero carry");wr=hr,yr++}if($[yr]!==" "){for(var vr=dr-wr;vr!==dr&&Kr[vr]===0;)vr++;for(var Pr=new Uint8Array(Sr+(dr-vr)),Zr=Sr;vr!==dr;)Pr[Zr++]=Kr[vr++];return Pr}}}x(Dr,"decodeUnsafe");function se($){var yr=Dr($);if(yr)return yr;throw new Error(`Non-${e} character`)}return x(se,"decode"),{encode:lr,decodeUnsafe:Dr,decode:se}}x(Ii,"base");var Li=Ii,Ni=Li,jn=Ni;var Lt=class{static{x(this,"Encoder")}name;prefix;baseEncode;constructor(e,i,s){this.name=e,this.prefix=i,this.baseEncode=s}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Nt=class{static{x(this,"Decoder")}name;prefix;baseDecode;prefixCodePoint;constructor(e,i,s){this.name=e,this.prefix=i;let y=i.codePointAt(0);if(y===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=y,this.baseDecode=s}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Hn(this,e)}},Rt=class{static{x(this,"ComposedDecoder")}decoders;constructor(e){this.decoders=e}or(e){return Hn(this,e)}decode(e){let i=e[0],s=this.decoders[i];if(s!=null)return s.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Hn(t,e){return new Rt({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}x(Hn,"or");var zt=class{static{x(this,"Codec")}name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,i,s,y){this.name=e,this.prefix=i,this.baseEncode=s,this.baseDecode=y,this.encoder=new Lt(e,i,s),this.decoder=new Nt(e,i,y)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function he({name:t,prefix:e,encode:i,decode:s}){return new zt(t,e,i,s)}x(he,"from");function qr({name:t,prefix:e,alphabet:i}){let{encode:s,decode:y}=jn(i,t);return he({prefix:e,name:t,encode:s,decode:x(g=>Xr(y(g)),"decode")})}x(qr,"baseX");function Ri(t,e,i,s){let y={};for(let ir=0;ir<e.length;++ir)y[e[ir]]=ir;let g=t.length;for(;t[g-1]==="=";)--g;let E=new Uint8Array(g*i/8|0),I=0,er=0,fr=0;for(let ir=0;ir<g;++ir){let lr=y[t[ir]];if(lr===void 0)throw new SyntaxError(`Non-${s} character`);er=er<<i|lr,I+=i,I>=8&&(I-=8,E[fr++]=255&er>>I)}if(I>=i||(255&er<<8-I)!==0)throw new SyntaxError("Unexpected end of data");return E}x(Ri,"decode");function zi(t,e,i){let s=e[e.length-1]==="=",y=(1<<i)-1,g="",E=0,I=0;for(let er=0;er<t.length;++er)for(I=I<<8|t[er],E+=8;E>i;)E-=i,g+=e[y&I>>E];if(E!==0&&(g+=e[y&I<<i-E]),s)for(;(g.length*i&7)!==0;)g+="=";return g}x(zi,"encode");function cr({name:t,prefix:e,bitsPerChar:i,alphabet:s}){return he({prefix:e,name:t,encode(y){return zi(y,s,i)},decode(y){return Ri(y,s,i,t)}})}x(cr,"rfc4648");var Oi=qr({prefix:"9",name:"base10",alphabet:"0123456789"});var Yt={};Er(Yt,{base16:()=>Yi,base16upper:()=>ji});var Yi=cr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ji=cr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var jt={};Er(jt,{base2:()=>Hi});var Hi=cr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ht={};Er(Ht,{base256emoji:()=>ki});var Fn=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}"),Fi=Fn.reduce((t,e,i)=>(t[i]=e,t),[]),Gi=Fn.reduce((t,e,i)=>{let s=e.codePointAt(0);if(s==null)throw new Error(`Invalid character: ${e}`);return t[s]=i,t},[]);function Vi(t){return t.reduce((e,i)=>(e+=Fi[i],e),"")}x(Vi,"encode");function Xi(t){let e=[];for(let i of t){let s=i.codePointAt(0);if(s==null)throw new Error(`Invalid character: ${i}`);let y=Gi[s];if(y==null)throw new Error(`Non-base256emoji character: ${i}`);e.push(y)}return new Uint8Array(e)}x(Xi,"decode");var ki=he({prefix:"\u{1F680}",name:"base256emoji",encode:Vi,decode:Xi});var Ft={};Er(Ft,{base32:()=>de,base32hex:()=>qi,base32hexpad:()=>Qi,base32hexpadupper:()=>rf,base32hexupper:()=>Ji,base32pad:()=>$i,base32padupper:()=>Zi,base32upper:()=>Wi,base32z:()=>ef});var de=cr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wi=cr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$i=cr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Zi=cr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qi=cr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ji=cr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qi=cr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),rf=cr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ef=cr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Gt={};Er(Gt,{base36:()=>Be,base36upper:()=>tf});var Be=qr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),tf=qr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vt={};Er(Vt,{base58btc:()=>Or,base58flickr:()=>nf});var Or=qr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nf=qr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Xt={};Er(Xt,{base64:()=>ff,base64pad:()=>of,base64url:()=>af,base64urlpad:()=>sf});var ff=cr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),of=cr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),af=cr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sf=cr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var kt={};Er(kt,{base8:()=>cf});var cf=cr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wt={};Er(Wt,{identity:()=>yf});var yf=he({prefix:"\0",name:"identity",encode:x(t=>On(t),"encode"),decode:x(t=>zn(t),"decode")});var ea=new TextEncoder,ta=new TextDecoder;var Zt={};Er(Zt,{identity:()=>Mf});var pf=Xn,Gn=128,hf=127,df=~hf,gf=Math.pow(2,31);function Xn(t,e,i){e=e||[],i=i||0;for(var s=i;t>=gf;)e[i++]=t&255|Gn,t/=128;for(;t&df;)e[i++]=t&255|Gn,t>>>=7;return e[i]=t|0,Xn.bytes=i-s+1,e}x(Xn,"encode");var lf=$t,bf=128,Vn=127;function $t(t,s){var i=0,s=s||0,y=0,g=s,E,I=t.length;do{if(g>=I)throw $t.bytes=0,new RangeError("Could not decode varint");E=t[g++],i+=y<28?(E&Vn)<<y:(E&Vn)*Math.pow(2,y),y+=7}while(E>=bf);return $t.bytes=g-s,i}x($t,"read");var Af=Math.pow(2,7),mf=Math.pow(2,14),wf=Math.pow(2,21),Kf=Math.pow(2,28),Ef=Math.pow(2,35),Uf=Math.pow(2,42),Sf=Math.pow(2,49),vf=Math.pow(2,56),_f=Math.pow(2,63),Cf=x(function(t){return t<Af?1:t<mf?2:t<wf?3:t<Kf?4:t<Ef?5:t<Uf?6:t<Sf?7:t<vf?8:t<_f?9:10},"length"),Pf={encode:pf,decode:lf,encodingLength:Cf},Bf=Pf,Te=Bf;function De(t,e=0){return[Te.decode(t,e),Te.decode.bytes]}x(De,"decode");function ge(t,e,i=0){return Te.encode(t,e,i),e}x(ge,"encodeTo");function le(t){return Te.encodingLength(t)}x(le,"encodingLength");function ee(t,e){let i=e.byteLength,s=le(t),y=s+le(i),g=new Uint8Array(y+i);return ge(t,g,0),ge(i,g,s),g.set(e,y),new be(t,i,e,g)}x(ee,"create");function kn(t){let e=Xr(t),[i,s]=De(e),[y,g]=De(e.subarray(s)),E=e.subarray(s+g);if(E.byteLength!==y)throw new Error("Incorrect length");return new be(i,y,E,e)}x(kn,"decode");function Wn(t,e){if(t===e)return!0;{let i=e;return t.code===i.code&&t.size===i.size&&i.bytes instanceof Uint8Array&&Rn(t.bytes,i.bytes)}}x(Wn,"equals");var be=class{static{x(this,"Digest")}code;size;digest;bytes;constructor(e,i,s,y){this.code=e,this.size=i,this.digest=s,this.bytes=y}};var $n=0,Tf="identity",Zn=Xr;function Df(t){return ee($n,Zn(t))}x(Df,"digest");var Mf={code:$n,name:Tf,encode:Zn,digest:Df};var Qt={};Er(Qt,{sha256:()=>If,sha512:()=>Lf});function Jt({name:t,code:e,encode:i}){return new qt(t,e,i)}x(Jt,"from");var qt=class{static{x(this,"Hasher")}name;code;encode;constructor(e,i,s){this.name=e,this.code=i,this.encode=s}digest(e){if(e instanceof Uint8Array){let i=this.encode(e);return i instanceof Uint8Array?ee(this.code,i):i.then(s=>ee(this.code,s))}else throw Error("Unknown type, must be binary type")}};function Jn(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}x(Jn,"sha");var If=Jt({name:"sha2-256",code:18,encode:Jn("SHA-256")}),Lf=Jt({name:"sha2-512",code:19,encode:Jn("SHA-512")});function Qn(t,e){let{bytes:i,version:s}=t;switch(s){case 0:return Rf(i,rn(t),e??Or.encoder);default:return zf(i,rn(t),e??de.encoder)}}x(Qn,"format");var ri=new WeakMap;function rn(t){let e=ri.get(t);if(e==null){let i=new Map;return ri.set(t,i),i}return e}x(rn,"baseCache");var et=class t{static{x(this,"CID")}code;version;multihash;bytes;"/";constructor(e,i,s,y){this.code=i,this.version=e,this.multihash=s,this.bytes=y,this["/"]=y}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:e,multihash:i}=this;if(e!==Ie)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(i.code!==Of)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(i)}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:e,digest:i}=this.multihash,s=ee(e,i);return t.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(e){return t.equals(this,e)}static equals(e,i){let s=i;return s!=null&&e.code===s.code&&e.version===s.version&&Wn(e.multihash,s.multihash)}toString(e){return Qn(this,e)}toJSON(){return{"/":Qn(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let i=e;if(i instanceof t)return i;if(i["/"]!=null&&i["/"]===i.bytes||i.asCID===i){let{version:s,code:y,multihash:g,bytes:E}=i;return new t(s,y,g,E??ei(s,y,g.bytes))}else if(i[Yf]===!0){let{version:s,multihash:y,code:g}=i,E=kn(y);return t.create(s,g,E)}else return null}static create(e,i,s){if(typeof i!="number")throw new Error("String codecs are no longer supported");if(!(s.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(i!==Ie)throw new Error(`Version 0 CID must use dag-pb (code: ${Ie}) block encoding`);return new t(e,i,s,s.bytes)}case 1:{let y=ei(e,i,s.bytes);return new t(e,i,s,y)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Ie,e)}static createV1(e,i){return t.create(1,e,i)}static decode(e){let[i,s]=t.decodeFirst(e);if(s.length!==0)throw new Error("Incorrect length");return i}static decodeFirst(e){let i=t.inspectBytes(e),s=i.size-i.multihashSize,y=Xr(e.subarray(s,s+i.multihashSize));if(y.byteLength!==i.multihashSize)throw new Error("Incorrect length");let g=y.subarray(i.multihashSize-i.digestSize),E=new be(i.multihashCode,i.digestSize,g,y);return[i.version===0?t.createV0(E):t.createV1(i.codec,E),e.subarray(i.size)]}static inspectBytes(e){let i=0,s=x(()=>{let[lr,Dr]=De(e.subarray(i));return i+=Dr,lr},"next"),y=s(),g=Ie;if(y===18?(y=0,i=0):g=s(),y!==0&&y!==1)throw new RangeError(`Invalid CID version ${y}`);let E=i,I=s(),er=s(),fr=i+er,ir=fr-E;return{version:y,codec:g,multihashCode:I,digestSize:er,multihashSize:ir,size:fr}}static parse(e,i){let[s,y]=Nf(e,i),g=t.decode(y);if(g.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return rn(g).set(s,e),g}};function Nf(t,e){switch(t[0]){case"Q":{let i=e??Or;return[Or.prefix,i.decode(`${Or.prefix}${t}`)]}case Or.prefix:{let i=e??Or;return[Or.prefix,i.decode(t)]}case de.prefix:{let i=e??de;return[de.prefix,i.decode(t)]}case Be.prefix:{let i=e??Be;return[Be.prefix,i.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}x(Nf,"parseCIDtoBytes");function Rf(t,e,i){let{prefix:s}=i;if(s!==Or.prefix)throw Error(`Cannot string encode V0 in ${i.name} encoding`);let y=e.get(s);if(y==null){let g=i.encode(t).slice(1);return e.set(s,g),g}else return y}x(Rf,"toStringV0");function zf(t,e,i){let{prefix:s}=i,y=e.get(s);if(y==null){let g=i.encode(t);return e.set(s,g),g}else return y}x(zf,"toStringV1");var Ie=112,Of=18;function ei(t,e,i){let s=le(t),y=s+le(e),g=new Uint8Array(y+i.byteLength);return ge(t,g,0),ge(e,g,s),g.set(i,y),g}x(ei,"encodeCID");var Yf=Symbol.for("@ipld/js-cid/CID");var en={...Wt,...jt,...kt,...Ot,...Yt,...Ft,...Gt,...Vt,...Xt,...Ht},Ma={...Qt,...Zt};function ni(t,e,i,s){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:i},decoder:{decode:s}}}x(ni,"createCodec");var ti=ni("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),tn=ni("ascii","a",t=>{let e="a";for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return e},t=>{t=t.substring(1);let e=Pe(t.length);for(let i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return e}),jf={utf8:ti,"utf-8":ti,hex:en.base16,latin1:tn,ascii:tn,binary:tn,...en},tt=jf;function Cr(t,e="utf8"){let i=tt[e];if(i==null)throw new Error(`Unsupported encoding "${e}"`);return i.decoder.decode(`${i.prefix}${t}`)}x(Cr,"fromString");function nr(t,e="utf8"){let i=tt[e];if(i==null)throw new Error(`Unsupported encoding "${e}"`);return i.encoder.encode(t).substring(1)}x(nr,"toString");var xi={};Er(xi,{AES:()=>ur,importAesKey:()=>Ke});var si=Ti(fi(),1);var Le="did:key:z",Ae="Ed25519",nn="X25519",Hf="X25519",fn="Ed25519",on="X25519",oi={sign:["sign","verify"],encrypt:["deriveKey","deriveBits"]},te="RSA-OAEP",ne="RSASSA-PKCS1-v1_5",it="SHA-256",ft=new Uint8Array([0,245,2]),ot=2048,ie="SHA-256",Yr=8,jr="AES-GCM",Hr=jr,Fr=256,Nr=12,at=new Uint8Array([234,1]),st=new Uint8Array([237,1]),Ne={RSA:"rsa",Edwards:"ed25519",BLS:"bls12-381"},ct="rsa-exchange-key",yt="rsa-write-key",Re="ecc-exchange",ze="ecc-write",Rr=16;function Tr(t){return new Uint8Array(t).buffer}x(Tr,"toArrayBuffer");var ai={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:x(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:Gf},ed25519:{magicBytes:new Uint8Array([237,1]),verify:Ff}}};async function Ff({message:t,publicKey:e,signature:i}){return si.default.sign.detached.verify(t,i,e)}x(Ff,"ed25519Verify");async function ci(t){return new Uint8Array(await W.subtle.digest("sha-256",t.buffer))}x(ci,"sha256");async function Ye(t,e="rsa"){let i=t instanceof CryptoKey?new Uint8Array(await Wr(t)):t,s=ai.keyTypes[e]?.magicBytes;if(!s)throw new Error(`Key type '${e}' not supported, available types: ${Object.keys(ai.keyTypes).join(", ")}`);let y=It([s,i]);return Le+nr(y,"base58btc")}x(Ye,"publicKeyToDid");var kr={verify:x(async function(e,i,s,y=Yr,g=ie){return W.subtle.verify({name:ne,saltLength:Rr},typeof s=="string"?await Oe(s,g,"signing"):s,cn(i),fe(e,y))},"rsaVerify"),sign:x(async function(e,i,s=Yr){return W.subtle.sign({name:ne,saltLength:Rr},i,fe(e,s))},"sign"),encrypt:x(async function(e,i,s=Yr,y=ie){let g;return typeof i=="string"?g=await Oe(i,y,"exchange"):g=i instanceof Uint8Array?await Oe(Tr(i),y,"exchange"):i,W.subtle.encrypt({name:te},g,fe(e,s))},"rsaEncrypt"),decrypt:x(async function(e,i){let s=me(i)?i:await Jf(i,["decrypt"]),y;typeof e=="string"?y=Cr(e,"base64pad"):y=e;let g=await W.subtle.decrypt({name:te},s,y instanceof Uint8Array?Tr(y):y);return new Uint8Array(g)},"rsaDecrypt")};async function Gf({message:t,publicKey:e,signature:i}){return kr.verify(t,i,await W.subtle.importKey("spki",Tr(e),{name:ne,hash:it},!1,["verify"]),8)}x(Gf,"rsaVerify");async function Oe(t,e,i){kf(i);let s=i==="exchange"?te:ne,y=i==="exchange"?["encrypt"]:["verify"],g=typeof t=="string"?zr($f(t)):t;return W.subtle.importKey("spki",g,{name:s,hash:{name:e}},!0,y)}x(Oe,"importPublicKey");var Vf=new Error("Invalid key use. Please use 'encryption' or 'signing"),Xf=new Error("Max must be less than 256 and greater than 0");function kf(t){Wf(t,["signing","exchange"],Vf)}x(kf,"checkValidKeyUse");function Wf(t,e,i){if(!e.some(y=>y===t))throw i}x(Wf,"checkValid");function $f(t){return t.replace(`-----BEGIN PUBLIC KEY-----
|
|
1
|
+
var zi=Object.create;var Ie=Object.defineProperty;var Oi=Object.getOwnPropertyDescriptor;var Yi=Object.getOwnPropertyNames;var ji=Object.getPrototypeOf,Hi=Object.prototype.hasOwnProperty;var Fi=(n,e,i)=>e in n?Ie(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var x=(n,e)=>Ie(n,"name",{value:e,configurable:!0}),Fn=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Gn=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Sr=(n,e)=>{for(var i in e)Ie(n,i,{get:e[i],enumerable:!0})},Gi=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let y of Yi(e))!Hi.call(n,y)&&y!==i&&Ie(n,y,{get:()=>e[y],enumerable:!(s=Oi(e,y))||s.enumerable});return n};var Vi=(n,e,i)=>(i=n!=null?zi(ji(n)):{},Gi(e||!n||!n.__esModule?Ie(i,"default",{value:n,enumerable:!0}):i,n));var I=(n,e,i)=>Fi(n,typeof e!="symbol"?e+"":e,i);var gi=Gn(()=>{"use strict"});var li=Gn((gs,st)=>{"use strict";(function(n){"use strict";var e=x(function(t){var o,f=new Float64Array(16);if(t)for(o=0;o<t.length;o++)f[o]=t[o];return f},"gf"),i=x(function(){throw new Error("no PRNG")},"randombytes"),s=new Uint8Array(16),y=new Uint8Array(32);y[0]=9;var g=e(),E=e([1]),L=e([56129,1]),tr=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),or=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),fr=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Ar=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Lr=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function pe(t,o,f,r){t[o]=f>>24&255,t[o+1]=f>>16&255,t[o+2]=f>>8&255,t[o+3]=f&255,t[o+4]=r>>24&255,t[o+5]=r>>16&255,t[o+6]=r>>8&255,t[o+7]=r&255}x(pe,"ts64");function Z(t,o,f,r,a){var u,p=0;for(u=0;u<a;u++)p|=t[o+u]^f[r+u];return(1&p-1>>>8)-1}x(Z,"vn");function xr(t,o,f,r){return Z(t,o,f,r,16)}x(xr,"crypto_verify_16");function Cr(t,o,f,r){return Z(t,o,f,r,32)}x(Cr,"crypto_verify_32");function Er(t,o,f,r){for(var a=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,u=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,p=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,b=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,K=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,T=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,S=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,C=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,N=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,R=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,H=f[16]&255|(f[17]&255)<<8|(f[18]&255)<<16|(f[19]&255)<<24,j=f[20]&255|(f[21]&255)<<8|(f[22]&255)<<16|(f[23]&255)<<24,z=f[24]&255|(f[25]&255)<<8|(f[26]&255)<<16|(f[27]&255)<<24,Y=f[28]&255|(f[29]&255)<<8|(f[30]&255)<<16|(f[31]&255)<<24,O=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,_=a,D=u,v=p,P=b,B=K,U=T,h=S,d=Q,m=C,l=N,A=R,w=H,M=j,F=z,V=Y,G=O,c,k=0;k<20;k+=2)c=_+M|0,B^=c<<7|c>>>25,c=B+_|0,m^=c<<9|c>>>23,c=m+B|0,M^=c<<13|c>>>19,c=M+m|0,_^=c<<18|c>>>14,c=U+D|0,l^=c<<7|c>>>25,c=l+U|0,F^=c<<9|c>>>23,c=F+l|0,D^=c<<13|c>>>19,c=D+F|0,U^=c<<18|c>>>14,c=A+h|0,V^=c<<7|c>>>25,c=V+A|0,v^=c<<9|c>>>23,c=v+V|0,h^=c<<13|c>>>19,c=h+v|0,A^=c<<18|c>>>14,c=G+w|0,P^=c<<7|c>>>25,c=P+G|0,d^=c<<9|c>>>23,c=d+P|0,w^=c<<13|c>>>19,c=w+d|0,G^=c<<18|c>>>14,c=_+P|0,D^=c<<7|c>>>25,c=D+_|0,v^=c<<9|c>>>23,c=v+D|0,P^=c<<13|c>>>19,c=P+v|0,_^=c<<18|c>>>14,c=U+B|0,h^=c<<7|c>>>25,c=h+U|0,d^=c<<9|c>>>23,c=d+h|0,B^=c<<13|c>>>19,c=B+d|0,U^=c<<18|c>>>14,c=A+l|0,w^=c<<7|c>>>25,c=w+A|0,m^=c<<9|c>>>23,c=m+w|0,l^=c<<13|c>>>19,c=l+m|0,A^=c<<18|c>>>14,c=G+V|0,M^=c<<7|c>>>25,c=M+G|0,F^=c<<9|c>>>23,c=F+M|0,V^=c<<13|c>>>19,c=V+F|0,G^=c<<18|c>>>14;_=_+a|0,D=D+u|0,v=v+p|0,P=P+b|0,B=B+K|0,U=U+T|0,h=h+S|0,d=d+Q|0,m=m+C|0,l=l+N|0,A=A+R|0,w=w+H|0,M=M+j|0,F=F+z|0,V=V+Y|0,G=G+O|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=D>>>0&255,t[5]=D>>>8&255,t[6]=D>>>16&255,t[7]=D>>>24&255,t[8]=v>>>0&255,t[9]=v>>>8&255,t[10]=v>>>16&255,t[11]=v>>>24&255,t[12]=P>>>0&255,t[13]=P>>>8&255,t[14]=P>>>16&255,t[15]=P>>>24&255,t[16]=B>>>0&255,t[17]=B>>>8&255,t[18]=B>>>16&255,t[19]=B>>>24&255,t[20]=U>>>0&255,t[21]=U>>>8&255,t[22]=U>>>16&255,t[23]=U>>>24&255,t[24]=h>>>0&255,t[25]=h>>>8&255,t[26]=h>>>16&255,t[27]=h>>>24&255,t[28]=d>>>0&255,t[29]=d>>>8&255,t[30]=d>>>16&255,t[31]=d>>>24&255,t[32]=m>>>0&255,t[33]=m>>>8&255,t[34]=m>>>16&255,t[35]=m>>>24&255,t[36]=l>>>0&255,t[37]=l>>>8&255,t[38]=l>>>16&255,t[39]=l>>>24&255,t[40]=A>>>0&255,t[41]=A>>>8&255,t[42]=A>>>16&255,t[43]=A>>>24&255,t[44]=w>>>0&255,t[45]=w>>>8&255,t[46]=w>>>16&255,t[47]=w>>>24&255,t[48]=M>>>0&255,t[49]=M>>>8&255,t[50]=M>>>16&255,t[51]=M>>>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}x(Er,"core_salsa20");function lr(t,o,f,r){for(var a=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,u=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,p=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,b=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,K=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,T=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,S=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,C=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,N=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,R=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,H=f[16]&255|(f[17]&255)<<8|(f[18]&255)<<16|(f[19]&255)<<24,j=f[20]&255|(f[21]&255)<<8|(f[22]&255)<<16|(f[23]&255)<<24,z=f[24]&255|(f[25]&255)<<8|(f[26]&255)<<16|(f[27]&255)<<24,Y=f[28]&255|(f[29]&255)<<8|(f[30]&255)<<16|(f[31]&255)<<24,O=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,_=a,D=u,v=p,P=b,B=K,U=T,h=S,d=Q,m=C,l=N,A=R,w=H,M=j,F=z,V=Y,G=O,c,k=0;k<20;k+=2)c=_+M|0,B^=c<<7|c>>>25,c=B+_|0,m^=c<<9|c>>>23,c=m+B|0,M^=c<<13|c>>>19,c=M+m|0,_^=c<<18|c>>>14,c=U+D|0,l^=c<<7|c>>>25,c=l+U|0,F^=c<<9|c>>>23,c=F+l|0,D^=c<<13|c>>>19,c=D+F|0,U^=c<<18|c>>>14,c=A+h|0,V^=c<<7|c>>>25,c=V+A|0,v^=c<<9|c>>>23,c=v+V|0,h^=c<<13|c>>>19,c=h+v|0,A^=c<<18|c>>>14,c=G+w|0,P^=c<<7|c>>>25,c=P+G|0,d^=c<<9|c>>>23,c=d+P|0,w^=c<<13|c>>>19,c=w+d|0,G^=c<<18|c>>>14,c=_+P|0,D^=c<<7|c>>>25,c=D+_|0,v^=c<<9|c>>>23,c=v+D|0,P^=c<<13|c>>>19,c=P+v|0,_^=c<<18|c>>>14,c=U+B|0,h^=c<<7|c>>>25,c=h+U|0,d^=c<<9|c>>>23,c=d+h|0,B^=c<<13|c>>>19,c=B+d|0,U^=c<<18|c>>>14,c=A+l|0,w^=c<<7|c>>>25,c=w+A|0,m^=c<<9|c>>>23,c=m+w|0,l^=c<<13|c>>>19,c=l+m|0,A^=c<<18|c>>>14,c=G+V|0,M^=c<<7|c>>>25,c=M+G|0,F^=c<<9|c>>>23,c=F+M|0,V^=c<<13|c>>>19,c=V+F|0,G^=c<<18|c>>>14;t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=U>>>0&255,t[5]=U>>>8&255,t[6]=U>>>16&255,t[7]=U>>>24&255,t[8]=A>>>0&255,t[9]=A>>>8&255,t[10]=A>>>16&255,t[11]=A>>>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]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=m>>>0&255,t[25]=m>>>8&255,t[26]=m>>>16&255,t[27]=m>>>24&255,t[28]=l>>>0&255,t[29]=l>>>8&255,t[30]=l>>>16&255,t[31]=l>>>24&255}x(lr,"core_hsalsa20");function Ur(t,o,f,r){Er(t,o,f,r)}x(Ur,"crypto_core_salsa20");function br(t,o,f,r){lr(t,o,f,r)}x(br,"crypto_core_hsalsa20");var dr=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Nr(t,o,f,r,a,u,p){var b=new Uint8Array(16),K=new Uint8Array(64),T,S;for(S=0;S<16;S++)b[S]=0;for(S=0;S<8;S++)b[S]=u[S];for(;a>=64;){for(Ur(K,b,p,dr),S=0;S<64;S++)t[o+S]=f[r+S]^K[S];for(T=1,S=8;S<16;S++)T=T+(b[S]&255)|0,b[S]=T&255,T>>>=8;a-=64,o+=64,r+=64}if(a>0)for(Ur(K,b,p,dr),S=0;S<a;S++)t[o+S]=f[r+S]^K[S];return 0}x(Nr,"crypto_stream_salsa20_xor");function _r(t,o,f,r,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]=r[K];for(;f>=64;){for(Ur(p,u,a,dr),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;f-=64,o+=64}if(f>0)for(Ur(p,u,a,dr),K=0;K<f;K++)t[o+K]=p[K];return 0}x(_r,"crypto_stream_salsa20");function Dr(t,o,f,r,a){var u=new Uint8Array(32);br(u,r,a,dr);for(var p=new Uint8Array(8),b=0;b<8;b++)p[b]=r[b+16];return _r(t,o,f,p,u)}x(Dr,"crypto_stream");function re(t,o,f,r,a,u,p){var b=new Uint8Array(32);br(b,u,p,dr);for(var K=new Uint8Array(8),T=0;T<8;T++)K[T]=u[T+16];return Nr(t,o,f,r,a,K,b)}x(re,"crypto_stream_xor");var Ze=x(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,f,r,a,u,p,b,K;o=t[0]&255|(t[1]&255)<<8,this.r[0]=o&8191,f=t[2]&255|(t[3]&255)<<8,this.r[1]=(o>>>13|f<<3)&8191,r=t[4]&255|(t[5]&255)<<8,this.r[2]=(f>>>10|r<<6)&7939,a=t[6]&255|(t[7]&255)<<8,this.r[3]=(r>>>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");Ze.prototype.blocks=function(t,o,f){for(var r=this.fin?0:2048,a,u,p,b,K,T,S,Q,C,N,R,H,j,z,Y,O,_,D,v,P=this.h[0],B=this.h[1],U=this.h[2],h=this.h[3],d=this.h[4],m=this.h[5],l=this.h[6],A=this.h[7],w=this.h[8],M=this.h[9],F=this.r[0],V=this.r[1],G=this.r[2],c=this.r[3],k=this.r[4],rr=this.r[5],er=this.r[6],X=this.r[7],q=this.r[8],J=this.r[9];f>=16;)a=t[o+0]&255|(t[o+1]&255)<<8,P+=a&8191,u=t[o+2]&255|(t[o+3]&255)<<8,B+=(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,d+=(b>>>4|K<<12)&8191,m+=K>>>1&8191,T=t[o+10]&255|(t[o+11]&255)<<8,l+=(K>>>14|T<<2)&8191,S=t[o+12]&255|(t[o+13]&255)<<8,A+=(T>>>11|S<<5)&8191,Q=t[o+14]&255|(t[o+15]&255)<<8,w+=(S>>>8|Q<<8)&8191,M+=Q>>>5|r,C=0,N=C,N+=P*F,N+=B*(5*J),N+=U*(5*q),N+=h*(5*X),N+=d*(5*er),C=N>>>13,N&=8191,N+=m*(5*rr),N+=l*(5*k),N+=A*(5*c),N+=w*(5*G),N+=M*(5*V),C+=N>>>13,N&=8191,R=C,R+=P*V,R+=B*F,R+=U*(5*J),R+=h*(5*q),R+=d*(5*X),C=R>>>13,R&=8191,R+=m*(5*er),R+=l*(5*rr),R+=A*(5*k),R+=w*(5*c),R+=M*(5*G),C+=R>>>13,R&=8191,H=C,H+=P*G,H+=B*V,H+=U*F,H+=h*(5*J),H+=d*(5*q),C=H>>>13,H&=8191,H+=m*(5*X),H+=l*(5*er),H+=A*(5*rr),H+=w*(5*k),H+=M*(5*c),C+=H>>>13,H&=8191,j=C,j+=P*c,j+=B*G,j+=U*V,j+=h*F,j+=d*(5*J),C=j>>>13,j&=8191,j+=m*(5*q),j+=l*(5*X),j+=A*(5*er),j+=w*(5*rr),j+=M*(5*k),C+=j>>>13,j&=8191,z=C,z+=P*k,z+=B*c,z+=U*G,z+=h*V,z+=d*F,C=z>>>13,z&=8191,z+=m*(5*J),z+=l*(5*q),z+=A*(5*X),z+=w*(5*er),z+=M*(5*rr),C+=z>>>13,z&=8191,Y=C,Y+=P*rr,Y+=B*k,Y+=U*c,Y+=h*G,Y+=d*V,C=Y>>>13,Y&=8191,Y+=m*F,Y+=l*(5*J),Y+=A*(5*q),Y+=w*(5*X),Y+=M*(5*er),C+=Y>>>13,Y&=8191,O=C,O+=P*er,O+=B*rr,O+=U*k,O+=h*c,O+=d*G,C=O>>>13,O&=8191,O+=m*V,O+=l*F,O+=A*(5*J),O+=w*(5*q),O+=M*(5*X),C+=O>>>13,O&=8191,_=C,_+=P*X,_+=B*er,_+=U*rr,_+=h*k,_+=d*c,C=_>>>13,_&=8191,_+=m*G,_+=l*V,_+=A*F,_+=w*(5*J),_+=M*(5*q),C+=_>>>13,_&=8191,D=C,D+=P*q,D+=B*X,D+=U*er,D+=h*rr,D+=d*k,C=D>>>13,D&=8191,D+=m*c,D+=l*G,D+=A*V,D+=w*F,D+=M*(5*J),C+=D>>>13,D&=8191,v=C,v+=P*J,v+=B*q,v+=U*X,v+=h*er,v+=d*rr,C=v>>>13,v&=8191,v+=m*k,v+=l*c,v+=A*G,v+=w*V,v+=M*F,C+=v>>>13,v&=8191,C=(C<<2)+C|0,C=C+N|0,N=C&8191,C=C>>>13,R+=C,P=N,B=R,U=H,h=j,d=z,m=Y,l=O,A=_,w=D,M=v,o+=16,f-=16;this.h[0]=P,this.h[1]=B,this.h[2]=U,this.h[3]=h,this.h[4]=d,this.h[5]=m,this.h[6]=l,this.h[7]=A,this.h[8]=w,this.h[9]=M},Ze.prototype.finish=function(t,o){var f=new Uint16Array(10),r,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(r=this.h[1]>>>13,this.h[1]&=8191,p=2;p<10;p++)this.h[p]+=r,r=this.h[p]>>>13,this.h[p]&=8191;for(this.h[0]+=r*5,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,f[0]=this.h[0]+5,r=f[0]>>>13,f[0]&=8191,p=1;p<10;p++)f[p]=this.h[p]+r,r=f[p]>>>13,f[p]&=8191;for(f[9]-=8192,a=(r^1)-1,p=0;p<10;p++)f[p]&=a;for(a=~a,p=0;p<10;p++)this.h[p]=this.h[p]&a|f[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},Ze.prototype.update=function(t,o,f){var r,a;if(this.leftover){for(a=16-this.leftover,a>f&&(a=f),r=0;r<a;r++)this.buffer[this.leftover+r]=t[o+r];if(f-=a,o+=a,this.leftover+=a,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(f>=16&&(a=f-f%16,this.blocks(t,o,a),o+=a,f-=a),f){for(r=0;r<f;r++)this.buffer[this.leftover+r]=t[o+r];this.leftover+=f}};function wt(t,o,f,r,a,u){var p=new Ze(u);return p.update(f,r,a),p.finish(t,o),0}x(wt,"crypto_onetimeauth");function Pn(t,o,f,r,a,u){var p=new Uint8Array(16);return wt(p,0,f,r,a,u),xr(t,o,p,0)}x(Pn,"crypto_onetimeauth_verify");function Kt(t,o,f,r,a){var u;if(f<32)return-1;for(re(t,0,o,0,f,r,a),wt(t,16,t,32,f-32,t),u=0;u<16;u++)t[u]=0;return 0}x(Kt,"crypto_secretbox");function Et(t,o,f,r,a){var u,p=new Uint8Array(32);if(f<32||(Dr(p,0,32,r,a),Pn(o,16,o,32,f-32,p)!==0))return-1;for(re(t,0,o,0,f,r,a),u=0;u<32;u++)t[u]=0;return 0}x(Et,"crypto_secretbox_open");function kr(t,o){var f;for(f=0;f<16;f++)t[f]=o[f]|0}x(kr,"set25519");function Ut(t){var o,f,r=1;for(o=0;o<16;o++)f=t[o]+r+65535,r=Math.floor(f/65536),t[o]=f-r*65536;t[0]+=r-1+37*(r-1)}x(Ut,"car25519");function he(t,o,f){for(var r,a=~(f-1),u=0;u<16;u++)r=a&(t[u]^o[u]),t[u]^=r,o[u]^=r}x(he,"sel25519");function de(t,o){var f,r,a,u=e(),p=e();for(f=0;f<16;f++)p[f]=o[f];for(Ut(p),Ut(p),Ut(p),r=0;r<2;r++){for(u[0]=p[0]-65517,f=1;f<15;f++)u[f]=p[f]-65535-(u[f-1]>>16&1),u[f-1]&=65535;u[15]=p[15]-32767-(u[14]>>16&1),a=u[15]>>16&1,u[14]&=65535,he(p,u,1-a)}for(f=0;f<16;f++)t[2*f]=p[f]&255,t[2*f+1]=p[f]>>8}x(de,"pack25519");function Bn(t,o){var f=new Uint8Array(32),r=new Uint8Array(32);return de(f,t),de(r,o),Cr(f,0,r,0)}x(Bn,"neq25519");function Tn(t){var o=new Uint8Array(32);return de(o,t),o[0]&1}x(Tn,"par25519");function St(t,o){var f;for(f=0;f<16;f++)t[f]=o[2*f]+(o[2*f+1]<<8);t[15]&=32767}x(St,"unpack25519");function Rr(t,o,f){for(var r=0;r<16;r++)t[r]=o[r]+f[r]}x(Rr,"A");function zr(t,o,f){for(var r=0;r<16;r++)t[r]=o[r]-f[r]}x(zr,"Z");function W(t,o,f){var r,a,u=0,p=0,b=0,K=0,T=0,S=0,Q=0,C=0,N=0,R=0,H=0,j=0,z=0,Y=0,O=0,_=0,D=0,v=0,P=0,B=0,U=0,h=0,d=0,m=0,l=0,A=0,w=0,M=0,F=0,V=0,G=0,c=f[0],k=f[1],rr=f[2],er=f[3],X=f[4],q=f[5],J=f[6],ur=f[7],nr=f[8],ar=f[9],sr=f[10],cr=f[11],hr=f[12],mr=f[13],wr=f[14],Kr=f[15];r=o[0],u+=r*c,p+=r*k,b+=r*rr,K+=r*er,T+=r*X,S+=r*q,Q+=r*J,C+=r*ur,N+=r*nr,R+=r*ar,H+=r*sr,j+=r*cr,z+=r*hr,Y+=r*mr,O+=r*wr,_+=r*Kr,r=o[1],p+=r*c,b+=r*k,K+=r*rr,T+=r*er,S+=r*X,Q+=r*q,C+=r*J,N+=r*ur,R+=r*nr,H+=r*ar,j+=r*sr,z+=r*cr,Y+=r*hr,O+=r*mr,_+=r*wr,D+=r*Kr,r=o[2],b+=r*c,K+=r*k,T+=r*rr,S+=r*er,Q+=r*X,C+=r*q,N+=r*J,R+=r*ur,H+=r*nr,j+=r*ar,z+=r*sr,Y+=r*cr,O+=r*hr,_+=r*mr,D+=r*wr,v+=r*Kr,r=o[3],K+=r*c,T+=r*k,S+=r*rr,Q+=r*er,C+=r*X,N+=r*q,R+=r*J,H+=r*ur,j+=r*nr,z+=r*ar,Y+=r*sr,O+=r*cr,_+=r*hr,D+=r*mr,v+=r*wr,P+=r*Kr,r=o[4],T+=r*c,S+=r*k,Q+=r*rr,C+=r*er,N+=r*X,R+=r*q,H+=r*J,j+=r*ur,z+=r*nr,Y+=r*ar,O+=r*sr,_+=r*cr,D+=r*hr,v+=r*mr,P+=r*wr,B+=r*Kr,r=o[5],S+=r*c,Q+=r*k,C+=r*rr,N+=r*er,R+=r*X,H+=r*q,j+=r*J,z+=r*ur,Y+=r*nr,O+=r*ar,_+=r*sr,D+=r*cr,v+=r*hr,P+=r*mr,B+=r*wr,U+=r*Kr,r=o[6],Q+=r*c,C+=r*k,N+=r*rr,R+=r*er,H+=r*X,j+=r*q,z+=r*J,Y+=r*ur,O+=r*nr,_+=r*ar,D+=r*sr,v+=r*cr,P+=r*hr,B+=r*mr,U+=r*wr,h+=r*Kr,r=o[7],C+=r*c,N+=r*k,R+=r*rr,H+=r*er,j+=r*X,z+=r*q,Y+=r*J,O+=r*ur,_+=r*nr,D+=r*ar,v+=r*sr,P+=r*cr,B+=r*hr,U+=r*mr,h+=r*wr,d+=r*Kr,r=o[8],N+=r*c,R+=r*k,H+=r*rr,j+=r*er,z+=r*X,Y+=r*q,O+=r*J,_+=r*ur,D+=r*nr,v+=r*ar,P+=r*sr,B+=r*cr,U+=r*hr,h+=r*mr,d+=r*wr,m+=r*Kr,r=o[9],R+=r*c,H+=r*k,j+=r*rr,z+=r*er,Y+=r*X,O+=r*q,_+=r*J,D+=r*ur,v+=r*nr,P+=r*ar,B+=r*sr,U+=r*cr,h+=r*hr,d+=r*mr,m+=r*wr,l+=r*Kr,r=o[10],H+=r*c,j+=r*k,z+=r*rr,Y+=r*er,O+=r*X,_+=r*q,D+=r*J,v+=r*ur,P+=r*nr,B+=r*ar,U+=r*sr,h+=r*cr,d+=r*hr,m+=r*mr,l+=r*wr,A+=r*Kr,r=o[11],j+=r*c,z+=r*k,Y+=r*rr,O+=r*er,_+=r*X,D+=r*q,v+=r*J,P+=r*ur,B+=r*nr,U+=r*ar,h+=r*sr,d+=r*cr,m+=r*hr,l+=r*mr,A+=r*wr,w+=r*Kr,r=o[12],z+=r*c,Y+=r*k,O+=r*rr,_+=r*er,D+=r*X,v+=r*q,P+=r*J,B+=r*ur,U+=r*nr,h+=r*ar,d+=r*sr,m+=r*cr,l+=r*hr,A+=r*mr,w+=r*wr,M+=r*Kr,r=o[13],Y+=r*c,O+=r*k,_+=r*rr,D+=r*er,v+=r*X,P+=r*q,B+=r*J,U+=r*ur,h+=r*nr,d+=r*ar,m+=r*sr,l+=r*cr,A+=r*hr,w+=r*mr,M+=r*wr,F+=r*Kr,r=o[14],O+=r*c,_+=r*k,D+=r*rr,v+=r*er,P+=r*X,B+=r*q,U+=r*J,h+=r*ur,d+=r*nr,m+=r*ar,l+=r*sr,A+=r*cr,w+=r*hr,M+=r*mr,F+=r*wr,V+=r*Kr,r=o[15],_+=r*c,D+=r*k,v+=r*rr,P+=r*er,B+=r*X,U+=r*q,h+=r*J,d+=r*ur,m+=r*nr,l+=r*ar,A+=r*sr,w+=r*cr,M+=r*hr,F+=r*mr,V+=r*wr,G+=r*Kr,u+=38*D,p+=38*v,b+=38*P,K+=38*B,T+=38*U,S+=38*h,Q+=38*d,C+=38*m,N+=38*l,R+=38*A,H+=38*w,j+=38*M,z+=38*F,Y+=38*V,O+=38*G,a=1,r=u+a+65535,a=Math.floor(r/65536),u=r-a*65536,r=p+a+65535,a=Math.floor(r/65536),p=r-a*65536,r=b+a+65535,a=Math.floor(r/65536),b=r-a*65536,r=K+a+65535,a=Math.floor(r/65536),K=r-a*65536,r=T+a+65535,a=Math.floor(r/65536),T=r-a*65536,r=S+a+65535,a=Math.floor(r/65536),S=r-a*65536,r=Q+a+65535,a=Math.floor(r/65536),Q=r-a*65536,r=C+a+65535,a=Math.floor(r/65536),C=r-a*65536,r=N+a+65535,a=Math.floor(r/65536),N=r-a*65536,r=R+a+65535,a=Math.floor(r/65536),R=r-a*65536,r=H+a+65535,a=Math.floor(r/65536),H=r-a*65536,r=j+a+65535,a=Math.floor(r/65536),j=r-a*65536,r=z+a+65535,a=Math.floor(r/65536),z=r-a*65536,r=Y+a+65535,a=Math.floor(r/65536),Y=r-a*65536,r=O+a+65535,a=Math.floor(r/65536),O=r-a*65536,r=_+a+65535,a=Math.floor(r/65536),_=r-a*65536,u+=a-1+37*(a-1),a=1,r=u+a+65535,a=Math.floor(r/65536),u=r-a*65536,r=p+a+65535,a=Math.floor(r/65536),p=r-a*65536,r=b+a+65535,a=Math.floor(r/65536),b=r-a*65536,r=K+a+65535,a=Math.floor(r/65536),K=r-a*65536,r=T+a+65535,a=Math.floor(r/65536),T=r-a*65536,r=S+a+65535,a=Math.floor(r/65536),S=r-a*65536,r=Q+a+65535,a=Math.floor(r/65536),Q=r-a*65536,r=C+a+65535,a=Math.floor(r/65536),C=r-a*65536,r=N+a+65535,a=Math.floor(r/65536),N=r-a*65536,r=R+a+65535,a=Math.floor(r/65536),R=r-a*65536,r=H+a+65535,a=Math.floor(r/65536),H=r-a*65536,r=j+a+65535,a=Math.floor(r/65536),j=r-a*65536,r=z+a+65535,a=Math.floor(r/65536),z=r-a*65536,r=Y+a+65535,a=Math.floor(r/65536),Y=r-a*65536,r=O+a+65535,a=Math.floor(r/65536),O=r-a*65536,r=_+a+65535,a=Math.floor(r/65536),_=r-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]=S,t[6]=Q,t[7]=C,t[8]=N,t[9]=R,t[10]=H,t[11]=j,t[12]=z,t[13]=Y,t[14]=O,t[15]=_}x(W,"M");function Mr(t,o){W(t,o,o)}x(Mr,"S");function Dn(t,o){var f=e(),r;for(r=0;r<16;r++)f[r]=o[r];for(r=253;r>=0;r--)Mr(f,f),r!==2&&r!==4&&W(f,f,o);for(r=0;r<16;r++)t[r]=f[r]}x(Dn,"inv25519");function Mn(t,o){var f=e(),r;for(r=0;r<16;r++)f[r]=o[r];for(r=250;r>=0;r--)Mr(f,f),r!==1&&W(f,f,o);for(r=0;r<16;r++)t[r]=f[r]}x(Mn,"pow2523");function qe(t,o,f){var r=new Uint8Array(32),a=new Float64Array(80),u,p,b=e(),K=e(),T=e(),S=e(),Q=e(),C=e();for(p=0;p<31;p++)r[p]=o[p];for(r[31]=o[31]&127|64,r[0]&=248,St(a,f),p=0;p<16;p++)K[p]=a[p],S[p]=b[p]=T[p]=0;for(b[0]=S[0]=1,p=254;p>=0;--p)u=r[p>>>3]>>>(p&7)&1,he(b,K,u),he(T,S,u),Rr(Q,b,T),zr(b,b,T),Rr(T,K,S),zr(K,K,S),Mr(S,Q),Mr(C,b),W(b,T,b),W(T,K,Q),Rr(Q,b,T),zr(b,b,T),Mr(K,b),zr(T,S,C),W(b,T,L),Rr(b,b,S),W(T,T,b),W(b,S,C),W(S,K,a),Mr(K,Q),he(b,K,u),he(T,S,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]=S[p];var N=a.subarray(32),R=a.subarray(16);return Dn(N,N),W(R,R,N),de(t,R),0}x(qe,"crypto_scalarmult");function Je(t,o){return qe(t,o,y)}x(Je,"crypto_scalarmult_base");function In(t,o){return i(o,32),Je(t,o)}x(In,"crypto_box_keypair");function Qe(t,o,f){var r=new Uint8Array(32);return qe(r,f,o),br(t,s,r,dr)}x(Qe,"crypto_box_beforenm");var Ln=Kt,Ti=Et;function Di(t,o,f,r,a,u){var p=new Uint8Array(32);return Qe(p,a,u),Ln(t,o,f,r,p)}x(Di,"crypto_box");function Mi(t,o,f,r,a,u){var p=new Uint8Array(32);return Qe(p,a,u),Ti(t,o,f,r,p)}x(Mi,"crypto_box_open");var Nn=[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 Rn(t,o,f,r){for(var a=new Int32Array(16),u=new Int32Array(16),p,b,K,T,S,Q,C,N,R,H,j,z,Y,O,_,D,v,P,B,U,h,d,m,l,A,w,M=t[0],F=t[1],V=t[2],G=t[3],c=t[4],k=t[5],rr=t[6],er=t[7],X=o[0],q=o[1],J=o[2],ur=o[3],nr=o[4],ar=o[5],sr=o[6],cr=o[7],hr=0;r>=128;){for(B=0;B<16;B++)U=8*B+hr,a[B]=f[U+0]<<24|f[U+1]<<16|f[U+2]<<8|f[U+3],u[B]=f[U+4]<<24|f[U+5]<<16|f[U+6]<<8|f[U+7];for(B=0;B<80;B++)if(p=M,b=F,K=V,T=G,S=c,Q=k,C=rr,N=er,R=X,H=q,j=J,z=ur,Y=nr,O=ar,_=sr,D=cr,h=er,d=cr,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=(c>>>14|nr<<18)^(c>>>18|nr<<14)^(nr>>>9|c<<23),d=(nr>>>14|c<<18)^(nr>>>18|c<<14)^(c>>>9|nr<<23),m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,h=c&k^~c&rr,d=nr&ar^~nr&sr,m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,h=Nn[B*2],d=Nn[B*2+1],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,h=a[B%16],d=u[B%16],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,v=A&65535|w<<16,P=m&65535|l<<16,h=v,d=P,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=(M>>>28|X<<4)^(X>>>2|M<<30)^(X>>>7|M<<25),d=(X>>>28|M<<4)^(M>>>2|X<<30)^(M>>>7|X<<25),m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,h=M&F^M&V^F&V,d=X&q^X&J^q&J,m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,N=A&65535|w<<16,D=m&65535|l<<16,h=T,d=z,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=v,d=P,m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,T=A&65535|w<<16,z=m&65535|l<<16,F=p,V=b,G=K,c=T,k=S,rr=Q,er=C,M=N,q=R,J=H,ur=j,nr=z,ar=Y,sr=O,cr=_,X=D,B%16===15)for(U=0;U<16;U++)h=a[U],d=u[U],m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=a[(U+9)%16],d=u[(U+9)%16],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,v=a[(U+1)%16],P=u[(U+1)%16],h=(v>>>1|P<<31)^(v>>>8|P<<24)^v>>>7,d=(P>>>1|v<<31)^(P>>>8|v<<24)^(P>>>7|v<<25),m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,v=a[(U+14)%16],P=u[(U+14)%16],h=(v>>>19|P<<13)^(P>>>29|v<<3)^v>>>6,d=(P>>>19|v<<13)^(v>>>29|P<<3)^(P>>>6|v<<26),m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,a[U]=A&65535|w<<16,u[U]=m&65535|l<<16;h=M,d=X,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=t[0],d=o[0],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,t[0]=M=A&65535|w<<16,o[0]=X=m&65535|l<<16,h=F,d=q,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=t[1],d=o[1],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,t[1]=F=A&65535|w<<16,o[1]=q=m&65535|l<<16,h=V,d=J,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=t[2],d=o[2],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,t[2]=V=A&65535|w<<16,o[2]=J=m&65535|l<<16,h=G,d=ur,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=t[3],d=o[3],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,t[3]=G=A&65535|w<<16,o[3]=ur=m&65535|l<<16,h=c,d=nr,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=t[4],d=o[4],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,t[4]=c=A&65535|w<<16,o[4]=nr=m&65535|l<<16,h=k,d=ar,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=t[5],d=o[5],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,t[5]=k=A&65535|w<<16,o[5]=ar=m&65535|l<<16,h=rr,d=sr,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=t[6],d=o[6],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,t[6]=rr=A&65535|w<<16,o[6]=sr=m&65535|l<<16,h=er,d=cr,m=d&65535,l=d>>>16,A=h&65535,w=h>>>16,h=t[7],d=o[7],m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,l+=m>>>16,A+=l>>>16,w+=A>>>16,t[7]=er=A&65535|w<<16,o[7]=cr=m&65535|l<<16,hr+=128,r-=128}return r}x(Rn,"crypto_hashblocks_hl");function ie(t,o,f){var r=new Int32Array(8),a=new Int32Array(8),u=new Uint8Array(256),p,b=f;for(r[0]=1779033703,r[1]=3144134277,r[2]=1013904242,r[3]=2773480762,r[4]=1359893119,r[5]=2600822924,r[6]=528734635,r[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,Rn(r,a,o,f),f%=128,p=0;p<f;p++)u[p]=o[b-f+p];for(u[f]=128,f=256-128*(f<112?1:0),u[f-9]=0,pe(u,f-8,b/536870912|0,b<<3),Rn(r,a,u,f),p=0;p<8;p++)pe(t,8*p,r[p],a[p]);return 0}x(ie,"crypto_hash");function rt(t,o){var f=e(),r=e(),a=e(),u=e(),p=e(),b=e(),K=e(),T=e(),S=e();zr(f,t[1],t[0]),zr(S,o[1],o[0]),W(f,f,S),Rr(r,t[0],t[1]),Rr(S,o[0],o[1]),W(r,r,S),W(a,t[3],o[3]),W(a,a,or),W(u,t[2],o[2]),Rr(u,u,u),zr(p,r,f),zr(b,u,a),Rr(K,u,a),Rr(T,r,f),W(t[0],p,b),W(t[1],T,K),W(t[2],K,b),W(t[3],p,T)}x(rt,"add");function zn(t,o,f){var r;for(r=0;r<4;r++)he(t[r],o[r],f)}x(zn,"cswap");function vt(t,o){var f=e(),r=e(),a=e();Dn(a,o[2]),W(f,o[0],a),W(r,o[1],a),de(t,r),t[31]^=Tn(f)<<7}x(vt,"pack");function Ct(t,o,f){var r,a;for(kr(t[0],g),kr(t[1],E),kr(t[2],E),kr(t[3],g),a=255;a>=0;--a)r=f[a/8|0]>>(a&7)&1,zn(t,o,r),rt(o,t),rt(t,t),zn(t,o,r)}x(Ct,"scalarmult");function et(t,o){var f=[e(),e(),e(),e()];kr(f[0],fr),kr(f[1],Ar),kr(f[2],E),W(f[3],fr,Ar),Ct(t,f,o)}x(et,"scalarbase");function _t(t,o,f){var r=new Uint8Array(64),a=[e(),e(),e(),e()],u;for(f||i(o,32),ie(r,o,32),r[0]&=248,r[31]&=127,r[31]|=64,et(a,r),vt(t,a),u=0;u<32;u++)o[u+32]=t[u];return 0}x(_t,"crypto_sign_keypair");var tt=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 Pt(t,o){var f,r,a,u;for(r=63;r>=32;--r){for(f=0,a=r-32,u=r-12;a<u;++a)o[a]+=f-16*o[r]*tt[a-(r-32)],f=Math.floor((o[a]+128)/256),o[a]-=f*256;o[a]+=f,o[r]=0}for(f=0,a=0;a<32;a++)o[a]+=f-(o[31]>>4)*tt[a],f=o[a]>>8,o[a]&=255;for(a=0;a<32;a++)o[a]-=f*tt[a];for(r=0;r<32;r++)o[r+1]+=o[r]>>8,t[r]=o[r]&255}x(Pt,"modL");function Bt(t){var o=new Float64Array(64),f;for(f=0;f<64;f++)o[f]=t[f];for(f=0;f<64;f++)t[f]=0;Pt(t,o)}x(Bt,"reduce");function On(t,o,f,r){var a=new Uint8Array(64),u=new Uint8Array(64),p=new Uint8Array(64),b,K,T=new Float64Array(64),S=[e(),e(),e(),e()];ie(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64;var Q=f+64;for(b=0;b<f;b++)t[64+b]=o[b];for(b=0;b<32;b++)t[32+b]=a[32+b];for(ie(p,t.subarray(32),f+32),Bt(p),et(S,p),vt(t,S),b=32;b<64;b++)t[b]=r[b];for(ie(u,t,f+64),Bt(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 Pt(t.subarray(32),T),Q}x(On,"crypto_sign");function Ii(t,o){var f=e(),r=e(),a=e(),u=e(),p=e(),b=e(),K=e();return kr(t[2],E),St(t[1],o),Mr(a,t[1]),W(u,a,tr),zr(a,a,t[2]),Rr(u,t[2],u),Mr(p,u),Mr(b,p),W(K,b,p),W(f,K,a),W(f,f,u),Mn(f,f),W(f,f,a),W(f,f,u),W(f,f,u),W(t[0],f,u),Mr(r,t[0]),W(r,r,u),Bn(r,a)&&W(t[0],t[0],Lr),Mr(r,t[0]),W(r,r,u),Bn(r,a)?-1:(Tn(t[0])===o[31]>>7&&zr(t[0],g,t[0]),W(t[3],t[0],t[1]),0)}x(Ii,"unpackneg");function Tt(t,o,f,r){var a,u=new Uint8Array(32),p=new Uint8Array(64),b=[e(),e(),e(),e()],K=[e(),e(),e(),e()];if(f<64||Ii(K,r))return-1;for(a=0;a<f;a++)t[a]=o[a];for(a=0;a<32;a++)t[a+32]=r[a];if(ie(p,t,f),Bt(p),Ct(b,K,p),et(K,o.subarray(32)),rt(b,K),vt(u,b),f-=64,Cr(o,0,u,0)){for(a=0;a<f;a++)t[a]=0;return-1}for(a=0;a<f;a++)t[a]=o[a+64];return f}x(Tt,"crypto_sign_open");var Dt=32,nt=24,Be=32,ge=16,Te=32,it=32,De=32,Me=32,Mt=32,Yn=nt,Li=Be,Ni=ge,Wr=64,fe=32,le=64,It=32,Lt=64;n.lowlevel={crypto_core_hsalsa20:br,crypto_stream_xor:re,crypto_stream:Dr,crypto_stream_salsa20_xor:Nr,crypto_stream_salsa20:_r,crypto_onetimeauth:wt,crypto_onetimeauth_verify:Pn,crypto_verify_16:xr,crypto_verify_32:Cr,crypto_secretbox:Kt,crypto_secretbox_open:Et,crypto_scalarmult:qe,crypto_scalarmult_base:Je,crypto_box_beforenm:Qe,crypto_box_afternm:Ln,crypto_box:Di,crypto_box_open:Mi,crypto_box_keypair:In,crypto_hash:ie,crypto_sign:On,crypto_sign_keypair:_t,crypto_sign_open:Tt,crypto_secretbox_KEYBYTES:Dt,crypto_secretbox_NONCEBYTES:nt,crypto_secretbox_ZEROBYTES:Be,crypto_secretbox_BOXZEROBYTES:ge,crypto_scalarmult_BYTES:Te,crypto_scalarmult_SCALARBYTES:it,crypto_box_PUBLICKEYBYTES:De,crypto_box_SECRETKEYBYTES:Me,crypto_box_BEFORENMBYTES:Mt,crypto_box_NONCEBYTES:Yn,crypto_box_ZEROBYTES:Li,crypto_box_BOXZEROBYTES:Ni,crypto_sign_BYTES:Wr,crypto_sign_PUBLICKEYBYTES:fe,crypto_sign_SECRETKEYBYTES:le,crypto_sign_SEEDBYTES:It,crypto_hash_BYTES:Lt,gf:e,D:tr,L:tt,pack25519:de,unpack25519:St,M:W,A:Rr,S:Mr,Z:zr,pow2523:Mn,add:rt,set25519:kr,modL:Pt,scalarmult:Ct,scalarbase:et};function jn(t,o){if(t.length!==Dt)throw new Error("bad key size");if(o.length!==nt)throw new Error("bad nonce size")}x(jn,"checkLengths");function Ri(t,o){if(t.length!==De)throw new Error("bad public key size");if(o.length!==Me)throw new Error("bad secret key size")}x(Ri,"checkBoxLengths");function Br(){for(var t=0;t<arguments.length;t++)if(!(arguments[t]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}x(Br,"checkArrayTypes");function Hn(t){for(var o=0;o<t.length;o++)t[o]=0}x(Hn,"cleanup"),n.randomBytes=function(t){var o=new Uint8Array(t);return i(o,t),o},n.secretbox=function(t,o,f){Br(t,o,f),jn(f,o);for(var r=new Uint8Array(Be+t.length),a=new Uint8Array(r.length),u=0;u<t.length;u++)r[u+Be]=t[u];return Kt(a,r,r.length,o,f),a.subarray(ge)},n.secretbox.open=function(t,o,f){Br(t,o,f),jn(f,o);for(var r=new Uint8Array(ge+t.length),a=new Uint8Array(r.length),u=0;u<t.length;u++)r[u+ge]=t[u];return r.length<32||Et(a,r,r.length,o,f)!==0?null:a.subarray(Be)},n.secretbox.keyLength=Dt,n.secretbox.nonceLength=nt,n.secretbox.overheadLength=ge,n.scalarMult=function(t,o){if(Br(t,o),t.length!==it)throw new Error("bad n size");if(o.length!==Te)throw new Error("bad p size");var f=new Uint8Array(Te);return qe(f,t,o),f},n.scalarMult.base=function(t){if(Br(t),t.length!==it)throw new Error("bad n size");var o=new Uint8Array(Te);return Je(o,t),o},n.scalarMult.scalarLength=it,n.scalarMult.groupElementLength=Te,n.box=function(t,o,f,r){var a=n.box.before(f,r);return n.secretbox(t,o,a)},n.box.before=function(t,o){Br(t,o),Ri(t,o);var f=new Uint8Array(Mt);return Qe(f,t,o),f},n.box.after=n.secretbox,n.box.open=function(t,o,f,r){var a=n.box.before(f,r);return n.secretbox.open(t,o,a)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var t=new Uint8Array(De),o=new Uint8Array(Me);return In(t,o),{publicKey:t,secretKey:o}},n.box.keyPair.fromSecretKey=function(t){if(Br(t),t.length!==Me)throw new Error("bad secret key size");var o=new Uint8Array(De);return Je(o,t),{publicKey:o,secretKey:new Uint8Array(t)}},n.box.publicKeyLength=De,n.box.secretKeyLength=Me,n.box.sharedKeyLength=Mt,n.box.nonceLength=Yn,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(t,o){if(Br(t,o),o.length!==le)throw new Error("bad secret key size");var f=new Uint8Array(Wr+t.length);return On(f,t,t.length,o),f},n.sign.open=function(t,o){if(Br(t,o),o.length!==fe)throw new Error("bad public key size");var f=new Uint8Array(t.length),r=Tt(f,t,t.length,o);if(r<0)return null;for(var a=new Uint8Array(r),u=0;u<a.length;u++)a[u]=f[u];return a},n.sign.detached=function(t,o){for(var f=n.sign(t,o),r=new Uint8Array(Wr),a=0;a<r.length;a++)r[a]=f[a];return r},n.sign.detached.verify=function(t,o,f){if(Br(t,o,f),o.length!==Wr)throw new Error("bad signature size");if(f.length!==fe)throw new Error("bad public key size");var r=new Uint8Array(Wr+t.length),a=new Uint8Array(Wr+t.length),u;for(u=0;u<Wr;u++)r[u]=o[u];for(u=0;u<t.length;u++)r[u+Wr]=t[u];return Tt(a,r,r.length,f)>=0},n.sign.keyPair=function(){var t=new Uint8Array(fe),o=new Uint8Array(le);return _t(t,o),{publicKey:t,secretKey:o}},n.sign.keyPair.fromSecretKey=function(t){if(Br(t),t.length!==le)throw new Error("bad secret key size");for(var o=new Uint8Array(fe),f=0;f<o.length;f++)o[f]=t[32+f];return{publicKey:o,secretKey:new Uint8Array(t)}},n.sign.keyPair.fromSeed=function(t){if(Br(t),t.length!==It)throw new Error("bad seed size");for(var o=new Uint8Array(fe),f=new Uint8Array(le),r=0;r<32;r++)f[r]=t[r];return _t(o,f,!0),{publicKey:o,secretKey:f}},n.sign.publicKeyLength=fe,n.sign.secretKeyLength=le,n.sign.seedLength=It,n.sign.signatureLength=Wr,n.hash=function(t){Br(t);var o=new Uint8Array(Lt);return ie(o,t,t.length),o},n.hash.hashLength=Lt,n.verify=function(t,o){return Br(t,o),t.length===0||o.length===0||t.length!==o.length?!1:Z(t,0,o,0,t.length)===0},n.setPRNG=function(t){i=t},function(){var t=typeof self<"u"?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){var o=65536;n.setPRNG(function(f,r){var a,u=new Uint8Array(r);for(a=0;a<r;a+=o)t.getRandomValues(u.subarray(a,a+Math.min(r-a,o)));for(a=0;a<r;a++)f[a]=u[a];Hn(u)})}else typeof Fn<"u"&&(t=gi(),t&&t.randomBytes&&n.setPRNG(function(f,r){var a,u=t.randomBytes(r);for(a=0;a<r;a++)f[a]=u[a];Hn(u)}))}()})(typeof st<"u"&&st.exports?st.exports:self.nacl=self.nacl||{})});var Vn=(s=>(s[s.B1024=1024]="B1024",s[s.B2048=2048]="B2048",s[s.B4096=4096]="B4096",s))(Vn||{}),Xn=(s=>(s[s.B128=128]="B128",s[s.B192=192]="B192",s[s.B256=256]="B256",s))(Xn||{}),kn=(i=>(i.ECC="ecc",i.RSA="rsa",i))(kn||{}),Nt=(y=>(y.SHA_1="SHA-1",y.SHA_256="SHA-256",y.SHA_384="SHA-384",y.SHA_512="SHA-512",y))(Nt||{}),Rt=(y=>(y.P_256="P-256",y.P_384="P-384",y.P_521="P-521",y.X25519="X25519",y))(Rt||{}),be=(s=>(s.Sign="signing",s.Exchange="exchange",s.Write="write",s))(be||{}),zt=(i=>(i[i.B8=8]="B8",i[i.B16=16]="B16",i))(zt||{});var _i={};Sr(_i,{AES_GCM:()=>Gr,BASE58_DID_PREFIX:()=>je,BLS_DID_PREFIX:()=>ut,DEFAULT_CHAR_SIZE:()=>Fr,DEFAULT_ECC_EXCHANGE:()=>Fe,DEFAULT_ECC_EXCHANGE_CURVE:()=>to,DEFAULT_ECC_WRITE:()=>Ge,DEFAULT_HASH_ALGORITHM:()=>ce,DEFAULT_RSA_EXCHANGE:()=>ht,DEFAULT_RSA_SIZE:()=>xt,DEFAULT_RSA_WRITE:()=>dt,DEFAULT_SYMM_ALGORITHM:()=>Vr,DEFAULT_SYMM_LENGTH:()=>Xr,ECC_EXCHANGE_ALG:()=>dn,ECC_EXCHANGE_NAME:()=>ln,ECC_WRITE_ALG:()=>Ue,ECC_WRITE_NAME:()=>gn,EDWARDS_DID_PREFIX:()=>pt,IV_LENGTH:()=>Or,KEY_TYPE:()=>He,KEY_USE:()=>bi,RSA_ALGORITHM:()=>ae,RSA_DID_PREFIX:()=>yt,RSA_HASHING_ALGORITHM:()=>ct,RSA_SIGN_ALGORITHM:()=>se,RsaKeys:()=>ue,SALT_LENGTH:()=>Yr,encrypt:()=>Ko,encryptKeyTo:()=>Pe,encryptTo:()=>Ci,getPublicKeyAsArrayBuffer:()=>qr,getPublicKeyAsUint8Array:()=>wn,publicKeyToDid:()=>Xe,verify:()=>wo});var Xi=globalThis||window||self,$=Xi.crypto;function Le(n=0){return new Uint8Array(n)}x(Le,"allocUnsafe");function Ot(n,e){e==null&&(e=n.reduce((y,g)=>y+g.length,0));let i=Le(e),s=0;for(let y of n)i.set(y,s),s+=y.length;return i}x(Ot,"concat");var Wt={};Sr(Wt,{base10:()=>Qi});var ko=new Uint8Array(0);function Wn(n,e){if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let i=0;i<n.byteLength;i++)if(n[i]!==e[i])return!1;return!0}x(Wn,"equals");function $r(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")}x($r,"coerce");function $n(n){return new TextEncoder().encode(n)}x($n,"fromString");function Zn(n){return new TextDecoder().decode(n)}x(Zn,"toString");function Wi(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var i=new Uint8Array(256),s=0;s<i.length;s++)i[s]=255;for(var y=0;y<n.length;y++){var g=n.charAt(y),E=g.charCodeAt(0);if(i[E]!==255)throw new TypeError(g+" is ambiguous");i[E]=y}var L=n.length,tr=n.charAt(0),or=Math.log(L)/Math.log(256),fr=Math.log(256)/Math.log(L);function Ar(Z){if(Z instanceof Uint8Array||(ArrayBuffer.isView(Z)?Z=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength):Array.isArray(Z)&&(Z=Uint8Array.from(Z))),!(Z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(Z.length===0)return"";for(var xr=0,Cr=0,Er=0,lr=Z.length;Er!==lr&&Z[Er]===0;)Er++,xr++;for(var Ur=(lr-Er)*fr+1>>>0,br=new Uint8Array(Ur);Er!==lr;){for(var dr=Z[Er],Nr=0,_r=Ur-1;(dr!==0||Nr<Cr)&&_r!==-1;_r--,Nr++)dr+=256*br[_r]>>>0,br[_r]=dr%L>>>0,dr=dr/L>>>0;if(dr!==0)throw new Error("Non-zero carry");Cr=Nr,Er++}for(var Dr=Ur-Cr;Dr!==Ur&&br[Dr]===0;)Dr++;for(var re=tr.repeat(xr);Dr<Ur;++Dr)re+=n.charAt(br[Dr]);return re}x(Ar,"encode");function Lr(Z){if(typeof Z!="string")throw new TypeError("Expected String");if(Z.length===0)return new Uint8Array;var xr=0;if(Z[xr]!==" "){for(var Cr=0,Er=0;Z[xr]===tr;)Cr++,xr++;for(var lr=(Z.length-xr)*or+1>>>0,Ur=new Uint8Array(lr);Z[xr];){var br=i[Z.charCodeAt(xr)];if(br===255)return;for(var dr=0,Nr=lr-1;(br!==0||dr<Er)&&Nr!==-1;Nr--,dr++)br+=L*Ur[Nr]>>>0,Ur[Nr]=br%256>>>0,br=br/256>>>0;if(br!==0)throw new Error("Non-zero carry");Er=dr,xr++}if(Z[xr]!==" "){for(var _r=lr-Er;_r!==lr&&Ur[_r]===0;)_r++;for(var Dr=new Uint8Array(Cr+(lr-_r)),re=Cr;_r!==lr;)Dr[re++]=Ur[_r++];return Dr}}}x(Lr,"decodeUnsafe");function pe(Z){var xr=Lr(Z);if(xr)return xr;throw new Error(`Non-${e} character`)}return x(pe,"decode"),{encode:Ar,decodeUnsafe:Lr,decode:pe}}x(Wi,"base");var $i=Wi,Zi=$i,Jn=Zi;var Gt=class Gt{constructor(e,i,s){I(this,"name");I(this,"prefix");I(this,"baseEncode");this.name=e,this.prefix=i,this.baseEncode=s}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};x(Gt,"Encoder");var Yt=Gt,Vt=class Vt{constructor(e,i,s){I(this,"name");I(this,"prefix");I(this,"baseDecode");I(this,"prefixCodePoint");this.name=e,this.prefix=i;let y=i.codePointAt(0);if(y===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=y,this.baseDecode=s}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Qn(this,e)}};x(Vt,"Decoder");var jt=Vt,Xt=class Xt{constructor(e){I(this,"decoders");this.decoders=e}or(e){return Qn(this,e)}decode(e){let i=e[0],s=this.decoders[i];if(s!=null)return s.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};x(Xt,"ComposedDecoder");var Ht=Xt;function Qn(n,e){return new Ht({...n.decoders??{[n.prefix]:n},...e.decoders??{[e.prefix]:e}})}x(Qn,"or");var kt=class kt{constructor(e,i,s,y){I(this,"name");I(this,"prefix");I(this,"baseEncode");I(this,"baseDecode");I(this,"encoder");I(this,"decoder");this.name=e,this.prefix=i,this.baseEncode=s,this.baseDecode=y,this.encoder=new Yt(e,i,s),this.decoder=new jt(e,i,y)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};x(kt,"Codec");var Ft=kt;function Ae({name:n,prefix:e,encode:i,decode:s}){return new Ft(n,e,i,s)}x(Ae,"from");function ee({name:n,prefix:e,alphabet:i}){let{encode:s,decode:y}=Jn(i,n);return Ae({prefix:e,name:n,encode:s,decode:x(g=>$r(y(g)),"decode")})}x(ee,"baseX");function qi(n,e,i,s){let y={};for(let fr=0;fr<e.length;++fr)y[e[fr]]=fr;let g=n.length;for(;n[g-1]==="=";)--g;let E=new Uint8Array(g*i/8|0),L=0,tr=0,or=0;for(let fr=0;fr<g;++fr){let Ar=y[n[fr]];if(Ar===void 0)throw new SyntaxError(`Non-${s} character`);tr=tr<<i|Ar,L+=i,L>=8&&(L-=8,E[or++]=255&tr>>L)}if(L>=i||(255&tr<<8-L)!==0)throw new SyntaxError("Unexpected end of data");return E}x(qi,"decode");function Ji(n,e,i){let s=e[e.length-1]==="=",y=(1<<i)-1,g="",E=0,L=0;for(let tr=0;tr<n.length;++tr)for(L=L<<8|n[tr],E+=8;E>i;)E-=i,g+=e[y&L>>E];if(E!==0&&(g+=e[y&L<<i-E]),s)for(;(g.length*i&7)!==0;)g+="=";return g}x(Ji,"encode");function yr({name:n,prefix:e,bitsPerChar:i,alphabet:s}){return Ae({prefix:e,name:n,encode(y){return Ji(y,s,i)},decode(y){return qi(y,s,i,n)}})}x(yr,"rfc4648");var Qi=ee({prefix:"9",name:"base10",alphabet:"0123456789"});var $t={};Sr($t,{base16:()=>rf,base16upper:()=>ef});var rf=yr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ef=yr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Zt={};Sr(Zt,{base2:()=>tf});var tf=yr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qt={};Sr(qt,{base256emoji:()=>sf});var ri=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}"),nf=ri.reduce((n,e,i)=>(n[i]=e,n),[]),ff=ri.reduce((n,e,i)=>{let s=e.codePointAt(0);if(s==null)throw new Error(`Invalid character: ${e}`);return n[s]=i,n},[]);function of(n){return n.reduce((e,i)=>(e+=nf[i],e),"")}x(of,"encode");function af(n){let e=[];for(let i of n){let s=i.codePointAt(0);if(s==null)throw new Error(`Invalid character: ${i}`);let y=ff[s];if(y==null)throw new Error(`Non-base256emoji character: ${i}`);e.push(y)}return new Uint8Array(e)}x(af,"decode");var sf=Ae({prefix:"\u{1F680}",name:"base256emoji",encode:of,decode:af});var Jt={};Sr(Jt,{base32:()=>me,base32hex:()=>uf,base32hexpad:()=>hf,base32hexpadupper:()=>df,base32hexupper:()=>pf,base32pad:()=>yf,base32padupper:()=>xf,base32upper:()=>cf,base32z:()=>gf});var me=yr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),cf=yr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yf=yr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),xf=yr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),uf=yr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pf=yr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),hf=yr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),df=yr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),gf=yr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Qt={};Sr(Qt,{base36:()=>Ne,base36upper:()=>lf});var Ne=ee({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),lf=ee({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var rn={};Sr(rn,{base58btc:()=>Hr,base58flickr:()=>bf});var Hr=ee({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bf=ee({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var en={};Sr(en,{base64:()=>Af,base64pad:()=>mf,base64url:()=>wf,base64urlpad:()=>Kf});var Af=yr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),mf=yr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),wf=yr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Kf=yr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var tn={};Sr(tn,{base8:()=>Ef});var Ef=yr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var nn={};Sr(nn,{identity:()=>Uf});var Uf=Ae({prefix:"\0",name:"identity",encode:x(n=>Zn(n),"encode"),decode:x(n=>$n(n),"decode")});var ha=new TextEncoder,da=new TextDecoder;var an={};Sr(an,{identity:()=>kf});var Cf=ni,ei=128,_f=127,Pf=~_f,Bf=Math.pow(2,31);function ni(n,e,i){e=e||[],i=i||0;for(var s=i;n>=Bf;)e[i++]=n&255|ei,n/=128;for(;n&Pf;)e[i++]=n&255|ei,n>>>=7;return e[i]=n|0,ni.bytes=i-s+1,e}x(ni,"encode");var Tf=fn,Df=128,ti=127;function fn(n,s){var i=0,s=s||0,y=0,g=s,E,L=n.length;do{if(g>=L)throw fn.bytes=0,new RangeError("Could not decode varint");E=n[g++],i+=y<28?(E&ti)<<y:(E&ti)*Math.pow(2,y),y+=7}while(E>=Df);return fn.bytes=g-s,i}x(fn,"read");var Mf=Math.pow(2,7),If=Math.pow(2,14),Lf=Math.pow(2,21),Nf=Math.pow(2,28),Rf=Math.pow(2,35),zf=Math.pow(2,42),Of=Math.pow(2,49),Yf=Math.pow(2,56),jf=Math.pow(2,63),Hf=x(function(n){return n<Mf?1:n<If?2:n<Lf?3:n<Nf?4:n<Rf?5:n<zf?6:n<Of?7:n<Yf?8:n<jf?9:10},"length"),Ff={encode:Cf,decode:Tf,encodingLength:Hf},Gf=Ff,Re=Gf;function ze(n,e=0){return[Re.decode(n,e),Re.decode.bytes]}x(ze,"decode");function we(n,e,i=0){return Re.encode(n,e,i),e}x(we,"encodeTo");function Ke(n){return Re.encodingLength(n)}x(Ke,"encodingLength");function oe(n,e){let i=e.byteLength,s=Ke(n),y=s+Ke(i),g=new Uint8Array(y+i);return we(n,g,0),we(i,g,s),g.set(e,y),new Ee(n,i,e,g)}x(oe,"create");function ii(n){let e=$r(n),[i,s]=ze(e),[y,g]=ze(e.subarray(s)),E=e.subarray(s+g);if(E.byteLength!==y)throw new Error("Incorrect length");return new Ee(i,y,E,e)}x(ii,"decode");function fi(n,e){if(n===e)return!0;{let i=e;return n.code===i.code&&n.size===i.size&&i.bytes instanceof Uint8Array&&Wn(n.bytes,i.bytes)}}x(fi,"equals");var on=class on{constructor(e,i,s,y){I(this,"code");I(this,"size");I(this,"digest");I(this,"bytes");this.code=e,this.size=i,this.digest=s,this.bytes=y}};x(on,"Digest");var Ee=on;var oi=0,Vf="identity",ai=$r;function Xf(n){return oe(oi,ai(n))}x(Xf,"digest");var kf={code:oi,name:Vf,encode:ai,digest:Xf};var xn={};Sr(xn,{sha256:()=>Wf,sha512:()=>$f});function cn({name:n,code:e,encode:i}){return new sn(n,e,i)}x(cn,"from");var yn=class yn{constructor(e,i,s){I(this,"name");I(this,"code");I(this,"encode");this.name=e,this.code=i,this.encode=s}digest(e){if(e instanceof Uint8Array){let i=this.encode(e);return i instanceof Uint8Array?oe(this.code,i):i.then(s=>oe(this.code,s))}else throw Error("Unknown type, must be binary type")}};x(yn,"Hasher");var sn=yn;function ci(n){return async e=>new Uint8Array(await crypto.subtle.digest(n,e))}x(ci,"sha");var Wf=cn({name:"sha2-256",code:18,encode:ci("SHA-256")}),$f=cn({name:"sha2-512",code:19,encode:ci("SHA-512")});function yi(n,e){let{bytes:i,version:s}=n;switch(s){case 0:return qf(i,un(n),e??Hr.encoder);default:return Jf(i,un(n),e??me.encoder)}}x(yi,"format");var xi=new WeakMap;function un(n){let e=xi.get(n);if(e==null){let i=new Map;return xi.set(n,i),i}return e}x(un,"baseCache");var pi,gr=class gr{constructor(e,i,s,y){I(this,"code");I(this,"version");I(this,"multihash");I(this,"bytes");I(this,"/");I(this,pi,"CID");this.code=i,this.version=e,this.multihash=s,this.bytes=y,this["/"]=y}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:e,multihash:i}=this;if(e!==Ye)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(i.code!==Qf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return gr.createV0(i)}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:e,digest:i}=this.multihash,s=oe(e,i);return gr.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(e){return gr.equals(this,e)}static equals(e,i){let s=i;return s!=null&&e.code===s.code&&e.version===s.version&&fi(e.multihash,s.multihash)}toString(e){return yi(this,e)}toJSON(){return{"/":yi(this)}}link(){return this}[(pi=Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"))](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let i=e;if(i instanceof gr)return i;if(i["/"]!=null&&i["/"]===i.bytes||i.asCID===i){let{version:s,code:y,multihash:g,bytes:E}=i;return new gr(s,y,g,E??ui(s,y,g.bytes))}else if(i[ro]===!0){let{version:s,multihash:y,code:g}=i,E=ii(y);return gr.create(s,g,E)}else return null}static create(e,i,s){if(typeof i!="number")throw new Error("String codecs are no longer supported");if(!(s.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(i!==Ye)throw new Error(`Version 0 CID must use dag-pb (code: ${Ye}) block encoding`);return new gr(e,i,s,s.bytes)}case 1:{let y=ui(e,i,s.bytes);return new gr(e,i,s,y)}default:throw new Error("Invalid version")}}static createV0(e){return gr.create(0,Ye,e)}static createV1(e,i){return gr.create(1,e,i)}static decode(e){let[i,s]=gr.decodeFirst(e);if(s.length!==0)throw new Error("Incorrect length");return i}static decodeFirst(e){let i=gr.inspectBytes(e),s=i.size-i.multihashSize,y=$r(e.subarray(s,s+i.multihashSize));if(y.byteLength!==i.multihashSize)throw new Error("Incorrect length");let g=y.subarray(i.multihashSize-i.digestSize),E=new Ee(i.multihashCode,i.digestSize,g,y);return[i.version===0?gr.createV0(E):gr.createV1(i.codec,E),e.subarray(i.size)]}static inspectBytes(e){let i=0,s=x(()=>{let[Ar,Lr]=ze(e.subarray(i));return i+=Lr,Ar},"next"),y=s(),g=Ye;if(y===18?(y=0,i=0):g=s(),y!==0&&y!==1)throw new RangeError(`Invalid CID version ${y}`);let E=i,L=s(),tr=s(),or=i+tr,fr=or-E;return{version:y,codec:g,multihashCode:L,digestSize:tr,multihashSize:fr,size:or}}static parse(e,i){let[s,y]=Zf(e,i),g=gr.decode(y);if(g.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return un(g).set(s,e),g}};x(gr,"CID");var ot=gr;function Zf(n,e){switch(n[0]){case"Q":{let i=e??Hr;return[Hr.prefix,i.decode(`${Hr.prefix}${n}`)]}case Hr.prefix:{let i=e??Hr;return[Hr.prefix,i.decode(n)]}case me.prefix:{let i=e??me;return[me.prefix,i.decode(n)]}case Ne.prefix:{let i=e??Ne;return[Ne.prefix,i.decode(n)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[n[0],e.decode(n)]}}}x(Zf,"parseCIDtoBytes");function qf(n,e,i){let{prefix:s}=i;if(s!==Hr.prefix)throw Error(`Cannot string encode V0 in ${i.name} encoding`);let y=e.get(s);if(y==null){let g=i.encode(n).slice(1);return e.set(s,g),g}else return y}x(qf,"toStringV0");function Jf(n,e,i){let{prefix:s}=i,y=e.get(s);if(y==null){let g=i.encode(n);return e.set(s,g),g}else return y}x(Jf,"toStringV1");var Ye=112,Qf=18;function ui(n,e,i){let s=Ke(n),y=s+Ke(e),g=new Uint8Array(y+i.byteLength);return we(n,g,0),we(e,g,s),g.set(i,y),g}x(ui,"encodeCID");var ro=Symbol.for("@ipld/js-cid/CID");var pn={...nn,...Zt,...tn,...Wt,...$t,...Jt,...Qt,...rn,...en,...qt},Xa={...xn,...an};function di(n,e,i,s){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:i},decoder:{decode:s}}}x(di,"createCodec");var hi=di("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>new TextEncoder().encode(n.substring(1))),hn=di("ascii","a",n=>{let e="a";for(let i=0;i<n.length;i++)e+=String.fromCharCode(n[i]);return e},n=>{n=n.substring(1);let e=Le(n.length);for(let i=0;i<n.length;i++)e[i]=n.charCodeAt(i);return e}),eo={utf8:hi,"utf-8":hi,hex:pn.base16,latin1:hn,ascii:hn,binary:hn,...pn},at=eo;function Tr(n,e="utf8"){let i=at[e];if(i==null)throw new Error(`Unsupported encoding "${e}"`);return i.decoder.decode(`${i.prefix}${n}`)}x(Tr,"fromString");function ir(n,e="utf8"){let i=at[e];if(i==null)throw new Error(`Unsupported encoding "${e}"`);return i.encoder.encode(n).substring(1)}x(ir,"toString");var Ui={};Sr(Ui,{AES:()=>pr,decryptBytes:()=>Ei,importAesKey:()=>Ce});var mi=Vi(li(),1);var je="did:key:z",Ue="Ed25519",dn="X25519",to="X25519",gn="Ed25519",ln="X25519",bi={sign:["sign","verify"],encrypt:["deriveKey","deriveBits"]},ae="RSA-OAEP",se="RSASSA-PKCS1-v1_5",ct="SHA-256",yt=new Uint8Array([0,245,2]),xt=2048,ce="SHA-256",Fr=8,Gr="AES-GCM",Vr=Gr,Xr=256,Or=12,ut=new Uint8Array([234,1]),pt=new Uint8Array([237,1]),He={RSA:"rsa",Edwards:"ed25519",BLS:"bls12-381"},ht="rsa-exchange-key",dt="rsa-write-key",Fe="ecc-exchange",Ge="ecc-write",Yr=16;function Ir(n){return new Uint8Array(n).buffer}x(Ir,"toArrayBuffer");var Ai={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:x(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:io},ed25519:{magicBytes:new Uint8Array([237,1]),verify:no}}};async function no({message:n,publicKey:e,signature:i}){return mi.default.sign.detached.verify(n,i,e)}x(no,"ed25519Verify");async function wi(n){return new Uint8Array(await $.subtle.digest("sha-256",n.buffer))}x(wi,"sha256");async function Xe(n,e="rsa"){let i=n instanceof CryptoKey?new Uint8Array(await qr(n)):n,s=Ai.keyTypes[e]?.magicBytes;if(!s)throw new Error(`Key type '${e}' not supported, available types: ${Object.keys(Ai.keyTypes).join(", ")}`);let y=Ot([s,i]);return je+ir(y,"base58btc")}x(Xe,"publicKeyToDid");var Zr={verify:x(async function(e,i,s,y=Fr,g=ce){return $.subtle.verify({name:se,saltLength:Yr},typeof s=="string"?await Ve(s,g,"signing"):s,mn(i),ye(e,y))},"rsaVerify"),sign:x(async function(e,i,s=Fr){return $.subtle.sign({name:se,saltLength:Yr},i,ye(e,s))},"sign"),encrypt:x(async function(e,i,s=Fr,y=ce){let g;return typeof i=="string"?g=await Ve(i,y,"exchange"):g=i instanceof Uint8Array?await Ve(Ir(i),y,"exchange"):i,$.subtle.encrypt({name:ae},g,ye(e,s))},"rsaEncrypt"),decrypt:x(async function(e,i){let s=Se(i)?i:await uo(i,["decrypt"]),y;typeof e=="string"?y=Tr(e,"base64pad"):y=e;let g=await $.subtle.decrypt({name:ae},s,y instanceof Uint8Array?Ir(y):y);return new Uint8Array(g)},"rsaDecrypt")};async function io({message:n,publicKey:e,signature:i}){return Zr.verify(n,i,await $.subtle.importKey("spki",Ir(e),{name:se,hash:ct},!1,["verify"]),8)}x(io,"rsaVerify");async function Ve(n,e,i){ao(i);let s=i==="exchange"?ae:se,y=i==="exchange"?["encrypt"]:["verify"],g=typeof n=="string"?jr(co(n)):n;return $.subtle.importKey("spki",g,{name:s,hash:{name:e}},!0,y)}x(Ve,"importPublicKey");var fo=new Error("Invalid key use. Please use 'encryption' or 'signing"),oo=new Error("Max must be less than 256 and greater than 0");function ao(n){so(n,["signing","exchange"],fo)}x(ao,"checkValidKeyUse");function so(n,e,i){if(!e.some(y=>y===n))throw i}x(so,"checkValid");function co(n){return n.replace(`-----BEGIN PUBLIC KEY-----
|
|
2
2
|
`,"").replace(`
|
|
3
|
-
-----END PUBLIC KEY-----`,"")}x($f,"stripKeyHeader");function zr(t){let e=Cr(t,"base64pad");return Tr(e)}x(zr,"base64ToArrBuf");var oe=x((t,e)=>{if(typeof t=="string")return e(t);if(typeof t=="object"&&t.byteLength!==void 0)return new Uint8Array(t).buffer;throw new Error("Improper value. Must be a string, ArrayBuffer, Uint8Array")},"normalizeToBuf");function cn(t){return oe(t,zr)}x(cn,"normalizeBase64ToBuf");var Zf=x(t=>oe(t,e=>yi(e,8)),"normalizeUtf8ToBuf");function yi(t,e){let i=e===8?new Uint8Array(t.length):new Uint16Array(t.length);for(let s=0,y=t.length;s<y;s++)i[s]=t.charCodeAt(s);return i.buffer}x(yi,"strToArrBuf");var qf=x(t=>oe(t,e=>yi(e,16)),"normalizeUtf16ToBuf");function fe(t,e){switch(e){case 8:return Zf(t);default:return qf(t)}}x(fe,"normalizeUnicodeToBuf");function Jf(t,e){return W.subtle.importKey("spki",t instanceof Uint8Array?Tr(t):t,{name:te,hash:it},!1,e)}x(Jf,"importRsaKey");function me(t){return an(t,"algorithm")&&an(t,"extractable")&&an(t,"type")}x(me,"isCryptoKey");function an(t,e){return typeof t=="object"&&t!=null&&e in t}x(an,"hasProp");async function Wr(t){return t instanceof CryptoKey?await W.subtle.exportKey("spki",t):await W.subtle.exportKey("spki",t.publicKey)}x(Wr,"getPublicKeyAsArrayBuffer");async function yn(t){let e=await Wr(t);return new Uint8Array(e)}x(yn,"getPublicKeyAsUint8Array");function xt(t){if(!t.startsWith(Le))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let e=""+t.substring(Le.length),i=Cr(e,"base58btc"),{keyBuffer:s,type:y}=Qf(Tr(i));return{publicKey:new Uint8Array(s),type:y}}x(xt,"didToPublicKey");function Qf(t){if(sn(t,Tr(ft)))return{keyBuffer:t.slice(ft.byteLength),type:Ne.RSA};if(sn(t,Tr(st)))return{keyBuffer:t.slice(st.byteLength),type:Ne.Edwards};if(sn(t,Tr(at)))return{keyBuffer:t.slice(at.byteLength),type:Ne.BLS};throw new Error("Unsupported key algorithm. Try using RSA.")}x(Qf,"parseMagicBytes");var ro={equal:x((t,e)=>{let i=new Uint8Array(t),s=new Uint8Array(e);if(i.length!==s.length)return!1;for(let y=0;y<i.length;y++)if(i[y]!==s[y])return!1;return!0},"equal")};function sn(t,e){return ro.equal(e,t.slice(0,e.byteLength))}x(sn,"hasPrefix");function Ur(t){return nr(t instanceof ArrayBuffer?new Uint8Array(t):t,"base64pad")}x(Ur,"toBase64");async function je(t,e){let i=typeof t=="string"?zr(t):Tr(t);return W.subtle.importKey("raw",i,{name:e?.alg||Hr,length:e?.length||Fr},!0,["encrypt","decrypt"])}x(je,"importKey");function ut(t,{max:e}={max:255}){if(e<1||e>255)throw Xf;let i=new Uint8Array(t);if(e===255)return W.getRandomValues(i),i.buffer;let s=0,y=e+1,g=Math.floor(256/y)*y,E=new Uint8Array(1);for(;s<i.length;)W.getRandomValues(E),E[0]<g&&(i[s]=E[0]%y,s++);return i.buffer}x(ut,"randomBuf");function $r(t,e){let i=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(Tr(t)),s=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(Tr(e)),y=new Uint8Array(i.length+s.length);return y.set(i),y.set(s,i.length),y.buffer}x($r,"joinBufs");async function xn(t,e,i){if(!Object.values(pe).includes(i))throw new Error("invalid key use");let s=i==="exchange"?te:ne,y=i==="exchange"?["encrypt","decrypt"]:["sign","verify"];return W.subtle.generateKey({name:s,modulusLength:t,publicExponent:eo(),hash:{name:e}},!1,y)}x(xn,"makeRSAKeypair");function eo(){return new Uint8Array([1,0,1])}x(eo,"publicExponent");function we(t){return new Uint8Array(t).buffer}x(we,"toArrayBuffer");var ur={create(t={alg:Hr,length:Fr}){let e=t.length||Fr,i=t.alg||Hr;return W.subtle.generateKey({name:i,length:e},!0,["encrypt","decrypt"])},export:Object.assign(async t=>{let e=await W.subtle.exportKey("raw",t);return new Uint8Array(e)},{asString:x(async(t,e)=>{let i=await ur.export(t);return e?nr(i,e):Ur(i)},"asString")}),import(t){return Ke(typeof t=="string"?zr(t):t)},async exportAsString(t){let e=await ur.export(t);return Ur(e)},encrypt:to,async decrypt(t,e,i){let s=me(e)?e:await Ke(e),y=i?await W.subtle.decrypt({name:jr,iv:we(i)},s,typeof t=="string"?we(Cr(t)):t instanceof Uint8Array?we(t):t):await io(t,s);return new Uint8Array(y)}};function Ke(t,e){return W.subtle.importKey("raw",t instanceof Uint8Array?we(t):t,{name:jr,length:e||256},!0,["encrypt","decrypt"])}x(Ke,"importAesKey");async function to(t,e,i,s){let y=me(e)?e:await Ke(e),g=s?await W.subtle.encrypt({name:jr,iv:we(s)},y,we(t)):await no(t,y);return i&&i==="arraybuffer"?g:new Uint8Array(g)}x(to,"encrypt");async function no(t,e,i){let s=fe(t,i?.charsize??Yr),y=typeof e=="string"?await je(e,i):e,g=i?.iv||ut(Nr),E=await W.subtle.encrypt({name:jr,iv:g},y,s);return $r(g,E)}x(no,"encryptBytes");async function io(t,e,i){let s=cn(t),y=typeof e=="string"?await je(e,i):e,g=s.slice(0,Nr),E=s.slice(Nr);return await W.subtle.decrypt({name:Hr,iv:g},y,E)}x(io,"decryptBytes");function pt(t){return new Promise((e,i)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>i(t.error)})}x(pt,"promisifyRequest");function fo(t,e){let i,s=x(()=>{if(i)return i;let y=indexedDB.open(t);return y.onupgradeneeded=()=>y.result.createObjectStore(e),i=pt(y),i.then(g=>{g.onclose=()=>i=void 0},()=>{}),i},"getDB");return(y,g)=>s().then(E=>g(E.transaction(e,y).objectStore(e)))}x(fo,"createStore");var un;function pn(){return un||(un=fo("keyval-store","keyval")),un}x(pn,"defaultGetStore");function hn(t,e=pn()){return e("readonly",i=>pt(i.get(t)))}x(hn,"get");function dn(t,e,i=pn()){return i("readwrite",s=>(s.put(e,t),pt(s.transaction)))}x(dn,"set");function ui(t,e=pn()){return e("readwrite",i=>(t.forEach(s=>i.delete(s)),pt(i.transaction)))}x(ui,"delMany");var Ee=class t{static{x(this,"AbstractKeys")}DID;exchangeKey;writeKey;hasPersisted;isSessionOnly;static EXCHANGE_KEY_NAME;static WRITE_KEY_NAME;static _instance;constructor(e){let{keys:i}=e;this.DID=e.did,this.exchangeKey=i.exchange,this.writeKey=i.write,this.hasPersisted=e.hasPersisted,this.isSessionOnly=!!e.isSessionOnly}publicExchangeKeyAsString(e){return this.publicExchangeKey.asString(e)}publicWriteKeyAsString(e){return this.publicWriteKey.asString(e)}get publicWriteKey(){let e=this.writeKey.publicKey;return Object.assign(e,{asString:x(async i=>{let s=await Wr(this.writeKey),y=new Uint8Array(s);return i?nr(y,i):Ur(y)},"asString")})}get publicExchangeKey(){let e=this.exchangeKey.publicKey;return Object.assign(e,{asString:x(async i=>{let s=await Wr(this.exchangeKey),y=new Uint8Array(s);return i?nr(y,i):Ur(y)},"asString")})}get privateWriteKey(){return this.writeKey.privateKey}get privateExchangeKey(){return this.exchangeKey.privateKey}get deviceName(){return t.deviceName(this.DID)}static deviceName(e){return oo(e)}async persist(){if(this.isSessionOnly)return;let e=this.constructor.EXCHANGE_KEY_NAME,i=this.constructor.WRITE_KEY_NAME;await Promise.all([dn(e,this.exchangeKey),dn(i,this.writeKey)]),this.hasPersisted=!0}async delete(){await ui([this.constructor.EXCHANGE_KEY_NAME,this.constructor.WRITE_KEY_NAME]),this.hasPersisted=!1}async getDeviceName(){return t.deviceName(this.DID)}static _createExchangeKeys(){throw new Error("The child should implement this")}static _createWriteKeys(){throw new Error("The child should implement this")}static async create(e){let i=await this._createExchangeKeys(),s=await this._createWriteKeys(),y=await Wr(s),g=await Ye(new Uint8Array(y),this.TYPE==="ecc"?"ed25519":"rsa"),E=new this({keys:{exchange:i,write:s},did:g,hasPersisted:!1,isSessionOnly:!!e});return this._instance=E,E}static async load(e={session:!1}){if(this._instance)return this._instance;let i=!0,s=await hn(e.encryptionKeyName||this.EXCHANGE_KEY_NAME),y=await hn(e.signingKeyName||this.WRITE_KEY_NAME);s||(i=!1,s=await this._createExchangeKeys()),y||(i=!1,y=await this._createWriteKeys());let g=await Wr(y),E=await Ye(new Uint8Array(g),this.TYPE==="ecc"?"ed25519":"rsa"),I=new this({keys:{exchange:s,write:y},did:E,hasPersisted:i,isSessionOnly:!!e.session});return this._instance=I,I}};async function pi(t,e){let{content:i,publicKey:s}=t,y=e||await ur.create(),g=await ur.encrypt(typeof i=="string"?Cr(i):i,typeof y=="string"?await ur.import(y):y),E=await gn({key:y,publicKey:s});return $r(E,g)}x(pi,"encryptTo");pi.asString=async function(t,e){let i=await pi(t,e);return nr(new Uint8Array(i),"base64pad")};async function gn({key:t,publicKey:e},i){let s;t instanceof CryptoKey?s=await ur.export(t):s=t;let y=await kr.encrypt(s,e);return i&&i==="arraybuffer"?y:new Uint8Array(y)}x(gn,"encryptKeyTo");gn.asString=async function({key:t,publicKey:e},i){let s=await gn({key:t,publicKey:e});return i?nr(s,i):Ur(s)};async function oo(t){let e=await ci(new TextEncoder().encode(t.normalize("NFD")));return nr(e,"base32").slice(0,32)}x(oo,"getDeviceName");function ln(t){return new Uint8Array(t).buffer}x(ln,"toArrayBuffer");var ae=class t extends Ee{static{x(this,"RsaKeys")}static TYPE="rsa";static INFO="keys";static EXCHANGE_KEY_NAME=ct;static WRITE_KEY_NAME=yt;constructor(e){super(e),t.EXCHANGE_KEY_NAME=e.exchangeKeyName||ct,t.WRITE_KEY_NAME=e.writeKeyName||yt}static async _createExchangeKeys(){return await xn(ot,ie,"exchange")}static async _createWriteKeys(){return await xn(ot,ie,"write")}async toJson(e){let i=this.publicExchangeKey,s=this.DID,y=await W.subtle.exportKey("spki",i);return{publicExchangeKey:e?nr(new Uint8Array(y),e):Ur(y),DID:s}}async sign(e,i=Yr){let s=this.writeKey,y=await kr.sign(e,s.privateKey,i);return new Uint8Array(y)}async signAsString(e,i){let s=await this.sign(e,i);return Ur(s)}async encrypt(e,i,s,y,g){let E=i||this.exchangeKey.publicKey,I=s,er=y,fr=I||await ur.create({length:er||g}),ir=await ur.encrypt(typeof e=="string"?Cr(e):e,typeof fr=="string"?await ur.import(fr):fr),lr=await Ue({key:fr,publicKey:E}),Dr=$r(lr,ir);return new Uint8Array(Dr)}async encryptAsString(e,i,s,y,g){let E=await this.encrypt(e,i,s,y,g);return nr(E,"base64pad")}async decrypt(e,i,s){let y=(typeof i=="number"?i:void 0)||Fr,g=oe(e,zr),E=g.slice(0,y),I=g.slice(y),er=await this.decryptKey(E);return await ur.decrypt(I,er)}async decryptAsString(e,i,s){let y=await this.decrypt(e,i,s);return nr(y)}async decryptKey(e){return await kr.decrypt(e,this.exchangeKey.privateKey)}async decryptKeyAsString(e,i){let s=await kr.decrypt(e,this.exchangeKey.privateKey);return nr(s,i)}async getAesKey(e,i){if(!e)throw new Error("RSA requires an encrypted AES key to decrypt");if(typeof e=="string"){let s=await this.decryptKey(e);return await ur.import(s)}else return e}};Object.assign(ae.prototype.sign,{asString:x(async function(t,e){return this.signAsString(t,e)},"asString")});Object.assign(ae.prototype.encrypt,{asString:x(async function(t,e,i,s){return this.encryptAsString(t,e,i,s)},"asString")});Object.assign(ae.prototype.decrypt,{asString:x(async function(t,e){return this.decryptAsString(t,e)},"asString")});async function ao(t,e,i){let s=xt(i),y=await Oe(ln(s.publicKey),"SHA-256","signing");try{return kr.verify(t,e,y)}catch{return!1}}x(ao,"verify");Object.assign(ae.prototype.decryptKey,{asString:x(async function(t,e){return this.decryptKeyAsString(t,e)},"asString")});async function hi(t,e){let{content:i,publicKey:s}=t,y=e||await ur.create(),g=await ur.encrypt(typeof i=="string"?Cr(i):i,typeof y=="string"?await ur.import(y):y),E=await Ue({key:y,publicKey:s});return $r(E,g)}x(hi,"encryptTo");hi.asString=async function(t,e){let{content:i,publicKey:s}=t,y=e||await ur.create(),g=await ur.encrypt(typeof i=="string"?Cr(i):i,typeof y=="string"?await ur.import(y):y,"arraybuffer"),E=await Ue({key:y,publicKey:s}),I=$r(E,g);return nr(new Uint8Array(I),"base64pad")};async function Ue({key:t,publicKey:e},i){let s;t instanceof CryptoKey?s=await ur.export(t):s=t;let y=await kr.encrypt(s,e);return i&&i==="arraybuffer"?y:new Uint8Array(y)}x(Ue,"encryptKeyTo");Ue.asString=async function({key:t,publicKey:e},i){let s=await Ue({key:t,publicKey:e});return i?nr(s,i):Ur(s)};async function so(t,e,i,s){let y=me(e)?e:await Ke(e),g=s?await W.subtle.encrypt({name:jr,iv:ln(s)},y,ln(t)):await co(t,y);return i&&i==="arraybuffer"?g:new Uint8Array(g)}x(so,"encrypt");async function co(t,e,i){let s=fe(t,i?.charsize??Yr),y=typeof e=="string"?await je(e,i):e,g=i?.iv||ut(Nr),E=await W.subtle.encrypt({name:jr,iv:g},y,s);return $r(g,E)}x(co,"encryptBytes");var li={};Er(li,{EccKeys:()=>Jr,default:()=>uo,exportPublicKey:()=>dt,importPublicKey:()=>He,verify:()=>po});var Ys=new Error("Key does not exist. Make sure you properly instantiated the keystore."),js=new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name."),Hs=new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name."),Fs=new Error("ECC is not enabled for this browser. Please use RSA instead."),Gs=new Error("Cryptosystem not supported. Please use ECC or RSA"),yo=new Error("Invalid key use. Please use 'exchange' or 'write'"),Vs=new Error("Max must be less than 256 and greater than 0");function gi(t){xo(t,["exchange","write","signing"],yo)}x(gi,"checkValidKeyUse");function xo(t,e,i){if(!e.some(y=>y===t))throw i}x(xo,"checkValid");function Fe(t){return new Uint8Array(t).buffer}x(Fe,"toArrayBuffer");var Jr=class t extends Ee{static{x(this,"EccKeys")}static TYPE="ecc";static EXCHANGE_KEY_NAME=Re;static WRITE_KEY_NAME=ze;static INFO="keys";constructor(e){super(e),t.EXCHANGE_KEY_NAME=e.exchangeKeyName||Re,t.WRITE_KEY_NAME=e.writeKeyName||ze}get publicExchangeKey(){let e=this.exchangeKey.publicKey;return Object.assign(e,{asString:x(async i=>{let s=await dt(this.exchangeKey),y=new Uint8Array(s);return i?nr(y,i):Ur(s)},"asString")})}get publicWriteKey(){let e=this.writeKey.publicKey;return Object.assign(e,{asString:x(async i=>{let s=await dt(this.writeKey),y=new Uint8Array(s);return i?nr(y,i):Ur(s)},"asString")})}static async _createExchangeKeys(){return await W.subtle.generateKey({name:on},!1,["deriveKey","deriveBits"])}static async _createWriteKeys(){return await W.subtle.generateKey({name:fn},!1,["sign","verify"])}static async load(e={session:!1}){if(this._instance)return this._instance;let i=e.encryptionKeyName||Re,s=e.signingKeyName||ze;return super.load({...e,encryptionKeyName:i,signingKeyName:s})}async toJson(e){let i=this.DID,s=await dt(this.exchangeKey);return{publicExchangeKey:e?nr(new Uint8Array(s),e):Ur(s),DID:i}}async encrypt(e,i,s,y,g){let E=new TextEncoder,I=crypto.getRandomValues(new Uint8Array(Rr)),er=i||this.exchangeKey.publicKey,fr;typeof er=="string"?fr=await He(er,"X25519","exchange"):fr=er;let ir=y||await ht(this.exchangeKey.privateKey,fr,I,s||t.INFO,g);ir instanceof CryptoKey||(ir=await ht(this.exchangeKey.privateKey,fr,I,s||t.INFO));let lr=crypto.getRandomValues(new Uint8Array(Nr)),Dr=typeof e=="string"?E.encode(e):e,se=await crypto.subtle.encrypt({name:Hr,iv:lr},ir,Fe(Dr)),$=new Uint8Array(I),yr=new Uint8Array(lr),Sr=new Uint8Array(se),wr=$.length+yr.length+Sr.length,dr=new Uint8Array(wr);return dr.set($,0),dr.set(yr,$.length),dr.set(Sr,$.length+yr.length),dr}async encryptAsString(e,i,s,y,g){let E=await this.encrypt(e,i,s||t.INFO,y,g);return nr(new Uint8Array(E),"base64pad")}async decrypt(e,i,s,y){let g=typeof i=="string"?await He(i,"X25519","write"):i;g||(g=this.publicExchangeKey);let E=oe(e,zr),I=E.slice(0,Rr),er=E.slice(Rr,Rr+Nr),fr=E.slice(Rr+Nr),{privateKey:ir}=this.exchangeKey,lr=await ht(ir,g,I,y||t.INFO);return await crypto.subtle.decrypt({name:s||Hr,iv:er},lr,fr)}async decryptAsString(e,i,s,y){let g=await this.decrypt(e,i,s,y);return nr(new Uint8Array(g))}async getAesKey(e,i){e||(e=this.publicExchangeKey);let s;typeof e=="string"?s=await He(e,"X25519","exchange"):s=e;let y=crypto.getRandomValues(new Uint8Array(Rr));return await ht(this.exchangeKey.privateKey,s,y,i||t.INFO)}async sign(e,i){let s=new TextEncoder,y;typeof e=="string"?y=s.encode(e):e instanceof ArrayBuffer?y=new Uint8Array(e):y=e;let g=await W.subtle.sign({name:Ae},this.writeKey.privateKey,Fe(y));return new Uint8Array(g)}async signAsString(e,i){let s=await this.sign(e,i);return nr(s,"base64pad")}};Object.assign(Jr.prototype.sign,{asString:x(async function(t,e){let i=await this.sign(t,e);return nr(i,"base64pad")},"asString")});async function dt(t){return await W.subtle.exportKey("raw",t.publicKey)}x(dt,"exportPublicKey");async function He(t,e,i){gi(i);let s=i==="exchange"?nn:Ae,y=i==="exchange"?[]:["verify"],g=zr(t),E=e==="X25519"?{name:s}:{name:s,namedCurve:e};return W.subtle.importKey("raw",g,E,!0,y)}x(He,"importPublicKey");var uo={EccKeys:Jr,importPublicKey:He};Object.assign(Jr.prototype.encrypt,{asString:x(async function(t,e,i,s,y){return this.encryptAsString(t,e,i,s,y)},"asString")});Object.assign(Jr.prototype.decrypt,{asString:x(async function(t,e,i){return this.decryptAsString(t,e,i)},"asString")});Object.assign(Jr.prototype.sign,{asString:x(async function(t,e){return this.signAsString(t,e)},"asString")});async function po(t,e,i){try{let s=xt(i);if(s.type!=="ed25519")throw new Error(`Expected Ed25519 key for ECC verification, got ${s.type}`);let y=s.publicKey.slice(-32),g=await W.subtle.importKey("raw",y,{name:Ae},!0,["verify"]),E=new TextEncoder,I;typeof t=="string"?I=E.encode(t):t instanceof ArrayBuffer?I=new Uint8Array(t):I=t;let er;return typeof e=="string"?er=new Uint8Array(zr(e)):er=e,await W.subtle.verify({name:Ae},g,Fe(er),Fe(I))}catch{return!1}}x(po,"verify");async function ht(t,e,i,s,y){let g=new TextEncoder,E=await crypto.subtle.deriveBits({name:"X25519",public:e},t,256),I=await crypto.subtle.importKey("raw",E,"HKDF",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:i instanceof Uint8Array?Fe(i):i,info:g.encode(s)},I,{name:"AES-GCM",length:y||Fr},!1,["encrypt","decrypt"])}x(ht,"deriveKey");})();
|
|
3
|
+
-----END PUBLIC KEY-----`,"")}x(co,"stripKeyHeader");function jr(n){let e=Tr(n,"base64pad");return Ir(e)}x(jr,"base64ToArrBuf");var xe=x((n,e)=>{if(typeof n=="string")return e(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 mn(n){return xe(n,jr)}x(mn,"normalizeBase64ToBuf");var yo=x(n=>xe(n,e=>Ki(e,8)),"normalizeUtf8ToBuf");function Ki(n,e){let i=e===8?new Uint8Array(n.length):new Uint16Array(n.length);for(let s=0,y=n.length;s<y;s++)i[s]=n.charCodeAt(s);return i.buffer}x(Ki,"strToArrBuf");var xo=x(n=>xe(n,e=>Ki(e,16)),"normalizeUtf16ToBuf");function ye(n,e){switch(e){case 8:return yo(n);default:return xo(n)}}x(ye,"normalizeUnicodeToBuf");function uo(n,e){return $.subtle.importKey("spki",n instanceof Uint8Array?Ir(n):n,{name:ae,hash:ct},!1,e)}x(uo,"importRsaKey");function Se(n){return bn(n,"algorithm")&&bn(n,"extractable")&&bn(n,"type")}x(Se,"isCryptoKey");function bn(n,e){return typeof n=="object"&&n!=null&&e in n}x(bn,"hasProp");async function qr(n){return n instanceof CryptoKey?await $.subtle.exportKey("spki",n):await $.subtle.exportKey("spki",n.publicKey)}x(qr,"getPublicKeyAsArrayBuffer");async function wn(n){let e=await qr(n);return new Uint8Array(e)}x(wn,"getPublicKeyAsUint8Array");function gt(n){if(!n.startsWith(je))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let e=""+n.substring(je.length),i=Tr(e,"base58btc"),{keyBuffer:s,type:y}=po(Ir(i));return{publicKey:new Uint8Array(s),type:y}}x(gt,"didToPublicKey");function po(n){if(An(n,Ir(yt)))return{keyBuffer:n.slice(yt.byteLength),type:He.RSA};if(An(n,Ir(pt)))return{keyBuffer:n.slice(pt.byteLength),type:He.Edwards};if(An(n,Ir(ut)))return{keyBuffer:n.slice(ut.byteLength),type:He.BLS};throw new Error("Unsupported key algorithm. Try using RSA.")}x(po,"parseMagicBytes");var ho={equal:x((n,e)=>{let i=new Uint8Array(n),s=new Uint8Array(e);if(i.length!==s.length)return!1;for(let y=0;y<i.length;y++)if(i[y]!==s[y])return!1;return!0},"equal")};function An(n,e){return ho.equal(e,n.slice(0,e.byteLength))}x(An,"hasPrefix");function vr(n){return ir(n instanceof ArrayBuffer?new Uint8Array(n):n,"base64pad")}x(vr,"toBase64");async function ke(n,e){let i=typeof n=="string"?jr(n):Ir(n);return $.subtle.importKey("raw",i,{name:e?.alg||Vr,length:e?.length||Xr},!0,["encrypt","decrypt"])}x(ke,"importKey");function lt(n,{max:e}={max:255}){if(e<1||e>255)throw oo;let i=new Uint8Array(n);if(e===255)return $.getRandomValues(i),i.buffer;let s=0,y=e+1,g=Math.floor(256/y)*y,E=new Uint8Array(1);for(;s<i.length;)$.getRandomValues(E),E[0]<g&&(i[s]=E[0]%y,s++);return i.buffer}x(lt,"randomBuf");function Jr(n,e){let i=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(Ir(n)),s=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(Ir(e)),y=new Uint8Array(i.length+s.length);return y.set(i),y.set(s,i.length),y.buffer}x(Jr,"joinBufs");async function Kn(n,e,i){if(!Object.values(be).includes(i))throw new Error("invalid key use");let s=i==="exchange"?ae:se,y=i==="exchange"?["encrypt","decrypt"]:["sign","verify"];return $.subtle.generateKey({name:s,modulusLength:n,publicExponent:go(),hash:{name:e}},!1,y)}x(Kn,"makeRSAKeypair");function go(){return new Uint8Array([1,0,1])}x(go,"publicExponent");function ve(n){return new Uint8Array(n).buffer}x(ve,"toArrayBuffer");var pr={create(n={alg:Vr,length:Xr}){let e=n.length||Xr,i=n.alg||Vr;return $.subtle.generateKey({name:i,length:e},!0,["encrypt","decrypt"])},export:Object.assign(async n=>{let e=await $.subtle.exportKey("raw",n);return new Uint8Array(e)},{asString:x(async(n,e)=>{let i=await pr.export(n);return e?ir(i,e):vr(i)},"asString")}),import(n){return Ce(typeof n=="string"?jr(n):n)},async exportAsString(n){let e=await pr.export(n);return vr(e)},encrypt:lo,async decrypt(n,e,i){let s=Se(e)?e:await Ce(e),y=i?await $.subtle.decrypt({name:Gr,iv:ve(i)},s,typeof n=="string"?ve(Tr(n)):n instanceof Uint8Array?ve(n):n):await Ei(n,s);return new Uint8Array(y)}};function Ce(n,e){return $.subtle.importKey("raw",n instanceof Uint8Array?ve(n):n,{name:Gr,length:e||256},!0,["encrypt","decrypt"])}x(Ce,"importAesKey");async function lo(n,e,i,s){let y=Se(e)?e:await Ce(e),g=s?await $.subtle.encrypt({name:Gr,iv:ve(s)},y,ve(n)):await bo(n,y);return i&&i==="arraybuffer"?g:new Uint8Array(g)}x(lo,"encrypt");async function bo(n,e,i){let s=ye(n,i?.charsize??Fr),y=typeof e=="string"?await ke(e,i):e,g=i?.iv||lt(Or),E=await $.subtle.encrypt({name:Gr,iv:g},y,s);return Jr(g,E)}x(bo,"encryptBytes");async function Ei(n,e,i){let s=mn(n),y=typeof e=="string"?await ke(e,i):e,g=s.slice(0,Or),E=s.slice(Or);return await $.subtle.decrypt({name:Vr,iv:g},y,E)}x(Ei,"decryptBytes");function bt(n){return new Promise((e,i)=>{n.oncomplete=n.onsuccess=()=>e(n.result),n.onabort=n.onerror=()=>i(n.error)})}x(bt,"promisifyRequest");function Ao(n,e){let i,s=x(()=>{if(i)return i;let y=indexedDB.open(n);return y.onupgradeneeded=()=>y.result.createObjectStore(e),i=bt(y),i.then(g=>{g.onclose=()=>i=void 0},()=>{}),i},"getDB");return(y,g)=>s().then(E=>g(E.transaction(e,y).objectStore(e)))}x(Ao,"createStore");var En;function Un(){return En||(En=Ao("keyval-store","keyval")),En}x(Un,"defaultGetStore");function Sn(n,e=Un()){return e("readonly",i=>bt(i.get(n)))}x(Sn,"get");function vn(n,e,i=Un()){return i("readwrite",s=>(s.put(e,n),bt(s.transaction)))}x(vn,"set");function Si(n,e=Un()){return e("readwrite",i=>(n.forEach(s=>i.delete(s)),bt(i.transaction)))}x(Si,"delMany");var te=class te{constructor(e){I(this,"DID");I(this,"exchangeKey");I(this,"writeKey");I(this,"hasPersisted");I(this,"isSessionOnly");let{keys:i}=e;this.DID=e.did,this.exchangeKey=i.exchange,this.writeKey=i.write,this.hasPersisted=e.hasPersisted,this.isSessionOnly=!!e.isSessionOnly}publicExchangeKeyAsString(e){return this.publicExchangeKey.asString(e)}publicWriteKeyAsString(e){return this.publicWriteKey.asString(e)}get publicWriteKey(){let e=this.writeKey.publicKey;return Object.assign(e,{asString:x(async i=>{let s=await qr(this.writeKey),y=new Uint8Array(s);return i?ir(y,i):vr(y)},"asString")})}get publicExchangeKey(){let e=this.exchangeKey.publicKey;return Object.assign(e,{asString:x(async i=>{let s=await qr(this.exchangeKey),y=new Uint8Array(s);return i?ir(y,i):vr(y)},"asString")})}get privateWriteKey(){return this.writeKey.privateKey}get privateExchangeKey(){return this.exchangeKey.privateKey}get deviceName(){return te.deviceName(this.DID)}static deviceName(e){return mo(e)}async persist(){if(this.isSessionOnly)return;let e=this.constructor.EXCHANGE_KEY_NAME,i=this.constructor.WRITE_KEY_NAME;await Promise.all([vn(e,this.exchangeKey),vn(i,this.writeKey)]),this.hasPersisted=!0}async delete(){await Si([this.constructor.EXCHANGE_KEY_NAME,this.constructor.WRITE_KEY_NAME]),this.hasPersisted=!1}async getDeviceName(){return te.deviceName(this.DID)}static _createExchangeKeys(){throw new Error("The child should implement this")}static _createWriteKeys(){throw new Error("The child should implement this")}static async create(e){let i=await this._createExchangeKeys(),s=await this._createWriteKeys(),y=await qr(s),g=await Xe(new Uint8Array(y),this.TYPE==="ecc"?"ed25519":"rsa"),E=new this({keys:{exchange:i,write:s},did:g,hasPersisted:!1,isSessionOnly:!!e});return this._instance=E,E}static async load(e={session:!1}){if(this._instance)return this._instance;let i=!0,s=await Sn(e.encryptionKeyName||this.EXCHANGE_KEY_NAME),y=await Sn(e.signingKeyName||this.WRITE_KEY_NAME);s||(i=!1,s=await this._createExchangeKeys()),y||(i=!1,y=await this._createWriteKeys());let g=await qr(y),E=await Xe(new Uint8Array(g),this.TYPE==="ecc"?"ed25519":"rsa"),L=new this({keys:{exchange:s,write:y},did:E,hasPersisted:i,isSessionOnly:!!e.session});return this._instance=L,L}};x(te,"AbstractKeys"),I(te,"EXCHANGE_KEY_NAME"),I(te,"WRITE_KEY_NAME"),I(te,"_instance");var _e=te;async function vi(n,e){let{content:i,publicKey:s}=n,y=e||await pr.create(),g=await pr.encrypt(typeof i=="string"?Tr(i):i,typeof y=="string"?await pr.import(y):y),E=await Cn({key:y,publicKey:s});return Jr(E,g)}x(vi,"encryptTo");vi.asString=async function(n,e){let i=await vi(n,e);return ir(new Uint8Array(i),"base64pad")};async function Cn({key:n,publicKey:e},i){let s;n instanceof CryptoKey?s=await pr.export(n):s=n;let y=await Zr.encrypt(s,e);return i&&i==="arraybuffer"?y:new Uint8Array(y)}x(Cn,"encryptKeyTo");Cn.asString=async function({key:n,publicKey:e},i){let s=await Cn({key:n,publicKey:e});return i?ir(s,i):vr(s)};async function mo(n){let e=await wi(new TextEncoder().encode(n.normalize("NFD")));return ir(e,"base32").slice(0,32)}x(mo,"getDeviceName");function _n(n){return new Uint8Array(n).buffer}x(_n,"toArrayBuffer");var Qr=class Qr extends _e{constructor(e){super(e),Qr.EXCHANGE_KEY_NAME=e.exchangeKeyName||ht,Qr.WRITE_KEY_NAME=e.writeKeyName||dt}static async _createExchangeKeys(){return await Kn(xt,ce,"exchange")}static async _createWriteKeys(){return await Kn(xt,ce,"write")}async toJson(e){let i=this.publicExchangeKey,s=this.DID,y=await $.subtle.exportKey("spki",i);return{publicExchangeKey:e?ir(new Uint8Array(y),e):vr(y),DID:s}}async sign(e,i=Fr){let s=this.writeKey,y=await Zr.sign(e,s.privateKey,i);return new Uint8Array(y)}async signAsString(e,i){let s=await this.sign(e,i);return vr(s)}async encrypt(e,i,s,y,g){let E=i||this.exchangeKey.publicKey,L=s,tr=y,or=L||await pr.create({length:tr||g}),fr=await pr.encrypt(typeof e=="string"?Tr(e):e,typeof or=="string"?await pr.import(or):or),Ar=await Pe({key:or,publicKey:E}),Lr=Jr(Ar,fr);return new Uint8Array(Lr)}async encryptAsString(e,i,s,y,g){let E=await this.encrypt(e,i,s,y,g);return ir(E,"base64pad")}async decrypt(e,i,s){let y=(typeof i=="number"?i:void 0)||Xr,g=xe(e,jr),E=g.slice(0,y),L=g.slice(y),tr=await this.decryptKey(E);return await pr.decrypt(L,tr)}async decryptAsString(e,i,s){let y=await this.decrypt(e,i,s);return ir(y)}async decryptKey(e){return await Zr.decrypt(e,this.exchangeKey.privateKey)}async decryptKeyAsString(e,i){let s=await Zr.decrypt(e,this.exchangeKey.privateKey);return ir(s,i)}async getAesKey(e,i){if(!e)throw new Error("RSA requires an encrypted AES key to decrypt");if(typeof e=="string"){let s=await this.decryptKey(e);return await pr.import(s)}else return e}};x(Qr,"RsaKeys"),I(Qr,"TYPE","rsa"),I(Qr,"INFO","keys"),I(Qr,"EXCHANGE_KEY_NAME",ht),I(Qr,"WRITE_KEY_NAME",dt);var ue=Qr;Object.assign(ue.prototype.sign,{asString:x(async function(n,e){return this.signAsString(n,e)},"asString")});Object.assign(ue.prototype.encrypt,{asString:x(async function(n,e,i,s){return this.encryptAsString(n,e,i,s)},"asString")});Object.assign(ue.prototype.decrypt,{asString:x(async function(n,e){return this.decryptAsString(n,e)},"asString")});async function wo(n,e,i){let s=gt(i),y=await Ve(_n(s.publicKey),"SHA-256","signing");try{return Zr.verify(n,e,y)}catch{return!1}}x(wo,"verify");Object.assign(ue.prototype.decryptKey,{asString:x(async function(n,e){return this.decryptKeyAsString(n,e)},"asString")});async function Ci(n,e){let{content:i,publicKey:s}=n,y=e||await pr.create(),g=await pr.encrypt(typeof i=="string"?Tr(i):i,typeof y=="string"?await pr.import(y):y),E=await Pe({key:y,publicKey:s});return Jr(E,g)}x(Ci,"encryptTo");Ci.asString=async function(n,e){let{content:i,publicKey:s}=n,y=e||await pr.create(),g=await pr.encrypt(typeof i=="string"?Tr(i):i,typeof y=="string"?await pr.import(y):y,"arraybuffer"),E=await Pe({key:y,publicKey:s}),L=Jr(E,g);return ir(new Uint8Array(L),"base64pad")};async function Pe({key:n,publicKey:e},i){let s;n instanceof CryptoKey?s=await pr.export(n):s=n;let y=await Zr.encrypt(s,e);return i&&i==="arraybuffer"?y:new Uint8Array(y)}x(Pe,"encryptKeyTo");Pe.asString=async function({key:n,publicKey:e},i){let s=await Pe({key:n,publicKey:e});return i?ir(s,i):vr(s)};async function Ko(n,e,i,s){let y=Se(e)?e:await Ce(e),g=s?await $.subtle.encrypt({name:Gr,iv:_n(s)},y,_n(n)):await Eo(n,y);return i&&i==="arraybuffer"?g:new Uint8Array(g)}x(Ko,"encrypt");async function Eo(n,e,i){let s=ye(n,i?.charsize??Fr),y=typeof e=="string"?await ke(e,i):e,g=i?.iv||lt(Or),E=await $.subtle.encrypt({name:Gr,iv:g},y,s);return Jr(g,E)}x(Eo,"encryptBytes");var Bi={};Sr(Bi,{EccKeys:()=>ne,default:()=>vo,exportPublicKey:()=>mt,importPublicKey:()=>We,verify:()=>Co});var Qs=new Error("Key does not exist. Make sure you properly instantiated the keystore."),rc=new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name."),ec=new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name."),tc=new Error("ECC is not enabled for this browser. Please use RSA instead."),nc=new Error("Cryptosystem not supported. Please use ECC or RSA"),Uo=new Error("Invalid key use. Please use 'exchange' or 'write'"),ic=new Error("Max must be less than 256 and greater than 0");function Pi(n){So(n,["exchange","write","signing"],Uo)}x(Pi,"checkValidKeyUse");function So(n,e,i){if(!e.some(y=>y===n))throw i}x(So,"checkValid");function $e(n){return new Uint8Array(n).buffer}x($e,"toArrayBuffer");var Pr=class Pr extends _e{constructor(e){super(e),Pr.EXCHANGE_KEY_NAME=e.exchangeKeyName||Fe,Pr.WRITE_KEY_NAME=e.writeKeyName||Ge}get publicExchangeKey(){let e=this.exchangeKey.publicKey;return Object.assign(e,{asString:x(async i=>{let s=await mt(this.exchangeKey),y=new Uint8Array(s);return i?ir(y,i):vr(s)},"asString")})}get publicWriteKey(){let e=this.writeKey.publicKey;return Object.assign(e,{asString:x(async i=>{let s=await mt(this.writeKey),y=new Uint8Array(s);return i?ir(y,i):vr(s)},"asString")})}static async _createExchangeKeys(){return await $.subtle.generateKey({name:ln},!1,["deriveKey","deriveBits"])}static async _createWriteKeys(){return await $.subtle.generateKey({name:gn},!1,["sign","verify"])}static async load(e={session:!1}){if(this._instance)return this._instance;let i=e.encryptionKeyName||Fe,s=e.signingKeyName||Ge;return super.load({...e,encryptionKeyName:i,signingKeyName:s})}async toJson(e){let i=this.DID,s=await mt(this.exchangeKey);return{publicExchangeKey:e?ir(new Uint8Array(s),e):vr(s),DID:i}}async encrypt(e,i,s,y,g){let E=new TextEncoder,L=crypto.getRandomValues(new Uint8Array(Yr)),tr=i||this.exchangeKey.publicKey,or;typeof tr=="string"?or=await We(tr,"X25519","exchange"):or=tr;let fr=y||await At(this.exchangeKey.privateKey,or,L,s||Pr.INFO,g);fr instanceof CryptoKey||(fr=await At(this.exchangeKey.privateKey,or,L,s||Pr.INFO));let Ar=crypto.getRandomValues(new Uint8Array(Or)),Lr=typeof e=="string"?E.encode(e):e,pe=await crypto.subtle.encrypt({name:Vr,iv:Ar},fr,$e(Lr)),Z=new Uint8Array(L),xr=new Uint8Array(Ar),Cr=new Uint8Array(pe),Er=Z.length+xr.length+Cr.length,lr=new Uint8Array(Er);return lr.set(Z,0),lr.set(xr,Z.length),lr.set(Cr,Z.length+xr.length),lr}async encryptAsString(e,i,s,y,g){let E=await this.encrypt(e,i,s||Pr.INFO,y,g);return ir(new Uint8Array(E),"base64pad")}async decrypt(e,i,s,y){let g=typeof i=="string"?await We(i,"X25519","write"):i;g||(g=this.publicExchangeKey);let E=xe(e,jr),L=E.slice(0,Yr),tr=E.slice(Yr,Yr+Or),or=E.slice(Yr+Or),{privateKey:fr}=this.exchangeKey,Ar=await At(fr,g,L,y||Pr.INFO);return await crypto.subtle.decrypt({name:s||Vr,iv:tr},Ar,or)}async decryptAsString(e,i,s,y){let g=await this.decrypt(e,i,s,y);return ir(new Uint8Array(g))}async getAesKey(e,i){e||(e=this.publicExchangeKey);let s;typeof e=="string"?s=await We(e,"X25519","exchange"):s=e;let y=crypto.getRandomValues(new Uint8Array(Yr));return await At(this.exchangeKey.privateKey,s,y,i||Pr.INFO)}async sign(e,i){let s=new TextEncoder,y;typeof e=="string"?y=s.encode(e):e instanceof ArrayBuffer?y=new Uint8Array(e):y=e;let g=await $.subtle.sign({name:Ue},this.writeKey.privateKey,$e(y));return new Uint8Array(g)}async signAsString(e,i){let s=await this.sign(e,i);return ir(s,"base64pad")}};x(Pr,"EccKeys"),I(Pr,"TYPE","ecc"),I(Pr,"EXCHANGE_KEY_NAME",Fe),I(Pr,"WRITE_KEY_NAME",Ge),I(Pr,"INFO","keys");var ne=Pr;Object.assign(ne.prototype.sign,{asString:x(async function(n,e){let i=await this.sign(n,e);return ir(i,"base64pad")},"asString")});async function mt(n){return await $.subtle.exportKey("raw",n.publicKey)}x(mt,"exportPublicKey");async function We(n,e,i){Pi(i);let s=i==="exchange"?dn:Ue,y=i==="exchange"?[]:["verify"],g=jr(n),E=e==="X25519"?{name:s}:{name:s,namedCurve:e};return $.subtle.importKey("raw",g,E,!0,y)}x(We,"importPublicKey");var vo={EccKeys:ne,importPublicKey:We};Object.assign(ne.prototype.encrypt,{asString:x(async function(n,e,i,s,y){return this.encryptAsString(n,e,i,s,y)},"asString")});Object.assign(ne.prototype.decrypt,{asString:x(async function(n,e,i){return this.decryptAsString(n,e,i)},"asString")});Object.assign(ne.prototype.sign,{asString:x(async function(n,e){return this.signAsString(n,e)},"asString")});async function Co(n,e,i){try{let s=gt(i);if(s.type!=="ed25519")throw new Error(`Expected Ed25519 key for ECC verification, got ${s.type}`);let y=s.publicKey.slice(-32),g=await $.subtle.importKey("raw",y,{name:Ue},!0,["verify"]),E=new TextEncoder,L;typeof n=="string"?L=E.encode(n):n instanceof ArrayBuffer?L=new Uint8Array(n):L=n;let tr;return typeof e=="string"?tr=new Uint8Array(jr(e)):tr=e,await $.subtle.verify({name:Ue},g,$e(tr),$e(L))}catch{return!1}}x(Co,"verify");async function At(n,e,i,s,y){let g=new TextEncoder,E=await crypto.subtle.deriveBits({name:"X25519",public:e},n,256),L=await crypto.subtle.importKey("raw",E,"HKDF",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:i instanceof Uint8Array?$e(i):i,info:g.encode(s)},L,{name:"AES-GCM",length:y||Xr},!1,["encrypt","decrypt"])}x(At,"deriveKey");export{Gr as AES_GCM,_e as AbstractKeys,je as BASE58_DID_PREFIX,ut as BLS_DID_PREFIX,zt as CharSize,kn as CryptoSystem,Fr as DEFAULT_CHAR_SIZE,Fe as DEFAULT_ECC_EXCHANGE,to as DEFAULT_ECC_EXCHANGE_CURVE,Ge as DEFAULT_ECC_WRITE,ce as DEFAULT_HASH_ALGORITHM,ht as DEFAULT_RSA_EXCHANGE,xt as DEFAULT_RSA_SIZE,dt as DEFAULT_RSA_WRITE,Vr as DEFAULT_SYMM_ALGORITHM,Xr as DEFAULT_SYMM_LENGTH,dn as ECC_EXCHANGE_ALG,ln as ECC_EXCHANGE_NAME,Ue as ECC_WRITE_ALG,gn as ECC_WRITE_NAME,pt as EDWARDS_DID_PREFIX,Rt as EccCurve,Nt as HashAlg,Or as IV_LENGTH,He as KEY_TYPE,bi as KEY_USE,be as KeyUse,ae as RSA_ALGORITHM,yt as RSA_DID_PREFIX,ct as RSA_HASHING_ALGORITHM,se as RSA_SIGN_ALGORITHM,Vn as RsaSize,Yr as SALT_LENGTH,Xn as SymmKeyLength,Ui as aes,Bi as ecc,Cn as encryptKeyTo,vi as encryptTo,mo as getDeviceName,qr as getPublicKeyAsArrayBuffer,wn as getPublicKeyAsUint8Array,Xe as publicKeyToDid,_i as rsa};
|
|
4
|
+
//# sourceMappingURL=index.min.js.map
|