@solana/webcrypto-ed25519-polyfill 2.0.0-experimental.ec2d4a4 → 2.0.0-experimental.f040ea3

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.
@@ -1,7 +1,7 @@
1
1
  (function () {
2
2
  'use strict';
3
3
 
4
- function Lt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function qe(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function ne(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function De(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Lt(t.outputLen),Lt(t.blockLen);}function Pe(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 Me(t,e){ne(t);let n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}var ke={number:Lt,bool:qe,bytes:ne,hash:De,exists:Pe,output:Me},yt=ke;var xt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var re=t=>t instanceof Uint8Array;var gt=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);var Ve=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ve)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ot(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Nt(t){if(typeof t=="string"&&(t=Ot(t)),!re(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function oe(...t){let e=new Uint8Array(t.reduce((r,o)=>r+o.length,0)),n=0;return t.forEach(r=>{if(!re(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length;}),e}var bt=class{clone(){return this._cloneInto()}};function lt(t){let e=r=>t().update(Nt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function se(t=32){if(xt&&typeof xt.getRandomValues=="function")return xt.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Ze(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);let o=BigInt(32),f=BigInt(4294967295),a=Number(n>>o&f),i=Number(n&f),s=r?4:0,l=r?0:4;t.setUint32(e+s,a,r),t.setUint32(e+l,i,r);}var wt=class extends bt{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=gt(this.buffer);}update(e){yt.exists(this);let{view:n,buffer:r,blockLen:o}=this;e=Nt(e);let f=e.length;for(let a=0;a<f;){let i=Math.min(o-this.pos,f-a);if(i===o){let s=gt(e);for(;o<=f-a;a+=o)this.process(s,a);continue}r.set(e.subarray(a,a+i),this.pos),this.pos+=i,a+=i,this.pos===o&&(this.process(n,0),this.pos=0);}return this.length+=e.length,this.roundClean(),this}digestInto(e){yt.exists(this),yt.output(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:f}=this,{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(r,0),a=0);for(let d=a;d<o;d++)n[d]=0;Ze(r,o-8,BigInt(this.length*8),f),this.process(r,0);let i=gt(e),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=s/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)i.setUint32(4*d,c[d],f);}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:n,buffer:r,length:o,finished:f,destroyed:a,pos:i}=this;return e.length=o,e.pos=i,e.finished=f,e.destroyed=a,o%n&&e.buffer.set(r),e}};var mt=BigInt(4294967295),Ct=BigInt(32);function ie(t,e=!1){return e?{h:Number(t&mt),l:Number(t>>Ct&mt)}:{h:Number(t>>Ct&mt)|0,l:Number(t&mt)|0}}function Ge(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let o=0;o<t.length;o++){let{h:f,l:a}=ie(t[o],e);[n[o],r[o]]=[f,a];}return [n,r]}var $e=(t,e)=>BigInt(t>>>0)<<Ct|BigInt(e>>>0),je=(t,e,n)=>t>>>n,ze=(t,e,n)=>t<<32-n|e>>>n,Fe=(t,e,n)=>t>>>n|e<<32-n,Ye=(t,e,n)=>t<<32-n|e>>>n,We=(t,e,n)=>t<<64-n|e>>>n-32,Xe=(t,e,n)=>t>>>n-32|e<<64-n,Qe=(t,e)=>e,Je=(t,e)=>t,tn=(t,e,n)=>t<<n|e>>>32-n,en=(t,e,n)=>e<<n|t>>>32-n,nn=(t,e,n)=>e<<n-32|t>>>64-n,rn=(t,e,n)=>t<<n-32|e>>>64-n;function on(t,e,n,r){let o=(e>>>0)+(r>>>0);return {h:t+n+(o/2**32|0)|0,l:o|0}}var sn=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),cn=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,fn=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),an=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,ln=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),un=(t,e,n,r,o,f)=>e+n+r+o+f+(t/2**32|0)|0,dn={fromBig:ie,split:Ge,toBig:$e,shrSH:je,shrSL:ze,rotrSH:Fe,rotrSL:Ye,rotrBH:We,rotrBL:Xe,rotr32H:Qe,rotr32L:Je,rotlSH:tn,rotlSL:en,rotlBH:nn,rotlBL:rn,add:on,add3L:sn,add3H:cn,add4L:fn,add4H:an,add5H:un,add5L:ln},y=dn;var [hn,pn]=y.split(["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))),Q=new Uint32Array(80),J=new Uint32Array(80),ft=class extends wt{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209;}get(){let{Ah:e,Al:n,Bh:r,Bl:o,Ch:f,Cl:a,Dh:i,Dl:s,Eh:l,El:c,Fh:d,Fl:b,Gh:N,Gl:O,Hh:C,Hl:S}=this;return [e,n,r,o,f,a,i,s,l,c,d,b,N,O,C,S]}set(e,n,r,o,f,a,i,s,l,c,d,b,N,O,C,S){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=f|0,this.Cl=a|0,this.Dh=i|0,this.Dl=s|0,this.Eh=l|0,this.El=c|0,this.Fh=d|0,this.Fl=b|0,this.Gh=N|0,this.Gl=O|0,this.Hh=C|0,this.Hl=S|0;}process(e,n){for(let m=0;m<16;m++,n+=4)Q[m]=e.getUint32(n),J[m]=e.getUint32(n+=4);for(let m=16;m<80;m++){let q=Q[m-15]|0,g=J[m-15]|0,z=y.rotrSH(q,g,1)^y.rotrSH(q,g,8)^y.shrSH(q,g,7),it=y.rotrSL(q,g,1)^y.rotrSL(q,g,8)^y.shrSL(q,g,7),D=Q[m-2]|0,k=J[m-2]|0,nt=y.rotrSH(D,k,19)^y.rotrBH(D,k,61)^y.shrSH(D,k,6),W=y.rotrSL(D,k,19)^y.rotrBL(D,k,61)^y.shrSL(D,k,6),ct=y.add4L(it,W,J[m-7],J[m-16]),rt=y.add4H(ct,z,nt,Q[m-7],Q[m-16]);Q[m]=rt|0,J[m]=ct|0;}let{Ah:r,Al:o,Bh:f,Bl:a,Ch:i,Cl:s,Dh:l,Dl:c,Eh:d,El:b,Fh:N,Fl:O,Gh:C,Gl:S,Hh:M,Hl:$}=this;for(let m=0;m<80;m++){let q=y.rotrSH(d,b,14)^y.rotrSH(d,b,18)^y.rotrBH(d,b,41),g=y.rotrSL(d,b,14)^y.rotrSL(d,b,18)^y.rotrBL(d,b,41),z=d&N^~d&C,it=b&O^~b&S,D=y.add5L($,g,it,pn[m],J[m]),k=y.add5H(D,M,q,z,hn[m],Q[m]),nt=D|0,W=y.rotrSH(r,o,28)^y.rotrBH(r,o,34)^y.rotrBH(r,o,39),ct=y.rotrSL(r,o,28)^y.rotrBL(r,o,34)^y.rotrBL(r,o,39),rt=r&f^r&i^f&i,At=o&a^o&s^a&s;M=C|0,$=S|0,C=N|0,S=O|0,N=d|0,O=b|0,{h:d,l:b}=y.add(l|0,c|0,k|0,nt|0),l=i|0,c=s|0,i=f|0,s=a|0,f=r|0,a=o|0;let dt=y.add3L(nt,ct,At);r=y.add3H(dt,k,W,rt),o=dt|0;}(({h:r,l:o}=y.add(this.Ah|0,this.Al|0,r|0,o|0))),{h:f,l:a}=y.add(this.Bh|0,this.Bl|0,f|0,a|0),{h:i,l:s}=y.add(this.Ch|0,this.Cl|0,i|0,s|0),{h:l,l:c}=y.add(this.Dh|0,this.Dl|0,l|0,c|0),{h:d,l:b}=y.add(this.Eh|0,this.El|0,d|0,b|0),{h:N,l:O}=y.add(this.Fh|0,this.Fl|0,N|0,O|0),{h:C,l:S}=y.add(this.Gh|0,this.Gl|0,C|0,S|0),{h:M,l:$}=y.add(this.Hh|0,this.Hl|0,M|0,$|0),this.set(r,o,f,a,i,s,l,c,d,b,N,O,C,S,M,$);}roundClean(){Q.fill(0),J.fill(0);}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);}},Tt=class extends ft{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28;}},Ut=class extends ft{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32;}},Kt=class extends ft{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48;}},Rt=lt(()=>new ft);lt(()=>new Tt);lt(()=>new Ut);lt(()=>new Kt);BigInt(0);var yn=BigInt(1),xn=BigInt(2),Et=t=>t instanceof Uint8Array,bn=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ut(t){if(!Et(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=bn[t[n]];return e}function ce(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function fe(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){let o=r*2,f=t.slice(o,o+2),a=Number.parseInt(f,16);if(Number.isNaN(a)||a<0)throw new Error("Invalid byte sequence");n[r]=a;}return n}function Ht(t){return ce(ut(t))}function tt(t){if(!Et(t))throw new Error("Uint8Array expected");return ce(ut(Uint8Array.from(t).reverse()))}function qt(t,e){return fe(t.toString(16).padStart(e*2,"0"))}function ot(t,e){return qt(t,e).reverse()}function V(t,e,n){let r;if(typeof e=="string")try{r=fe(e);}catch(f){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${f}`)}else if(Et(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let o=r.length;if(typeof n=="number"&&o!==n)throw new Error(`${t} expected ${n} bytes, got ${o}`);return r}function Bt(...t){let e=new Uint8Array(t.reduce((r,o)=>r+o.length,0)),n=0;return t.forEach(r=>{if(!Et(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length;}),e}var ae=t=>(xn<<BigInt(t-1))-yn;var gn={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function et(t,e,n={}){let r=(o,f,a)=>{let i=gn[f];if(typeof i!="function")throw new Error(`Invalid validator "${f}", expected function`);let s=t[o];if(!(a&&s===void 0)&&!i(s,t))throw new Error(`Invalid param ${String(o)}=${s} (${typeof s}), expected ${f}`)};for(let[o,f]of Object.entries(e))r(o,f,!1);for(let[o,f]of Object.entries(n))r(o,f,!0);return t}var T=BigInt(0),L=BigInt(1),st=BigInt(2),mn=BigInt(3),Dt=BigInt(4),le=BigInt(5),ue=BigInt(8);BigInt(9);BigInt(16);function A(t,e){let n=t%e;return n>=T?n:e+n}function he(t,e,n){if(n<=T||e<T)throw new Error("Expected power/modulo > 0");if(n===L)return T;let r=L;for(;e>T;)e&L&&(r=r*t%n),t=t*t%n,e>>=L;return r}function Z(t,e,n){let r=t;for(;e-- >T;)r*=r,r%=n;return r}function de(t,e){if(t===T||e<=T)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=A(t,e),r=e,o=T,a=L;for(;n!==T;){let l=r/n,c=r%n,d=o-a*l;r=n,n=c,o=a,a=d;}if(r!==L)throw new Error("invert: does not exist");return A(o,e)}function _n(t){let e=(t-L)/st,n,r,o;for(n=t-L,r=0;n%st===T;n/=st,r++);for(o=st;o<t&&he(o,e,t)!==t-L;o++);if(r===1){let a=(t+L)/Dt;return function(s,l){let c=s.pow(l,a);if(!s.eql(s.sqr(c),l))throw new Error("Cannot find square root");return c}}let f=(n+L)/st;return function(i,s){if(i.pow(s,e)===i.neg(i.ONE))throw new Error("Cannot find square root");let l=r,c=i.pow(i.mul(i.ONE,o),n),d=i.pow(s,f),b=i.pow(s,n);for(;!i.eql(b,i.ONE);){if(i.eql(b,i.ZERO))return i.ZERO;let N=1;for(let C=i.sqr(b);N<l&&!i.eql(C,i.ONE);N++)C=i.sqr(C);let O=i.pow(c,L<<BigInt(l-N-1));c=i.sqr(O),d=i.mul(d,O),b=i.mul(b,c),l=N;}return d}}function Sn(t){if(t%Dt===mn){let e=(t+L)/Dt;return function(r,o){let f=r.pow(o,e);if(!r.eql(r.sqr(f),o))throw new Error("Cannot find square root");return f}}if(t%ue===le){let e=(t-le)/ue;return function(r,o){let f=r.mul(o,st),a=r.pow(f,e),i=r.mul(o,a),s=r.mul(r.mul(i,st),a),l=r.mul(i,r.sub(s,r.ONE));if(!r.eql(r.sqr(l),o))throw new Error("Cannot find square root");return l}}return _n(t)}var pe=(t,e)=>(A(t,e)&L)===L,vn=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ye(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=vn.reduce((r,o)=>(r[o]="function",r),e);return et(t,n)}function An(t,e,n){if(n<T)throw new Error("Expected power > 0");if(n===T)return t.ONE;if(n===L)return e;let r=t.ONE,o=e;for(;n>T;)n&L&&(r=t.mul(r,o)),o=t.sqr(o),n>>=L;return r}function In(t,e){let n=new Array(e.length),r=e.reduce((f,a,i)=>t.is0(a)?f:(n[i]=f,t.mul(f,a)),t.ONE),o=t.inv(r);return e.reduceRight((f,a,i)=>t.is0(a)?f:(n[i]=t.mul(f,n[i]),t.mul(f,a)),o),n}function Pt(t,e){let n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return {nBitLength:n,nByteLength:r}}function xe(t,e,n=!1,r={}){if(t<=T)throw new Error(`Expected Fp ORDER > 0, got ${t}`);let{nBitLength:o,nByteLength:f}=Pt(t,e);if(f>2048)throw new Error("Field lengths over 2048 bytes are not supported");let a=Sn(t),i=Object.freeze({ORDER:t,BITS:o,BYTES:f,MASK:ae(o),ZERO:T,ONE:L,create:s=>A(s,t),isValid:s=>{if(typeof s!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof s}`);return T<=s&&s<t},is0:s=>s===T,isOdd:s=>(s&L)===L,neg:s=>A(-s,t),eql:(s,l)=>s===l,sqr:s=>A(s*s,t),add:(s,l)=>A(s+l,t),sub:(s,l)=>A(s-l,t),mul:(s,l)=>A(s*l,t),pow:(s,l)=>An(i,s,l),div:(s,l)=>A(s*de(l,t),t),sqrN:s=>s*s,addN:(s,l)=>s+l,subN:(s,l)=>s-l,mulN:(s,l)=>s*l,inv:s=>de(s,t),sqrt:r.sqrt||(s=>a(i,s)),invertBatch:s=>In(i,s),cmov:(s,l,c)=>c?l:s,toBytes:s=>n?ot(s,f):qt(s,f),fromBytes:s=>{if(s.length!==f)throw new Error(`Fp.fromBytes: expected ${f}, got ${s.length}`);return n?tt(s):Ht(s)}});return Object.freeze(i)}function be(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let n=t.sqrt(e);return t.isOdd(n)?t.neg(n):n}var Ln=BigInt(0),Mt=BigInt(1);function ge(t,e){let n=(o,f)=>{let a=f.negate();return o?a:f},r=o=>{let f=Math.ceil(e/o)+1,a=2**(o-1);return {windows:f,windowSize:a}};return {constTimeNegate:n,unsafeLadder(o,f){let a=t.ZERO,i=o;for(;f>Ln;)f&Mt&&(a=a.add(i)),i=i.double(),f>>=Mt;return a},precomputeWindow(o,f){let{windows:a,windowSize:i}=r(f),s=[],l=o,c=l;for(let d=0;d<a;d++){c=l,s.push(c);for(let b=1;b<i;b++)c=c.add(l),s.push(c);l=c.double();}return s},wNAF(o,f,a){let{windows:i,windowSize:s}=r(o),l=t.ZERO,c=t.BASE,d=BigInt(2**o-1),b=2**o,N=BigInt(o);for(let O=0;O<i;O++){let C=O*s,S=Number(a&d);a>>=N,S>s&&(S-=b,a+=Mt);let M=C,$=C+Math.abs(S)-1,m=O%2!==0,q=S<0;S===0?c=c.add(n(m,f[M])):l=l.add(n(q,f[$]));}return {p:l,f:c}},wNAFCached(o,f,a,i){let s=o._WINDOW_SIZE||1,l=f.get(o);return l||(l=this.precomputeWindow(o,s),s!==1&&f.set(o,i(l))),this.wNAF(s,l,a)}}}function we(t){return ye(t.Fp),et(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Pt(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var G=BigInt(0),P=BigInt(1),_t=BigInt(2),On=BigInt(8),Nn={zip215:!0};function Cn(t){let e=we(t);return et(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function St(t){let e=Cn(t),{Fp:n,n:r,prehash:o,hash:f,randomBytes:a,nByteLength:i,h:s}=e,l=_t<<BigInt(i*8)-P,c=n.create,d=e.uvRatio||((h,u)=>{try{return {isValid:!0,value:n.sqrt(h*n.inv(u))}}catch{return {isValid:!1,value:G}}}),b=e.adjustScalarBytes||(h=>h),N=e.domain||((h,u,p)=>{if(u.length||p)throw new Error("Contexts/pre-hash are not supported");return h}),O=h=>typeof h=="bigint"&&G<h,C=(h,u)=>O(h)&&O(u)&&h<u,S=h=>h===G||C(h,l);function M(h,u){if(C(h,u))return h;throw new Error(`Expected valid scalar < ${u}, got ${typeof h} ${h}`)}function $(h){return h===G?h:M(h,r)}let m=new Map;function q(h){if(!(h instanceof g))throw new Error("ExtendedPoint expected")}class g{constructor(u,p,x,w){if(this.ex=u,this.ey=p,this.ez=x,this.et=w,!S(u))throw new Error("x required");if(!S(p))throw new Error("y required");if(!S(x))throw new Error("z required");if(!S(w))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(u){if(u instanceof g)throw new Error("extended point not allowed");let{x:p,y:x}=u||{};if(!S(p)||!S(x))throw new Error("invalid affine point");return new g(p,x,P,c(p*x))}static normalizeZ(u){let p=n.invertBatch(u.map(x=>x.ez));return u.map((x,w)=>x.toAffine(p[w])).map(g.fromAffine)}_setWindowSize(u){this._WINDOW_SIZE=u,m.delete(this);}assertValidity(){let{a:u,d:p}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:x,ey:w,ez:E,et:_}=this,I=c(x*x),B=c(w*w),v=c(E*E),U=c(v*v),K=c(I*u),j=c(v*c(K+B)),R=c(U+c(p*c(I*B)));if(j!==R)throw new Error("bad point: equation left != right (1)");let X=c(x*w),F=c(E*_);if(X!==F)throw new Error("bad point: equation left != right (2)")}equals(u){q(u);let{ex:p,ey:x,ez:w}=this,{ex:E,ey:_,ez:I}=u,B=c(p*I),v=c(E*w),U=c(x*I),K=c(_*w);return B===v&&U===K}is0(){return this.equals(g.ZERO)}negate(){return new g(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:u}=e,{ex:p,ey:x,ez:w}=this,E=c(p*p),_=c(x*x),I=c(_t*c(w*w)),B=c(u*E),v=p+x,U=c(c(v*v)-E-_),K=B+_,j=K-I,R=B-_,X=c(U*j),F=c(K*R),ht=c(U*R),pt=c(j*K);return new g(X,F,pt,ht)}add(u){q(u);let{a:p,d:x}=e,{ex:w,ey:E,ez:_,et:I}=this,{ex:B,ey:v,ez:U,et:K}=u;if(p===BigInt(-1)){let Yt=c((E-w)*(v+B)),Wt=c((E+w)*(v-B)),It=c(Wt-Yt);if(It===G)return this.double();let Xt=c(_*_t*K),Qt=c(I*_t*U),Jt=Qt+Xt,te=Wt+Yt,ee=Qt-Xt,Ue=c(Jt*It),Ke=c(te*ee),Re=c(Jt*ee),He=c(It*te);return new g(Ue,Ke,He,Re)}let j=c(w*B),R=c(E*v),X=c(I*x*K),F=c(_*U),ht=c((w+E)*(B+v)-j-R),pt=F-X,zt=F+X,Ft=c(R-p*j),Oe=c(ht*pt),Ne=c(zt*Ft),Ce=c(ht*Ft),Te=c(pt*zt);return new g(Oe,Ne,Te,Ce)}subtract(u){return this.add(u.negate())}wNAF(u){return D.wNAFCached(this,m,u,g.normalizeZ)}multiply(u){let{p,f:x}=this.wNAF(M(u,r));return g.normalizeZ([p,x])[0]}multiplyUnsafe(u){let p=$(u);return p===G?it:this.equals(it)||p===P?this:this.equals(z)?this.wNAF(p).p:D.unsafeLadder(this,p)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return D.unsafeLadder(this,r).is0()}toAffine(u){let{ex:p,ey:x,ez:w}=this,E=this.is0();u==null&&(u=E?On:n.inv(w));let _=c(p*u),I=c(x*u),B=c(w*u);if(E)return {x:G,y:P};if(B!==P)throw new Error("invZ was invalid");return {x:_,y:I}}clearCofactor(){let{h:u}=e;return u===P?this:this.multiplyUnsafe(u)}static fromHex(u,p=!1){let{d:x,a:w}=e,E=n.BYTES;u=V("pointHex",u,E);let _=u.slice(),I=u[E-1];_[E-1]=I&-129;let B=tt(_);B===G||(p?M(B,l):M(B,n.ORDER));let v=c(B*B),U=c(v-P),K=c(x*v-w),{isValid:j,value:R}=d(U,K);if(!j)throw new Error("Point.fromHex: invalid y coordinate");let X=(R&P)===P,F=(I&128)!==0;if(!p&&R===G&&F)throw new Error("Point.fromHex: x=0 and x_0=1");return F!==X&&(R=c(-R)),g.fromAffine({x:R,y:B})}static fromPrivateKey(u){return W(u).point}toRawBytes(){let{x:u,y:p}=this.toAffine(),x=ot(p,n.BYTES);return x[x.length-1]|=u&P?128:0,x}toHex(){return ut(this.toRawBytes())}}g.BASE=new g(e.Gx,e.Gy,P,c(e.Gx*e.Gy)),g.ZERO=new g(G,P,P,G);let{BASE:z,ZERO:it}=g,D=ge(g,i*8);function k(h){return A(h,r)}function nt(h){return k(tt(h))}function W(h){let u=i;h=V("private key",h,u);let p=V("hashed private key",f(h),2*u),x=b(p.slice(0,u)),w=p.slice(u,2*u),E=nt(x),_=z.multiply(E),I=_.toRawBytes();return {head:x,prefix:w,scalar:E,point:_,pointBytes:I}}function ct(h){return W(h).pointBytes}function rt(h=new Uint8Array,...u){let p=Bt(...u);return nt(f(N(p,V("context",h),!!o)))}function At(h,u,p={}){h=V("message",h),o&&(h=o(h));let{prefix:x,scalar:w,pointBytes:E}=W(u),_=rt(p.context,x,h),I=z.multiply(_).toRawBytes(),B=rt(p.context,I,E,h),v=k(_+B*w);$(v);let U=Bt(I,ot(v,n.BYTES));return V("result",U,i*2)}let dt=Nn;function Le(h,u,p,x=dt){let{context:w,zip215:E}=x,_=n.BYTES;h=V("signature",h,2*_),u=V("message",u),o&&(u=o(u));let I=tt(h.slice(_,2*_)),B,v,U;try{B=g.fromHex(p,E),v=g.fromHex(h.slice(0,_),E),U=z.multiplyUnsafe(I);}catch{return !1}if(!E&&B.isSmallOrder())return !1;let K=rt(w,v.toRawBytes(),B.toRawBytes(),u);return v.add(B.multiplyUnsafe(K)).subtract(U).clearCofactor().equals(g.ZERO)}return z._setWindowSize(8),{CURVE:e,getPublicKey:ct,sign:At,verify:Le,ExtendedPoint:g,utils:{getExtendedPublicKey:W,randomPrivateKey:()=>a(n.BYTES),precompute(h=8,u=g.BASE){return u._setWindowSize(h),u.multiply(BigInt(3)),u}}}}BigInt(0);BigInt(1);var Vt=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),me=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);var Tn=BigInt(1),kt=BigInt(2),Un=BigInt(5),Ee=BigInt(10),Kn=BigInt(20),Rn=BigInt(40),Be=BigInt(80);function Hn(t){let e=Vt,r=t*t%e*t%e,o=Z(r,kt,e)*r%e,f=Z(o,Tn,e)*t%e,a=Z(f,Un,e)*f%e,i=Z(a,Ee,e)*a%e,s=Z(i,Kn,e)*i%e,l=Z(s,Rn,e)*s%e,c=Z(l,Be,e)*l%e,d=Z(c,Be,e)*l%e,b=Z(d,Ee,e)*a%e;return {pow_p_5_8:Z(b,kt,e)*t%e,b2:r}}function qn(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Dn(t,e){let n=Vt,r=A(e*e*e,n),o=A(r*r*e,n),f=Hn(t*o).pow_p_5_8,a=A(t*r*f,n),i=A(e*a*a,n),s=a,l=A(a*me,n),c=i===t,d=i===A(-t,n),b=i===A(-t*me,n);return c&&(a=s),(d||b)&&(a=l),pe(a,n)&&(a=A(-a,n)),{isValid:c||d,value:a}}var Y=xe(Vt,void 0,!0),Zt={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Y,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Rt,randomBytes:se,adjustScalarBytes:qn,uvRatio:Dn},at=St(Zt);function _e(t,e,n){if(e.length>255)throw new Error("Context is too big");return oe(Ot("SigEd25519 no Ed25519 collisions"),new Uint8Array([n?1:0,e.length]),e,t)}St({...Zt,domain:_e});St({...Zt,domain:_e,prehash:Rt});var Pn=(Y.ORDER+BigInt(3))/BigInt(8);Y.pow(kt,Pn);Y.sqrt(Y.neg(Y.ONE));(Y.ORDER-BigInt(5))/BigInt(8);BigInt(486662);be(Y,Y.neg(BigInt(486664)));BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235");BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578");BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838");BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Mn=new Set(["decrypt","deriveBits","deriveKey","encrypt","unwrapKey","wrapKey"]);function Gt(t){return t instanceof Uint8Array?t:new Uint8Array(ArrayBuffer.isView(t)?t.buffer:t)}var $t;function kn(t,e,n){let r=Vn(e,n),o=$t||($t=new WeakMap);return o.set(r.privateKey,t),o.set(r.publicKey,t),r}function Vn(t,e){if(e.length===0)throw new DOMException("Usages cannot be empty when creating a key.","SyntaxError");if(e.some(f=>Mn.has(f)))throw new DOMException("Unsupported key usage for an Ed25519 key.","SyntaxError");let n={[Symbol.toStringTag]:"CryptoKey",algorithm:Object.freeze({name:"Ed25519"})},r={...n,extractable:t,type:"private",usages:Object.freeze(e.filter(f=>f==="sign"))},o={...n,extractable:!0,type:"public",usages:Object.freeze(e.filter(f=>f==="verify"))};return Object.freeze({privateKey:Object.freeze(r),publicKey:Object.freeze(o)})}function jt(t){let e=$t?.get(t);if(e===void 0)throw new Error("Could not find secret key material associated with this `CryptoKey`");return e}function Se(t,e){switch(t){case"raw":{if(e.extractable===!1)throw new DOMException("key is not extractable","InvalidAccessException");if(e.type!=="public")throw new DOMException(`Unable to export a raw Ed25519 ${e.type} key`,"InvalidAccessError");return at.getPublicKey(jt(e))}default:throw new Error(`Exporting polyfilled Ed25519 keys in the "${t}" format is unimplemented`)}}function ve(t,e){let n=at.utils.randomPrivateKey();return kn(n,t,e)}function vt(t){return !!$t?.has(t)}function Ae(t,e){if(t.type!=="private"||!t.usages.includes("sign"))throw new DOMException("Unable to use this key to sign","InvalidAccessError");let n=jt(t),r=Gt(e);return at.sign(r,n)}function Ie(t,e,n){if(t.type!=="public"||!t.usages.includes("verify"))throw new DOMException("Unable to use this key to verify","InvalidAccessError");let r=at.getPublicKey(jt(t));try{return at.verify(Gt(e),Gt(n),r)}catch{return !1}}if(globalThis.isSecureContext){let t=globalThis.crypto||(globalThis.crypto={}),e=t.subtle||(t.subtle={}),n=e.exportKey;e.exportKey=async(...i)=>{let[s,l]=i;if(vt(l))return Se(...i);if(n)return await n.apply(e,i);throw new TypeError("No native `exportKey` function exists to handle this call")};let r=e.generateKey,o;e.generateKey=async(...i)=>{let[s]=i;if(s!=="Ed25519"){if(r)return await r.apply(e,i);throw new TypeError("No native `generateKey` function exists to handle this call")}let l;if(o===void 0&&(o=new Promise(c=>{if(!r){c(o=!1);return}r.apply(e,i).then(d=>{e.generateKey!==r&&(e.generateKey=r),l=d,c(o=!0);}).catch(()=>{c(o=!1);});})),typeof o=="boolean"?o:await o){if(l)return l;if(r)return await r.apply(e,i);throw new TypeError("No native `generateKey` function exists to handle this call")}else {let[c,d,b]=i;return ve(d,b)}};let f=e.sign;e.sign=async(...i)=>{let[s,l]=i;if(vt(l)){let[c,...d]=i;return Ae(...d)}else {if(f)return await f.apply(e,i);throw new TypeError("No native `sign` function exists to handle this call")}};let a=e.verify;e.verify=async(...i)=>{let[s,l]=i;if(vt(l)){let[c,...d]=i;return Ie(...d)}else {if(a)return await a.apply(e,i);throw new TypeError("No native `verify` function exists to handle this call")}};}
4
+ function Ce(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function St(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 Wt(t,e){Ce(t);let n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}var dt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Xt=t=>t instanceof Uint8Array;var pt=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);var Ue=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ue)throw new Error("Non little-endian hardware is not supported");function vt(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function At(t){if(typeof t=="string"&&(t=vt(t)),!Xt(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function Qt(...t){let e=new Uint8Array(t.reduce((r,o)=>r+o.length,0)),n=0;return t.forEach(r=>{if(!Xt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length;}),e}var ht=class{clone(){return this._cloneInto()}};function Jt(t){let e=r=>t().update(At(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function te(t=32){if(dt&&typeof dt.getRandomValues=="function")return dt.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Ke(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);let o=BigInt(32),f=BigInt(4294967295),a=Number(n>>o&f),i=Number(n&f),s=r?4:0,l=r?0:4;t.setUint32(e+s,a,r),t.setUint32(e+l,i,r);}var yt=class extends ht{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=pt(this.buffer);}update(e){St(this);let{view:n,buffer:r,blockLen:o}=this;e=At(e);let f=e.length;for(let a=0;a<f;){let i=Math.min(o-this.pos,f-a);if(i===o){let s=pt(e);for(;o<=f-a;a+=o)this.process(s,a);continue}r.set(e.subarray(a,a+i),this.pos),this.pos+=i,a+=i,this.pos===o&&(this.process(n,0),this.pos=0);}return this.length+=e.length,this.roundClean(),this}digestInto(e){St(this),Wt(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:f}=this,{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(r,0),a=0);for(let d=a;d<o;d++)n[d]=0;Ke(r,o-8,BigInt(this.length*8),f),this.process(r,0);let i=pt(e),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=s/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)i.setUint32(4*d,c[d],f);}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:n,buffer:r,length:o,finished:f,destroyed:a,pos:i}=this;return e.length=o,e.pos=i,e.finished=f,e.destroyed=a,o%n&&e.buffer.set(r),e}};var xt=BigInt(4294967295),It=BigInt(32);function ee(t,e=!1){return e?{h:Number(t&xt),l:Number(t>>It&xt)}:{h:Number(t>>It&xt)|0,l:Number(t&xt)|0}}function Re(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let o=0;o<t.length;o++){let{h:f,l:a}=ee(t[o],e);[n[o],r[o]]=[f,a];}return [n,r]}var He=(t,e)=>BigInt(t>>>0)<<It|BigInt(e>>>0),qe=(t,e,n)=>t>>>n,De=(t,e,n)=>t<<32-n|e>>>n,Pe=(t,e,n)=>t>>>n|e<<32-n,Me=(t,e,n)=>t<<32-n|e>>>n,Ze=(t,e,n)=>t<<64-n|e>>>n-32,ke=(t,e,n)=>t>>>n-32|e<<64-n,Ve=(t,e)=>e,$e=(t,e)=>t,Ge=(t,e,n)=>t<<n|e>>>32-n,Fe=(t,e,n)=>e<<n|t>>>32-n,ze=(t,e,n)=>e<<n-32|t>>>64-n,Ye=(t,e,n)=>t<<n-32|e>>>64-n;function je(t,e,n,r){let o=(e>>>0)+(r>>>0);return {h:t+n+(o/2**32|0)|0,l:o|0}}var We=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Xe=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Qe=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Je=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,tn=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),en=(t,e,n,r,o,f)=>e+n+r+o+f+(t/2**32|0)|0;var nn={fromBig:ee,split:Re,toBig:He,shrSH:qe,shrSL:De,rotrSH:Pe,rotrSL:Me,rotrBH:Ze,rotrBL:ke,rotr32H:Ve,rotr32L:$e,rotlSH:Ge,rotlSL:Fe,rotlBH:ze,rotlBL:Ye,add:je,add3L:We,add3H:Xe,add4L:Qe,add4H:Je,add5H:en,add5L:tn},y=nn;var[rn,on]=(()=>y.split(["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))))(),Q=new Uint32Array(80),J=new Uint32Array(80),Lt=class extends yt{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209;}get(){let{Ah:e,Al:n,Bh:r,Bl:o,Ch:f,Cl:a,Dh:i,Dl:s,Eh:l,El:c,Fh:d,Fl:b,Gh:T,Gl:L,Hh:O,Hl:S}=this;return [e,n,r,o,f,a,i,s,l,c,d,b,T,L,O,S]}set(e,n,r,o,f,a,i,s,l,c,d,b,T,L,O,S){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=f|0,this.Cl=a|0,this.Dh=i|0,this.Dl=s|0,this.Eh=l|0,this.El=c|0,this.Fh=d|0,this.Fl=b|0,this.Gh=T|0,this.Gl=L|0,this.Hh=O|0,this.Hl=S|0;}process(e,n){for(let m=0;m<16;m++,n+=4)Q[m]=e.getUint32(n),J[m]=e.getUint32(n+=4);for(let m=16;m<80;m++){let H=Q[m-15]|0,g=J[m-15]|0,z=y.rotrSH(H,g,1)^y.rotrSH(H,g,8)^y.shrSH(H,g,7),rt=y.rotrSL(H,g,1)^y.rotrSL(H,g,8)^y.shrSL(H,g,7),q=Q[m-2]|0,M=J[m-2]|0,tt=y.rotrSH(q,M,19)^y.rotrBH(q,M,61)^y.shrSH(q,M,6),W=y.rotrSL(q,M,19)^y.rotrBL(q,M,61)^y.shrSL(q,M,6),ot=y.add4L(rt,W,J[m-7],J[m-16]),et=y.add4H(ot,z,tt,Q[m-7],Q[m-16]);Q[m]=et|0,J[m]=ot|0;}let{Ah:r,Al:o,Bh:f,Bl:a,Ch:i,Cl:s,Dh:l,Dl:c,Eh:d,El:b,Fh:T,Fl:L,Gh:O,Gl:S,Hh:P,Hl:$}=this;for(let m=0;m<80;m++){let H=y.rotrSH(d,b,14)^y.rotrSH(d,b,18)^y.rotrBH(d,b,41),g=y.rotrSL(d,b,14)^y.rotrSL(d,b,18)^y.rotrBL(d,b,41),z=d&T^~d&O,rt=b&L^~b&S,q=y.add5L($,g,rt,on[m],J[m]),M=y.add5H(q,P,H,z,rn[m],Q[m]),tt=q|0,W=y.rotrSH(r,o,28)^y.rotrBH(r,o,34)^y.rotrBH(r,o,39),ot=y.rotrSL(r,o,28)^y.rotrBL(r,o,34)^y.rotrBL(r,o,39),et=r&f^r&i^f&i,Bt=o&a^o&s^a&s;P=O|0,$=S|0,O=T|0,S=L|0,T=d|0,L=b|0,{h:d,l:b}=y.add(l|0,c|0,M|0,tt|0),l=i|0,c=s|0,i=f|0,s=a|0,f=r|0,a=o|0;let at=y.add3L(tt,ot,Bt);r=y.add3H(at,M,W,et),o=at|0;}(({h:r,l:o}=y.add(this.Ah|0,this.Al|0,r|0,o|0))),{h:f,l:a}=y.add(this.Bh|0,this.Bl|0,f|0,a|0),{h:i,l:s}=y.add(this.Ch|0,this.Cl|0,i|0,s|0),{h:l,l:c}=y.add(this.Dh|0,this.Dl|0,l|0,c|0),{h:d,l:b}=y.add(this.Eh|0,this.El|0,d|0,b|0),{h:T,l:L}=y.add(this.Fh|0,this.Fl|0,T|0,L|0),{h:O,l:S}=y.add(this.Gh|0,this.Gl|0,O|0,S|0),{h:P,l:$}=y.add(this.Hh|0,this.Hl|0,P|0,$|0),this.set(r,o,f,a,i,s,l,c,d,b,T,L,O,S,P,$);}roundClean(){Q.fill(0),J.fill(0);}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);}};var Nt=Jt(()=>new Lt);BigInt(0);var sn=BigInt(1),cn=BigInt(2),bt=t=>t instanceof Uint8Array,fn=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function gt(t){if(!bt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=fn[t[n]];return e}function ne(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function re(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){let o=r*2,f=t.slice(o,o+2),a=Number.parseInt(f,16);if(Number.isNaN(a)||a<0)throw new Error("Invalid byte sequence");n[r]=a;}return n}function oe(t){return ne(gt(t))}function st(t){if(!bt(t))throw new Error("Uint8Array expected");return ne(gt(Uint8Array.from(t).reverse()))}function Tt(t,e){return re(t.toString(16).padStart(e*2,"0"))}function ft(t,e){return Tt(t,e).reverse()}function F(t,e,n){let r;if(typeof e=="string")try{r=re(e);}catch(f){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${f}`)}else if(bt(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let o=r.length;if(typeof n=="number"&&o!==n)throw new Error(`${t} expected ${n} bytes, got ${o}`);return r}function Ot(...t){let e=new Uint8Array(t.reduce((r,o)=>r+o.length,0)),n=0;return t.forEach(r=>{if(!bt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length;}),e}var se=t=>(cn<<BigInt(t-1))-sn;var an={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function it(t,e,n={}){let r=(o,f,a)=>{let i=an[f];if(typeof i!="function")throw new Error(`Invalid validator "${f}", expected function`);let s=t[o];if(!(a&&s===void 0)&&!i(s,t))throw new Error(`Invalid param ${String(o)}=${s} (${typeof s}), expected ${f}`)};for(let[o,f]of Object.entries(e))r(o,f,!1);for(let[o,f]of Object.entries(n))r(o,f,!0);return t}var C=BigInt(0),I=BigInt(1),nt=BigInt(2),un=BigInt(3),Ct=BigInt(4),ie=BigInt(5),ce=BigInt(8);BigInt(9);BigInt(16);function N(t,e){let n=t%e;return n>=C?n:e+n}function pn(t,e,n){if(n<=C||e<C)throw new Error("Expected power/modulo > 0");if(n===I)return C;let r=I;for(;e>C;)e&I&&(r=r*t%n),t=t*t%n,e>>=I;return r}function k(t,e,n){let r=t;for(;e-- >C;)r*=r,r%=n;return r}function fe(t,e){if(t===C||e<=C)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=N(t,e),r=e,o=C,a=I;for(;n!==C;){let l=r/n,c=r%n,d=o-a*l;r=n,n=c,o=a,a=d;}if(r!==I)throw new Error("invert: does not exist");return N(o,e)}function yn(t){let e=(t-I)/nt,n,r,o;for(n=t-I,r=0;n%nt===C;n/=nt,r++);for(o=nt;o<t&&pn(o,e,t)!==t-I;o++);if(r===1){let a=(t+I)/Ct;return function(s,l){let c=s.pow(l,a);if(!s.eql(s.sqr(c),l))throw new Error("Cannot find square root");return c}}let f=(n+I)/nt;return function(i,s){if(i.pow(s,e)===i.neg(i.ONE))throw new Error("Cannot find square root");let l=r,c=i.pow(i.mul(i.ONE,o),n),d=i.pow(s,f),b=i.pow(s,n);for(;!i.eql(b,i.ONE);){if(i.eql(b,i.ZERO))return i.ZERO;let T=1;for(let O=i.sqr(b);T<l&&!i.eql(O,i.ONE);T++)O=i.sqr(O);let L=i.pow(c,I<<BigInt(l-T-1));c=i.sqr(L),d=i.mul(d,L),b=i.mul(b,c),l=T;}return d}}function xn(t){if(t%Ct===un){let e=(t+I)/Ct;return function(r,o){let f=r.pow(o,e);if(!r.eql(r.sqr(f),o))throw new Error("Cannot find square root");return f}}if(t%ce===ie){let e=(t-ie)/ce;return function(r,o){let f=r.mul(o,nt),a=r.pow(f,e),i=r.mul(o,a),s=r.mul(r.mul(i,nt),a),l=r.mul(i,r.sub(s,r.ONE));if(!r.eql(r.sqr(l),o))throw new Error("Cannot find square root");return l}}return yn(t)}var ae=(t,e)=>(N(t,e)&I)===I,bn=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function le(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=bn.reduce((r,o)=>(r[o]="function",r),e);return it(t,n)}function gn(t,e,n){if(n<C)throw new Error("Expected power > 0");if(n===C)return t.ONE;if(n===I)return e;let r=t.ONE,o=e;for(;n>C;)n&I&&(r=t.mul(r,o)),o=t.sqr(o),n>>=I;return r}function wn(t,e){let n=new Array(e.length),r=e.reduce((f,a,i)=>t.is0(a)?f:(n[i]=f,t.mul(f,a)),t.ONE),o=t.inv(r);return e.reduceRight((f,a,i)=>t.is0(a)?f:(n[i]=t.mul(f,n[i]),t.mul(f,a)),o),n}function Ut(t,e){let n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return {nBitLength:n,nByteLength:r}}function ue(t,e,n=!1,r={}){if(t<=C)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:o,nByteLength:f}=Ut(t,e);if(f>2048)throw new Error("Field lengths over 2048 bytes are not supported");let a=xn(t),i=Object.freeze({ORDER:t,BITS:o,BYTES:f,MASK:se(o),ZERO:C,ONE:I,create:s=>N(s,t),isValid:s=>{if(typeof s!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof s}`);return C<=s&&s<t},is0:s=>s===C,isOdd:s=>(s&I)===I,neg:s=>N(-s,t),eql:(s,l)=>s===l,sqr:s=>N(s*s,t),add:(s,l)=>N(s+l,t),sub:(s,l)=>N(s-l,t),mul:(s,l)=>N(s*l,t),pow:(s,l)=>gn(i,s,l),div:(s,l)=>N(s*fe(l,t),t),sqrN:s=>s*s,addN:(s,l)=>s+l,subN:(s,l)=>s-l,mulN:(s,l)=>s*l,inv:s=>fe(s,t),sqrt:r.sqrt||(s=>a(i,s)),invertBatch:s=>wn(i,s),cmov:(s,l,c)=>c?l:s,toBytes:s=>n?ft(s,f):Tt(s,f),fromBytes:s=>{if(s.length!==f)throw new Error(`Fp.fromBytes: expected ${f}, got ${s.length}`);return n?st(s):oe(s)}});return Object.freeze(i)}function de(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let n=t.sqrt(e);return t.isOdd(n)?t.neg(n):n}var mn=BigInt(0),Kt=BigInt(1);function he(t,e){let n=(o,f)=>{let a=f.negate();return o?a:f},r=o=>{let f=Math.ceil(e/o)+1,a=2**(o-1);return {windows:f,windowSize:a}};return {constTimeNegate:n,unsafeLadder(o,f){let a=t.ZERO,i=o;for(;f>mn;)f&Kt&&(a=a.add(i)),i=i.double(),f>>=Kt;return a},precomputeWindow(o,f){let{windows:a,windowSize:i}=r(f),s=[],l=o,c=l;for(let d=0;d<a;d++){c=l,s.push(c);for(let b=1;b<i;b++)c=c.add(l),s.push(c);l=c.double();}return s},wNAF(o,f,a){let{windows:i,windowSize:s}=r(o),l=t.ZERO,c=t.BASE,d=BigInt(2**o-1),b=2**o,T=BigInt(o);for(let L=0;L<i;L++){let O=L*s,S=Number(a&d);a>>=T,S>s&&(S-=b,a+=Kt);let P=O,$=O+Math.abs(S)-1,m=L%2!==0,H=S<0;S===0?c=c.add(n(m,f[P])):l=l.add(n(H,f[$]));}return {p:l,f:c}},wNAFCached(o,f,a,i){let s=o._WINDOW_SIZE||1,l=f.get(o);return l||(l=this.precomputeWindow(o,s),s!==1&&f.set(o,i(l))),this.wNAF(s,l,a)}}}function pe(t){return le(t.Fp),it(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ut(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var V=BigInt(0),D=BigInt(1),wt=BigInt(2),En=BigInt(8),Bn={zip215:!0};function _n(t){let e=pe(t);return it(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function mt(t){let e=_n(t),{Fp:n,n:r,prehash:o,hash:f,randomBytes:a,nByteLength:i,h:s}=e,l=wt<<BigInt(i*8)-D,c=n.create,d=e.uvRatio||((h,u)=>{try{return {isValid:!0,value:n.sqrt(h*n.inv(u))}}catch{return {isValid:!1,value:V}}}),b=e.adjustScalarBytes||(h=>h),T=e.domain||((h,u,p)=>{if(u.length||p)throw new Error("Contexts/pre-hash are not supported");return h}),L=h=>typeof h=="bigint"&&V<h,O=(h,u)=>L(h)&&L(u)&&h<u,S=h=>h===V||O(h,l);function P(h,u){if(O(h,u))return h;throw new Error(`Expected valid scalar < ${u}, got ${typeof h} ${h}`)}function $(h){return h===V?h:P(h,r)}let m=new Map;function H(h){if(!(h instanceof g))throw new Error("ExtendedPoint expected")}class g{constructor(u,p,x,w){if(this.ex=u,this.ey=p,this.ez=x,this.et=w,!S(u))throw new Error("x required");if(!S(p))throw new Error("y required");if(!S(x))throw new Error("z required");if(!S(w))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(u){if(u instanceof g)throw new Error("extended point not allowed");let{x:p,y:x}=u||{};if(!S(p)||!S(x))throw new Error("invalid affine point");return new g(p,x,D,c(p*x))}static normalizeZ(u){let p=n.invertBatch(u.map(x=>x.ez));return u.map((x,w)=>x.toAffine(p[w])).map(g.fromAffine)}_setWindowSize(u){this._WINDOW_SIZE=u,m.delete(this);}assertValidity(){let{a:u,d:p}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:x,ey:w,ez:E,et:_}=this,A=c(x*x),B=c(w*w),v=c(E*E),U=c(v*v),K=c(A*u),G=c(v*c(K+B)),R=c(U+c(p*c(A*B)));if(G!==R)throw new Error("bad point: equation left != right (1)");let X=c(x*w),Y=c(E*_);if(X!==Y)throw new Error("bad point: equation left != right (2)")}equals(u){H(u);let{ex:p,ey:x,ez:w}=this,{ex:E,ey:_,ez:A}=u,B=c(p*A),v=c(E*w),U=c(x*A),K=c(_*w);return B===v&&U===K}is0(){return this.equals(g.ZERO)}negate(){return new g(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:u}=e,{ex:p,ey:x,ez:w}=this,E=c(p*p),_=c(x*x),A=c(wt*c(w*w)),B=c(u*E),v=p+x,U=c(c(v*v)-E-_),K=B+_,G=K-A,R=B-_,X=c(U*G),Y=c(K*R),lt=c(U*R),ut=c(G*K);return new g(X,Y,ut,lt)}add(u){H(u);let{a:p,d:x}=e,{ex:w,ey:E,ez:_,et:A}=this,{ex:B,ey:v,ez:U,et:K}=u;if(p===BigInt(-1)){let Vt=c((E-w)*(v+B)),$t=c((E+w)*(v-B)),_t=c($t-Vt);if(_t===V)return this.double();let Gt=c(_*wt*K),Ft=c(A*wt*U),zt=Ft+Gt,Yt=$t+Vt,jt=Ft-Gt,Le=c(zt*_t),Ne=c(Yt*jt),Te=c(zt*jt),Oe=c(_t*Yt);return new g(Le,Ne,Oe,Te)}let G=c(w*B),R=c(E*v),X=c(A*x*K),Y=c(_*U),lt=c((w+E)*(B+v)-G-R),ut=Y-X,Zt=Y+X,kt=c(R-p*G),Se=c(lt*ut),ve=c(Zt*kt),Ae=c(lt*kt),Ie=c(ut*Zt);return new g(Se,ve,Ie,Ae)}subtract(u){return this.add(u.negate())}wNAF(u){return q.wNAFCached(this,m,u,g.normalizeZ)}multiply(u){let{p,f:x}=this.wNAF(P(u,r));return g.normalizeZ([p,x])[0]}multiplyUnsafe(u){let p=$(u);return p===V?rt:this.equals(rt)||p===D?this:this.equals(z)?this.wNAF(p).p:q.unsafeLadder(this,p)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return q.unsafeLadder(this,r).is0()}toAffine(u){let{ex:p,ey:x,ez:w}=this,E=this.is0();u==null&&(u=E?En:n.inv(w));let _=c(p*u),A=c(x*u),B=c(w*u);if(E)return {x:V,y:D};if(B!==D)throw new Error("invZ was invalid");return {x:_,y:A}}clearCofactor(){let{h:u}=e;return u===D?this:this.multiplyUnsafe(u)}static fromHex(u,p=!1){let{d:x,a:w}=e,E=n.BYTES;u=F("pointHex",u,E);let _=u.slice(),A=u[E-1];_[E-1]=A&-129;let B=st(_);B===V||(p?P(B,l):P(B,n.ORDER));let v=c(B*B),U=c(v-D),K=c(x*v-w),{isValid:G,value:R}=d(U,K);if(!G)throw new Error("Point.fromHex: invalid y coordinate");let X=(R&D)===D,Y=(A&128)!==0;if(!p&&R===V&&Y)throw new Error("Point.fromHex: x=0 and x_0=1");return Y!==X&&(R=c(-R)),g.fromAffine({x:R,y:B})}static fromPrivateKey(u){return W(u).point}toRawBytes(){let{x:u,y:p}=this.toAffine(),x=ft(p,n.BYTES);return x[x.length-1]|=u&D?128:0,x}toHex(){return gt(this.toRawBytes())}}g.BASE=new g(e.Gx,e.Gy,D,c(e.Gx*e.Gy)),g.ZERO=new g(V,D,D,V);let{BASE:z,ZERO:rt}=g,q=he(g,i*8);function M(h){return N(h,r)}function tt(h){return M(st(h))}function W(h){let u=i;h=F("private key",h,u);let p=F("hashed private key",f(h),2*u),x=b(p.slice(0,u)),w=p.slice(u,2*u),E=tt(x),_=z.multiply(E),A=_.toRawBytes();return {head:x,prefix:w,scalar:E,point:_,pointBytes:A}}function ot(h){return W(h).pointBytes}function et(h=new Uint8Array,...u){let p=Ot(...u);return tt(f(T(p,F("context",h),!!o)))}function Bt(h,u,p={}){h=F("message",h),o&&(h=o(h));let{prefix:x,scalar:w,pointBytes:E}=W(u),_=et(p.context,x,h),A=z.multiply(_).toRawBytes(),B=et(p.context,A,E,h),v=M(_+B*w);$(v);let U=Ot(A,ft(v,n.BYTES));return F("result",U,i*2)}let at=Bn;function _e(h,u,p,x=at){let{context:w,zip215:E}=x,_=n.BYTES;h=F("signature",h,2*_),u=F("message",u),o&&(u=o(u));let A=st(h.slice(_,2*_)),B,v,U;try{B=g.fromHex(p,E),v=g.fromHex(h.slice(0,_),E),U=z.multiplyUnsafe(A);}catch{return !1}if(!E&&B.isSmallOrder())return !1;let K=et(w,v.toRawBytes(),B.toRawBytes(),u);return v.add(B.multiplyUnsafe(K)).subtract(U).clearCofactor().equals(g.ZERO)}return z._setWindowSize(8),{CURVE:e,getPublicKey:ot,sign:Bt,verify:_e,ExtendedPoint:g,utils:{getExtendedPublicKey:W,randomPrivateKey:()=>a(n.BYTES),precompute(h=8,u=g.BASE){return u._setWindowSize(h),u.multiply(BigInt(3)),u}}}}var Ht=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ye=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);var Sn=BigInt(1),Rt=BigInt(2),vn=BigInt(5),xe=BigInt(10),An=BigInt(20),In=BigInt(40),be=BigInt(80);function Ln(t){let e=Ht,r=t*t%e*t%e,o=k(r,Rt,e)*r%e,f=k(o,Sn,e)*t%e,a=k(f,vn,e)*f%e,i=k(a,xe,e)*a%e,s=k(i,An,e)*i%e,l=k(s,In,e)*s%e,c=k(l,be,e)*l%e,d=k(c,be,e)*l%e,b=k(d,xe,e)*a%e;return {pow_p_5_8:k(b,Rt,e)*t%e,b2:r}}function Nn(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Tn(t,e){let n=Ht,r=N(e*e*e,n),o=N(r*r*e,n),f=Ln(t*o).pow_p_5_8,a=N(t*r*f,n),i=N(e*a*a,n),s=a,l=N(a*ye,n),c=i===t,d=i===N(-t,n),b=i===N(-t*ye,n);return c&&(a=s),(d||b)&&(a=l),ae(a,n)&&(a=N(-a,n)),{isValid:c||d,value:a}}var j=ue(Ht,void 0,!0),qt={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:j,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Nt,randomBytes:te,adjustScalarBytes:Nn,uvRatio:Tn},ct=mt(qt);function ge(t,e,n){if(e.length>255)throw new Error("Context is too big");return Qt(vt("SigEd25519 no Ed25519 collisions"),new Uint8Array([n?1:0,e.length]),e,t)}mt({...qt,domain:ge});mt({...qt,domain:ge,prehash:Nt});var On=(j.ORDER+BigInt(3))/BigInt(8);j.pow(Rt,On);j.sqrt(j.neg(j.ONE));(j.ORDER-BigInt(5))/BigInt(8);BigInt(486662);de(j,j.neg(BigInt(486664)));BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235");BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578");BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838");BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Cn=new Set(["decrypt","deriveBits","deriveKey","encrypt","unwrapKey","wrapKey"]);function Dt(t){return t instanceof Uint8Array?t:new Uint8Array(ArrayBuffer.isView(t)?t.buffer:t)}var Pt;function Un(t,e,n){let r=Kn(e,n),o=Pt||(Pt=new WeakMap);return o.set(r.privateKey,t),o.set(r.publicKey,t),r}function Kn(t,e){if(e.length===0)throw new DOMException("Usages cannot be empty when creating a key.","SyntaxError");if(e.some(f=>Cn.has(f)))throw new DOMException("Unsupported key usage for an Ed25519 key.","SyntaxError");let n={[Symbol.toStringTag]:"CryptoKey",algorithm:Object.freeze({name:"Ed25519"})},r={...n,extractable:t,type:"private",usages:Object.freeze(e.filter(f=>f==="sign"))},o={...n,extractable:!0,type:"public",usages:Object.freeze(e.filter(f=>f==="verify"))};return Object.freeze({privateKey:Object.freeze(r),publicKey:Object.freeze(o)})}function Mt(t){let e=Pt?.get(t);if(e===void 0)throw new Error("Could not find secret key material associated with this `CryptoKey`");return e}function we(t,e){switch(t){case"raw":{if(e.extractable===!1)throw new DOMException("key is not extractable","InvalidAccessException");if(e.type!=="public")throw new DOMException(`Unable to export a raw Ed25519 ${e.type} key`,"InvalidAccessError");return ct.getPublicKey(Mt(e))}default:throw new Error(`Exporting polyfilled Ed25519 keys in the "${t}" format is unimplemented`)}}function me(t,e){let n=ct.utils.randomPrivateKey();return Un(n,t,e)}function Et(t){return !!Pt?.has(t)}function Ee(t,e){if(t.type!=="private"||!t.usages.includes("sign"))throw new DOMException("Unable to use this key to sign","InvalidAccessError");let n=Mt(t),r=Dt(e);return ct.sign(r,n)}function Be(t,e,n){if(t.type!=="public"||!t.usages.includes("verify"))throw new DOMException("Unable to use this key to verify","InvalidAccessError");let r=ct.getPublicKey(Mt(t));try{return ct.verify(Dt(e),Dt(n),r)}catch{return !1}}if(globalThis.isSecureContext){let t=globalThis.crypto||(globalThis.crypto={}),e=t.subtle||(t.subtle={}),n=e.exportKey;e.exportKey=async(...i)=>{let[s,l]=i;if(Et(l))return we(...i);if(n)return await n.apply(e,i);throw new TypeError("No native `exportKey` function exists to handle this call")};let r=e.generateKey,o;e.generateKey=async(...i)=>{let[s]=i;if(s!=="Ed25519"){if(r)return await r.apply(e,i);throw new TypeError("No native `generateKey` function exists to handle this call")}let l;if(o===void 0&&(o=new Promise(c=>{if(!r){c(o=!1);return}r.apply(e,i).then(d=>{e.generateKey!==r&&(e.generateKey=r),l=d,c(o=!0);}).catch(()=>{c(o=!1);});})),typeof o=="boolean"?o:await o){if(l)return l;if(r)return await r.apply(e,i);throw new TypeError("No native `generateKey` function exists to handle this call")}else {let[c,d,b]=i;return me(d,b)}};let f=e.sign;e.sign=async(...i)=>{let[s,l]=i;if(Et(l)){let[c,...d]=i;return Ee(...d)}else {if(f)return await f.apply(e,i);throw new TypeError("No native `sign` function exists to handle this call")}};let a=e.verify;e.verify=async(...i)=>{let[s,l]=i;if(Et(l)){let[c,...d]=i;return Be(...d)}else {if(a)return await a.apply(e,i);throw new TypeError("No native `verify` function exists to handle this call")}};}
5
5
  /*! Bundled license information:
6
6
 
7
7
  @noble/hashes/esm/utils.js:
@@ -19,9 +19,6 @@
19
19
  @noble/curves/esm/abstract/edwards.js:
20
20
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
21
21
 
22
- @noble/curves/esm/abstract/montgomery.js:
23
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
24
-
25
22
  @noble/curves/esm/ed25519.js:
26
23
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
27
24
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/secrets.ts"],"names":[],"mappings":"AAoFA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,GAAG,UAAU,CAAC;AAC7E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,GAAG,WAAW,CAAC;AAkBlF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,QAAQ,EAAE,GAAG,aAAa,CAIvG;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAEvD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,GAAG,WAAW,CAQ5E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAUnG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/webcrypto-ed25519-polyfill",
3
- "version": "2.0.0-experimental.ec2d4a4",
3
+ "version": "2.0.0-experimental.f040ea3",
4
4
  "description": "A polyfill that adds Ed25519 key manipulation capabilities to `SubtleCrypto` in environments where it is not yet supported",
5
5
  "exports": {
6
6
  "browser": {
@@ -49,24 +49,24 @@
49
49
  "node": ">=17.4"
50
50
  },
51
51
  "dependencies": {
52
- "@noble/curves": "^1.1.0"
52
+ "@noble/curves": "^1.2.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@solana/eslint-config-solana": "^1.0.2",
56
56
  "@swc/jest": "^0.2.28",
57
- "@types/jest": "^29.5.3",
58
- "@typescript-eslint/eslint-plugin": "^6.3.0",
57
+ "@types/jest": "^29.5.5",
58
+ "@typescript-eslint/eslint-plugin": "^6.7.0",
59
59
  "@typescript-eslint/parser": "^6.3.0",
60
60
  "eslint": "^8.45.0",
61
61
  "eslint-plugin-jest": "^27.2.3",
62
62
  "eslint-plugin-sort-keys-fix": "^1.1.2",
63
- "jest": "^29.6.1",
64
- "jest-environment-jsdom": "^29.6.2",
63
+ "jest": "^29.7.0",
64
+ "jest-environment-jsdom": "^29.6.4",
65
65
  "jest-runner-eslint": "^2.1.0",
66
66
  "jest-runner-prettier": "^1.0.0",
67
67
  "prettier": "^2.8",
68
68
  "tsup": "7.2.0",
69
- "typescript": "^5.1.6",
69
+ "typescript": "^5.2.2",
70
70
  "version-from-git": "^1.1.1",
71
71
  "build-scripts": "0.0.0",
72
72
  "test-config": "0.0.0",
@@ -85,6 +85,7 @@
85
85
  "compile:typedefs": "tsc -p ./tsconfig.declarations.json",
86
86
  "dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
87
87
  "publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",
88
+ "style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/*",
88
89
  "test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
89
90
  "test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
90
91
  "test:typecheck": "tsc --noEmit",