@notabene/verify-proof 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -3
package/dist/index.modern.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{ProofStatus as e,ProofTypes as t}from"@notabene/javascript-sdk";import{bech32 as n}from"bech32";import{secp256k1 as r,hash160 as i,encodeBase58AddressFormat as o,hash256 as s}from"@bitauth/libauth";import{encode as a}from"varuint-bitcoin";import{decode as c}from"@stablelib/base64";import u from"tweetnacl";import f from"bs58";function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l.apply(null,arguments)}var h,d;function g(e){const t=n.toWords(e);return t.unshift(0),n.encode("bc",t)}!function(e){e.P2WPKH="p2wpkh",e.P2SH_P2WPKH="p2sh(p2wpkh)"}(h||(h={})),function(e){e.LEGACY="Legacy",e.NATIVE="Native SegWit",e.SEGWIT="SegWit",e.P2SH_SEGWIT="p2sh",e.BCH="Bitcoin Cash",e.ETHEREUM="Ethereum",e.DOGECOIN="Dogecoin",e.UNKNOWN="Unknown"}(d||(d={}));class p extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof p){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause?.message?t.cause.message:t.details})(),r=t.cause instanceof p&&t.cause.docsPath||t.docsPath,i=`https://oxlib.sh${r??""}`;super([e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${i}`:void 0]:[]].filter(e=>"string"==typeof e).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:"ox@0.1.1"}),this.cause=t.cause,this.details=n,this.docs=i,this.docsPath=r,this.shortMessage=e}walk(e){return w(this,e)}}function w(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?w(e.cause,t):t?null:e}function y(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function b(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function m(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}const E=/* @__PURE__ */(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function v(e){for(let n=0;n<e.length;n++)e[n]=(t=e[n])<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;var t}function x(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),b(e),e}class B{clone(){return this._cloneInto()}}const I=/* @__PURE__ */BigInt(2**32-1),A=/* @__PURE__ */BigInt(32);function S(e,t=!1){return t?{h:Number(e&I),l:Number(e>>A&I)}:{h:0|Number(e>>A&I),l:0|Number(e&I)}}function O(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:o,l:s}=S(e[i],t);[n[i],r[i]]=[o,s]}return[n,r]}const P=[],z=[],L=[],U=/* @__PURE__ */BigInt(0),N=/* @__PURE__ */BigInt(1),k=/* @__PURE__ */BigInt(2),R=/* @__PURE__ */BigInt(7),H=/* @__PURE__ */BigInt(256),T=/* @__PURE__ */BigInt(113);for(let e=0,t=N,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],P.push(2*(5*r+n)),z.push((e+1)*(e+2)/2%64);let i=U;for(let e=0;e<7;e++)t=(t<<N^(t>>R)*T)%H,t&k&&(i^=N<<(N<</* @__PURE__ */BigInt(e))-N);L.push(i)}const[$,F]=/* @__PURE__ */O(L,!0),j=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),q=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class C extends B{constructor(e,t,n,r=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,y(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var o;this.state=new Uint8Array(200),this.state32=(o=this.state,new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)))}keccak(){E||v(this.state32),function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,i=(t+2)%10,o=n[i],s=n[i+1],a=j(o,s,1)^n[r],c=q(o,s,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=a,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){const r=z[n],o=j(t,i,r),s=q(t,i,r),a=P[n];t=e[a],i=e[a+1],e[a]=o,e[a+1]=s}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=$[r],e[1]^=F[r]}n.fill(0)}(this.state32,this.rounds),E||v(this.state32),this.posOut=0,this.pos=0}update(e){m(this);const{blockLen:t,state:n}=this,r=(e=x(e)).length;for(let i=0;i<r;){const o=Math.min(t-this.pos,r-i);for(let t=0;t<o;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){m(this,!1),b(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return y(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(function(e,t){b(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:i,enableXOF:o}=this;return e||(e=new C(t,n,r,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=n,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}}const D=/* @__PURE__ */(()=>function(e){const t=t=>e().update(x(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}(()=>new C(136,1,32)))(),V=/* @__PURE__ */BigInt(0),M=/* @__PURE__ */BigInt(1),_=/* @__PURE__ */BigInt(2);function K(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Z(e){if(!K(e))throw new Error("Uint8Array expected")}function G(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}const W=/* @__PURE__ */Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Y(e){Z(e);let t="";for(let n=0;n<e.length;n++)t+=W[e[n]];return t}function X(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function J(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?V:BigInt("0x"+e)}function Q(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function ee(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=Q(e.charCodeAt(i)),o=Q(e.charCodeAt(i+1));if(void 0===n||void 0===o)throw new Error('hex string expected, got non-hex character "'+(e[i]+e[i+1])+'" at index '+i);r[t]=16*n+o}return r}function te(e){return J(Y(e))}function ne(e){return Z(e),J(Y(Uint8Array.from(e).reverse()))}function re(e,t){return ee(e.toString(16).padStart(2*t,"0"))}function ie(e,t){return re(e,t).reverse()}function oe(e,t,n){let r;if("string"==typeof t)try{r=ee(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!K(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}function se(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];Z(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 ae=e=>"bigint"==typeof e&&V<=e;function ce(e,t,n){return ae(e)&&ae(t)&&ae(n)&&t<=e&&e<n}function ue(e,t,n,r){if(!ce(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function fe(e){let t;for(t=0;e>V;e>>=M,t+=1);return t}const le=e=>(_<<BigInt(e-1))-M,he=e=>new Uint8Array(e),de=e=>Uint8Array.from(e);function ge(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=he(e),i=he(e),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...e)=>n(i,r,...e),c=(e=he())=>{i=a(de([0]),e),r=a(),0!==e.length&&(i=a(de([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 se(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(u()));)c();return s(),n}}const pe={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||K(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)};function we(e,t,n={}){const r=(t,n,r)=>{const i=pe[n];if("function"!=typeof i)throw new Error("invalid validator function");const o=e[t];if(!(r&&void 0===o||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}function ye(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(void 0!==i)return i;const o=e(n,...r);return t.set(n,o),o}}var be={__proto__:null,isBytes:K,abytes:Z,abool:G,bytesToHex:Y,numberToHexUnpadded:X,hexToNumber:J,hexToBytes:ee,bytesToNumberBE:te,bytesToNumberLE:ne,numberToBytesBE:re,numberToBytesLE:ie,numberToVarBytesBE:function(e){return ee(X(e))},ensureBytes:oe,concatBytes:se,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},utf8ToBytes:function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))},inRange:ce,aInRange:ue,bitLen:fe,bitGet:function(e,t){return e>>BigInt(t)&M},bitSet:function(e,t,n){return e|(n?M:V)<<BigInt(t)},bitMask:le,createHmacDrbg:ge,validateObject:we,notImplemented:()=>{throw new Error("not implemented")},memoized:ye};function me(e,t,n){return JSON.stringify(e,(e,n)=>"function"==typeof t?t(e,n):"bigint"==typeof n?n.toString()+"#__bigint":n,n)}function Ee(e,t){if(Ce(e)>t)throw new Ve({givenSize:Ce(e),maxSize:t})}function ve(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function xe(e,t){if(ke(e)>t)throw new $e({givenSize:ke(e),maxSize:t})}function Be(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;const i=e.replace("0x","");if(i.length>2*r)throw new je({size:Math.ceil(i.length/2),targetSize:r,type:"Hex"});return`0x${i["right"===n?"padEnd":"padStart"](2*r,"0")}`}const Ie=/*#__PURE__*/new TextEncoder,Ae=/*#__PURE__*/Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Se(...e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function Oe(e){return e instanceof Uint8Array?Pe(e):Array.isArray(e)?Pe(new Uint8Array(e)):e}function Pe(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Ae[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(xe(r,t.size),Ue(r,t.size)):r}function ze(e,t={}){const{signed:n,size:r}=t,i=BigInt(e);let o;r?o=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(o=BigInt(Number.MAX_SAFE_INTEGER));const s="bigint"==typeof o&&n?-o-1n:0;if(o&&i>o||i<s){const t="bigint"==typeof e?"n":"";throw new Re({max:o?`${o}${t}`:void 0,min:`${s}${t}`,signed:n,size:r,value:`${e}${t}`})}const a=`0x${(n&&i<0?(1n<<BigInt(8*r))+BigInt(i):i).toString(16)}`;return r?function(e,t){return Be(e,{dir:"left",size:t})}(a,r):a}function Le(e,t={}){return Pe(Ie.encode(e),t)}function Ue(e,t){return Be(e,{dir:"right",size:t})}function Ne(e,t,n,r={}){const{strict:i}=r;!function(e,t){if("number"==typeof t&&t>0&&t>ke(e)-1)throw new Fe({offset:t,position:"start",size:ke(e)})}(e,t);const o=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return i&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&ke(e)!==n-t)throw new Fe({offset:n,position:"end",size:ke(e)})}(o,t,n),o}function ke(e){return Math.ceil((e.length-2)/2)}class Re extends p{constructor({max:e,min:t,signed:n,size:r,value:i}){super(`Number \`${i}\` is not in safe${r?` ${8*r}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class He extends p{constructor(e){super(`Value \`${"object"==typeof e?me(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class Te extends p{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}class $e extends p{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class Fe extends p{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class je extends p{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}const qe=/*#__PURE__*/new TextEncoder;function Ce(e){return e.length}class De extends p{constructor(e){super(`Value \`${"object"==typeof e?me(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class Ve extends p{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Me extends p{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}function _e(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=D(function(e){return e instanceof Uint8Array?e:"string"==typeof e?function(e,t={}){const{size:n}=t;let r=e;n&&(xe(e,n),r=Ue(e,n));let i=r.slice(2);i.length%2&&(i=`0${i}`);const o=i.length/2,s=new Uint8Array(o);for(let e=0,t=0;e<o;e++){const n=ve(i.charCodeAt(t++)),r=ve(i.charCodeAt(t++));if(void 0===n||void 0===r)throw new p(`Invalid byte sequence ("${i[t-2]}${i[t-1]}" in "${i}").`);s[e]=16*n+r}return s}(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}(e));return"Bytes"===n?r:Pe(r)}class Ke extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const Ze=/*#__PURE__*/new Ke(8192);function Ge(e,t={}){const{compressed:n}=t,{prefix:r,x:i,y:o}=e;if(!1===n||"bigint"==typeof i&&"bigint"==typeof o){if(4!==r)throw new Xe({prefix:r,cause:new Qe})}else{if(!0!==n&&("bigint"!=typeof i||void 0!==o))throw new Ye({publicKey:e});if(3!==r&&2!==r)throw new Xe({prefix:r,cause:new Je})}}function We(e){if(132!==e.length&&130!==e.length&&68!==e.length)throw new et({publicKey:e});return 130===e.length?{prefix:4,x:BigInt(Ne(e,0,32)),y:BigInt(Ne(e,32,64))}:132===e.length?{prefix:Number(Ne(e,0,1)),x:BigInt(Ne(e,1,33)),y:BigInt(Ne(e,33,65))}:{prefix:Number(Ne(e,0,1)),x:BigInt(Ne(e,1,33))}}class Ye extends p{constructor({publicKey:e}){super(`Value \`${me(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class Xe extends p{constructor({prefix:e,cause:t}){super(`Prefix "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class Je extends p{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class Qe extends p{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}class et extends p{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${ke(Oe(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}}const tt=/^0x[a-fA-F0-9]{40}$/;function nt(e,t={}){const{strict:n=!0}=t;if(!tt.test(e))throw new it({address:e,cause:new ot});if(n){if(e.toLowerCase()===e)return;if(rt(e)!==e)throw new it({address:e,cause:new st})}}function rt(e){if(Ze.has(e))return Ze.get(e);nt(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=_e(function(e,t={}){const{size:n}=t,r=qe.encode(e);return"number"==typeof n?(Ee(r,n),function(e,t){return function(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;if(e.length>r)throw new Me({size:e.length,targetSize:r,type:"Bytes"});const i=new Uint8Array(r);for(let t=0;t<r;t++){const o="right"===n;i[o?t:r-t-1]=e[o?t:e.length-t-1]}return i}(e,{dir:"right",size:t})}(r,n)):r}(t),{as:"Bytes"}),r=t.split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&r[e]&&(r[e]=r[e].toUpperCase()),(15&n[e>>1])>=8&&r[e+1]&&(r[e+1]=r[e+1].toUpperCase());const i=`0x${r.join("")}`;return Ze.set(e,i),i}class it extends p{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class ot extends p{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class st extends p{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}function at(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ct(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ut(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}const ft="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,lt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),ht=(e,t)=>e<<32-t|e>>>t;function dt(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),ct(e),e}class gt{clone(){return this._cloneInto()}}function pt(e){const t=t=>e().update(dt(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function wt(e=32){if(ft&&"function"==typeof ft.getRandomValues)return ft.getRandomValues(new Uint8Array(e));if(ft&&"function"==typeof ft.randomBytes)return ft.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const yt=(e,t,n)=>e&t^e&n^t&n;class bt extends gt{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=lt(this.buffer)}update(e){ut(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=dt(e)).length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s!==r)n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=lt(e);for(;r<=i-o;o+=r)this.process(t,o)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){ut(this),function(e,t){ct(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let e=o;e<r;e++)t[e]=0;!function(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?0:4;e.setUint32(t+(r?4:0),s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=lt(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,u[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return e.length=r,e.pos=s,e.finished=i,e.destroyed=o,r%t&&e.buffer.set(n),e}}const mt=/* @__PURE__ */new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Et=/* @__PURE__ */new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),vt=/* @__PURE__ */new Uint32Array(64);class xt extends bt{constructor(){super(64,32,8,!1),this.A=0|Et[0],this.B=0|Et[1],this.C=0|Et[2],this.D=0|Et[3],this.E=0|Et[4],this.F=0|Et[5],this.G=0|Et[6],this.H=0|Et[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)vt[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=vt[e-15],n=vt[e-2],r=ht(t,7)^ht(t,18)^t>>>3,i=ht(n,17)^ht(n,19)^n>>>10;vt[e]=i+vt[e-7]+r+vt[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(ht(s,6)^ht(s,11)^ht(s,25))+((f=s)&a^~f&c)+mt[e]+vt[e]|0,l=(ht(n,2)^ht(n,13)^ht(n,22))+yt(n,r,i)|0;u=c,c=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+l|0}var f;n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,i,o,s,a,c,u)}roundClean(){vt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Bt=/* @__PURE__ */pt(()=>new xt);class It extends gt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");at(e.outputLen),at(e.blockLen)}(e);const n=dt(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return ut(this),this.iHash.update(e),this}digestInto(e){ut(this),ct(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return e.finished=r,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const At=(e,t,n)=>new It(e,t).update(n).digest();At.create=(e,t)=>new It(e,t);const St=BigInt(0),Ot=BigInt(1),Pt=/* @__PURE__ */BigInt(2),zt=/* @__PURE__ */BigInt(3),Lt=/* @__PURE__ */BigInt(4),Ut=/* @__PURE__ */BigInt(5),Nt=/* @__PURE__ */BigInt(8);function kt(e,t){const n=e%t;return n>=St?n:t+n}function Rt(e,t,n){if(t<St)throw new Error("invalid exponent, negatives unsupported");if(n<=St)throw new Error("invalid modulus");if(n===Ot)return St;let r=Ot;for(;t>St;)t&Ot&&(r=r*e%n),e=e*e%n,t>>=Ot;return r}function Ht(e,t,n){let r=e;for(;t-- >St;)r*=r,r%=n;return r}function Tt(e,t){if(e===St)throw new Error("invert: expected non-zero number");if(t<=St)throw new Error("invert: expected positive modulus, got "+t);let n=kt(e,t),r=t,i=St,o=Ot;for(;n!==St;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==Ot)throw new Error("invert: does not exist");return kt(i,t)}const $t=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ft(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function jt(e,t,n=!1,r={}){if(e<=St)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:i,nByteLength:o}=Ft(e,t);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s;const a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:le(i),ZERO:St,ONE:Ot,create:t=>kt(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return St<=t&&t<e},is0:e=>e===St,isOdd:e=>(e&Ot)===Ot,neg:t=>kt(-t,e),eql:(e,t)=>e===t,sqr:t=>kt(t*t,e),add:(t,n)=>kt(t+n,e),sub:(t,n)=>kt(t-n,e),mul:(t,n)=>kt(t*n,e),pow:(e,t)=>function(e,t,n){if(n<St)throw new Error("invalid exponent, negatives unsupported");if(n===St)return e.ONE;if(n===Ot)return t;let r=e.ONE,i=t;for(;n>St;)n&Ot&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Ot;return r}(a,e,t),div:(t,n)=>kt(t*Tt(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Tt(t,e),sqrt:r.sqrt||(t=>(s||(s=function(e){if(e%Lt===zt){const t=(e+Ot)/Lt;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%Nt===Ut){const t=(e-Ut)/Nt;return function(e,n){const r=e.mul(n,Pt),i=e.pow(r,t),o=e.mul(n,i),s=e.mul(e.mul(o,Pt),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-Ot)/Pt;let n,r,i;for(n=e-Ot,r=0;n%Pt===St;n/=Pt,r++);for(i=Pt;i<e&&Rt(i,t,e)!==e-Ot;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(1===r){const t=(e+Ot)/Lt;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 o=(n+Ot)/Pt;return function(e,s){if(e.pow(s,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,i),n),u=e.pow(s,o),f=e.pow(s,n);for(;!e.eql(f,e.ONE);){if(e.eql(f,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(f);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,Ot<<BigInt(a-t-1));c=e.sqr(n),u=e.mul(u,n),f=e.mul(f,c),a=t}return u}}(e)}(e)),s(a,t))),invertBatch:e=>function(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}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?ie(e,o):re(e,o),fromBytes:e=>{if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);return n?ne(e):te(e)}});return Object.freeze(a)}function qt(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 Ct(e){const t=qt(e);return t+Math.ceil(t/2)}const Dt=BigInt(0),Vt=BigInt(1);function Mt(e,t){const n=t.negate();return e?n:t}function _t(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Kt(e,t){return _t(e,t),{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}}const Zt=new WeakMap,Gt=new WeakMap;function Wt(e){return Gt.get(e)||1}function Yt(e){return we(e.Fp,$t.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),we(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ft(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function Xt(e){void 0!==e.lowS&&G("lowS",e.lowS),void 0!==e.prehash&&G("prehash",e.prehash)}const{bytesToNumberBE:Jt,hexToBytes:Qt}=be,en={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(e,t)=>{const{Err:n}=en;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,i=X(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?X(i.length/2|128):"";return X(e)+o+i+t},decode(e,t){const{Err:n}=en;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const i=t[r++];let o=0;if(128&i){const e=127&i;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(r,r+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of s)o=o<<8|e;if(r+=e,o<128)throw new n("tlv.decode(long): not minimal encoding")}else o=i;const s=t.subarray(r,r+o);if(s.length!==o)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){const{Err:t}=en;if(e<tn)throw new t("integer: negative integers are not allowed");let n=X(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=en;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 Jt(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=en,i="string"==typeof e?Qt(e):e;Z(i);const{v:o,l:s}=r.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,o),{v:u,l:f}=r.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=en,r=t.encode(2,n.encode(e.r)),i=t.encode(2,n.encode(e.s));return t.encode(48,r+i)}},tn=BigInt(0),nn=BigInt(1);BigInt(2);const rn=BigInt(3);function on(e){return{hash:e,hmac:(t,...n)=>At(e,t,function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];ct(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)),randomBytes:wt}}BigInt(4);const sn=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),an=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),cn=BigInt(1),un=BigInt(2),fn=(e,t)=>(e+t/un)/t,ln=jt(sn,void 0,void 0,{sqrt:function(e){const t=sn,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,f=u*u*e%t,l=Ht(f,n,t)*f%t,h=Ht(l,n,t)*f%t,d=Ht(h,un,t)*u%t,g=Ht(d,i,t)*d%t,p=Ht(g,o,t)*g%t,w=Ht(p,a,t)*p%t,y=Ht(w,c,t)*w%t,b=Ht(y,a,t)*p%t,m=Ht(b,n,t)*f%t,E=Ht(m,s,t)*g%t,v=Ht(E,r,t)*u%t,x=Ht(v,un,t);if(!ln.eql(ln.sqr(x),e))throw new Error("Cannot find square root");return x}}),hn=function(e){const t=t=>function(e){const t=function(e){const t=Yt(e);return we(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r}=t,i=n.BYTES+1,o=2*n.BYTES+1;function s(e){return kt(e,r)}function a(e){return Tt(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:l}=function(e){const t=function(e){const t=Yt(e);we(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=t;if(n){if(!r.eql(i,r.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,r=jt(t.n,t.nBitLength),i=t.toBytes||((e,t,r)=>{const i=t.toAffine();return se(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),o=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 s(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),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:o}=t;if(n&&"bigint"!=typeof e){if(K(e)&&(e=Y(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*r,"0")}let s;try{s="bigint"==typeof e?e:te(oe("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return i&&(s=kt(s,o)),ue("private key",s,nn,o),s}function c(e){if(!(e instanceof l))throw new Error("ProjectivePoint expected")}const u=ye((e,t)=>{const{px:r,py:i,pz:o}=e;if(n.eql(o,n.ONE))return{x:r,y:i};const s=e.is0();null==t&&(t=s?n.ONE:n.inv(o));const a=n.mul(r,t),c=n.mul(i,t),u=n.mul(o,t);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),f=ye(e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:r,y:i}=e.toAffine();if(!n.isValid(r)||!n.isValid(i))throw new Error("bad point: x or y not FE");const o=n.sqr(i),a=s(r);if(!n.eql(o,a))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class l{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");Object.freeze(this)}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 l)throw new Error("projective point not allowed");const i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?l.ZERO:new l(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(l.fromAffine)}static fromHex(e){const t=l.fromAffine(o(oe("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return l.BASE.multiply(a(e))}static msm(e,t){return function(e,t,n,r){if(function(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)})}(n,e),function(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)})}(r,t),n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=e.ZERO,o=fe(BigInt(n.length)),s=o>12?o-3:o>4?o-2:o?2:1,a=(1<<s)-1,c=new Array(a+1).fill(i);let u=i;for(let e=Math.floor((t.BITS-1)/s)*s;e>=0;e-=s){c.fill(i);for(let t=0;t<r.length;t++){const i=Number(r[t]>>BigInt(e)&BigInt(a));c[i]=c[i].add(n[t])}let t=i;for(let e=c.length-1,n=i;e>0;e--)n=n.add(c[e]),t=t.add(n);if(u=u.add(t),0!==e)for(let e=0;e<s;e++)u=u.double()}return u}(l,r,e,t)}_setWindowSize(e){d.setWindowSize(this,e)}assertValidity(){f(this)}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){c(e);const{px:t,py:r,pz:i}=this,{px:o,py:s,pz:a}=e,u=n.eql(n.mul(t,a),n.mul(o,i)),f=n.eql(n.mul(r,a),n.mul(s,i));return u&&f}negate(){return new l(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,i=n.mul(r,rn),{px:o,py:s,pz:a}=this;let c=n.ZERO,u=n.ZERO,f=n.ZERO,h=n.mul(o,o),d=n.mul(s,s),g=n.mul(a,a),p=n.mul(o,s);return p=n.add(p,p),f=n.mul(o,a),f=n.add(f,f),c=n.mul(e,f),u=n.mul(i,g),u=n.add(c,u),c=n.sub(d,u),u=n.add(d,u),u=n.mul(c,u),c=n.mul(p,c),f=n.mul(i,f),g=n.mul(e,g),p=n.sub(h,g),p=n.mul(e,p),p=n.add(p,f),f=n.add(h,h),h=n.add(f,h),h=n.add(h,g),h=n.mul(h,p),u=n.add(u,h),g=n.mul(s,a),g=n.add(g,g),h=n.mul(g,p),c=n.sub(c,h),f=n.mul(g,d),f=n.add(f,f),f=n.add(f,f),new l(c,u,f)}add(e){c(e);const{px:r,py:i,pz:o}=this,{px:s,py:a,pz:u}=e;let f=n.ZERO,h=n.ZERO,d=n.ZERO;const g=t.a,p=n.mul(t.b,rn);let w=n.mul(r,s),y=n.mul(i,a),b=n.mul(o,u),m=n.add(r,i),E=n.add(s,a);m=n.mul(m,E),E=n.add(w,y),m=n.sub(m,E),E=n.add(r,o);let v=n.add(s,u);return E=n.mul(E,v),v=n.add(w,b),E=n.sub(E,v),v=n.add(i,o),f=n.add(a,u),v=n.mul(v,f),f=n.add(y,b),v=n.sub(v,f),d=n.mul(g,E),f=n.mul(p,b),d=n.add(f,d),f=n.sub(y,d),d=n.add(y,d),h=n.mul(f,d),y=n.add(w,w),y=n.add(y,w),b=n.mul(g,b),E=n.mul(p,E),y=n.add(y,b),b=n.sub(w,b),b=n.mul(g,b),E=n.add(E,b),w=n.mul(y,E),h=n.add(h,w),w=n.mul(v,E),f=n.mul(m,f),f=n.sub(f,w),w=n.mul(m,y),d=n.mul(v,d),d=n.add(d,w),new l(f,h,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(l.ZERO)}wNAF(e){return d.wNAFCached(this,e,l.normalizeZ)}multiplyUnsafe(e){const{endo:r,n:i}=t;ue("scalar",e,tn,i);const o=l.ZERO;if(e===tn)return o;if(this.is0()||e===nn)return this;if(!r||d.hasPrecomputes(this))return d.wNAFCachedUnsafe(this,e,l.normalizeZ);let{k1neg:s,k1:a,k2neg:c,k2:u}=r.splitScalar(e),f=o,h=o,g=this;for(;a>tn||u>tn;)a&nn&&(f=f.add(g)),u&nn&&(h=h.add(g)),g=g.double(),a>>=nn,u>>=nn;return s&&(f=f.negate()),c&&(h=h.negate()),h=new l(n.mul(h.px,r.beta),h.py,h.pz),f.add(h)}multiply(e){const{endo:r,n:i}=t;let o,s;if(ue("scalar",e,nn,i),r){const{k1neg:t,k1:i,k2neg:a,k2:c}=r.splitScalar(e);let{p:u,f}=this.wNAF(i),{p:h,f:g}=this.wNAF(c);u=d.constTimeNegate(t,u),h=d.constTimeNegate(a,h),h=new l(n.mul(h.px,r.beta),h.py,h.pz),o=u.add(h),s=f.add(g)}else{const{p:t,f:n}=this.wNAF(e);o=t,s=n}return l.normalizeZ([o,s])[0]}multiplyAndAddUnsafe(e,t,n){const r=l.BASE,i=(e,t)=>t!==tn&&t!==nn&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,n));return o.is0()?void 0:o}toAffine(e){return u(this,e)}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===nn)return!0;if(n)return n(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===nn?this:n?n(l,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return G("isCompressed",e),this.assertValidity(),i(l,this,e)}toHex(e=!0){return G("isCompressed",e),Y(this.toRawBytes(e))}}l.BASE=new l(t.Gx,t.Gy,n.ONE),l.ZERO=new l(n.ZERO,n.ONE,n.ZERO);const h=t.nBitLength,d=(g=l,p=t.endo?Math.ceil(h/2):h,{constTimeNegate:Mt,hasPrecomputes:e=>1!==Wt(e),unsafeLadder(e,t,n=g.ZERO){let r=e;for(;t>Dt;)t&Vt&&(n=n.add(r)),r=r.double(),t>>=Vt;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=Kt(t,p),i=[];let o=e,s=o;for(let e=0;e<n;e++){s=o,i.push(s);for(let e=1;e<r;e++)s=s.add(o),i.push(s);o=s.double()}return i},wNAF(e,t,n){const{windows:r,windowSize:i}=Kt(e,p);let o=g.ZERO,s=g.BASE;const a=BigInt(2**e-1),c=2**e,u=BigInt(e);for(let e=0;e<r;e++){const r=e*i;let f=Number(n&a);n>>=u,f>i&&(f-=c,n+=Vt);const l=r,h=r+Math.abs(f)-1,d=f<0;0===f?s=s.add(Mt(e%2!=0,t[l])):o=o.add(Mt(d,t[h]))}return{p:o,f:s}},wNAFUnsafe(e,t,n,r=g.ZERO){const{windows:i,windowSize:o}=Kt(e,p),s=BigInt(2**e-1),a=2**e,c=BigInt(e);for(let e=0;e<i;e++){const i=e*o;if(n===Dt)break;let u=Number(n&s);if(n>>=c,u>o&&(u-=a,n+=Vt),0===u)continue;let f=t[i+Math.abs(u)-1];u<0&&(f=f.negate()),r=r.add(f)}return r},getPrecomputes(e,t,n){let r=Zt.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&Zt.set(t,n(r))),r},wNAFCached(e,t,n){const r=Wt(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const i=Wt(e);return 1===i?this.unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)},setWindowSize(e,t){_t(t,p),Gt.set(e,t),Zt.delete(e)}});var g,p;return{CURVE:t,ProjectivePoint:l,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:function(e){return ce(e,nn,t.n)}}}({...t,toBytes(e,t,r){const i=t.toAffine(),o=n.toBytes(i.x),s=se;return G("isCompressed",r),r?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,n.toBytes(i.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==i||2!==r&&3!==r){if(t===o&&4===r)return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))};throw new Error("invalid Point, expected length of "+i+", or uncompressed "+o+", got "+t)}{const e=te(s);if(!ce(e,nn,n.ORDER))throw new Error("Point is not on curve");const t=f(e);let i;try{i=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~r)!=((i&nn)===nn)&&(i=n.neg(i)),{x:e,y:i}}}}),h=e=>Y(re(e,t.nByteLength));function d(e){return e>r>>nn}const g=(e,t,n)=>te(e.slice(t,n));class p{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=oe("compactSignature",e,2*n),new p(g(e,0,n),g(e,n,2*n))}static fromDER(e){const{r:t,s:n}=en.toSig(oe("DER",e));return new p(t,n)}assertValidity(){ue("r",this.r,nn,r),ue("s",this.s,nn,r)}addRecoveryBit(e){return new p(this.r,this.s,e)}recoverPublicKey(e){const{r,s:i,recovery:o}=this,u=m(oe("msgHash",e));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const f=2===o||3===o?r+t.n:r;if(f>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=c.fromHex((1&o?"03":"02")+h(f)),d=a(f),g=s(-u*d),p=s(i*d),w=c.BASE.multiplyAndAddUnsafe(l,g,p);if(!w)throw new Error("point at infinify");return w.assertValidity(),w}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return ee(this.toDERHex())}toDERHex(){return en.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ee(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const w={isValidPrivateKey(e){try{return u(e),!0}catch(e){return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const e=Ct(t.n);return function(e,t,n=!1){const r=e.length,i=qt(t),o=Ct(t);if(r<16||r<o||r>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const s=kt(n?te(e):ne(e),t-Ot)+Ot;return n?ie(s,i):re(s,i)}(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function y(e){const t=K(e),n="string"==typeof e,r=(t||n)&&e.length;return t?r===i||r===o:n?r===2*i||r===2*o:e instanceof c}const b=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const n=te(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},m=t.bits2int_modN||function(e){return s(b(e))},E=le(t.nBitLength);function v(e){return ue("num < 2^"+t.nBitLength,e,tn,E),re(e,t.nByteLength)}const x={lowS:t.lowS,prehash:!1},B={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(y(e))throw new Error("first arg must be private key");if(!y(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(u(e)).toRawBytes(n)},sign:function(e,r,i=x){const{seed:o,k2sig:f}=function(e,r,i=x){if(["recovered","canonical"].some(e=>e in i))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:f}=t;let{lowS:h,prehash:g,extraEntropy:w}=i;null==h&&(h=!0),e=oe("msgHash",e),Xt(i),g&&(e=oe("prehashed msgHash",o(e)));const y=m(e),E=u(r),B=[v(E),v(y)];if(null!=w&&!1!==w){const e=!0===w?f(n.BYTES):w;B.push(oe("extraEntropy",e))}const I=se(...B),A=y;return{seed:I,k2sig:function(e){const t=b(e);if(!l(t))return;const n=a(t),r=c.BASE.multiply(t).toAffine(),i=s(r.x);if(i===tn)return;const o=s(n*s(A+i*E));if(o===tn)return;let u=(r.x===i?0:2)|Number(r.y&nn),f=o;return h&&d(o)&&(f=function(e){return d(e)?s(-e):e}(o),u^=1),new p(i,f,u)}}}(e,r,i);return ge(t.hash.outputLen,t.nByteLength,t.hmac)(o,f)},verify:function(e,n,r,i=B){const o=e;n=oe("msgHash",n),r=oe("publicKey",r);const{lowS:u,prehash:f,format:l}=i;if(Xt(i),"strict"in i)throw new Error("options.strict was renamed to lowS");if(void 0!==l&&"compact"!==l&&"der"!==l)throw new Error("format must be compact or der");const h="string"==typeof o||K(o),d=!h&&!l&&"object"==typeof o&&null!==o&&"bigint"==typeof o.r&&"bigint"==typeof o.s;if(!h&&!d)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let g,w;try{if(d&&(g=new p(o.r,o.s)),h){try{"compact"!==l&&(g=p.fromDER(o))}catch(e){if(!(e instanceof en.Err))throw e}g||"der"===l||(g=p.fromCompact(o))}w=c.fromHex(r)}catch(e){return!1}if(!g)return!1;if(u&&g.hasHighS())return!1;f&&(n=t.hash(n));const{r:y,s:b}=g,E=m(n),v=a(b),x=s(E*v),I=s(y*v),A=c.BASE.multiplyAndAddUnsafe(w,x,I)?.toAffine();return!!A&&s(A.x)===y},ProjectivePoint:c,Signature:p,utils:w}}({...e,...on(t)});return Object.freeze({...t(Bt),create:t})}({a:BigInt(0),b:BigInt(7),Fp:ln,n:an,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=an,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-cn*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=fn(o*e,t),c=fn(-r*e,t);let u=kt(e-a*n-c*i,t),f=kt(-a*r-c*o,t);const l=u>s,h=f>s;if(l&&(u=t-u),h&&(f=t-f),u>s||f>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:u,k2neg:h,k2:f}}}});function dn(e){if(130!==e.length&&132!==e.length)throw new gn({signature:e});const t=BigInt(Ne(e,0,32)),n=BigInt(Ne(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return function(e){if(0===e||27===e)return 0;if(1===e||28===e)return 1;if(e>=35)return e%2==0?1:0;throw new wn({value:e})}(t)}catch{throw new pn({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}BigInt(0);class gn extends p{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${ke(Oe(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class pn extends p{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class wn extends p{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function yn(e,t,n){try{const r=_e(function(e){const t=Oe(e);return Se("0x19",Le("Ethereum Signed Message:\n"+ke(t)),t)}(Le(t))),i=function(e){const{payload:t,signature:n}=e,{r,s:i,yParity:o}=n;return function(e){const t=(()=>{if(function(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new He(e);if("string"!=typeof e)throw new He(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new Te(e);if(!e.startsWith("0x"))throw new Te(e)}(e,{strict:n}),!0}catch{return!1}}(e))return We(e);if(function(e){try{return function(e){if(!(e instanceof Uint8Array)){if(!e)throw new De(e);if("object"!=typeof e)throw new De(e);if(!("BYTES_PER_ELEMENT"in e))throw new De(e);if(1!==e.BYTES_PER_ELEMENT||"Uint8Array"!==e.constructor.name)throw new De(e)}}(e),!0}catch{return!1}}(e))return function(e){return We(Pe(e))}(e);const{prefix:t,x:n,y:r}=e;return"bigint"==typeof n&&"bigint"==typeof r?{prefix:t??4,x:n,y:r}:{prefix:t,x:n}})();return Ge(t),t}(new hn.Signature(BigInt(r),BigInt(i)).addRecoveryBit(o).recoverPublicKey(Oe(t).substring(2)))}({payload:r,signature:dn(n)});return function(e,t={}){const n=_e(`0x${function(e,t={}){Ge(e);const{prefix:n,x:r,y:i}=e,{includePrefix:o=!0}=t;return Se(o?ze(n,{size:1}):"0x",ze(r,{size:32}),"bigint"==typeof i?ze(i,{size:32}):"0x")}(e).slice(4)}`).substring(26);return function(e,t={}){const{checksum:n=!1}=t;return nt(e),n?rt(e):e}(`0x${n}`,t)}(i).toString()===e.toString()}catch(e){return!1}}async function bn(n){switch(n.type){case t.SelfDeclaration:return l({},n,{status:n.confirmed?e.VERIFIED:e.FAILED});case t.Screenshot:return l({},n,{status:n.url?e.FLAGGED:e.FAILED});case t.EIP191:return async function(t){const[n,r,i]=t.address.split(/:/);return l({},t,"eip155"!==n?{status:e.FAILED}:{status:yn(i,t.attestation,t.proof)?e.VERIFIED:e.FAILED})}(n);case t.ED25519:return async function(t){const[n,r,i]=t.address.split(/:/);if("solana"!==n)return l({},t,{status:e.FAILED});try{const n=f.decode(i),r=(new TextEncoder).encode(t.attestation),o=c(t.proof);return l({},t,{status:u.sign.detached.verify(r,o,n)?e.VERIFIED:e.FAILED})}catch(n){return l({},t,{status:e.FAILED})}}(n);case t.EIP712:case t.BIP137:return async function(t){const[n,u,f]=t.address.split(/:/);if("bip122"!==n)return l({},t,{status:e.FAILED});try{const n=[d.SEGWIT,d.NATIVE].includes(function(e){if(e.match("^(bc1|tb1|ltc1).*"))return d.NATIVE;if(e.match("^[32M].*"))return d.SEGWIT;if(e.match("^[1nmL].*"))return d.LEGACY;if(e.match("^(D).*"))return d.DOGECOIN;throw new Error("INVALID ADDRESS: ".concat(e).concat(" is not a valid or a supported address"))}(f)),u=function(e,t,n,u){const{compressed:f,segwitType:l,recovery:d,signature:p}=function(e){const t=c(e);if(65!==t.length)throw new Error("Invalid signature length");const n=t[0]-27;if(n>15||n<0)throw new Error("Invalid signature parameter");return{compressed:!!(12&n),segwitType:8&n?4&n?h.P2WPKH:h.P2SH_P2WPKH:void 0,recovery:3&n,signature:t.slice(1)}}(n);if(u&&!f)throw new Error("checkSegwitAlways can only be used with a compressed pubkey signature flagbyte");const w=function(e){const t=(new TextEncoder).encode("Bitcoin Signed Message:\n"),n=(new TextEncoder).encode(e),r=a(n.length).buffer,i=new Uint8Array(t.length+r.byteLength+n.length);return i.set(t),i.set(new Uint8Array(r),t.length),i.set(n,t.length+r.byteLength),s(i)}(e),y=f?r.recoverPublicKeyCompressed(p,d,w):r.recoverPublicKeyUncompressed(p,d,w);if("string"==typeof y)throw new Error(y);const b=i(y);let m="";if(l)m=g(b);else if(u)try{m=g(b)}catch(e){m=g(b)}else m=o(0,b);return m===t}(t.attestation,f,t.proof,n);return l({},t,{status:u?e.VERIFIED:e.FAILED})}catch(n){return l({},t,{status:e.FAILED})}}(n)}return n}export{bn as verifyProof};
|
1
|
+
import{ProofStatus as t,ProofTypes as e}from"@notabene/javascript-sdk";import{bech32 as r}from"bech32";import{secp256k1 as n,hash160 as o,encodeBase58AddressFormat as s,hash256 as c}from"@bitauth/libauth";import{encode as i}from"varuint-bitcoin";import{decode as a}from"@stablelib/base64";import{PersonalMessage as u,Hex as f,Signature as E,Secp256k1 as l,Address as p}from"ox";import h from"tweetnacl";import d from"bs58";function g(){return g=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},g.apply(null,arguments)}var I,m;function y(t){const e=r.toWords(t);return e.unshift(0),r.encode("bc",e)}async function b(r){switch(r.type){case e.SelfDeclaration:return g({},r,{status:r.confirmed?t.VERIFIED:t.FAILED});case e.Screenshot:return g({},r,{status:r.url?t.FLAGGED:t.FAILED});case e.EIP191:return async function(e){const[r,n,o]=e.address.split(/:/);if("eip155"!==r)return g({},e,{status:t.FAILED});const s=function(t,e,r){try{const n=u.getSignPayload(f.fromString(e)),o=E.fromHex(r),s=l.recoverPublicKey({payload:n,signature:o});return p.fromPublicKey(s).toString()===t.toString()}catch(t){return!1}}(o,e.attestation,e.proof);return g({},e,{status:s?t.VERIFIED:t.FAILED})}(r);case e.ED25519:return async function(e){const[r,n,o]=e.address.split(/:/);if("solana"!==r)return g({},e,{status:t.FAILED});try{const r=d.decode(o),n=(new TextEncoder).encode(e.attestation),s=a(e.proof);return g({},e,{status:h.sign.detached.verify(n,s,r)?t.VERIFIED:t.FAILED})}catch(r){return g({},e,{status:t.FAILED})}}(r);case e.EIP712:case e.BIP137:return async function(e){const[r,u,f]=e.address.split(/:/);if("bip122"!==r)return g({},e,{status:t.FAILED});try{const r=[m.SEGWIT,m.NATIVE].includes(function(t){if(t.match("^(bc1|tb1|ltc1).*"))return m.NATIVE;if(t.match("^[32M].*"))return m.SEGWIT;if(t.match("^[1nmL].*"))return m.LEGACY;if(t.match("^(D).*"))return m.DOGECOIN;throw new Error("INVALID ADDRESS: ".concat(t).concat(" is not a valid or a supported address"))}(f)),u=function(t,e,r,u){const{compressed:f,segwitType:E,recovery:l,signature:p}=function(t){const e=a(t);if(65!==e.length)throw new Error("Invalid signature length");const r=e[0]-27;if(r>15||r<0)throw new Error("Invalid signature parameter");return{compressed:!!(12&r),segwitType:8&r?4&r?I.P2WPKH:I.P2SH_P2WPKH:void 0,recovery:3&r,signature:e.slice(1)}}(r);if(u&&!f)throw new Error("checkSegwitAlways can only be used with a compressed pubkey signature flagbyte");const h=function(t){const e=(new TextEncoder).encode("Bitcoin Signed Message:\n"),r=(new TextEncoder).encode(t),n=i(r.length).buffer,o=new Uint8Array(e.length+n.byteLength+r.length);return o.set(e),o.set(new Uint8Array(n),e.length),o.set(r,e.length+n.byteLength),c(o)}(t),d=f?n.recoverPublicKeyCompressed(p,l,h):n.recoverPublicKeyUncompressed(p,l,h);if("string"==typeof d)throw new Error(d);const g=o(d);let m="";if(E)m=y(g);else if(u)try{m=y(g)}catch(t){m=y(g)}else m=s(0,g);return m===e}(e.attestation,f,e.proof,r);return g({},e,{status:u?t.VERIFIED:t.FAILED})}catch(r){return g({},e,{status:t.FAILED})}}(r)}return r}!function(t){t.P2WPKH="p2wpkh",t.P2SH_P2WPKH="p2sh(p2wpkh)"}(I||(I={})),function(t){t.LEGACY="Legacy",t.NATIVE="Native SegWit",t.SEGWIT="SegWit",t.P2SH_SEGWIT="p2sh",t.BCH="Bitcoin Cash",t.ETHEREUM="Ethereum",t.DOGECOIN="Dogecoin",t.UNKNOWN="Unknown"}(m||(m={}));export{b as verifyProof};
|
2
2
|
//# sourceMappingURL=index.modern.js.map
|