@substrate-system/keys 0.2.10 → 0.2.12
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.cjs +12 -11
- package/dist/_base.cjs.map +3 -3
- package/dist/_base.d.ts +2 -2
- package/dist/_base.d.ts.map +1 -1
- package/dist/_base.js +6 -4
- package/dist/_base.js.map +2 -2
- package/dist/_base.min.cjs +1 -1
- package/dist/_base.min.cjs.map +3 -3
- package/dist/_base.min.js +2 -2
- package/dist/_base.min.js.map +4 -4
- package/dist/aes/index.cjs +3 -2
- package/dist/aes/index.cjs.map +2 -2
- package/dist/aes/index.js +1 -1
- 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 +2 -2
- package/dist/aes/index.min.js.map +4 -4
- package/dist/browser/index.js +178 -177
- package/dist/browser/index.min.js +2 -2
- package/dist/crypto.cjs +221 -0
- package/dist/crypto.cjs.map +7 -0
- package/dist/crypto.d.ts +54 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +208 -0
- package/dist/crypto.js.map +7 -0
- package/dist/crypto.min.cjs +4 -0
- package/dist/crypto.min.cjs.map +7 -0
- package/dist/crypto.min.js +4 -0
- package/dist/crypto.min.js.map +7 -0
- package/dist/ecc/index.min.js +2 -2
- package/dist/ecc/index.min.js.map +4 -4
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +99 -34
- package/dist/rsa/index.cjs +12 -11
- package/dist/rsa/index.cjs.map +3 -3
- package/dist/rsa/index.d.ts +2 -2
- package/dist/rsa/index.d.ts.map +1 -1
- package/dist/rsa/index.js +8 -6
- package/dist/rsa/index.js.map +2 -2
- package/dist/rsa/index.min.cjs +1 -1
- package/dist/rsa/index.min.cjs.map +3 -3
- package/dist/rsa/index.min.js +2 -2
- package/dist/rsa/index.min.js.map +4 -4
- package/dist/util.cjs +13 -203
- package/dist/util.cjs.map +3 -3
- package/dist/util.d.ts +4 -54
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +14 -198
- package/dist/util.js.map +3 -3
- package/dist/util.min.cjs +1 -3
- package/dist/util.min.cjs.map +3 -3
- package/dist/util.min.js +1 -3
- package/dist/util.min.js.map +4 -4
- package/package.json +5 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";(()=>{var vi=Object.create;var Qe=Object.defineProperty;var _i=Object.getOwnPropertyDescriptor;var Ci=Object.getOwnPropertyNames;var Pi=Object.getPrototypeOf,Bi=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})},Ti=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let y of Ci(e))!Bi.call(t,y)&&y!==i&&Qe(t,y,{get:()=>e[y],enumerable:!(s=_i(e,y))||s.enumerable});return t};var Di=(t,e,i)=>(i=t!=null?vi(Pi(t)):{},Ti(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,Ai=bt;function mi(n,o,f,r,a,u){var p=new Uint8Array(32);return ke(p,a,u),Un(n,o,f,r,p)}x(mi,"crypto_box");function wi(n,o,f,r,a,u){var p=new Uint8Array(32);return ke(p,a,u),Ai(n,o,f,r,p)}x(wi,"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 Ki(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(Ki,"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||Ki(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,Ei=Se,Ui=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:mi,crypto_box_open:wi,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:Ei,crypto_box_BOXZEROBYTES:Ui,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 Si(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(Si,"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),Si(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 gi={};Er(gi,{AES_GCM:()=>jr,BASE58_DID_PREFIX:()=>Le,BLS_DID_PREFIX:()=>at,DEFAULT_CHAR_SIZE:()=>Yr,DEFAULT_ECC_EXCHANGE:()=>Re,DEFAULT_ECC_EXCHANGE_CURVE:()=>Ff,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:()=>di,getPublicKeyAsArrayBuffer:()=>Wr,getPublicKeyAsUint8Array:()=>yn,publicKeyToDid:()=>Ye,verify:()=>ao});var Mi=globalThis||window||self,W=Mi.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:()=>Yi});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 Li(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(Li,"base");var Ni=Li,Ri=Ni,jn=Ri;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 zi(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(zi,"decode");function Oi(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(Oi,"encode");function cr({name:t,prefix:e,bitsPerChar:i,alphabet:s}){return he({prefix:e,name:t,encode(y){return Oi(y,s,i)},decode(y){return zi(y,s,i,t)}})}x(cr,"rfc4648");var Yi=qr({prefix:"9",name:"base10",alphabet:"0123456789"});var Yt={};Er(Yt,{base16:()=>ji,base16upper:()=>Hi});var ji=cr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Hi=cr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var jt={};Er(jt,{base2:()=>Fi});var Fi=cr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ht={};Er(Ht,{base256emoji:()=>Wi});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}"),Gi=Fn.reduce((t,e,i)=>(t[i]=e,t),[]),Vi=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 Xi(t){return t.reduce((e,i)=>(e+=Gi[i],e),"")}x(Xi,"encode");function ki(t){let e=[];for(let i of t){let s=i.codePointAt(0);if(s==null)throw new Error(`Invalid character: ${i}`);let y=Vi[s];if(y==null)throw new Error(`Non-base256emoji character: ${i}`);e.push(y)}return new Uint8Array(e)}x(ki,"decode");var Wi=he({prefix:"\u{1F680}",name:"base256emoji",encode:Xi,decode:ki});var Ft={};Er(Ft,{base32:()=>de,base32hex:()=>Ji,base32hexpad:()=>rf,base32hexpadupper:()=>ef,base32hexupper:()=>Qi,base32pad:()=>Zi,base32padupper:()=>qi,base32upper:()=>$i,base32z:()=>tf});var de=cr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),$i=cr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zi=cr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),qi=cr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ji=cr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qi=cr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rf=cr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ef=cr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),tf=cr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Gt={};Er(Gt,{base36:()=>Be,base36upper:()=>nf});var Be=qr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),nf=qr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vt={};Er(Vt,{base58btc:()=>Or,base58flickr:()=>ff});var Or=qr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ff=qr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Xt={};Er(Xt,{base64:()=>of,base64pad:()=>af,base64url:()=>sf,base64urlpad:()=>cf});var of=cr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),af=cr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),sf=cr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cf=cr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var kt={};Er(kt,{base8:()=>yf});var yf=cr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wt={};Er(Wt,{identity:()=>xf});var xf=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:()=>If});var hf=Xn,Gn=128,df=127,gf=~df,lf=Math.pow(2,31);function Xn(t,e,i){e=e||[],i=i||0;for(var s=i;t>=lf;)e[i++]=t&255|Gn,t/=128;for(;t&gf;)e[i++]=t&255|Gn,t>>>=7;return e[i]=t|0,Xn.bytes=i-s+1,e}x(Xn,"encode");var bf=$t,Af=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>=Af);return $t.bytes=g-s,i}x($t,"read");var mf=Math.pow(2,7),wf=Math.pow(2,14),Kf=Math.pow(2,21),Ef=Math.pow(2,28),Uf=Math.pow(2,35),Sf=Math.pow(2,42),vf=Math.pow(2,49),_f=Math.pow(2,56),Cf=Math.pow(2,63),Pf=x(function(t){return t<mf?1:t<wf?2:t<Kf?3:t<Ef?4:t<Uf?5:t<Sf?6:t<vf?7:t<_f?8:t<Cf?9:10},"length"),Bf={encode:hf,decode:bf,encodingLength:Pf},Tf=Bf,Te=Tf;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,Df="identity",Zn=Xr;function Mf(t){return ee($n,Zn(t))}x(Mf,"digest");var If={code:$n,name:Df,encode:Zn,digest:Mf};var Qt={};Er(Qt,{sha256:()=>Lf,sha512:()=>Nf});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 Lf=Jt({name:"sha2-256",code:18,encode:Jn("SHA-256")}),Nf=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 zf(i,rn(t),e??Or.encoder);default:return Of(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!==Yf)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[jf]===!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]=Rf(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 Rf(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(Rf,"parseCIDtoBytes");function zf(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(zf,"toStringV0");function Of(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(Of,"toStringV1");var Ie=112,Yf=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 jf=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}),Hf={utf8:ti,"utf-8":ti,hex:en.base16,latin1:tn,ascii:tn,binary:tn,...en},tt=Hf;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 ui={};Er(ui,{AES:()=>ur,decryptBytes:()=>xi,importAesKey:()=>Ke});var si=Di(fi(),1);var Le="did:key:z",Ae="Ed25519",nn="X25519",Ff="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:Vf},ed25519:{magicBytes:new Uint8Array([237,1]),verify:Gf}}};async function Gf({message:t,publicKey:e,signature:i}){return si.default.sign.detached.verify(t,i,e)}x(Gf,"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 Qf(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 Vf({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(Vf,"rsaVerify");async function Oe(t,e,i){Wf(i);let s=i==="exchange"?te:ne,y=i==="exchange"?["encrypt"]:["verify"],g=typeof t=="string"?zr(Zf(t)):t;return W.subtle.importKey("spki",g,{name:s,hash:{name:e}},!0,y)}x(Oe,"importPublicKey");var Xf=new Error("Invalid key use. Please use 'encryption' or 'signing"),kf=new Error("Max must be less than 256 and greater than 0");function Wf(t){$f(t,["signing","exchange"],Xf)}x(Wf,"checkValidKeyUse");function $f(t,e,i){if(!e.some(y=>y===t))throw i}x($f,"checkValid");function Zf(t){return t.replace(`-----BEGIN PUBLIC KEY-----
|
|
1
|
+
"use strict";(()=>{var _i=Object.create;var Qe=Object.defineProperty;var Ci=Object.getOwnPropertyDescriptor;var Pi=Object.getOwnPropertyNames;var Bi=Object.getPrototypeOf,Ti=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 In=(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})},Di=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let y of Pi(e))!Ti.call(t,y)&&y!==i&&Qe(t,y,{get:()=>e[y],enumerable:!(s=Ci(e,y))||s.enumerable});return t};var Ii=(t,e,i)=>(i=t!=null?_i(Bi(t)):{},Di(e||!t||!t.__esModule?Qe(i,"default",{value:t,enumerable:!0}):i,t));var si=In(()=>{});var ci=In((xs,pt)=>{(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]),M=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]),Ir=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function ce(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(ce,"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,H=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=H,I=Y,j=R,G=O,F=z,c,X=0;X<20;X+=2)c=C+I|0,B^=c<<7|c>>>25,c=B+C|0,m^=c<<9|c>>>23,c=m+B|0,I^=c<<13|c>>>19,c=I+m|0,C^=c<<18|c>>>14,c=U+D|0,l^=c<<7|c>>>25,c=l+U|0,j^=c<<9|c>>>23,c=j+l|0,D^=c<<13|c>>>19,c=D+j|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,I^=c<<7|c>>>25,c=I+F|0,j^=c<<9|c>>>23,c=j+I|0,G^=c<<13|c>>>19,c=G+j|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+H|0,I=I+Y|0,j=j+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]=I>>>0&255,n[49]=I>>>8&255,n[50]=I>>>16&255,n[51]=I>>>24&255,n[52]=j>>>0&255,n[53]=j>>>8&255,n[54]=j>>>16&255,n[55]=j>>>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,H=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=H,I=Y,j=R,G=O,F=z,c,X=0;X<20;X+=2)c=C+I|0,B^=c<<7|c>>>25,c=B+C|0,m^=c<<9|c>>>23,c=m+B|0,I^=c<<13|c>>>19,c=I+m|0,C^=c<<18|c>>>14,c=U+D|0,l^=c<<7|c>>>25,c=l+U|0,j^=c<<9|c>>>23,c=j+l|0,D^=c<<13|c>>>19,c=D+j|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,I^=c<<7|c>>>25,c=I+F|0,j^=c<<9|c>>>23,c=j+I|0,G^=c<<13|c>>>19,c=G+j|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 Br(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(Br,"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,H,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],I=this.h[9],j=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,I+=J>>>5|r,_=0,L=_,L+=P*j,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+=I*(5*G),_+=L>>>13,L&=8191,N=_,N+=P*G,N+=B*j,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+=I*(5*F),_+=N>>>13,N&=8191,H=_,H+=P*F,H+=B*G,H+=U*j,H+=h*(5*q),H+=d*(5*Z),_=H>>>13,H&=8191,H+=m*(5*V),H+=l*(5*rr),H+=A*(5*Q),H+=w*(5*X),H+=I*(5*c),_+=H>>>13,H&=8191,Y=_,Y+=P*c,Y+=B*F,Y+=U*G,Y+=h*j,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+=I*(5*X),_+=Y>>>13,Y&=8191,R=_,R+=P*X,R+=B*c,R+=U*F,R+=h*G,R+=d*j,_=R>>>13,R&=8191,R+=m*(5*q),R+=l*(5*Z),R+=A*(5*V),R+=w*(5*rr),R+=I*(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*j,O+=l*(5*q),O+=A*(5*Z),O+=w*(5*V),O+=I*(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*j,z+=A*(5*q),z+=w*(5*Z),z+=I*(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*j,C+=w*(5*q),C+=I*(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*j,D+=I*(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+=I*j,_+=v>>>13,v&=8191,_=(_<<2)+_|0,_=_+L|0,L=_&8191,_=_>>>13,N+=_,P=L,B=N,U=H,h=Y,d=R,m=O,l=z,A=C,w=D,I=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]=I},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 lt(n,o,f,r,a,u){var p=new Ge(u);return p.update(f,r,a),p.finish(n,o),0}x(lt,"crypto_onetimeauth");function bn(n,o,f,r,a,u){var p=new Uint8Array(16);return lt(p,0,f,r,a,u),yr(n,o,p,0)}x(bn,"crypto_onetimeauth_verify");function bt(n,o,f,r,a){var u;if(f<32)return-1;for(Zr(n,0,o,0,f,r,a),lt(n,16,n,32,f-32,n),u=0;u<16;u++)n[u]=0;return 0}x(bt,"crypto_secretbox");function At(n,o,f,r,a){var u,p=new Uint8Array(32);if(f<32||(Br(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(At,"crypto_secretbox_open");function Gr(n,o){var f;for(f=0;f<16;f++)n[f]=o[f]|0}x(Gr,"set25519");function mt(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(mt,"car25519");function ye(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(ye,"sel25519");function xe(n,o){var f,r,a,u=e(),p=e();for(f=0;f<16;f++)p[f]=o[f];for(mt(p),mt(p),mt(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,ye(p,u,1-a)}for(f=0;f<16;f++)n[2*f]=p[f]&255,n[2*f+1]=p[f]>>8}x(xe,"pack25519");function An(n,o){var f=new Uint8Array(32),r=new Uint8Array(32);return xe(f,n),xe(r,o),Sr(f,0,r,0)}x(An,"neq25519");function mn(n){var o=new Uint8Array(32);return xe(o,n),o[0]&1}x(mn,"par25519");function wt(n,o){var f;for(f=0;f<16;f++)n[f]=o[2*f]+(o[2*f+1]<<8);n[15]&=32767}x(wt,"unpack25519");function Lr(n,o,f){for(var r=0;r<16;r++)n[r]=o[r]+f[r]}x(Lr,"A");function Nr(n,o,f){for(var r=0;r<16;r++)n[r]=o[r]-f[r]}x(Nr,"Z");function W(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,H=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,I=0,j=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,H+=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,H+=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,H+=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,H+=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,H+=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,H+=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,H+=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,H+=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,H+=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,H+=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],H+=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,I+=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,I+=r*Ar,j+=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,I+=r*br,j+=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,I+=r*pr,j+=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,H+=38*w,Y+=38*I,R+=38*j,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=H+a+65535,a=Math.floor(r/65536),H=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=H+a+65535,a=Math.floor(r/65536),H=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]=H,n[11]=Y,n[12]=R,n[13]=O,n[14]=z,n[15]=C}x(W,"M");function Tr(n,o){W(n,o,o)}x(Tr,"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--)Tr(f,f),r!==2&&r!==4&&W(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--)Tr(f,f),r!==1&&W(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,wt(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,ye(b,K,u),ye(T,S,u),Lr(J,b,T),Nr(b,b,T),Lr(T,K,S),Nr(K,K,S),Tr(S,J),Tr(_,b),W(b,T,b),W(T,K,J),Lr(J,b,T),Nr(b,b,T),Tr(K,b),Nr(T,S,_),W(b,T,M),Lr(b,b,S),W(T,T,b),W(b,S,_),W(S,K,a),Tr(K,J),ye(b,K,u),ye(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),W(N,N,L),xe(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=bt,mi=At;function wi(n,o,f,r,a,u){var p=new Uint8Array(32);return ke(p,a,u),Un(n,o,f,r,p)}x(wi,"crypto_box");function Ki(n,o,f,r,a,u){var p=new Uint8Array(32);return ke(p,a,u),mi(n,o,f,r,p)}x(Ki,"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,H,Y,R,O,z,C,D,v,P,B,U,h,d,m,l,A,w,I=n[0],j=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=I,b=j,K=G,T=F,S=c,J=X,_=Q,L=rr,N=V,H=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=(I>>>28|V<<4)^(V>>>2|I<<30)^(V>>>7|I<<25),d=(V>>>28|I<<4)^(I>>>2|V<<30)^(I>>>7|V<<25),m+=d&65535,l+=d>>>16,A+=h&65535,w+=h>>>16,h=I&j^I&G^j&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,j=p,G=b,F=K,c=T,X=S,Q=J,rr=_,I=L,Z=N,q=H,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=I,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]=I=A&65535|w<<16,o[0]=V=m&65535|l<<16,h=j,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]=j=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 te(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,ce(u,f-8,b/536870912|0,b<<3),vn(r,a,u,f),p=0;p<8;p++)ce(n,8*p,r[p],a[p]);return 0}x(te,"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();Nr(f,n[1],n[0]),Nr(S,o[1],o[0]),W(f,f,S),Lr(r,n[0],n[1]),Lr(S,o[0],o[1]),W(r,r,S),W(a,n[3],o[3]),W(a,a,fr),W(u,n[2],o[2]),Lr(u,u,u),Nr(p,r,f),Nr(b,u,a),Lr(K,u,a),Lr(T,r,f),W(n[0],p,b),W(n[1],T,K),W(n[2],K,b),W(n[3],p,T)}x(We,"add");function _n(n,o,f){var r;for(r=0;r<4;r++)ye(n[r],o[r],f)}x(_n,"cswap");function Kt(n,o){var f=e(),r=e(),a=e();wn(a,o[2]),W(f,o[0],a),W(r,o[1],a),xe(n,r),n[31]^=mn(f)<<7}x(Kt,"pack");function Et(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(Et,"scalarmult");function $e(n,o){var f=[e(),e(),e(),e()];Gr(f[0],ir),Gr(f[1],lr),Gr(f[2],E),W(f[3],ir,lr),Et(n,f,o)}x($e,"scalarbase");function Ut(n,o,f){var r=new Uint8Array(64),a=[e(),e(),e(),e()],u;for(f||i(o,32),te(r,o,32),r[0]&=248,r[31]&=127,r[31]|=64,$e(a,r),Kt(n,a),u=0;u<32;u++)o[u+32]=n[u];return 0}x(Ut,"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 St(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(St,"modL");function vt(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;St(n,o)}x(vt,"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()];te(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(te(p,n.subarray(32),f+32),vt(p),$e(S,p),Kt(n,S),b=32;b<64;b++)n[b]=r[b];for(te(u,n,f+64),vt(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 St(n.subarray(32),T),J}x(Cn,"crypto_sign");function Ei(n,o){var f=e(),r=e(),a=e(),u=e(),p=e(),b=e(),K=e();return Gr(n[2],E),wt(n[1],o),Tr(a,n[1]),W(u,a,er),Nr(a,a,n[2]),Lr(u,n[2],u),Tr(p,u),Tr(b,p),W(K,b,p),W(f,K,a),W(f,f,u),Kn(f,f),W(f,f,a),W(f,f,u),W(f,f,u),W(n[0],f,u),Tr(r,n[0]),W(r,r,u),An(r,a)&&W(n[0],n[0],Ir),Tr(r,n[0]),W(r,r,u),An(r,a)?-1:(mn(n[0])===o[31]>>7&&Nr(n[0],g,n[0]),W(n[3],n[0],n[1]),0)}x(Ei,"unpackneg");function _t(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||Ei(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(te(p,n,f),vt(p),Et(b,K,p),$e(K,o.subarray(32)),We(b,K),Kt(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(_t,"crypto_sign_open");var Ct=32,qe=24,ve=32,ue=16,_e=32,Je=32,Ce=32,Pe=32,Pt=32,Pn=qe,Ui=ve,Si=ue,Vr=64,ne=32,pe=64,Bt=32,Tt=64;t.lowlevel={crypto_core_hsalsa20:gr,crypto_stream_xor:Zr,crypto_stream:Br,crypto_stream_salsa20_xor:Mr,crypto_stream_salsa20:vr,crypto_onetimeauth:lt,crypto_onetimeauth_verify:bn,crypto_verify_16:yr,crypto_verify_32:Sr,crypto_secretbox:bt,crypto_secretbox_open:At,crypto_scalarmult:Ve,crypto_scalarmult_base:Xe,crypto_box_beforenm:ke,crypto_box_afternm:Un,crypto_box:wi,crypto_box_open:Ki,crypto_box_keypair:En,crypto_hash:te,crypto_sign:Cn,crypto_sign_keypair:Ut,crypto_sign_open:_t,crypto_secretbox_KEYBYTES:Ct,crypto_secretbox_NONCEBYTES:qe,crypto_secretbox_ZEROBYTES:ve,crypto_secretbox_BOXZEROBYTES:ue,crypto_scalarmult_BYTES:_e,crypto_scalarmult_SCALARBYTES:Je,crypto_box_PUBLICKEYBYTES:Ce,crypto_box_SECRETKEYBYTES:Pe,crypto_box_BEFORENMBYTES:Pt,crypto_box_NONCEBYTES:Pn,crypto_box_ZEROBYTES:Ui,crypto_box_BOXZEROBYTES:Si,crypto_sign_BYTES:Vr,crypto_sign_PUBLICKEYBYTES:ne,crypto_sign_SECRETKEYBYTES:pe,crypto_sign_SEEDBYTES:Bt,crypto_hash_BYTES:Tt,gf:e,D:er,L:Ze,pack25519:xe,unpack25519:wt,M:W,A:Lr,S:Tr,Z:Nr,pow2523:Kn,add:We,set25519:Gr,modL:St,scalarmult:Et,scalarbase:$e};function Bn(n,o){if(n.length!==Ct)throw new Error("bad key size");if(o.length!==qe)throw new Error("bad nonce size")}x(Bn,"checkLengths");function vi(n,o){if(n.length!==Ce)throw new Error("bad public key size");if(o.length!==Pe)throw new Error("bad secret key size")}x(vi,"checkBoxLengths");function Cr(){for(var n=0;n<arguments.length;n++)if(!(arguments[n]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}x(Cr,"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){Cr(n,o,f),Bn(f,o);for(var r=new Uint8Array(ve+n.length),a=new Uint8Array(r.length),u=0;u<n.length;u++)r[u+ve]=n[u];return bt(a,r,r.length,o,f),a.subarray(ue)},t.secretbox.open=function(n,o,f){Cr(n,o,f),Bn(f,o);for(var r=new Uint8Array(ue+n.length),a=new Uint8Array(r.length),u=0;u<n.length;u++)r[u+ue]=n[u];return r.length<32||At(a,r,r.length,o,f)!==0?null:a.subarray(ve)},t.secretbox.keyLength=Ct,t.secretbox.nonceLength=qe,t.secretbox.overheadLength=ue,t.scalarMult=function(n,o){if(Cr(n,o),n.length!==Je)throw new Error("bad n size");if(o.length!==_e)throw new Error("bad p size");var f=new Uint8Array(_e);return Ve(f,n,o),f},t.scalarMult.base=function(n){if(Cr(n),n.length!==Je)throw new Error("bad n size");var o=new Uint8Array(_e);return Xe(o,n),o},t.scalarMult.scalarLength=Je,t.scalarMult.groupElementLength=_e,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){Cr(n,o),vi(n,o);var f=new Uint8Array(Pt);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(Ce),o=new Uint8Array(Pe);return En(n,o),{publicKey:n,secretKey:o}},t.box.keyPair.fromSecretKey=function(n){if(Cr(n),n.length!==Pe)throw new Error("bad secret key size");var o=new Uint8Array(Ce);return Xe(o,n),{publicKey:o,secretKey:new Uint8Array(n)}},t.box.publicKeyLength=Ce,t.box.secretKeyLength=Pe,t.box.sharedKeyLength=Pt,t.box.nonceLength=Pn,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(n,o){if(Cr(n,o),o.length!==pe)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(Cr(n,o),o.length!==ne)throw new Error("bad public key size");var f=new Uint8Array(n.length),r=_t(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(Cr(n,o,f),o.length!==Vr)throw new Error("bad signature size");if(f.length!==ne)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 _t(a,r,r.length,f)>=0},t.sign.keyPair=function(){var n=new Uint8Array(ne),o=new Uint8Array(pe);return Ut(n,o),{publicKey:n,secretKey:o}},t.sign.keyPair.fromSecretKey=function(n){if(Cr(n),n.length!==pe)throw new Error("bad secret key size");for(var o=new Uint8Array(ne),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(Cr(n),n.length!==Bt)throw new Error("bad seed size");for(var o=new Uint8Array(ne),f=new Uint8Array(pe),r=0;r<32;r++)f[r]=n[r];return Ut(o,f,!0),{publicKey:o,secretKey:f}},t.sign.publicKeyLength=ne,t.sign.secretKeyLength=pe,t.sign.seedLength=Bt,t.sign.signatureLength=Vr,t.hash=function(n){Cr(n);var o=new Uint8Array(Tt);return te(o,n,n.length),o},t.hash.hashLength=Tt,t.verify=function(n,o){return Cr(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=si(),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 pt<"u"&&pt.exports?pt.exports:self.nacl=self.nacl||{})});var Mn=(s=>(s[s.B1024=1024]="B1024",s[s.B2048=2048]="B2048",s[s.B4096=4096]="B4096",s))(Mn||{}),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||{}),Dt=(y=>(y.SHA_1="SHA-1",y.SHA_256="SHA-256",y.SHA_384="SHA-384",y.SHA_512="SHA-512",y))(Dt||{}),It=(y=>(y.P_256="P-256",y.P_384="P-384",y.P_521="P-521",y.X25519="X25519",y))(It||{}),ie=(s=>(s.Sign="signing",s.Exchange="exchange",s.Write="write",s))(ie||{}),Mt=(i=>(i[i.B8=8]="B8",i[i.B16=16]="B16",i))(Mt||{});var li={};Er(li,{AES_GCM:()=>Hr,BASE58_DID_PREFIX:()=>Ae,BLS_DID_PREFIX:()=>ot,DEFAULT_CHAR_SIZE:()=>Yr,DEFAULT_ECC_EXCHANGE:()=>Re,DEFAULT_ECC_EXCHANGE_CURVE:()=>Gf,DEFAULT_ECC_WRITE:()=>ze,DEFAULT_HASH_ALGORITHM:()=>oe,DEFAULT_RSA_EXCHANGE:()=>st,DEFAULT_RSA_SIZE:()=>ft,DEFAULT_RSA_WRITE:()=>ct,DEFAULT_SYMM_ALGORITHM:()=>jr,DEFAULT_SYMM_LENGTH:()=>Fr,ECC_EXCHANGE_ALG:()=>fn,ECC_EXCHANGE_NAME:()=>an,ECC_WRITE_ALG:()=>me,ECC_WRITE_NAME:()=>on,EDWARDS_DID_PREFIX:()=>at,IV_LENGTH:()=>Rr,KEY_TYPE:()=>Ne,KEY_USE:()=>ii,RSA_ALGORITHM:()=>Jr,RSA_DID_PREFIX:()=>it,RSA_HASHING_ALGORITHM:()=>nt,RSA_SIGN_ALGORITHM:()=>Qr,RsaKeys:()=>se,SALT_LENGTH:()=>zr,encrypt:()=>so,encryptKeyTo:()=>Se,encryptTo:()=>gi,getPublicKeyAsArrayBuffer:()=>$r,getPublicKeyAsUint8Array:()=>xn,publicKeyToDid:()=>He,verify:()=>ao});var Mi=globalThis||window||self,k=Mi.crypto;function Be(t=0){return new Uint8Array(t)}x(Be,"allocUnsafe");function Lt(t,e){e==null&&(e=t.reduce((y,g)=>y+g.length,0));let i=Be(e),s=0;for(let y of t)i.set(y,s),s+=y.length;return i}x(Lt,"concat");var Yt={};Er(Yt,{base10:()=>Hi});var Mo=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 Ni(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 M=t.length,er=t.charAt(0),fr=Math.log(M)/Math.log(256),ir=Math.log(256)/Math.log(M);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%M>>>0,hr=hr/M>>>0;if(hr!==0)throw new Error("Non-zero carry");Sr=Mr,wr++}for(var Br=Kr-Sr;Br!==Kr&&gr[Br]===0;)Br++;for(var Zr=er.repeat(yr);Br<Kr;++Br)Zr+=t.charAt(gr[Br]);return Zr}x(lr,"encode");function Ir($){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+=M*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 Br=new Uint8Array(Sr+(dr-vr)),Zr=Sr;vr!==dr;)Br[Zr++]=Kr[vr++];return Br}}}x(Ir,"decodeUnsafe");function ce($){var yr=Ir($);if(yr)return yr;throw new Error(`Non-${e} character`)}return x(ce,"decode"),{encode:lr,decodeUnsafe:Ir,decode:ce}}x(Ni,"base");var Ri=Ni,zi=Ri,Hn=zi;var Nt=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")}},Rt=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 jn(this,e)}},zt=class{static{x(this,"ComposedDecoder")}decoders;constructor(e){this.decoders=e}or(e){return jn(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 jn(t,e){return new zt({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}x(jn,"or");var Ot=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 Nt(e,i,s),this.decoder=new Rt(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 Ot(t,e,i,s)}x(he,"from");function qr({name:t,prefix:e,alphabet:i}){let{encode:s,decode:y}=Hn(i,t);return he({prefix:e,name:t,encode:s,decode:x(g=>Xr(y(g)),"decode")})}x(qr,"baseX");function Oi(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),M=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,M+=i,M>=8&&(M-=8,E[fr++]=255&er>>M)}if(M>=i||(255&er<<8-M)!==0)throw new SyntaxError("Unexpected end of data");return E}x(Oi,"decode");function Yi(t,e,i){let s=e[e.length-1]==="=",y=(1<<i)-1,g="",E=0,M=0;for(let er=0;er<t.length;++er)for(M=M<<8|t[er],E+=8;E>i;)E-=i,g+=e[y&M>>E];if(E!==0&&(g+=e[y&M<<i-E]),s)for(;(g.length*i&7)!==0;)g+="=";return g}x(Yi,"encode");function cr({name:t,prefix:e,bitsPerChar:i,alphabet:s}){return he({prefix:e,name:t,encode(y){return Yi(y,s,i)},decode(y){return Oi(y,s,i,t)}})}x(cr,"rfc4648");var Hi=qr({prefix:"9",name:"base10",alphabet:"0123456789"});var Ht={};Er(Ht,{base16:()=>ji,base16upper:()=>Fi});var ji=cr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fi=cr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var jt={};Er(jt,{base2:()=>Gi});var Gi=cr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ft={};Er(Ft,{base256emoji:()=>$i});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}"),Vi=Fn.reduce((t,e,i)=>(t[i]=e,t),[]),Xi=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 ki(t){return t.reduce((e,i)=>(e+=Vi[i],e),"")}x(ki,"encode");function Wi(t){let e=[];for(let i of t){let s=i.codePointAt(0);if(s==null)throw new Error(`Invalid character: ${i}`);let y=Xi[s];if(y==null)throw new Error(`Non-base256emoji character: ${i}`);e.push(y)}return new Uint8Array(e)}x(Wi,"decode");var $i=he({prefix:"\u{1F680}",name:"base256emoji",encode:ki,decode:Wi});var Gt={};Er(Gt,{base32:()=>de,base32hex:()=>Qi,base32hexpad:()=>ef,base32hexpadupper:()=>tf,base32hexupper:()=>rf,base32pad:()=>qi,base32padupper:()=>Ji,base32upper:()=>Zi,base32z:()=>nf});var de=cr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zi=cr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qi=cr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ji=cr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qi=cr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rf=cr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ef=cr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),tf=cr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),nf=cr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vt={};Er(Vt,{base36:()=>Te,base36upper:()=>ff});var Te=qr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ff=qr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Xt={};Er(Xt,{base58btc:()=>Or,base58flickr:()=>of});var Or=qr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),of=qr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kt={};Er(kt,{base64:()=>af,base64pad:()=>sf,base64url:()=>cf,base64urlpad:()=>yf});var af=cr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sf=cr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),cf=cr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yf=cr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Wt={};Er(Wt,{base8:()=>xf});var xf=cr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var $t={};Er($t,{identity:()=>uf});var uf=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 qt={};Er(qt,{identity:()=>Lf});var df=Xn,Gn=128,gf=127,lf=~gf,bf=Math.pow(2,31);function Xn(t,e,i){e=e||[],i=i||0;for(var s=i;t>=bf;)e[i++]=t&255|Gn,t/=128;for(;t&lf;)e[i++]=t&255|Gn,t>>>=7;return e[i]=t|0,Xn.bytes=i-s+1,e}x(Xn,"encode");var Af=Zt,mf=128,Vn=127;function Zt(t,s){var i=0,s=s||0,y=0,g=s,E,M=t.length;do{if(g>=M)throw Zt.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>=mf);return Zt.bytes=g-s,i}x(Zt,"read");var wf=Math.pow(2,7),Kf=Math.pow(2,14),Ef=Math.pow(2,21),Uf=Math.pow(2,28),Sf=Math.pow(2,35),vf=Math.pow(2,42),_f=Math.pow(2,49),Cf=Math.pow(2,56),Pf=Math.pow(2,63),Bf=x(function(t){return t<wf?1:t<Kf?2:t<Ef?3:t<Uf?4:t<Sf?5:t<vf?6:t<_f?7:t<Cf?8:t<Pf?9:10},"length"),Tf={encode:df,decode:Af,encodingLength:Bf},Df=Tf,De=Df;function Ie(t,e=0){return[De.decode(t,e),De.decode.bytes]}x(Ie,"decode");function ge(t,e,i=0){return De.encode(t,e,i),e}x(ge,"encodeTo");function le(t){return De.encodingLength(t)}x(le,"encodingLength");function fe(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(fe,"create");function kn(t){let e=Xr(t),[i,s]=Ie(e),[y,g]=Ie(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,If="identity",Zn=Xr;function Mf(t){return fe($n,Zn(t))}x(Mf,"digest");var Lf={code:$n,name:If,encode:Zn,digest:Mf};var rn={};Er(rn,{sha256:()=>Nf,sha512:()=>Rf});function Qt({name:t,code:e,encode:i}){return new Jt(t,e,i)}x(Qt,"from");var Jt=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?fe(this.code,i):i.then(s=>fe(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 Nf=Qt({name:"sha2-256",code:18,encode:Jn("SHA-256")}),Rf=Qt({name:"sha2-512",code:19,encode:Jn("SHA-512")});function Qn(t,e){let{bytes:i,version:s}=t;switch(s){case 0:return Of(i,en(t),e??Or.encoder);default:return Yf(i,en(t),e??de.encoder)}}x(Qn,"format");var ri=new WeakMap;function en(t){let e=ri.get(t);if(e==null){let i=new Map;return ri.set(t,i),i}return e}x(en,"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!==Le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(i.code!==Hf)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=fe(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[jf]===!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!==Le)throw new Error(`Version 0 CID must use dag-pb (code: ${Le}) 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,Le,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,Ir]=Ie(e.subarray(i));return i+=Ir,lr},"next"),y=s(),g=Le;if(y===18?(y=0,i=0):g=s(),y!==0&&y!==1)throw new RangeError(`Invalid CID version ${y}`);let E=i,M=s(),er=s(),fr=i+er,ir=fr-E;return{version:y,codec:g,multihashCode:M,digestSize:er,multihashSize:ir,size:fr}}static parse(e,i){let[s,y]=zf(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 en(g).set(s,e),g}};function zf(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 Te.prefix:{let i=e??Te;return[Te.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(zf,"parseCIDtoBytes");function Of(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(Of,"toStringV0");function Yf(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(Yf,"toStringV1");var Le=112,Hf=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 jf=Symbol.for("@ipld/js-cid/CID");var tn={...$t,...jt,...Wt,...Yt,...Ht,...Gt,...Vt,...Xt,...kt,...Ft},Ia={...rn,...qt};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))),nn=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=Be(t.length);for(let i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return e}),Ff={utf8:ti,"utf-8":ti,hex:tn.base16,latin1:nn,ascii:nn,binary:nn,...tn},tt=Ff;function _r(t,e="utf8"){let i=tt[e];if(i==null)throw new Error(`Unsupported encoding "${e}"`);return i.decoder.decode(`${i.prefix}${t}`)}x(_r,"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 pi={};Er(pi,{AES:()=>ur,decryptBytes:()=>ui,importAesKey:()=>Ee});var Ae="did:key:z",me="Ed25519",fn="X25519",Gf="X25519",on="Ed25519",an="X25519",ii={sign:["sign","verify"],encrypt:["deriveKey","deriveBits"]},Jr="RSA-OAEP",Qr="RSASSA-PKCS1-v1_5",nt="SHA-256",it=new Uint8Array([0,245,2]),ft=2048,oe="SHA-256",Yr=8,Hr="AES-GCM",jr=Hr,Fr=256,Rr=12,ot=new Uint8Array([234,1]),at=new Uint8Array([237,1]),Ne={RSA:"rsa",Edwards:"ed25519",BLS:"bls12-381"},st="rsa-exchange-key",ct="rsa-write-key",Re="ecc-exchange",ze="ecc-write",zr=16;var fi=new Error("Invalid key use. Please use 'encryption' or 'signing"),Vf=new Error("Max must be less than 256 and greater than 0");function Pr(t){return new Uint8Array(t).buffer}x(Pr,"toArrayBuffer");async function oi(t){return new Uint8Array(await k.subtle.digest("sha-256",t.buffer))}x(oi,"sha256");function Dr(t){let e=_r(t,"base64pad");return Pr(e)}x(Dr,"base64ToArrBuf");var ae=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 yt(t){return ae(t,Dr)}x(yt,"normalizeBase64ToBuf");var Xf=x(t=>ae(t,e=>ai(e,8)),"normalizeUtf8ToBuf");function ai(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(ai,"strToArrBuf");var kf=x(t=>ae(t,e=>ai(e,16)),"normalizeUtf16ToBuf");function re(t,e){switch(e){case 8:return Xf(t);default:return kf(t)}}x(re,"normalizeUnicodeToBuf");function xt(t){if(!t.startsWith(Ae))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let e=""+t.substring(Ae.length),i=_r(e,"base58btc"),{keyBuffer:s,type:y}=Wf(Pr(i));return{publicKey:new Uint8Array(s),type:y}}x(xt,"didToPublicKey");function Wf(t){if(sn(t,Pr(it)))return{keyBuffer:t.slice(it.byteLength),type:Ne.RSA};if(sn(t,Pr(at)))return{keyBuffer:t.slice(at.byteLength),type:Ne.Edwards};if(sn(t,Pr(ot)))return{keyBuffer:t.slice(ot.byteLength),type:Ne.BLS};throw new Error("Unsupported key algorithm. Try using RSA.")}x(Wf,"parseMagicBytes");var $f={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 $f.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 Oe(t,e){let i=typeof t=="string"?Dr(t):Pr(t);return k.subtle.importKey("raw",i,{name:e?.alg||jr,length:e?.length||Fr},!0,["encrypt","decrypt"])}x(Oe,"importKey");function ut(t,{max:e}={max:255}){if(e<1||e>255)throw Vf;let i=new Uint8Array(t);if(e===255)return k.getRandomValues(i),i.buffer;let s=0,y=e+1,g=Math.floor(256/y)*y,E=new Uint8Array(1);for(;s<i.length;)k.getRandomValues(E),E[0]<g&&(i[s]=E[0]%y,s++);return i.buffer}x(ut,"randomBuf");function kr(t,e){let i=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(Pr(t)),s=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(Pr(e)),y=new Uint8Array(i.length+s.length);return y.set(i),y.set(s,i.length),y.buffer}x(kr,"joinBufs");async function cn(t,e,i,s){let y=s||!1;if(!Object.values(ie).includes(i))throw new Error("invalid key use");let g=i==="exchange"?Jr:Qr,E=i==="exchange"?["encrypt","decrypt"]:["sign","verify"];return k.subtle.generateKey({name:g,modulusLength:t,publicExponent:Zf(),hash:{name:e}},y,E)}x(cn,"makeRSAKeypair");function Zf(){return new Uint8Array([1,0,1])}x(Zf,"publicExponent");var xi=Ii(ci(),1);async function qf({message:t,publicKey:e,signature:i}){return xi.default.sign.detached.verify(t,i,e)}x(qf,"ed25519Verify");var yi={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:x(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:Jf},ed25519:{magicBytes:new Uint8Array([237,1]),verify:qf}}};async function Jf({message:t,publicKey:e,signature:i}){return Wr.verify(t,i,await k.subtle.importKey("spki",Pr(e),{name:Qr,hash:nt},!1,["verify"]),8)}x(Jf,"rsaVerify");var Wr={verify:x(async function(e,i,s,y=Yr,g=oe){return k.subtle.verify({name:Qr,saltLength:zr},typeof s=="string"?await Ye(s,g,"signing"):s,yt(i),re(e,y))},"rsaVerify"),sign:x(async function(e,i,s=Yr){return k.subtle.sign({name:Qr,saltLength:zr},i,re(e,s))},"sign"),encrypt:x(async function(e,i,s=Yr,y=oe){let g;return typeof i=="string"?g=await Ye(i,y,"exchange"):g=i instanceof Uint8Array?await Ye(Pr(i),y,"exchange"):i,k.subtle.encrypt({name:Jr},g,re(e,s))},"rsaEncrypt"),decrypt:x(async function(e,i){let s=we(i)?i:await to(i,["decrypt"]),y;typeof e=="string"?y=_r(e,"base64pad"):y=e;let g=await k.subtle.decrypt({name:Jr},s,y instanceof Uint8Array?Pr(y):y);return new Uint8Array(g)},"rsaDecrypt")};async function Ye(t,e,i){Qf(i);let s=i==="exchange"?Jr:Qr,y=i==="exchange"?["encrypt"]:["verify"],g=typeof t=="string"?Dr(eo(t)):t;return k.subtle.importKey("spki",g,{name:s,hash:{name:e}},!0,y)}x(Ye,"importPublicKey");function Qf(t){ro(t,["signing","exchange"],fi)}x(Qf,"checkValidKeyUse");function ro(t,e,i){if(!e.some(y=>y===t))throw i}x(ro,"checkValid");function eo(t){return t.replace(`-----BEGIN PUBLIC KEY-----
|
|
2
2
|
`,"").replace(`
|
|
3
|
-
-----END PUBLIC KEY-----`,"")}x(Zf,"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 qf=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 Jf=x(t=>oe(t,e=>yi(e,16)),"normalizeUtf16ToBuf");function fe(t,e){switch(e){case 8:return qf(t);default:return Jf(t)}}x(fe,"normalizeUnicodeToBuf");function Qf(t,e){return W.subtle.importKey("spki",t instanceof Uint8Array?Tr(t):t,{name:te,hash:it},!1,e)}x(Qf,"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}=ro(Tr(i));return{publicKey:new Uint8Array(s),type:y}}x(xt,"didToPublicKey");function ro(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(ro,"parseMagicBytes");var eo={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 eo.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 kf;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:to(),hash:{name:e}},!1,y)}x(xn,"makeRSAKeypair");function to(){return new Uint8Array([1,0,1])}x(to,"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:no,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 xi(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 no(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 io(t,y);return i&&i==="arraybuffer"?g:new Uint8Array(g)}x(no,"encrypt");async function io(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(io,"encryptBytes");async function xi(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(xi,"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 pi(t,e=pn()){return e("readwrite",i=>(t.forEach(s=>i.delete(s)),pt(i.transaction)))}x(pi,"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 pi([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 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 gn({key:y,publicKey:s});return $r(E,g)}x(hi,"encryptTo");hi.asString=async function(t,e){let i=await hi(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 di(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(di,"encryptTo");di.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 bi={};Er(bi,{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 li(t){xo(t,["exchange","write","signing"],yo)}x(li,"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){li(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(eo,"stripKeyHeader");function we(t){return yn(t,"algorithm")&&yn(t,"extractable")&&yn(t,"type")}x(we,"isCryptoKey");function yn(t,e){return typeof t=="object"&&t!=null&&e in t}x(yn,"hasProp");function to(t,e){return k.subtle.importKey("spki",t instanceof Uint8Array?Pr(t):t,{name:Jr,hash:nt},!1,e)}x(to,"importRsaKey");async function He(t,e="rsa"){let i=t instanceof CryptoKey?new Uint8Array(await $r(t)):t,s=yi.keyTypes[e]?.magicBytes;if(!s)throw new Error(`Key type '${e}' not supported, available types: ${Object.keys(yi.keyTypes).join(", ")}`);let y=Lt([s,i]);return Ae+nr(y,"base58btc")}x(He,"publicKeyToDid");async function $r(t){return t instanceof CryptoKey?await k.subtle.exportKey("spki",t):await k.subtle.exportKey("spki",t.publicKey)}x($r,"getPublicKeyAsArrayBuffer");async function xn(t){let e=await $r(t);return new Uint8Array(e)}x(xn,"getPublicKeyAsUint8Array");function Ke(t){return new Uint8Array(t).buffer}x(Ke,"toArrayBuffer");var ur={create(t={alg:jr,length:Fr}){let e=t.length||Fr,i=t.alg||jr;return k.subtle.generateKey({name:i,length:e},!0,["encrypt","decrypt"])},export:Object.assign(async t=>{let e=await k.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 Ee(typeof t=="string"?Dr(t):t)},async exportAsString(t){let e=await ur.export(t);return Ur(e)},encrypt:no,async decrypt(t,e,i){let s=we(e)?e:await Ee(e),y=i?await k.subtle.decrypt({name:Hr,iv:Ke(i)},s,typeof t=="string"?Ke(_r(t)):t instanceof Uint8Array?Ke(t):t):await ui(t,s);return new Uint8Array(y)}};function Ee(t,e){return k.subtle.importKey("raw",t instanceof Uint8Array?Ke(t):t,{name:Hr,length:e||256},!0,["encrypt","decrypt"])}x(Ee,"importAesKey");async function no(t,e,i,s){let y=we(e)?e:await Ee(e),g=s?await k.subtle.encrypt({name:Hr,iv:Ke(s)},y,Ke(t)):await io(t,y);return i&&i==="arraybuffer"?g:new Uint8Array(g)}x(no,"encrypt");async function io(t,e,i){let s=re(t,i?.charsize??Yr),y=typeof e=="string"?await Oe(e,i):e,g=i?.iv||ut(Rr),E=await k.subtle.encrypt({name:Hr,iv:g},y,s);return kr(g,E)}x(io,"encryptBytes");async function ui(t,e,i){let s=yt(t),y=typeof e=="string"?await Oe(e,i):e,g=s.slice(0,Rr),E=s.slice(Rr);return await k.subtle.decrypt({name:jr,iv:g},y,E)}x(ui,"decryptBytes");function ht(t){return new Promise((e,i)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>i(t.error)})}x(ht,"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=ht(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=>ht(i.get(t)))}x(hn,"get");function dn(t,e,i=pn()){return i("readwrite",s=>(s.put(e,t),ht(s.transaction)))}x(dn,"set");function hi(t,e=pn()){return e("readwrite",i=>(t.forEach(s=>i.delete(s)),ht(i.transaction)))}x(hi,"delMany");var Ue=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 $r(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 $r(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 hi([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 $r(s),g=await He(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 $r(y),E=await He(new Uint8Array(g),this.TYPE==="ecc"?"ed25519":"rsa"),M=new this({keys:{exchange:s,write:y},did:E,hasPersisted:i,isSessionOnly:!!e.session});return this._instance=M,M}};async function di(t,e){let{content:i,publicKey:s}=t,y=e||await ur.create(),g=await ur.encrypt(typeof i=="string"?_r(i):i,typeof y=="string"?await ur.import(y):y),E=await gn({key:y,publicKey:s});return kr(E,g)}x(di,"encryptTo");di.asString=async function(t,e){let i=await di(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 Wr.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 oi(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 se=class t extends Ue{static{x(this,"RsaKeys")}static TYPE="rsa";static INFO="keys";static EXCHANGE_KEY_NAME=st;static WRITE_KEY_NAME=ct;constructor(e){super(e),t.EXCHANGE_KEY_NAME=e.exchangeKeyName||st,t.WRITE_KEY_NAME=e.writeKeyName||ct}static async _createExchangeKeys(){return await cn(ft,oe,"exchange")}static async _createWriteKeys(){return await cn(ft,oe,"write")}async toJson(e){let i=this.publicExchangeKey,s=this.DID,y=await k.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 Wr.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,M=s,er=y,fr=M||await ur.create({length:er||g}),ir=await ur.encrypt(typeof e=="string"?_r(e):e,typeof fr=="string"?await ur.import(fr):fr),lr=await Se({key:fr,publicKey:E}),Ir=kr(lr,ir);return new Uint8Array(Ir)}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=ae(e,Dr),E=g.slice(0,y),M=g.slice(y),er=await this.decryptKey(E);return await ur.decrypt(M,er)}async decryptAsString(e,i,s){let y=await this.decrypt(e,i,s);return nr(y)}async decryptKey(e){return await Wr.decrypt(e,this.exchangeKey.privateKey)}async decryptKeyAsString(e,i){let s=await Wr.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(se.prototype.sign,{asString:x(async function(t,e){return this.signAsString(t,e)},"asString")});Object.assign(se.prototype.encrypt,{asString:x(async function(t,e,i,s){return this.encryptAsString(t,e,i,s)},"asString")});Object.assign(se.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 Ye(ln(s.publicKey),"SHA-256","signing");try{return Wr.verify(t,e,y)}catch{return!1}}x(ao,"verify");Object.assign(se.prototype.decryptKey,{asString:x(async function(t,e){return this.decryptKeyAsString(t,e)},"asString")});async function gi(t,e){let{content:i,publicKey:s}=t,y=e||await ur.create(),g=await ur.encrypt(typeof i=="string"?_r(i):i,typeof y=="string"?await ur.import(y):y),E=await Se({key:y,publicKey:s});return kr(E,g)}x(gi,"encryptTo");gi.asString=async function(t,e){let{content:i,publicKey:s}=t,y=e||await ur.create(),g=await ur.encrypt(typeof i=="string"?_r(i):i,typeof y=="string"?await ur.import(y):y,"arraybuffer"),E=await Se({key:y,publicKey:s}),M=kr(E,g);return nr(new Uint8Array(M),"base64pad")};async function Se({key:t,publicKey:e},i){let s;t instanceof CryptoKey?s=await ur.export(t):s=t;let y=await Wr.encrypt(s,e);return i&&i==="arraybuffer"?y:new Uint8Array(y)}x(Se,"encryptKeyTo");Se.asString=async function({key:t,publicKey:e},i){let s=await Se({key:t,publicKey:e});return i?nr(s,i):Ur(s)};async function so(t,e,i,s){let y=we(e)?e:await Ee(e),g=s?await k.subtle.encrypt({name:Hr,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=re(t,i?.charsize??Yr),y=typeof e=="string"?await Oe(e,i):e,g=i?.iv||ut(Rr),E=await k.subtle.encrypt({name:Hr,iv:g},y,s);return kr(g,E)}x(co,"encryptBytes");var Ai={};Er(Ai,{EccKeys:()=>ee,default:()=>uo,exportPublicKey:()=>gt,importPublicKey:()=>je,verify:()=>po});var Zs=new Error("Key does not exist. Make sure you properly instantiated the keystore."),qs=new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name."),Js=new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name."),Qs=new Error("ECC is not enabled for this browser. Please use RSA instead."),rc=new Error("Cryptosystem not supported. Please use ECC or RSA"),yo=new Error("Invalid key use. Please use 'exchange' or 'write'"),ec=new Error("Max must be less than 256 and greater than 0");function bi(t){xo(t,["exchange","write","signing"],yo)}x(bi,"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 ee=class t extends Ue{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 gt(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 gt(this.writeKey),y=new Uint8Array(s);return i?nr(y,i):Ur(s)},"asString")})}static async _createExchangeKeys(){return await k.subtle.generateKey({name:an},!1,["deriveKey","deriveBits"])}static async _createWriteKeys(){return await k.subtle.generateKey({name:on},!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 gt(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,M=crypto.getRandomValues(new Uint8Array(zr)),er=i||this.exchangeKey.publicKey,fr;typeof er=="string"?fr=await je(er,"X25519","exchange"):fr=er;let ir=y||await dt(this.exchangeKey.privateKey,fr,M,s||t.INFO,g);ir instanceof CryptoKey||(ir=await dt(this.exchangeKey.privateKey,fr,M,s||t.INFO));let lr=crypto.getRandomValues(new Uint8Array(Rr)),Ir=typeof e=="string"?E.encode(e):e,ce=await crypto.subtle.encrypt({name:jr,iv:lr},ir,Fe(Ir)),$=new Uint8Array(M),yr=new Uint8Array(lr),Sr=new Uint8Array(ce),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 je(i,"X25519","write"):i;g||(g=this.publicExchangeKey);let E=ae(e,Dr),M=E.slice(0,zr),er=E.slice(zr,zr+Rr),fr=E.slice(zr+Rr),{privateKey:ir}=this.exchangeKey,lr=await dt(ir,g,M,y||t.INFO);return await crypto.subtle.decrypt({name:s||jr,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 je(e,"X25519","exchange"):s=e;let y=crypto.getRandomValues(new Uint8Array(zr));return await dt(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 k.subtle.sign({name:me},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(ee.prototype.sign,{asString:x(async function(t,e){let i=await this.sign(t,e);return nr(i,"base64pad")},"asString")});async function gt(t){return await k.subtle.exportKey("raw",t.publicKey)}x(gt,"exportPublicKey");async function je(t,e,i){bi(i);let s=i==="exchange"?fn:me,y=i==="exchange"?[]:["verify"],g=Dr(t),E=e==="X25519"?{name:s}:{name:s,namedCurve:e};return k.subtle.importKey("raw",g,E,!0,y)}x(je,"importPublicKey");var uo={EccKeys:ee,importPublicKey:je};Object.assign(ee.prototype.encrypt,{asString:x(async function(t,e,i,s,y){return this.encryptAsString(t,e,i,s,y)},"asString")});Object.assign(ee.prototype.decrypt,{asString:x(async function(t,e,i){return this.decryptAsString(t,e,i)},"asString")});Object.assign(ee.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 k.subtle.importKey("raw",y,{name:me},!0,["verify"]),E=new TextEncoder,M;typeof t=="string"?M=E.encode(t):t instanceof ArrayBuffer?M=new Uint8Array(t):M=t;let er;return typeof e=="string"?er=new Uint8Array(Dr(e)):er=e,await k.subtle.verify({name:me},g,Fe(er),Fe(M))}catch{return!1}}x(po,"verify");async function dt(t,e,i,s,y){let g=new TextEncoder,E=await crypto.subtle.deriveBits({name:"X25519",public:e},t,256),M=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)},M,{name:"AES-GCM",length:y||Fr},!1,["encrypt","decrypt"])}x(dt,"deriveKey");})();
|