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