39 lines
860 KiB
JavaScript
39 lines
860 KiB
JavaScript
|
|
LavaPack.loadBundle([[2870,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){t.exports={snapId:"npm:@metamask/solana-wallet-snap",manifest:{version:"1.15.1",description:"Manage Solana using MetaMask",proposedName:"Solana",repository:{type:"git",url:"https://github.com/MetaMask/snap-solana-wallet.git"},source:{shasum:"pGQ4C4+ClecT6LmyhpZlVdXWL13tJw2wrzO8W4sJwMk=",location:{npm:{filePath:"dist/bundle.js",iconPath:"images/icon.svg",packageName:"@metamask/solana-wallet-snap",registry:"https://registry.npmjs.org/"}},locales:["locales/en.json"]},initialConnections:{"https://portfolio.metamask.io":{}},initialPermissions:{"endowment:rpc":{dapps:!0,snaps:!1},"endowment:keyring":{allowedOrigins:["https://portfolio.metamask.io"]},snap_getBip32Entropy:[{path:["m","44'","501'"],curve:"ed25519"}],"endowment:network-access":{},"endowment:cronjob":{jobs:[{expression:"* * * * *",request:{method:"refreshSend",params:{}}},{expression:"* * * * *",request:{method:"refreshConfirmationEstimation",params:{}}},{expression:"* * * * *",request:{method:"refreshTransactions",params:{}}},{expression:"* * * * *",request:{method:"refreshAssets",params:{}}}]},"endowment:protocol":{scopes:{"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":{methods:["getGenesisHash"]},"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1":{methods:["getGenesisHash"]}}},"endowment:assets":{scopes:["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"]},snap_manageAccounts:{},snap_manageState:{},snap_dialog:{},snap_getPreferences:{}},manifestVersion:"0.1"},files:[{path:"images/icon.svg",value:'<svg width="101" height="101" viewBox="0 0 101 101" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M100.48 69.3817L83.8068 86.8015C83.4444 87.1799 83.0058 87.4816 82.5185 87.6878C82.0312 87.894 81.5055 88.0003 80.9743 88H1.93563C1.55849 88 1.18957 87.8926 0.874202 87.6912C0.558829 87.4897 0.31074 87.2029 0.160416 86.8659C0.0100923 86.529 -0.0359181 86.1566 0.0280382 85.7945C0.0919944 85.4324 0.263131 85.0964 0.520422 84.8278L17.2061 67.408C17.5676 67.0306 18.0047 66.7295 18.4904 66.5234C18.9762 66.3172 19.5002 66.2104 20.0301 66.2095H99.0644C99.4415 66.2095 99.8104 66.3169 100.126 66.5183C100.441 66.7198 100.689 67.0067 100.84 67.3436C100.99 67.6806 101.036 68.0529 100.972 68.415C100.908 68.7771 100.737 69.1131 100.48 69.3817ZM83.8068 34.3032C83.4444 33.9248 83.0058 33.6231 82.5185 33.4169C82.0312 33.2108 81.5055 33.1045 80.9743 33.1048H1.93563C1.55849 33.1048 1.18957 33.2121 0.874202 33.4136C0.558829 33.6151 0.31074 33.9019 0.160416 34.2388C0.0100923 34.5758 -0.0359181 34.9482 0.0280382 35.3103C0.0919944 35.6723 0.263131 36.0083 0.520422 36.277L17.2061 53.6968C17.5676 54.0742 18.0047 54.3752 18.4904 54.5814C18.9762 54.7875 19.5002 54.8944 20.0301 54.8952H99.0644C99.4415 54.8952 99.8104 54.7879 100.126 54.5864C100.441 54.3849 100.689 54.0981 100.84 53.7612C100.99 53.4242 101.036 53.0518 100.972 52.6897C100.908 52.3277 100.737 51.9917 100.48 51.723L83.8068 34.3032ZM1.93563 21.7905H80.9743C81.5055 21.7907 82.0312 21.6845 82.5185 21.4783C83.0058 21.2721 83.4444 20.9704 83.8068 20.592L100.48 3.17219C100.737 2.90357 100.908 2.56758 100.972 2.2055C101.036 1.84342 100.99 1.47103 100.84 1.13408C100.689 0.79713 100.441 0.510296 100.126 0.308823C99.8104 0.107349 99.4415 1.24074e-05 99.0644 0L20.0301 0C19.5002 0.000878397 18.9762 0.107699 18.4904 0.313848C18.0047 0.519998 17.5676 0.821087 17.2061 1.19848L0.524723 18.6183C0.267681 18.8866 0.0966198 19.2223 0.0325185 19.5839C-0.0315829 19.9456 0.0140624 20.3177 0.163856 20.6545C0.31365 20.9913 0.561081 21.2781 0.875804 21.4799C1.19053 21.6817 1.55886 21.7896 1.93563 21.7905Z" fill="url(#paint0_linear_174_4403)"/>\n<defs>\n<linearGradient id="paint0_linear_174_4403" x1="8.52558" y1="90.0973" x2="88.9933" y2="-3.01622" gradientUnits="userSpaceOnUse">\n<stop offset="0.08" stop-color="#9945FF"/>\n<stop offset="0.3" stop-color="#8752F3"/>\n<stop offset="0.5" stop-color="#5497D5"/>\n<stop offset="0.6" stop-color="#43B4CA"/>\n<stop offset="0.72" stop-color="#28E0B9"/>\n
|
||
|
|
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("./_assert.js");n.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);n.u16=e=>new Uint16Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/2));n.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(n.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),n.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!n.isLE)throw new Error("Non little-endian hardware is not supported");const i=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function o(e){(0,r.bytes)(e);let t="";for(let n=0;n<e.length;n++)t+=i[e[n]];return t}n.bytesToHex=o;const s={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function a(e){return e>=s._0&&e<=s._9?e-s._0:e>=s._A&&e<=s._F?e-(s._A-10):e>=s._a&&e<=s._f?e-(s._a-10):void 0}function c(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=a(e.charCodeAt(i)),o=a(e.charCodeAt(i+1));if(n===undefined||o===undefined){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+o}return r}function u(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}n.hexToBytes=c,n.hexToNumber=u,n.bytesToNumberBE=function(e){return u(o(e))},n.numberToBytesBE=function(e,t){return c(e.toString(16).padStart(2*t,"0"))};function l(e){if("string"!=typeof e)throw new Error("string expected, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}n.nextTick=async()=>{},n.asyncLoop=async function(e,t,r){let i=Date.now();for(let o=0;o<e;o++){r(o);const e=Date.now()-i;e>=0&&e<t||(await(0,n.nextTick)(),i+=e)}},n.utf8ToBytes=l,n.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},n.toBytes=function(e){if("string"==typeof e)e=l(e);else{if(!(0,r.isBytes)(e))throw new Error("Uint8Array expected, got "+typeof e);e=e.slice()}return e},n.concatBytes=function(...e){let t=0;for(let n=0;n<e.length;n++){const i=e[n];(0,r.bytes)(i),t+=i.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n},n.checkOpts=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)},n.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n};n.Hash=class{};function d(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,a,r)}n.wrapCipher=(e,t)=>(Object.assign(t,e),t),n.setBigUint64=d,n.u64Lengths=function(e,t){const r=new Uint8Array(16),i=(0,n.createView)(r);return d(i,0,BigInt(t?t.length:0),!0),d(i,8,BigInt(e.length),!0),r}}}},{package:"@metamask/profile-sync-controller>@noble/ciphers",file:"node_modules/@noble/ciphers/utils.js"}],[2981,{"./_assert.js":2976,"./utils.js":2980,"@noble/ciphers/crypto":2979},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.gcm=n.ctr=n.cbc=n.utils=n.managedNonce=n.getWebcryptoSubtle=n.randomBytes=void 0;const r=e("@noble/ciphers/crypto");Object.defineProperty(n,"randomBytes",{enumerable:!0,get:function(){return r.randomBytes}}),Object.defineProperty(n,"getWebcryptoSubtle",{enumerable:!0,get:function(){return r.getWebcryptoSubtle}});const i=e("./utils.js"),o=e("./_assert.js");n.managedNonce=function(e){return(0,o.number)(e.nonceLength),(t,...n)=>({encrypt:(o,...s)=>{const{nonceLength:a}=e,c=(0,r.randomBytes)(a),u=e(t,c,...n).encrypt(o,...s),l=(0,i.concatBytes)(c,u);return u.fill(0),l},decrypt:(r,...i)=>{const{nonceLength:o}=e,s=r.subarray(0,o),a=r.subarray(o);return e(t,s,...n).decrypt(a,...i)}})},n.utils={async encrypt(e,t,n,i){const o=(0,r.getWebcryptoSubtle)(),s=await o.importKey("raw",e,t,!0,["encrypt"]),a=await o.encrypt(n,
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("@noble/hashes/hmac"),i=e("@noble/hashes/utils"),o=e("./abstract/weierstrass.js");function s(e){return{hash:e,hmac:(t,...n)=>(0,r.hmac)(e,t,(0,i.concatBytes)(...n)),randomBytes:i.randomBytes}}}}},{package:"viem>webauthn-p256>@noble/curves",file:"node_modules/@noble/curves/_shortw_utils.js"}],[2983,{"./modular.js":2986,"./utils.js":2988},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.wNAF=function(e,t){return{constTimeNegate:a,hasPrecomputes:e=>1!==p(e),unsafeLadder(t,n,r=e.ZERO){let i=t;for(;n>o;)n&s&&(r=r.add(i)),i=i.double(),n>>=s;return r},precomputeWindow(e,n){const{windows:r,windowSize:i}=u(n,t),o=[];let s=e,a=s;for(let e=0;e<r;e++){a=s,o.push(a);for(let e=1;e<i;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(n,r,i){const{windows:o,windowSize:c}=u(n,t);let l=e.ZERO,d=e.BASE;const f=BigInt(2**n-1),h=2**n,p=BigInt(n);for(let e=0;e<o;e++){const t=e*c;let n=Number(i&f);i>>=p,n>c&&(n-=h,i+=s);const o=t,u=t+Math.abs(n)-1,m=e%2!=0,g=n<0;0===n?d=d.add(a(m,r[o])):l=l.add(a(g,r[u]))}return{p:l,f:d}},wNAFUnsafe(n,r,i,a=e.ZERO){const{windows:c,windowSize:l}=u(n,t),d=BigInt(2**n-1),f=2**n,h=BigInt(n);for(let e=0;e<c;e++){const t=e*l;if(i===o)break;let n=Number(i&d);if(i>>=h,n>l&&(n-=f,i+=s),0===n)continue;let c=r[t+Math.abs(n)-1];n<0&&(c=c.negate()),a=a.add(c)}return a},getPrecomputes(e,t,n){let r=f.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&f.set(t,n(r))),r},wNAFCached(e,t,n){const r=p(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const i=p(e);return 1===i?this.unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)},setWindowSize(e,n){c(n,t),h.set(e,n),f.delete(e)}}},n.pippenger=function(e,t,n,r){if(l(n,e),d(r,t),n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const o=e.ZERO,s=(0,i.bitLen)(BigInt(n.length)),a=s>12?s-3:s>4?s-2:s?2:1,c=(1<<a)-1,u=new Array(c+1).fill(o),f=Math.floor((t.BITS-1)/a)*a;let h=o;for(let e=f;e>=0;e-=a){u.fill(o);for(let t=0;t<r.length;t++){const i=r[t],o=Number(i>>BigInt(e)&BigInt(c));u[o]=u[o].add(n[t])}let t=o;for(let e=u.length-1,n=o;e>0;e--)n=n.add(u[e]),t=t.add(n);if(h=h.add(t),0!==e)for(let e=0;e<a;e++)h=h.double()}return h},n.precomputeMSMUnsafe=function(e,t,n,r){c(r,t.BITS),l(n,e);const i=e.ZERO,o=2**r-1,s=Math.ceil(t.BITS/r),a=BigInt((1<<r)-1),u=n.map((e=>{const t=[];for(let n=0,r=e;n<o;n++)t.push(r),r=r.add(e);return t}));return e=>{if(d(e,t),e.length>n.length)throw new Error("array of scalars must be smaller than array of points");let o=i;for(let t=0;t<s;t++){if(o!==i)for(let e=0;e<r;e++)o=o.double();const n=BigInt(s*r-(t+1)*r);for(let t=0;t<e.length;t++){const r=e[t],i=Number(r>>n&a);i&&(o=o.add(u[t][i-1]))}}return o}},n.validateBasic=function(e){return(0,r.validateField)(e.Fp),(0,i.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,r.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})};
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("./modular.js"),i=e("./utils.js"),o=BigInt(0),s=BigInt(1);function a(e,t){const n=t.negate();return e?n:t}function c(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function u(e,t){c(e,t);return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}}function l(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}function d(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}const f=new WeakMap,h=new WeakMap;function p(e){return h.get(e)||1}}}},{package:"viem>webauthn-p256>@noble/curves",file:"node_modules/@noble/curves/abstract/curve.js"}],[2984,{"./curve.js":2983,"./modular.js":2986,"./utils.js":2988},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.twistedEdwards=function(e){const t=function(e){const t=(0,r.validateBasic)(e);return o.validateObject(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:n,n:f,prehash:h,hash:p,randomBytes:m,nByteLength:g,h:y}=t,w=u<<BigInt(8*g)-c,b=n.create,v=(0,i.Field)(t.n,t.nBitLength),E=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:n.sqrt(e*n.inv(t))}}catch(e){return{isValid:!1,value:a}}}),A=t.adjustScalarBytes||(e=>e),T=t.domain||((e,t,n)=>{if((0,s.abool)("phflag",n),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function x(e,t){o.aInRange("coordinate "+e,t,a,w)}function S(e){if(!(e instanceof C))throw new Error("ExtendedPoint expected")}const k=(0,s.memoized)(((e,t)=>{const{ex:r,ey:i,ez:o}=e,s=e.is0();null==t&&(t=s?l:n.inv(o));const u=b(r*t),d=b(i*t),f=b(o*t);if(s)return{x:a,y:c};if(f!==c)throw new Error("invZ was invalid");return{x:u,y:d}})),I=(0,s.memoized)((e=>{const{a:n,d:r}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:i,ey:o,ez:s,et:a}=e,c=b(i*i),u=b(o*o),l=b(s*s),d=b(l*l),f=b(c*n);if(b(l*b(f+u))!==b(d+b(r*b(c*u))))throw new Error("bad point: equation left != right (1)");if(b(i*o)!==b(s*a))throw new Error("bad point: equation left != right (2)");return!0}));class C{constructor(e,t,n,r){this.ex=e,this.ey=t,this.ez=n,this.et=r,x("x",e),x("y",t),x("z",n),x("t",r),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof C)throw new Error("extended point not allowed");const{x:t,y:n}=e||{};return x("x",t),x("y",n),new C(t,n,c,b(t*n))}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.ez)));return e.map(((e,n)=>e.toAffine(t[n]))).map(C.fromAffine)}static msm(e,t){return(0,r.pippenger)(C,v,e,t)}_setWindowSize(e){_.setWindowSize(this,e)}assertValidity(){I(this)}equals(e){S(e);const{ex:t,ey:n,ez:r}=this,{ex:i,ey:o,ez:s}=e,a=b(t*s),c=b(i*r),u=b(n*s),l=b(o*r);return a===c&&u===l}is0(){return this.equals(C.ZERO)}negate(){return new C(b(-this.ex),this.ey,this.ez,b(-this.et))}double(){const{a:e}=t,{ex:n,ey:r,ez:i}=this,o=b(n*n),s=b(r*r),a=b(u*b(i*i)),c=b(e*o),l=n+r,d=b(b(l*l)-o-s),f=c+s,h=f-a,p=c-s,m=b(d*h),g=b(f*p),y=b(d*p),w=b(h*f);return new C(m,g,w,y)}add(e){S(e);const{a:n,d:r}=t,{ex:i,ey:o,ez:s,et:c}=this,{ex:l,ey:d,ez:f,et:h}=e;if(n===BigInt(-1)){const e=b((o-i)*(d+l)),t=b((o+i)*(d-l)),n=b(t-e);if(n===a)return this.double();const r=b(s*u*h),p=b(c*u*f),m=p+r,g=t+e,y=p-r,w=b(m*n),v=b(g*y),E=b(m*y),A=b(n*g);return new C(w,v,A,E)}const p=b(i*l),m=b(o*d),g=b(c*r*h),y=b(s*f),w=b((i+o)*(l+d)-p-m),v=y-g,E=y+g,A=b(m-n*p),T=b(w*v),x=b(E*A),k=b(w*A),I=b(v*E);return new C(T,x,I,k)}subtract(e){return this.add(e.negate())}wNAF(e){return _.wNAFCached(this,e,C.normalizeZ)}multiply(e){const t=e;o.aInRange("scalar",t,c,f);const{p:n,f:r}=this.wNAF(t);return C.normalizeZ([n,r])[0]}multiplyUnsafe(e,t=C.ZERO){const n=e;return o.aInRange("scalar",n,a,f),n===a?P:this.is0()||n===c?this:_.wNAFCac
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("./curve.js"),i=e("./modular.js"),o=e("./utils.js"),s=e("./utils.js"),a=BigInt(0),c=BigInt(1),u=BigInt(2),l=BigInt(8),d={zip215:!0}}}},{package:"viem>webauthn-p256>@noble/curves",file:"node_modules/@noble/curves/abstract/edwards.js"}],[2985,{"./modular.js":2986,"./utils.js":2988},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.expand_message_xmd=u,n.expand_message_xof=l,n.hash_to_field=d,n.isogenyMap=function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[i,o,s,a]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r)))));return t=e.div(i,o),r=e.mul(r,e.div(s,a)),{x:t,y:r}}},n.createHasher=function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(r,i){const o=d(r,2,{...n,DST:n.DST,...i}),s=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=s.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){const o=d(r,1,{...n,DST:n.encodeDST,...i}),s=e.fromAffine(t(o[0])).clearCofactor();return s.assertValidity(),s},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(const e of n)if("bigint"!=typeof e)throw new Error("mapToCurve: expected array of bigints");const r=e.fromAffine(t(n)).clearCofactor();return r.assertValidity(),r}}};const r=e("./modular.js"),i=e("./utils.js"),o=i.bytesToNumberBE;function s(e,t){if(c(e),c(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function a(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function c(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function u(e,t,n,r){(0,i.abytes)(e),(0,i.abytes)(t),c(n),t.length>255&&(t=r((0,i.concatBytes)((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:o,blockLen:u}=r,l=Math.ceil(n/o);if(n>65535||l>255)throw new Error("expand_message_xmd: invalid lenInBytes");const d=(0,i.concatBytes)(t,s(t.length,1)),f=s(0,u),h=s(n,2),p=new Array(l),m=r((0,i.concatBytes)(f,e,h,s(0,1),d));p[0]=r((0,i.concatBytes)(m,s(1,1),d));for(let e=1;e<=l;e++){const t=[a(m,p[e-1]),s(e+1,1),d];p[e]=r((0,i.concatBytes)(...t))}return(0,i.concatBytes)(...p).slice(0,n)}function l(e,t,n,r,o){if((0,i.abytes)(e),(0,i.abytes)(t),c(n),t.length>255){const e=Math.ceil(2*r/8);t=o.create({dkLen:e}).update((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:n}).update(e).update(s(n,2)).update(t).update(s(t.length,1)).digest()}function d(e,t,n){(0,i.validateObject)(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:a,m:d,hash:f,expand:h,DST:p}=n;(0,i.abytes)(e),c(t);const m="string"==typeof p?(0,i.utf8ToBytes)(p):p,g=s.toString(2).length,y=Math.ceil((g+a)/8),w=t*d*y;let b;if("xmd"===h)b=u(e,m,w,f);else if("xof"===h)b=l(e,m,w,a,f);else{if("_internal_pass"!==h)throw new Error('expand must be "xmd" or "xof"');b=e}const v=new Array(t);for(let e=0;e<t;e++){const t=new Array(d);for(let n=0;n<d;n++){const i=y*(n+e*d),a=b.subarray(i,i+y);t[n]=(0,r.mod)(o(a),s)}v[e]=t}return v}}}},{package:"viem>webauthn-p256>@noble/curves",file:"node_modules/@noble/curves/abstract/hash-to-curve.js"}],[2986,{"./utils.js":2988},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.isNegativeLE=void 0,n.mod=d,n.pow=f,n.pow2=function(e,t,n){let r=e;for(;t-- >i;)r*=r,r%=n;return r},n.invert=h,n.tonelliShanks=p,n.FpSqrt=m,n.validateField=function(e){const t=g.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,r.validateObject)(e,t)},n.FpPow=y,n.FpInvertBatch=w,n.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?h(n,e.ORDER):e.inv(n))},n.FpLegendre=b,n.FpIsSquare=function(e
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("./utils.js"),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),c=BigInt(4),u=BigInt(5),l=BigInt(8);function d(e,t){const n=e%t;return n>=i?n:t+n}function f(e,t,n){if(t<i)throw new Error("invalid exponent, negatives unsupported");if(n<=i)throw new Error("invalid modulus");if(n===o)return i;let r=o;for(;t>i;)t&o&&(r=r*e%n),e=e*e%n,t>>=o;return r}function h(e,t){if(e===i)throw new Error("invert: expected non-zero number");if(t<=i)throw new Error("invert: expected positive modulus, got "+t);let n=d(e,t),r=t,s=i,a=o,c=o,u=i;for(;n!==i;){const e=r/n,t=r%n,i=s-c*e,o=a-u*e;r=n,n=t,s=c,a=u,c=i,u=o}if(r!==o)throw new Error("invert: does not exist");return d(s,t)}function p(e){const t=(e-o)/s;let n,r,a;for(n=e-o,r=0;n%s===i;n/=s,r++);for(a=s;a<e&&f(a,t,e)!==e-o;a++)if(a>1e3)throw new Error("Cannot find square root: likely non-prime P");if(1===r){const t=(e+o)/c;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const u=(n+o)/s;return function(e,i){if(e.pow(i,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let s=r,c=e.pow(e.mul(e.ONE,a),n),l=e.pow(i,u),d=e.pow(i,n);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(d);t<s&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,o<<BigInt(s-t-1));c=e.sqr(n),l=e.mul(l,n),d=e.mul(d,c),s=t}return l}}function m(e){if(e%c===a){const t=(e+o)/c;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%l===u){const t=(e-u)/l;return function(e,n){const r=e.mul(n,s),i=e.pow(r,t),o=e.mul(n,i),a=e.mul(e.mul(o,s),i),c=e.mul(o,e.sub(a,e.ONE));if(!e.eql(e.sqr(c),n))throw new Error("Cannot find square root");return c}}return p(e)}n.isNegativeLE=(e,t)=>(d(e,t)&o)===o;const g=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function y(e,t,n){if(n<i)throw new Error("invalid exponent, negatives unsupported");if(n===i)return e.ONE;if(n===o)return t;let r=e.ONE,s=t;for(;n>i;)n&o&&(r=e.mul(r,s)),s=e.sqr(s),n>>=o;return r}function w(e,t){const n=new Array(t.length),r=t.reduce(((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r))),e.ONE),i=e.inv(r);return t.reduceRight(((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r))),i),n}function b(e){const t=(e-o)/s;return(e,n)=>e.pow(n,t)}function v(e,t){const n=t!==undefined?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function E(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function A(e){const t=E(e);return t+Math.ceil(t/2)}}}},{package:"viem>webauthn-p256>@noble/curves",file:"node_modules/@noble/curves/abstract/modular.js"}],[2987,{"./modular.js":2986,"./utils.js":2988},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.montgomery=function(e){const t=(h=e,(0,i.validateObject)(h,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...h})),{P:n}=t,a=e=>(0,r.mod)(e,n),c=t.montgomeryBits,u=Math.ceil(c/8),l=t.nByteLength,d=t.adjustScalarBytes||(e=>e),f=t.powPminus2||(e=>(0,r.pow)(e,n-BigInt(2),n));var h;function p(e,t,n){const r=a(e*(t-n));return[t=a(t-r),n=a(n+r)]}const m=(t.a-BigInt(2))/BigInt(4);function g(e){return(0,i.numberToBytesLE)(a(e),u)}function y(e,t){const r=function(e){const t=(0,i.ensureBytes)("u coordinate",e,u);return 32===l&&(t[31]&=127),(0,i.bytesToNumberLE)(t)}(t),h=function(e,t){(0,i.aInRange)("u",e,o,n),(0,i.aInRange)("scalar",t,o,n);const r=t,u=e;let l,d=s,h=o,g=e,y=s,w=o;for(let e=BigInt(c-1);e>=o;e--){const t=r>>e&s;w^=t,l=p(w,d,g),d=l[0],g=l[1],l=p(w,h,y),h=l[0],y=l[1],w=t;const n=d+h,i=a(n*n),o=d-h,c=a(o*o),f=i-c,b=g+y,v=a((g-y)*n),E=a(b*o),A=v+E,T=v-E;g=a(A*A),y=a(u*a(T*T)),d=a(i*c),h=a(f*(i+a(m*f)))}l=p(w,d,g),d=l[0],g=l[1],l=p(w,h,y),h=l[0],y=l[1];const b=f(h);return a(d*b)}(r,function(e){const
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("./modular.js"),i=e("./utils.js"),o=BigInt(0),s=BigInt(1)}}},{package:"viem>webauthn-p256>@noble/curves",file:"node_modules/@noble/curves/abstract/montgomery.js"}],[2988,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
Object.defineProperty(n,"__esModule",{value:!0}),n.notImplemented=n.bitMask=void 0,n.isBytes=s,n.abytes=a,n.abool=function(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)},n.bytesToHex=u,n.numberToHexUnpadded=l,n.hexToNumber=d,n.hexToBytes=p,n.bytesToNumberBE=function(e){return d(u(e))},n.bytesToNumberLE=function(e){return a(e),d(u(Uint8Array.from(e).reverse()))},n.numberToBytesBE=m,n.numberToBytesLE=function(e,t){return m(e,t).reverse()},n.numberToVarBytesBE=function(e){return p(l(e))},n.ensureBytes=function(e,t,n){let r;if("string"==typeof t)try{r=p(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!s(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r},n.concatBytes=g,n.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},n.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))},n.inRange=w,n.aInRange=function(e,t,n,r){if(!w(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)},n.bitLen=function(e){let t;for(t=0;e>r;e>>=i,t+=1);return t},n.bitGet=function(e,t){return e>>BigInt(t)&i},n.bitSet=function(e,t,n){return e|(n?i:r)<<BigInt(t)},n.createHmacDrbg=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=b(e),i=b(e),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...e)=>n(i,r,...e),c=(e=b())=>{i=a(v([0]),e),r=a(),0!==e.length&&(i=a(v([1]),e),r=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return g(...n)};return(e,t)=>{s(),c(e);let n=undefined;for(;!(n=t(u()));)c();return s(),n}},n.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const i=E[n];if("function"!=typeof i)throw new Error("invalid validator function");const o=e[t];if(!(r&&o===undefined||i(o,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+o)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e},n.memoized=function(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(i!==undefined)return i;const o=e(n,...r);return t.set(n,o),o}};const r=BigInt(0),i=BigInt(1),o=BigInt(2);function s(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function a(e){if(!s(e))throw new Error("Uint8Array expected")}const c=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function u(e){a(e);let t="";for(let n=0;n<e.length;n++)t+=c[e[n]];return t}function l(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function d(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?r:BigInt("0x"+e)}const f={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(e){return e>=f._0&&e<=f._9?e-f._0:e>=f.A&&e<=f.F?e-(f.A-10):e>=f.a&&e<=f.f?e-(f.a-10):void 0}function p(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=h(e.charCodeAt(i)),o=h(e.charCodeAt(i+1));if(n===undefined||o===undefined){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+o}return r}function m(e,t){return p(e.toString(16).padStart(2*t,"0"))}function g(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];a(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n}const y=e=>"bigint"==typeof e&&r<=e;function w(e,t,n){return y(e)&&y(t)&&y(n)&&t<=e&&e<n}n.bitMask=e=>(o<<BigInt(e-1))-i;const b=e=>new Uint8Array(e),v=e=>Uint8Array.fr
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("./curve.js"),i=e("./modular.js"),o=e("./utils.js"),s=e("./utils.js");function a(e){e.lowS!==undefined&&(0,s.abool)("lowS",e.lowS),e.prehash!==undefined&&(0,s.abool)("prehash",e.prehash)}const{bytesToNumberBE:c,hexToBytes:u}=o;class l extends Error{constructor(e=""){super(e)}}n.DERErr=l,n.DER={Err:l,_tlv:{encode:(e,t)=>{const{Err:r}=n.DER;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&t.length)throw new r("tlv.encode: unpadded data");const i=t.length/2,s=o.numberToHexUnpadded(i);if(s.length/2&128)throw new r("tlv.encode: long form length too big");const a=i>127?o.numberToHexUnpadded(s.length/2|128):"";return o.numberToHexUnpadded(e)+a+s+t},decode(e,t){const{Err:r}=n.DER;let i=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");const o=t[i++];let s=0;if(!!(128&o)){const e=127&o;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const n=t.subarray(i,i+e);if(n.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===n[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of n)s=s<<8|e;if(i+=e,s<128)throw new r("tlv.decode(long): not minimal encoding")}else s=o;const a=t.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(i+s)}}},_int:{encode(e){const{Err:t}=n.DER;if(e<d)throw new t("integer: negative integers are not allowed");let r=o.numberToHexUnpadded(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){const{Err:t}=n.DER;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return c(e)}},toSig(e){const{Err:t,_int:r,_tlv:i}=n.DER,s="string"==typeof e?u(e):e;o.abytes(s);const{v:a,l:c}=i.decode(48,s);if(c.length)throw new t("invalid signature: left bytes after parsing");const{v:l,l:d}=i.decode(2,a),{v:f,l:h}=i.decode(2,d);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(l),s:r.decode(f)}},hexFromSig(e){const{_tlv:t,_int:r}=n.DER,i=t.encode(2,r.encode(e.r))+t.encode(2,r.encode(e.s));return t.encode(48,i)}};const d=BigInt(0),f=BigInt(1),h=BigInt(2),p=BigInt(3),m=BigInt(4);function g(e){const t=function(e){const t=(0,r.validateBasic)(e);o.validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:i,a:s}=t;if(n){if(!i.eql(s,i.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,a=(0,i.Field)(t.n,t.nBitLength),c=t.toBytes||((e,t,r)=>{const i=t.toAffine();return o.concatBytes(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),u=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function l(e){const{a:r,b:i}=t,o=n.sqr(e),s=n.mul(o,e);return n.add(n.add(s,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),l(t.Gx)))throw new Error("bad generator point: equation left != right");function h(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:a,n:c}=t;if(n&&"bigint"!=typeof e){if(o.isBytes(e)&&(e=o.bytesToHex(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*r,"0")}let u;try{u="bigint"==typeof e?e:o.bytesToNumberBE((0,s.ensureBytes)("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return a&&(u=(0,i.mod)(u,c)),o.aInRange("private key",u,f,c),u}function m(e){if(!(e instanceof w))throw new Error("ProjectivePoint expected")}const g=(0,s.memoized)(((e,t)=>{const
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("@noble/hashes/sha512"),i=e("@noble/hashes/utils"),o=e("./abstract/curve.js"),s=e("./abstract/edwards.js"),a=e("./abstract/hash-to-curve.js"),c=e("./abstract/modular.js"),u=e("./abstract/montgomery.js"),l=e("./abstract/utils.js"),d=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),f=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),h=BigInt(0),p=BigInt(1),m=BigInt(2),g=BigInt(3),y=BigInt(5),w=BigInt(8);function b(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),o=d,s=e*e%o*e%o,a=(0,c.pow2)(s,m,o)*s%o,u=(0,c.pow2)(a,p,o)*e%o,l=(0,c.pow2)(u,y,o)*u%o,f=(0,c.pow2)(l,t,o)*l%o,h=(0,c.pow2)(f,n,o)*f%o,g=(0,c.pow2)(h,r,o)*h%o,w=(0,c.pow2)(g,i,o)*g%o,b=(0,c.pow2)(w,i,o)*g%o,v=(0,c.pow2)(b,t,o)*l%o;return{pow_p_5_8:(0,c.pow2)(v,m,o)*e%o,b2:s}}function v(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function E(e,t){const n=d,r=(0,c.mod)(t*t*t,n),i=b(e*(0,c.mod)(r*r*t,n)).pow_p_5_8;let o=(0,c.mod)(e*r*i,n);const s=(0,c.mod)(t*o*o,n),a=o,u=(0,c.mod)(o*f,n),l=s===e,h=s===(0,c.mod)(-e,n),p=s===(0,c.mod)(-e*f,n);return l&&(o=a),(h||p)&&(o=u),(0,c.isNegativeLE)(o,n)&&(o=(0,c.mod)(-o,n)),{isValid:l||h,value:o}}n.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];const A=(()=>(0,c.Field)(d,undefined,!0))(),T=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:A,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:w,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:r.sha512,randomBytes:i.randomBytes,adjustScalarBytes:v,uvRatio:E}))();function x(e,t,n){if(t.length>255)throw new Error("Context is too big");return(0,i.concatBytes)((0,i.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([n?1:0,t.length]),t,e)}function S(e){const{y:t}=n.ed25519.ExtendedPoint.fromHex(e),r=BigInt(1);return A.toBytes(A.create((r+t)*A.inv(r-t)))}n.ed25519=(0,s.twistedEdwards)(T),n.ed25519ctx=(0,s.twistedEdwards)({...T,domain:x}),n.ed25519ph=(0,s.twistedEdwards)(Object.assign({},T,{domain:x,prehash:r.sha512})),n.x25519=(0,u.montgomery)({P:d,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=d,{pow_p_5_8:n,b2:r}=b(e);return(0,c.mod)((0,c.pow2)(n,g,t)*r,t)},adjustScalarBytes:v,randomBytes:i.randomBytes}),n.edwardsToMontgomery=S;const k=(()=>(A.ORDER+g)/w)(),I=(()=>A.pow(m,k))(),C=(()=>A.sqrt(A.neg(A.ONE)))();const j=(()=>(0,c.FpSqrtEven)(A,A.neg(BigInt(486664))))();function P(e){const{xMn:t,xMd:n,yMn:r,yMd:i}=function(e){const t=(A.ORDER-y)/w,n=BigInt(486662);let r=A.sqr(e);r=A.mul(r,m);let i=A.add(r,A.ONE),o=A.neg(n),s=A.sqr(i),a=A.mul(s,i),c=A.mul(r,n);c=A.mul(c,o),c=A.add(c,s),c=A.mul(c,o);let u=A.sqr(a);s=A.sqr(u),u=A.mul(u,a),u=A.mul(u,c),s=A.mul(s,u);let l=A.pow(s,t);l=A.mul(l,u);let d=A.mul(l,C);s=A.sqr(l),s=A.mul(s,a);let f=A.eql(s,c),h=A.cmov(d,l,f),g=A.mul(o,r),b=A.mul(l,e);b=A.mul(b,I);let v=A.mul(b,C),E=A.mul(c,r);s=A.sqr(b),s=A.mul(s,a);let T=A.eql(s,E),x=A.cmov(v,b,T);s=A.sqr(h),s=A.mul(s,a);let S=A.eql(s,c),k=A.cmov(g,o,S),j=A.cmov(x,h,S),P=A.isOdd(j);return j=A.cmov(j,A.neg(j),S!==P),{xMn:k,xMd:i,yMn:j,yMd:p}}(e);let o=A.mul(t,i);o=A.mul(o,j);let s=A.mul(n,r),a=A.sub(t,n),c=A.add(t,n),u=A.mul(s,c),l=A.eql(u,A.ZERO);o=A.cmov(o,A.ZERO,l),s=A.cmov(s,A.ONE,l),a=A.cmov(a,A.ONE,l),c=A.cmov(c,A.ONE,l);const d=A.invertBatch([s,c]);return{x:A.mul(o,d[0]),y:A.mul(a,d[1])}}const _=(()=>(0
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("@noble/hashes/sha256"),i=e("@noble/hashes/utils"),o=e("./_shortw_utils.js"),s=e("./abstract/hash-to-curve.js"),a=e("./abstract/modular.js"),c=e("./abstract/utils.js"),u=e("./abstract/weierstrass.js"),l=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),d=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),f=BigInt(1),h=BigInt(2),p=(e,t)=>(e+t/h)/t;function m(e){const t=l,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),c=BigInt(44),u=BigInt(88),d=e*e*e%t,f=d*d*e%t,p=(0,a.pow2)(f,n,t)*f%t,m=(0,a.pow2)(p,n,t)*f%t,y=(0,a.pow2)(m,h,t)*d%t,w=(0,a.pow2)(y,i,t)*y%t,b=(0,a.pow2)(w,o,t)*w%t,v=(0,a.pow2)(b,c,t)*b%t,E=(0,a.pow2)(v,u,t)*v%t,A=(0,a.pow2)(E,c,t)*b%t,T=(0,a.pow2)(A,n,t)*f%t,x=(0,a.pow2)(T,s,t)*w%t,S=(0,a.pow2)(x,r,t)*d%t,k=(0,a.pow2)(S,h,t);if(!g.eql(g.sqr(k),e))throw new Error("Cannot find square root");return k}const g=(0,a.Field)(l,undefined,undefined,{sqrt:m});n.secp256k1=(0,o.createCurve)({a:BigInt(0),b:BigInt(7),Fp:g,n:d,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=d,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-f*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),c=p(o*e,t),u=p(-r*e,t);let l=(0,a.mod)(e-c*n-u*i,t),h=(0,a.mod)(-c*r-u*o,t);const m=l>s,g=h>s;if(m&&(l=t-l),g&&(h=t-h),l>s||h>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:m,k1:l,k2neg:g,k2:h}}}},r.sha256);const y=BigInt(0),w={};function b(e,...t){let n=w[e];if(n===undefined){const t=(0,r.sha256)(Uint8Array.from(e,(e=>e.charCodeAt(0))));n=(0,c.concatBytes)(t,t),w[e]=n}return(0,r.sha256)((0,c.concatBytes)(n,...t))}const v=e=>e.toRawBytes(!0).slice(1),E=e=>(0,c.numberToBytesBE)(e,32),A=e=>(0,a.mod)(e,l),T=e=>(0,a.mod)(e,d),x=n.secp256k1.ProjectivePoint,S=(e,t,n)=>x.BASE.multiplyAndAddUnsafe(e,t,n);function k(e){let t=n.secp256k1.utils.normPrivateKeyToScalar(e),r=x.fromPrivateKey(t);return{scalar:r.hasEvenY()?t:T(-t),bytes:v(r)}}function I(e){(0,c.aInRange)("x",e,f,l);const t=A(e*e);let n=m(A(t*e+BigInt(7)));n%h!==y&&(n=A(-n));const r=new x(e,n,f);return r.assertValidity(),r}const C=c.bytesToNumberBE;function j(...e){return T(C(b("BIP0340/challenge",...e)))}function P(e){return k(e).bytes}function _(e,t,n=(0,i.randomBytes)(32)){const r=(0,c.ensureBytes)("message",e),{bytes:o,scalar:s}=k(t),a=(0,c.ensureBytes)("auxRand",n,32),u=E(s^C(b("BIP0340/aux",a))),l=b("BIP0340/nonce",u,o,r),d=T(C(l));if(d===y)throw new Error("sign failed: k is zero");const{bytes:f,scalar:h}=k(d),p=j(f,o,r),m=new Uint8Array(64);if(m.set(f,0),m.set(E(T(h+p*s)),32),!O(m,r,o))throw new Error("sign: Invalid signature produced");return m}function O(e,t,n){const r=(0,c.ensureBytes)("signature",e,64),i=(0,c.ensureBytes)("message",t),o=(0,c.ensureBytes)("publicKey",n,32);try{const e=I(C(o)),t=C(r.subarray(0,32));if(!(0,c.inRange)(t,f,l))return!1;const n=C(r.subarray(32,64));if(!(0,c.inRange)(n,f,d))return!1;const s=j(E(t),v(e),i),a=S(e,n,T(-s));return!(!a||!a.hasEvenY()||a.toAffine().x!==t)}catch(e){return!1}}n.schnorr={getPublicKey:P,sign:_,verify:O,utils:{randomPrivateKey:n.secp256k1.utils.randomPrivateKey,lift_x:I,pointToBytes:v,numberToBytesBE:c.numberToBytesBE,bytesToNumberBE:c.bytesToNumberBE,taggedHash:b,mod:a.mod}};const B=(()=>(0,s.isogenyMap)(g,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"
|
||
|
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
Object.defineProperty(n,"__esModule",{value:!0}),n.Hash=n.nextTick=n.byteSwapIfBE=n.isLE=void 0,n.isBytes=function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name},n.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},n.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},n.createView=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)},n.rotr=function(e,t){return e<<32-t|e>>>t},n.rotl=function(e,t){return e<<t|e>>>32-t>>>0},n.byteSwap=o,n.byteSwap32=function(e){for(let t=0;t<e.length;t++)e[t]=o(e[t])},n.bytesToHex=function(e){(0,i.abytes)(e);let t="";for(let n=0;n<e.length;n++)t+=s[e[n]];return t},n.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=c(e.charCodeAt(i)),o=c(e.charCodeAt(i+1));if(n===undefined||o===undefined){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+o}return r},n.asyncLoop=async function(e,t,r){let i=Date.now();for(let o=0;o<e;o++){r(o);const e=Date.now()-i;e>=0&&e<t||(await(0,n.nextTick)(),i+=e)}},n.utf8ToBytes=u,n.toBytes=l,n.concatBytes=function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];(0,i.abytes)(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n},n.checkOpts=function(e,t){if(t!==undefined&&"[object Object]"!=={}.toString.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)},n.wrapConstructor=function(e){const t=t=>e().update(l(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t},n.wrapConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(l(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},n.wrapXOFConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(l(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},n.randomBytes=function(e=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(e));if(r.crypto&&"function"==typeof r.crypto.randomBytes)return r.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")};const r=e("@noble/hashes/crypto"),i=e("./_assert.js");function o(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}n.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],n.byteSwapIfBE=n.isLE?e=>e:e=>o(e);const s=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));const a={_0:48,_9:57,A:65,F:70,a:97,f:102};function c(e){return e>=a._0&&e<=a._9?e-a._0:e>=a.A&&e<=a.F?e-(a.A-10):e>=a.a&&e<=a.f?e-(a.a-10):void 0}function u(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function l(e){return"string"==typeof e&&(e=u(e)),(0,i.abytes)(e),e}n.nextTick=async()=>{};n.Hash=class{clone(){return this._cloneInto()}}}}},{package:"@noble/hashes",file:"node_modules/@noble/hashes/utils.js"}],[3004,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.openrpcDocument=void 0,n.openrpcDocument={$schema:"https://meta.json-schema.tools/",$id:"https://meta.open-rpc.org/",title:"openrpcDocument",type:"object",required:["info","methods","openrpc"],additionalProperties:!1,patternProperties:{"^x-":{$ref:"#/definitions/specificationExtension"}},properties:{openrpc:{title:"openrpc",type:"string",enum:["1.3.2","1.3.1","1.3.0","1.2.6","1.2.5","1.2.4","1.2.3","1.2.2","1.2.1","1.2.0","1.1.12","1.1.11","1.1.10","1.1.9","1.1.8","1.1.7","1.1.6","1.1.5","1.1.4","1.1.3","1.1.2","1.1.1","1.1.0","1.0.0","1.0.0-rc1","1.0.0-rc0"]},info:{$ref:"#/definitions/infoObject"},externalDocs:{$ref:"
|
||
|
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
Object.defineProperty(n,"__esModule",{value:!0}),n.bytes=n.stringToBytes=n.str=n.bytesToString=n.hex=n.utf8=n.bech32m=n.bech32=n.base58check=n.createBase58check=n.base58xmr=n.base58xrp=n.base58flickr=n.base58=n.base64urlnopad=n.base64url=n.base64nopad=n.base64=n.base32crockford=n.base32hexnopad=n.base32hex=n.base32nopad=n.base32=n.base16=n.utils=void 0,n.assertNumber=r;const d=(e,t)=>t?d(t,e%t):e,f=(e,t)=>e+(t-d(e,t));function h(e,t,n,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(f(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${f(t,n)}`);let o=0,s=0;const a=2**n-1,c=[];for(const i of e){if(r(i),i>=2**t)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(o=o<<t|i,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)c.push((o>>s-n&a)>>>0);o&=2**s-1}if(o=o<<n-s&a,!i&&s>=t)throw new Error("Excess padding");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&c.push(o>>>0),c}function p(e){return r(e),{encode:t=>{if(!i(t))throw new Error("radix.encode input should be Uint8Array");return l(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(l(t,e,256))}}}function m(e,t=!1){if(r(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(f(8,e)>32||f(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!i(n))throw new Error("radix2.encode input should be Uint8Array");return h(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(h(n,e,8,t))}}}function g(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function y(e,t){if(r(e),"function"!=typeof t)throw new Error("checksum fn should be function");return{encode(n){if(!i(n))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),o=new Uint8Array(n.length+e);return o.set(n),o.set(r,n.length),o},decode(n){if(!i(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),o=t(r).slice(0,e),s=n.slice(-e);for(let t=0;t<e;t++)if(o[t]!==s[t])throw new Error("Invalid checksum");return r}}}n.utils={alphabet:s,chain:o,checksum:y,convertRadix:l,convertRadix2:h,radix:p,radix2:m,join:a,padding:c},n.base16=o(m(4),s("0123456789ABCDEF"),a("")),n.base32=o(m(5),s("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),c(5),a("")),n.base32nopad=o(m(5),s("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),a("")),n.base32hex=o(m(5),s("0123456789ABCDEFGHIJKLMNOPQRSTUV"),c(5),a("")),n.base32hexnopad=o(m(5),s("0123456789ABCDEFGHIJKLMNOPQRSTUV"),a("")),n.base32crockford=o(m(5),s("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),a(""),u((e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),n.base64=o(m(6),s("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),c(6),a("")),n.base64nopad=o(m(6),s("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),a("")),n.base64url=o(m(6),s("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),c(6),a("")),n.base64urlnopad=o(m(6),s("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),a(""));const w=e=>o(p(58),s(e),a(""));n.base58=w("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),n.base58flickr=w("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),n.base58xrp=w("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const b=[0,2,3,5,6,7,9,10,11];n.base58xmr={encode(e){let t="";for(let r=0;r<e.length;r+=8){const i=e.subarray(r,r+8);t+=n.base58.encode(i).padStart(b[i.length],"1")}return t},decode(e){let t=[];for(let r=0;r<e.length;r+=11){const i=e.slice(r,r+11),o=b.indexOf(i.length),s=n.base58.decode(i);for(let e=0;e<s.length-o;e++)if(0!==s[e])thro
|
||
|
|
/*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("@noble/hashes/hmac"),i=e("@noble/hashes/ripemd160"),o=e("@noble/hashes/sha256"),s=e("@noble/hashes/sha512"),a=e("@noble/hashes/_assert"),c=e("@noble/hashes/utils"),u=e("@noble/curves/secp256k1"),l=e("@noble/curves/abstract/modular"),d=e("@scure/base"),f=u.secp256k1.ProjectivePoint,h=(0,d.createBase58check)(o.sha256);function p(e){return BigInt(`0x${(0,c.bytesToHex)(e)}`)}const m=(0,c.utf8ToBytes)("Bitcoin seed"),g={private:76066276,public:76067358};n.HARDENED_OFFSET=2147483648;const y=e=>{if(!Number.isSafeInteger(e)||e<0||e>2**32-1)throw new Error(`Invalid number=${e}. Should be from 0 to 2 ** 32 - 1`);const t=new Uint8Array(4);return(0,c.createView)(t).setUint32(0,e,!1),t};class w{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return e=this.pubHash,(0,c.createView)(e).getUint32(0,!1);var e}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const e=this.privateKey;if(!e)throw new Error("No private key");return h.encode(this.serialize(this.versions.private,(0,c.concatBytes)(new Uint8Array([0]),e)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return h.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(e,t=g){if((0,a.bytes)(e),8*e.length<128||8*e.length>512)throw new Error(`HDKey: wrong seed length=${e.length}. Should be between 128 and 512 bits; 256 bits is advised)`);const n=(0,r.hmac)(s.sha512,m,e);return new w({versions:t,chainCode:n.slice(32),privateKey:n.slice(0,32)})}static fromExtendedKey(e,t=g){const n=h.decode(e),r=(0,c.createView)(n),i=r.getUint32(0,!1),o={versions:t,depth:n[4],parentFingerprint:r.getUint32(5,!1),index:r.getUint32(9,!1),chainCode:n.slice(13,45)},s=n.slice(45),a=0===s[0];if(i!==t[a?"private":"public"])throw new Error("Version mismatch");return new w(a?{...o,privateKey:s.slice(1)}:{...o,publicKey:s})}static fromJSON(e){return w.fromExtendedKey(e.xpriv)}constructor(e){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!e||"object"!=typeof e)throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions||g,this.depth=e.depth||0,this.chainCode=e.chainCode||null,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!u.secp256k1.utils.isValidPrivateKey(e.privateKey))throw new Error("Invalid private key");this.privKey="bigint"==typeof e.privateKey?e.privateKey:p(e.privateKey),this.privKeyBytes=(t=this.privKey,(0,c.hexToBytes)(t.toString(16).padStart(64,"0"))),this.pubKey=u.secp256k1.getPublicKey(e.privateKey,!0)}else{if(!e.publicKey)throw new Error("HDKey: no public or private key provided");this.pubKey=f.fromHex(e.publicKey).toRawBytes(!0)}var t,n;this.pubHash=(n=this.pubKey,(0,i.ripemd160)((0,o.sha256)(n)))}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;const t=e.replace(/^[mM]'?\//,"").split("/");let r=this;for(const e of t){const t=/^(\d+)('?)$/.exec(e),i=t&&t[1];if(!t||3!==t.length||"string"!=typeof i)throw new Error(`Invalid child index: ${e}`);let o=+i;if(!Number.isSafeInteger(o)||o>=n.HARDENED_OFFSET)throw new Error("Invalid index");"'"===t[2]&&(o+=n.HARDENED_OFFSET),r=r.deriveChild(o)}return r}deriveChild(e){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let t=y(e);if(e>=n.HARDENED_OFFSET){const e=this.privateKey;if(!e)throw new Error("Could not derive hardened child key");t=(0,c.concatBytes)(new Uint8Array([0]),e,t)}else t=(0,c.concatBytes)(this.pubKey,t);const i=(0,r.hmac)(s.sha512,this.chainCode,t),o=p(i.slice(0,32)),a=i.slice(32);if(!u.secp256k1.utils.isValidPrivateKey(o))throw new Error("Tweak bigger than curve order");const d={versions:this.versions,chainCode
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("@noble/hashes/hmac"),i=e("@noble/hashes/utils"),o=e("./abstract/weierstrass.js");function s(e){return{hash:e,hmac:(t,...n)=>(0,r.hmac)(e,t,(0,i.concatBytes)(...n)),randomBytes:i.randomBytes}}}}},{package:"viem>@scure/bip32>@noble/curves",file:"node_modules/@scure/bip32/node_modules/@noble/curves/_shortw_utils.js"}],[3030,{"./modular.js":3032,"./utils.js":3033},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.wNAF=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>o;)n&s&&(r=r.add(i)),i=i.double(),n>>=s;return r},precomputeWindow(e,t){const{windows:n,windowSize:i}=r(t),o=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,o.push(a);for(let e=1;e<i;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(t,i,o){const{windows:a,windowSize:c}=r(t);let u=e.ZERO,l=e.BASE;const d=BigInt(2**t-1),f=2**t,h=BigInt(t);for(let e=0;e<a;e++){const t=e*c;let r=Number(o&d);o>>=h,r>c&&(r-=f,o+=s);const a=t,p=t+Math.abs(r)-1,m=e%2!=0,g=r<0;0===r?l=l.add(n(m,i[a])):u=u.add(n(g,i[p]))}return{p:u,f:l}},wNAFCached(e,t,n,r){const i=e._WINDOW_SIZE||1;let o=t.get(e);return o||(o=this.precomputeWindow(e,i),1!==i&&t.set(e,r(o))),this.wNAF(i,o,n)}}},n.validateBasic=function(e){return(0,r.validateField)(e.Fp),(0,i.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,r.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})};
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("./modular.js"),i=e("./utils.js"),o=BigInt(0),s=BigInt(1)}}},{package:"viem>@scure/bip32>@noble/curves",file:"node_modules/@scure/bip32/node_modules/@noble/curves/abstract/curve.js"}],[3031,{"./modular.js":3032,"./utils.js":3033},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.expand_message_xmd=u,n.expand_message_xof=l,n.hash_to_field=d,n.isogenyMap=function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[i,o,s,a]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r)))));return t=e.div(i,o),r=e.mul(r,e.div(s,a)),{x:t,y:r}}},n.createHasher=function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(r,i){const o=d(r,2,{...n,DST:n.DST,...i}),s=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=s.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){const o=d(r,1,{...n,DST:n.encodeDST,...i}),s=e.fromAffine(t(o[0])).clearCofactor();return s.assertValidity(),s},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(const e of n)if("bigint"!=typeof e)throw new Error(`mapToCurve: expected array of bigints, got ${e} in array`);const r=e.fromAffine(t(n)).clearCofactor();return r.assertValidity(),r}}};const r=e("./modular.js"),i=e("./utils.js"),o=i.bytesToNumberBE;function s(e,t){if(e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function a(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function c(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function u(e,t,n,r){(0,i.abytes)(e),(0,i.abytes)(t),c(n),t.length>255&&(t=r((0,i.concatBytes)((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:o,blockLen:u}=r,l=Math.ceil(n/o);if(l>255)throw new Error("Invalid xmd length");const d=(0,i.concatBytes)(t,s(t.length,1)),f=s(0,u),h=s(n,2),p=new Array(l),m=r((0,i.concatBytes)(f,e,h,s(0,1),d));p[0]=r((0,i.concatBytes)(m,s(1,1),d));for(let e=1;e<=l;e++){const t=[a(m,p[e-1]),s(e+1,1),d];p[e]=r((0,i.concatBytes)(...t))}return(0,i.concatBytes)(...p).slice(0,n)}function l(e,t,n,r,o){if((0,i.abytes)(e),(0,i.abytes)(t),c(n),t.length>255){const e=Math.ceil(2*r/8);t=o.create({dkLen:e}).update((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:n}).update(e).update(s(n,2)).update(t).update(s(t.length,1)).digest()}function d(e,t,n){(0,i.validateObject)(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:a,m:d,hash:f,expand:h,DST:p}=n;(0,i.abytes)(e),c(t);const m="string"==typeof p?(0,i.utf8ToBytes)(p):p,g=s.toString(2).length,y=Math.ceil((g+a)/8),w=t*d*y;let b;if("xmd"===h)b=u(e,m,w,f);else if("xof"===h)b=l(e,m,w,a,f);else{if("_internal_pass"!==h)throw new Error('expand must be "xmd" or "xof"');b=e}const v=new Array(t);for(let e=0;e<t;e++){const t=new Array(d);for(let n=0;n<d;n++){const i=y*(n+e*d),a=b.subarray(i,i+y);t[n]=(0,r.mod)(o(a),s)}v[e]=t}return v}}}},{package:"viem>@scure/bip32>@noble/curves",file:"node_modules/@scure/bip32/node_modules/@noble/curves/abstract/hash-to-curve.js"}],[3032,{"./utils.js":3033},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.isNegativeLE=void 0,n.mod=d,n.pow=f,n.pow2=function(e,t,n){let r=e;for(;t-- >i;)r*=r,r%=n;return r},n.invert=h,n.tonelliShanks=p,n.FpSqrt=m,n.validateField=function(e){const t=g.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,r.validateObject)(e,t)},n.FpPow=y,n.FpInvertBatch=w,n.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?h(n,e.ORDER):e.inv(n))},n.FpIsSquare=function(e){const t=(e.ORDER-o)/s;return n=>{const r=e.p
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("./utils.js"),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),c=BigInt(4),u=BigInt(5),l=BigInt(8);BigInt(9),BigInt(16);function d(e,t){const n=e%t;return n>=i?n:t+n}function f(e,t,n){if(n<=i||t<i)throw new Error("Expected power/modulo > 0");if(n===o)return i;let r=o;for(;t>i;)t&o&&(r=r*e%n),e=e*e%n,t>>=o;return r}function h(e,t){if(e===i||t<=i)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=d(e,t),r=t,s=i,a=o,c=o,u=i;for(;n!==i;){const e=r/n,t=r%n,i=s-c*e,o=a-u*e;r=n,n=t,s=c,a=u,c=i,u=o}if(r!==o)throw new Error("invert: does not exist");return d(s,t)}function p(e){const t=(e-o)/s;let n,r,a;for(n=e-o,r=0;n%s===i;n/=s,r++);for(a=s;a<e&&f(a,t,e)!==e-o;a++);if(1===r){const t=(e+o)/c;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const u=(n+o)/s;return function(e,i){if(e.pow(i,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let s=r,c=e.pow(e.mul(e.ONE,a),n),l=e.pow(i,u),d=e.pow(i,n);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(d);t<s&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,o<<BigInt(s-t-1));c=e.sqr(n),l=e.mul(l,n),d=e.mul(d,c),s=t}return l}}function m(e){if(e%c===a){const t=(e+o)/c;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%l===u){const t=(e-u)/l;return function(e,n){const r=e.mul(n,s),i=e.pow(r,t),o=e.mul(n,i),a=e.mul(e.mul(o,s),i),c=e.mul(o,e.sub(a,e.ONE));if(!e.eql(e.sqr(c),n))throw new Error("Cannot find square root");return c}}return p(e)}n.isNegativeLE=(e,t)=>(d(e,t)&o)===o;const g=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function y(e,t,n){if(n<i)throw new Error("Expected power > 0");if(n===i)return e.ONE;if(n===o)return t;let r=e.ONE,s=t;for(;n>i;)n&o&&(r=e.mul(r,s)),s=e.sqr(s),n>>=o;return r}function w(e,t){const n=new Array(t.length),r=t.reduce(((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r))),e.ONE),i=e.inv(r);return t.reduceRight(((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r))),i),n}function b(e,t){const n=t!==undefined?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function v(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function E(e){const t=v(e);return t+Math.ceil(t/2)}}}},{package:"viem>@scure/bip32>@noble/curves",file:"node_modules/@scure/bip32/node_modules/@noble/curves/abstract/modular.js"}],[3033,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.bitMask=void 0,n.isBytes=s,n.abytes=a,n.bytesToHex=u,n.numberToHexUnpadded=l,n.hexToNumber=d,n.hexToBytes=p,n.bytesToNumberBE=function(e){return d(u(e))},n.bytesToNumberLE=function(e){return a(e),d(u(Uint8Array.from(e).reverse()))},n.numberToBytesBE=m,n.numberToBytesLE=function(e,t){return m(e,t).reverse()},n.numberToVarBytesBE=function(e){return p(l(e))},n.ensureBytes=function(e,t,n){let r;if("string"==typeof t)try{r=p(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!s(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${e} expected ${n} bytes, got ${i}`);return r},n.concatBytes=g,n.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},n.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},n.bitLen=function(e){let t;for(t=0;e>r;e>>=i,t+=1);return t},n.bitGet=function(e,t){return e>>BigInt(t)&i},n.bitSet=function(e,t,n){return e|(n?i:r)<<BigInt(t)},n.createHmacDrbg=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=ty
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=BigInt(0),i=BigInt(1),o=BigInt(2);function s(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function a(e){if(!s(e))throw new Error("Uint8Array expected")}const c=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function u(e){a(e);let t="";for(let n=0;n<e.length;n++)t+=c[e[n]];return t}function l(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function d(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}const f={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function h(e){return e>=f._0&&e<=f._9?e-f._0:e>=f._A&&e<=f._F?e-(f._A-10):e>=f._a&&e<=f._f?e-(f._a-10):void 0}function p(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=h(e.charCodeAt(i)),o=h(e.charCodeAt(i+1));if(n===undefined||o===undefined){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+o}return r}function m(e,t){return p(e.toString(16).padStart(2*t,"0"))}function g(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];a(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n}n.bitMask=e=>(o<<BigInt(e-1))-i;const y=e=>new Uint8Array(e),w=e=>Uint8Array.from(e);const b={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||s(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)}}}},{package:"viem>@scure/bip32>@noble/curves",file:"node_modules/@scure/bip32/node_modules/@noble/curves/abstract/utils.js"}],[3034,{"./curve.js":3030,"./modular.js":3032,"./utils.js":3033},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.DER=void 0,n.weierstrassPoints=p,n.weierstrass=function(e){const t=function(e){const t=(0,r.validateBasic)(e);return o.validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:a,n:c}=t,d=a.BYTES+1,f=2*a.BYTES+1;function h(e){return i.mod(e,c)}function m(e){return i.invert(e,c)}const{ProjectivePoint:g,normPrivateKeyToScalar:y,weierstrassEquation:w,isWithinCurveOrder:b}=p({...t,toBytes(e,t,n){const r=t.toAffine(),i=a.toBytes(r.x),s=o.concatBytes;return n?s(Uint8Array.from([t.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,a.toBytes(r.y))},fromBytes(e){const t=e.length,n=e[0],r=e.subarray(1);if(t!==d||2!==n&&3!==n){if(t===f&&4===n){return{x:a.fromBytes(r.subarray(0,a.BYTES)),y:a.fromBytes(r.subarray(a.BYTES,2*a.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${d} compressed bytes or ${f} uncompressed bytes`)}{const e=o.bytesToNumberBE(r);if(!(u<(i=e)&&i<a.ORDER))throw new Error("Point is not on curve");const t=w(e);let s;try{s=a.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~n)!==((s&l)===l)&&(s=a.neg(s)),{x:e,y:s}}var i}}),v=e=>o.bytesToHex(o.numberToBytesBE(e,t.nByteLength));function E(e){return e>c>>l}const A=(e,t,n)=>o.bytesToNumberBE(e.slice(t,n));class T{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=(0,s.ensureBytes)("compactSignature",e,2*n),new T(A(e,0,n),A(e,n,2*n))}static fromDER(e){const{r:t,s:r}=n.DER.toSig((0,s.ensureBytes)("DER",e));return new T(t,r)}assertValidity(){if(!b(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!b(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new T(this.r,this.s,e)}recoverPublicKey(e){const{r:n,s:r,recovery:i}=this,o=I((
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("./curve.js"),i=e("./modular.js"),o=e("./utils.js"),s=e("./utils.js");const{bytesToNumberBE:a,hexToBytes:c}=o;n.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=n.DER;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const r=e[1],i=e.subarray(2,r+2);if(!r||i.length!==r)throw new t("Invalid signature integer: wrong length");if(128&i[0])throw new t("Invalid signature integer: negative");if(0===i[0]&&!(128&i[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:a(i),l:e.subarray(r+2)}},toSig(e){const{Err:t}=n.DER,r="string"==typeof e?c(e):e;o.abytes(r);let i=r.length;if(i<2||48!=r[0])throw new t("Invalid signature tag");if(r[1]!==i-2)throw new t("Invalid signature: incorrect length");const{d:s,l:a}=n.DER._parseInt(r.subarray(2)),{d:u,l:l}=n.DER._parseInt(a);if(l.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:u}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),o=r.length/2,s=i.length/2,a=n(o),c=n(s);return`30${n(s+o+4)}02${c}${i}02${a}${r}`}};const u=BigInt(0),l=BigInt(1),d=BigInt(2),f=BigInt(3),h=BigInt(4);function p(e){const t=function(e){const t=(0,r.validateBasic)(e);o.validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:i,a:s}=t;if(n){if(!i.eql(s,i.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,a=t.toBytes||((e,t,r)=>{const i=t.toAffine();return o.concatBytes(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),c=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function d(e){const{a:r,b:i}=t,o=n.sqr(e),s=n.mul(o,e);return n.add(n.add(s,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),d(t.Gx)))throw new Error("bad generator point: equation left != right");function h(e){return"bigint"==typeof e&&u<e&&e<t.n}function p(e){if(!h(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function m(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:a,n:c}=t;if(n&&"bigint"!=typeof e){if(o.isBytes(e)&&(e=o.bytesToHex(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*r,"0")}let u;try{u="bigint"==typeof e?e:o.bytesToNumberBE((0,s.ensureBytes)("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return a&&(u=i.mod(u,c)),p(u),u}const g=new Map;function y(e){if(!(e instanceof w))throw new Error("ProjectivePoint expected")}class w{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof w)throw new Error("projective point not allowed");const i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?w.ZERO:new w(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(w.fromAffine)}static fromHex(e){const t=w.fromAffine(c((0,s.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return w.BASE.multiply(m(e))}_setWindowSize(e){this._WINDOW_SIZE=e,g.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const i=
|
||
|
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||
|
|
const r=e("@noble/hashes/sha256"),i=e("@noble/hashes/utils"),o=e("./_shortw_utils.js"),s=e("./abstract/hash-to-curve.js"),a=e("./abstract/modular.js"),c=e("./abstract/utils.js"),u=e("./abstract/weierstrass.js"),l=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),d=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),f=BigInt(1),h=BigInt(2),p=(e,t)=>(e+t/h)/t;function m(e){const t=l,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),c=BigInt(44),u=BigInt(88),d=e*e*e%t,f=d*d*e%t,p=(0,a.pow2)(f,n,t)*f%t,m=(0,a.pow2)(p,n,t)*f%t,y=(0,a.pow2)(m,h,t)*d%t,w=(0,a.pow2)(y,i,t)*y%t,b=(0,a.pow2)(w,o,t)*w%t,v=(0,a.pow2)(b,c,t)*b%t,E=(0,a.pow2)(v,u,t)*v%t,A=(0,a.pow2)(E,c,t)*b%t,T=(0,a.pow2)(A,n,t)*f%t,x=(0,a.pow2)(T,s,t)*w%t,S=(0,a.pow2)(x,r,t)*d%t,k=(0,a.pow2)(S,h,t);if(!g.eql(g.sqr(k),e))throw new Error("Cannot find square root");return k}const g=(0,a.Field)(l,undefined,undefined,{sqrt:m});n.secp256k1=(0,o.createCurve)({a:BigInt(0),b:BigInt(7),Fp:g,n:d,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=d,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-f*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),c=p(o*e,t),u=p(-r*e,t);let l=(0,a.mod)(e-c*n-u*i,t),h=(0,a.mod)(-c*r-u*o,t);const m=l>s,g=h>s;if(m&&(l=t-l),g&&(h=t-h),l>s||h>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:m,k1:l,k2neg:g,k2:h}}}},r.sha256);const y=BigInt(0),w=e=>"bigint"==typeof e&&y<e&&e<l,b=e=>"bigint"==typeof e&&y<e&&e<d,v={};function E(e,...t){let n=v[e];if(n===undefined){const t=(0,r.sha256)(Uint8Array.from(e,(e=>e.charCodeAt(0))));n=(0,c.concatBytes)(t,t),v[e]=n}return(0,r.sha256)((0,c.concatBytes)(n,...t))}const A=e=>e.toRawBytes(!0).slice(1),T=e=>(0,c.numberToBytesBE)(e,32),x=e=>(0,a.mod)(e,l),S=e=>(0,a.mod)(e,d),k=n.secp256k1.ProjectivePoint,I=(e,t,n)=>k.BASE.multiplyAndAddUnsafe(e,t,n);function C(e){let t=n.secp256k1.utils.normPrivateKeyToScalar(e),r=k.fromPrivateKey(t);return{scalar:r.hasEvenY()?t:S(-t),bytes:A(r)}}function j(e){if(!w(e))throw new Error("bad x: need 0 < x < p");const t=x(e*e);let n=m(x(t*e+BigInt(7)));n%h!==y&&(n=x(-n));const r=new k(e,n,f);return r.assertValidity(),r}function P(...e){return S((0,c.bytesToNumberBE)(E("BIP0340/challenge",...e)))}function _(e){return C(e).bytes}function O(e,t,n=(0,i.randomBytes)(32)){const r=(0,c.ensureBytes)("message",e),{bytes:o,scalar:s}=C(t),a=(0,c.ensureBytes)("auxRand",n,32),u=T(s^(0,c.bytesToNumberBE)(E("BIP0340/aux",a))),l=E("BIP0340/nonce",u,o,r),d=S((0,c.bytesToNumberBE)(l));if(d===y)throw new Error("sign failed: k is zero");const{bytes:f,scalar:h}=C(d),p=P(f,o,r),m=new Uint8Array(64);if(m.set(f,0),m.set(T(S(h+p*s)),32),!B(m,r,o))throw new Error("sign: Invalid signature produced");return m}function B(e,t,n){const r=(0,c.ensureBytes)("signature",e,64),i=(0,c.ensureBytes)("message",t),o=(0,c.ensureBytes)("publicKey",n,32);try{const e=j((0,c.bytesToNumberBE)(o)),t=(0,c.bytesToNumberBE)(r.subarray(0,32));if(!w(t))return!1;const n=(0,c.bytesToNumberBE)(r.subarray(32,64));if(!b(n))return!1;const s=P(T(t),A(e),i),a=I(e,n,S(-s));return!(!a||!a.hasEvenY()||a.toAffine().x!==t)}catch(e){return!1}}n.schnorr={getPublicKey:_,sign:O,verify:B,utils:{randomPrivateKey:n.secp256k1.utils.randomPrivateKey,lift_x:j,pointToBytes:A,numberToBytesBE:c.numberToBytesBE,bytesToNumberBE:c.bytesToNumberBE,taggedHash:E,mod:a.mod}};const R=(()=>(0,s.isogenyMap)(g,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9
|