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