@smartledger/keys 2.0.0 → 3.0.0
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/LICENSE +23 -23
- package/README.md +548 -548
- package/dist/lumen-keys.js +3748 -2564
- package/dist/lumen-keys.js.map +4 -4
- package/dist/lumen-keys.min.js +8 -31
- package/dist/lumen-keys.min.js.map +4 -4
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +79 -76
package/dist/lumen-keys.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var LumenKeys=(()=>{var sn=Object.defineProperty;var e0=Object.getOwnPropertyDescriptor;var t0=Object.getOwnPropertyNames;var r0=Object.prototype.hasOwnProperty;var n0=(t,e,r)=>e in t?sn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pe=(t,e)=>()=>(t&&(e=t(t=0)),e);var oo=(t,e)=>{for(var r in e)sn(t,r,{get:e[r],enumerable:!0})},o0=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of t0(e))!r0.call(t,o)&&o!==r&&sn(t,o,{get:()=>e[o],enumerable:!(n=e0(e,o))||n.enumerable});return t};var s0=t=>o0(sn({},"__esModule",{value:!0}),t);var d=(t,e,r)=>n0(t,typeof e!="symbol"?e+"":e,r);var m=pe(()=>{"use strict";if(typeof Uint8Array.prototype.toString!="function"||!Uint8Array.prototype.toString.toString().includes("[native code]")){let t=Uint8Array.prototype.toString;Uint8Array.prototype.toString=function(e){if(e==="base64"){let r="",n=new Uint8Array(this);for(let o=0;o<n.byteLength;o++)r+=String.fromCharCode(n[o]);return btoa(r)}return t.call(this)}}typeof window>"u"&&(window.global=window)});function S0(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function vr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Xe(t,...e){if(!S0(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function bi(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");vr(t.outputLen),vr(t.blockLen)}function Je(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ln(t,e){Xe(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function gi(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function ke(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function dn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ie(t,e){return t<<32-e|t>>>e}function H0(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function I0(t){for(let e=0;e<t.length;e++)t[e]=H0(t[e]);return t}function L0(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Kt(t){return typeof t=="string"&&(t=L0(t)),Xe(t),t}function Br(t){let e=n=>t().update(Kt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}var k0,lo,at,Sr=pe(()=>{m();k0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;lo=k0?t=>t:I0;at=class{}});function U0(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),c=Number(r&s),a=n?4:0,u=n?0:4;t.setUint32(e+a,i,n),t.setUint32(e+u,c,n)}function mi(t,e,r){return t&e^~t&r}function wi(t,e,r){return t&e^t&r^e&r}var kr,Qe,fe,Ei=pe(()=>{m();Sr();kr=class extends at{constructor(e,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=dn(this.buffer)}update(e){Je(this),e=Kt(e),Xe(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=dn(e);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(e.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Je(this),ln(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,ke(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;U0(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=dn(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)c.setUint32(4*f,l[f],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Qe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fe=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function _0(t,e=!1){return e?{h:Number(t&pn),l:Number(t>>Ai&pn)}:{h:Number(t>>Ai&pn)|0,l:Number(t&pn)|0}}function xn(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=_0(t[s],e);[n[s],o[s]]=[i,c]}return[n,o]}function Ve(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var pn,Ai,po,xo,Ct,Ot,Hr,Ir,vi,Bi,Si,ki,Hi,Ii,Li,Ui,_i,Ki,yo=pe(()=>{m();pn=BigInt(4294967295),Ai=BigInt(32);po=(t,e,r)=>t>>>r,xo=(t,e,r)=>t<<32-r|e>>>r,Ct=(t,e,r)=>t>>>r|e<<32-r,Ot=(t,e,r)=>t<<32-r|e>>>r,Hr=(t,e,r)=>t<<64-r|e>>>r-32,Ir=(t,e,r)=>t>>>r-32|e<<64-r,vi=(t,e,r)=>t<<r|e>>>32-r,Bi=(t,e,r)=>e<<r|t>>>32-r,Si=(t,e,r)=>e<<r-32|t>>>64-r,ki=(t,e,r)=>t<<r-32|e>>>64-r;Hi=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Ii=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Li=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Ui=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,_i=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ki=(t,e,r,n,o,s)=>e+r+n+o+s+(t/2**32|0)|0});var C0,ft,yn,Ci,O0,R0,ut,lt,bo,bn,Oi,go=pe(()=>{m();Ei();yo();Sr();C0=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ft=new Uint32Array(64),yn=class extends kr{constructor(e=32){super(64,e,8,!1),this.A=Qe[0]|0,this.B=Qe[1]|0,this.C=Qe[2]|0,this.D=Qe[3]|0,this.E=Qe[4]|0,this.F=Qe[5]|0,this.G=Qe[6]|0,this.H=Qe[7]|0}get(){let{A:e,B:r,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[e,r,n,o,s,i,c,a]}set(e,r,n,o,s,i,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(e,r){for(let f=0;f<16;f++,r+=4)ft[f]=e.getUint32(r,!1);for(let f=16;f<64;f++){let h=ft[f-15],p=ft[f-2],x=Ie(h,7)^Ie(h,18)^h>>>3,w=Ie(p,17)^Ie(p,19)^p>>>10;ft[f]=w+ft[f-7]+x+ft[f-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:u,H:l}=this;for(let f=0;f<64;f++){let h=Ie(c,6)^Ie(c,11)^Ie(c,25),p=l+h+mi(c,a,u)+C0[f]+ft[f]|0,w=(Ie(n,2)^Ie(n,13)^Ie(n,22))+wi(n,o,s)|0;l=u,u=a,a=c,c=i+p|0,i=s,s=o,o=n,n=p+w|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,s,i,c,a,u,l)}roundClean(){ke(ft)}destroy(){this.set(0,0,0,0,0,0,0,0),ke(this.buffer)}},Ci=xn(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),O0=Ci[0],R0=Ci[1],ut=new Uint32Array(80),lt=new Uint32Array(80),bo=class extends kr{constructor(e=64){super(128,e,16,!1),this.Ah=fe[0]|0,this.Al=fe[1]|0,this.Bh=fe[2]|0,this.Bl=fe[3]|0,this.Ch=fe[4]|0,this.Cl=fe[5]|0,this.Dh=fe[6]|0,this.Dl=fe[7]|0,this.Eh=fe[8]|0,this.El=fe[9]|0,this.Fh=fe[10]|0,this.Fl=fe[11]|0,this.Gh=fe[12]|0,this.Gl=fe[13]|0,this.Hh=fe[14]|0,this.Hl=fe[15]|0}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:u,El:l,Fh:f,Fl:h,Gh:p,Gl:x,Hh:w,Hl:v}=this;return[e,r,n,o,s,i,c,a,u,l,f,h,p,x,w,v]}set(e,r,n,o,s,i,c,a,u,l,f,h,p,x,w,v){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=h|0,this.Gh=p|0,this.Gl=x|0,this.Hh=w|0,this.Hl=v|0}process(e,r){for(let y=0;y<16;y++,r+=4)ut[y]=e.getUint32(r),lt[y]=e.getUint32(r+=4);for(let y=16;y<80;y++){let L=ut[y-15]|0,P=lt[y-15]|0,F=Ct(L,P,1)^Ct(L,P,8)^po(L,P,7),X=Ot(L,P,1)^Ot(L,P,8)^xo(L,P,7),M=ut[y-2]|0,U=lt[y-2]|0,Y=Ct(M,U,19)^Hr(M,U,61)^po(M,U,6),ee=Ot(M,U,19)^Ir(M,U,61)^xo(M,U,6),$=Li(X,ee,lt[y-7],lt[y-16]),j=Ui($,F,Y,ut[y-7],ut[y-16]);ut[y]=j|0,lt[y]=$|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:u,Dl:l,Eh:f,El:h,Fh:p,Fl:x,Gh:w,Gl:v,Hh:I,Hl:B}=this;for(let y=0;y<80;y++){let L=Ct(f,h,14)^Ct(f,h,18)^Hr(f,h,41),P=Ot(f,h,14)^Ot(f,h,18)^Ir(f,h,41),F=f&p^~f&w,X=h&x^~h&v,M=_i(B,P,X,R0[y],lt[y]),U=Ki(M,I,L,F,O0[y],ut[y]),Y=M|0,ee=Ct(n,o,28)^Hr(n,o,34)^Hr(n,o,39),$=Ot(n,o,28)^Ir(n,o,34)^Ir(n,o,39),j=n&s^n&c^s&c,g=o&i^o&a^i&a;I=w|0,B=v|0,w=p|0,v=x|0,p=f|0,x=h|0,{h:f,l:h}=Ve(u|0,l|0,U|0,Y|0),u=c|0,l=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let b=Hi(Y,$,g);n=Ii(b,U,ee,j),o=b|0}({h:n,l:o}=Ve(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Ve(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=Ve(this.Ch|0,this.Cl|0,c|0,a|0),{h:u,l}=Ve(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:h}=Ve(this.Eh|0,this.El|0,f|0,h|0),{h:p,l:x}=Ve(this.Fh|0,this.Fl|0,p|0,x|0),{h:w,l:v}=Ve(this.Gh|0,this.Gl|0,w|0,v|0),{h:I,l:B}=Ve(this.Hh|0,this.Hl|0,I|0,B|0),this.set(n,o,s,i,c,a,u,l,f,h,p,x,w,v,I,B)}roundClean(){ke(ut,lt)}destroy(){ke(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},bn=Br(()=>new yn),Oi=Br(()=>new bo)});function j0(t,e=24){let r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let i=0;i<10;i++)r[i]=t[i]^t[i+10]^t[i+20]^t[i+30]^t[i+40];for(let i=0;i<10;i+=2){let c=(i+8)%10,a=(i+2)%10,u=r[a],l=r[a+1],f=Ri(u,l,1)^r[c],h=Ti(u,l,1)^r[c+1];for(let p=0;p<50;p+=10)t[i+p]^=f,t[i+p+1]^=h}let o=t[2],s=t[3];for(let i=0;i<24;i++){let c=Mi[i],a=Ri(o,s,c),u=Ti(o,s,c),l=Di[i];o=t[l],s=t[l+1],t[l]=a,t[l+1]=u}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)r[c]=t[i+c];for(let c=0;c<10;c++)t[i+c]^=~r[(c+2)%10]&r[(c+4)%10]}t[0]^=V0[n],t[1]^=$0[n]}ke(r)}var T0,Lr,D0,M0,N0,P0,Di,Mi,Ni,Pi,V0,$0,Ri,Ti,mo,q0,Vi,$i=pe(()=>{m();yo();Sr();T0=BigInt(0),Lr=BigInt(1),D0=BigInt(2),M0=BigInt(7),N0=BigInt(256),P0=BigInt(113),Di=[],Mi=[],Ni=[];for(let t=0,e=Lr,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],Di.push(2*(5*n+r)),Mi.push((t+1)*(t+2)/2%64);let o=T0;for(let s=0;s<7;s++)e=(e<<Lr^(e>>M0)*P0)%N0,e&D0&&(o^=Lr<<(Lr<<BigInt(s))-Lr);Ni.push(o)}Pi=xn(Ni,!0),V0=Pi[0],$0=Pi[1],Ri=(t,e,r)=>r>32?Si(t,e,r):vi(t,e,r),Ti=(t,e,r)=>r>32?ki(t,e,r):Bi(t,e,r);mo=class t extends at{constructor(e,r,n,o=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=o,this.rounds=s,vr(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=gi(this.state)}clone(){return this._cloneInto()}keccak(){lo(this.state32),j0(this.state32,this.rounds),lo(this.state32),this.posOut=0,this.pos=0}update(e){Je(this),e=Kt(e),Xe(e);let{blockLen:r,state:n}=this,o=e.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let c=0;c<i;c++)n[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:r,pos:n,blockLen:o}=this;e[n]^=r,r&128&&n===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){Je(this,!1),Xe(e),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=e.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);e.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return vr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ln(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ke(this.state)}_cloneInto(e){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return e||(e=new t(r,n,o,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}},q0=(t,e,r)=>Br(()=>new mo(e,t,r)),Vi=q0(6,136,256/8)});var gn={};oo(gn,{createHash:()=>ji,default:()=>G0});function ji(t){let e=new Uint8Array(0),r;switch(t.toLowerCase()){case"sha256":case"sha-256":r=bn;break;case"sha512":case"sha-512":r=Oi;break;case"sha3-256":r=Vi;break;default:throw new Error(`Unsupported hash algorithm: ${t}`)}return{update(n){let o=n instanceof Uint8Array?n:new Uint8Array(n),s=new Uint8Array(e.length+o.length);return s.set(e),s.set(o,e.length),e=s,this},digest(){return r(e)}}}var G0,mn=pe(()=>{"use strict";m();go();$i();G0={createHash:ji}});function _r(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function $e(t,e=""){if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function Q(t,e,r=""){let n=_r(t),o=t?.length,s=e!==void 0;if(!n||s&&o!==e){let i=r&&`"${r}" `,c=s?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+c+", got "+a)}return t}function En(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash must wrapped by utils.createHasher");$e(t.outputLen),$e(t.blockLen)}function nr(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Gi(t,e){Q(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Tt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function An(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Le(t,e){return t<<32-e|t>>>e}function Dt(t){if(Q(t),Fi)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=F0[t[r]];return e}function qi(t){if(t>=et._0&&t<=et._9)return t-et._0;if(t>=et.A&&t<=et.F)return t-(et.A-10);if(t>=et.a&&t<=et.f)return t-(et.a-10)}function Mt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Fi)return Uint8Array.fromHex(t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=qi(t.charCodeAt(s)),c=qi(t.charCodeAt(s+1));if(i===void 0||c===void 0){let a=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Ue(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];Q(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let s=t[n];r.set(s,o),o+=s.length}return r}function Wi(t,e={}){let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function vn(t=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}var Fi,F0,et,zi,Nt=pe(()=>{m();Fi=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",F0=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));et={_0:48,_9:57,A:65,F:70,a:97,f:102};zi=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])})});function Pt(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function Ji(t){if(typeof t=="bigint"){if(!Sn(t))throw new Error("positive bigint expected, got "+t)}else $e(t);return t}function Kr(t){let e=Ji(t).toString(16);return e.length&1?"0"+e:e}function Qi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?vo:BigInt("0x"+t)}function or(t){return Qi(Dt(t))}function Bo(t){return Qi(Dt(z0(Q(t)).reverse()))}function kn(t,e){$e(e),t=Ji(t);let r=Mt(t.toString(16).padStart(e*2,"0"));if(r.length!==e)throw new Error("number too large");return r}function So(t,e){return kn(t,e).reverse()}function z0(t){return Uint8Array.from(t)}function Z0(t,e,r){return Sn(t)&&Sn(e)&&Sn(r)&&e<=t&&t<r}function ec(t,e,r,n){if(!Z0(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function ko(t){let e;for(e=0;t>vo;t>>=Ao,e+=1);return e}function tc(t,e,r){if($e(t,"hashLen"),$e(e,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=v=>new Uint8Array(v),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,a=n(t),u=n(t),l=0,f=()=>{a.fill(1),u.fill(0),l=0},h=(...v)=>r(u,Ue(a,...v)),p=(v=o)=>{u=h(s,v),a=h(),v.length!==0&&(u=h(i,v),a=h())},x=()=>{if(l++>=c)throw new Error("drbg: tried max amount of iterations");let v=0,I=[];for(;v<e;){a=h();let B=a.slice();I.push(B),v+=a.length}return Ue(...I)};return(v,I)=>{f(),p(v);let B;for(;!(B=I(x()));)p();return f(),B}}function Or(t,e={},r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(s,i,c){let a=t[s];if(c&&a===void 0)return;let u=typeof a;if(u!==i||a===null)throw new Error(`param "${s}" is invalid: expected ${i}, got ${u}`)}let o=(s,i)=>Object.entries(s).forEach(([c,a])=>n(c,a,i));o(e,!1),o(r,!0)}function Ho(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let s=t(r,...n);return e.set(r,s),s}}var vo,Ao,Sn,Cr,Rr=pe(()=>{m();Nt();Nt();vo=BigInt(0),Ao=BigInt(1);Sn=t=>typeof t=="bigint"&&vo<=t;Cr=t=>(Ao<<BigInt(t))-Ao});function Zf(t,e=!1){return e?{h:Number(t&Gn),l:Number(t>>Aa&Gn)}:{h:Number(t>>Aa&Gn)|0,l:Number(t&Gn)|0}}function va(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=Zf(t[s],e);[n[s],o[s]]=[i,c]}return[n,o]}var Gn,Aa,Ba,Sa,ka,Ha,Ia=pe(()=>{m();Gn=BigInt(4294967295),Aa=BigInt(32);Ba=(t,e,r)=>t<<r|e>>>32-r,Sa=(t,e,r)=>e<<r|t>>>32-r,ka=(t,e,r)=>e<<r-32|t>>>64-r,Ha=(t,e,r)=>t<<r-32|e>>>64-r});function ws(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Es(t,e=""){if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function ie(t,e,r=""){let n=ws(t),o=t?.length,s=e!==void 0;if(!n||s&&o!==e){let i=r&&`"${r}" `,c=s?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+c+", got "+a)}return t}function As(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function La(t,e){ie(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Ua(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function vs(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Xf(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Jf(t){for(let e=0;e<t.length;e++)t[e]=Xf(t[e]);return t}function Ss(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];ie(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let s=t[n];r.set(s,o),o+=s.length}return r}function _a(t,e={}){let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Ka(t=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}var Yf,Bs,ks,Fn=pe(()=>{m();Yf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Bs=Yf?t=>t:Jf;ks=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])})});function iu(t,e=24){let r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let i=0;i<10;i++)r[i]=t[i]^t[i+10]^t[i+20]^t[i+30]^t[i+40];for(let i=0;i<10;i+=2){let c=(i+8)%10,a=(i+2)%10,u=r[a],l=r[a+1],f=Ca(u,l,1)^r[c],h=Oa(u,l,1)^r[c+1];for(let p=0;p<50;p+=10)t[i+p]^=f,t[i+p+1]^=h}let o=t[2],s=t[3];for(let i=0;i<24;i++){let c=Ta[i],a=Ca(o,s,c),u=Oa(o,s,c),l=Ra[i];o=t[l],s=t[l+1],t[l]=a,t[l+1]=u}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)r[c]=t[i+c];for(let c=0;c<10;c++)t[i+c]^=~r[(c+2)%10]&r[(c+4)%10]}t[0]^=ou[n],t[1]^=su[n]}vs(r)}var Qf,zr,eu,tu,ru,nu,Ra,Ta,Da,Ma,ou,su,Ca,Oa,Hs,Na,Pa,be,Is=pe(()=>{m();Ia();Fn();Qf=BigInt(0),zr=BigInt(1),eu=BigInt(2),tu=BigInt(7),ru=BigInt(256),nu=BigInt(113),Ra=[],Ta=[],Da=[];for(let t=0,e=zr,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],Ra.push(2*(5*n+r)),Ta.push((t+1)*(t+2)/2%64);let o=Qf;for(let s=0;s<7;s++)e=(e<<zr^(e>>tu)*nu)%ru,e&eu&&(o^=zr<<(zr<<BigInt(s))-zr);Da.push(o)}Ma=va(Da,!0),ou=Ma[0],su=Ma[1],Ca=(t,e,r)=>r>32?ka(t,e,r):Ba(t,e,r),Oa=(t,e,r)=>r>32?Ha(t,e,r):Sa(t,e,r);Hs=class t{constructor(e,r,n,o=!1,s=24){d(this,"state");d(this,"pos",0);d(this,"posOut",0);d(this,"finished",!1);d(this,"state32");d(this,"destroyed",!1);d(this,"blockLen");d(this,"suffix");d(this,"outputLen");d(this,"enableXOF",!1);d(this,"rounds");if(this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=o,this.rounds=s,Es(n,"outputLen"),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ua(this.state)}clone(){return this._cloneInto()}keccak(){Bs(this.state32),iu(this.state32,this.rounds),Bs(this.state32),this.posOut=0,this.pos=0}update(e){As(this),ie(e);let{blockLen:r,state:n}=this,o=e.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let c=0;c<i;c++)n[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:r,pos:n,blockLen:o}=this;e[n]^=r,r&128&&n===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){As(this,!1),ie(e),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=e.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);e.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Es(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(La(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,vs(this.state)}_cloneInto(e){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return e||(e=new t(r,n,o,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}},Na=(t,e,r,n={})=>_a((o={})=>new Hs(e,t,o.dkLen===void 0?r:o.dkLen,!0),n),Pa=Na(31,168,16,ks(11)),be=Na(31,136,32,ks(12))});function Ls(t){if(!Number.isSafeInteger(t)||t<0||t>4294967295)throw new Error("wrong u32 integer:"+t);return t}function $a(t){return Ls(t),(t&t-1)===0&&t!==0}function Us(t,e){Ls(t);let r=0;for(let n=0;n<e;n++,t>>>=1)r=r<<1|t&1;return r}function ja(t){return Ls(t),31-Math.clz32(t)}function Va(t){let e=t.length;if(e<2||!$a(e))throw new Error("n must be a power of 2 and greater than 1. Got "+e);let r=ja(e);for(let n=0;n<e;n++){let o=Us(n,r);if(n<o){let s=t[n];t[n]=t[o],t[o]=s}}return t}var _s,qa=pe(()=>{m();_s=(t,e)=>{let{N:r,roots:n,dit:o,invertButterflies:s=!1,skipStages:i=0,brp:c=!0}=e,a=ja(r);if(!$a(r))throw new Error("FFT: Polynomial size should be power of two");let u=o!==s;return l=>{if(l.length!==r)throw new Error("FFT: wrong Polynomial length");o&&c&&Va(l);for(let f=0,h=1;f<a-i;f++){let p=o?f+1+i:a-f,x=1<<p,w=x>>1,v=r>>p;for(let I=0;I<r;I+=x)for(let B=0,y=h++;B<w;B++){let L=s?o?r-y:y:B*v,P=I+B,F=I+B+w,X=n[L],M=l[F],U=l[P];if(u){let Y=t.mul(M,X);l[P]=t.add(U,Y),l[F]=t.sub(U,Y)}else s?(l[P]=t.add(M,U),l[F]=t.mul(t.sub(M,U),X)):(l[P]=t.add(U,M),l[F]=t.mul(t.sub(U,M),X))}}return!o&&c&&Va(l),l}}});function Cs(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function Os(t){if(typeof t!="object"||t===null||ws(t))throw new Error("expected opts to be an object")}function Wn(t){Os(t),t.context!==void 0&&ie(t.context,void 0,"opts.context")}function zn(t){Wn(t),t.extraEntropy!==!1&&t.extraEntropy!==void 0&&ie(t.extraEntropy,void 0,"opts.extraEntropy")}function Zr(t,...e){let r=o=>typeof o=="number"?o:o.bytesLen,n=e.reduce((o,s)=>o+r(s),0);return{bytesLen:n,encode:o=>{let s=new Uint8Array(n);for(let i=0,c=0;i<e.length;i++){let a=e[i],u=r(a),l=typeof a=="number"?o[i]:a.encode(o[i]);ie(l,u,t),s.set(l,c),typeof a!="number"&&l.fill(0),c+=u}return s},decode:o=>{ie(o,n,t);let s=[];for(let i of e){let c=r(i),a=o.subarray(0,c);s.push(typeof i=="number"?a:i.decode(a)),o=o.subarray(c)}return s}}}function Zt(t,e){let r=e*t.bytesLen;return{bytesLen:r,encode:n=>{if(n.length!==e)throw new Error(`vecCoder.encode: wrong length=${n.length}. Expected: ${e}`);let o=new Uint8Array(r);for(let s=0,i=0;s<n.length;s++){let c=t.encode(n[s]);o.set(c,i),c.fill(0),i+=c.length}return o},decode:n=>{ie(n,r);let o=[];for(let s=0;s<n.length;s+=t.bytesLen)o.push(t.decode(n.subarray(s,s+t.bytesLen)));return o}}}function Fe(...t){for(let e of t)if(Array.isArray(e))for(let r of e)r.fill(0);else e.fill(0)}function Rs(t){return(1<<t)-1}function Ts(t,e=Ga){if(ie(t),ie(e),e.length>255)throw new Error("context should be less than 255 bytes");return Ss(new Uint8Array([0,e.length]),e,t)}function Fa(t,e=0){if(!t.oid||!Cs(t.oid.subarray(0,10),cu))throw new Error("hash.oid is invalid: expected NIST hash");let r=t.outputLen*8/2;if(e>r)throw new Error("Pre-hash security strength too low: "+r+", required: "+e)}function Ds(t,e,r=Ga){if(ie(e),ie(r),r.length>255)throw new Error("context should be less than 255 bytes");let n=t(e);return Ss(new Uint8Array([1,r.length]),r,t.oid,n)}var Ks,Ga,cu,Ms=pe(()=>{m();Fn();Fn();Ks=Ka;Ga=Uint8Array.of();cu=Uint8Array.from([6,9,96,134,72,1,101,3,4,2])});var Wa,za,Zn,Yn,Za=pe(()=>{m();qa();Is();Ms();Wa=t=>{let{newPoly:e,N:r,Q:n,F:o,ROOT_OF_UNITY:s,brvBits:i,isKyber:c}=t,a=(B,y=n)=>{let L=B%y|0;return(L>=0?L|0:y+L|0)|0},u=(B,y=n)=>{let L=a(B,y)|0;return(L>y>>1?L-y|0:L)|0};function l(){let B=e(r);for(let y=0;y<r;y++){let L=Us(y,i),P=BigInt(s)**BigInt(L)%BigInt(n);B[y]=Number(P)|0}return B}let f=l(),h={add:(B,y)=>a((B|0)+(y|0))|0,sub:(B,y)=>a((B|0)-(y|0))|0,mul:(B,y)=>a((B|0)*(y|0))|0,inv:B=>{throw new Error("not implemented")}},p={N:r,roots:f,invertButterflies:!0,skipStages:c?1:0,brp:!1},x=_s(h,{dit:!1,...p}),w=_s(h,{dit:!0,...p});return{mod:a,smod:u,nttZetas:f,NTT:{encode:B=>x(B),decode:B=>{w(B);for(let y=0;y<B.length;y++)B[y]=a(o*B[y]);return B}},bitsCoder:(B,y)=>{let L=Rs(B),P=B*(r/8);return{bytesLen:P,encode:F=>{let X=new Uint8Array(P);for(let M=0,U=0,Y=0,ee=0;M<F.length;M++)for(U|=(y.encode(F[M])&L)<<Y,Y+=B;Y>=8;Y-=8,U>>=8)X[ee++]=U&Rs(Y);return X},decode:F=>{let X=e(r);for(let M=0,U=0,Y=0,ee=0;M<F.length;M++)for(U|=F[M]<<Y,Y+=8;Y>=B;Y-=B,U>>=B)X[ee++]=y.decode(U&L);return X}}}}},za=t=>(e,r)=>{r||(r=t.blockLen);let n=new Uint8Array(e.length+2);n.set(e);let o=e.length,s=new Uint8Array(r),i=t.create({}),c=0,a=0;return{stats:()=>({calls:c,xofs:a}),get:(u,l)=>(n[o+0]=u,n[o+1]=l,i.destroy(),i=t.create({}).update(n),c++,()=>(a++,i.xofInto(s))),clean:()=>{i.destroy(),Fe(s,n)}}},Zn=za(Pa),Yn=za(be)});var eo={};oo(eo,{PARAMS:()=>Qn,ml_dsa44:()=>du,ml_dsa65:()=>hu,ml_dsa87:()=>pu});function Ya(t){Os(t),t.externalMu!==void 0&&Pt(t.externalMu,"opts.externalMu")}function Xn(t){let e=ve(re);for(let r=0;r<re;){let n=t();if(n.length%3)throw new Error("RejNTTPoly: unaligned block");for(let o=0;r<re&&o<=n.length-3;o+=3){let s=(n[o+0]|n[o+1]<<8|n[o+2]<<16)&8388607;s<Bt&&(e[r++]=s)}}return e}function Vs(t){let{K:e,L:r,GAMMA1:n,GAMMA2:o,TAU:s,ETA:i,OMEGA:c}=t,{CRH_BYTES:a,TR_BYTES:u,C_TILDE_BYTES:l,XOF128:f,XOF256:h,securityLevel:p}=t;if(![2,4].includes(i))throw new Error("Wrong ETA");if(![1<<17,1<<19].includes(n))throw new Error("Wrong GAMMA1");if(![Ns,Ps].includes(o))throw new Error("Wrong GAMMA2");let x=s*i,w=A=>{let S=Yt(A),E=Jn(S,2*o)|0;return S-E===Bt-1?{r1:0,r0:E-1|0}:{r1:Math.floor((S-E)/(2*o))|0,r0:E}},v=A=>w(A).r1,I=A=>w(A).r0,B=(A,S)=>A<=o||A>Bt-o||A===Bt-o&&S===0?0:1,y=(A,S)=>{let E=Math.floor((Bt-1)/(2*o)),{r1:k,r0:O}=w(S);return A===1?O>0?Yt(k+1,E)|0:Yt(k-1,E)|0:k|0},L=A=>{let S=Yt(A),E=Jn(S,2**Xt)|0;return{r1:Math.floor((S-E)/2**Xt)|0,r0:E}},P={bytesLen:c+e,encode:A=>{if(A===!1)throw new Error("hint.encode: hint is false");let S=new Uint8Array(c+e);for(let E=0,k=0;E<e;E++){for(let O=0;O<re;O++)A[E][O]!==0&&(S[k++]=O);S[c+E]=k}return S},decode:A=>{let S=[],E=0;for(let k=0;k<e;k++){let O=ve(re);if(A[c+k]<E||A[c+k]>c)return!1;for(let G=E;G<A[c+k];G++){if(G>E&&A[G]<=A[G-1])return!1;O[A[G]]=1}E=A[c+k],S.push(O)}for(let k=E;k<c;k++)if(A[k]!==0)return!1;return S}},F=Yr(i===2?3:4,A=>i-A,A=>{if(!(-i<=A&&A<=i))throw new Error(`malformed key s1/s3 ${A} outside of ETA range [${-i}, ${i}]`);return A}),X=Yr(13,A=>(1<<Xt-1)-A),M=Yr(10),U=Yr(n===1<<17?18:20,A=>Jn(n-A)),Y=Yr(o===Ns?6:4),ee=Zt(Y,e),$=Zr("publicKey",32,Zt(M,e)),j=Zr("secretKey",32,32,u,Zt(F,r),Zt(F,e),Zt(X,e)),g=Zr("signature",l,Zt(U,r),P),b=i===2?A=>A<15?2-A%5:!1:A=>A<9?4-A:!1;function H(A){let S=ve(re);for(let E=0;E<re;){let k=A();for(let O=0;E<re&&O<k.length;O+=1){let G=b(k[O]&15),Z=b(k[O]>>4&15);G!==!1&&(S[E++]=G),E<re&&Z!==!1&&(S[E++]=Z)}}return S}let C=A=>{let S=ve(re),E=be.create({}).update(A),k=new Uint8Array(be.blockLen);E.xofInto(k);let O=k.slice(0,8);for(let G=re-s,Z=8,J=0,oe=0;G<re;G++){let se=G+1;for(;se>G;)se=k[Z++],!(Z<be.blockLen)&&(E.xofInto(k),Z=0);S[G]=S[se],S[se]=1-((O[J]>>oe++&1)<<1),oe>=8&&(J++,oe=0)}return S},q=A=>{let S=ve(re),E=ve(re);for(let k=0;k<A.length;k++){let{r0:O,r1:G}=L(A[k]);S[k]=O,E[k]=G}return{r0:S,r1:E}},N=(A,S)=>{for(let E=0;E<re;E++)A[E]=y(S[E],A[E]);return A},W=(A,S)=>{let E=ve(re),k=0;for(let O=0;O<re;O++){let G=B(A[O],S[O]);E[O]=G,k+=G}return{v:E,cnt:k}},_=32,z=Zr("seed",32,64,32),V={info:{type:"internal-ml-dsa"},lengths:{secretKey:j.bytesLen,publicKey:$.bytesLen,seed:32,signature:g.bytesLen,signRand:_},keygen:A=>{let S=new Uint8Array(34),E=A===void 0;E&&(A=Ks(32)),ie(A,32,"seed"),S.set(A),E&&Fe(A),S[32]=e,S[33]=r;let[k,O,G]=z.decode(be(S,{dkLen:z.bytesLen})),Z=h(O),J=[];for(let D=0;D<r;D++)J.push(H(Z.get(D&255,D>>8&255)));let oe=[];for(let D=r;D<r+e;D++)oe.push(H(Z.get(D&255,D>>8&255)));let se=J.map(D=>de.encode(D.slice())),ce=[],he=[],We=f(k),ae=ve(re);for(let D=0;D<e;D++){Fe(ae);for(let me=0;me<r;me++){let Te=Xn(We.get(me,D));At(ae,vt(Te,se[me]))}de.decode(ae);let{r0:Be,r1:ge}=q(At(ae,oe[D]));ce.push(Be),he.push(ge)}let Re=$.encode([k,he]),ze=be(Re,{dkLen:u}),Qt=j.encode([k,G,ze,J,oe,ce]);return We.clean(),Z.clean(),Fe(k,O,G,J,oe,se,ae,ce,he,ze,S),{publicKey:Re,secretKey:Qt}},getPublicKey:A=>{let[S,E,k,O,G,Z]=j.decode(A),J=f(S),oe=O.map(he=>de.encode(he.slice())),se=[],ce=ve(re);for(let he=0;he<e;he++){ce.fill(0);for(let ae=0;ae<r;ae++){let Re=Xn(J.get(ae,he));At(ce,vt(Re,oe[ae]))}de.decode(ce),At(ce,G[he]);let{r1:We}=q(ce);se.push(We)}return J.clean(),Fe(ce,oe,Z,O,G),$.encode([S,se])},sign:(A,S,E={})=>{zn(E),Ya(E);let{extraEntropy:k,externalMu:O=!1}=E,[G,Z,J,oe,se,ce]=j.decode(S),he=[],We=f(G);for(let D=0;D<e;D++){let Be=[];for(let ge=0;ge<r;ge++)Be.push(Xn(We.get(ge,D)));he.push(Be)}We.clean();for(let D=0;D<r;D++)de.encode(oe[D]);for(let D=0;D<e;D++)de.encode(se[D]),de.encode(ce[D]);let ae=O?A:be.create({dkLen:a}).update(J).update(A).digest(),Re=k===!1?new Uint8Array(32):k===void 0?Ks(_):k;ie(Re,32,"extraEntropy");let ze=be.create({dkLen:a}).update(Z).update(Re).update(ae).digest();ie(ze,a);let Qt=h(ze,U.bytesLen);e:for(let D=0;;){let Be=[];for(let te=0;te<r;te++,D++)Be.push(U.decode(Qt.get(D&255,D>>8)()));let ge=Be.map(te=>de.encode(te.slice())),me=[];for(let te=0;te<e;te++){let xr=ve(re);for(let it=0;it<r;it++)At(xr,vt(he[te][it],ge[it]));de.decode(xr),me.push(xr)}let Te=me.map(te=>te.map(v)),pr=be.create({dkLen:l}).update(ae).update(ee.encode(Te)).digest(),nn=de.encode(C(pr)),on=oe.map(te=>vt(te,nn));for(let te=0;te<r;te++)if(At(de.decode(on[te]),Be[te]),Xr(on[te],n-x))continue e;let Ws=0,no=[];for(let te=0;te<e;te++){let xr=de.decode(vt(se[te],nn)),it=Ja(me[te],xr).map(I);if(Xr(it,o-x))continue e;let zs=de.decode(vt(ce[te],nn));if(Xr(zs,o))continue e;At(it,zs);let Zs=W(it,Te[te]);no.push(Zs.v),Ws+=Zs.cnt}if(Ws>c)continue;Qt.clean();let Qa=g.encode([pr,on,no]);return Fe(pr,on,no,nn,Te,me,ge,Be,ze,ae,oe,se,ce,...he),Qa}throw new Error("Unreachable code path reached, report this error")},verify:(A,S,E,k={})=>{Ya(k);let{externalMu:O=!1}=k,[G,Z]=$.decode(E),J=be(E,{dkLen:u});if(A.length!==g.bytesLen)return!1;let[oe,se,ce]=g.decode(A);if(ce===!1)return!1;for(let D=0;D<r;D++)if(Xr(se[D],n-x))return!1;let he=O?S:be.create({dkLen:a}).update(J).update(S).digest(),We=de.encode(C(oe)),ae=se.map(D=>D.slice());for(let D=0;D<r;D++)de.encode(ae[D]);let Re=[],ze=f(G);for(let D=0;D<e;D++){let Be=vt(de.encode(lu(Z[D])),We),ge=ve(re);for(let Te=0;Te<r;Te++){let pr=Xn(ze.get(Te,D));At(ge,vt(pr,ae[Te]))}let me=de.decode(Ja(ge,Be));Re.push(N(me,ce[D]))}ze.clean();let Qt=be.create({dkLen:l}).update(he).update(ee.encode(Re)).digest();for(let D of ce)if(!(D.reduce((ge,me)=>ge+me,0)<=c))return!1;for(let D of se)if(Xr(D,n-x))return!1;return Cs(oe,Qt)}};return{info:{type:"ml-dsa"},internal:V,securityLevel:p,keygen:V.keygen,lengths:V.lengths,getPublicKey:V.getPublicKey,sign:(A,S,E={})=>{zn(E);let k=Ts(A,E.context),O=V.sign(k,S,E);return Fe(k),O},verify:(A,S,E,k={})=>(Wn(k),V.verify(A,Ts(S,k.context),E)),prehash:A=>(Fa(A,p),{info:{type:"hashml-dsa"},securityLevel:p,lengths:V.lengths,keygen:V.keygen,getPublicKey:V.getPublicKey,sign:(S,E,k={})=>{zn(k);let O=Ds(A,S,k.context),G=V.sign(O,E,k);return Fe(O),G},verify:(S,E,k,O={})=>(Wn(O),V.verify(S,Ds(A,E,O.context),k))})}}var re,Bt,au,fu,Xt,Ns,Ps,Qn,ve,Yt,Jn,de,uu,Xa,Yr,At,Ja,lu,Xr,vt,du,hu,pu,to=pe(()=>{m();Rr();Is();Za();Ms();re=256,Bt=8380417,au=1753,fu=8347681,Xt=13,Ns=Math.floor((Bt-1)/88)|0,Ps=Math.floor((Bt-1)/32)|0,Qn={2:{K:4,L:4,D:Xt,GAMMA1:2**17,GAMMA2:Ns,TAU:39,ETA:2,OMEGA:80},3:{K:6,L:5,D:Xt,GAMMA1:2**19,GAMMA2:Ps,TAU:49,ETA:4,OMEGA:55},5:{K:8,L:7,D:Xt,GAMMA1:2**19,GAMMA2:Ps,TAU:60,ETA:2,OMEGA:75}},ve=t=>new Int32Array(t),{mod:Yt,smod:Jn,NTT:de,bitsCoder:uu}=Wa({N:re,Q:Bt,F:fu,ROOT_OF_UNITY:au,newPoly:ve,isKyber:!1,brvBits:8}),Xa=t=>t,Yr=(t,e=Xa,r=Xa)=>uu(t,{encode:n=>e(r(n)),decode:n=>r(e(n))}),At=(t,e)=>{for(let r=0;r<t.length;r++)t[r]=Yt(t[r]+e[r]);return t},Ja=(t,e)=>{for(let r=0;r<t.length;r++)t[r]=Yt(t[r]-e[r]);return t},lu=t=>{for(let e=0;e<re;e++)t[e]<<=Xt;return t},Xr=(t,e)=>{for(let r=0;r<re;r++)if(Math.abs(Jn(t[r]))>=e)return!0;return!1},vt=(t,e)=>{let r=ve(re);for(let n=0;n<t.length;n++)r[n]=Yt(t[n]*e[n]);return r};du=Vs({...Qn[2],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:32,XOF128:Zn,XOF256:Yn,securityLevel:128}),hu=Vs({...Qn[3],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:48,XOF128:Zn,XOF256:Yn,securityLevel:192}),pu=Vs({...Qn[5],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:64,XOF128:Zn,XOF256:Yn,securityLevel:256})});var mu={};oo(mu,{InMemoryKeyStorage:()=>St,createKeySDK:()=>Fs,default:()=>gu});m();m();m();m();m();m();m();var i0={p:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,n:0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,h:1n,a:0n,b:7n,Gx:0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Gy:0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n},{p:Ht,n:Pe,Gx:c0,Gy:a0,b:ti}=i0,we=32,It=64,ne=(t="")=>{throw new Error(t)},ri=t=>typeof t=="bigint",ni=t=>typeof t=="string",f0=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",Ut=(t,e)=>!f0(t)||typeof e=="number"&&e>0&&t.length!==e?ne("Uint8Array expected"):t,Lt=t=>new Uint8Array(t),u0=t=>Uint8Array.from(t),oi=(t,e)=>t.toString(16).padStart(e,"0"),un=t=>Array.from(Ut(t)).map(e=>oi(e,2)).join(""),Ze={_0:48,_9:57,A:65,F:70,a:97,f:102},Ys=t=>{if(t>=Ze._0&&t<=Ze._9)return t-Ze._0;if(t>=Ze.A&&t<=Ze.F)return t-(Ze.A-10);if(t>=Ze.a&&t<=Ze.f)return t-(Ze.a-10)},ao=t=>{let e="hex invalid";if(!ni(t))return ne(e);let r=t.length,n=r/2;if(r%2)return ne(e);let o=Lt(n);for(let s=0,i=0;s<n;s++,i+=2){let c=Ys(t.charCodeAt(i)),a=Ys(t.charCodeAt(i+1));if(c===void 0||a===void 0)return ne(e);o[s]=c*16+a}return o},Me=(t,e)=>Ut(ni(t)?ao(t):u0(Ut(t)),e),si=()=>globalThis?.crypto,l0=()=>si()?.subtle??ne("crypto.subtle must be defined"),_t=(...t)=>{let e=Lt(t.reduce((n,o)=>n+Ut(o).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},fo=(t=we)=>si().getRandomValues(Lt(t)),tr=BigInt,mr=(t,e,r,n="bad number: out of range")=>ri(t)&&e<=t&&t<r?t:ne(n),K=(t,e=Ht)=>{let r=t%e;return r>=0n?r:e+r},Se=t=>K(t,Pe),wr=(t,e)=>{(t===0n||e<=0n)&&ne("no inverse n="+t+" mod="+e);let r=K(t,e),n=e,o=0n,s=1n,i=1n,c=0n;for(;r!==0n;){let a=n/r,u=n%r,l=o-i*a,f=s-c*a;n=r,r=u,o=i,s=c,i=l,c=f}return n===1n?K(o,e):ne("no inverse")},d0=t=>{let e=Ar[t];return typeof e!="function"&&ne("hashes."+t+" not set"),e},Xs=t=>t instanceof Ye?t:ne("Point expected"),ii=t=>K(K(t*t)*t+ti),Js=t=>mr(t,0n,Ht),yr=t=>mr(t,1n,Ht),so=t=>mr(t,1n,Pe),io=t=>(t&1n)===0n,er=t=>Uint8Array.of(t),ci=t=>er(io(t)?2:3),h0=t=>{let e=ii(yr(t)),r=1n;for(let n=e,o=(Ht+1n)/4n;o>0n;o>>=1n)o&1n&&(r=r*n%Ht),n=n*n%Ht;return K(r*r)===e?r:ne("sqrt invalid")},De=class De{constructor(e,r,n){d(this,"px");d(this,"py");d(this,"pz");this.px=Js(e),this.py=yr(r),this.pz=Js(n),Object.freeze(this)}static fromBytes(e){Ut(e);let r,n=e[0],o=e.subarray(1),s=cn(o,0,we),i=e.length;if(i===we+1&&[2,3].includes(n)){let c=h0(s),a=io(c);io(tr(n))!==a&&(c=K(-c)),r=new De(s,c,1n)}return i===It+1&&n===4&&(r=new De(s,cn(o,we,It),1n)),r?r.assertValidity():ne("bad point: not on curve")}equals(e){let{px:r,py:n,pz:o}=this,{px:s,py:i,pz:c}=Xs(e),a=K(r*c),u=K(s*o),l=K(n*c),f=K(i*o);return a===u&&l===f}is0(){return this.equals(kt)}negate(){return new De(this.px,K(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:n,pz:o}=this,{px:s,py:i,pz:c}=Xs(e),a=0n,u=ti,l=0n,f=0n,h=0n,p=K(u*3n),x=K(r*s),w=K(n*i),v=K(o*c),I=K(r+n),B=K(s+i);I=K(I*B),B=K(x+w),I=K(I-B),B=K(r+o);let y=K(s+c);return B=K(B*y),y=K(x+v),B=K(B-y),y=K(n+o),l=K(i+c),y=K(y*l),l=K(w+v),y=K(y-l),h=K(a*B),l=K(p*v),h=K(l+h),l=K(w-h),h=K(w+h),f=K(l*h),w=K(x+x),w=K(w+x),v=K(a*v),B=K(p*B),w=K(w+v),v=K(x-v),v=K(a*v),B=K(B+v),x=K(w*B),f=K(f+x),x=K(y*B),l=K(I*l),l=K(l-x),x=K(I*w),h=K(y*h),h=K(h+x),new De(l,f,h)}multiply(e,r=!0){if(!r&&e===0n)return kt;if(so(e),e===1n)return this;if(this.equals(Ne))return v0(e).p;let n=kt,o=Ne;for(let s=this;e>0n;s=s.double(),e>>=1n)e&1n?n=n.add(s):r&&(o=o.add(s));return n}toAffine(){let{px:e,py:r,pz:n}=this;if(this.equals(kt))return{x:0n,y:0n};if(n===1n)return{x:e,y:r};let o=wr(n,Ht);return K(n*o)!==1n&&ne("inverse invalid"),{x:K(e*o),y:K(r*o)}}assertValidity(){let{x:e,y:r}=this.toAffine();return yr(e),yr(r),K(r*r)===ii(e)?this:ne("bad point: not on curve")}toBytes(e=!0){let{x:r,y:n}=this.assertValidity().toAffine(),o=ct(r);return e?_t(ci(n),o):_t(er(4),o,ct(n))}static fromAffine(e){let{x:r,y:n}=e;return r===0n&&n===0n?kt:new De(r,n,1n)}toHex(e){return un(this.toBytes(e))}static fromPrivateKey(e){return Ne.multiply(br(e))}static fromHex(e){return De.fromBytes(Me(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(e){return this.toBytes(e)}};d(De,"BASE"),d(De,"ZERO");var Ye=De,Ne=new Ye(c0,a0,1n),kt=new Ye(0n,1n,0n);Ye.BASE=Ne;Ye.ZERO=kt;var ai=(t,e,r)=>Ne.multiply(e,!1).add(t.multiply(r,!1)).assertValidity(),Er=t=>tr("0x"+(un(t)||"0")),cn=(t,e,r)=>Er(t.subarray(e,r)),p0=2n**256n,ct=t=>ao(oi(mr(t,0n,p0),It)),br=t=>{let e=ri(t)?t:Er(Me(t,we));return mr(e,1n,Pe,"private key invalid 3")},an=t=>t>Pe>>1n,fi=(t,e=!0)=>Ne.multiply(br(t)).toBytes(e),gr=class t{constructor(e,r,n){d(this,"r");d(this,"s");d(this,"recovery");this.r=so(e),this.s=so(r),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(e){Ut(e,It);let r=cn(e,0,we),n=cn(e,we,It);return new t(r,n)}toBytes(){let{r:e,s:r}=this;return _t(ct(e),ct(r))}addRecoveryBit(e){return new t(this.r,this.s,e)}hasHighS(){return an(this.s)}toCompactRawBytes(){return this.toBytes()}toCompactHex(){return un(this.toBytes())}recoverPublicKey(e){return g0(this,e)}static fromCompact(e){return t.fromBytes(Me(e,It))}assertValidity(){return this}normalizeS(){let{r:e,s:r,recovery:n}=this;return an(r)?new t(e,Se(-r),n):this}},ui=t=>{let e=t.length*8-256;e>1024&&ne("msg invalid");let r=Er(t);return e>0?r>>tr(e):r},uo=t=>Se(ui(Ut(t))),li={lowS:!0},x0={lowS:!0},y0=(t,e,r=li)=>{["der","recovered","canonical"].some(h=>h in r)&&ne("option not supported");let{lowS:n,extraEntropy:o}=r;n==null&&(n=!0);let s=ct,i=uo(Me(t)),c=s(i),a=br(e),u=[s(a),c];o&&u.push(o===!0?fo(we):Me(o));let l=i,f=h=>{let p=ui(h);if(!(1n<=p&&p<Pe))return;let x=Ne.multiply(p).toAffine(),w=Se(x.x);if(w===0n)return;let v=wr(p,Pe),I=Se(v*Se(l+Se(a*w)));if(I===0n)return;let B=I,y=(x.x===w?0:2)|Number(x.y&1n);return n&&an(I)&&(B=Se(-I),y^=1),new gr(w,B,y)};return{seed:_t(...u),k2sig:f}},b0=t=>{let e=Lt(we),r=Lt(we),n=0,o=Lt(0),s=()=>{e.fill(1),r.fill(0),n=0},i=1e3,c="drbg: tried 1000 values";if(t){let a=(...f)=>Ar.hmacSha256Async(r,e,...f),u=async(f=o)=>{r=await a(er(0),f),e=await a(),f.length!==0&&(r=await a(er(1),f),e=await a())},l=async()=>(n++>=i&&ne(c),e=await a(),e);return async(f,h)=>{s(),await u(f);let p;for(;!(p=h(await l()));)await u();return s(),p}}else{let a=(...f)=>d0("hmacSha256Sync")(r,e,...f),u=(f=o)=>{r=a(er(0),f),e=a(),f.length!==0&&(r=a(er(1),f),e=a())},l=()=>(n++>=i&&ne(c),e=a(),e);return(f,h)=>{s(),u(f);let p;for(;!(p=h(l()));)u();return s(),p}}};var di=(t,e,r=li)=>{let{seed:n,k2sig:o}=y0(t,e,r);return b0(!1)(n,o)},hi=(t,e,r,n=x0)=>{let{lowS:o}=n;o==null&&(o=!0),"strict"in n&&ne("option not supported");let s,i=t&&typeof t=="object"&&"r"in t;!i&&Me(t).length!==It&&ne("signature must be 64 bytes");try{s=i?new gr(t.r,t.s):gr.fromCompact(t);let c=uo(Me(e)),a=Ye.fromBytes(Me(r)),{r:u,s:l}=s;if(o&&an(l))return!1;let f=wr(l,Pe),h=Se(c*f),p=Se(u*f),x=ai(a,h,p).toAffine();return Se(x.x)===u}catch{return!1}},g0=(t,e)=>{let{r,s:n,recovery:o}=t;[0,1,2,3].includes(o)||ne("recovery id invalid");let s=uo(Me(e,we)),i=o===2||o===3?r+Pe:r;yr(i);let c=ci(tr(o)),a=_t(c,ct(i)),u=Ye.fromBytes(a),l=wr(i,Pe),f=Se(-s*l),h=Se(n*l);return ai(u,f,h)};var pi=t=>{t=Me(t),(t.length<we+8||t.length>1024)&&ne("expected 40-1024b");let e=K(Er(t),Pe-1n);return ct(e+1n)},m0=()=>pi(fo(we+16)),w0="SHA-256",Ar={hexToBytes:ao,bytesToHex:un,concatBytes:_t,bytesToNumberBE:Er,numberToBytesBE:ct,mod:K,invert:wr,hmacSha256Async:async(t,...e)=>{let r=l0(),n="HMAC",o=await r.importKey("raw",t,{name:n,hash:{name:w0}},!1,["sign"]);return Lt(await r.sign(n,o,_t(...e)))},hmacSha256Sync:void 0,hashToPrivateKey:pi,randomBytes:fo},xi={normPrivateKeyToScalar:br,isValidPrivateKey:t=>{try{return!!br(t)}catch{return!1}},randomPrivateKey:m0,precompute:(t=8,e=Ne)=>(e.multiply(3n),e)},fn=8,E0=256,yi=Math.ceil(E0/fn)+1,co=2**(fn-1),A0=()=>{let t=[],e=Ne,r=e;for(let n=0;n<yi;n++){r=e,t.push(r);for(let o=1;o<co;o++)r=r.add(e),t.push(r);e=r.double()}return t},Qs,ei=(t,e)=>{let r=e.negate();return t?r:e},v0=t=>{let e=Qs||(Qs=A0()),r=kt,n=Ne,o=2**fn,s=o,i=tr(o-1),c=tr(fn);for(let a=0;a<yi;a++){let u=Number(t&i);t>>=c,u>co&&(u-=s,t+=1n);let l=a*co,f=l,h=l+Math.abs(u)-1,p=a%2!==0,x=u<0;u===0?n=n.add(ei(p,e[f])):r=r.add(ei(x,e[h]))}return{p:r,f:n}};m();Sr();var hn=class extends at{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,bi(e);let n=Kt(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),ke(s)}update(e){return Je(this),this.iHash.update(e),this}digestInto(e){Je(this),Xe(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ho=(t,e,r)=>new hn(t,e).update(r).digest();ho.create=(t,e)=>new hn(t,e);m();go();var Rt=bn;m();function Ur(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}function rr(t){if(t.length%2!==0)throw new Error("Hex string must have even length");let e=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)e[r/2]=parseInt(t.slice(r,r+2),16);return e}async function wn(t,e){if(e==="sha256"){let r=await Promise.resolve().then(()=>(mn(),gn));return new Uint8Array(r.createHash("sha256").update(t).digest())}else if(e==="sha512"){let r=await Promise.resolve().then(()=>(mn(),gn));return new Uint8Array(r.createHash("sha512").update(t).digest())}else if(e==="sha3-256"){let r=await Promise.resolve().then(()=>(mn(),gn));return new Uint8Array(r.createHash("sha3-256").update(t).digest())}throw new Error(`Unsupported hash algorithm: ${e}`)}m();m();m();m();m();Nt();function Zi(t,e,r){return t&e^~t&r}function Yi(t,e,r){return t&e^t&r^e&r}var Bn=class{constructor(e,r,n,o){d(this,"blockLen");d(this,"outputLen");d(this,"padOffset");d(this,"isLE");d(this,"buffer");d(this,"view");d(this,"finished",!1);d(this,"length",0);d(this,"pos",0);d(this,"destroyed",!1);this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=An(this.buffer)}update(e){nr(this),Q(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=An(e);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(e.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){nr(this),Gi(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Tt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let c=An(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=a/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)c.setUint32(4*f,l[f],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},tt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);Nt();var W0=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),dt=new Uint32Array(64),wo=class extends Bn{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[e,r,n,o,s,i,c,a]}set(e,r,n,o,s,i,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(e,r){for(let f=0;f<16;f++,r+=4)dt[f]=e.getUint32(r,!1);for(let f=16;f<64;f++){let h=dt[f-15],p=dt[f-2],x=Le(h,7)^Le(h,18)^h>>>3,w=Le(p,17)^Le(p,19)^p>>>10;dt[f]=w+dt[f-7]+x+dt[f-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:u,H:l}=this;for(let f=0;f<64;f++){let h=Le(c,6)^Le(c,11)^Le(c,25),p=l+h+Zi(c,a,u)+W0[f]+dt[f]|0,w=(Le(n,2)^Le(n,13)^Le(n,22))+Yi(n,o,s)|0;l=u,u=a,a=c,c=i+p|0,i=s,s=o,o=n,n=p+w|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,s,i,c,a,u,l)}roundClean(){Tt(dt)}destroy(){this.set(0,0,0,0,0,0,0,0),Tt(this.buffer)}},Eo=class extends wo{constructor(){super(32);d(this,"A",tt[0]|0);d(this,"B",tt[1]|0);d(this,"C",tt[2]|0);d(this,"D",tt[3]|0);d(this,"E",tt[4]|0);d(this,"F",tt[5]|0);d(this,"G",tt[6]|0);d(this,"H",tt[7]|0)}};var Xi=Wi(()=>new Eo,zi(1));m();Rr();m();Rr();var ye=BigInt(0),xe=BigInt(1),Vt=BigInt(2),oc=BigInt(3),sc=BigInt(4),ic=BigInt(5),Y0=BigInt(7),cc=BigInt(8),X0=BigInt(9),ac=BigInt(16);function _e(t,e){let r=t%e;return r>=ye?r:e+r}function Ee(t,e,r){let n=t;for(;e-- >ye;)n*=n,n%=r;return n}function rc(t,e){if(t===ye)throw new Error("invert: expected non-zero number");if(e<=ye)throw new Error("invert: expected positive modulus, got "+e);let r=_e(t,e),n=e,o=ye,s=xe,i=xe,c=ye;for(;r!==ye;){let u=n/r,l=n%r,f=o-i*u,h=s-c*u;n=r,r=l,o=i,s=c,i=f,c=h}if(n!==xe)throw new Error("invert: does not exist");return _e(o,e)}function Lo(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function fc(t,e){let r=(t.ORDER+xe)/sc,n=t.pow(e,r);return Lo(t,n,e),n}function J0(t,e){let r=(t.ORDER-ic)/cc,n=t.mul(e,Vt),o=t.pow(n,r),s=t.mul(e,o),i=t.mul(t.mul(s,Vt),o),c=t.mul(s,t.sub(i,t.ONE));return Lo(t,c,e),c}function Q0(t){let e=sr(t),r=uc(t),n=r(e,e.neg(e.ONE)),o=r(e,n),s=r(e,e.neg(n)),i=(t+Y0)/ac;return(c,a)=>{let u=c.pow(a,i),l=c.mul(u,n),f=c.mul(u,o),h=c.mul(u,s),p=c.eql(c.sqr(l),a),x=c.eql(c.sqr(f),a);u=c.cmov(u,l,p),l=c.cmov(h,f,x);let w=c.eql(c.sqr(l),a),v=c.cmov(u,l,w);return Lo(c,v,a),v}}function uc(t){if(t<oc)throw new Error("sqrt is not defined for small field");let e=t-xe,r=0;for(;e%Vt===ye;)e/=Vt,r++;let n=Vt,o=sr(t);for(;nc(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return fc;let s=o.pow(n,e),i=(e+xe)/Vt;return function(a,u){if(a.is0(u))return u;if(nc(a,u)!==1)throw new Error("Cannot find square root");let l=r,f=a.mul(a.ONE,s),h=a.pow(u,e),p=a.pow(u,i);for(;!a.eql(h,a.ONE);){if(a.is0(h))return a.ZERO;let x=1,w=a.sqr(h);for(;!a.eql(w,a.ONE);)if(x++,w=a.sqr(w),x===l)throw new Error("Cannot find square root");let v=xe<<BigInt(l-x-1),I=a.pow(f,v);l=x,f=a.sqr(I),h=a.mul(h,f),p=a.mul(p,I)}return p}}function ef(t){return t%sc===oc?fc:t%cc===ic?J0:t%ac===X0?Q0(t):uc(t)}var tf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Uo(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=tf.reduce((n,o)=>(n[o]="function",n),e);return Or(t,r),t}function rf(t,e,r){if(r<ye)throw new Error("invalid exponent, negatives unsupported");if(r===ye)return t.ONE;if(r===xe)return e;let n=t.ONE,o=e;for(;r>ye;)r&xe&&(n=t.mul(n,o)),o=t.sqr(o),r>>=xe;return n}function Hn(t,e,r=!1){let n=new Array(e.length).fill(r?t.ZERO:void 0),o=e.reduce((i,c,a)=>t.is0(c)?i:(n[a]=i,t.mul(i,c)),t.ONE),s=t.inv(o);return e.reduceRight((i,c,a)=>t.is0(c)?i:(n[a]=t.mul(i,n[a]),t.mul(i,c)),s),n}function nc(t,e){let r=(t.ORDER-xe)/Vt,n=t.pow(e,r),o=t.eql(n,t.ONE),s=t.eql(n,t.ZERO),i=t.eql(n,t.neg(t.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function nf(t,e){e!==void 0&&$e(e);let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var Io=class{constructor(e,r={}){d(this,"ORDER");d(this,"BITS");d(this,"BYTES");d(this,"isLE");d(this,"ZERO",ye);d(this,"ONE",xe);d(this,"_lengths");d(this,"_sqrt");d(this,"_mod");if(e<=ye)throw new Error("invalid field: expected ORDER > 0, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=nf(e,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=s,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return _e(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return ye<=e&&e<this.ORDER}is0(e){return e===ye}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&xe)===xe}neg(e){return _e(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return _e(e*e,this.ORDER)}add(e,r){return _e(e+r,this.ORDER)}sub(e,r){return _e(e-r,this.ORDER)}mul(e,r){return _e(e*r,this.ORDER)}pow(e,r){return rf(this,e,r)}div(e,r){return _e(e*rc(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return rc(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=ef(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?So(e,this.BYTES):kn(e,this.BYTES)}fromBytes(e,r=!1){Q(e);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:c}=this;if(n){if(!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let u=new Uint8Array(o);u.set(e,s?0:u.length-e.length),e=u}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=s?Bo(e):or(e);if(c&&(a=_e(a,i)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(e){return Hn(this,e)}cmov(e,r,n){return n?r:e}};function sr(t,e={}){return new Io(t,e)}function lc(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function _o(t){let e=lc(t);return e+Math.ceil(e/2)}function Ko(t,e,r=!1){Q(t);let n=t.length,o=lc(e),s=_o(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?Bo(t):or(t),c=_e(i,e-xe)+xe;return r?So(c,o):kn(c,o)}var ir=BigInt(0),$t=BigInt(1);function Tr(t,e){let r=e.negate();return t?r:e}function To(t,e){let r=Hn(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function xc(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Co(t,e){xc(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,s=Cr(t),i=BigInt(t);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function dc(t,e,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,c=Number(t&o),a=t>>i;c>n&&(c-=s,a+=$t);let u=e*n,l=u+Math.abs(c)-1,f=c===0,h=c<0,p=e%2!==0;return{nextN:a,offset:l,isZero:f,isNeg:h,isNegF:p,offsetF:u}}var Oo=new WeakMap,yc=new WeakMap;function Ro(t){return yc.get(t)||1}function hc(t){if(t!==ir)throw new Error("invalid wNAF")}var In=class{constructor(e,r){d(this,"BASE");d(this,"ZERO");d(this,"Fn");d(this,"bits");this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>ir;)r&$t&&(n=n.add(o)),o=o.double(),r>>=$t;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=Co(r,this.bits),s=[],i=e,c=i;for(let a=0;a<n;a++){c=i,s.push(c);for(let u=1;u<o;u++)c=c.add(i),s.push(c);i=c.double()}return s}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=Co(e,this.bits);for(let c=0;c<i.windows;c++){let{nextN:a,offset:u,isZero:l,isNeg:f,isNegF:h,offsetF:p}=dc(n,c,i);n=a,l?s=s.add(Tr(h,r[p])):o=o.add(Tr(f,r[u]))}return hc(n),{p:o,f:s}}wNAFUnsafe(e,r,n,o=this.ZERO){let s=Co(e,this.bits);for(let i=0;i<s.windows&&n!==ir;i++){let{nextN:c,offset:a,isZero:u,isNeg:l}=dc(n,i,s);if(n=c,!u){let f=r[a];o=o.add(l?f.negate():f)}}return hc(n),o}getPrecomputes(e,r,n){let o=Oo.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Oo.set(r,o))),o}cached(e,r,n){let o=Ro(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let s=Ro(e);return s===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),r,o)}createCache(e,r){xc(r,this.bits),yc.set(e,r),Oo.delete(e)}hasCache(e){return Ro(e)!==1}};function bc(t,e,r,n){let o=e,s=t.ZERO,i=t.ZERO;for(;r>ir||n>ir;)r&$t&&(s=s.add(o)),n&$t&&(i=i.add(o)),o=o.double(),r>>=$t,n>>=$t;return{p1:s,p2:i}}function pc(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Uo(e),e}else return sr(t,{isLE:r})}function gc(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let a of["p","n","h"]){let u=e[a];if(!(typeof u=="bigint"&&u>ir))throw new Error(`CURVE.${a} must be positive bigint`)}let o=pc(e.p,r.Fp,n),s=pc(e.n,r.Fn,n),c=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:s}}function mc(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}m();m();Nt();var Ln=class{constructor(e,r){d(this,"oHash");d(this,"iHash");d(this,"blockLen");d(this,"outputLen");d(this,"finished",!1);d(this,"destroyed",!1);if(En(e),Q(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Tt(o)}update(e){return nr(this),this.iHash.update(e),this}digestInto(e){nr(this),Q(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Do=(t,e,r)=>new Ln(t,e).update(r).digest();Do.create=(t,e)=>new Ln(t,e);Nt();Rr();var wc=(t,e)=>(t+(t>=0?e:-e)/Ec)/e;function of(t,e,r){let[[n,o],[s,i]]=e,c=wc(i*t,r),a=wc(-o*t,r),u=t-c*n-a*s,l=-c*o-a*i,f=u<rt,h=l<rt;f&&(u=-u),h&&(l=-l);let p=Cr(Math.ceil(ko(r)/2))+cr;if(u<rt||u>=p||l<rt||l>=p)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:f,k1:u,k2neg:h,k2:l}}function No(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Mo(t,e){let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return Pt(r.lowS,"lowS"),Pt(r.prehash,"prehash"),r.format!==void 0&&No(r.format),r}var Po=class extends Error{constructor(e=""){super(e)}},ht={Err:Po,_tlv:{encode:(t,e)=>{let{Err:r}=ht;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Kr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Kr(o.length/2|128):"";return Kr(t)+s+o+e},decode(t,e){let{Err:r}=ht,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+a);if(u.length!==a)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let l of u)i=i<<8|l;if(n+=a,i<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+i)}}},_int:{encode(t){let{Err:e}=ht;if(t<rt)throw new e("integer: negative integers are not allowed");let r=Kr(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=ht;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return or(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=ht,o=Q(t,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:u,l}=n.decode(2,a);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(u)}},hexFromSig(t){let{_tlv:e,_int:r}=ht,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),s=n+o;return e.encode(48,s)}},rt=BigInt(0),cr=BigInt(1),Ec=BigInt(2),Un=BigInt(3),sf=BigInt(4);function Ac(t,e={}){let r=gc("weierstrass",t,e),{Fp:n,Fn:o}=r,s=r.CURVE,{h:i,n:c}=s;Or(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:a}=e;if(a&&(!n.is0(s.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=Bc(n,o);function l(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(j,g,b){let{x:H,y:C}=g.toAffine(),q=n.toBytes(H);if(Pt(b,"isCompressed"),b){l();let N=!n.isOdd(C);return Ue(vc(N),q)}else return Ue(Uint8Array.of(4),q,n.toBytes(C))}function h(j){Q(j,void 0,"Point");let{publicKey:g,publicKeyUncompressed:b}=u,H=j.length,C=j[0],q=j.subarray(1);if(H===g&&(C===2||C===3)){let N=n.fromBytes(q);if(!n.isValid(N))throw new Error("bad point: is not on curve, wrong x");let W=w(N),_;try{_=n.sqrt(W)}catch(A){let S=A instanceof Error?": "+A.message:"";throw new Error("bad point: is not on curve, sqrt error"+S)}l();let z=n.isOdd(_);return(C&1)===1!==z&&(_=n.neg(_)),{x:N,y:_}}else if(H===b&&C===4){let N=n.BYTES,W=n.fromBytes(q.subarray(0,N)),_=n.fromBytes(q.subarray(N,N*2));if(!v(W,_))throw new Error("bad point: is not on curve");return{x:W,y:_}}else throw new Error(`bad point: got length ${H}, expected compressed=${g} or uncompressed=${b}`)}let p=e.toBytes||f,x=e.fromBytes||h;function w(j){let g=n.sqr(j),b=n.mul(g,j);return n.add(n.add(b,n.mul(j,s.a)),s.b)}function v(j,g){let b=n.sqr(g),H=w(j);return n.eql(b,H)}if(!v(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let I=n.mul(n.pow(s.a,Un),sf),B=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(I,B)))throw new Error("bad curve params: a or b");function y(j,g,b=!1){if(!n.isValid(g)||b&&n.is0(g))throw new Error(`bad point coordinate ${j}`);return g}function L(j){if(!(j instanceof U))throw new Error("Weierstrass Point expected")}function P(j){if(!a||!a.basises)throw new Error("no endo");return of(j,a.basises,o.ORDER)}let F=Ho((j,g)=>{let{X:b,Y:H,Z:C}=j;if(n.eql(C,n.ONE))return{x:b,y:H};let q=j.is0();g==null&&(g=q?n.ONE:n.inv(C));let N=n.mul(b,g),W=n.mul(H,g),_=n.mul(C,g);if(q)return{x:n.ZERO,y:n.ZERO};if(!n.eql(_,n.ONE))throw new Error("invZ was invalid");return{x:N,y:W}}),X=Ho(j=>{if(j.is0()){if(e.allowInfinityPoint&&!n.is0(j.Y))return;throw new Error("bad point: ZERO")}let{x:g,y:b}=j.toAffine();if(!n.isValid(g)||!n.isValid(b))throw new Error("bad point: x or y not field elements");if(!v(g,b))throw new Error("bad point: equation left != right");if(!j.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function M(j,g,b,H,C){return b=new U(n.mul(b.X,j),b.Y,b.Z),g=Tr(H,g),b=Tr(C,b),g.add(b)}let $=class ${constructor(g,b,H){d(this,"X");d(this,"Y");d(this,"Z");this.X=y("x",g),this.Y=y("y",b,!0),this.Z=y("z",H),Object.freeze(this)}static CURVE(){return s}static fromAffine(g){let{x:b,y:H}=g||{};if(!g||!n.isValid(b)||!n.isValid(H))throw new Error("invalid affine point");if(g instanceof $)throw new Error("projective point not allowed");return n.is0(b)&&n.is0(H)?$.ZERO:new $(b,H,n.ONE)}static fromBytes(g){let b=$.fromAffine(x(Q(g,void 0,"point")));return b.assertValidity(),b}static fromHex(g){return $.fromBytes(Mt(g))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,b=!0){return ee.createCache(this,g),b||this.multiply(Un),this}assertValidity(){X(this)}hasEvenY(){let{y:g}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(g)}equals(g){L(g);let{X:b,Y:H,Z:C}=this,{X:q,Y:N,Z:W}=g,_=n.eql(n.mul(b,W),n.mul(q,C)),z=n.eql(n.mul(H,W),n.mul(N,C));return _&&z}negate(){return new $(this.X,n.neg(this.Y),this.Z)}double(){let{a:g,b}=s,H=n.mul(b,Un),{X:C,Y:q,Z:N}=this,W=n.ZERO,_=n.ZERO,z=n.ZERO,V=n.mul(C,C),A=n.mul(q,q),S=n.mul(N,N),E=n.mul(C,q);return E=n.add(E,E),z=n.mul(C,N),z=n.add(z,z),W=n.mul(g,z),_=n.mul(H,S),_=n.add(W,_),W=n.sub(A,_),_=n.add(A,_),_=n.mul(W,_),W=n.mul(E,W),z=n.mul(H,z),S=n.mul(g,S),E=n.sub(V,S),E=n.mul(g,E),E=n.add(E,z),z=n.add(V,V),V=n.add(z,V),V=n.add(V,S),V=n.mul(V,E),_=n.add(_,V),S=n.mul(q,N),S=n.add(S,S),V=n.mul(S,E),W=n.sub(W,V),z=n.mul(S,A),z=n.add(z,z),z=n.add(z,z),new $(W,_,z)}add(g){L(g);let{X:b,Y:H,Z:C}=this,{X:q,Y:N,Z:W}=g,_=n.ZERO,z=n.ZERO,V=n.ZERO,A=s.a,S=n.mul(s.b,Un),E=n.mul(b,q),k=n.mul(H,N),O=n.mul(C,W),G=n.add(b,H),Z=n.add(q,N);G=n.mul(G,Z),Z=n.add(E,k),G=n.sub(G,Z),Z=n.add(b,C);let J=n.add(q,W);return Z=n.mul(Z,J),J=n.add(E,O),Z=n.sub(Z,J),J=n.add(H,C),_=n.add(N,W),J=n.mul(J,_),_=n.add(k,O),J=n.sub(J,_),V=n.mul(A,Z),_=n.mul(S,O),V=n.add(_,V),_=n.sub(k,V),V=n.add(k,V),z=n.mul(_,V),k=n.add(E,E),k=n.add(k,E),O=n.mul(A,O),Z=n.mul(S,Z),k=n.add(k,O),O=n.sub(E,O),O=n.mul(A,O),Z=n.add(Z,O),E=n.mul(k,Z),z=n.add(z,E),E=n.mul(J,Z),_=n.mul(G,_),_=n.sub(_,E),E=n.mul(G,k),V=n.mul(J,V),V=n.add(V,E),new $(_,z,V)}subtract(g){return this.add(g.negate())}is0(){return this.equals($.ZERO)}multiply(g){let{endo:b}=e;if(!o.isValidNot0(g))throw new Error("invalid scalar: out of range");let H,C,q=N=>ee.cached(this,N,W=>To($,W));if(b){let{k1neg:N,k1:W,k2neg:_,k2:z}=P(g),{p:V,f:A}=q(W),{p:S,f:E}=q(z);C=A.add(E),H=M(b.beta,V,S,N,_)}else{let{p:N,f:W}=q(g);H=N,C=W}return To($,[H,C])[0]}multiplyUnsafe(g){let{endo:b}=e,H=this;if(!o.isValid(g))throw new Error("invalid scalar: out of range");if(g===rt||H.is0())return $.ZERO;if(g===cr)return H;if(ee.hasCache(this))return this.multiply(g);if(b){let{k1neg:C,k1:q,k2neg:N,k2:W}=P(g),{p1:_,p2:z}=bc($,H,q,W);return M(b.beta,_,z,C,N)}else return ee.unsafe(H,g)}toAffine(g){return F(this,g)}isTorsionFree(){let{isTorsionFree:g}=e;return i===cr?!0:g?g($,this):ee.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:g}=e;return i===cr?this:g?g($,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(g=!0){return Pt(g,"isCompressed"),this.assertValidity(),p($,this,g)}toHex(g=!0){return Dt(this.toBytes(g))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};d($,"BASE",new $(s.Gx,s.Gy,n.ONE)),d($,"ZERO",new $(n.ZERO,n.ONE,n.ZERO)),d($,"Fp",n),d($,"Fn",o);let U=$,Y=o.BITS,ee=new In(U,e.endo?Math.ceil(Y/2):Y);return U.BASE.precompute(8),U}function vc(t){return Uint8Array.of(t?2:3)}function Bc(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function cf(t,e={}){let{Fn:r}=t,n=e.randomBytes||vn,o=Object.assign(Bc(t.Fp,r),{seed:_o(r.ORDER)});function s(p){try{let x=r.fromBytes(p);return r.isValidNot0(x)}catch{return!1}}function i(p,x){let{publicKey:w,publicKeyUncompressed:v}=o;try{let I=p.length;return x===!0&&I!==w||x===!1&&I!==v?!1:!!t.fromBytes(p)}catch{return!1}}function c(p=n(o.seed)){return Ko(Q(p,o.seed,"seed"),r.ORDER)}function a(p,x=!0){return t.BASE.multiply(r.fromBytes(p)).toBytes(x)}function u(p){let{secretKey:x,publicKey:w,publicKeyUncompressed:v}=o;if(!_r(p)||"_lengths"in r&&r._lengths||x===w)return;let I=Q(p,void 0,"key").length;return I===w||I===v}function l(p,x,w=!0){if(u(p)===!0)throw new Error("first arg must be private key");if(u(x)===!1)throw new Error("second arg must be public key");let v=r.fromBytes(p);return t.fromBytes(x).multiply(v).toBytes(w)}let f={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c},h=mc(c,a);return Object.freeze({getPublicKey:a,getSharedSecret:l,keygen:h,Point:t,utils:f,lengths:o})}function Sc(t,e,r={}){En(e),Or(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||vn,o=r.hmac||((g,b)=>Do(e,g,b)),{Fp:s,Fn:i}=t,{ORDER:c,BITS:a}=i,{keygen:u,getPublicKey:l,getSharedSecret:f,utils:h,lengths:p}=cf(t,r),x={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},w=c*Ec<s.ORDER;function v(g){let b=c>>cr;return g>b}function I(g,b){if(!i.isValidNot0(b))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return b}function B(){if(w)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function y(g,b){No(b);let H=p.signature,C=b==="compact"?H:b==="recovered"?H+1:void 0;return Q(g,C)}class L{constructor(b,H,C){d(this,"r");d(this,"s");d(this,"recovery");if(this.r=I("r",b),this.s=I("s",H),C!=null){if(B(),![0,1,2,3].includes(C))throw new Error("invalid recovery id");this.recovery=C}Object.freeze(this)}static fromBytes(b,H=x.format){y(b,H);let C;if(H==="der"){let{r:_,s:z}=ht.toSig(Q(b));return new L(_,z)}H==="recovered"&&(C=b[0],H="compact",b=b.subarray(1));let q=p.signature/2,N=b.subarray(0,q),W=b.subarray(q,q*2);return new L(i.fromBytes(N),i.fromBytes(W),C)}static fromHex(b,H){return this.fromBytes(Mt(b),H)}assertRecovery(){let{recovery:b}=this;if(b==null)throw new Error("invalid recovery id: must be present");return b}addRecoveryBit(b){return new L(this.r,this.s,b)}recoverPublicKey(b){let{r:H,s:C}=this,q=this.assertRecovery(),N=q===2||q===3?H+c:H;if(!s.isValid(N))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let W=s.toBytes(N),_=t.fromBytes(Ue(vc((q&1)===0),W)),z=i.inv(N),V=F(Q(b,void 0,"msgHash")),A=i.create(-V*z),S=i.create(C*z),E=t.BASE.multiplyUnsafe(A).add(_.multiplyUnsafe(S));if(E.is0())throw new Error("invalid recovery: point at infinify");return E.assertValidity(),E}hasHighS(){return v(this.s)}toBytes(b=x.format){if(No(b),b==="der")return Mt(ht.hexFromSig(this));let{r:H,s:C}=this,q=i.toBytes(H),N=i.toBytes(C);return b==="recovered"?(B(),Ue(Uint8Array.of(this.assertRecovery()),q,N)):Ue(q,N)}toHex(b){return Dt(this.toBytes(b))}}let P=r.bits2int||function(b){if(b.length>8192)throw new Error("input is too large");let H=or(b),C=b.length*8-a;return C>0?H>>BigInt(C):H},F=r.bits2int_modN||function(b){return i.create(P(b))},X=Cr(a);function M(g){return ec("num < 2^"+a,g,rt,X),i.toBytes(g)}function U(g,b){return Q(g,void 0,"message"),b?Q(e(g),void 0,"prehashed message"):g}function Y(g,b,H){let{lowS:C,prehash:q,extraEntropy:N}=Mo(H,x);g=U(g,q);let W=F(g),_=i.fromBytes(b);if(!i.isValidNot0(_))throw new Error("invalid private key");let z=[M(_),M(W)];if(N!=null&&N!==!1){let E=N===!0?n(p.secretKey):N;z.push(Q(E,void 0,"extraEntropy"))}let V=Ue(...z),A=W;function S(E){let k=P(E);if(!i.isValidNot0(k))return;let O=i.inv(k),G=t.BASE.multiply(k).toAffine(),Z=i.create(G.x);if(Z===rt)return;let J=i.create(O*i.create(A+Z*_));if(J===rt)return;let oe=(G.x===Z?0:2)|Number(G.y&cr),se=J;return C&&v(J)&&(se=i.neg(J),oe^=1),new L(Z,se,w?void 0:oe)}return{seed:V,k2sig:S}}function ee(g,b,H={}){let{seed:C,k2sig:q}=Y(g,b,H);return tc(e.outputLen,i.BYTES,o)(C,q).toBytes(H.format)}function $(g,b,H,C={}){let{lowS:q,prehash:N,format:W}=Mo(C,x);if(H=Q(H,void 0,"publicKey"),b=U(b,N),!_r(g)){let _=g instanceof L?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+_)}y(g,W);try{let _=L.fromBytes(g,W),z=t.fromBytes(H);if(q&&_.hasHighS())return!1;let{r:V,s:A}=_,S=F(b),E=i.inv(A),k=i.create(S*E),O=i.create(V*E),G=t.BASE.multiplyUnsafe(k).add(z.multiplyUnsafe(O));return G.is0()?!1:i.create(G.x)===V}catch{return!1}}function j(g,b,H={}){let{prehash:C}=Mo(H,x);return b=U(b,C),L.fromBytes(g,"recovered").recoverPublicKey(b).toBytes()}return Object.freeze({keygen:u,getPublicKey:l,getSharedSecret:f,utils:h,lengths:p,Point:t,sign:ee,verify:$,recoverPublicKey:j,Signature:L,hash:e})}var $o={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},af={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var kc=BigInt(2);function ff(t){let e=$o.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),u=t*t*t%e,l=u*u*t%e,f=Ee(l,r,e)*l%e,h=Ee(f,r,e)*l%e,p=Ee(h,kc,e)*u%e,x=Ee(p,o,e)*p%e,w=Ee(x,s,e)*x%e,v=Ee(w,c,e)*w%e,I=Ee(v,a,e)*v%e,B=Ee(I,c,e)*w%e,y=Ee(B,r,e)*l%e,L=Ee(y,i,e)*x%e,P=Ee(L,n,e)*u%e,F=Ee(P,kc,e);if(!Vo.eql(Vo.sqr(F),t))throw new Error("Cannot find square root");return F}var Vo=sr($o.p,{sqrt:ff}),uf=Ac($o,{Fp:Vo,endo:af}),jt=Sc(uf,Xi);m();m();function lf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Hc(t,e=""){if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function Ae(t,e,r=""){let n=lf(t),o=t?.length,s=e!==void 0;if(!n||s&&o!==e){let i=r&&`"${r}" `,c=s?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+c+", got "+a)}return t}function Ic(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Hc(t.outputLen),Hc(t.blockLen)}function ar(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Lc(t,e){Ae(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function He(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function pt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ke(t,e){return t<<32-e|t>>>e}function Dr(t,e){return t<<e|t>>>32-e>>>0}function Mr(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];Ae(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let s=t[n];r.set(s,o),o+=s.length}return r}function Nr(t,e={}){let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}var jo=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});var _n=class{constructor(e,r){d(this,"oHash");d(this,"iHash");d(this,"blockLen");d(this,"outputLen");d(this,"finished",!1);d(this,"destroyed",!1);if(Ic(e),Ae(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),He(o)}update(e){return ar(this),this.iHash.update(e),this}digestInto(e){ar(this),Ae(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Kn=(t,e,r)=>new _n(t,e).update(r).digest();Kn.create=(t,e)=>new _n(t,e);m();m();function qo(t,e,r){return t&e^~t&r}function Go(t,e,r){return t&e^t&r^e&r}var qt=class{constructor(e,r,n,o){d(this,"blockLen");d(this,"outputLen");d(this,"padOffset");d(this,"isLE");d(this,"buffer");d(this,"view");d(this,"finished",!1);d(this,"length",0);d(this,"pos",0);d(this,"destroyed",!1);this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=pt(this.buffer)}update(e){ar(this),Ae(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=pt(e);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(e.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ar(this),Lc(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,He(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let c=pt(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=a/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)c.setUint32(4*f,l[f],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},nt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ue=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var df=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),_c=Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)),hf=_c.map(t=>(9*t+5)%16),Kc=(()=>{let r=[[_c],[hf]];for(let n=0;n<4;n++)for(let o of r)o.push(o[n].map(s=>df[s]));return r})(),Cc=Kc[0],Oc=Kc[1],Rc=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),pf=Cc.map((t,e)=>t.map(r=>Rc[e][r])),xf=Oc.map((t,e)=>t.map(r=>Rc[e][r])),yf=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),bf=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function Uc(t,e,r,n){return t===0?e^r^n:t===1?e&r|~e&n:t===2?(e|~r)^n:t===3?e&n|r&~n:e^(r|~n)}var Cn=new Uint32Array(16),Fo=class extends qt{constructor(){super(64,20,8,!0);d(this,"h0",1732584193);d(this,"h1",-271733879);d(this,"h2",-1732584194);d(this,"h3",271733878);d(this,"h4",-1009589776)}get(){let{h0:r,h1:n,h2:o,h3:s,h4:i}=this;return[r,n,o,s,i]}set(r,n,o,s,i){this.h0=r|0,this.h1=n|0,this.h2=o|0,this.h3=s|0,this.h4=i|0}process(r,n){for(let x=0;x<16;x++,n+=4)Cn[x]=r.getUint32(n,!0);let o=this.h0|0,s=o,i=this.h1|0,c=i,a=this.h2|0,u=a,l=this.h3|0,f=l,h=this.h4|0,p=h;for(let x=0;x<5;x++){let w=4-x,v=yf[x],I=bf[x],B=Cc[x],y=Oc[x],L=pf[x],P=xf[x];for(let F=0;F<16;F++){let X=Dr(o+Uc(x,i,a,l)+Cn[B[F]]+v,L[F])+h|0;o=h,h=l,l=Dr(a,10)|0,a=i,i=X}for(let F=0;F<16;F++){let X=Dr(s+Uc(w,c,u,f)+Cn[y[F]]+I,P[F])+p|0;s=p,p=f,f=Dr(u,10)|0,u=c,c=X}}this.set(this.h1+a+f|0,this.h2+l+p|0,this.h3+h+s|0,this.h4+o+c|0,this.h0+i+u|0)}roundClean(){He(Cn)}destroy(){this.destroyed=!0,He(this.buffer),this.set(0,0,0,0,0)}},Tc=Nr(()=>new Fo);m();m();var On=BigInt(4294967295),Dc=BigInt(32);function gf(t,e=!1){return e?{h:Number(t&On),l:Number(t>>Dc&On)}:{h:Number(t>>Dc&On)|0,l:Number(t&On)|0}}function Mc(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=gf(t[s],e);[n[s],o[s]]=[i,c]}return[n,o]}var Wo=(t,e,r)=>t>>>r,zo=(t,e,r)=>t<<32-r|e>>>r,Gt=(t,e,r)=>t>>>r|e<<32-r,Ft=(t,e,r)=>t<<32-r|e>>>r,Pr=(t,e,r)=>t<<64-r|e>>>r-32,Vr=(t,e,r)=>t>>>r-32|e<<64-r;function je(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var Nc=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Pc=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Vc=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),$c=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,jc=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),qc=(t,e,r,n,o,s)=>e+r+n+o+s+(t/2**32|0)|0;var wf=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),xt=new Uint32Array(64),Zo=class extends qt{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[e,r,n,o,s,i,c,a]}set(e,r,n,o,s,i,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(e,r){for(let f=0;f<16;f++,r+=4)xt[f]=e.getUint32(r,!1);for(let f=16;f<64;f++){let h=xt[f-15],p=xt[f-2],x=Ke(h,7)^Ke(h,18)^h>>>3,w=Ke(p,17)^Ke(p,19)^p>>>10;xt[f]=w+xt[f-7]+x+xt[f-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:u,H:l}=this;for(let f=0;f<64;f++){let h=Ke(c,6)^Ke(c,11)^Ke(c,25),p=l+h+qo(c,a,u)+wf[f]+xt[f]|0,w=(Ke(n,2)^Ke(n,13)^Ke(n,22))+Go(n,o,s)|0;l=u,u=a,a=c,c=i+p|0,i=s,s=o,o=n,n=p+w|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,s,i,c,a,u,l)}roundClean(){He(xt)}destroy(){this.set(0,0,0,0,0,0,0,0),He(this.buffer)}},Yo=class extends Zo{constructor(){super(32);d(this,"A",nt[0]|0);d(this,"B",nt[1]|0);d(this,"C",nt[2]|0);d(this,"D",nt[3]|0);d(this,"E",nt[4]|0);d(this,"F",nt[5]|0);d(this,"G",nt[6]|0);d(this,"H",nt[7]|0)}};var Gc=Mc(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Ef=Gc[0],Af=Gc[1],yt=new Uint32Array(80),bt=new Uint32Array(80),Xo=class extends qt{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:u,El:l,Fh:f,Fl:h,Gh:p,Gl:x,Hh:w,Hl:v}=this;return[e,r,n,o,s,i,c,a,u,l,f,h,p,x,w,v]}set(e,r,n,o,s,i,c,a,u,l,f,h,p,x,w,v){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=h|0,this.Gh=p|0,this.Gl=x|0,this.Hh=w|0,this.Hl=v|0}process(e,r){for(let y=0;y<16;y++,r+=4)yt[y]=e.getUint32(r),bt[y]=e.getUint32(r+=4);for(let y=16;y<80;y++){let L=yt[y-15]|0,P=bt[y-15]|0,F=Gt(L,P,1)^Gt(L,P,8)^Wo(L,P,7),X=Ft(L,P,1)^Ft(L,P,8)^zo(L,P,7),M=yt[y-2]|0,U=bt[y-2]|0,Y=Gt(M,U,19)^Pr(M,U,61)^Wo(M,U,6),ee=Ft(M,U,19)^Vr(M,U,61)^zo(M,U,6),$=Vc(X,ee,bt[y-7],bt[y-16]),j=$c($,F,Y,yt[y-7],yt[y-16]);yt[y]=j|0,bt[y]=$|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:u,Dl:l,Eh:f,El:h,Fh:p,Fl:x,Gh:w,Gl:v,Hh:I,Hl:B}=this;for(let y=0;y<80;y++){let L=Gt(f,h,14)^Gt(f,h,18)^Pr(f,h,41),P=Ft(f,h,14)^Ft(f,h,18)^Vr(f,h,41),F=f&p^~f&w,X=h&x^~h&v,M=jc(B,P,X,Af[y],bt[y]),U=qc(M,I,L,F,Ef[y],yt[y]),Y=M|0,ee=Gt(n,o,28)^Pr(n,o,34)^Pr(n,o,39),$=Ft(n,o,28)^Vr(n,o,34)^Vr(n,o,39),j=n&s^n&c^s&c,g=o&i^o&a^i&a;I=w|0,B=v|0,w=p|0,v=x|0,p=f|0,x=h|0,{h:f,l:h}=je(u|0,l|0,U|0,Y|0),u=c|0,l=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let b=Nc(Y,$,g);n=Pc(b,U,ee,j),o=b|0}({h:n,l:o}=je(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=je(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=je(this.Ch|0,this.Cl|0,c|0,a|0),{h:u,l}=je(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:h}=je(this.Eh|0,this.El|0,f|0,h|0),{h:p,l:x}=je(this.Fh|0,this.Fl|0,p|0,x|0),{h:w,l:v}=je(this.Gh|0,this.Gl|0,w|0,v|0),{h:I,l:B}=je(this.Hh|0,this.Hl|0,I|0,B|0),this.set(n,o,s,i,c,a,u,l,f,h,p,x,w,v,I,B)}roundClean(){He(yt,bt)}destroy(){He(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Jo=class extends Xo{constructor(){super(64);d(this,"Ah",ue[0]|0);d(this,"Al",ue[1]|0);d(this,"Bh",ue[2]|0);d(this,"Bl",ue[3]|0);d(this,"Ch",ue[4]|0);d(this,"Cl",ue[5]|0);d(this,"Dh",ue[6]|0);d(this,"Dl",ue[7]|0);d(this,"Eh",ue[8]|0);d(this,"El",ue[9]|0);d(this,"Fh",ue[10]|0);d(this,"Fl",ue[11]|0);d(this,"Gh",ue[12]|0);d(this,"Gl",ue[13]|0);d(this,"Hh",ue[14]|0);d(this,"Hl",ue[15]|0)}};var Qo=Nr(()=>new Yo,jo(1));var es=Nr(()=>new Jo,jo(3));m();function Rn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Fc(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(r=>typeof r=="string"):e.every(r=>Number.isSafeInteger(r)):!1}function vf(t){if(typeof t!="function")throw new Error("function expected");return!0}function Tn(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function fr(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Dn(t){if(!Array.isArray(t))throw new Error("array expected")}function Mn(t,e){if(!Fc(!0,e))throw new Error(`${t}: array of strings expected`)}function Wc(t,e){if(!Fc(!1,e))throw new Error(`${t}: array of numbers expected`)}function os(...t){let e=s=>s,r=(s,i)=>c=>s(i(c)),n=t.map(s=>s.encode).reduceRight(r,e),o=t.map(s=>s.decode).reduce(r,e);return{encode:n,decode:o}}function zc(t){let e=typeof t=="string"?t.split(""):t,r=e.length;Mn("alphabet",e);let n=new Map(e.map((o,s)=>[o,s]));return{encode:o=>(Dn(o),o.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${t}`);return e[s]})),decode:o=>(Dn(o),o.map(s=>{Tn("alphabet.decode",s);let i=n.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${t}`);return i}))}}function Zc(t=""){return Tn("join",t),{encode:e=>(Mn("join.decode",e),e.join(t)),decode:e=>(Tn("join.decode",e),e.split(t))}}function Bf(t,e="="){return fr(t),Tn("padding",e),{encode(r){for(Mn("padding.encode",r);r.length*t%8;)r.push(e);return r},decode(r){Mn("padding.decode",r);let n=r.length;if(n*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if((n-1)*t%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,n)}}}function rs(t,e,r){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Dn(t),!t.length)return[];let n=0,o=[],s=Array.from(t,c=>{if(fr(c),c<0||c>=e)throw new Error(`invalid integer: ${c}`);return c}),i=s.length;for(;;){let c=0,a=!0;for(let u=n;u<i;u++){let l=s[u],f=e*c,h=f+l;if(!Number.isSafeInteger(h)||f/e!==c||h-l!==f)throw new Error("convertRadix: carry overflow");let p=h/r;c=h%r;let x=Math.floor(p);if(s[u]=x,!Number.isSafeInteger(x)||x*r+c!==h)throw new Error("convertRadix: carry overflow");if(a)x?a=!1:n=u;else continue}if(o.push(c),a)break}for(let c=0;c<t.length-1&&t[c]===0;c++)o.push(0);return o.reverse()}var Yc=(t,e)=>e===0?t:Yc(e,t%e),Nn=(t,e)=>t+(e-Yc(t,e)),ts=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function ns(t,e,r,n){if(Dn(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Nn(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${Nn(e,r)}`);let o=0,s=0,i=ts[e],c=ts[r]-1,a=[];for(let u of t){if(fr(u),u>=i)throw new Error(`convertRadix2: invalid data word=${u} from=${e}`);if(o=o<<e|u,s+e>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=r;s-=r)a.push((o>>s-r&c)>>>0);let l=ts[s];if(l===void 0)throw new Error("invalid carry");o&=l-1}if(o=o<<r-s&c,!n&&s>=e)throw new Error("Excess padding");if(!n&&o>0)throw new Error(`Non-zero padding: ${o}`);return n&&s>0&&a.push(o>>>0),a}function Xc(t){fr(t);let e=2**8;return{encode:r=>{if(!Rn(r))throw new Error("radix.encode input should be Uint8Array");return rs(Array.from(r),e,t)},decode:r=>(Wc("radix.decode",r),Uint8Array.from(rs(r,t,e)))}}function Sf(t,e=!1){if(fr(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Nn(8,t)>32||Nn(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Rn(r))throw new Error("radix2.encode input should be Uint8Array");return ns(Array.from(r),8,t,!e)},decode:r=>(Wc("radix2.decode",r),Uint8Array.from(ns(r,t,8,e)))}}function Jc(t,e){return fr(t),vf(e),{encode(r){if(!Rn(r))throw new Error("checksum.encode: input should be Uint8Array");let n=e(r).slice(0,t),o=new Uint8Array(r.length+t);return o.set(r),o.set(n,r.length),o},decode(r){if(!Rn(r))throw new Error("checksum.decode: input should be Uint8Array");let n=r.slice(0,-t),o=r.slice(-t),s=e(n).slice(0,t);for(let i=0;i<t;i++)if(s[i]!==o[i])throw new Error("Invalid checksum");return n}}}var $r={alphabet:zc,chain:os,checksum:Jc,convertRadix:rs,convertRadix2:ns,radix:Xc,radix2:Sf,join:Zc,padding:Bf};var kf=t=>os(Xc(58),zc(t),Zc("")),Hf=kf("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var Qc=t=>os(Jc(4,e=>t(t(e))),Hf);var qr=jt.Point,{Fn:jr}=qr,ss=Qc(Qo),If=Uint8Array.from("Bitcoin seed".split(""),t=>t.charCodeAt(0)),is={private:76066276,public:76067358},cs=2147483648,Lf=t=>Tc(Qo(t)),Uf=t=>pt(t).getUint32(0,!1),Pn=t=>{if(!Number.isSafeInteger(t)||t<0||t>2**32-1)throw new Error("invalid number, should be from 0 to 2**32-1, got "+t);let e=new Uint8Array(4);return pt(e).setUint32(0,t,!1),e},Vn=class t{constructor(e){d(this,"versions");d(this,"depth",0);d(this,"index",0);d(this,"chainCode",null);d(this,"parentFingerprint",0);d(this,"_privateKey");d(this,"_publicKey");d(this,"pubHash");if(!e||typeof e!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions||is,this.depth=e.depth||0,this.chainCode=e.chainCode||null,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(this.depth>255)throw new Error("HDKey: depth exceeds the serializable value 255");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!jt.utils.isValidSecretKey(e.privateKey))throw new Error("Invalid private key");this._privateKey=e.privateKey,this._publicKey=jt.getPublicKey(e.privateKey,!0)}else if(e.publicKey)this._publicKey=qr.fromBytes(e.publicKey).toBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=Lf(this._publicKey)}get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return Uf(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this._privateKey||null}get publicKey(){return this._publicKey||null}get privateExtendedKey(){let e=this._privateKey;if(!e)throw new Error("No private key");return ss.encode(this.serialize(this.versions.private,Mr(Uint8Array.of(0),e)))}get publicExtendedKey(){if(!this._publicKey)throw new Error("No public key");return ss.encode(this.serialize(this.versions.public,this._publicKey))}static fromMasterSeed(e,r=is){if(Ae(e),8*e.length<128||8*e.length>512)throw new Error("HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got "+e.length);let n=Kn(es,If,e),o=n.slice(0,32),s=n.slice(32);return new t({versions:r,chainCode:s,privateKey:o})}static fromExtendedKey(e,r=is){let n=ss.decode(e),o=pt(n),s=o.getUint32(0,!1),i={versions:r,depth:n[4],parentFingerprint:o.getUint32(5,!1),index:o.getUint32(9,!1),chainCode:n.slice(13,45)},c=n.slice(45),a=c[0]===0;if(s!==r[a?"private":"public"])throw new Error("Version mismatch");return a?new t({...i,privateKey:c.slice(1)}):new t({...i,publicKey:c})}static fromJSON(e){return t.fromExtendedKey(e.xpriv)}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;let r=e.replace(/^[mM]'?\//,"").split("/"),n=this;for(let o of r){let s=/^(\d+)('?)$/.exec(o),i=s&&s[1];if(!s||s.length!==3||typeof i!="string")throw new Error("invalid child index: "+o);let c=+i;if(!Number.isSafeInteger(c)||c>=cs)throw new Error("Invalid index");s[2]==="'"&&(c+=cs),n=n.deriveChild(c)}return n}deriveChild(e){if(!this._publicKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let r=Pn(e);if(e>=cs){let a=this._privateKey;if(!a)throw new Error("Could not derive hardened child key");r=Mr(Uint8Array.of(0),a,r)}else r=Mr(this._publicKey,r);let n=Kn(es,this.chainCode,r),o=n.slice(0,32),s=n.slice(32);if(!jt.utils.isValidSecretKey(o))throw new Error("Tweak bigger than curve order");let i={versions:this.versions,chainCode:s,depth:this.depth+1,parentFingerprint:this.fingerprint,index:e},c=jr.fromBytes(o);try{if(this._privateKey){let a=jr.create(jr.fromBytes(this._privateKey)+c);if(!jr.isValidNot0(a))throw new Error("The tweak was out of range or the resulted private key is invalid");i.privateKey=jr.toBytes(a)}else{let a=qr.fromBytes(this._publicKey).add(qr.BASE.multiply(c));if(a.equals(qr.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");i.publicKey=a.toBytes(!0)}return new t(i)}catch{return this.deriveChild(e+1)}}sign(e){if(!this._privateKey)throw new Error("No privateKey set!");return Ae(e,32),jt.sign(e,this._privateKey,{prehash:!1})}verify(e,r){if(Ae(e,32),Ae(r,64),!this._publicKey)throw new Error("No publicKey set!");return jt.verify(r,e,this._publicKey,{prehash:!1})}wipePrivateData(){return this._privateKey&&(this._privateKey.fill(0),this._privateKey=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(e,r){if(!this.chainCode)throw new Error("No chainCode set");return Ae(r,33),Mr(Pn(e),new Uint8Array([this.depth]),Pn(this.parentFingerprint),Pn(this.index),this.chainCode,r)}};m();m();m();m();function _f(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function gt(t,e=""){if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function ot(t,e,r=""){let n=_f(t),o=t?.length,s=e!==void 0;if(!n||s&&o!==e){let i=r&&`"${r}" `,c=s?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+c+", got "+a)}return t}function $n(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash must wrapped by utils.createHasher");gt(t.outputLen),gt(t.blockLen)}function ur(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ea(t,e){ot(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Ce(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function lr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Oe(t,e){return t<<32-e|t>>>e}function Kf(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function as(t,e=""){return typeof t=="string"?Kf(t):ot(t,void 0,e)}function ta(t,e){if(e!==void 0&&{}.toString.call(e)!=="[object Object]")throw new Error("options must be object or undefined");return Object.assign(t,e)}function fs(t,e={}){let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function ra(t=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}var us=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});var jn=class{constructor(e,r){d(this,"oHash");d(this,"iHash");d(this,"blockLen");d(this,"outputLen");d(this,"finished",!1);d(this,"destroyed",!1);if($n(e),ot(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Ce(o)}update(e){return ur(this),this.iHash.update(e),this}digestInto(e){ur(this),ot(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ls=(t,e,r)=>new jn(t,e).update(r).digest();ls.create=(t,e)=>new jn(t,e);function Cf(t,e,r,n){$n(t);let o=ta({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:c}=o;if(gt(s,"c"),gt(i,"dkLen"),gt(c,"asyncTick"),s<1)throw new Error("iterations (c) must be >= 1");let a=as(e,"password"),u=as(r,"salt"),l=new Uint8Array(i),f=ls.create(t,a),h=f._cloneInto().update(u);return{c:s,dkLen:i,asyncTick:c,DK:l,PRF:f,PRFSalt:h}}function Of(t,e,r,n,o){return t.destroy(),e.destroy(),n&&n.destroy(),Ce(o),r}function na(t,e,r,n){let{c:o,dkLen:s,DK:i,PRF:c,PRFSalt:a}=Cf(t,e,r,n),u,l=new Uint8Array(4),f=lr(l),h=new Uint8Array(c.outputLen);for(let p=1,x=0;x<s;p++,x+=c.outputLen){let w=i.subarray(x,x+c.outputLen);f.setInt32(0,p,!1),(u=a._cloneInto(u)).update(l).digestInto(h),w.set(h.subarray(0,w.length));for(let v=1;v<o;v++){c._cloneInto(u).update(h).digestInto(h);for(let I=0;I<w.length;I++)w[I]^=h[I]}}return Of(c,a,i,u,h)}m();m();function oa(t,e,r){return t&e^~t&r}function sa(t,e,r){return t&e^t&r^e&r}var Gr=class{constructor(e,r,n,o){d(this,"blockLen");d(this,"outputLen");d(this,"padOffset");d(this,"isLE");d(this,"buffer");d(this,"view");d(this,"finished",!1);d(this,"length",0);d(this,"pos",0);d(this,"destroyed",!1);this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=lr(this.buffer)}update(e){ur(this),ot(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=lr(e);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(e.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ur(this),ea(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Ce(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let c=lr(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=a/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)c.setUint32(4*f,l[f],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},st=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var le=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);m();var qn=BigInt(4294967295),ia=BigInt(32);function Rf(t,e=!1){return e?{h:Number(t&qn),l:Number(t>>ia&qn)}:{h:Number(t>>ia&qn)|0,l:Number(t&qn)|0}}function ca(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=Rf(t[s],e);[n[s],o[s]]=[i,c]}return[n,o]}var ds=(t,e,r)=>t>>>r,hs=(t,e,r)=>t<<32-r|e>>>r,Wt=(t,e,r)=>t>>>r|e<<32-r,zt=(t,e,r)=>t<<32-r|e>>>r,Fr=(t,e,r)=>t<<64-r|e>>>r-32,Wr=(t,e,r)=>t>>>r-32|e<<64-r;function qe(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var aa=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),fa=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,ua=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),la=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,da=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),ha=(t,e,r,n,o,s)=>e+r+n+o+s+(t/2**32|0)|0;var Df=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),mt=new Uint32Array(64),ps=class extends Gr{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[e,r,n,o,s,i,c,a]}set(e,r,n,o,s,i,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(e,r){for(let f=0;f<16;f++,r+=4)mt[f]=e.getUint32(r,!1);for(let f=16;f<64;f++){let h=mt[f-15],p=mt[f-2],x=Oe(h,7)^Oe(h,18)^h>>>3,w=Oe(p,17)^Oe(p,19)^p>>>10;mt[f]=w+mt[f-7]+x+mt[f-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:u,H:l}=this;for(let f=0;f<64;f++){let h=Oe(c,6)^Oe(c,11)^Oe(c,25),p=l+h+oa(c,a,u)+Df[f]+mt[f]|0,w=(Oe(n,2)^Oe(n,13)^Oe(n,22))+sa(n,o,s)|0;l=u,u=a,a=c,c=i+p|0,i=s,s=o,o=n,n=p+w|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,s,i,c,a,u,l)}roundClean(){Ce(mt)}destroy(){this.set(0,0,0,0,0,0,0,0),Ce(this.buffer)}},xs=class extends ps{constructor(){super(32);d(this,"A",st[0]|0);d(this,"B",st[1]|0);d(this,"C",st[2]|0);d(this,"D",st[3]|0);d(this,"E",st[4]|0);d(this,"F",st[5]|0);d(this,"G",st[6]|0);d(this,"H",st[7]|0)}};var pa=ca(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Mf=pa[0],Nf=pa[1],wt=new Uint32Array(80),Et=new Uint32Array(80),ys=class extends Gr{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:u,El:l,Fh:f,Fl:h,Gh:p,Gl:x,Hh:w,Hl:v}=this;return[e,r,n,o,s,i,c,a,u,l,f,h,p,x,w,v]}set(e,r,n,o,s,i,c,a,u,l,f,h,p,x,w,v){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=h|0,this.Gh=p|0,this.Gl=x|0,this.Hh=w|0,this.Hl=v|0}process(e,r){for(let y=0;y<16;y++,r+=4)wt[y]=e.getUint32(r),Et[y]=e.getUint32(r+=4);for(let y=16;y<80;y++){let L=wt[y-15]|0,P=Et[y-15]|0,F=Wt(L,P,1)^Wt(L,P,8)^ds(L,P,7),X=zt(L,P,1)^zt(L,P,8)^hs(L,P,7),M=wt[y-2]|0,U=Et[y-2]|0,Y=Wt(M,U,19)^Fr(M,U,61)^ds(M,U,6),ee=zt(M,U,19)^Wr(M,U,61)^hs(M,U,6),$=ua(X,ee,Et[y-7],Et[y-16]),j=la($,F,Y,wt[y-7],wt[y-16]);wt[y]=j|0,Et[y]=$|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:u,Dl:l,Eh:f,El:h,Fh:p,Fl:x,Gh:w,Gl:v,Hh:I,Hl:B}=this;for(let y=0;y<80;y++){let L=Wt(f,h,14)^Wt(f,h,18)^Fr(f,h,41),P=zt(f,h,14)^zt(f,h,18)^Wr(f,h,41),F=f&p^~f&w,X=h&x^~h&v,M=da(B,P,X,Nf[y],Et[y]),U=ha(M,I,L,F,Mf[y],wt[y]),Y=M|0,ee=Wt(n,o,28)^Fr(n,o,34)^Fr(n,o,39),$=zt(n,o,28)^Wr(n,o,34)^Wr(n,o,39),j=n&s^n&c^s&c,g=o&i^o&a^i&a;I=w|0,B=v|0,w=p|0,v=x|0,p=f|0,x=h|0,{h:f,l:h}=qe(u|0,l|0,U|0,Y|0),u=c|0,l=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let b=aa(Y,$,g);n=fa(b,U,ee,j),o=b|0}({h:n,l:o}=qe(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=qe(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=qe(this.Ch|0,this.Cl|0,c|0,a|0),{h:u,l}=qe(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:h}=qe(this.Eh|0,this.El|0,f|0,h|0),{h:p,l:x}=qe(this.Fh|0,this.Fl|0,p|0,x|0),{h:w,l:v}=qe(this.Gh|0,this.Gl|0,w|0,v|0),{h:I,l:B}=qe(this.Hh|0,this.Hl|0,I|0,B|0),this.set(n,o,s,i,c,a,u,l,f,h,p,x,w,v,I,B)}roundClean(){Ce(wt,Et)}destroy(){Ce(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},bs=class extends ys{constructor(){super(64);d(this,"Ah",le[0]|0);d(this,"Al",le[1]|0);d(this,"Bh",le[2]|0);d(this,"Bl",le[3]|0);d(this,"Ch",le[4]|0);d(this,"Cl",le[5]|0);d(this,"Dh",le[6]|0);d(this,"Dl",le[7]|0);d(this,"Eh",le[8]|0);d(this,"El",le[9]|0);d(this,"Fh",le[10]|0);d(this,"Fl",le[11]|0);d(this,"Gh",le[12]|0);d(this,"Gl",le[13]|0);d(this,"Hh",le[14]|0);d(this,"Hl",le[15]|0)}};var xa=fs(()=>new xs,us(1));var ya=fs(()=>new bs,us(3));var Pf=t=>t[0]==="\u3042\u3044\u3053\u304F\u3057\u3093";function ba(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function Vf(t){let e=ba(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}function $f(t){if(ot(t),![16,20,24,28,32].includes(t.length))throw new Error("invalid entropy length")}function ga(t,e=128){if(gt(e),e%32!==0||e>256)throw new TypeError("Invalid entropy");return Gf(ra(e/8),t)}var jf=t=>{let e=8-t.length/4;return new Uint8Array([xa(t)[0]>>e<<e])};function qf(t){if(!Array.isArray(t)||t.length!==2048||typeof t[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return t.forEach(e=>{if(typeof e!="string")throw new Error("wordlist: non-string element: "+e)}),$r.chain($r.checksum(1,jf),$r.radix2(11,!0),$r.alphabet(t))}function Gf(t,e){return $f(t),qf(e).encode(t).join(Pf(e)?"\u3000":" ")}var Ff=t=>ba("mnemonic"+t);function ma(t,e=""){return na(ya,Vf(t).nfkd,Ff(e),{c:2048,dkLen:64})}m();var wa=`abandon
|
|
1
|
+
"use strict";var LumenKeys=(()=>{var sn=Object.defineProperty;var Y0=Object.getOwnPropertyDescriptor;var X0=Object.getOwnPropertyNames;var Z0=Object.prototype.hasOwnProperty;var J0=(t,e,r)=>e in t?sn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ye=(t,e)=>()=>(t&&(e=t(t=0)),e);var yo=(t,e)=>{for(var r in e)sn(t,r,{get:e[r],enumerable:!0})},Q0=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of X0(e))!Z0.call(t,o)&&o!==r&&sn(t,o,{get:()=>e[o],enumerable:!(n=Y0(e,o))||n.enumerable});return t};var ef=t=>Q0(sn({},"__esModule",{value:!0}),t);var u=(t,e,r)=>J0(t,typeof e!="symbol"?e+"":e,r);var y=ye(()=>{"use strict";if(typeof Uint8Array.prototype.toString!="function"||!Uint8Array.prototype.toString.toString().includes("[native code]")){let t=Uint8Array.prototype.toString;Uint8Array.prototype.toString=function(e){if(e==="base64"){let r="",n=new Uint8Array(this);for(let o=0;o<n.byteLength;o++)r+=String.fromCharCode(n[o]);return btoa(r)}return t.call(this)}}typeof window>"u"&&(window.global=window)});function _f(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Lo(t,e=""){if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function Zt(t,e,r=""){let n=_f(t),o=t?.length,s=e!==void 0;if(!n||s&&o!==e){let i=r&&`"${r}" `,c=s?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+c+", got "+a)}return t}function Jt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function gn(t,e){Zt(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function rc(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Me(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function mn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Oe(t,e){return t<<32-e|t>>>e}function Uf(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Of(t){for(let e=0;e<t.length;e++)t[e]=Uf(t[e]);return t}function vr(t,e={}){let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}var If,To,kr,wn=ye(()=>{y();If=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;To=If?t=>t:Of;kr=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])})});function nc(t,e,r){return t&e^~t&r}function oc(t,e,r){return t&e^t&r^e&r}var Hr,Je,be,sc=ye(()=>{y();wn();Hr=class{constructor(e,r,n,o){u(this,"blockLen");u(this,"outputLen");u(this,"padOffset");u(this,"isLE");u(this,"buffer");u(this,"view");u(this,"finished",!1);u(this,"length",0);u(this,"pos",0);u(this,"destroyed",!1);this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=mn(this.buffer)}update(e){Jt(this),Zt(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=mn(e);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(e.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Jt(this),gn(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Me(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let h=i;h<o;h++)r[h]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let c=mn(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=a/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)c.setUint32(4*h,l[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Je=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),be=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function Rf(t,e=!1){return e?{h:Number(t&En),l:Number(t>>ic&En)}:{h:Number(t>>ic&En)|0,l:Number(t&En)|0}}function An(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=Rf(t[s],e);[n[s],o[s]]=[i,c]}return[n,o]}function Ne(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var En,ic,_o,Io,Rt,Kt,Lr,Tr,cc,ac,fc,uc,lc,dc,hc,pc,xc,yc,Uo=ye(()=>{y();En=BigInt(4294967295),ic=BigInt(32);_o=(t,e,r)=>t>>>r,Io=(t,e,r)=>t<<32-r|e>>>r,Rt=(t,e,r)=>t>>>r|e<<32-r,Kt=(t,e,r)=>t<<32-r|e>>>r,Lr=(t,e,r)=>t<<64-r|e>>>r-32,Tr=(t,e,r)=>t>>>r-32|e<<64-r,cc=(t,e,r)=>t<<r|e>>>32-r,ac=(t,e,r)=>e<<r|t>>>32-r,fc=(t,e,r)=>e<<r-32|t>>>64-r,uc=(t,e,r)=>t<<r-32|e>>>64-r;lc=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),dc=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,hc=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),pc=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,xc=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),yc=(t,e,r,n,o,s)=>e+r+n+o+s+(t/2**32|0)|0});var Cf,lt,Oo,Ro,bc,Ff,Df,dt,ht,Ko,Co,gc,mc,wc=ye(()=>{y();sc();Uo();wn();Cf=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),lt=new Uint32Array(64),Oo=class extends Hr{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[e,r,n,o,s,i,c,a]}set(e,r,n,o,s,i,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(e,r){for(let h=0;h<16;h++,r+=4)lt[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let d=lt[h-15],p=lt[h-2],x=Oe(d,7)^Oe(d,18)^d>>>3,E=Oe(p,17)^Oe(p,19)^p>>>10;lt[h]=E+lt[h-7]+x+lt[h-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:f,H:l}=this;for(let h=0;h<64;h++){let d=Oe(c,6)^Oe(c,11)^Oe(c,25),p=l+d+nc(c,a,f)+Cf[h]+lt[h]|0,E=(Oe(n,2)^Oe(n,13)^Oe(n,22))+oc(n,o,s)|0;l=f,f=a,a=c,c=i+p|0,i=s,s=o,o=n,n=p+E|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,l=l+this.H|0,this.set(n,o,s,i,c,a,f,l)}roundClean(){Me(lt)}destroy(){this.set(0,0,0,0,0,0,0,0),Me(this.buffer)}},Ro=class extends Oo{constructor(){super(32);u(this,"A",Je[0]|0);u(this,"B",Je[1]|0);u(this,"C",Je[2]|0);u(this,"D",Je[3]|0);u(this,"E",Je[4]|0);u(this,"F",Je[5]|0);u(this,"G",Je[6]|0);u(this,"H",Je[7]|0)}},bc=An(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Ff=bc[0],Df=bc[1],dt=new Uint32Array(80),ht=new Uint32Array(80),Ko=class extends Hr{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:f,El:l,Fh:h,Fl:d,Gh:p,Gl:x,Hh:E,Hl:w}=this;return[e,r,n,o,s,i,c,a,f,l,h,d,p,x,E,w]}set(e,r,n,o,s,i,c,a,f,l,h,d,p,x,E,w){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=l|0,this.Fh=h|0,this.Fl=d|0,this.Gh=p|0,this.Gl=x|0,this.Hh=E|0,this.Hl=w|0}process(e,r){for(let g=0;g<16;g++,r+=4)dt[g]=e.getUint32(r),ht[g]=e.getUint32(r+=4);for(let g=16;g<80;g++){let m=dt[g-15]|0,U=ht[g-15]|0,P=Rt(m,U,1)^Rt(m,U,8)^_o(m,U,7),X=Kt(m,U,1)^Kt(m,U,8)^Io(m,U,7),q=dt[g-2]|0,z=ht[g-2]|0,D=Rt(q,z,19)^Lr(q,z,61)^_o(q,z,6),J=Kt(q,z,19)^Tr(q,z,61)^Io(q,z,6),Z=hc(X,J,ht[g-7],ht[g-16]),ae=pc(Z,P,D,dt[g-7],dt[g-16]);dt[g]=ae|0,ht[g]=Z|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:f,Dl:l,Eh:h,El:d,Fh:p,Fl:x,Gh:E,Gl:w,Hh:H,Hl:L}=this;for(let g=0;g<80;g++){let m=Rt(h,d,14)^Rt(h,d,18)^Lr(h,d,41),U=Kt(h,d,14)^Kt(h,d,18)^Tr(h,d,41),P=h&p^~h&E,X=d&x^~d&w,q=xc(L,U,X,Df[g],ht[g]),z=yc(q,H,m,P,Ff[g],dt[g]),D=q|0,J=Rt(n,o,28)^Lr(n,o,34)^Lr(n,o,39),Z=Kt(n,o,28)^Tr(n,o,34)^Tr(n,o,39),ae=n&s^n&c^s&c,fe=o&i^o&a^i&a;H=E|0,L=w|0,E=p|0,w=x|0,p=h|0,x=d|0,{h,l:d}=Ne(f|0,l|0,z|0,D|0),f=c|0,l=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let V=lc(D,Z,fe);n=dc(V,z,J,ae),o=V|0}({h:n,l:o}=Ne(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Ne(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=Ne(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l}=Ne(this.Dh|0,this.Dl|0,f|0,l|0),{h,l:d}=Ne(this.Eh|0,this.El|0,h|0,d|0),{h:p,l:x}=Ne(this.Fh|0,this.Fl|0,p|0,x|0),{h:E,l:w}=Ne(this.Gh|0,this.Gl|0,E|0,w|0),{h:H,l:L}=Ne(this.Hh|0,this.Hl|0,H|0,L|0),this.set(n,o,s,i,c,a,f,l,h,d,p,x,E,w,H,L)}roundClean(){Me(dt,ht)}destroy(){Me(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Co=class extends Ko{constructor(){super(64);u(this,"Ah",be[0]|0);u(this,"Al",be[1]|0);u(this,"Bh",be[2]|0);u(this,"Bl",be[3]|0);u(this,"Ch",be[4]|0);u(this,"Cl",be[5]|0);u(this,"Dh",be[6]|0);u(this,"Dl",be[7]|0);u(this,"Eh",be[8]|0);u(this,"El",be[9]|0);u(this,"Fh",be[10]|0);u(this,"Fl",be[11]|0);u(this,"Gh",be[12]|0);u(this,"Gl",be[13]|0);u(this,"Hh",be[14]|0);u(this,"Hl",be[15]|0)}},gc=vr(()=>new Ro,kr(1)),mc=vr(()=>new Co,kr(3))});function qf(t,e=24){let r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let i=0;i<10;i++)r[i]=t[i]^t[i+10]^t[i+20]^t[i+30]^t[i+40];for(let i=0;i<10;i+=2){let c=(i+8)%10,a=(i+2)%10,f=r[a],l=r[a+1],h=Ec(f,l,1)^r[c],d=Ac(f,l,1)^r[c+1];for(let p=0;p<50;p+=10)t[i+p]^=h,t[i+p+1]^=d}let o=t[2],s=t[3];for(let i=0;i<24;i++){let c=Sc[i],a=Ec(o,s,c),f=Ac(o,s,c),l=Bc[i];o=t[l],s=t[l+1],t[l]=a,t[l+1]=f}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)r[c]=t[i+c];for(let c=0;c<10;c++)t[i+c]^=~r[(c+2)%10]&r[(c+4)%10]}t[0]^=Gf[n],t[1]^=zf[n]}Me(r)}var Mf,_r,Nf,jf,Pf,$f,Bc,Sc,vc,kc,Gf,zf,Ec,Ac,Fo,Wf,Hc,Lc=ye(()=>{y();Uo();wn();Mf=BigInt(0),_r=BigInt(1),Nf=BigInt(2),jf=BigInt(7),Pf=BigInt(256),$f=BigInt(113),Bc=[],Sc=[],vc=[];for(let t=0,e=_r,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],Bc.push(2*(5*n+r)),Sc.push((t+1)*(t+2)/2%64);let o=Mf;for(let s=0;s<7;s++)e=(e<<_r^(e>>jf)*$f)%Pf,e&Nf&&(o^=_r<<(_r<<BigInt(s))-_r);vc.push(o)}kc=An(vc,!0),Gf=kc[0],zf=kc[1],Ec=(t,e,r)=>r>32?fc(t,e,r):cc(t,e,r),Ac=(t,e,r)=>r>32?uc(t,e,r):ac(t,e,r);Fo=class t{constructor(e,r,n,o=!1,s=24){u(this,"state");u(this,"pos",0);u(this,"posOut",0);u(this,"finished",!1);u(this,"state32");u(this,"destroyed",!1);u(this,"blockLen");u(this,"suffix");u(this,"outputLen");u(this,"enableXOF",!1);u(this,"rounds");if(this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=o,this.rounds=s,Lo(n,"outputLen"),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=rc(this.state)}clone(){return this._cloneInto()}keccak(){To(this.state32),qf(this.state32,this.rounds),To(this.state32),this.posOut=0,this.pos=0}update(e){Jt(this),Zt(e);let{blockLen:r,state:n}=this,o=e.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let c=0;c<i;c++)n[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:r,pos:n,blockLen:o}=this;e[n]^=r,(r&128)!==0&&n===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){Jt(this,!1),Zt(e),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=e.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);e.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Lo(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gn(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Me(this.state)}_cloneInto(e){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return e||(e=new t(r,n,o,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}},Wf=(t,e,r,n={})=>vr(()=>new Fo(e,t,r),n),Hc=Wf(6,136,32,kr(8))});var Bn={};yo(Bn,{createHash:()=>Tc,default:()=>Vf});function Tc(t){let e=new Uint8Array(0),r;switch(t.toLowerCase()){case"sha256":case"sha-256":r=gc;break;case"sha512":case"sha-512":r=mc;break;case"sha3-256":r=Hc;break;default:throw new Error(`Unsupported hash algorithm: ${t}`)}return{update(n){let o=n instanceof Uint8Array?n:new Uint8Array(n),s=new Uint8Array(e.length+o.length);return s.set(e),s.set(o,e.length),e=s,this},digest(){return r(e)}}}var Vf,Sn=ye(()=>{"use strict";y();wc();Lc();Vf={createHash:Tc}});function kn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function Qe(t,e=""){if(typeof t!="number")throw new TypeError(Do(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(Do(e)+"expected integer >= 0, got "+t);return t}function je(t,e,r=""){if(kn(t)&&(e===void 0||t.length===e))return t;e!==void 0&&Qe(e,"length");let n=kn(t),o=e!==void 0?` of length ${e}`:"",s=n?`length=${t.length}`:`type=${typeof t}`,i=Do(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function Hn(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Qe(t.outputLen),Qe(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function er(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function Ln(t,e){je(t,void 0,"output");let r=e.outputLen;if(!(t.length>=r))throw new RangeError('"output" expected length >= '+r)}function Ur(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Tn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Re(t,e){return t<<32-e|t>>>e}function _n(t){if(je(t),Oc)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Zf[t[r]];return e}function Uc(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function Mo(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(Oc)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,r=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=Uc(t.charCodeAt(s)),c=Uc(t.charCodeAt(s+1));if(i===void 0||c===void 0){let a=t[s]+t[s+1];throw new RangeError('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Rc(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];je(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let s=t[n];r.set(s,o),o+=s.length}return r}function Jf(t,e,r="opts"){return Ic(t,"defaults"),e!==void 0&&Ic(e,r),Object.assign(t,e)}function Kc(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=Jf({},e,"info");let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Cc(t=32){Qe(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var Do,Ic,Oc,Zf,Fc,tr=ye(()=>{y();Do=t=>t?`"${t}" `:"";Ic=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};Oc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Zf=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));Fc=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])})});function Or(t,e,r=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let n=0;n<t.length;n++)r(t[n],`${e}[${n}]`);return t}function $c(t,e=""){if(typeof t!="string"){let r=e&&`"${e}" `;throw new TypeError(r+"expected string, got type="+typeof t)}return t}function xt(t,e="object"){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(e==="object"?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function Ct(t,e){if(typeof t!="function")throw new TypeError(`"${e}" is invalid: expected function, got ${typeof t}`);return t}function _e(t,e=""){if(typeof t!="boolean")throw new TypeError(eu(e)+"expected boolean, got type="+typeof t);return t}function Kn(t){if(typeof t=="bigint"){if(!yt(t))throw new RangeError("positive bigint expected, got "+t)}else Po(t);return t}function nr(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(r+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let r=e&&`"${e}" `;throw new RangeError(r+"expected safe integer, got "+t)}}function Rr(t){let e=Kn(t).toString(16);return e.length&1?"0"+e:e}function Gc(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?Un:BigInt("0x"+t)}function Pe(t){return Gc(_n(t))}function Go(t){return Gc(_n(tu(je(t)).reverse()))}function Cn(t,e){if(Qe(e),e===0)throw new Error("zero output length is invalid");t=Kn(t);let r=e*2,n=t.toString(16);if(n.length>r)throw new RangeError("number is too large");return Mo(n.padStart(r,"0"))}function zo(t,e){return Cn(t,e).reverse()}function tu(t){return Uint8Array.from(pe(t))}function yt(t){return typeof t=="bigint"&&Un<=t}function qo(t,e,r){return yt(t)&&yt(e)&&yt(r)&&e<=t&&t<r}function Wo(t,e,r,n){if(!qo(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function or(t){if(t<Un)throw new Error("expected non-negative bigint, got "+t);return t===Un?0:t.toString(2).length}function zc(t,e,r){if(Qe(t,"hashLen"),Qe(e,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=w=>new Uint8Array(w),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,a=n(t),f=n(t),l=0,h=()=>{a.fill(1),f.fill(0),l=0},d=(...w)=>r(f,et(a,...w)),p=(w=o)=>{f=d(s,w),a=d(),w.length!==0&&(f=d(i,w),a=d())},x=()=>{if(l++>=c)throw new Error("drbg: tried max amount of iterations");let w=0,H=[];for(;w<e;){a=d();let L=a.slice();H.push(L),w+=a.length}return et(...H)};return(w,H)=>{h(),p(w);let L;for(;(L=H(x()))===void 0;)p();return h(),L}}function $e(t,e={},r={},n="object"){xt(t,n),xt(e,"fields"),xt(r,"optFields");function o(i,c,a){let f=n==="object"?`param "${String(i)}"`:`"${n}.${String(i)}"`,l=t[i];if(!Object.hasOwn(t,i)&&(a?l!==void 0:c!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(a&&l===void 0)return;let h=typeof l;if(h!==c||l===null)throw new TypeError(`${f} is invalid: expected ${c}, got ${h}`)}let s=(i,c)=>Object.entries(i).forEach(([a,f])=>o(a,f,c));s(e,!1),s(r,!0)}var pe,Po,$o,et,On,rr,Rn,Un,Pc,eu,Kr,Ft=ye(()=>{y();tr();pe=(t,e,r)=>je(t,e,r),Po=Qe;$o=_n,et=(...t)=>Rc(...t),On=t=>Mo(t),rr=kn,Rn=t=>Cc(t),Un=BigInt(0),Pc=BigInt(1),eu=t=>t?`"${t}" `:"";Kr=t=>(nr(t,"n"),(Pc<<BigInt(t))-Pc)});function ve(t,e){if(e<=xe)throw new Error("mod: expected positive modulus, got "+e);let r=t%e;return r>=xe?r:e+r}function Qc(t,e,r){if(r<=ee)throw new Error("pow: expected modulus > 1, got "+r);if(typeof e!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof e);if(e<xe)throw new Error("invalid exponent, negatives unsupported");if(e===xe)return ee;if(e===ee)return t;let n=t%r;if(n<xe&&(n+=r),e<su){let c=ee;for(;e>xe;)e&ee&&(c=c*n%r),n=n*n%r,e>>=ee;return c}let o=[];for(;e>xe;)o.push(Number(e&ou)),e>>=Vo;let s=new Array(16);s[0]=ee,s[1]=n;for(let c=2;c<16;c++)s[c]=s[c-1]*n%r;let i=s[o[o.length-1]];for(let c=o.length-2;c>=0;c--){i=i*i%r,i=i*i%r,i=i*i%r,i=i*i%r;let a=o[c];a!==0&&(i=i*s[a]%r)}return i}function ke(t,e,r){if(r<=ee)throw new Error("pow2: expected modulus > 1, got "+r);if(e<xe)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >xe;)n*=n,n%=r;return n}function qc(t,e){if(t===xe)throw new Error("invert: expected non-zero number");if(e<=ee)throw new Error("invert: expected modulus > 1, got "+e);let r=ve(t,e),n=e,o=xe,s=ee;for(;r!==xe;){let c=n/r,a=n-r*c,f=o-s*c;n=r,r=a,o=s,s=f}if(n!==ee)throw new Error("invert: does not exist");return ve(o,e)}function ea(t,e){if(e<=ee)throw new Error("invertCt: expected prime modulus > 1, got "+e);let r=ve(t,e);if(r===xe)throw new Error("invertCt: expected non-zero number");let n=Qc(r,e-bt,e);if(ve(r*n,e)!==ee)throw new Error("invertCt: does not exist");return n}function Yo(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function Xo(t,e){if((t&ee)===xe)throw new Error(e+": expected odd modulus, got "+t)}function ta(t,e){let r=t,n=(r.ORDER+ee)/Vo,o=r.pow(e,n);return Yo(r,o,e),o}function iu(t,e){let r=t,n=(r.ORDER-Xc)/Zc,o=r.mul(e,bt),s=r.pow(o,n),i=r.mul(e,s),c=r.mul(r.mul(i,bt),s),a=r.mul(i,r.sub(c,r.ONE));return Yo(r,a,e),a}function cu(t){let e=ir(t),r=ra(t),n=r(e,e.neg(e.ONE)),o=r(e,n),s=r(e,e.neg(n)),i=(t+ru)/Jc;return((c,a)=>{let f=c,l=f.pow(a,i),h=f.mul(l,n),d=f.mul(l,o),p=f.mul(l,s),x=f.eql(f.sqr(h),a),E=f.eql(f.sqr(d),a);l=f.cmov(l,h,x),h=f.cmov(p,d,E);let w=f.eql(f.sqr(h),a),H=f.cmov(l,h,w);return Yo(f,H,a),H})}function ra(t){if(t<Yc)throw new Error("sqrt is not defined for small field");Xo(t,"tonelliShanks");let e=t-ee,r=0;for(;e%bt===xe;)e/=bt,r++;let n=bt,o=ir(t);for(;Wc(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return ta;let s=o.pow(n,e),i=(e+ee)/bt;return function(a,f){let l=a;if(l.is0(f))return f;if(Wc(l,f)!==1)throw new Error("Cannot find square root");let h=r,d=l.mul(l.ONE,s),p=l.pow(f,e),x=l.pow(f,i);for(;!l.eql(p,l.ONE);){if(l.is0(p))throw new Error("Cannot find square root: probably non-prime P");let E=1,w=l.sqr(p);for(;!l.eql(w,l.ONE);)if(E++,w=l.sqr(w),E===h)throw new Error("Cannot find square root");let H=ee<<BigInt(h-E-1),L=l.pow(d,H);h=E,d=l.sqr(L),p=l.mul(p,d),x=l.mul(x,L)}return x}}function au(t){return Xo(t,"Fp.sqrt"),t%Vo===Yc?ta:t%Zc===Xc?iu:t%Jc===nu?cu(t):ra(t)}function sr(t){if(xt(t,"field"),typeof t.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof t.ORDER);nr(t.BYTES,"BYTES"),nr(t.BITS,"BITS");for(let e of fu)Ct(t[e],"field."+e);if(t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=ee)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Zo(t,e,r=!1){sr(t),Or(e,"nums"),_e(r,"passZero");let n=t,o=new Array(e.length).fill(r?n.ZERO:void 0),s=e.reduce((c,a,f)=>n.is0(a)?c:(o[f]=c,n.mul(c,a)),n.ONE),i=n.inv(s);return e.reduceRight((c,a,f)=>n.is0(a)?c:(o[f]=n.mul(c,o[f]),n.mul(c,a)),i),o}function Wc(t,e){sr(t);let r=t;Xo(r.ORDER,"FpLegendre");let n=(r.ORDER-ee)/bt,o=r.pow(e,n),s=r.eql(o,r.ONE),i=r.eql(o,r.ZERO),c=r.eql(o,r.neg(r.ONE));if(!s&&!i&&!c)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function uu(t,e){if(e!==void 0&&Po(e),t<=xe)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let r=or(t);if(e!==void 0&&e<r)throw new Error(`invalid n length: expected nBitLength (${e}) >= bitLen(n) (${r})`);let n=e!==void 0?e:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}function ir(t,e={}){return Object.freeze(Fn.prototype),new Fn(t,e)}function na(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=ee)throw new Error("field order must be greater than 1");let e=or(t-ee);return Math.ceil(e/8)}function Dn(t){let e=na(t);return e+Math.ceil(e/2)}function Mn(t,e,r=!1){pe(t);let n=t.length,o=na(e),s=Math.max(Dn(e),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?Go(t):Pe(t),c=ve(i,e-ee)+ee;return r?zo(c,o):Cn(c,o)}var xe,ee,bt,Yc,Vo,Xc,ru,Zc,nu,ou,Jc,su,fu,Vc,Fn,Nn=ye(()=>{y();Ft();xe=BigInt(0),ee=BigInt(1),bt=BigInt(2),Yc=BigInt(3),Vo=BigInt(4),Xc=BigInt(5),ru=BigInt(7),Zc=BigInt(8),nu=BigInt(9),ou=BigInt(15),Jc=BigInt(16),su=BigInt("0x10000000000000000");fu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];Vc=new WeakMap,Fn=class{constructor(e,r={}){u(this,"ORDER");u(this,"BITS");u(this,"BYTES");u(this,"isLE");u(this,"ZERO",xe);u(this,"ONE",ee);u(this,"_lengths");u(this,"_mod");if(e<=ee)throw new Error("invalid field: expected ORDER > 1, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=uu(e,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(e){return ve(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return xe<=e&&e<this.ORDER}is0(e){return e===xe}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&ee)===ee}neg(e){return ve(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return ve(e*e,this.ORDER)}add(e,r){return ve(e+r,this.ORDER)}sub(e,r){return ve(e-r,this.ORDER)}mul(e,r){return ve(e*r,this.ORDER)}pow(e,r){return Qc(e,r,this.ORDER)}div(e,r){return ve(e*qc(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return qc(e,this.ORDER)}sqrt(e){let r=Vc.get(this);return r||Vc.set(this,r=au(this.ORDER)),r(this,e)}toBytes(e){return this.isLE?zo(e,this.BYTES):Cn(e,this.BYTES)}fromBytes(e,r=!1){pe(e);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:c}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let f=new Uint8Array(o);f.set(e,s?0:f.length-e.length),e=f}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=s?Go(e):Pe(e);if(c&&(a=ve(a,i)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(e){return Zo(this,e,!0)}cmov(e,r,n){return _e(n,"condition"),n?r:e}}});function Fr(t,e="n"){if(typeof t!="number")throw new TypeError(`wrong u32 integer "${e}": expected number, got type=${typeof t}`);if(!Number.isSafeInteger(t)||t<0||t>4294967295)throw new RangeError(`wrong u32 integer "${e}": expected 0..4294967295, got ${t}`);return t}function ha(t){return Fr(t,"x"),(t&t-1)===0&&t!==0}function rs(t,e){if(Fr(t),typeof e!="number")throw new TypeError('"bits" expected number, got type='+typeof e);if(!Number.isSafeInteger(e)||e<0||e>32)throw new Error(`expected integer 0 <= bits <= 32, got ${e}`);let r=0;for(let n=0;n<e;n++,t>>>=1)r=r<<1|t&1;return r>>>0}function pa(t){return Fr(t),31-Math.clz32(t)}function da(t){if(!t||typeof t!="object"||typeof t.length!="number")throw new TypeError('"values" expected array-like, got type='+typeof t);let e=t.length;if(!ha(e))throw new Error("expected positive power-of-two length, got "+e);let r=pa(e);for(let n=0;n<e;n++){let o=rs(n,r);if(n<o){let s=t[n];t[n]=t[o],t[o]=s}}return t}var ns,xa=ye(()=>{y();Ft();ns=(t,e)=>{$e(e,{N:"number",roots:"object",dit:"boolean"},{invertButterflies:"boolean",skipStages:"number",brp:"boolean"},"coreOpts");let{N:r,roots:n,dit:o,invertButterflies:s=!1,skipStages:i=0,brp:c=!0}=e;Fr(r,"coreOpts.N");let a=pa(r);if(!ha(r))throw new Error("FFT: Polynomial size should be power of two");Fr(i,"coreOpts.skipStages");let f=a===0?0:a-1;if(i>f)throw new Error(`FFT: wrong skipStages: expected 0 <= skipStages <= ${f}`);if(n.length!==r)throw new Error(`FFT: wrong roots length: expected ${r}, got ${n.length}`);let l=o!==s;return h=>{if(h.length!==r)throw new Error("FFT: wrong Polynomial length");o&&c&&da(h);for(let d=0,p=1;d<a-i;d++){let x=o?d+1+i:a-d,E=1<<x,w=E>>1,H=r>>x;for(let L=0;L<r;L+=E)for(let g=0,m=p++;g<w;g++){let U=s?o?r-m:m:g*H,P=L+g,X=L+g+w,q=n[U],z=h[X],D=h[P];if(l){let J=t.mul(z,q);h[P]=t.add(D,J),h[X]=t.sub(D,J)}else s?(h[P]=t.add(z,D),h[X]=t.mul(t.sub(z,D),q)):(h[P]=t.add(D,z),h[X]=t.mul(t.sub(D,z),q))}}return!o&&c&&da(h),h}}});function wl(t,e=!1){return e?{h:Number(t&eo),l:Number(t>>B0&eo)}:{h:Number(t>>B0&eo)|0,l:Number(t&eo)|0}}function S0(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=wl(t[s],e);[n[s],o[s]]=[i,c]}return[n,o]}var eo,B0,v0=ye(()=>{y();eo=BigInt(4294967295),B0=BigInt(32)});function to(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function we(t,e=""){if(typeof t!="number")throw new TypeError(ro(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(ro(e)+"expected integer >= 0, got "+t);return t}function H0(t,e=""){if(typeof t!="boolean")throw new TypeError(ro(e)+"expected boolean, got type="+typeof t);return t}function he(t,e,r=""){if(to(t)&&(e===void 0||t.length===e))return t;e!==void 0&&we(e,"length");let n=to(t),o=e!==void 0?` of length ${e}`:"",s=n?`length=${t.length}`:`type=${typeof t}`,i=ro(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function L0(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(we(t.outputLen),we(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function Gs(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function T0(t,e){he(t,void 0,"output");let r=e.outputLen;if(!(t.length>=r))throw new RangeError('"output" expected length >= '+r)}function zs(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function qs(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function El(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Al(t){for(let e=0;e<t.length;e++)t[e]=El(t[e]);return t}function Vs(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];he(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let s=t[n];r.set(s,o),o+=s.length}return r}function Ys(t,e,r="opts"){return k0(t,"defaults"),e!==void 0&&k0(e,r),Object.assign(t,e)}function I0(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=Ys({},e,"info");let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function U0(t=32){we(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var ro,k0,_0,Ws,Xs,Zs=ye(()=>{y();ro=t=>t?`"${t}" `:"";k0=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};_0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Ws=_0?t=>t:Al;Xs=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])})});function Rl(t,e=24){if(!(t instanceof Uint32Array))throw new TypeError('"s" expected Uint32Array(50), got type='+typeof t);if(t.length!==50)throw new RangeError('"s" expected Uint32Array(50), got length='+t.length);if(we(e,"rounds"),e<1||e>24)throw new Error('"rounds" expected integer 1..24');for(let r=24-e;r<24;r++){for(let s=0;s<10;s++)pr[s]=t[s]^t[s+10]^t[s+20]^t[s+30]^t[s+40];for(let s=0;s<10;s+=2){let i=(s+8)%10,c=(s+2)%10,a=pr[c],f=pr[c+1],l=O0(a,f,1)^pr[i],h=R0(a,f,1)^pr[i+1];for(let d=0;d<50;d+=10)t[s+d]^=l,t[s+d+1]^=h}let n=t[2],o=t[3];for(let s=0;s<24;s++){let i=C0[s],c=O0(n,o,i),a=R0(n,o,i),f=K0[s];n=t[f],o=t[f+1],t[f]=c,t[f+1]=a}for(let s=0;s<50;s+=10){let i=t[s],c=t[s+1],a=t[s+2],f=t[s+3];t[s]^=~t[s+2]&t[s+4],t[s+1]^=~t[s+3]&t[s+5],t[s+2]^=~t[s+4]&t[s+6],t[s+3]^=~t[s+5]&t[s+7],t[s+4]^=~t[s+6]&t[s+8],t[s+5]^=~t[s+7]&t[s+9],t[s+6]^=~t[s+8]&i,t[s+7]^=~t[s+9]&c,t[s+8]^=~i&a,t[s+9]^=~c&f}t[0]^=Ll[r],t[1]^=Tl[r]}qs(pr)}var Bl,Vr,Sl,vl,kl,Hl,K0,C0,F0,D0,Ll,Tl,_l,Il,Ul,Ol,O0,R0,pr,Js,M0,N0,Ee,Qs=ye(()=>{y();v0();Zs();Bl=BigInt(0),Vr=BigInt(1),Sl=BigInt(2),vl=BigInt(7),kl=BigInt(256),Hl=BigInt(113),K0=[],C0=[],F0=[];for(let t=0,e=Vr,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],K0.push(2*(5*n+r)),C0.push((t+1)*(t+2)/2%64);let o=Bl;for(let s=0;s<7;s++)e=(e<<Vr^(e>>vl)*Hl)%kl,e&Sl&&(o^=Vr<<(Vr<<BigInt(s))-Vr);F0.push(o)}D0=S0(F0,!0),Ll=D0[0],Tl=D0[1],_l=(t,e,r)=>t<<r|e>>>32-r,Il=(t,e,r)=>e<<r|t>>>32-r,Ul=(t,e,r)=>e<<r-32|t>>>64-r,Ol=(t,e,r)=>t<<r-32|e>>>64-r,O0=(t,e,r)=>r>32?Ul(t,e,r):_l(t,e,r),R0=(t,e,r)=>r>32?Ol(t,e,r):Il(t,e,r),pr=new Uint32Array(10);Js=class t{constructor(e,r,n,o=!1,s=24){u(this,"state");u(this,"pos",0);u(this,"posOut",0);u(this,"finished",!1);u(this,"state32");u(this,"destroyed",!1);u(this,"blockLen");u(this,"suffix");u(this,"outputLen");u(this,"canXOF");u(this,"enableXOF",!1);u(this,"rounds");if(we(e,"blockLen"),we(r,"suffix"),we(s,"rounds"),H0(o,"enableXOF"),this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=o,this.canXOF=o,this.rounds=s,we(n,"outputLen"),!(0<e&&e<200))throw new Error('"blockLen" must be 1..199');this.state=new Uint8Array(200),this.state32=zs(this.state)}clone(){return this._cloneInto()}keccak(){Ws(this.state32),Rl(this.state32,this.rounds),Ws(this.state32),this.posOut=0,this.pos=0}update(e){Gs(this),he(e);let{blockLen:r,state:n,state32:o}=this,s=e.length,i=r%4===0&&e.byteOffset%4===0,c=r/4,a=i&&s>=r?zs(e):void 0;for(let f=0;f<s;){if(a!==void 0&&this.pos===0&&f%4===0&&s-f>=r){for(let h=0,d=f/4;h<c;h++)o[h]^=a[d+h];f+=r,this.pos=r,this.keccak();continue}let l=Math.min(r-this.pos,s-f);for(let h=0;h<l;h++)n[this.pos++]^=e[f++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:r,pos:n,blockLen:o}=this;e[n]^=r,(r&128)!==0&&n===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){Gs(this,!1),he(e),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=e.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);e.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not enabled");return this.writeInto(e)}xof(e){return we(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(T0(e,this),this.finished)throw new Error("digest() was already called");this.writeInto(e.length===this.outputLen?e:e.subarray(0,this.outputLen)),this.destroy()}digest(){let e=new Uint8Array(this.outputLen);return this.digestInto(e),e}destroy(){this.destroyed=!0,qs(this.state)}_cloneInto(e){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return e||(e=new t(r,n,o,i,s)),e.blockLen=r,e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=o,e.enableXOF=i,e.canXOF=this.canXOF,e.destroyed=this.destroyed,e}},M0=(t,e,r,n={})=>I0((o={})=>(o=Ys({},o),new Js(e,t,o.dkLen===void 0?r:o.dkLen,!0)),n),N0=M0(31,168,16,Xs(11)),Ee=M0(31,136,32,Xs(12))});function Kl(t,e,r=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let n=0;n<t.length;n++)r(t[n],`${e}[${n}]`);return t}function Cl(t,e="object"){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(e==="object"?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function ti(t,e){if(t=he(t),e=he(e),t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function ri(t){if(to(t))throw new TypeError('"opts" expected object, got Uint8Array');Cl(t,"opts")}function no(t){ri(t),t.context!==void 0&&he(t.context,void 0,"opts.context")}function oo(t){no(t),t.extraEntropy!==!1&&t.extraEntropy!==void 0&&he(t.extraEntropy,void 0,"opts.extraEntropy")}function Yr(t,...e){let r=o=>typeof o=="number"?o:o.bytesLen,n=e.reduce((o,s)=>o+r(s),0);return{bytesLen:n,encode:o=>{let s=new Uint8Array(n);for(let i=0,c=0;i<e.length;i++){let a=e[i],f=r(a),l=typeof a=="number"?o[i]:a.encode(o[i]);he(l,f,t),s.set(l,c),typeof a!="number"&&l.fill(0),c+=f}return s},decode:o=>{he(o,n,t);let s=[];for(let i of e){let c=r(i),a=o.subarray(0,c);s.push(typeof i=="number"?a:i.decode(a)),o=o.subarray(c)}return s}}}function Gt(t,e){let r=t,n=e*r.bytesLen;return{bytesLen:n,encode:o=>{let s=Kl(o,"u");if(s.length!==e)throw new RangeError(`vecCoder.encode: wrong length=${s.length}. Expected: ${e}`);let i=new Uint8Array(n);for(let c=0,a=0;c<s.length;c++){let f=r.encode(s[c]);i.set(f,a),f.fill(0),a+=f.length}return i},decode:o=>{he(o,n);let s=[];for(let i=0;i<o.length;i+=r.bytesLen)s.push(r.decode(o.subarray(i,i+r.bytesLen)));return s}}}function Le(...t){for(let e of t)if(Array.isArray(e))for(let r of e)r.fill(0);else e.fill(0)}function ni(t){if(we(t,"bits"),t>32)throw new RangeError('"bits" expected <= 32, got '+t);return t===32?4294967295:~(-1<<t)>>>0}function oi(t,e=j0){if(he(t,void 0,"msg"),he(e,void 0,"ctx"),e.length>255)throw new RangeError("context should be 255 bytes or less");return Vs(new Uint8Array([0,e.length]),e,t)}function si(t,e=0){if(typeof t!="function"||typeof t.create!="function")throw new TypeError('"hash" expected hash function, got type='+typeof t);L0(t),we(e,"requiredStrength");let r=t.oid;if(he(r,void 0,"hash.oid"),!ti(r.subarray(0,10),Fl))throw new Error('"hash.oid" is invalid: expected NIST hash');let n=t.outputLen*8/2;if(e>n)throw new Error("Pre-hash security strength too low: "+n+", required: "+e)}function ii(t,e,r=j0){if(si(t),he(e,void 0,"msg"),he(r,void 0,"ctx"),r.length>255)throw new RangeError("context should be 255 bytes or less");let n=t(e);return Vs(new Uint8Array([1,r.length]),r,t.oid,n)}var kt,ei,j0,Fl,ci=ye(()=>{y();Zs();kt=he,ei=U0;j0=Uint8Array.of();Fl=Uint8Array.from([6,9,96,134,72,1,101,3,4,2])});var P0,$0,so,io,G0=ye(()=>{y();xa();Qs();ci();P0=t=>{let{newPoly:e,N:r,Q:n,F:o,ROOT_OF_UNITY:s,brvBits:i,isKyber:c}=t,a=(g,m=n)=>{let U=g%m|0;return(U>=0?U|0:m+U|0)|0},f=(g,m=n)=>{let U=a(g,m)|0;return(U>m>>1?U-m|0:U)|0};function l(){let g=e(r);for(let m=0;m<r;m++){let U=rs(m,i),P=BigInt(s)**BigInt(U)%BigInt(n);g[m]=Number(P)|0}return g}let h=l(),d=g=>{throw new Error("not implemented")},p=c?{add:(g,m)=>{let U=g+m|0;return U>=n?U-n|0:U},sub:(g,m)=>{let U=g-m|0;return U<0?U+n|0:U},mul:(g,m)=>a((g|0)*(m|0))|0,inv:d}:{add:(g,m)=>a((g|0)+(m|0))|0,sub:(g,m)=>a((g|0)-(m|0))|0,mul:(g,m)=>a((g|0)*(m|0))|0,inv:d},x={N:r,roots:h,invertButterflies:!0,skipStages:c?1:0,brp:!1},E=ns(p,{dit:!1,...x}),w=ns(p,{dit:!0,...x}),H={encode:g=>E(g),decode:g=>{w(g);for(let m=0;m<g.length;m++)g[m]=a(o*g[m]);return g}};return{mod:a,smod:f,nttZetas:h,NTT:{encode:g=>H.encode(g),decode:g=>H.decode(g)},bitsCoder:(g,m)=>{for(let X=0,q=0;X<r;X++)q+=g,q>32&&ni(q),q%=8;let U=ni(g),P=g*(r/8);return{bytesLen:P,encode:X=>{let q=X,z=new Uint8Array(P);for(let D=0,J=0,Z=0,ae=0;D<q.length;D++)for(J|=(m.encode(q[D])&U)<<Z,Z+=g;Z>=8;Z-=8,J>>=8)z[ae++]=J&255;return z},decode:X=>{let q=e(r);for(let z=0,D=0,J=0,Z=0;z<X.length;z++)for(D|=X[z]<<J,J+=8;J>=g;J-=g,D>>=g)q[Z++]=m.decode(D&U);return q}}}}},$0=t=>(e,r)=>{r||(r=t.blockLen);let n=new Uint8Array(e.length+2);n.set(e);let o=e.length,s=new Uint8Array(r),i=t.create({}),c=0,a=0;return{stats:()=>({calls:c,xofs:a}),get:(f,l)=>(n[o+0]=f,n[o+1]=l,i.destroy(),i=t.create({}).update(n),c++,()=>(a++,i.xofInto(s))),clean:()=>{i.destroy(),Le(s,n)}}},so=$0(N0),io=$0(Ee)});var fo={};yo(fo,{PARAMS:()=>ao,ml_dsa44:()=>jl,ml_dsa65:()=>Pl,ml_dsa87:()=>$l});function z0(t){ri(t),t.externalMu!==void 0&&_e(t.externalMu,"opts.externalMu")}function co(t){let e=t,r=Te(ce);for(let n=0;n<ce;){let o=e();if(o.length%3)throw new Error("RejNTTPoly: unaligned block");for(let s=0;n<ce&&s<=o.length-3;s+=3){let i=(o[s+0]|o[s+1]<<8|o[s+2]<<16)&8388607;i<Tt&&(r[n++]=i)}}return r}function ui(t){let e=t,{K:r,L:n,GAMMA1:o,GAMMA2:s,TAU:i,ETA:c,OMEGA:a}=e,{CRH_BYTES:f,TR_BYTES:l,C_TILDE_BYTES:h,XOF128:d,XOF256:p,securityLevel:x}=e;if(![2,4].includes(c))throw new Error("Wrong ETA");if(![1<<17,1<<19].includes(o))throw new Error("Wrong GAMMA1");if(![ai,fi].includes(s))throw new Error("Wrong GAMMA2");let E=i*c,w=b=>{let B=Q.mod(b),S=Q.smod(B,2*s)|0;return B-S===Tt-1?{r1:0,r0:S-1|0}:{r1:Math.floor((B-S)/(2*s))|0,r0:S}},H=b=>w(b).r1,L=b=>w(b).r0,g=(b,B)=>b<=s||b>Tt-s||b===Tt-s&&B===0?0:1,m=Math.floor((Tt-1)/(2*s)),U=(b,B)=>{let{r1:S,r0:v}=w(B);return b===1?v>0?Q.mod(S+1,m)|0:Q.mod(S-1,m)|0:S|0},P=b=>{let B=Q.mod(b),S=Q.smod(B,2**zt)|0;return{r1:Math.floor((B-S)/2**zt)|0,r0:S}},X={bytesLen:a+r,encode:b=>{let B=b;if(B===!1)throw new Error("hint.encode: hint is false");let S=new Uint8Array(a+r);for(let v=0,R=0;v<r;v++){for(let I=0;I<ce;I++)B[v][I]!==0&&(S[R++]=I);S[a+v]=R}return S},decode:b=>{let B=[],S=0;for(let v=0;v<r;v++){let R=Te(ce);if(b[a+v]<S||b[a+v]>a)return!1;for(let I=S;I<b[a+v];I++){if(I>S&&b[I]<=b[I-1])return!1;R[b[I]]=1}S=b[a+v],B.push(R)}for(let v=S;v<a;v++)if(b[v]!==0)return!1;return B}},q=Xr(c===2?3:4,b=>c-b,b=>{if(!(-c<=b&&b<=c))throw new Error(`malformed key s1/s3 ${b} outside of ETA range [${-c}, ${c}]`);return b}),z=Xr(13,b=>(1<<zt-1)-b),D=Xr(10),J=Xr(o===1<<17?18:20,b=>Q.smod(o-b)),Z=Xr(s===ai?6:4),ae=Gt(Z,r),fe=Yr("publicKey",32,Gt(D,r)),V=Yr("secretKey",32,32,l,Gt(q,n),Gt(q,r),Gt(z,r)),Y=Yr("signature",h,Gt(J,n),X),k=c===2?b=>b<15?2-b%5:!1:b=>b<9?4-b:!1;function O(b){let B=b,S=Te(ce);for(let v=0;v<ce;){let R=B();for(let I=0;v<ce&&I<R.length;I+=1){let G=k(R[I]&15),te=k(R[I]>>4&15);G!==!1&&(S[v++]=G),v<ce&&te!==!1&&(S[v++]=te)}}return S}let N=b=>{let B=Te(ce),S=Ee.create({}).update(b),v=new Uint8Array(Ee.blockLen);S.xofInto(v);let R=v.slice(0,8);for(let I=ce-i,G=8,te=0,le=0;I<ce;I++){let oe=I+1;for(;oe>I;)oe=v[G++],!(G<Ee.blockLen)&&(S.xofInto(v),G=0);B[I]=B[oe],B[oe]=1-((R[te]>>le++&1)<<1),le>=8&&(te++,le=0)}return B},_=b=>{let B=b,S=Te(ce),v=Te(ce);for(let R=0;R<B.length;R++){let{r0:I,r1:G}=P(B[R]);S[R]=I,v[R]=G}return{r0:S,r1:v}},A=(b,B)=>{let S=b,v=B;for(let R=0;R<ce;R++)S[R]=U(v[R],S[R]);return S},T=(b,B)=>{let S=b,v=B,R=Te(ce),I=0;for(let G=0;G<ce;G++){let te=g(S[G],v[G]);R[G]=te,I+=te}return{v:R,cnt:I}},M=32,j=Yr("seed",32,64,32),$=Object.freeze({info:Object.freeze({type:"internal-ml-dsa"}),lengths:Object.freeze({secretKey:V.bytesLen,publicKey:fe.bytesLen,seed:32,signature:Y.bytesLen,signRand:M}),keygen:b=>{let B=new Uint8Array(34),S=b===void 0;S&&(b=ei(32)),kt(b,32,"seed"),B.set(b),S&&Le(b),B[32]=r,B[33]=n;let[v,R,I]=j.decode(Ee(B,{dkLen:j.bytesLen})),G=p(R),te=[];for(let W=0;W<n;W++)te.push(O(G.get(W&255,W>>8&255)));let le=[];for(let W=n;W<n+r;W++)le.push(O(G.get(W&255,W>>8&255)));let oe=te.map(W=>Q.NTT.encode(W.slice())),re=[],de=[],Ae=d(v),ue=Te(ce);for(let W=0;W<r;W++){Le(ue);for(let ge=0;ge<n;ge++){let Se=co(Ae.get(ge,W));Ht(ue,Lt(Se,oe[ge]))}Q.NTT.decode(ue);let{r0:It,r1:se}=_(Ht(ue,le[W]));re.push(It),de.push(se)}let Be=fe.encode([v,de]),Fe=Ee(Be,{dkLen:l}),Ye=V.encode([v,I,Fe,te,le,re]);return Ae.clean(),G.clean(),Le(v,R,I,te,le,oe,ue,re,de,Fe,B),{publicKey:Be,secretKey:Ye}},getPublicKey:b=>{let[B,S,v,R,I,G]=V.decode(b),te=d(B),le=R.map(de=>Q.NTT.encode(de.slice())),oe=[],re=Te(ce);for(let de=0;de<r;de++){re.fill(0);for(let ue=0;ue<n;ue++){let Be=co(te.get(ue,de));Ht(re,Lt(Be,le[ue]))}Q.NTT.decode(re),Ht(re,I[de]);let{r1:Ae}=_(re);oe.push(Ae)}return te.clean(),Le(re,le,G,R,I),fe.encode([B,oe])},sign:(b,B,S={})=>{oo(S),z0(S);let{extraEntropy:v,externalMu:R=!1}=S;R&&kt(b,f,"mu");let I=v===!1||v===void 0,G=v===!1?new Uint8Array(32):v===void 0?ei(M):v;kt(G,32,"extraEntropy");let te=(()=>{try{return V.decode(B)}catch(se){throw I&&Le(G),se}})(),[le,oe,re,de,Ae,ue]=te,Be=[],Fe=d(le);for(let se=0;se<r;se++){let ge=[];for(let Se=0;Se<n;Se++)ge.push(co(Fe.get(Se,se)));Be.push(ge)}Fe.clean();for(let se=0;se<n;se++)Q.NTT.encode(de[se]);for(let se=0;se<r;se++)Q.NTT.encode(Ae[se]),Q.NTT.encode(ue[se]);let Ye=R?b:Ee.create({dkLen:f}).update(re).update(b).digest(),W=Ee.create({dkLen:f}).update(oe).update(G).update(Ye).digest();I&&Le(G),kt(W,f);let It=p(W,J.bytesLen);e:for(let se=0;;){let ge=[];for(let ie=0;ie<n;ie++,se++)ge.push(J.decode(It.get(se&255,se>>8)()));let Se=ge.map(ie=>Q.NTT.encode(ie.slice())),Wt=[];for(let ie=0;ie<r;ie++){let yr=Te(ce);for(let ot=0;ot<n;ot++)Ht(yr,Lt(Be[ie][ot],Se[ot]));Q.NTT.decode(yr),Wt.push(yr)}let ho=Wt.map(ie=>ie.map(H)),po=Ee.create({dkLen:h}).update(Ye).update(ae.encode(ho)).digest(),nn=Q.NTT.encode(N(po)),on=de.map(ie=>Lt(ie,nn));for(let ie=0;ie<n;ie++)if(Ht(Q.NTT.decode(on[ie]),ge[ie]),Zr(on[ie],o-E))continue e;let yi=0,xo=[];for(let ie=0;ie<r;ie++){let yr=Q.NTT.decode(Lt(Ae[ie],nn)),ot=W0(Wt[ie],yr).map(L);if(Zr(ot,s-E))continue e;let bi=Q.NTT.decode(Lt(ue[ie],nn));if(Zr(bi,s))continue e;Ht(ot,bi);let gi=T(ot,ho[ie]);xo.push(gi.v),yi+=gi.cnt}if(yi>a)continue;It.clean();let V0=Y.encode([po,on,xo]);return Le(po,on,xo,nn,ho,Wt,Se,ge,W,de,Ae,ue,...Be),R||Le(Ye),V0}throw new Error("Unreachable code path reached, report this error")},verify:(b,B,S,v={})=>{z0(v);let{externalMu:R=!1}=v;R&&kt(B,f,"mu");let[I,G]=fe.decode(S),te=Ee(S,{dkLen:l});if(b.length!==Y.bytesLen)return!1;let[le,oe,re]=Y.decode(b);if(re===!1)return!1;for(let W=0;W<n;W++)if(Zr(oe[W],o-E))return!1;let de=R?B:Ee.create({dkLen:f}).update(te).update(B).digest(),Ae=Q.NTT.encode(N(le)),ue=oe.map(W=>W.slice());for(let W=0;W<n;W++)Q.NTT.encode(ue[W]);let Be=[],Fe=d(I);for(let W=0;W<r;W++){let It=Lt(Q.NTT.encode(Nl(G[W])),Ae),se=Te(ce);for(let Se=0;Se<n;Se++){let Wt=co(Fe.get(Se,W));Ht(se,Lt(Wt,ue[Se]))}let ge=Q.NTT.decode(W0(se,It));Be.push(A(ge,re[W]))}Fe.clean();let Ye=Ee.create({dkLen:h}).update(de).update(ae.encode(Be)).digest();for(let W of re)if(!(W.reduce((se,ge)=>se+ge,0)<=a))return!1;for(let W of oe)if(Zr(W,o-E))return!1;return ti(le,Ye)}});return Object.freeze({info:Object.freeze({type:"ml-dsa"}),internal:$,securityLevel:x,keygen:$.keygen,lengths:$.lengths,getPublicKey:$.getPublicKey,sign:(b,B,S={})=>{oo(S);let v=oi(b,S.context),R=$.sign(v,B,S);return Le(v),R},verify:(b,B,S,v={})=>(no(v),kt(b,void 0,"signature"),$.verify(b,oi(B,v.context),S)),prehash:b=>{si(b,x);let B=b;return Object.freeze({info:Object.freeze({type:"hashml-dsa"}),securityLevel:x,lengths:$.lengths,keygen:$.keygen,getPublicKey:$.getPublicKey,sign:(S,v,R={})=>{oo(R);let I=ii(B,S,R.context),G=$.sign(I,v,R);return Le(I),G},verify:(S,v,R,I={})=>(no(I),kt(S,void 0,"signature"),$.verify(S,ii(B,v,I.context),R))})}})}var ce,Tt,Dl,Ml,zt,ai,fi,ao,Te,Q,q0,Xr,Ht,W0,Nl,Zr,Lt,jl,Pl,$l,uo=ye(()=>{y();Ft();Qs();G0();ci();ce=256,Tt=8380417,Dl=1753,Ml=8347681,zt=13,ai=Math.floor((Tt-1)/88)|0,fi=Math.floor((Tt-1)/32)|0,ao=Object.freeze({2:Object.freeze({K:4,L:4,D:zt,GAMMA1:2**17,GAMMA2:ai,TAU:39,ETA:2,OMEGA:80}),3:Object.freeze({K:6,L:5,D:zt,GAMMA1:2**19,GAMMA2:fi,TAU:49,ETA:4,OMEGA:55}),5:Object.freeze({K:8,L:7,D:zt,GAMMA1:2**19,GAMMA2:fi,TAU:60,ETA:2,OMEGA:75})}),Te=t=>new Int32Array(t),Q=P0({N:ce,Q:Tt,F:Ml,ROOT_OF_UNITY:Dl,newPoly:Te,isKyber:!1,brvBits:8}),q0=t=>t,Xr=(t,e=q0,r=q0)=>Q.bitsCoder(t,{encode:n=>e(r(n)),decode:n=>r(e(n))}),Ht=(t,e)=>{let r=t,n=e;for(let o=0;o<r.length;o++)r[o]=Q.mod(r[o]+n[o]);return r},W0=(t,e)=>{let r=t,n=e;for(let o=0;o<r.length;o++)r[o]=Q.mod(r[o]-n[o]);return r},Nl=t=>{let e=t;for(let r=0;r<ce;r++)e[r]<<=zt;return e},Zr=(t,e)=>{let r=t;for(let n=0;n<ce;n++)if(Math.abs(Q.smod(r[n]))>=e)return!0;return!1},Lt=(t,e)=>{let r=t,n=e,o=Te(ce);for(let s=0;s<r.length;s++)o[s]=Q.mod(r[s]*n[s]);return o};jl=ui({...ao[2],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:32,XOF128:so,XOF256:io,securityLevel:128}),Pl=ui({...ao[3],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:48,XOF128:so,XOF256:io,securityLevel:192}),$l=ui({...ao[5],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:64,XOF128:so,XOF256:io,securityLevel:256})});var Vl={};yo(Vl,{InMemoryKeyStorage:()=>_t,createKeySDK:()=>xi,default:()=>Wl});y();y();y();y();y();y();y();var ki=Object.freeze({p:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,n:0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,h:1n,a:0n,b:7n,Gx:0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Gy:0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n}),{p:Ot,n:it,Gx:tf,Gy:rf,b:Hi}=ki,me=32,br=64,gr={publicKey:me+1,publicKeyUncompressed:br+1,signature:br,seed:me+me/2},ne=(t="",e=Error)=>{let r=new e(t),{captureStackTrace:n}=Error;throw typeof n=="function"&&n(r,ne),r},nf=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&t.BYTES_PER_ELEMENT===1,Ie=(t,e,r="")=>{let n=nf(t),o=t?.length,s=e!==void 0;if(!n||s&&o!==e){let i=r&&`"${r}" `,c=s?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`,f=i+"expected Uint8Array"+c+", got "+a;return n?ne(f,RangeError):ne(f,TypeError)}return t},ct=t=>new Uint8Array(t),Li=(t,e)=>t.toString(16).padStart(e,"0"),Ti=t=>{let e="";for(let r of Ie(t))e+=Li(r,2);return e},Xe={_0:48,_9:57,A:65,F:70,a:97,f:102},mi=t=>t>=Xe._0&&t<=Xe._9?t-Xe._0:t>=Xe.A&&t<=Xe.F?t-(Xe.A-10):t>=Xe.a&&t<=Xe.f?t-(Xe.a-10):void 0,_i=t=>{let e="hex invalid";if(typeof t!="string")return ne(e);let r=t.length,n=r/2;if(r%2)return ne(e);let o=ct(n);for(let s=0,i=0;s<n;s++,i+=2){let c=mi(t.charCodeAt(i)),a=mi(t.charCodeAt(i+1));if(c===void 0||a===void 0)return ne(e);o[s]=c*16+a}return o},wi=()=>globalThis?.crypto?.subtle??ne("crypto.subtle must be defined, consider polyfill"),Vt=(...t)=>{let e=0;for(let o of t)e+=Ie(o).length;let r=ct(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r},Ii=(t=me)=>(globalThis?.crypto).getRandomValues(ct(t)),an=BigInt,Er=(t,e,r,n="bad number: out of range")=>typeof t!="bigint"?ne(n,TypeError):e<=t&&t<r?t:ne(n,RangeError),F=(t,e=Ot)=>{let r=t%e;return r>=0n?r:e+r},st=t=>F(t,it),wo=(t,e)=>{(t===0n||e<=0n)&&ne("no inverse n="+t+" mod="+e);let r=F(t,e),n=e,o=0n,s=1n,i=1n,c=0n;for(;r!==0n;){let a=n/r,f=n%r,l=o-i*a,h=s-c*a;n=r,r=f,o=i,s=c,i=l,c=h}return n===1n?F(o,e):ne("no inverse")},Ui=t=>{let e=hn[t];return typeof e!="function"&&ne("hashes."+t+" not set"),e},Oi=(t,e,r)=>Ie(Ui(t)(e,r),me,"digest"),of=(t,e,r)=>Promise.resolve(Ui(t)(e,r)).then(n=>Ie(n,me,"digest"));var bo=t=>t instanceof Ze?t:ne("Point expected"),Ri=t=>F(F(t*t)*t+Hi),Ei=t=>Er(t,0n,Ot),cn=t=>Er(t,1n,Ot),go=t=>Er(t,1n,it),Ki=t=>!(t&1n),Ar=t=>Uint8Array.of(t),sf=t=>Ar(Ki(t)?2:3),cf=t=>{let e=Ri(cn(t)),r=1n;for(let n=e,o=(Ot+1n)/4n;o>0n;o>>=1n)o&1n&&(r=r*n%Ot),n=n*n%Ot;return F(r*r)!==e&&ne("sqrt invalid"),Ki(r)?r:F(-r)};var De=class De{constructor(e,r,n){u(this,"X");u(this,"Y");u(this,"Z");this.X=Ei(e),this.Y=cn(r),this.Z=Ei(n),Object.freeze(this)}static CURVE(){return ki}static fromAffine(e){let{x:r,y:n}=e;return r===0n&&n===0n?Ut:new De(r,n,1n)}static fromBytes(e){Ie(e);let{publicKey:r,publicKeyUncompressed:n}=gr,o,s=e.length,i=e[0],c=e.subarray(1),a=fn(c,0,me);if(s===r&&(i===2||i===3)){let f=cf(a);i===3&&(f=F(-f)),o=new De(a,f,1n)}return s===n&&i===4&&(o=new De(a,fn(c,me,br),1n)),o?o.assertValidity():ne("bad point: not on curve")}static fromHex(e){return De.fromBytes(_i(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(e){let{X:r,Y:n,Z:o}=this,{X:s,Y:i,Z:c}=bo(e),a=F(r*c),f=F(s*o),l=F(n*c),h=F(i*o);return a===f&&l===h}is0(){return this.equals(Ut)}negate(){return new De(this.X,F(-this.Y),this.Z)}double(){return this.add(this)}add(e){let{X:r,Y:n,Z:o}=this,{X:s,Y:i,Z:c}=bo(e),a=0n,f=Hi,l=0n,h=0n,d=0n,p=F(f*3n),x=F(r*s),E=F(n*i),w=F(o*c),H=F(r+n),L=F(s+i);H=F(H*L),L=F(x+E),H=F(H-L),L=F(r+o);let g=F(s+c);return L=F(L*g),g=F(x+w),L=F(L-g),g=F(n+o),l=F(i+c),g=F(g*l),l=F(E+w),g=F(g-l),d=F(a*L),l=F(p*w),d=F(l+d),l=F(E-d),d=F(E+d),h=F(l*d),E=F(x+x),E=F(E+x),w=F(a*w),L=F(p*L),E=F(E+w),w=F(x-w),w=F(a*w),L=F(L+w),x=F(E*L),h=F(h+x),x=F(g*L),l=F(H*l),l=F(l-x),x=F(H*E),d=F(g*d),d=F(d+x),new De(l,h,d)}subtract(e){return this.add(bo(e).negate())}multiply(e,r=!0){if(!r&&e===0n)return Ut;if(go(e),e===1n)return this;if(this.equals(at))return Sf(e).p;let n=Ut,o=at;for(let s=this;e>0n;s=s.double(),e>>=1n)e&1n?n=n.add(s):r&&(o=o.add(s));return n}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){let{X:e,Y:r,Z:n}=this;if(this.equals(Ut))return{x:0n,y:0n};if(n===1n)return{x:e,y:r};let o=wo(n,Ot);return F(n*o)!==1n&&ne("inverse invalid"),{x:F(e*o),y:F(r*o)}}assertValidity(){let{x:e,y:r}=this.toAffine();return cn(e),cn(r),F(r*r)===Ri(e)?this:ne("bad point: not on curve")}toBytes(e=!0){let{x:r,y:n}=this.assertValidity().toAffine(),o=Yt(r);return e?Vt(sf(n),o):Vt(Ar(4),o,Yt(n))}toHex(e){return Ti(this.toBytes(e))}};u(De,"BASE"),u(De,"ZERO");var Ze=De,at=new Ze(tf,rf,1n),Ut=new Ze(0n,1n,0n);Ze.BASE=at;Ze.ZERO=Ut;var af=(t,e,r)=>at.multiply(e,!1).add(t.multiply(r,!1)).assertValidity(),dn=t=>an("0x"+(Ti(t)||"0")),fn=(t,e,r)=>dn(t.subarray(e,r)),ff=2n**256n,Yt=t=>_i(Li(Er(t,0n,ff),br)),Eo=t=>{let e=dn(Ie(t,me,"secret key"));return Er(e,1n,it,"invalid secret key: outside of range")},Ao=t=>t>it>>1n,Ci=(t,e=!0)=>at.multiply(Eo(t)).toBytes(e),uf=t=>{try{return!!Eo(t)}catch{return!1}},lf=(t,e)=>{let{publicKey:r,publicKeyUncompressed:n}=gr;try{let o=t.length;return e===!0&&o!==r||e===!1&&o!==n?!1:!!Ze.fromBytes(t)}catch{return!1}},Ai=t=>[0,1,2,3].includes(t)?t:ne("invalid recovery id"),Bo=t=>{t===df&&ne('Signature format "der" is not supported: switch to noble-curves'),t!=null&&t!==wr&&t!==un&&ne("Signature format must be one of: compact, recovered, der")},Fi=(t,e=wr)=>{Bo(e);let r=gr.signature+ +(e===un);t.length!==r&&ne(`Signature format "${e}" expects Uint8Array with length ${r}`)},mr=class t{constructor(e,r,n){u(this,"r");u(this,"s");u(this,"recovery");this.r=go(e),this.s=go(r),n!=null&&(this.recovery=Ai(n)),Object.freeze(this)}static fromBytes(e,r=wr){Fi(e,r);let n;r===un&&(n=e[0],e=e.subarray(1));let o=fn(e,0,me),s=fn(e,me,br);return new t(o,s,n)}addRecoveryBit(e){return new t(this.r,this.s,e)}hasHighS(){return Ao(this.s)}toBytes(e=wr){Bo(e);let{r,s:n,recovery:o}=this,s=Vt(Yt(r),Yt(n));return e===un?Vt(Ar(Ai(o)),s):s}},Di=t=>{t.length>8192&&ne("input is too large");let e=t.length*8-256,r=dn(t);return e>0?r>>an(e):r},Mi=t=>st(Di(Ie(t))),wr="compact",un="recovered",df="der",Bi="SHA-256",hn={hmacSha256Async:async(t,e)=>{let r=wi(),n="HMAC",o=await r.importKey("raw",t,{name:n,hash:{name:Bi}},!1,["sign"]);return ct(await r.sign(n,o,e))},hmacSha256:void 0,sha256Async:async t=>ct(await wi().digest(Bi,t)),sha256:void 0},Ni=(t,e,r)=>{let n=Ie(t,void 0,"message");return e.prehash?r?of("sha256Async",n):Oi("sha256",n):n},hf=ct(0),pf=Ar(0),xf=Ar(1),yf=1e3,bf="drbg: tried max amount of iterations",gf=(t,e)=>{let r=ct(me),n=ct(me),o=0,s=()=>{r.fill(1),n.fill(0)},i=(...l)=>Oi("hmacSha256",n,Vt(r,...l)),c=(l=hf)=>{n=i(pf,l),r=i(),l.length!==0&&(n=i(xf,l),r=i())},a=()=>(o++>=yf&&ne(bf),r=i(),r);s(),c(t);let f;for(;!(f=e(a()));)c();return s(),f};var mf=(t,e,r,n)=>{let{lowS:o,extraEntropy:s}=r,i=Yt,c=Mi(t),a=i(c),f=Eo(e),l=[i(f),a];if(s!=null&&s!==!1){let x=s===!0?Ii(me):s;l.push(Ie(x,void 0,"extraEntropy"))}let h=Vt(...l),d=c;return n(h,x=>{let E=Di(x);if(!(1n<=E&&E<it))return;let w=wo(E,it),H=at.multiply(E).toAffine(),L=st(H.x);if(L===0n)return;let g=st(w*st(d+L*f));if(g===0n)return;let m=(H.x===L?0:2)|Number(H.y&1n),U=g;return o&&Ao(g)&&(U=st(-g),m^=1),new mr(L,U,m).toBytes(r.format)})},wf=(t,e,r,n={})=>{let{lowS:o,format:s}=n;t instanceof mr&&ne("Signature must be in Uint8Array, use .toBytes()"),Fi(t,s),Ie(r,void 0,"publicKey");try{let{r:i,s:c}=mr.fromBytes(t,s),a=Mi(e),f=Ze.fromBytes(r);if(o&&Ao(c))return!1;let l=wo(c,it),h=st(a*l),d=st(i*l),p=af(f,h,d).toAffine();return st(p.x)===i}catch{return!1}},ji=t=>({lowS:t.lowS??!0,prehash:t.prehash??!0,format:t.format??wr,extraEntropy:t.extraEntropy??!1}),Pi=(t,e,r={})=>{r=ji(r),Bo(r.format);let n=Ni(t,r,!1);return mf(n,e,r,gf)};var $i=(t,e,r,n={})=>{n=ji(n);let o=Ni(e,n,!1);return wf(t,o,r,n)};var Ef=t=>{if(t=t===void 0?Ii(gr.seed):t,Ie(t),t.length<gr.seed||t.length>1024)return ne("expected 48-1024b",RangeError);let e=F(dn(t),it-1n);return Yt(e+1n)};var Gi=Object.freeze({isValidSecretKey:uf,isValidPublicKey:lf,randomSecretKey:Ef});var ln=8,Af=256,zi=Math.ceil(Af/ln)+1,mo=2**(ln-1),Bf=()=>{let t=[],e=at,r=e;for(let n=0;n<zi;n++){r=e,t.push(r);for(let o=1;o<mo;o++)r=r.add(e),t.push(r);e=r.double()}return t},Si,vi=(t,e)=>{let r=e.negate();return t?r:e},Sf=t=>{let e=Si||(Si=Bf()),r=Ut,n=at,o=2**ln,s=o,i=an(o-1),c=an(ln);for(let a=0;a<zi;a++){let f=Number(t&i);t>>=c,f>mo&&(f-=s,t+=1n);let l=a*mo,h=l,d=l+Math.abs(f)-1,p=a%2!==0,x=f<0;f===0?n=n.add(vi(p,e[h])):r=r.add(vi(x,e[d]))}return t!==0n&&ne("invalid wnaf"),{p:r,f:n}};y();y();function qi(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var So=t=>t?`"${t}" `:"";function vo(t,e=""){if(typeof t!="number")throw new TypeError(So(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(So(e)+"expected integer >= 0, got "+t);return t}function Br(t,e,r=""){if(qi(t)&&(e===void 0||t.length===e))return t;e!==void 0&&vo(e,"length");let n=qi(t),o=e!==void 0?` of length ${e}`:"",s=n?`length=${t.length}`:`type=${typeof t}`,i=So(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function Vi(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(vo(t.outputLen),vo(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var Wi=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};function Xt(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function pn(t,e){Br(t,void 0,"output");let r=e.outputLen;if(!(t.length>=r))throw new RangeError('"output" expected length >= '+r)}function Sr(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function xn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ue(t,e){return t<<32-e|t>>>e}function kf(t,e,r="opts"){return Wi(t,"defaults"),e!==void 0&&Wi(e,r),Object.assign(t,e)}function Yi(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=kf({},e,"info");let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}var Xi=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});var yn=class{constructor(e,r){u(this,"oHash");u(this,"iHash");u(this,"blockLen");u(this,"outputLen");u(this,"canXOF",!1);u(this,"finished",!1);u(this,"destroyed",!1);if(Vi(e),Br(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Sr(o)}update(e){return Xt(this),this.iHash.update(e),this}digestInto(e){Xt(this),pn(e,this),this.finished=!0;let r=e.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c,canXOF:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.canXOF=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Zi=(()=>{let t=((e,r,n)=>new yn(e,r).update(n).digest());return t.create=(e,r)=>new yn(e,r),t})();y();y();y();var Hf=t=>t/2**32|0,Lf=t=>t>>>0;function Ji(t,e,r,n){let o=Hf(r),s=Lf(r);t.setUint32(e,n?s:o,n),t.setUint32(e+4,n?o:s,n)}function Qi(t,e,r){return t&e^~t&r}function ec(t,e,r){return t&e^t&r^e&r}var bn=class{constructor(e,r,n,o){u(this,"blockLen");u(this,"outputLen");u(this,"canXOF",!1);u(this,"padOffset");u(this,"isLE");u(this,"buffer");u(this,"view");u(this,"finished",!1);u(this,"length",0);u(this,"pos",0);u(this,"destroyed",!1);this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=xn(this.buffer)}update(e){Xt(this),Br(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length,i=!1;for(let c=0;c<s;){let a=Math.min(o-this.pos,s-c);if(a===o){let f=xn(e);for(;o<=s-c;c+=o)this.process(f,c);i=!0;continue}n.set(c===0&&a===s?e:e.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===o&&(this.process(r,0),this.pos=0,i=!0)}return this.length+=e.length,i&&this.roundClean(),this}digestInto(e){Xt(this),pn(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,r.fill(0,i),this.padOffset>o-i&&(this.process(n,0),r.fill(0)),Ji(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let c=e===r?n:xn(e),a=this.outputLen,f=a/4,l=this.get();if(a%4||f>l.length)throw new Error("invalid outputLen");for(let h=0;h<f;h++)c.setUint32(4*h,l[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=n,e.pos=i,i&&e.buffer.set(r),e}clone(){return this._cloneInto()}},tc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Tf=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ft=new Uint32Array(64),ko=class extends bn{constructor(r,n){super(64,r,8,!1);u(this,"A",0);u(this,"B",0);u(this,"C",0);u(this,"D",0);u(this,"E",0);u(this,"F",0);u(this,"G",0);u(this,"H",0);this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:r,B:n,C:o,D:s,E:i,F:c,G:a,H:f}=this;return[r,n,o,s,i,c,a,f]}set(r,n,o,s,i,c,a,f){this.A=r|0,this.B=n|0,this.C=o|0,this.D=s|0,this.E=i|0,this.F=c|0,this.G=a|0,this.H=f|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let d=0;d<16;d++,n+=4)ft[d]=r.getUint32(n,!1);for(let d=16;d<64;d++){let p=ft[d-15],x=ft[d-2],E=Ue(p,7)^Ue(p,18)^p>>>3,w=Ue(x,17)^Ue(x,19)^x>>>10;ft[d]=w+ft[d-7]+E+ft[d-16]|0}let{A:o,B:s,C:i,D:c,E:a,F:f,G:l,H:h}=this;for(let d=0;d<64;d++){let p=Ue(a,6)^Ue(a,11)^Ue(a,25),x=h+p+Qi(a,f,l)+Tf[d]+ft[d]|0,w=(Ue(o,2)^Ue(o,13)^Ue(o,22))+ec(o,s,i)|0;h=l,l=f,f=a,a=c+x|0,c=i,i=s,s=o,o=x+w|0}o=o+this.A|0,s=s+this.B|0,i=i+this.C|0,c=c+this.D|0,a=a+this.E|0,f=f+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(o,s,i,c,a,f,l,h)}roundClean(){Sr(ft)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Sr(this.buffer)}},Ho=class extends ko{constructor(){super(32,tc)}};var ut=Yi(()=>new Ho,Xi(1));y();function Ir(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}function Qt(t){if(t.length%2!==0)throw new Error("Hex string must have even length");let e=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)e[r/2]=parseInt(t.slice(r,r+2),16);return e}async function vn(t,e){if(e==="sha256"){let r=await Promise.resolve().then(()=>(Sn(),Bn));return new Uint8Array(r.createHash("sha256").update(t).digest())}else if(e==="sha512"){let r=await Promise.resolve().then(()=>(Sn(),Bn));return new Uint8Array(r.createHash("sha512").update(t).digest())}else if(e==="sha3-256"){let r=await Promise.resolve().then(()=>(Sn(),Bn));return new Uint8Array(r.createHash("sha3-256").update(t).digest())}throw new Error(`Unsupported hash algorithm: ${e}`)}y();y();y();y();y();y();var Yf=t=>t/2**32|0,Xf=t=>t>>>0;function _c(t,e,r,n){let o=Yf(r),s=Xf(r);t.setUint32(e,n?s:o,n),t.setUint32(e+4,n?o:s,n)}tr();function Dc(t,e,r){return t&e^~t&r}function Mc(t,e,r){return t&e^t&r^e&r}var In=class{constructor(e,r,n,o){u(this,"blockLen");u(this,"outputLen");u(this,"canXOF",!1);u(this,"padOffset");u(this,"isLE");u(this,"buffer");u(this,"view");u(this,"finished",!1);u(this,"length",0);u(this,"pos",0);u(this,"destroyed",!1);this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Tn(this.buffer)}update(e){er(this),je(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length,i=!1;for(let c=0;c<s;){let a=Math.min(o-this.pos,s-c);if(a===o){let f=Tn(e);for(;o<=s-c;c+=o)this.process(f,c);i=!0;continue}n.set(c===0&&a===s?e:e.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===o&&(this.process(r,0),this.pos=0,i=!0)}return this.length+=e.length,i&&this.roundClean(),this}digestInto(e){er(this),Ln(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,r.fill(0,i),this.padOffset>o-i&&(this.process(n,0),r.fill(0)),_c(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let c=e===r?n:Tn(e),a=this.outputLen,f=a/4,l=this.get();if(a%4||f>l.length)throw new Error("invalid outputLen");for(let h=0;h<f;h++)c.setUint32(4*h,l[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=n,e.pos=i,i&&e.buffer.set(r),e}clone(){return this._cloneInto()}},Nc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);tr();var Qf=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),pt=new Uint32Array(64),No=class extends In{constructor(r,n){super(64,r,8,!1);u(this,"A",0);u(this,"B",0);u(this,"C",0);u(this,"D",0);u(this,"E",0);u(this,"F",0);u(this,"G",0);u(this,"H",0);this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:r,B:n,C:o,D:s,E:i,F:c,G:a,H:f}=this;return[r,n,o,s,i,c,a,f]}set(r,n,o,s,i,c,a,f){this.A=r|0,this.B=n|0,this.C=o|0,this.D=s|0,this.E=i|0,this.F=c|0,this.G=a|0,this.H=f|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let d=0;d<16;d++,n+=4)pt[d]=r.getUint32(n,!1);for(let d=16;d<64;d++){let p=pt[d-15],x=pt[d-2],E=Re(p,7)^Re(p,18)^p>>>3,w=Re(x,17)^Re(x,19)^x>>>10;pt[d]=w+pt[d-7]+E+pt[d-16]|0}let{A:o,B:s,C:i,D:c,E:a,F:f,G:l,H:h}=this;for(let d=0;d<64;d++){let p=Re(a,6)^Re(a,11)^Re(a,25),x=h+p+Dc(a,f,l)+Qf[d]+pt[d]|0,w=(Re(o,2)^Re(o,13)^Re(o,22))+Mc(o,s,i)|0;h=l,l=f,f=a,a=c+x|0,c=i,i=s,s=o,o=x+w|0}o=o+this.A|0,s=s+this.B|0,i=i+this.C|0,c=c+this.D|0,a=a+this.E|0,f=f+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(o,s,i,c,a,f,l,h)}roundClean(){Ur(pt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ur(this.buffer)}},jo=class extends No{constructor(){super(32,Nc)}};var jc=Kc(()=>new jo,Fc(1));y();Ft();Nn();var es=BigInt(0),Cr=BigInt(1),lu=BigInt(4),Jo=16,oa=128,du=5,sa=2**31;function cr(t){let e=t;if(typeof e!="function")throw new TypeError('"Point" expected constructor, got type='+typeof t);Ct(e.fromAffine,"Point.fromAffine"),Ct(e.fromBytes,"Point.fromBytes"),Ct(e.fromHex,"Point.fromHex"),xt(e.BASE,"Point.BASE"),xt(e.ZERO,"Point.ZERO"),sr(e.Fp),sr(e.Fn)}function ca(t,e){cr(t),aa(e,t);let r=Zo(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function hu(t,e,r=1){if(!Number.isSafeInteger(t)||t<r||t>e)throw new Error("invalid window size, expected ["+r+".."+e+"], got W="+t)}function pu(t,e){let r=t*(4*e+128);if(r>sa)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+sa/2**20+" MiB")}function ts(t,e){if(t!==void 0){Ct(t,"randomBytes");try{let r=t(e);if(!rr(r)||r.length!==e)return}catch{return}return t}}function aa(t,e){Or(t,"points"),t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function xu(t,e,r){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,o)=>{if(!(r===void 0?e.isValid(n):yt(n)&&n<r))throw new Error("invalid scalar at index "+o)})}var fa=new WeakMap;function Qo(t){return fa.get(t)||1}function yu(t,e){let r=t.double(),n=[t];for(let o=1;o<e;o++)n.push(n[o-1].add(r));return n}function bu(t,e){let r=2**e,n=r/2,o=BigInt(r-1),s=[];for(;t>es;){let i=0;t&Cr&&(i=Number(t&o),i>=n&&(i-=r),t-=BigInt(i)),s.push(i),t>>=Cr}return s}function gu(t,e,r){let n=2**e,o=n/2,s=BigInt(n-1),i=BigInt(e),c=[];for(let a=0;a<r;a++){let f=Number(t&s);t>>=i,f>o&&(f-=n,t+=Cr),c.push(f)}if(t!==es)throw new Error("invalid wnaf");return c}function mu(t,e,r){let n=0;for(let s of r)n=Math.max(n,s.length);let o=t;for(let s=n-1;s>=0;s--){s!==n-1&&(o=o.double());for(let i=0;i<r.length;i++){let c=r[i][s];if(c){let a=e[i][Math.abs(c)-1>>1];o=o.add(c<0?a.negate():a)}}}return o}var jn=class{constructor(e,r){u(this,"Point");u(this,"BASE");u(this,"ZERO");u(this,"randomBytes");u(this,"wnafPrecomputes",new WeakMap);u(this,"baseCanBeBlinded");u(this,"bits");cr(e),this.randomBytes=ts(r,Jo),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,r,n){let o=Math.ceil(n/r)+1,s=2**(r-1),i=[],c=e;for(let a=0;a<o;a++){let f=c;for(let l=0;l<s;l++)i.push(f),f=f.add(c);c=i[i.length-1].double()}return{W:r,bits:n,windows:o,comp:i}}wnafCachedCT(e,r){let{W:n,windows:o,comp:s}=e,i=2**(n-1),c=gu(r,n,o),a=this.ZERO,f=this.BASE;for(let l=0;l<o;l++){let h=c[l],d=l*i,p=Math.abs(h)-1,x=s[d];for(let w=1;w<i;w++)x=w===p?s[d+w]:x;let E=x.negate();h===0?f=f.add(s[d]):a=a.add(h<0?E:x)}return{p:a,f}}getWnafPrecomputes(e,r,n,o){let s=this.wnafPrecomputes.get(r),i=s?.find(c=>c.W===e&&c.bits===n);return i||(i=this.buildWnafTable(r,e,n),typeof o=="function"&&(i={...i,comp:o(i.comp)}),s||(s=[],this.wnafPrecomputes.set(r,s)),s.push(i)),i}assertPoint(e){if(!(e instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof e)}validateMulInput(e,r){if(this.assertPoint(e),!qo(r,Cr,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(e,r,n,o){let s=Qo(e);return s===1?this.fixedWindowCT(e,r,n):this.wnafCachedCT(this.getWnafPrecomputes(s,e,n,o),r)}mulCT(e,r,n){return this.validateMulInput(e,r),this.runCT(e,r,this.bits,n)}mulCTBlinded(e,r,n){if(this.validateMulInput(e,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+oa,s=this.randomBytes(Jo);if(!rr(s)||s.length!==Jo)throw new Error("randomBytes returned invalid byte array");s[0]=s[0]&63|128;let i=r+Pe(s)*this.Point.Fn.ORDER;return this.runCT(e,i,o,n)}fixedWindowCT(e,r,n){let o=du,s=1<<o,i=Kr(o),c=new Array(s);c[0]=this.ZERO;for(let l=1;l<s;l++)c[l]=c[l-1].add(e);let a=Math.ceil(n/o),f=this.ZERO;for(let l=a-1;l>=0;l--){if(l!==a-1)for(let p=0;p<o;p++)f=f.double();let h=Number(r>>BigInt(l*o)&i),d=c[0];for(let p=1;p<s;p++)d=p===h?c[p]:d;f=f.add(d)}return{p:f,f}}shouldBlind(e,r){return this.randomBytes===void 0?!1:r===Cr?!0:e!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,r,n,o){return this.shouldBlind(e,n)?this.mulCTBlinded(e,r,o):this.mulCT(e,r,o)}mulUnsafe(e,r,n){if(this.assertPoint(e),!yt(r))throw new Error("invalid scalar");let o=Qo(e);if(o===1||r>=this.Point.Fn.ORDER)return Pn(this.Point,[e],[r],!0);let s=this.getWnafPrecomputes(o,e,this.bits,n);return this.wnafCachedCT(s,r).p}setWindowSize(e,r){this.assertPoint(e),hu(r,this.bits);let n=Math.ceil((this.bits+oa)/r)+1;pu(n*2**(r-1),this.Point.Fp.BYTES),fa.set(e,r),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Qo(e)!==1}};function Pn(t,e,r,n=!1){if(cr(t),aa(e,t),_e(n,"allowOversized"),xu(r,t.Fn,n?t.Fn.ORDER**lu:void 0),e.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let o=e.map(i=>yu(i,4)),s=r.map(i=>bu(i,4));return mu(t.ZERO,o,s)}function ia(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return sr(e),e}else return ir(t,{isLE:r})}function ua(t,e,r={},n){if(t!=="weierstrass"&&t!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);$e(r);for(let a of["p","n","h"]){let f=e[a];if(!(yt(f)&&f!==es))throw new Error(`CURVE.${a} must be positive bigint`)}let o=ia(e.p,r.Fp,n),s=ia(e.n,r.Fn,n),c=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:s}}function la(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}Nn();y();y();tr();var $n=class{constructor(e,r){u(this,"oHash");u(this,"iHash");u(this,"blockLen");u(this,"outputLen");u(this,"canXOF",!1);u(this,"finished",!1);u(this,"destroyed",!1);if(Hn(e),je(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Ur(o)}update(e){return er(this),this.iHash.update(e),this}digestInto(e){er(this),Ln(e,this),this.finished=!0;let r=e.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c,canXOF:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.canXOF=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ya=(()=>{let t=((e,r,n)=>new $n(e,r).update(n).digest());return t.create=(e,r)=>new $n(e,r),t})();tr();Ft();y();Ft();var wu=BigInt(0),os=class extends Error{constructor(e=""){super(e)}},tt={Err:os,_tlv:{encode:(t,e)=>{let{Err:r}=tt;if(nr(t,"tag"),t<0||t>255)throw new r("tlv.encode: wrong tag");if($c(e,"data"),e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Rr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Rr(o.length/2|128):"";return Rr(t)+s+o+e},decode(t,e){let{Err:r}=tt;e=pe(e,void 0,"DER data");let n=0;if(t<0||t>255)throw new r("tlv.decode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+a);if(f.length!==a)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let l of f)i=i<<8|l;if(n+=a,i<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+i)}}},_int:{encode(t){let{Err:e}=tt;if(Kn(t),t<wu)throw new e("integer: negative integers are not allowed");let r=Rr(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=tt;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Pe(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=tt,o=pe(t,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:f,l}=n.decode(2,a);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=tt;$e(t,{r:"bigint",s:"bigint"},{},"sig");let n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),s=n+o;return e.encode(48,s)}},ss=(Object.freeze(tt._tlv),Object.freeze(tt._int),Object.freeze(tt));Nn();var ba=(t,e)=>(t+(t>=0?e:-e)/ga)/e;function Eu(t,e,r){Wo("scalar",t,rt,r);let[[n,o],[s,i]]=e,c=ba(i*t,r),a=ba(-o*t,r),f=t-c*n-a*s,l=-c*o-a*i,h=f<rt,d=l<rt;h&&(f=-f),d&&(l=-l);let p=Kr(Math.ceil(or(r)/2))+Dt;if(f<rt||f>=p||l<rt||l>=p)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:h,k1:f,k2neg:d,k2:l}}function as(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function is(t,e){$e(t);let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return _e(r.lowS,"lowS"),_e(r.prehash,"prehash"),r.format!==void 0&&as(r.format),r}var rt=BigInt(0),Dt=BigInt(1),ga=BigInt(2),cs=BigInt(3),Au=BigInt(4);function ma(t,e={}){let r=ua("weierstrass",t,e),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:c}=s;$e(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:a,allowInfinityPoint:f}=e,l=e.randomBytes===void 0?Rn:e.randomBytes;if(a&&(!n.is0(s.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let h=Ea(n,o);function d(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function p(Y,k,O){if(f&&k.is0())return Uint8Array.of(0);let{x:N,y:_}=k.toAffine(),A=n.toBytes(N);if(_e(O,"isCompressed"),O){d();let T=!n.isOdd(_);return et(wa(T),A)}else return et(Uint8Array.of(4),A,n.toBytes(_))}function x(Y){pe(Y,void 0,"Point");let{publicKey:k,publicKeyUncompressed:O}=h,N=Y.length,_=Y[0],A=Y.subarray(1);if(f&&N===1&&_===0)return{x:n.ZERO,y:n.ZERO};if(N===k&&(_===2||_===3)){let T=n.fromBytes(A);if(!n.isValid(T))throw new Error("bad point: is not on curve, wrong x");let M=g(T),j;try{j=n.sqrt(M)}catch(B){let S=B instanceof Error?": "+B.message:"";throw new Error("bad point: is not on curve, sqrt error"+S)}d();let $=n.isOdd(j);return(_&1)===1!==$&&(j=n.neg(j)),{x:T,y:j}}else if(N===O&&_===4){let T=n.BYTES,M=n.fromBytes(A.subarray(0,T)),j=n.fromBytes(A.subarray(T,T*2));if(!m(M,j))throw new Error("bad point: is not on curve");return{x:M,y:j}}else throw new Error(`bad point: got length ${N}, expected compressed=${k} or uncompressed=${O}`)}let E=e.toBytes===void 0?p:e.toBytes,w=e.fromBytes===void 0?x:e.fromBytes,H=n.mul(s.b,cs),L=n.is0(s.a)?Y=>n.ZERO:Y=>n.mul(s.a,Y);function g(Y){let k=n.sqr(Y),O=n.mul(k,Y);return n.add(n.add(O,n.mul(Y,s.a)),s.b)}function m(Y,k){let O=n.sqr(k),N=g(Y);return n.eql(O,N)}if(!m(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let U=n.mul(n.pow(s.a,cs),Au),P=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(U,P)))throw new Error("bad curve params: a or b");function X(Y,k,O=!1){if(!n.isValid(k)||O&&n.is0(k))throw new Error(`bad point coordinate ${Y}`);return k}function q(Y){if(!(Y instanceof Z))throw new Error("Weierstrass Point expected")}function z(Y){if(!a||!a.basises)throw new Error("no endo");return Eu(Y,a.basises,o.ORDER)}function D(Y,k,O,N){if(!o.isValid(N))throw new RangeError("invalid scalar: out of range");if(a){let{k1neg:_,k1:A,k2neg:T,k2:M}=z(N),j=new Z(n.mul(O.X,a.beta),O.Y,O.Z);Y.push(_?O.negate():O,T?j.negate():j),k.push(A,M)}else Y.push(O),k.push(N)}let J=new WeakSet,V=class V{constructor(k,O,N){u(this,"X");u(this,"Y");u(this,"Z");this.X=X("x",k),this.Y=X("y",O,!0),this.Z=X("z",N),Object.freeze(this)}static CURVE(){return s}static fromAffine(k){let{x:O,y:N}=k||{};if(!k||!n.isValid(O)||!n.isValid(N))throw new Error("invalid affine point");if(k instanceof V)throw new Error("projective point not allowed");return n.is0(O)&&n.is0(N)?V.ZERO:new V(O,N,n.ONE)}static fromBytes(k){let O=V.fromAffine(w(pe(k,void 0,"point")));return O.assertValidity(),O}static fromHex(k){return V.fromBytes(On(k))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(k=6,O=!0){return fe.setWindowSize(this,k),O||this.multiply(cs),this}assertValidity(){let k=this;if(k.is0()){if(e.allowInfinityPoint&&n.is0(k.X)&&n.eql(k.Y,n.ONE)&&n.is0(k.Z))return;throw new Error("bad point: ZERO")}if(J.has(k))return;let{x:O,y:N}=k.toAffine();if(!n.isValid(O)||!n.isValid(N))throw new Error("bad point: x or y not field elements");if(!m(O,N))throw new Error("bad point: equation left != right");if(!k.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");J.add(k)}hasEvenY(){let{y:k}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(k)}equals(k){q(k);let{X:O,Y:N,Z:_}=this,{X:A,Y:T,Z:M}=k,j=n.eql(n.mul(O,M),n.mul(A,_)),$=n.eql(n.mul(N,M),n.mul(T,_));return j&&$}negate(){return new V(this.X,n.neg(this.Y),this.Z)}double(){let{X:k,Y:O,Z:N}=this,_=n.ZERO,A=n.ZERO,T=n.ZERO,M=n.mul(k,k),j=n.mul(O,O),$=n.mul(N,N),b=n.mul(k,O);return b=n.add(b,b),T=n.mul(k,N),T=n.add(T,T),_=L(T),A=n.mul(H,$),A=n.add(_,A),_=n.sub(j,A),A=n.add(j,A),A=n.mul(_,A),_=n.mul(b,_),T=n.mul(H,T),$=L($),b=n.sub(M,$),b=L(b),b=n.add(b,T),T=n.add(M,M),M=n.add(T,M),M=n.add(M,$),M=n.mul(M,b),A=n.add(A,M),$=n.mul(O,N),$=n.add($,$),M=n.mul($,b),_=n.sub(_,M),T=n.mul($,j),T=n.add(T,T),T=n.add(T,T),new V(_,A,T)}add(k){q(k);let{X:O,Y:N,Z:_}=this,{X:A,Y:T,Z:M}=k,j=n.ZERO,$=n.ZERO,b=n.ZERO,B=n.mul(O,A),S=n.mul(N,T),v=n.mul(_,M),R=n.add(O,N),I=n.add(A,T);R=n.mul(R,I),I=n.add(B,S),R=n.sub(R,I),I=n.add(O,_);let G=n.add(A,M);return I=n.mul(I,G),G=n.add(B,v),I=n.sub(I,G),G=n.add(N,_),j=n.add(T,M),G=n.mul(G,j),j=n.add(S,v),G=n.sub(G,j),b=L(I),j=n.mul(H,v),b=n.add(j,b),j=n.sub(S,b),b=n.add(S,b),$=n.mul(j,b),S=n.add(B,B),S=n.add(S,B),v=L(v),I=n.mul(H,I),S=n.add(S,v),v=n.sub(B,v),v=L(v),I=n.add(I,v),B=n.mul(S,I),$=n.add($,B),B=n.mul(G,I),j=n.mul(R,j),j=n.sub(j,B),B=n.mul(R,S),b=n.mul(G,b),b=n.add(b,B),new V(j,$,b)}subtract(k){return q(k),this.add(k.negate())}is0(){return this.equals(V.ZERO)}multiply(k){if(!o.isValidNot0(k))throw new RangeError("invalid scalar: out of range");let{p:O,f:N}=fe.mulSecret(this,k,i,ae);return ae([O,N])[0]}multiplyUnsafe(k){let O=this,N=k;if(!o.isValid(N))throw new RangeError("invalid scalar: out of range");if(N===rt||O.is0())return V.ZERO;if(N===Dt)return O;if(fe.hasWindowSize(this))return fe.mulUnsafe(O,N,ae);let _=[],A=[];return D(_,A,O,N),Pn(V,_,A)}mulAddUnsafe(k,O,N){q(O);let _=[],A=[];return D(_,A,this,k),D(_,A,O,N),Pn(V,_,A)}toAffine(k){let O=this,N=k;if(N!=null&&!n.isValid(N))throw new RangeError('"invertedZ" expected valid field element');let{X:_,Y:A,Z:T}=O;if(n.eql(T,n.ONE))return{x:_,y:A};let M=O.is0();N==null&&(N=M?n.ONE:n.inv(T));let j=n.mul(_,N),$=n.mul(A,N),b=n.mul(T,N);if(M)return{x:n.ZERO,y:n.ZERO};if(!n.eql(b,n.ONE))throw new Error("invZ was invalid");return{x:j,y:$}}isTorsionFree(){let{isTorsionFree:k}=e;return i===Dt?!0:k?k(V,this):fe.mulUnsafe(this,c).is0()}clearCofactor(){let{clearCofactor:k}=e;return i===Dt?this:k?k(V,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===Dt?this.is0():this.clearCofactor().is0()}toBytes(k=!0){return _e(k,"isCompressed"),this.assertValidity(),E(V,this,k)}toHex(k=!0){return $o(this.toBytes(k))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};u(V,"BASE",new V(s.Gx,s.Gy,n.ONE)),u(V,"ZERO",new V(n.ZERO,n.ONE,n.ZERO)),u(V,"Fp",n),u(V,"Fn",o);let Z=V,ae=Y=>ca(Z,Y),fe=new jn(Z,l);return fe.bits>=6&&Z.BASE.precompute(6),Object.freeze(Z.prototype),Object.freeze(Z),Z}function wa(t){return Uint8Array.of(t?2:3)}function Ea(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Bu(t,e={}){cr(t);let{Fn:r}=t,n=e.randomBytes===void 0?Rn:e.randomBytes,o=Object.assign(Ea(t.Fp,r),{seed:Math.max(Dn(r.ORDER),16)});function s(p){try{let x=r.fromBytes(p);return r.isValidNot0(x)}catch{return!1}}function i(p,x){let{publicKey:E,publicKeyUncompressed:w}=o;try{let H=p.length;return x===!0&&H!==E||x===!1&&H!==w?!1:!!t.fromBytes(p)}catch{return!1}}function c(p){return p=p===void 0?n(o.seed):p,Mn(pe(p,o.seed,"seed"),r.ORDER)}function a(p,x=!0){return t.BASE.multiply(r.fromBytes(p)).toBytes(x)}function f(p){let{secretKey:x,publicKey:E,publicKeyUncompressed:w}=o,H=r._lengths;if(!rr(p))return;let L=pe(p,void 0,"key").length,g=L===E||L===w,m=L===x||!!H?.includes(L);if(!(g&&m))return g}function l(p,x,E=!0){if(f(p)===!0)throw new Error("first arg must be private key");if(f(x)===!1)throw new Error("second arg must be public key");let w=r.fromBytes(p);return t.fromBytes(x).multiply(w).toBytes(E)}let h={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c},d=la(c,a);return Object.freeze(h),Object.freeze(o),Object.freeze({getPublicKey:a,getSharedSecret:l,keygen:d,Point:t,utils:h,lengths:o})}function Aa(t,e,r={}){cr(t);let n=e;Hn(n),$e(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},r),s=o.randomBytes===void 0?Rn:o.randomBytes,i=o.hmac===void 0?(_,A)=>ya(n,_,A):o.hmac,{Fp:c,Fn:a}=t,{ORDER:f,BITS:l}=a,h=Dn(f),d=ts(s,h),{keygen:p,getPublicKey:x,getSharedSecret:E,utils:w,lengths:H}=Bu(t,o),L={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},g=f*ga+Dt<c.ORDER;function m(_){let A=f>>Dt;return _>A}function U(_,A){if(!a.isValidNot0(A))throw new Error(`invalid signature ${_}: out of range 1..Point.Fn.ORDER`);return A}function P(){if(!c.isOdd)throw new Error("Field doesn't support isOdd")}function X(_,A,T){return P(),(_===T?0:2)|Number(c.isOdd(A))}function q(){if(g)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function z(_,A){as(A);let T=H.signature,M=A==="compact"?T:A==="recovered"?T+1:void 0;return pe(_,M)}class D{constructor(A,T,M){u(this,"r");u(this,"s");u(this,"recovery");if(this.r=U("r",A),this.s=U("s",T),M!=null){if(q(),![0,1,2,3].includes(M))throw new Error("invalid recovery id");this.recovery=M}Object.freeze(this)}static fromBytes(A,T=L.format){z(A,T);let M;if(T==="der"){let{r:B,s:S}=ss.toSig(pe(A));return new D(B,S)}T==="recovered"&&(M=A[0],T="compact",A=A.subarray(1));let j=H.signature/2,$=A.subarray(0,j),b=A.subarray(j,j*2);return new D(a.fromBytes($),a.fromBytes(b),M)}static fromHex(A,T){return this.fromBytes(On(A),T)}assertRecovery(){let{recovery:A}=this;if(A==null)throw new Error("invalid recovery id: must be present");return A}addRecoveryBit(A){return new D(this.r,this.s,A)}recoverPublicKey(A){let{r:T,s:M}=this,j=this.assertRecovery(),$=j===2||j===3?T+f:T;if(!c.isValid($))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let b=c.toBytes($),B=t.fromBytes(et(wa((j&1)===0),b)),S=a.inv($),v=Z(pe(A,void 0,"msgHash")),R=a.create(-v*S),I=a.create(M*S),G=t.BASE.mulAddUnsafe(R,B,I);if(G.is0())throw new Error("invalid recovery: point at infinify");return G.assertValidity(),G}hasHighS(){return m(this.s)}toBytes(A=L.format){if(as(A),A==="der")return On(ss.hexFromSig(this));let{r:T,s:M}=this,j=a.toBytes(T),$=a.toBytes(M);return A==="recovered"?(q(),et(Uint8Array.of(this.assertRecovery()),j,$)):et(j,$)}toHex(A){return $o(this.toBytes(A))}}Object.freeze(D.prototype),Object.freeze(D);let J=o.bits2int===void 0?function(A){if(A.length>8192)throw new Error("input is too large");let T=Pe(A),M=A.length*8-l;return M>0?T>>BigInt(M):T}:o.bits2int,Z=o.bits2int_modN===void 0?function(A){return a.create(J(A))}:o.bits2int_modN,ae=Kr(l);function fe(_){return Wo("num < 2^"+l,_,rt,ae),a.toBytes(_)}function V(_,A){return pe(_,void 0,"message"),A?pe(n(_),void 0,"prehashed message"):_}function Y(_,A,T){let{lowS:M,prehash:j,extraEntropy:$}=is(T,L);_=V(_,j);let b=Z(_),B=a.fromBytes(A);if(!a.isValidNot0(B))throw new Error("invalid private key");let S=[fe(B),fe(b)];if($!=null&&$!==!1){let G=$===!0?s(H.secretKey):$;S.push(pe(G,void 0,"extraEntropy"))}let v=et(...S),R=b;function I(G){let te=J(G);if(!a.isValidNot0(te))return;let le=t.BASE.multiply(te).toAffine(),oe=a.create(le.x);if(oe===rt)return;let re;if(d!==void 0){let ue=Pe(Mn(d(h),f)),Be=a.inv(a.mul(ue,te)),Fe=a.mul(ue,R),Ye=a.mul(ue,B);re=a.create(Be*a.create(Fe+Ye*oe))}else{let ue=ea(te,f);re=a.create(ue*a.create(R+oe*B))}if(re===rt)return;let de=X(le.x,le.y,oe),Ae=re;return M&&m(re)&&(Ae=a.neg(re),de^=1),new D(oe,Ae,g?void 0:de)}return{seed:v,k2sig:I}}function k(_,A,T={}){let{seed:M,k2sig:j}=Y(_,A,T);return zc(n.outputLen,a.BYTES,i)(M,j).toBytes(T.format)}function O(_,A,T,M={}){let{lowS:j,prehash:$,format:b}=is(M,L);if(T=pe(T,void 0,"publicKey"),A=V(A,$),!rr(_)){let B=_ instanceof D?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+B)}z(_,b);try{let B=D.fromBytes(_,b),S=t.fromBytes(T);if(j&&B.hasHighS())return!1;let{r:v,s:R}=B,I=Z(A),G=a.inv(R),te=a.create(I*G),le=a.create(v*G),oe=t.BASE.mulAddUnsafe(te,S,le);if(oe.is0())return!1;let re=oe.toAffine();return!(a.create(re.x)!==v||b==="recovered"&&B.recovery!==X(re.x,re.y,v))}catch{return!1}}function N(_,A,T={}){let{prehash:M}=is(T,L);return A=V(A,M),D.fromBytes(_,"recovered").recoverPublicKey(A).toBytes()}return Object.freeze({keygen:p,getPublicKey:x,getSharedSecret:E,utils:w,lengths:H,Point:t,sign:k,verify:O,recoverPublicKey:N,Signature:D,hash:n})}var us={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Su={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Ba=BigInt(2);function vu(t){let e=us.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),f=t*t*t%e,l=f*f*t%e,h=ke(l,r,e)*l%e,d=ke(h,r,e)*l%e,p=ke(d,Ba,e)*f%e,x=ke(p,o,e)*p%e,E=ke(x,s,e)*x%e,w=ke(E,c,e)*E%e,H=ke(w,a,e)*w%e,L=ke(H,c,e)*E%e,g=ke(L,r,e)*l%e,m=ke(g,i,e)*x%e,U=ke(m,n,e)*f%e,P=ke(U,Ba,e);if(!fs.eql(fs.sqr(P),t))throw new Error("Cannot find square root");return P}var fs=ir(us.p,{sqrt:vu}),ku=ma(us,{Fp:fs,endo:Su}),ar=Aa(ku,jc);y();y();function Sa(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var ls=t=>t?`"${t}" `:"";function ds(t,e=""){if(typeof t!="number")throw new TypeError(ls(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(ls(e)+"expected integer >= 0, got "+t);return t}function He(t,e,r=""){if(Sa(t)&&(e===void 0||t.length===e))return t;e!==void 0&&ds(e,"length");let n=Sa(t),o=e!==void 0?` of length ${e}`:"",s=n?`length=${t.length}`:`type=${typeof t}`,i=ls(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function ka(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(ds(t.outputLen),ds(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var va=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};function fr(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function Gn(t,e){He(t,void 0,"output");let r=e.outputLen;if(!(t.length>=r))throw new RangeError('"output" expected length >= '+r)}function Ge(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function gt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ke(t,e){return t<<32-e|t>>>e}function Dr(t,e){return t<<e|t>>>32-e>>>0}function Mr(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];He(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let s=t[n];r.set(s,o),o+=s.length}return r}function Hu(t,e,r="opts"){return va(t,"defaults"),e!==void 0&&va(e,r),Object.assign(t,e)}function Nr(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=Hu({},e,"info");let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}var hs=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});var zn=class{constructor(e,r){u(this,"oHash");u(this,"iHash");u(this,"blockLen");u(this,"outputLen");u(this,"canXOF",!1);u(this,"finished",!1);u(this,"destroyed",!1);if(ka(e),He(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Ge(o)}update(e){return fr(this),this.iHash.update(e),this}digestInto(e){fr(this),Gn(e,this),this.finished=!0;let r=e.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c,canXOF:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.canXOF=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ps=(()=>{let t=((e,r,n)=>new zn(e,r).update(n).digest());return t.create=(e,r)=>new zn(e,r),t})();y();y();y();var qn=BigInt(4294967295),Ha=BigInt(32);function Lu(t,e=!1){return e?{h:Number(t&qn),l:Number(t>>Ha&qn)}:{h:Number(t>>Ha&qn)|0,l:Number(t&qn)|0}}function La(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=Lu(t[s],e);[n[s],o[s]]=[i,c]}return[n,o]}var Tu=t=>t/2**32|0,_u=t=>t>>>0;function Ta(t,e,r,n){let o=Tu(r),s=_u(r);t.setUint32(e,n?s:o,n),t.setUint32(e+4,n?o:s,n)}var xs=(t,e,r)=>t>>>r,ys=(t,e,r)=>t<<32-r|e>>>r,Mt=(t,e,r)=>t>>>r|e<<32-r,Nt=(t,e,r)=>t<<32-r|e>>>r,jr=(t,e,r)=>t<<64-r|e>>>r-32,Pr=(t,e,r)=>t>>>r-32|e<<64-r;function ze(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var _a=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Ia=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Ua=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Oa=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,Ra=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ka=(t,e,r,n,o,s)=>e+r+n+o+s+(t/2**32|0)|0;function bs(t,e,r){return t&e^~t&r}function gs(t,e,r){return t&e^t&r^e&r}var jt=class{constructor(e,r,n,o){u(this,"blockLen");u(this,"outputLen");u(this,"canXOF",!1);u(this,"padOffset");u(this,"isLE");u(this,"buffer");u(this,"view");u(this,"finished",!1);u(this,"length",0);u(this,"pos",0);u(this,"destroyed",!1);this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=gt(this.buffer)}update(e){fr(this),He(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length,i=!1;for(let c=0;c<s;){let a=Math.min(o-this.pos,s-c);if(a===o){let f=gt(e);for(;o<=s-c;c+=o)this.process(f,c);i=!0;continue}n.set(c===0&&a===s?e:e.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===o&&(this.process(r,0),this.pos=0,i=!0)}return this.length+=e.length,i&&this.roundClean(),this}digestInto(e){fr(this),Gn(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,r.fill(0,i),this.padOffset>o-i&&(this.process(n,0),r.fill(0)),Ta(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let c=e===r?n:gt(e),a=this.outputLen,f=a/4,l=this.get();if(a%4||f>l.length)throw new Error("invalid outputLen");for(let h=0;h<f;h++)c.setUint32(4*h,l[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=n,e.pos=i,i&&e.buffer.set(r),e}clone(){return this._cloneInto()}},Ca=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Fa=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Uu=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Ma=Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)),Ou=Ma.map(t=>(9*t+5)%16),Na=(()=>{let r=[[Ma],[Ou]];for(let n=0;n<4;n++)for(let o of r)o.push(o[n].map(s=>Uu[s]));return r})(),ja=Na[0],Pa=Na[1],$a=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),Ru=ja.map((t,e)=>t.map(r=>$a[e][r])),Ku=Pa.map((t,e)=>t.map(r=>$a[e][r])),Cu=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),Fu=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function Da(t,e,r,n){return t===0?e^r^n:t===1?e&r|~e&n:t===2?(e|~r)^n:t===3?e&n|r&~n:e^(r|~n)}var Wn=new Uint32Array(16),ms=class extends jt{constructor(){super(64,20,8,!0);u(this,"h0",1732584193);u(this,"h1",-271733879);u(this,"h2",-1732584194);u(this,"h3",271733878);u(this,"h4",-1009589776)}get(){let{h0:r,h1:n,h2:o,h3:s,h4:i}=this;return[r,n,o,s,i]}set(r,n,o,s,i){this.h0=r|0,this.h1=n|0,this.h2=o|0,this.h3=s|0,this.h4=i|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let x=0;x<16;x++,n+=4)Wn[x]=r.getUint32(n,!0);let o=this.h0|0,s=o,i=this.h1|0,c=i,a=this.h2|0,f=a,l=this.h3|0,h=l,d=this.h4|0,p=d;for(let x=0;x<5;x++){let E=4-x,w=Cu[x],H=Fu[x],L=ja[x],g=Pa[x],m=Ru[x],U=Ku[x];for(let P=0;P<16;P++){let X=Dr(o+Da(x,i,a,l)+Wn[L[P]]+w,m[P])+d|0;o=d,d=l,l=Dr(a,10)|0,a=i,i=X}for(let P=0;P<16;P++){let X=Dr(s+Da(E,c,f,h)+Wn[g[P]]+H,U[P])+p|0;s=p,p=h,h=Dr(f,10)|0,f=c,c=X}}this.set(this.h1+a+h|0,this.h2+l+p|0,this.h3+d+s|0,this.h4+o+c|0,this.h0+i+f|0)}roundClean(){Ge(Wn)}destroy(){this.destroyed=!0,Ge(this.buffer),this.set(0,0,0,0,0)}},Ga=Nr(()=>new ms);y();var Du=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),mt=new Uint32Array(64),ws=class extends jt{constructor(r,n){super(64,r,8,!1);u(this,"A",0);u(this,"B",0);u(this,"C",0);u(this,"D",0);u(this,"E",0);u(this,"F",0);u(this,"G",0);u(this,"H",0);this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:r,B:n,C:o,D:s,E:i,F:c,G:a,H:f}=this;return[r,n,o,s,i,c,a,f]}set(r,n,o,s,i,c,a,f){this.A=r|0,this.B=n|0,this.C=o|0,this.D=s|0,this.E=i|0,this.F=c|0,this.G=a|0,this.H=f|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let d=0;d<16;d++,n+=4)mt[d]=r.getUint32(n,!1);for(let d=16;d<64;d++){let p=mt[d-15],x=mt[d-2],E=Ke(p,7)^Ke(p,18)^p>>>3,w=Ke(x,17)^Ke(x,19)^x>>>10;mt[d]=w+mt[d-7]+E+mt[d-16]|0}let{A:o,B:s,C:i,D:c,E:a,F:f,G:l,H:h}=this;for(let d=0;d<64;d++){let p=Ke(a,6)^Ke(a,11)^Ke(a,25),x=h+p+bs(a,f,l)+Du[d]+mt[d]|0,w=(Ke(o,2)^Ke(o,13)^Ke(o,22))+gs(o,s,i)|0;h=l,l=f,f=a,a=c+x|0,c=i,i=s,s=o,o=x+w|0}o=o+this.A|0,s=s+this.B|0,i=i+this.C|0,c=c+this.D|0,a=a+this.E|0,f=f+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(o,s,i,c,a,f,l,h)}roundClean(){Ge(mt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ge(this.buffer)}},Es=class extends ws{constructor(){super(32,Ca)}};var za=La(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Mu=za[0],Nu=za[1],wt=new Uint32Array(80),Et=new Uint32Array(80),As=class extends jt{constructor(r,n){super(128,r,16,!1);u(this,"Ah",0);u(this,"Al",0);u(this,"Bh",0);u(this,"Bl",0);u(this,"Ch",0);u(this,"Cl",0);u(this,"Dh",0);u(this,"Dl",0);u(this,"Eh",0);u(this,"El",0);u(this,"Fh",0);u(this,"Fl",0);u(this,"Gh",0);u(this,"Gl",0);u(this,"Hh",0);u(this,"Hl",0);this.Ah=n[0]|0,this.Al=n[1]|0,this.Bh=n[2]|0,this.Bl=n[3]|0,this.Ch=n[4]|0,this.Cl=n[5]|0,this.Dh=n[6]|0,this.Dl=n[7]|0,this.Eh=n[8]|0,this.El=n[9]|0,this.Fh=n[10]|0,this.Fl=n[11]|0,this.Gh=n[12]|0,this.Gl=n[13]|0,this.Hh=n[14]|0,this.Hl=n[15]|0}get(){let{Ah:r,Al:n,Bh:o,Bl:s,Ch:i,Cl:c,Dh:a,Dl:f,Eh:l,El:h,Fh:d,Fl:p,Gh:x,Gl:E,Hh:w,Hl:H}=this;return[r,n,o,s,i,c,a,f,l,h,d,p,x,E,w,H]}set(r,n,o,s,i,c,a,f,l,h,d,p,x,E,w,H){this.Ah=r|0,this.Al=n|0,this.Bh=o|0,this.Bl=s|0,this.Ch=i|0,this.Cl=c|0,this.Dh=a|0,this.Dl=f|0,this.Eh=l|0,this.El=h|0,this.Fh=d|0,this.Fl=p|0,this.Gh=x|0,this.Gl=E|0,this.Hh=w|0,this.Hl=H|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let m=0;m<16;m++,n+=4)wt[m]=r.getUint32(n),Et[m]=r.getUint32(n+=4);for(let m=16;m<80;m++){let U=wt[m-15]|0,P=Et[m-15]|0,X=Mt(U,P,1)^Mt(U,P,8)^xs(U,P,7),q=Nt(U,P,1)^Nt(U,P,8)^ys(U,P,7),z=wt[m-2]|0,D=Et[m-2]|0,J=Mt(z,D,19)^jr(z,D,61)^xs(z,D,6),Z=Nt(z,D,19)^Pr(z,D,61)^ys(z,D,6),ae=Ua(q,Z,Et[m-7],Et[m-16]),fe=Oa(ae,X,J,wt[m-7],wt[m-16]);wt[m]=fe|0,Et[m]=ae|0}let{Ah:o,Al:s,Bh:i,Bl:c,Ch:a,Cl:f,Dh:l,Dl:h,Eh:d,El:p,Fh:x,Fl:E,Gh:w,Gl:H,Hh:L,Hl:g}=this;for(let m=0;m<80;m++){let U=Mt(d,p,14)^Mt(d,p,18)^jr(d,p,41),P=Nt(d,p,14)^Nt(d,p,18)^Pr(d,p,41),X=d&x^~d&w,q=p&E^~p&H,z=Ra(g,P,q,Nu[m],Et[m]),D=Ka(z,L,U,X,Mu[m],wt[m]),J=z|0,Z=Mt(o,s,28)^jr(o,s,34)^jr(o,s,39),ae=Nt(o,s,28)^Pr(o,s,34)^Pr(o,s,39),fe=o&i^o&a^i&a,V=s&c^s&f^c&f;L=w|0,g=H|0,w=x|0,H=E|0,x=d|0,E=p|0,{h:d,l:p}=ze(l|0,h|0,D|0,J|0),l=a|0,h=f|0,a=i|0,f=c|0,i=o|0,c=s|0;let Y=_a(J,ae,V);o=Ia(Y,D,Z,fe),s=Y|0}({h:o,l:s}=ze(this.Ah|0,this.Al|0,o|0,s|0)),{h:i,l:c}=ze(this.Bh|0,this.Bl|0,i|0,c|0),{h:a,l:f}=ze(this.Ch|0,this.Cl|0,a|0,f|0),{h:l,l:h}=ze(this.Dh|0,this.Dl|0,l|0,h|0),{h:d,l:p}=ze(this.Eh|0,this.El|0,d|0,p|0),{h:x,l:E}=ze(this.Fh|0,this.Fl|0,x|0,E|0),{h:w,l:H}=ze(this.Gh|0,this.Gl|0,w|0,H|0),{h:L,l:g}=ze(this.Hh|0,this.Hl|0,L|0,g|0),this.set(o,s,i,c,a,f,l,h,d,p,x,E,w,H,L,g)}roundClean(){Ge(wt,Et)}destroy(){this.destroyed=!0,Ge(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Bs=class extends As{constructor(){super(64,Fa)}};var Ss=Nr(()=>new Es,hs(1));var vs=Nr(()=>new Bs,hs(3));y();var ju=t=>Object.freeze(t());function Pu(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function Vn(t){if(!Pu(t))throw new TypeError("Uint8Array expected")}function Va(t){if(typeof t!="function")throw new TypeError("function expected");return!0}function $u(t,e){if(typeof e!="string")throw new TypeError(`${t}: string expected`);return!0}function Gu(t,e="number"){if(typeof t!="number")throw new TypeError(`${e}: expected number, got ${typeof t}`);if(!Number.isSafeInteger(t))throw new RangeError(`${e}: expected safe integer, got ${t}`)}function Ya(...t){let e=s=>s,r=(s,i)=>c=>s(i(c)),n=t.map(s=>s.encode).reduceRight(r,e),o=t.map(s=>s.decode).reduce(r,e);return{encode:n,decode:o}}var qa=(()=>{try{let t=new TextDecoder;return t.decode(Uint8Array.of(65,48,43,127))==="A0+\x7F"?t:void 0}catch{return}})(),ks=8192;function zu(t){let e=t.length;if(qa!==void 0&&e>=12)return qa.decode(t);if(e<=ks)return String.fromCharCode.apply(null,t);let r="";for(let n=0;n<e;n+=ks)r+=String.fromCharCode.apply(null,t.subarray(n,n+ks));return r}function qu(t,e){let r=t.length;if(r>128)throw new Error("alphabet: max 128 letters");let n=new Uint8Array(r),o=new Int8Array(128).fill(-1);for(let s=0;s<r;s++){let i=t.charCodeAt(s);if(t.codePointAt(s)!==i||i>127)throw new Error("alphabet: single-char ASCII letters only");n[s]=i,o[i]=s}if(e!==void 0)for(let s of Object.keys(e)){let i=s.charCodeAt(0),c=o[e[s].charCodeAt(0)];if(s.length!==1||i>127||c===void 0||c===-1)throw new Error(`alphabet: invalid alias ${s}`);o[i]=c}return{encode:s=>{let i=new Uint8Array(s.length);for(let c=0;c<s.length;c++){let a=s[c],f=n[a];if(f===void 0)throw new Error(`alphabet.encode: invalid digit ${a}`);i[c]=f}return zu(i)},decode:s=>{$u("decode",s);let i=s.length,c=new Uint8Array(i);for(let a=0;a<i;a++){let f=s.charCodeAt(a),l=f<128?o[f]:-1;if(l===-1)throw new Error(`Unknown letter "${s[a]}". Allowed: ${t}`);c[a]=l}return c}}}function Wu(t,e){if(Gu(t),t<=0)throw new RangeError(`checksum length must be positive: ${t}`);Va(e);let r=e;return{encode(n){Vn(n);let o=r(n).slice(0,t),s=new Uint8Array(n.length+t);return s.set(n),s.set(o,n.length),s},decode(n){Vn(n);let o=n.slice(0,-t),s=n.slice(-t),i=r(o).slice(0,t);for(let c=0;c<t;c++)if(i[c]!==s[c])throw new Error("Invalid checksum");return o}}}var Wa=656356768,Vu={encode:t=>{Vn(t);let e=t.length;if(e===0)return new Uint8Array(0);let r=0;for(;r<e-1&&t[r]===0;)r++;let n=Math.ceil(e/2),o=new Uint16Array(n),s=e&1;s&&(o[0]=t[0]);for(let d=s,p=s;d<e;d+=2,p++)o[p]=t[d]<<8|t[d+1];let i=[],c=0;for(;c<n;){let d=0;for(let p=c;p<n;p++){let x=d*65536+o[p],E=Math.floor(x/Wa);d=x-E*Wa,o[p]=E,E===0&&p===c&&c++}i.push(d)}let a=i.length-1,f=a*5;for(let d=i[a];f++,!(d<58);d=Math.floor(d/58));let l=new Uint8Array(r+f),h=l.length-1;for(let d=0;d<a;d++){let p=i[d];for(let x=0;x<5;x++)l[h--]=p%58,p=Math.floor(p/58)}for(let d=i[a];h>=r;d=Math.floor(d/58))l[h--]=d%58;return l},decode:t=>{Vn(t);let e=t.length;if(e===0)return new Uint8Array(0);if(e>=65536)throw new Error("invalid length");let r=0;for(;r<e-1&&t[r]===0;)r++;let n=new Uint16Array(Math.ceil(e*6/16)+1),o=0,s=0,i=e%5||5;for(;s<e;){let l=0,h=1;for(let p=s+i;s<p;s++){let x=t[s];if(x>=58)throw new Error(`invalid integer: ${x}`);l=l*58+x,h*=58}i=5;let d=l;for(let p=0;p<o;p++){let x=n[p]*h+d;d=Math.floor(x/65536),n[p]=x-d*65536}for(;d>0;d=Math.floor(d/65536))n[o++]=d%65536}let c=o===0?1:o*2-(n[o-1]<256?1:0),a=new Uint8Array(r+c),f=a.length-1;for(let l=0;l<o;l++){let h=n[l];a[f--]=h&255,f>=r&&(a[f--]=h>>8)}return a}},Yu=t=>Ya(Vu,qu(t)),Xu=ju(()=>Yu("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"));var Xa=t=>{Va(t);let e=t;return Ya(Wu(4,r=>e(e(r))),Xu)};var Gr=ar.Point,$r=Gr.Fn,Hs=Xa(Ss),Zu=Uint8Array.from("Bitcoin seed".split(""),t=>t.charCodeAt(0)),Ls={private:76066276,public:76067358},Ts=2147483648,Ju=t=>Ga(Ss(t)),Qu=t=>gt(t).getUint32(0,!1),ur=(t,e="number")=>{if(typeof t!="number")throw new TypeError(`"${e}" expected number, got type=${typeof t}`);if(!Number.isSafeInteger(t)||t<0||t>2**32-1)throw new RangeError(`"${e}" expected integer in range 0..2**32-1, got ${t}`);let r=new Uint8Array(4);return gt(r).setUint32(0,t,!1),r},_s=(t,e="versions")=>{if(!(typeof t=="object"&&t!==null))throw new Error("versions must be an object");return ur(t.private,`${e}.private`),ur(t.public,`${e}.public`),t},Yn=class t{constructor(e){u(this,"versions");u(this,"depth",0);u(this,"index",0);u(this,"chainCode",null);u(this,"parentFingerprint",0);u(this,"_privateKey");u(this,"_publicKey");u(this,"pubHash");if(!e||typeof e!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions?_s(e.versions):Ls,this.depth=e.depth||0,this.chainCode=e.chainCode?Uint8Array.from(e.chainCode):null,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(this.depth>255)throw new Error("HDKey: depth exceeds the serializable value 255");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!ar.utils.isValidSecretKey(e.privateKey))throw new Error("Invalid private key");this._privateKey=Uint8Array.from(e.privateKey),this._publicKey=ar.getPublicKey(this._privateKey,!0)}else if(e.publicKey)this._publicKey=Gr.fromBytes(e.publicKey).toBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=Ju(this._publicKey)}get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return Qu(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this._privateKey||null}get publicKey(){return this._publicKey||null}get privateExtendedKey(){let e=this._privateKey;if(!e)throw new Error("No private key");return Hs.encode(this.serialize(this.versions.private,Mr(Uint8Array.of(0),e)))}get publicExtendedKey(){if(!this._publicKey)throw new Error("No public key");return Hs.encode(this.serialize(this.versions.public,this._publicKey))}static fromMasterSeed(e,r=Ls){if(He(e),r=_s(r),8*e.length<128||8*e.length>512)throw new RangeError("HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got "+e.length);let n=ps(vs,Zu,e),o=n.slice(0,32),s=n.slice(32);return new t({versions:r,chainCode:s,privateKey:o})}static fromExtendedKey(e,r=Ls){r=_s(r);let n=Hs.decode(e),o=gt(n),s=o.getUint32(0,!1),i={versions:r,depth:n[4],parentFingerprint:o.getUint32(5,!1),index:o.getUint32(9,!1),chainCode:n.slice(13,45)},c=n.slice(45),a=c[0]===0;if(s!==r[a?"private":"public"])throw new Error("Version mismatch");return a?new t({...i,privateKey:c.slice(1)}):new t({...i,publicKey:c})}static fromJSON(e){return t.fromExtendedKey(e.xpriv)}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;let r=e.replace(/^[mM]'?\//,"").split("/"),n=this;for(let o of r){let s=/^(\d+)('?)$/.exec(o),i=s&&s[1];if(!s||s.length!==3||typeof i!="string")throw new Error("invalid child index: "+o);let c=+i;if(!Number.isSafeInteger(c)||c>=Ts)throw new Error("Invalid index");s[2]==="'"&&(c+=Ts),n=n.deriveChild(c)}return n}deriveChild(e,r){if(!this._publicKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let n=ur(e,"index");if(e>=Ts){let a=this._privateKey;if(!a)throw new Error("Could not derive hardened child key");n=Mr(Uint8Array.of(0),a,n)}else n=Mr(this._publicKey,n);let o=r||ps(vs,this.chainCode,n);He(o,64);let s=o.slice(0,32),i=o.slice(32),c={versions:this.versions,chainCode:i,depth:this.depth+1,parentFingerprint:this.fingerprint,index:e};if(c.depth>255)throw new Error("HDKey: depth exceeds the serializable value 255");try{let a=$r.fromBytes(s);if(this._privateKey){let f=$r.create($r.fromBytes(this._privateKey)+a);if(!$r.isValidNot0(f))throw new Error("The tweak was out of range or the resulted private key is invalid");c.privateKey=$r.toBytes(f)}else{let f=Gr.fromBytes(this._publicKey),l=a===0n?f:f.add(Gr.BASE.multiply(a));if(l.equals(Gr.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");c.publicKey=l.toBytes(!0)}return new t(c)}catch{return this.deriveChild(e+1)}}sign(e){if(!this._privateKey)throw new Error("No privateKey set!");return He(e,32),ar.sign(e,this._privateKey,{prehash:!1})}verify(e,r){if(He(e,32),He(r,64),!this._publicKey)throw new Error("No publicKey set!");return ar.verify(r,e,this._publicKey,{prehash:!1})}wipePrivateData(){return this._privateKey&&(this._privateKey.fill(0),this._privateKey=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(e,r){if(!this.chainCode)throw new Error("No chainCode set");return He(r,33),Mr(ur(e,"version"),new Uint8Array([this.depth]),ur(this.parentFingerprint,"parentFingerprint"),ur(this.index,"index"),this.chainCode,r)}};y();y();y();y();function Za(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var Is=t=>t?`"${t}" `:"";function qe(t,e=""){if(typeof t!="number")throw new TypeError(Is(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(Is(e)+"expected integer >= 0, got "+t);return t}function At(t,e,r=""){if(Za(t)&&(e===void 0||t.length===e))return t;e!==void 0&&qe(e,"length");let n=Za(t),o=e!==void 0?` of length ${e}`:"",s=n?`length=${t.length}`:`type=${typeof t}`,i=Is(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function Xn(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(qe(t.outputLen),qe(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var Ja=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};function lr(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function Zn(t,e){At(t,void 0,"output");let r=e.outputLen;if(!(t.length>=r))throw new RangeError('"output" expected length >= '+r)}function nt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function dr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ce(t,e){return t<<32-e|t>>>e}function el(t){if(typeof t!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Us(t,e=""){return typeof t=="string"?el(t):At(t,void 0,e)}function Os(t,e,r="opts"){return Ja(t,"defaults"),e!==void 0&&Ja(e,r),Object.assign(t,e)}function Rs(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=Os({},e,"info");let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Qa(t=32){qe(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var Ks=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});var Jn=class{constructor(e,r){u(this,"oHash");u(this,"iHash");u(this,"blockLen");u(this,"outputLen");u(this,"canXOF",!1);u(this,"finished",!1);u(this,"destroyed",!1);if(Xn(e),At(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),nt(o)}update(e){return lr(this),this.iHash.update(e),this}digestInto(e){lr(this),Zn(e,this),this.finished=!0;let r=e.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c,canXOF:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.canXOF=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},e0=(()=>{let t=((e,r,n)=>new Jn(e,r).update(n).digest());return t.create=(e,r)=>new Jn(e,r),t})();function tl(t,e,r,n){Xn(t);let o=Os({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:c}=o;if(qe(s,"c"),qe(i,"dkLen"),qe(c,"asyncTick"),s<1)throw new Error('"c" (iterations) must be >= 1');if(i<1)throw new Error('"dkLen" must be >= 1');if(i>(2**32-1)*t.outputLen)throw new Error("derived key too long");let a=Us(e,"password"),f=Us(r,"salt"),l=new Uint8Array(i),{iHash:h,oHash:d,outputLen:p}=e0.create(t,a),x=new Uint8Array(p),E=rl(h,d,f,x);return{c:s,dkLen:i,asyncTick:c,DK:l,outputLen:p,eng:E}}function rl(t,e,r,n){let o=new Uint8Array(4),s=dr(o),i=t._cloneInto().update(r),c=e._cloneInto(),a=t._cloneInto,f=e._cloneInto;return{u1:(l,h)=>{s.setInt32(0,l,!1),i._cloneInto(c).update(o).digestInto(n),e._cloneInto(c).update(n).digestInto(n),h.set(n.subarray(0,h.length))},rounds:(l,h)=>{for(let d=1;d<l;d++){a.call(t,c).update(n).digestInto(n),f.call(e,c).update(n).digestInto(n);for(let p=0;p<h.length;p++)h[p]^=n[p]}},output:l=>(t.destroy(),e.destroy(),i.destroy(),c.destroy(),nt(n),l)}}function t0(t,e,r,n){let{c:o,dkLen:s,DK:i,outputLen:c,eng:a}=tl(t,e,r,n);for(let f=1,l=0;l<s;f++,l+=c){let h=i.subarray(l,l+c);a.u1(f,h),a.rounds(o,h)}return a.output(i)}y();y();y();var Qn=BigInt(4294967295),r0=BigInt(32);function nl(t,e=!1){return e?{h:Number(t&Qn),l:Number(t>>r0&Qn)}:{h:Number(t>>r0&Qn)|0,l:Number(t&Qn)|0}}function n0(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=nl(t[s],e);[n[s],o[s]]=[i,c]}return[n,o]}var ol=t=>t/2**32|0,sl=t=>t>>>0;function o0(t,e,r,n){let o=ol(r),s=sl(r);t.setUint32(e,n?s:o,n),t.setUint32(e+4,n?o:s,n)}var Cs=(t,e,r)=>t>>>r,Fs=(t,e,r)=>t<<32-r|e>>>r,Pt=(t,e,r)=>t>>>r|e<<32-r,$t=(t,e,r)=>t<<32-r|e>>>r,zr=(t,e,r)=>t<<64-r|e>>>r-32,qr=(t,e,r)=>t>>>r-32|e<<64-r;function We(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var s0=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),i0=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,c0=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),a0=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,f0=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),u0=(t,e,r,n,o,s)=>e+r+n+o+s+(t/2**32|0)|0;function l0(t,e,r){return t&e^~t&r}function d0(t,e,r){return t&e^t&r^e&r}var Wr=class{constructor(e,r,n,o){u(this,"blockLen");u(this,"outputLen");u(this,"canXOF",!1);u(this,"padOffset");u(this,"isLE");u(this,"buffer");u(this,"view");u(this,"finished",!1);u(this,"length",0);u(this,"pos",0);u(this,"destroyed",!1);this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=dr(this.buffer)}update(e){lr(this),At(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length,i=!1;for(let c=0;c<s;){let a=Math.min(o-this.pos,s-c);if(a===o){let f=dr(e);for(;o<=s-c;c+=o)this.process(f,c);i=!0;continue}n.set(c===0&&a===s?e:e.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===o&&(this.process(r,0),this.pos=0,i=!0)}return this.length+=e.length,i&&this.roundClean(),this}digestInto(e){lr(this),Zn(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,r.fill(0,i),this.padOffset>o-i&&(this.process(n,0),r.fill(0)),o0(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let c=e===r?n:dr(e),a=this.outputLen,f=a/4,l=this.get();if(a%4||f>l.length)throw new Error("invalid outputLen");for(let h=0;h<f;h++)c.setUint32(4*h,l[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=n,e.pos=i,i&&e.buffer.set(r),e}clone(){return this._cloneInto()}},h0=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var p0=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var cl=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Bt=new Uint32Array(64),Ds=class extends Wr{constructor(r,n){super(64,r,8,!1);u(this,"A",0);u(this,"B",0);u(this,"C",0);u(this,"D",0);u(this,"E",0);u(this,"F",0);u(this,"G",0);u(this,"H",0);this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:r,B:n,C:o,D:s,E:i,F:c,G:a,H:f}=this;return[r,n,o,s,i,c,a,f]}set(r,n,o,s,i,c,a,f){this.A=r|0,this.B=n|0,this.C=o|0,this.D=s|0,this.E=i|0,this.F=c|0,this.G=a|0,this.H=f|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let d=0;d<16;d++,n+=4)Bt[d]=r.getUint32(n,!1);for(let d=16;d<64;d++){let p=Bt[d-15],x=Bt[d-2],E=Ce(p,7)^Ce(p,18)^p>>>3,w=Ce(x,17)^Ce(x,19)^x>>>10;Bt[d]=w+Bt[d-7]+E+Bt[d-16]|0}let{A:o,B:s,C:i,D:c,E:a,F:f,G:l,H:h}=this;for(let d=0;d<64;d++){let p=Ce(a,6)^Ce(a,11)^Ce(a,25),x=h+p+l0(a,f,l)+cl[d]+Bt[d]|0,w=(Ce(o,2)^Ce(o,13)^Ce(o,22))+d0(o,s,i)|0;h=l,l=f,f=a,a=c+x|0,c=i,i=s,s=o,o=x+w|0}o=o+this.A|0,s=s+this.B|0,i=i+this.C|0,c=c+this.D|0,a=a+this.E|0,f=f+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(o,s,i,c,a,f,l,h)}roundClean(){nt(Bt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),nt(this.buffer)}},Ms=class extends Ds{constructor(){super(32,h0)}};var x0=n0(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),al=x0[0],fl=x0[1],St=new Uint32Array(80),vt=new Uint32Array(80),Ns=class extends Wr{constructor(r,n){super(128,r,16,!1);u(this,"Ah",0);u(this,"Al",0);u(this,"Bh",0);u(this,"Bl",0);u(this,"Ch",0);u(this,"Cl",0);u(this,"Dh",0);u(this,"Dl",0);u(this,"Eh",0);u(this,"El",0);u(this,"Fh",0);u(this,"Fl",0);u(this,"Gh",0);u(this,"Gl",0);u(this,"Hh",0);u(this,"Hl",0);this.Ah=n[0]|0,this.Al=n[1]|0,this.Bh=n[2]|0,this.Bl=n[3]|0,this.Ch=n[4]|0,this.Cl=n[5]|0,this.Dh=n[6]|0,this.Dl=n[7]|0,this.Eh=n[8]|0,this.El=n[9]|0,this.Fh=n[10]|0,this.Fl=n[11]|0,this.Gh=n[12]|0,this.Gl=n[13]|0,this.Hh=n[14]|0,this.Hl=n[15]|0}get(){let{Ah:r,Al:n,Bh:o,Bl:s,Ch:i,Cl:c,Dh:a,Dl:f,Eh:l,El:h,Fh:d,Fl:p,Gh:x,Gl:E,Hh:w,Hl:H}=this;return[r,n,o,s,i,c,a,f,l,h,d,p,x,E,w,H]}set(r,n,o,s,i,c,a,f,l,h,d,p,x,E,w,H){this.Ah=r|0,this.Al=n|0,this.Bh=o|0,this.Bl=s|0,this.Ch=i|0,this.Cl=c|0,this.Dh=a|0,this.Dl=f|0,this.Eh=l|0,this.El=h|0,this.Fh=d|0,this.Fl=p|0,this.Gh=x|0,this.Gl=E|0,this.Hh=w|0,this.Hl=H|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let m=0;m<16;m++,n+=4)St[m]=r.getUint32(n),vt[m]=r.getUint32(n+=4);for(let m=16;m<80;m++){let U=St[m-15]|0,P=vt[m-15]|0,X=Pt(U,P,1)^Pt(U,P,8)^Cs(U,P,7),q=$t(U,P,1)^$t(U,P,8)^Fs(U,P,7),z=St[m-2]|0,D=vt[m-2]|0,J=Pt(z,D,19)^zr(z,D,61)^Cs(z,D,6),Z=$t(z,D,19)^qr(z,D,61)^Fs(z,D,6),ae=c0(q,Z,vt[m-7],vt[m-16]),fe=a0(ae,X,J,St[m-7],St[m-16]);St[m]=fe|0,vt[m]=ae|0}let{Ah:o,Al:s,Bh:i,Bl:c,Ch:a,Cl:f,Dh:l,Dl:h,Eh:d,El:p,Fh:x,Fl:E,Gh:w,Gl:H,Hh:L,Hl:g}=this;for(let m=0;m<80;m++){let U=Pt(d,p,14)^Pt(d,p,18)^zr(d,p,41),P=$t(d,p,14)^$t(d,p,18)^qr(d,p,41),X=d&x^~d&w,q=p&E^~p&H,z=f0(g,P,q,fl[m],vt[m]),D=u0(z,L,U,X,al[m],St[m]),J=z|0,Z=Pt(o,s,28)^zr(o,s,34)^zr(o,s,39),ae=$t(o,s,28)^qr(o,s,34)^qr(o,s,39),fe=o&i^o&a^i&a,V=s&c^s&f^c&f;L=w|0,g=H|0,w=x|0,H=E|0,x=d|0,E=p|0,{h:d,l:p}=We(l|0,h|0,D|0,J|0),l=a|0,h=f|0,a=i|0,f=c|0,i=o|0,c=s|0;let Y=s0(J,ae,V);o=i0(Y,D,Z,fe),s=Y|0}({h:o,l:s}=We(this.Ah|0,this.Al|0,o|0,s|0)),{h:i,l:c}=We(this.Bh|0,this.Bl|0,i|0,c|0),{h:a,l:f}=We(this.Ch|0,this.Cl|0,a|0,f|0),{h:l,l:h}=We(this.Dh|0,this.Dl|0,l|0,h|0),{h:d,l:p}=We(this.Eh|0,this.El|0,d|0,p|0),{h:x,l:E}=We(this.Fh|0,this.Fl|0,x|0,E|0),{h:w,l:H}=We(this.Gh|0,this.Gl|0,w|0,H|0),{h:L,l:g}=We(this.Hh|0,this.Hl|0,L|0,g|0),this.set(o,s,i,c,a,f,l,h,d,p,x,E,w,H,L,g)}roundClean(){nt(St,vt)}destroy(){this.destroyed=!0,nt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},js=class extends Ns{constructor(){super(64,p0)}};var y0=Rs(()=>new Ms,Ks(1));var b0=Rs(()=>new js,Ks(3));var ul=t=>t[0]==="\u3042\u3044\u3053\u304F\u3057\u3093";function g0(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function ll(t){let e=g0(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}function dl(t){if(At(t),![16,20,24,28,32].includes(t.length))throw new RangeError("invalid entropy length")}function m0(t,e=128){if(qe(e),e%32!==0||e>256)throw new RangeError("Invalid entropy");return yl(Qa(e/8),t)}var hl=t=>{let e=8-t.length/4;return y0(t)[0]>>e<<e};function pl(t){if(!Array.isArray(t)||t.length!==2048||typeof t[0]!="string")throw new TypeError("Wordlist: expected array of 2048 strings");t.forEach(e=>{if(typeof e!="string")throw new TypeError("wordlist: non-string element: "+e)})}function xl(t,e){pl(e);let r=new Uint8Array(t.length+1);r.set(t),r[t.length]=hl(t);let n=[],o=0,s=0;for(let i of r)o=o<<8|i,s+=8,s>=11&&(s-=11,n.push(e[o>>>s&2047]),o&=(1<<s)-1);return n}function yl(t,e){return dl(t),xl(t,e).join(ul(e)?"\u3000":" ")}var bl=t=>{if(typeof t!="string")throw new TypeError("invalid passphrase type: "+typeof t);return g0("mnemonic"+t)};function w0(t,e=""){return t0(b0,ll(t).nfkd,bl(e),{c:2048,dkLen:64})}y();var E0=Object.freeze(`abandon
|
|
2
2
|
ability
|
|
3
3
|
able
|
|
4
4
|
about
|
|
@@ -2046,59 +2046,36 @@ zebra
|
|
|
2046
2046
|
zero
|
|
2047
2047
|
zone
|
|
2048
2048
|
zoo`.split(`
|
|
2049
|
-
`);var
|
|
2049
|
+
`));var Ve=class{async deriveKeypair(e){if(!e.seed)throw new Error("BIP32 derivation requires a seed");if(!e.path)throw new Error(`BIP32 derivation requires a path (e.g., "m/44'/0'/0'/0/0")`);try{let n=Yn.fromMasterSeed(e.seed).derive(e.path);if(!n.privateKey)throw new Error(`Failed to derive private key at path ${e.path}`);if(!n.publicKey)throw new Error(`Failed to derive public key at path ${e.path}`);return{privateKey:n.privateKey,publicKey:n.publicKey}}catch(r){throw new Error(`BIP32 derivation failed at path ${e.path}: ${r instanceof Error?r.message:String(r)}`)}}mnemonicToSeed(e,r){return w0(e,r)}generateMnemonic(e=256){return m0(E0,e)}static bitcoinPath(e=0,r=0,n=0){return`m/44'/0'/${e}'/${r}/${n}`}static bitcoinSegWitPath(e=0,r=0,n=0){return`m/84'/0'/${e}'/${r}/${n}`}};y();var A0="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function gl(t){let e=0n;for(let n of t)e=e*256n+BigInt(n);let r="";for(;e>0n;){let n=Number(e%58n);r=A0[n]+r,e=e/58n}for(let n of t){if(n!==0)break;r="1"+r}return r}function ml(t){let e=0n;for(let n of t){let o=A0.indexOf(n);if(o===-1)throw new Error(`Invalid Base58 character: ${n}`);e=e*58n+BigInt(o)}let r=[];for(;e>0n;)r.unshift(Number(e%256n)),e=e/256n;for(let n of t){if(n!=="1")break;r.unshift(0)}return new Uint8Array(r)}function Ps(t,e=!0,r="mainnet"){if(t.length!==32)throw new Error("Private key must be 32 bytes");let n=r==="mainnet"?128:239,o=new Uint8Array(e?34:33);o[0]=n,o.set(t,1),e&&(o[33]=1);let s=ut(o),c=ut(s).slice(0,4),a=new Uint8Array(o.length+4);return a.set(o),a.set(c,o.length),gl(a)}function $s(t){let e=ml(t);if(e.length!==37&&e.length!==38)throw new Error("Invalid WIF length");let r=e.slice(0,-4),n=e.slice(-4),o=ut(r),i=ut(o).slice(0,4);if(!n.every((h,d)=>h===i[d]))throw new Error("Invalid WIF checksum");let c=r[0],a=c===128?"mainnet":c===239?"testnet":null;if(!a)throw new Error(`Invalid WIF version byte: 0x${c.toString(16)}`);let f=r.length===34&&r[33]===1;return{privateKey:r.slice(1,33),compressed:f,network:a}}hn.sha256=t=>ut(t);hn.hmacSha256=(t,e)=>Zi(ut,t,e);var hr=class{constructor(){u(this,"suiteId","bsv-ecdsa-secp256k1");u(this,"version","1.0.0");u(this,"capabilities",{derivation:new Ve})}async generateKeypair(){let e=Gi.randomSecretKey(),r=Ci(e,!0);return{privateKey:e,publicKey:r}}async sign(e,r){try{return Pi(r,e,{prehash:!1})}catch(n){throw new Error(`BsvEcdsaSuite signing failed: ${n instanceof Error?n.message:String(n)}`)}}async verify(e,r,n){try{return $i(n,r,e,{prehash:!1})}catch{return!1}}exportPublicKey(e){return Ir(e)}importPublicKey(e){return Qt(e)}exportPrivateKey(e){return Ps(e,!0,"mainnet")}importPrivateKey(e){if(e.length===64){let r=Qt(e);if(r.length!==32)throw new Error("Private key must be 32 bytes");return r}else try{let{privateKey:r}=$s(e);return r}catch(r){throw new Error(`Invalid private key format: ${r instanceof Error?r.message:String(r)}`)}}};y();var li=null,di=null,hi=null;async function Gl(){return li||(li=(await Promise.resolve().then(()=>(uo(),fo))).ml_dsa44),li}async function zl(){return di||(di=(await Promise.resolve().then(()=>(uo(),fo))).ml_dsa65),di}async function ql(){return hi||(hi=(await Promise.resolve().then(()=>(uo(),fo))).ml_dsa87),hi}var pi={"ml-dsa-44":{publicKey:1312,privateKey:2560,signature:2420},"ml-dsa-65":{publicKey:1952,privateKey:4032,signature:3309},"ml-dsa-87":{publicKey:2592,privateKey:4896,signature:4627}},Jr=class{constructor(){u(this,"version","2.0.0");u(this,"capabilities",{})}async generateKeypair(){try{let r=(await this.getLib()).keygen();return{publicKey:r.publicKey,privateKey:r.secretKey}}catch(e){throw new Error(`${this.suiteId} key generation failed: ${e instanceof Error?e.message:String(e)}`)}}async sign(e,r){try{return(await this.getLib()).sign(r,e)}catch(n){throw new Error(`${this.suiteId} signing failed: ${n instanceof Error?n.message:String(n)}`)}}async verify(e,r,n){try{return(await this.getLib()).verify(n,r,e)}catch{return!1}}exportPublicKey(e){return Ir(e)}importPublicKey(e){let r=Qt(e);if(r.length!==this.sizes.publicKey)throw new Error(`${this.suiteId} public key must be ${this.sizes.publicKey} bytes, got ${r.length}`);return r}exportPrivateKey(e){return Ir(e)}importPrivateKey(e){let r=Qt(e);if(r.length!==this.sizes.privateKey)throw new Error(`${this.suiteId} private key must be ${this.sizes.privateKey} bytes, got ${r.length}`);return r}},Qr=class extends Jr{constructor(){super(...arguments);u(this,"suiteId","ml-dsa-44")}get sizes(){return pi["ml-dsa-44"]}async getLib(){return Gl()}},en=class extends Jr{constructor(){super(...arguments);u(this,"suiteId","ml-dsa-65")}get sizes(){return pi["ml-dsa-65"]}async getLib(){return zl()}},xr=class extends Jr{constructor(){super(...arguments);u(this,"suiteId","ml-dsa-87")}get sizes(){return pi["ml-dsa-87"]}async getLib(){return ql()}};var tn=class{constructor(){u(this,"suites",new Map)}register(e){if(this.suites.has(e.suiteId))throw new Error(`Signature suite already registered: ${e.suiteId}`);this.suites.set(e.suiteId,e)}getSuite(e){let r=this.suites.get(e);if(!r)throw new Error(`Unknown signature suite: ${e}. Available: ${this.listSuites().join(", ")}`);return r}hasSuite(e){return this.suites.has(e)}listSuites(){return[...this.suites.keys()]}getAllSuites(){return[...this.suites.values()]}unregister(e){return this.suites.delete(e)}clear(){this.suites.clear()}},qt=new tn;qt.register(new hr);qt.register(new Qr);qt.register(new en);qt.register(new xr);y();y();var _t=class{constructor(){u(this,"keys",new Map)}async store(e,r,n){this.keys.set(e,{keypair:r,meta:n})}async load(e){return this.keys.get(e)||null}async list(e){let r=Array.from(this.keys.values()).map(n=>n.meta);return e?r.filter(n=>Object.entries(e).every(([o,s])=>o==="usage"&&Array.isArray(s)?s.some(i=>n.usage.includes(i)):n[o]===s)):r}async delete(e){this.keys.delete(e)}async updateMeta(e,r){let n=this.keys.get(e);if(!n)throw new Error(`Key not found: ${e}`);this.keys.set(e,{keypair:n.keypair,meta:{...n.meta,...r}})}clear(){this.keys.clear()}},rn=class{constructor(e=new _t){u(this,"storage");this.storage=e}async registerKey(e,r,n,o={}){let s={keyId:e,suiteId:n,createdAt:new Date().toISOString(),expiresAt:o.expiresAt,usage:o.usage||["signing"],cryptoProfileVersion:o.cryptoProfileVersion||"1.0.0",status:o.status||"active"};return await this.storage.store(e,r,s),s}async getKey(e){return await this.storage.load(e)}async getPublicKey(e){let r=await this.storage.load(e);return r?{publicKey:r.keypair.publicKey,meta:r.meta}:null}async listKeys(e){return await this.storage.list(e)}async listActiveKeys(e){let r=await this.storage.list(e),n=new Date;return r.filter(o=>!(o.status&&o.status!=="active"||o.expiresAt&&new Date(o.expiresAt)<n))}async rotateKey(e,r,n){let o=await this.storage.load(e);if(!o)throw new Error(`Cannot rotate: key not found: ${e}`);return await this.storage.updateMeta(e,{status:"rotated"}),await this.registerKey(r,n,o.meta.suiteId,{usage:o.meta.usage,cryptoProfileVersion:o.meta.cryptoProfileVersion,expiresAt:o.meta.expiresAt,status:"active"}),await this.storage.updateMeta(r,{rotatedFrom:e}),(await this.storage.load(r)).meta}async revokeKey(e,r){await this.storage.updateMeta(e,{status:"revoked",revokedAt:new Date().toISOString()})}async deleteKey(e){await this.storage.delete(e)}async markExpiredKeys(){let e=await this.storage.list(),r=new Date,n=0;for(let o of e)o.expiresAt&&new Date(o.expiresAt)<r&&o.status==="active"&&(await this.storage.updateMeta(o.keyId,{status:"expired"}),n++);return n}async pruneOldKeys(e=90){let r=await this.storage.list(),n=new Date;n.setDate(n.getDate()-e);let o=0;for(let s of r)(s.status==="revoked"&&s.revokedAt&&new Date(s.revokedAt)<n||s.status==="expired"&&s.expiresAt&&new Date(s.expiresAt)<n)&&(await this.storage.delete(s.keyId),o++);return o}};y();y();var lo=class{constructor(e){this.keyCounter=new Map;this.counterInitialized=new Set;this.counterInitPromises=new Map;this.keyRegistry=e.keyRegistry,this.suiteRegistry=e.suiteRegistry}async createKey(e,r,n={}){let o=this.suiteRegistry.getSuite(r.primarySignatureSuite),s;if(n.derivationContext){if(!o.capabilities?.derivation){let l=this.getSuitesWithCapability("derivation");throw new Error(`Suite '${o.suiteId}' does not support key derivation.
|
|
2050
2050
|
`+(l.length>0?`Suites with derivation capability: ${l.join(", ")}
|
|
2051
|
-
Consider using one of these suites or remove the derivationContext option.`:"No suites currently support derivation. Remove the derivationContext option."))}s=await o.capabilities.derivation.deriveKeypair(n.derivationContext)}else s=await o.generateKeypair();let i=await this.getNextCounter(e),c=r.primarySignatureSuite.split("-")[0],a=`${e}:pk-${c}-${i}`;return{meta:await this.keyRegistry.registerKey(a,s,r.primarySignatureSuite,{expiresAt:n.expiresAt,usage:n.usage||["signing"],cryptoProfileVersion:n.cryptoProfileVersion||"1.0.0"}),publicKey:s.publicKey}}async getKey(e){let r=await this.keyRegistry.getPublicKey(e);return r?{meta:r.meta,publicKey:r.publicKey}:null}async signWithKey(e,r){let n=await this.keyRegistry.getKey(e);if(!n)throw new Error(`Key not found: ${e}`);if(n.meta.status!=="active")throw new Error(`Key is not active: ${e} (status: ${n.meta.status})`);let o=this.suiteRegistry.getSuite(n.meta.suiteId),s=this.getHashAlgorithm(n.meta.suiteId),i=await
|
|
2051
|
+
Consider using one of these suites or remove the derivationContext option.`:"No suites currently support derivation. Remove the derivationContext option."))}s=await o.capabilities.derivation.deriveKeypair(n.derivationContext)}else s=await o.generateKeypair();let i=await this.getNextCounter(e),c=r.primarySignatureSuite.split("-")[0],a=`${e}:pk-${c}-${i}`;return{meta:await this.keyRegistry.registerKey(a,s,r.primarySignatureSuite,{expiresAt:n.expiresAt,usage:n.usage||["signing"],cryptoProfileVersion:n.cryptoProfileVersion||"1.0.0"}),publicKey:s.publicKey}}async getKey(e){let r=await this.keyRegistry.getPublicKey(e);return r?{meta:r.meta,publicKey:r.publicKey}:null}async signWithKey(e,r){let n=await this.keyRegistry.getKey(e);if(!n)throw new Error(`Key not found: ${e}`);if(n.meta.status!=="active")throw new Error(`Key is not active: ${e} (status: ${n.meta.status})`);let o=this.suiteRegistry.getSuite(n.meta.suiteId),s=this.getHashAlgorithm(n.meta.suiteId),i=await vn(r,s);return await o.sign(n.keypair.privateKey,i)}async verifySignature(e,r,n){let o=await this.keyRegistry.getPublicKey(e);if(!o)return!1;let s=this.suiteRegistry.getSuite(o.meta.suiteId),i=this.getHashAlgorithm(o.meta.suiteId),c=await vn(r,i);try{return await s.verify(o.publicKey,c,n)}catch{return!1}}async listKeysForAgent(e,r=!0){let o=(r?await this.keyRegistry.listActiveKeys():await this.keyRegistry.listKeys()).filter(i=>i.keyId.startsWith(`${e}:`)),s=[];for(let i of o){let c=await this.keyRegistry.getPublicKey(i.keyId);c&&s.push({meta:c.meta,publicKey:c.publicKey})}return s}async getActiveCryptoProfile(e){let r=await this.listKeysForAgent(e,!0);if(r.length===0)return null;let n=this.sortKeysByCreatedAt(r),o=new Set(n.map(i=>i.meta.suiteId)),s=Array.from(o);return{primarySignatureSuite:s[0],secondarySignatureSuite:s[1]}}async rotateAgentKeys(e){let r=await this.listKeysForAgent(e,!0),n=[];for(let o of r){let i=await this.suiteRegistry.getSuite(o.meta.suiteId).generateKeypair(),c=await this.getNextCounter(e),a=o.meta.suiteId.split("-")[0],f=`${e}:pk-${a}-${c}`,l=await this.keyRegistry.rotateKey(o.meta.keyId,f,i);n.push({meta:l,publicKey:i.publicKey})}return n}async getOrCreateKey(e,r,n={}){let s=(await this.listKeysForAgent(e,!0)).find(i=>i.meta.suiteId===r.primarySignatureSuite);return s||await this.createKey(e,r,n)}async createDualSignatureKeys(e,r,n={}){if(!r.secondarySignatureSuite)throw new Error("secondarySignatureSuite is required to create dual signature keys");let o=await this.createKey(e,{primarySignatureSuite:r.primarySignatureSuite},n),s=await this.createKey(e,{primarySignatureSuite:r.secondarySignatureSuite},n);return{primaryKey:o,secondaryKey:s}}async getOrCreateDualSignatureKeys(e,r,n={}){if(!r.secondarySignatureSuite)throw new Error("secondarySignatureSuite is required to create dual signature keys");let o=await this.getOrCreateKey(e,{primarySignatureSuite:r.primarySignatureSuite},n),s=await this.getOrCreateKey(e,{primarySignatureSuite:r.secondarySignatureSuite},n);return{primaryKey:o,secondaryKey:s}}async signWithSuites(e,r,n){let o=this.sortKeysByCreatedAt(await this.listKeysForAgent(e,!0));if(o.length===0)throw new Error(`No active keys found for agent: ${e}`);let s=n?.length?n:Array.from(new Set(o.map(c=>c.meta.suiteId))),i=[];for(let c of s){let a=o.find(l=>l.meta.suiteId===c);if(!a)throw new Error(`No active key for suite '${c}' and agent '${e}'`);let f=await this.signWithKey(a.meta.keyId,r);i.push({suiteId:c,keyId:a.meta.keyId,signature:f})}return{signatures:i}}async verifyWithSuites(e,r,n){let o=[];for(let s of n)try{let i=await this.verifySignature(s.keyId,r,s.signature);o.push({suiteId:s.suiteId,keyId:s.keyId,valid:i})}catch(i){o.push({suiteId:s.suiteId,keyId:s.keyId,valid:!1,error:i.message})}return{results:o,allValid:o.every(s=>s.valid)}}generateMnemonic(e=256){return new Ve().generateMnemonic(e)}async createKeyFromMnemonic(e,r,n,o=Ve.bitcoinPath(0,0,0),s,i={}){let a=new Ve().mnemonicToSeed(n,s);return await this.createKey(e,r,{...i,derivationContext:{seed:a,path:o}})}getCapabilities(e){let r=this.suiteRegistry.getSuite(e),n=[];return r.capabilities?.derivation&&n.push("derivation"),r.capabilities?.encryption&&n.push("encryption"),r.capabilities?.threshold&&n.push("threshold"),n}getSuitesWithCapability(e){return this.suiteRegistry.getAllSuites().filter(n=>!!n.capabilities?.[e]).map(n=>n.suiteId)}async createBitcoinWalletKey(e,r,n=0,o=0,s=!1,i={}){let c=Ve.bitcoinPath(n,s?1:0,o);return this.createKeyFromMnemonic(e,{primarySignatureSuite:"bsv-ecdsa-secp256k1"},r,c,void 0,i)}getHashAlgorithm(e){return e.startsWith("ml-dsa")?"sha3-256":"sha256"}async getNextCounter(e){if(!this.counterInitialized.has(e)){if(!this.counterInitPromises.has(e)){let s=(async()=>{let c=(await this.keyRegistry.listKeys()).reduce((a,f)=>{if(!f.keyId.startsWith(`${e}:pk-`))return a;let l=f.keyId.match(/:pk-[^-]+-(\d+)$/);if(!l)return a;let h=parseInt(l[1],10);return Number.isFinite(h)?Math.max(a,h):a},0);this.keyCounter.set(e,c),this.counterInitialized.add(e),this.counterInitPromises.delete(e)})();this.counterInitPromises.set(e,s)}let o=this.counterInitPromises.get(e);o&&await o}let n=(this.keyCounter.get(e)||0)+1;return this.keyCounter.set(e,n),n}sortKeysByCreatedAt(e){return[...e].sort((r,n)=>{let o=new Date(r.meta.createdAt).getTime(),s=new Date(n.meta.createdAt).getTime();if(o!==s)return o-s;let i=this.getSuitePriority(r.meta.suiteId)-this.getSuitePriority(n.meta.suiteId);return i!==0?i:r.meta.keyId.localeCompare(n.meta.keyId)})}getSuitePriority(e){return e.startsWith("ml-dsa")?0:e.includes("ecdsa")?1:2}};y();async function xi(){let t=new _t,e=new rn(t);return new lo({keyRegistry:e,suiteRegistry:qt})}var Wl={createKeySDK:xi};typeof window<"u"&&(window.LumenKeys={createKeySDK:xi});return ef(Vl);})();
|
|
2052
2052
|
/*! Bundled license information:
|
|
2053
2053
|
|
|
2054
|
-
@noble/hashes/esm/utils.js:
|
|
2055
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2056
|
-
|
|
2057
2054
|
@noble/hashes/utils.js:
|
|
2058
2055
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2059
2056
|
|
|
2060
2057
|
@noble/curves/utils.js:
|
|
2058
|
+
@noble/curves/abstract/modular.js:
|
|
2059
|
+
@noble/curves/abstract/curve.js:
|
|
2060
|
+
@noble/curves/abstract/der.js:
|
|
2061
|
+
@noble/curves/abstract/weierstrass.js:
|
|
2062
|
+
@noble/curves/secp256k1.js:
|
|
2061
2063
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2062
2064
|
|
|
2063
|
-
@noble/hashes/utils.js:
|
|
2064
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2065
|
-
|
|
2066
2065
|
@noble/post-quantum/utils.js:
|
|
2067
|
-
(*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *)
|
|
2068
|
-
|
|
2069
2066
|
@noble/post-quantum/_crystals.js:
|
|
2070
|
-
(*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *)
|
|
2071
|
-
|
|
2072
2067
|
@noble/post-quantum/ml-dsa.js:
|
|
2073
2068
|
(*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *)
|
|
2074
2069
|
|
|
2075
2070
|
@noble/secp256k1/index.js:
|
|
2076
2071
|
(*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
2077
2072
|
|
|
2078
|
-
@noble/curves/abstract/modular.js:
|
|
2079
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2080
|
-
|
|
2081
|
-
@noble/curves/abstract/curve.js:
|
|
2082
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2083
|
-
|
|
2084
|
-
@noble/curves/abstract/weierstrass.js:
|
|
2085
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2086
|
-
|
|
2087
|
-
@noble/curves/secp256k1.js:
|
|
2088
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2089
|
-
|
|
2090
|
-
@noble/hashes/utils.js:
|
|
2091
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2092
|
-
|
|
2093
2073
|
@scure/base/index.js:
|
|
2094
2074
|
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2095
2075
|
|
|
2096
2076
|
@scure/bip32/index.js:
|
|
2097
2077
|
(*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
2098
2078
|
|
|
2099
|
-
@noble/hashes/utils.js:
|
|
2100
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2101
|
-
|
|
2102
2079
|
@scure/bip39/index.js:
|
|
2103
2080
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
2104
2081
|
*/
|