@solana/webcrypto-ed25519-polyfill 2.0.0-experimental.6cedd3a → 2.0.0-experimental.6ec1b2d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/index.browser.cjs +84 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +84 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +84 -0
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +84 -0
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +84 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +84 -0
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +1 -1
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/secrets.d.ts +5 -0
- package/dist/types/secrets.d.ts.map +1 -0
- package/package.json +7 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
function It(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Ne(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function Xt(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 Te(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");It(t.outputLen),It(t.blockLen);}function Ue(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 Ce(t,e){Xt(t);let n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}var He={number:It,bool:Ne,bytes:Xt,hash:Te,exists:Ue,output:Ce},pt=He;var xt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Qt=t=>t instanceof Uint8Array;var bt=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);var Re=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Re)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function At(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Lt(t){if(typeof t=="string"&&(t=At(t)),!Qt(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function Jt(...t){let e=new Uint8Array(t.reduce((r,o)=>r+o.length,0)),n=0;return t.forEach(r=>{if(!Qt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length;}),e}var yt=class{clone(){return this._cloneInto()}};function at(t){let e=r=>t().update(Lt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function te(t=32){if(xt&&typeof xt.getRandomValues=="function")return xt.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function qe(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);let o=BigInt(32),i=BigInt(4294967295),f=Number(n>>o&i),a=Number(n&i),s=r?4:0,u=r?0:4;t.setUint32(e+s,f,r),t.setUint32(e+u,a,r);}var gt=class extends yt{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=bt(this.buffer);}update(e){pt.exists(this);let{view:n,buffer:r,blockLen:o}=this;e=Lt(e);let i=e.length;for(let f=0;f<i;){let a=Math.min(o-this.pos,i-f);if(a===o){let s=bt(e);for(;o<=i-f;f+=o)this.process(s,f);continue}r.set(e.subarray(f,f+a),this.pos),this.pos+=a,f+=a,this.pos===o&&(this.process(n,0),this.pos=0);}return this.length+=e.length,this.roundClean(),this}digestInto(e){pt.exists(this),pt.output(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:f}=this;n[f++]=128,this.buffer.subarray(f).fill(0),this.padOffset>o-f&&(this.process(r,0),f=0);for(let p=f;p<o;p++)n[p]=0;qe(r,o-8,BigInt(this.length*8),i),this.process(r,0);let a=bt(e),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=s/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<u;p++)a.setUint32(4*p,c[p],i);}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:i,destroyed:f,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=f,o%n&&e.buffer.set(r),e}};var wt=BigInt(4294967295),Ot=BigInt(32);function ee(t,e=!1){return e?{h:Number(t&wt),l:Number(t>>Ot&wt)}:{h:Number(t>>Ot&wt)|0,l:Number(t&wt)|0}}function De(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let o=0;o<t.length;o++){let{h:i,l:f}=ee(t[o],e);[n[o],r[o]]=[i,f];}return [n,r]}var Ke=(t,e)=>BigInt(t>>>0)<<Ot|BigInt(e>>>0),Me=(t,e,n)=>t>>>n,ke=(t,e,n)=>t<<32-n|e>>>n,Ve=(t,e,n)=>t>>>n|e<<32-n,Ze=(t,e,n)=>t<<32-n|e>>>n,Ge=(t,e,n)=>t<<64-n|e>>>n-32,Pe=(t,e,n)=>t>>>n-32|e<<64-n,$e=(t,e)=>e,ze=(t,e)=>t,je=(t,e,n)=>t<<n|e>>>32-n,Fe=(t,e,n)=>e<<n|t>>>32-n,Ye=(t,e,n)=>e<<n-32|t>>>64-n,We=(t,e,n)=>t<<n-32|e>>>64-n;function Xe(t,e,n,r){let o=(e>>>0)+(r>>>0);return {h:t+n+(o/2**32|0)|0,l:o|0}}var Qe=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Je=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,tn=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),en=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,nn=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),rn=(t,e,n,r,o,i)=>e+n+r+o+i+(t/2**32|0)|0,on={fromBig:ee,split:De,toBig:Ke,shrSH:Me,shrSL:ke,rotrSH:Ve,rotrSL:Ze,rotrBH:Ge,rotrBL:Pe,rotr32H:$e,rotr32L:ze,rotlSH:je,rotlSL:Fe,rotlBH:Ye,rotlBL:We,add:Xe,add3L:Qe,add3H:Je,add4L:tn,add4H:en,add5H:rn,add5L:nn},x=on;var [sn,cn]=x.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 gt{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:i,Cl:f,Dh:a,Dl:s,Eh:u,El:c,Fh:p,Fl:b,Gh:N,Gl:O,Hh:T,Hl:S}=this;return [e,n,r,o,i,f,a,s,u,c,p,b,N,O,T,S]}set(e,n,r,o,i,f,a,s,u,c,p,b,N,O,T,S){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=f|0,this.Dh=a|0,this.Dl=s|0,this.Eh=u|0,this.El=c|0,this.Fh=p|0,this.Fl=b|0,this.Gh=N|0,this.Gl=O|0,this.Hh=T|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 D=Q[m-15]|0,g=J[m-15]|0,j=x.rotrSH(D,g,1)^x.rotrSH(D,g,8)^x.shrSH(D,g,7),it=x.rotrSL(D,g,1)^x.rotrSL(D,g,8)^x.shrSL(D,g,7),K=Q[m-2]|0,V=J[m-2]|0,nt=x.rotrSH(K,V,19)^x.rotrBH(K,V,61)^x.shrSH(K,V,6),W=x.rotrSL(K,V,19)^x.rotrBL(K,V,61)^x.shrSL(K,V,6),ct=x.add4L(it,W,J[m-7],J[m-16]),rt=x.add4H(ct,j,nt,Q[m-7],Q[m-16]);Q[m]=rt|0,J[m]=ct|0;}let{Ah:r,Al:o,Bh:i,Bl:f,Ch:a,Cl:s,Dh:u,Dl:c,Eh:p,El:b,Fh:N,Fl:O,Gh:T,Gl:S,Hh:k,Hl:$}=this;for(let m=0;m<80;m++){let D=x.rotrSH(p,b,14)^x.rotrSH(p,b,18)^x.rotrBH(p,b,41),g=x.rotrSL(p,b,14)^x.rotrSL(p,b,18)^x.rotrBL(p,b,41),j=p&N^~p&T,it=b&O^~b&S,K=x.add5L($,g,it,cn[m],J[m]),V=x.add5H(K,k,D,j,sn[m],Q[m]),nt=K|0,W=x.rotrSH(r,o,28)^x.rotrBH(r,o,34)^x.rotrBH(r,o,39),ct=x.rotrSL(r,o,28)^x.rotrBL(r,o,34)^x.rotrBL(r,o,39),rt=r&i^r&a^i&a,St=o&f^o&s^f&s;k=T|0,$=S|0,T=N|0,S=O|0,N=p|0,O=b|0,{h:p,l:b}=x.add(u|0,c|0,V|0,nt|0),u=a|0,c=s|0,a=i|0,s=f|0,i=r|0,f=o|0;let ut=x.add3L(nt,ct,St);r=x.add3H(ut,V,W,rt),o=ut|0;}(({h:r,l:o}=x.add(this.Ah|0,this.Al|0,r|0,o|0))),{h:i,l:f}=x.add(this.Bh|0,this.Bl|0,i|0,f|0),{h:a,l:s}=x.add(this.Ch|0,this.Cl|0,a|0,s|0),{h:u,l:c}=x.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:p,l:b}=x.add(this.Eh|0,this.El|0,p|0,b|0),{h:N,l:O}=x.add(this.Fh|0,this.Fl|0,N|0,O|0),{h:T,l:S}=x.add(this.Gh|0,this.Gl|0,T|0,S|0),{h:k,l:$}=x.add(this.Hh|0,this.Hl|0,k|0,$|0),this.set(r,o,i,f,a,s,u,c,p,b,N,O,T,S,k,$);}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);}},Nt=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;}},Tt=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;}},Ut=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;}},Ct=at(()=>new ft);at(()=>new Nt);at(()=>new Tt);at(()=>new Ut);BigInt(0);var fn=BigInt(1),an=BigInt(2),mt=t=>t instanceof Uint8Array,ln=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function lt(t){if(!mt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=ln[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,i=t.slice(o,o+2),f=Number.parseInt(i,16);if(Number.isNaN(f)||f<0)throw new Error("Invalid byte sequence");n[r]=f;}return n}function Ht(t){return ne(lt(t))}function tt(t){if(!mt(t))throw new Error("Uint8Array expected");return ne(lt(Uint8Array.from(t).reverse()))}function Rt(t,e){return re(t.toString(16).padStart(e*2,"0"))}function ot(t,e){return Rt(t,e).reverse()}function Z(t,e,n){let r;if(typeof e=="string")try{r=re(e);}catch(i){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`)}else if(mt(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 Et(...t){let e=new Uint8Array(t.reduce((r,o)=>r+o.length,0)),n=0;return t.forEach(r=>{if(!mt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length;}),e}var oe=t=>(an<<BigInt(t-1))-fn;var un={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,i,f)=>{let a=un[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let s=t[o];if(!(f&&s===void 0)&&!a(s,t))throw new Error(`Invalid param ${String(o)}=${s} (${typeof s}), expected ${i}`)};for(let[o,i]of Object.entries(e))r(o,i,!1);for(let[o,i]of Object.entries(n))r(o,i,!0);return t}var U=BigInt(0),L=BigInt(1),st=BigInt(2),hn=BigInt(3),qt=BigInt(4),se=BigInt(5),ie=BigInt(8);BigInt(9);BigInt(16);function I(t,e){let n=t%e;return n>=U?n:e+n}function fe(t,e,n){if(n<=U||e<U)throw new Error("Expected power/modulo > 0");if(n===L)return U;let r=L;for(;e>U;)e&L&&(r=r*t%n),t=t*t%n,e>>=L;return r}function G(t,e,n){let r=t;for(;e-- >U;)r*=r,r%=n;return r}function ce(t,e){if(t===U||e<=U)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=I(t,e),r=e,o=U,f=L;for(;n!==U;){let u=r/n,c=r%n,p=o-f*u;r=n,n=c,o=f,f=p;}if(r!==L)throw new Error("invert: does not exist");return I(o,e)}function yn(t){let e=(t-L)/st,n,r,o;for(n=t-L,r=0;n%st===U;n/=st,r++);for(o=st;o<t&&fe(o,e,t)!==t-L;o++);if(r===1){let f=(t+L)/qt;return function(s,u){let c=s.pow(u,f);if(!s.eql(s.sqr(c),u))throw new Error("Cannot find square root");return c}}let i=(n+L)/st;return function(a,s){if(a.pow(s,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=r,c=a.pow(a.mul(a.ONE,o),n),p=a.pow(s,i),b=a.pow(s,n);for(;!a.eql(b,a.ONE);){if(a.eql(b,a.ZERO))return a.ZERO;let N=1;for(let T=a.sqr(b);N<u&&!a.eql(T,a.ONE);N++)T=a.sqr(T);let O=a.pow(c,L<<BigInt(u-N-1));c=a.sqr(O),p=a.mul(p,O),b=a.mul(b,c),u=N;}return p}}function bn(t){if(t%qt===hn){let e=(t+L)/qt;return function(r,o){let i=r.pow(o,e);if(!r.eql(r.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%ie===se){let e=(t-se)/ie;return function(r,o){let i=r.mul(o,st),f=r.pow(i,e),a=r.mul(o,f),s=r.mul(r.mul(a,st),f),u=r.mul(a,r.sub(s,r.ONE));if(!r.eql(r.sqr(u),o))throw new Error("Cannot find square root");return u}}return yn(t)}var ae=(t,e)=>(I(t,e)&L)===L,gn=["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=gn.reduce((r,o)=>(r[o]="function",r),e);return et(t,n)}function wn(t,e,n){if(n<U)throw new Error("Expected power > 0");if(n===U)return t.ONE;if(n===L)return e;let r=t.ONE,o=e;for(;n>U;)n&L&&(r=t.mul(r,o)),o=t.sqr(o),n>>=L;return r}function mn(t,e){let n=new Array(e.length),r=e.reduce((i,f,a)=>t.is0(f)?i:(n[a]=i,t.mul(i,f)),t.ONE),o=t.inv(r);return e.reduceRight((i,f,a)=>t.is0(f)?i:(n[a]=t.mul(i,n[a]),t.mul(i,f)),o),n}function Dt(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<=U)throw new Error(`Expected Fp ORDER > 0, got ${t}`);let{nBitLength:o,nByteLength:i}=Dt(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let f=bn(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:oe(o),ZERO:U,ONE:L,create:s=>I(s,t),isValid:s=>{if(typeof s!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof s}`);return U<=s&&s<t},is0:s=>s===U,isOdd:s=>(s&L)===L,neg:s=>I(-s,t),eql:(s,u)=>s===u,sqr:s=>I(s*s,t),add:(s,u)=>I(s+u,t),sub:(s,u)=>I(s-u,t),mul:(s,u)=>I(s*u,t),pow:(s,u)=>wn(a,s,u),div:(s,u)=>I(s*ce(u,t),t),sqrN:s=>s*s,addN:(s,u)=>s+u,subN:(s,u)=>s-u,mulN:(s,u)=>s*u,inv:s=>ce(s,t),sqrt:r.sqrt||(s=>f(a,s)),invertBatch:s=>mn(a,s),cmov:(s,u,c)=>c?u:s,toBytes:s=>n?ot(s,i):Rt(s,i),fromBytes:s=>{if(s.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${s.length}`);return n?tt(s):Ht(s)}});return Object.freeze(a)}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 En=BigInt(0),Kt=BigInt(1);function he(t,e){let n=(o,i)=>{let f=i.negate();return o?f:i},r=o=>{let i=Math.ceil(e/o)+1,f=2**(o-1);return {windows:i,windowSize:f}};return {constTimeNegate:n,unsafeLadder(o,i){let f=t.ZERO,a=o;for(;i>En;)i&Kt&&(f=f.add(a)),a=a.double(),i>>=Kt;return f},precomputeWindow(o,i){let{windows:f,windowSize:a}=r(i),s=[],u=o,c=u;for(let p=0;p<f;p++){c=u,s.push(c);for(let b=1;b<a;b++)c=c.add(u),s.push(c);u=c.double();}return s},wNAF(o,i,f){let{windows:a,windowSize:s}=r(o),u=t.ZERO,c=t.BASE,p=BigInt(2**o-1),b=2**o,N=BigInt(o);for(let O=0;O<a;O++){let T=O*s,S=Number(f&p);f>>=N,S>s&&(S-=b,f+=Kt);let k=T,$=T+Math.abs(S)-1,m=O%2!==0,D=S<0;S===0?c=c.add(n(m,i[k])):u=u.add(n(D,i[$]));}return {p:u,f:c}},wNAFCached(o,i,f,a){let s=o._WINDOW_SIZE||1,u=i.get(o);return u||(u=this.precomputeWindow(o,s),s!==1&&i.set(o,a(u))),this.wNAF(s,u,f)}}}function pe(t){return le(t.Fp),et(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Dt(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var P=BigInt(0),M=BigInt(1),Bt=BigInt(2),Bn=BigInt(8),_n={zip215:!0};function Sn(t){let e=pe(t);return et(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function _t(t){let e=Sn(t),{Fp:n,n:r,prehash:o,hash:i,randomBytes:f,nByteLength:a,h:s}=e,u=Bt<<BigInt(a*8)-M,c=n.create,p=e.uvRatio||((d,l)=>{try{return {isValid:!0,value:n.sqrt(d*n.inv(l))}}catch{return {isValid:!1,value:P}}}),b=e.adjustScalarBytes||(d=>d),N=e.domain||((d,l,h)=>{if(l.length||h)throw new Error("Contexts/pre-hash are not supported");return d}),O=d=>typeof d=="bigint"&&P<d,T=(d,l)=>O(d)&&O(l)&&d<l,S=d=>d===P||T(d,u);function k(d,l){if(T(d,l))return d;throw new Error(`Expected valid scalar < ${l}, got ${typeof d} ${d}`)}function $(d){return d===P?d:k(d,r)}let m=new Map;function D(d){if(!(d instanceof g))throw new Error("ExtendedPoint expected")}class g{constructor(l,h,y,w){if(this.ex=l,this.ey=h,this.ez=y,this.et=w,!S(l))throw new Error("x required");if(!S(h))throw new Error("y required");if(!S(y))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(l){if(l instanceof g)throw new Error("extended point not allowed");let{x:h,y}=l||{};if(!S(h)||!S(y))throw new Error("invalid affine point");return new g(h,y,M,c(h*y))}static normalizeZ(l){let h=n.invertBatch(l.map(y=>y.ez));return l.map((y,w)=>y.toAffine(h[w])).map(g.fromAffine)}_setWindowSize(l){this._WINDOW_SIZE=l,m.delete(this);}assertValidity(){let{a:l,d:h}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:y,ey:w,ez:E,et:_}=this,A=c(y*y),B=c(w*w),v=c(E*E),C=c(v*v),H=c(A*l),z=c(v*c(H+B)),R=c(C+c(h*c(A*B)));if(z!==R)throw new Error("bad point: equation left != right (1)");let X=c(y*w),F=c(E*_);if(X!==F)throw new Error("bad point: equation left != right (2)")}equals(l){D(l);let{ex:h,ey:y,ez:w}=this,{ex:E,ey:_,ez:A}=l,B=c(h*A),v=c(E*w),C=c(y*A),H=c(_*w);return B===v&&C===H}is0(){return this.equals(g.ZERO)}negate(){return new g(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:l}=e,{ex:h,ey:y,ez:w}=this,E=c(h*h),_=c(y*y),A=c(Bt*c(w*w)),B=c(l*E),v=h+y,C=c(c(v*v)-E-_),H=B+_,z=H-A,R=B-_,X=c(C*z),F=c(H*R),dt=c(C*R),ht=c(z*H);return new g(X,F,ht,dt)}add(l){D(l);let{a:h,d:y}=e,{ex:w,ey:E,ez:_,et:A}=this,{ex:B,ey:v,ez:C,et:H}=l;if(h===BigInt(-1)){let Pt=c((E-w)*(v+B)),$t=c((E+w)*(v-B)),vt=c($t-Pt);if(vt===P)return this.double();let zt=c(_*Bt*H),jt=c(A*Bt*C),Ft=jt+zt,Yt=$t+Pt,Wt=jt-zt,Ie=c(Ft*vt),Ae=c(Yt*Wt),Le=c(Ft*Wt),Oe=c(vt*Yt);return new g(Ie,Ae,Oe,Le)}let z=c(w*B),R=c(E*v),X=c(A*y*H),F=c(_*C),dt=c((w+E)*(B+v)-z-R),ht=F-X,Zt=F+X,Gt=c(R-h*z),Be=c(dt*ht),_e=c(Zt*Gt),Se=c(dt*Gt),ve=c(ht*Zt);return new g(Be,_e,ve,Se)}subtract(l){return this.add(l.negate())}wNAF(l){return K.wNAFCached(this,m,l,g.normalizeZ)}multiply(l){let{p:h,f:y}=this.wNAF(k(l,r));return g.normalizeZ([h,y])[0]}multiplyUnsafe(l){let h=$(l);return h===P?it:this.equals(it)||h===M?this:this.equals(j)?this.wNAF(h).p:K.unsafeLadder(this,h)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return K.unsafeLadder(this,r).is0()}toAffine(l){let{ex:h,ey:y,ez:w}=this,E=this.is0();l==null&&(l=E?Bn:n.inv(w));let _=c(h*l),A=c(y*l),B=c(w*l);if(E)return {x:P,y:M};if(B!==M)throw new Error("invZ was invalid");return {x:_,y:A}}clearCofactor(){let{h:l}=e;return l===M?this:this.multiplyUnsafe(l)}static fromHex(l,h=!1){let{d:y,a:w}=e,E=n.BYTES;l=Z("pointHex",l,E);let _=l.slice(),A=l[E-1];_[E-1]=A&-129;let B=tt(_);B===P||(h?k(B,u):k(B,n.ORDER));let v=c(B*B),C=c(v-M),H=c(y*v-w),{isValid:z,value:R}=p(C,H);if(!z)throw new Error("Point.fromHex: invalid y coordinate");let X=(R&M)===M,F=(A&128)!==0;if(!h&&R===P&&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(l){return W(l).point}toRawBytes(){let{x:l,y:h}=this.toAffine(),y=ot(h,n.BYTES);return y[y.length-1]|=l&M?128:0,y}toHex(){return lt(this.toRawBytes())}}g.BASE=new g(e.Gx,e.Gy,M,c(e.Gx*e.Gy)),g.ZERO=new g(P,M,M,P);let{BASE:j,ZERO:it}=g,K=he(g,a*8);function V(d){return I(d,r)}function nt(d){return V(tt(d))}function W(d){let l=a;d=Z("private key",d,l);let h=Z("hashed private key",i(d),2*l),y=b(h.slice(0,l)),w=h.slice(l,2*l),E=nt(y),_=j.multiply(E),A=_.toRawBytes();return {head:y,prefix:w,scalar:E,point:_,pointBytes:A}}function ct(d){return W(d).pointBytes}function rt(d=new Uint8Array,...l){let h=Et(...l);return nt(i(N(h,Z("context",d),!!o)))}function St(d,l,h={}){d=Z("message",d),o&&(d=o(d));let{prefix:y,scalar:w,pointBytes:E}=W(l),_=rt(h.context,y,d),A=j.multiply(_).toRawBytes(),B=rt(h.context,A,E,d),v=V(_+B*w);$(v);let C=Et(A,ot(v,n.BYTES));return Z("result",C,a*2)}let ut=_n;function Ee(d,l,h,y=ut){let{context:w,zip215:E}=y,_=n.BYTES;d=Z("signature",d,2*_),l=Z("message",l),o&&(l=o(l));let A=tt(d.slice(_,2*_)),B,v,C;try{B=g.fromHex(h,E),v=g.fromHex(d.slice(0,_),E),C=j.multiplyUnsafe(A);}catch{return !1}if(!E&&B.isSmallOrder())return !1;let H=rt(w,v.toRawBytes(),B.toRawBytes(),l);return v.add(B.multiplyUnsafe(H)).subtract(C).clearCofactor().equals(g.ZERO)}return j._setWindowSize(8),{CURVE:e,getPublicKey:ct,sign:St,verify:Ee,ExtendedPoint:g,utils:{getExtendedPublicKey:W,randomPrivateKey:()=>f(n.BYTES),precompute(d=8,l=g.BASE){return l._setWindowSize(d),l.multiply(BigInt(3)),l}}}}BigInt(0);BigInt(1);var kt=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),xe=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);var vn=BigInt(1),Mt=BigInt(2),In=BigInt(5),ye=BigInt(10),An=BigInt(20),Ln=BigInt(40),be=BigInt(80);function On(t){let e=kt,r=t*t%e*t%e,o=G(r,Mt,e)*r%e,i=G(o,vn,e)*t%e,f=G(i,In,e)*i%e,a=G(f,ye,e)*f%e,s=G(a,An,e)*a%e,u=G(s,Ln,e)*s%e,c=G(u,be,e)*u%e,p=G(c,be,e)*u%e,b=G(p,ye,e)*f%e;return {pow_p_5_8:G(b,Mt,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=kt,r=I(e*e*e,n),o=I(r*r*e,n),i=On(t*o).pow_p_5_8,f=I(t*r*i,n),a=I(e*f*f,n),s=f,u=I(f*xe,n),c=a===t,p=a===I(-t,n),b=a===I(-t*xe,n);return c&&(f=s),(p||b)&&(f=u),ae(f,n)&&(f=I(-f,n)),{isValid:c||p,value:f}}var Y=ue(kt,void 0,!0),Vt={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Y,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ct,randomBytes:te,adjustScalarBytes:Nn,uvRatio:Tn},ge=_t(Vt);function we(t,e,n){if(e.length>255)throw new Error("Context is too big");return Jt(At("SigEd25519 no Ed25519 collisions"),new Uint8Array([n?1:0,e.length]),e,t)}_t({...Vt,domain:we});_t({...Vt,domain:we,prehash:Ct});var Un=(Y.ORDER+BigInt(3))/BigInt(8);Y.pow(Mt,Un);Y.sqrt(Y.neg(Y.ONE));(Y.ORDER-BigInt(5))/BigInt(8);BigInt(486662);de(Y,Y.neg(BigInt(486664)));BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235");BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578");BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838");BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Cn=new Set(["decrypt","deriveBits","deriveKey","encrypt","unwrapKey","wrapKey"]),Hn;function Rn(t,e,n){let r=qn(e,n),o=Hn||(Hn=new WeakMap);return o.set(r.privateKey,t),o.set(r.publicKey,t),r}function qn(t,e){if(e.length===0)throw new DOMException("Usages cannot be empty when creating a key.","SyntaxError");if(e.some(i=>Cn.has(i)))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(i=>i==="sign"))},o={...n,extractable:!0,type:"public",usages:Object.freeze(e.filter(i=>i==="verify"))};return Object.freeze({privateKey:Object.freeze(r),publicKey:Object.freeze(o)})}function me(t,e){let n=ge.utils.randomPrivateKey();return Rn(n,t,e)}if(globalThis.isSecureContext){let t=globalThis.crypto||(globalThis.crypto={}),e=t.subtle||(t.subtle={}),n=e.generateKey,r;e.generateKey=async(...o)=>{let[i]=o;if(i!=="Ed25519"){if(n)return await n.apply(e,o);throw new TypeError("No native `generateKey` function exists to handle this call")}let f;if(r===void 0&&(r=new Promise(a=>{if(!n){a(r=!1);return}n.apply(e,o).then(s=>{e.generateKey!==n&&(e.generateKey=n),f=s,a(r=!0);}).catch(()=>{a(r=!1);});})),typeof r=="boolean"?r:await r){if(f)return f;if(n)return await n.apply(e,o);throw new TypeError("No native `generateKey` function exists to handle this call")}else {let[a,s,u]=o;return me(s,u)}};}
|
|
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")}};}
|
|
5
5
|
/*! Bundled license information:
|
|
6
6
|
|
|
7
7
|
@noble/hashes/esm/utils.js:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
|
package/dist/types/secrets.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare function exportKeyPolyfill(format: 'jwk', key: CryptoKey): JsonWebKey;
|
|
2
|
+
export declare function exportKeyPolyfill(format: KeyFormat, key: CryptoKey): ArrayBuffer;
|
|
1
3
|
/**
|
|
2
4
|
* This function generates a key pair and stores the secret bytes associated with it in a
|
|
3
5
|
* module-private cache. Instead of vending the actual secret bytes, it returns a `CryptoKeyPair`
|
|
@@ -5,4 +7,7 @@
|
|
|
5
7
|
* associated with the secret.
|
|
6
8
|
*/
|
|
7
9
|
export declare function generateKeyPolyfill(extractable: boolean, keyUsages: readonly KeyUsage[]): CryptoKeyPair;
|
|
10
|
+
export declare function isPolyfilledKey(key: CryptoKey): boolean;
|
|
11
|
+
export declare function signPolyfill(key: CryptoKey, data: BufferSource): ArrayBuffer;
|
|
12
|
+
export declare function verifyPolyfill(key: CryptoKey, signature: BufferSource, data: BufferSource): boolean;
|
|
8
13
|
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -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.
|
|
3
|
+
"version": "2.0.0-experimental.6ec1b2d",
|
|
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": {
|
|
@@ -53,23 +53,19 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@solana/eslint-config-solana": "^1.0.2",
|
|
56
|
-
"@swc/
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
56
|
+
"@swc/jest": "^0.2.27",
|
|
57
|
+
"@types/jest": "^29.5.3",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
60
59
|
"@typescript-eslint/parser": "^6.0.0",
|
|
61
60
|
"eslint": "^8.45.0",
|
|
62
61
|
"eslint-plugin-jest": "^27.2.3",
|
|
63
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
64
62
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
65
63
|
"jest": "^29.6.1",
|
|
66
|
-
"jest-environment-jsdom": "^29.6.
|
|
64
|
+
"jest-environment-jsdom": "^29.6.2",
|
|
67
65
|
"jest-runner-eslint": "^2.1.0",
|
|
68
66
|
"jest-runner-prettier": "^1.0.0",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"ts-node": "^10.9.1",
|
|
72
|
-
"tsup": "6.7.0",
|
|
67
|
+
"prettier": "^3.0.1",
|
|
68
|
+
"tsup": "7.2.0",
|
|
73
69
|
"typescript": "^5.1.6",
|
|
74
70
|
"version-from-git": "^1.1.1",
|
|
75
71
|
"build-scripts": "0.0.0",
|