@notabene/verify-proof 1.8.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{ProofStatus as e,ProofTypes as t}from"@notabene/javascript-sdk";import{encode as r}from"varuint-bitcoin";import n,{createBase58check as s,bech32 as o,base64 as i,base58 as c}from"@scure/base";import{Hash as a,PersonalMessage as u,Hex as d,Signature as f,Secp256k1 as h,Address as l,PublicKey as p,Bytes as y}from"ox";import b,{secp256k1 as g}from"@noble/curves/secp256k1";import{Verifier as A}from"bip322-js";import m from"tweetnacl";import _ from"@cardano-foundation/cardano-verify-datasignature";import{Client as x}from"xrpl";import E from"@noble/curves/abstract/utils";import w from"@noble/curves/ed25519";import{Keypair as H}from"@stellar/stellar-sdk";function I(){return I=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},I.apply(null,arguments)}var v;!function(e){e.P2WPKH="p2wpkh",e.P2SH_P2WPKH="p2sh(p2wpkh)"}(v||(v={}));const S={bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc",isTestnet:!1},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc",isTestnet:!1},litecoin:{messagePrefix:"Litecoin Signed Message:\n",pubKeyHashVersion:48,scriptHashVersion:50,bech32Prefix:"ltc",isTestnet:!1},dogecoin:{messagePrefix:"Dogecoin Signed Message:\n",pubKeyHashVersion:30,scriptHashVersion:22,isTestnet:!1},dash:{messagePrefix:"DarkCoin Signed Message:\n",pubKeyHashVersion:76,scriptHashVersion:16,isTestnet:!1},zcash:{messagePrefix:"Zcash Signed Message:\n",pubKeyHashVersion:Uint8Array.from([28,184]),scriptHashVersion:Uint8Array.from([28,189]),isTestnet:!1},testnet:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:111,scriptHashVersion:196,bech32Prefix:"tb",isTestnet:!0}};var D;function P(t,r){const{attestation:n,proof:s}=r;return I({},r,{status:A.verifySignature(t,n,s)?e.VERIFIED:e.FAILED})}function L(t,n,s){const o=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;if(e.match("^(q).*"))return D.BCH;if(e.match("^(t1|t3).*"))return D.LEGACY;if(e.match("^[X7].*"))return D.LEGACY;throw new Error("INVALID ADDRESS: ".concat(e).concat(" is not a valid or a supported address"))}(t),c=Boolean(s.bech32Prefix&&(o===D.NATIVE||o===D.SEGWIT&&!t.startsWith("1"))),u=function(e,t,n,s,o){const{compressed:c,segwitType:u,signature:d}=function(e){const t=i.decode(e);if(65!==t.length)throw new Error("Invalid signature length");const r=t[0]-27;if(r>15||r<0)throw new Error("Invalid signature parameter");const n=!!(12&r),s=3&r,o=g.Signature.fromCompact(t.slice(1));return{compressed:n,segwitType:8&r?4&r?v.P2WPKH:v.P2SH_P2WPKH:void 0,signature:o.addRecoveryBit(s)}}(n);if(s&&!c)throw new Error("checkSegwitAlways can only be used with a compressed pubkey signature flagbyte");const f=function(e,t){const n=(new TextEncoder).encode(t),s=(new TextEncoder).encode(e),o=r(s.length).buffer,i=new Uint8Array(n.length+o.byteLength+s.length);return i.set(n),i.set(new Uint8Array(o),n.length),i.set(s,n.length+o.byteLength),function(e){return a.sha256(a.sha256(e))}(i)}(e,o.messagePrefix),h=C(d.recoverPublicKey(f).toRawBytes(c));let l="";if(t.startsWith("q"))return l=V(o.pubKeyHashVersion,h),l.startsWith("1");if(u)l=u===v.P2SH_P2WPKH?V(o.scriptHashVersion,h):o.bech32Prefix?U(h,o.bech32Prefix):V(o.scriptHashVersion,h);else if(t.startsWith("3")&&!u){const e=new Uint8Array(22);e[0]=0,e[1]=20,e.set(h,2);const r=C(e),n=V(o.scriptHashVersion,r),s=V(o.scriptHashVersion,h);if(t===n||t===s)return!0;l=s}else if(s&&o.bech32Prefix)try{l=U(h,o.bech32Prefix)}catch(e){l=V(o.scriptHashVersion,h)}else l=V(o.pubKeyHashVersion,h);return l===t}(n.attestation,t,n.proof,c,s);return I({},n,{status:u?e.VERIFIED:e.FAILED})}!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={}));const B=s(a.sha256);function V(e,t){const r="number"==typeof e?Uint8Array.of(e):e,n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),B.encode(n)}function U(e,t="bc"){const r=o.toWords(e);return r.unshift(0),o.encode(t,r)}function C(e){return a.ripemd160(a.sha256(e))}function k(e,t){const r=[];let n=t;for(;n<e.length&&null!=(s=e[n])&&s.startsWith("- ");){var s;r.push(e[n].substring(2)),n++}return r}function F(e,t,r){try{const s=(n=d.fromString(t),a.keccak256(function(e){const t=d.from(e);return d.concat("0x19",d.fromString("TRON Signed Message:\n"+d.size(t)),t)}(n))),o=f.fromHex(r),i=h.recoverPublicKey({payload:s,signature:o}),u=`0x41${a.keccak256(`0x${p.toHex(i).slice(4)}`).substring(26)}`,l=y.from(u),b=y.from(a.sha256(a.sha256(u))).slice(0,4),g=y.concat(l,b);return c.encode(g)===e}catch(e){return!1}var n}var T="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function O(e){var t={exports:{}};return e(t,t.exports),t.exports}var K=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0}),M=O(function(e,t){function r(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function n(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function s(e,...t){if(!r(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function o(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function i(e){for(let t=0;t<e.length;t++)e[t]=o(e[t]);return e}Object.defineProperty(t,"__esModule",{value:!0}),t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.Hash=t.nextTick=t.swap32IfBE=t.byteSwapIfBE=t.swap8IfBE=t.isLE=void 0,t.isBytes=r,t.anumber=n,t.abytes=s,t.ahash=function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");n(e.outputLen),n(e.blockLen)},t.aexists=function(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")},t.aoutput=function(e,t){s(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)},t.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.createView=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)},t.rotr=function(e,t){return e<<32-t|e>>>t},t.rotl=function(e,t){return e<<t|e>>>32-t>>>0},t.byteSwap=o,t.byteSwap32=i,t.bytesToHex=function(e){if(s(e),c)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=a[e[r]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(c)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,s=0;t<r;t++,s+=2){const r=d(e.charCodeAt(s)),o=d(e.charCodeAt(s+1));if(void 0===r||void 0===o)throw new Error('hex string expected, got non-hex character "'+(e[s]+e[s+1])+'" at index '+s);n[t]=16*r+o}return n},t.asyncLoop=async function(e,r,n){let s=Date.now();for(let o=0;o<e;o++){n(o);const e=Date.now()-s;e>=0&&e<r||(await(0,t.nextTick)(),s+=e)}},t.utf8ToBytes=f,t.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},t.toBytes=h,t.kdfInputToBytes=function(e){return"string"==typeof e&&(e=f(e)),s(e),e},t.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];s(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const s=e[t];r.set(s,n),n+=s.length}return r},t.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("options should be object or undefined");return Object.assign(e,t)},t.createHasher=l,t.createOptHasher=p,t.createXOFer=y,t.randomBytes=function(e=32){if(K.crypto&&"function"==typeof K.crypto.getRandomValues)return K.crypto.getRandomValues(new Uint8Array(e));if(K.crypto&&"function"==typeof K.crypto.randomBytes)return Uint8Array.from(K.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")},t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],t.swap8IfBE=t.isLE?e=>e:e=>o(e),t.byteSwapIfBE=t.swap8IfBE,t.swap32IfBE=t.isLE?e=>e:i;const c=/* @__PURE__ */(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),a=/* @__PURE__ */Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),u={_0:48,_9:57,A:65,F:70,a:97,f:102};function d(e){return e>=u._0&&e<=u._9?e-u._0:e>=u.A&&e<=u.F?e-(u.A-10):e>=u.a&&e<=u.f?e-(u.a-10):void 0}function f(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function h(e){return"string"==typeof e&&(e=f(e)),s(e),e}function l(e){const t=t=>e().update(h(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function p(e){const t=(t,r)=>e(r).update(h(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}function y(e){const t=(t,r)=>e(r).update(h(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}t.nextTick=async()=>{},t.Hash=class{},t.wrapConstructor=l,t.wrapConstructorWithOpts=p,t.wrapXOFConstructorWithOpts=y}),j=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.equal=t.concat=t.HEX_REGEX=void 0,t.HEX_REGEX=/^[A-F0-9]*$/iu,t.concat=function(e){return(0,M.concatBytes)(...e)},t.equal=function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Int8Array(e),n=new Int8Array(t);for(let t=0;t!==e.byteLength;t++)if(r[t]!==n[t])return!1;return!0}}),N=O(function(e,t){var r=T&&T.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=T&&T.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.randomBytes=t.stringToHex=t.hexToString=t.hexToBytes=t.bytesToHex=void 0,t.bytesToHex=e=>(0,M.bytesToHex)(e instanceof Uint8Array?e:Uint8Array.from(e)).toUpperCase(),t.hexToBytes=e=>{const t=new Uint8Array(e.length/2);if(!j.HEX_REGEX.test(e))throw new Error("Invalid hex string");for(let r=0;r<t.length;r++){const n=2*r,s=e.slice(n,n+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t},t.hexToString=(e,r="utf8")=>new TextDecoder(r).decode((0,t.hexToBytes)(e)),t.stringToHex=e=>(0,t.bytesToHex)((new TextEncoder).encode(e)),t.randomBytes=M.randomBytes,n(j,t)}),R=O(function(e,t){function r(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const s=BigInt(32),o=BigInt(4294967295),i=Number(r>>s&o),c=Number(r&o),a=n?0:4;e.setUint32(t+(n?4:0),i,n),e.setUint32(t+a,c,n)}Object.defineProperty(t,"__esModule",{value:!0}),t.SHA512_IV=t.SHA384_IV=t.SHA224_IV=t.SHA256_IV=t.HashMD=void 0,t.setBigUint64=r,t.Chi=function(e,t,r){return e&t^~e&r},t.Maj=function(e,t,r){return e&t^e&r^t&r},t.HashMD=class extends M.Hash{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=(0,M.createView)(this.buffer)}update(e){(0,M.aexists)(this),e=(0,M.toBytes)(e),(0,M.abytes)(e);const{view:t,buffer:r,blockLen:n}=this,s=e.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);if(i===n){const t=(0,M.createView)(e);for(;n<=s-o;o+=n)this.process(t,o);continue}r.set(e.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,M.aexists)(this),(0,M.aoutput)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:o}=this;let{pos:i}=this;t[i++]=128,(0,M.clean)(this.buffer.subarray(i)),this.padOffset>s-i&&(this.process(n,0),i=0);for(let e=i;e<s;e++)t[e]=0;r(n,s-8,BigInt(8*this.length),o),this.process(n,0);const c=(0,M.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,d=this.get();if(u>d.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)c.setUint32(4*e,d[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:s,destroyed:o,pos:i}=this;return e.destroyed=o,e.finished=s,e.length=n,e.pos=i,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}},t.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),t.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),t.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),t.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])}),W=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.toBig=t.shrSL=t.shrSH=t.rotrSL=t.rotrSH=t.rotrBL=t.rotrBH=t.rotr32L=t.rotr32H=t.rotlSL=t.rotlSH=t.rotlBL=t.rotlBH=t.add5L=t.add5H=t.add4L=t.add4H=t.add3L=t.add3H=void 0,t.add=m,t.fromBig=s,t.split=o;const r=/* @__PURE__ */BigInt(2**32-1),n=/* @__PURE__ */BigInt(32);function s(e,t=!1){return t?{h:Number(e&r),l:Number(e>>n&r)}:{h:0|Number(e>>n&r),l:0|Number(e&r)}}function o(e,t=!1){const r=e.length;let n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){const{h:r,l:c}=s(e[i],t);[n[i],o[i]]=[r,c]}return[n,o]}const i=(e,t)=>BigInt(e>>>0)<<n|BigInt(t>>>0);t.toBig=i;const c=(e,t,r)=>e>>>r;t.shrSH=c;const a=(e,t,r)=>e<<32-r|t>>>r;t.shrSL=a;const u=(e,t,r)=>e>>>r|t<<32-r;t.rotrSH=u;const d=(e,t,r)=>e<<32-r|t>>>r;t.rotrSL=d;const f=(e,t,r)=>e<<64-r|t>>>r-32;t.rotrBH=f;const h=(e,t,r)=>e>>>r-32|t<<64-r;t.rotrBL=h;const l=(e,t)=>t;t.rotr32H=l;const p=(e,t)=>e;t.rotr32L=p;const y=(e,t,r)=>e<<r|t>>>32-r;t.rotlSH=y;const b=(e,t,r)=>t<<r|e>>>32-r;t.rotlSL=b;const g=(e,t,r)=>t<<r-32|e>>>64-r;t.rotlBH=g;const A=(e,t,r)=>e<<r-32|t>>>64-r;function m(e,t,r,n){const s=(t>>>0)+(n>>>0);return{h:e+r+(s/2**32|0)|0,l:0|s}}t.rotlBL=A;const _=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);t.add3L=_;const x=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;t.add3H=x;const E=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);t.add4L=E;const w=(e,t,r,n,s)=>t+r+n+s+(e/2**32|0)|0;t.add4H=w;const H=(e,t,r,n,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(s>>>0);t.add5L=H;const I=(e,t,r,n,s,o)=>t+r+n+s+o+(e/2**32|0)|0;t.add5H=I,t.default={fromBig:s,split:o,toBig:i,shrSH:c,shrSL:a,rotrSH:u,rotrSL:d,rotrBH:f,rotrBL:h,rotr32H:l,rotr32L:p,rotlSH:y,rotlSL:b,rotlBH:g,rotlBL:A,add:m,add3L:_,add3H:x,add4L:E,add4H:w,add5H:I,add5L:H}}),G=R,$=W,X=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_224=t.sha512_256=t.sha384=t.sha512=t.sha224=t.sha256=t.SHA512_256=t.SHA512_224=t.SHA384=t.SHA512=t.SHA224=t.SHA256=void 0;const r=/* @__PURE__ */Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),n=/* @__PURE__ */new Uint32Array(64);class s extends G.HashMD{constructor(e=32){super(64,e,8,!1),this.A=0|G.SHA256_IV[0],this.B=0|G.SHA256_IV[1],this.C=0|G.SHA256_IV[2],this.D=0|G.SHA256_IV[3],this.E=0|G.SHA256_IV[4],this.F=0|G.SHA256_IV[5],this.G=0|G.SHA256_IV[6],this.H=0|G.SHA256_IV[7]}get(){const{A:e,B:t,C:r,D:n,E:s,F:o,G:i,H:c}=this;return[e,t,r,n,s,o,i,c]}set(e,t,r,n,s,o,i,c){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|s,this.F=0|o,this.G=0|i,this.H=0|c}process(e,t){for(let r=0;r<16;r++,t+=4)n[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=n[e-15],r=n[e-2],s=(0,M.rotr)(t,7)^(0,M.rotr)(t,18)^t>>>3,o=(0,M.rotr)(r,17)^(0,M.rotr)(r,19)^r>>>10;n[e]=o+n[e-7]+s+n[e-16]|0}let{A:s,B:o,C:i,D:c,E:a,F:u,G:d,H:f}=this;for(let e=0;e<64;e++){const t=f+((0,M.rotr)(a,6)^(0,M.rotr)(a,11)^(0,M.rotr)(a,25))+(0,G.Chi)(a,u,d)+r[e]+n[e]|0,h=((0,M.rotr)(s,2)^(0,M.rotr)(s,13)^(0,M.rotr)(s,22))+(0,G.Maj)(s,o,i)|0;f=d,d=u,u=a,a=c+t|0,c=i,i=o,o=s,s=t+h|0}s=s+this.A|0,o=o+this.B|0,i=i+this.C|0,c=c+this.D|0,a=a+this.E|0,u=u+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(s,o,i,c,a,u,d,f)}roundClean(){(0,M.clean)(n)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,M.clean)(this.buffer)}}t.SHA256=s;class o extends s{constructor(){super(28),this.A=0|G.SHA224_IV[0],this.B=0|G.SHA224_IV[1],this.C=0|G.SHA224_IV[2],this.D=0|G.SHA224_IV[3],this.E=0|G.SHA224_IV[4],this.F=0|G.SHA224_IV[5],this.G=0|G.SHA224_IV[6],this.H=0|G.SHA224_IV[7]}}t.SHA224=o;const i=/* @__PURE__ */(()=>$.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),c=/* @__PURE__ */(()=>i[0])(),a=/* @__PURE__ */(()=>i[1])(),u=/* @__PURE__ */new Uint32Array(80),d=/* @__PURE__ */new Uint32Array(80);class f extends G.HashMD{constructor(e=64){super(128,e,16,!1),this.Ah=0|G.SHA512_IV[0],this.Al=0|G.SHA512_IV[1],this.Bh=0|G.SHA512_IV[2],this.Bl=0|G.SHA512_IV[3],this.Ch=0|G.SHA512_IV[4],this.Cl=0|G.SHA512_IV[5],this.Dh=0|G.SHA512_IV[6],this.Dl=0|G.SHA512_IV[7],this.Eh=0|G.SHA512_IV[8],this.El=0|G.SHA512_IV[9],this.Fh=0|G.SHA512_IV[10],this.Fl=0|G.SHA512_IV[11],this.Gh=0|G.SHA512_IV[12],this.Gl=0|G.SHA512_IV[13],this.Hh=0|G.SHA512_IV[14],this.Hl=0|G.SHA512_IV[15]}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:s,Cl:o,Dh:i,Dl:c,Eh:a,El:u,Fh:d,Fl:f,Gh:h,Gl:l,Hh:p,Hl:y}=this;return[e,t,r,n,s,o,i,c,a,u,d,f,h,l,p,y]}set(e,t,r,n,s,o,i,c,a,u,d,f,h,l,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|s,this.Cl=0|o,this.Dh=0|i,this.Dl=0|c,this.Eh=0|a,this.El=0|u,this.Fh=0|d,this.Fl=0|f,this.Gh=0|h,this.Gl=0|l,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let r=0;r<16;r++,t+=4)u[r]=e.getUint32(t),d[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|u[e-15],r=0|d[e-15],n=$.rotrSH(t,r,1)^$.rotrSH(t,r,8)^$.shrSH(t,r,7),s=$.rotrSL(t,r,1)^$.rotrSL(t,r,8)^$.shrSL(t,r,7),o=0|u[e-2],i=0|d[e-2],c=$.rotrSH(o,i,19)^$.rotrBH(o,i,61)^$.shrSH(o,i,6),a=$.rotrSL(o,i,19)^$.rotrBL(o,i,61)^$.shrSL(o,i,6),f=$.add4L(s,a,d[e-7],d[e-16]),h=$.add4H(f,n,c,u[e-7],u[e-16]);u[e]=0|h,d[e]=0|f}let{Ah:r,Al:n,Bh:s,Bl:o,Ch:i,Cl:f,Dh:h,Dl:l,Eh:p,El:y,Fh:b,Fl:g,Gh:A,Gl:m,Hh:_,Hl:x}=this;for(let e=0;e<80;e++){const t=$.rotrSH(p,y,14)^$.rotrSH(p,y,18)^$.rotrBH(p,y,41),E=$.rotrSL(p,y,14)^$.rotrSL(p,y,18)^$.rotrBL(p,y,41),w=p&b^~p&A,H=$.add5L(x,E,y&g^~y&m,a[e],d[e]),I=$.add5H(H,_,t,w,c[e],u[e]),v=0|H,S=$.rotrSH(r,n,28)^$.rotrBH(r,n,34)^$.rotrBH(r,n,39),D=$.rotrSL(r,n,28)^$.rotrBL(r,n,34)^$.rotrBL(r,n,39),P=r&s^r&i^s&i,L=n&o^n&f^o&f;_=0|A,x=0|m,A=0|b,m=0|g,b=0|p,g=0|y,({h:p,l:y}=$.add(0|h,0|l,0|I,0|v)),h=0|i,l=0|f,i=0|s,f=0|o,s=0|r,o=0|n;const B=$.add3L(v,D,L);r=$.add3H(B,I,S,P),n=0|B}({h:r,l:n}=$.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:s,l:o}=$.add(0|this.Bh,0|this.Bl,0|s,0|o)),({h:i,l:f}=$.add(0|this.Ch,0|this.Cl,0|i,0|f)),({h,l}=$.add(0|this.Dh,0|this.Dl,0|h,0|l)),({h:p,l:y}=$.add(0|this.Eh,0|this.El,0|p,0|y)),({h:b,l:g}=$.add(0|this.Fh,0|this.Fl,0|b,0|g)),({h:A,l:m}=$.add(0|this.Gh,0|this.Gl,0|A,0|m)),({h:_,l:x}=$.add(0|this.Hh,0|this.Hl,0|_,0|x)),this.set(r,n,s,o,i,f,h,l,p,y,b,g,A,m,_,x)}roundClean(){(0,M.clean)(u,d)}destroy(){(0,M.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=f;class h extends f{constructor(){super(48),this.Ah=0|G.SHA384_IV[0],this.Al=0|G.SHA384_IV[1],this.Bh=0|G.SHA384_IV[2],this.Bl=0|G.SHA384_IV[3],this.Ch=0|G.SHA384_IV[4],this.Cl=0|G.SHA384_IV[5],this.Dh=0|G.SHA384_IV[6],this.Dl=0|G.SHA384_IV[7],this.Eh=0|G.SHA384_IV[8],this.El=0|G.SHA384_IV[9],this.Fh=0|G.SHA384_IV[10],this.Fl=0|G.SHA384_IV[11],this.Gh=0|G.SHA384_IV[12],this.Gl=0|G.SHA384_IV[13],this.Hh=0|G.SHA384_IV[14],this.Hl=0|G.SHA384_IV[15]}}t.SHA384=h;const l=/* @__PURE__ */Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),p=/* @__PURE__ */Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class y extends f{constructor(){super(28),this.Ah=0|l[0],this.Al=0|l[1],this.Bh=0|l[2],this.Bl=0|l[3],this.Ch=0|l[4],this.Cl=0|l[5],this.Dh=0|l[6],this.Dl=0|l[7],this.Eh=0|l[8],this.El=0|l[9],this.Fh=0|l[10],this.Fl=0|l[11],this.Gh=0|l[12],this.Gl=0|l[13],this.Hh=0|l[14],this.Hl=0|l[15]}}t.SHA512_224=y;class b extends f{constructor(){super(32),this.Ah=0|p[0],this.Al=0|p[1],this.Bh=0|p[2],this.Bl=0|p[3],this.Ch=0|p[4],this.Cl=0|p[5],this.Dh=0|p[6],this.Dl=0|p[7],this.Eh=0|p[8],this.El=0|p[9],this.Fh=0|p[10],this.Fl=0|p[11],this.Gh=0|p[12],this.Gl=0|p[13],this.Hh=0|p[14],this.Hl=0|p[15]}}t.SHA512_256=b,t.sha256=(0,M.createHasher)(()=>new s),t.sha224=(0,M.createHasher)(()=>new o),t.sha512=(0,M.createHasher)(()=>new f),t.sha384=(0,M.createHasher)(()=>new h),t.sha512_256=(0,M.createHasher)(()=>new b),t.sha512_224=(0,M.createHasher)(()=>new y)}),q=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.SHA224=t.sha256=t.SHA256=void 0,t.SHA256=X.SHA256,t.sha256=X.sha256,t.SHA224=X.SHA224,t.sha224=X.sha224});const Y=(T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(/*#__PURE__*/Object.defineProperty({default:function(e){return Array.isArray(e)?new Uint8Array(e):e}},"__esModule",{value:!0}));var z=/*#__PURE__*/Object.defineProperty({default:function(e){function t(t){return e((0,Y.default)(t))}return t.create=()=>{const t=e.create();return{update(e){return t.update((0,Y.default)(e)),this},digest:()=>t.digest()}},t}},"__esModule",{value:!0}),Z=q,J=O(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sha256=void 0;const n=r(z);t.sha256=(0,n.default)(Z.sha256)}),Q=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.concatArgs=t.arrayEqual=void 0,t.arrayEqual=function(e,t){return e.length===t.length&&e.every((e,r)=>e===t[r])},t.concatArgs=function(...e){return e.flatMap(e=>"number"==typeof e?[e]:Array.from(e))}}),ee=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidClassicAddress=t.decodeAccountPublic=t.encodeAccountPublic=t.encodeNodePublic=t.decodeNodePublic=t.decodeAddress=t.decodeAccountID=t.encodeAddress=t.encodeAccountID=t.decodeSeed=t.encodeSeed=t.codec=void 0;const r=[1,225,75],s={sha256:J.sha256},o=new class{constructor(e){this._sha256=e.sha256,this._codec=n.base58xrp}encode(e,t){return this._encodeVersioned(e,t.versions,t.expectedLength)}decode(e,t){var r;const n=t.versions,s=t.versionTypes,o=this.decodeChecked(e);if(n.length>1&&!t.expectedLength)throw new Error("expectedLength is required because there are >= 2 possible versions");const i=null!==(r=t.expectedLength)&&void 0!==r?r:o.length-("number"==typeof n[0]?1:n[0].length),c=o.slice(0,-i),a=o.slice(-i);for(let e=0;e<n.length;e++){const t=Array.isArray(n[e])?n[e]:[n[e]];if((0,Q.arrayEqual)(c,t))return{version:t,bytes:a,type:s?s[e]:null}}throw new Error("version_invalid: version bytes do not match any of the provided version(s)")}encodeChecked(e){const t=this._sha256(this._sha256(e)).slice(0,4);return this._encodeRaw(Uint8Array.from((0,Q.concatArgs)(e,t)))}decodeChecked(e){const t=this._decodeRaw(e);if(t.byteLength<5)throw new Error("invalid_input_size: decoded data must have length >= 5");if(!this._verifyCheckSum(t))throw new Error("checksum_invalid");return t.slice(0,-4)}_encodeVersioned(e,t,r){if(!a(e,r))throw new Error("unexpected_payload_length: bytes.length does not match expectedLength. Ensure that the bytes are a Uint8Array.");return this.encodeChecked((0,Q.concatArgs)(t,e))}_encodeRaw(e){return this._codec.encode(Uint8Array.from(e))}_decodeRaw(e){return this._codec.decode(e)}_verifyCheckSum(e){const t=this._sha256(this._sha256(e.slice(0,-4))).slice(0,4),r=e.slice(-4);return(0,Q.arrayEqual)(t,r)}}(s);function i(e){return o.encode(e,{versions:[0],expectedLength:20})}function c(e){return o.decode(e,{versions:[0],expectedLength:20}).bytes}function a(e,t){return"byteLength"in e?e.byteLength===t:e.length===t}t.codec=o,t.encodeSeed=function(e,t){if(!a(e,16))throw new Error("entropy must have length 16");return o.encode(e,{expectedLength:16,versions:"ed25519"===t?r:[33]})},t.decodeSeed=function(e,t={versionTypes:["ed25519","secp256k1"],versions:[r,33],expectedLength:16}){return o.decode(e,t)},t.encodeAccountID=i,t.encodeAddress=i,t.decodeAccountID=c,t.decodeAddress=c,t.decodeNodePublic=function(e){return o.decode(e,{versions:[28],expectedLength:33}).bytes},t.encodeNodePublic=function(e){return o.encode(e,{versions:[28],expectedLength:33})},t.encodeAccountPublic=function(e){return o.encode(e,{versions:[35],expectedLength:33})},t.decodeAccountPublic=function(e){return o.decode(e,{versions:[35],expectedLength:33}).bytes},t.isValidClassicAddress=function(e){try{c(e)}catch(e){return!1}return!0}}),te=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidXAddress=t.decodeXAddress=t.xAddressToClassicAddress=t.encodeXAddress=t.classicAddressToXAddress=t.isValidClassicAddress=t.decodeAccountPublic=t.encodeAccountPublic=t.decodeNodePublic=t.encodeNodePublic=t.decodeAccountID=t.encodeAccountID=t.decodeSeed=t.encodeSeed=t.codec=void 0,Object.defineProperty(t,"codec",{enumerable:!0,get:function(){return ee.codec}}),Object.defineProperty(t,"encodeSeed",{enumerable:!0,get:function(){return ee.encodeSeed}}),Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return ee.decodeSeed}}),Object.defineProperty(t,"encodeAccountID",{enumerable:!0,get:function(){return ee.encodeAccountID}}),Object.defineProperty(t,"decodeAccountID",{enumerable:!0,get:function(){return ee.decodeAccountID}}),Object.defineProperty(t,"encodeNodePublic",{enumerable:!0,get:function(){return ee.encodeNodePublic}}),Object.defineProperty(t,"decodeNodePublic",{enumerable:!0,get:function(){return ee.decodeNodePublic}}),Object.defineProperty(t,"encodeAccountPublic",{enumerable:!0,get:function(){return ee.encodeAccountPublic}}),Object.defineProperty(t,"decodeAccountPublic",{enumerable:!0,get:function(){return ee.decodeAccountPublic}}),Object.defineProperty(t,"isValidClassicAddress",{enumerable:!0,get:function(){return ee.isValidClassicAddress}});const r={main:Uint8Array.from([5,68]),test:Uint8Array.from([4,147])};function n(e,t,n){if(20!==e.length)throw new Error("Account ID must be 20 bytes");if(!1!==t&&t>4294967295)throw new Error("Invalid tag");const s=t||0,o=(0,N.concat)([n?r.test:r.main,e,Uint8Array.from([!1===t||null==t?0:1,255&s,s>>8&255,s>>16&255,s>>24&255,0,0,0,0])]);return ee.codec.encodeChecked(o)}function s(e){const t=ee.codec.decodeChecked(e),n=function(e){const t=e.slice(0,2);if((0,N.equal)(r.main,t))return!1;if((0,N.equal)(r.test,t))return!0;throw new Error("Invalid X-address: bad prefix")}(t);return{accountId:t.slice(2,22),tag:function(e){const t=e[22];if(t>=2)throw new Error("Unsupported X-address");if(1===t)return e[23]+256*e[24]+65536*e[25]+16777216*e[26];if(0!==t)throw new Error("flag must be zero to indicate no tag");if(!(0,N.equal)((0,N.hexToBytes)("0000000000000000"),e.slice(23,31)))throw new Error("remaining bytes must be zero");return!1}(t),test:n}}t.classicAddressToXAddress=function(e,t,r){return n((0,ee.decodeAccountID)(e),t,r)},t.encodeXAddress=n,t.xAddressToClassicAddress=function(e){const{accountId:t,tag:r,test:n}=s(e);return{classicAddress:(0,ee.encodeAccountID)(t),tag:r,test:n}},t.decodeXAddress=s,t.isValidXAddress=function(e){try{s(e)}catch(e){return!1}return!0}}),re=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=t.md5=t.MD5=t.sha1=t.SHA1=void 0;const r=/* @__PURE__ */Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),n=/* @__PURE__ */new Uint32Array(80);class s extends G.HashMD{constructor(){super(64,20,8,!1),this.A=0|r[0],this.B=0|r[1],this.C=0|r[2],this.D=0|r[3],this.E=0|r[4]}get(){const{A:e,B:t,C:r,D:n,E:s}=this;return[e,t,r,n,s]}set(e,t,r,n,s){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)n[r]=e.getUint32(t,!1);for(let e=16;e<80;e++)n[e]=(0,M.rotl)(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let{A:r,B:s,C:o,D:i,E:c}=this;for(let e=0;e<80;e++){let t,a;e<20?(t=(0,G.Chi)(s,o,i),a=1518500249):e<40?(t=s^o^i,a=1859775393):e<60?(t=(0,G.Maj)(s,o,i),a=2400959708):(t=s^o^i,a=3395469782);const u=(0,M.rotl)(r,5)+t+c+a+n[e]|0;c=i,i=o,o=(0,M.rotl)(s,30),s=r,r=u}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,c=c+this.E|0,this.set(r,s,o,i,c)}roundClean(){(0,M.clean)(n)}destroy(){this.set(0,0,0,0,0),(0,M.clean)(this.buffer)}}t.SHA1=s,t.sha1=(0,M.createHasher)(()=>new s);const o=/* @__PURE__ */Math.pow(2,32),i=/* @__PURE__ */Array.from({length:64},(e,t)=>Math.floor(o*Math.abs(Math.sin(t+1)))),c=/* @__PURE__ */r.slice(0,4),a=/* @__PURE__ */new Uint32Array(16);class u extends G.HashMD{constructor(){super(64,16,8,!0),this.A=0|c[0],this.B=0|c[1],this.C=0|c[2],this.D=0|c[3]}get(){const{A:e,B:t,C:r,D:n}=this;return[e,t,r,n]}set(e,t,r,n){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n}process(e,t){for(let r=0;r<16;r++,t+=4)a[r]=e.getUint32(t,!0);let{A:r,B:n,C:s,D:o}=this;for(let e=0;e<64;e++){let t,c,u;e<16?(t=(0,G.Chi)(n,s,o),c=e,u=[7,12,17,22]):e<32?(t=(0,G.Chi)(o,n,s),c=(5*e+1)%16,u=[5,9,14,20]):e<48?(t=n^s^o,c=(3*e+5)%16,u=[4,11,16,23]):(t=s^(n|~o),c=7*e%16,u=[6,10,15,21]),t=t+r+i[e]+a[c],r=o,o=s,s=n,n+=(0,M.rotl)(t,u[e%4])}r=r+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,this.set(r,n,s,o)}roundClean(){(0,M.clean)(a)}destroy(){this.set(0,0,0,0),(0,M.clean)(this.buffer)}}t.MD5=u,t.md5=(0,M.createHasher)(()=>new u);const d=/* @__PURE__ */Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),f=/* @__PURE__ */(()=>Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)))(),h=/* @__PURE__ */(()=>f.map(e=>(9*e+5)%16))(),l=/* @__PURE__ */(()=>{const e=[[f],[h]];for(let t=0;t<4;t++)for(let r of e)r.push(r[t].map(e=>d[e]));return e})(),p=/* @__PURE__ */(()=>l[0])(),y=/* @__PURE__ */(()=>l[1])(),b=/* @__PURE__ */[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),g=/* @__PURE__ */p.map((e,t)=>e.map(e=>b[t][e])),A=/* @__PURE__ */y.map((e,t)=>e.map(e=>b[t][e])),m=/* @__PURE__ */Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),_=/* @__PURE__ */Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function x(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const E=/* @__PURE__ */new Uint32Array(16);class w extends G.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:r,h3:n,h4:s}=this;return[e,t,r,n,s]}set(e,t,r,n,s){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)E[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,s=0|this.h1,o=s,i=0|this.h2,c=i,a=0|this.h3,u=a,d=0|this.h4,f=d;for(let e=0;e<5;e++){const t=4-e,h=m[e],l=_[e],b=p[e],w=y[e],H=g[e],I=A[e];for(let t=0;t<16;t++){const n=(0,M.rotl)(r+x(e,s,i,a)+E[b[t]]+h,H[t])+d|0;r=d,d=a,a=0|(0,M.rotl)(i,10),i=s,s=n}for(let e=0;e<16;e++){const r=(0,M.rotl)(n+x(t,o,c,u)+E[w[e]]+l,I[e])+f|0;n=f,f=u,u=0|(0,M.rotl)(c,10),c=o,o=r}}this.set(this.h1+i+u|0,this.h2+a+f|0,this.h3+d+n|0,this.h4+r+o|0,this.h0+s+c|0)}roundClean(){(0,M.clean)(E)}destroy(){this.destroyed=!0,(0,M.clean)(this.buffer),this.set(0,0,0,0,0)}}t.RIPEMD160=w,t.ripemd160=(0,M.createHasher)(()=>new w)}),ne=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=void 0,t.RIPEMD160=re.RIPEMD160,t.ripemd160=re.ripemd160}),se=O(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=void 0;const n=r(z);t.ripemd160=(0,n.default)(ne.ripemd160)}),oe=O(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_256=t.SHA512_256=t.sha512_224=t.SHA512_224=t.sha384=t.SHA384=t.sha512=t.SHA512=void 0,t.SHA512=X.SHA512,t.sha512=X.sha512,t.SHA384=X.SHA384,t.sha384=X.sha384,t.SHA512_224=X.SHA512_224,t.sha512_224=X.sha512_224,t.SHA512_256=X.SHA512_256,t.sha512_256=X.sha512_256}),ie=O(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sha512=void 0;const n=r(z);t.sha512=(0,n.default)(oe.sha512)});class ce{constructor(){this.hash=ie.sha512.create()}static half(e){return(new ce).add(e).first256()}add(e){return this.hash.update(e),this}addU32(e){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),this.add(t)}finish(){return this.hash.digest()}first256(){return this.finish().slice(0,32)}first256BigInt(){return(0,E.bytesToNumberBE)(this.first256())}}var ae=/*#__PURE__*/Object.defineProperty({default:ce},"__esModule",{value:!0}),ue=O(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.accountPublicFromPublicGenerator=t.derivePrivateKey=void 0;const n=r(ae),s=BigInt(0);function o(e,t){const r=b.secp256k1.CURVE.n;for(let o=0;o<=4294967295;o++){const i=(new n.default).add(e);void 0!==t&&i.addU32(t),i.addU32(o);const c=i.first256BigInt();if(c>s&&c<r)return c}throw new Error("impossible unicorn ;)")}t.derivePrivateKey=function(e,t={}){const r=t.validator,n=b.secp256k1.CURVE.n,s=o(e);return r?s:(o(b.secp256k1.ProjectivePoint.BASE.multiply(s).toRawBytes(!0),t.accountIndex||0)+s)%n},t.accountPublicFromPublicGenerator=function(e){const t=b.secp256k1.ProjectivePoint.fromHex(e),r=o(e,0),n=b.secp256k1.ProjectivePoint.BASE.multiply(r);return t.add(n).toRawBytes(!0)}}),de=/*#__PURE__*/Object.defineProperty({default:{ok(e,t){if(!e)throw new Error(t)}}},"__esModule",{value:!0}),fe=O(function(e,t){var r;Object.defineProperty(t,"__esModule",{value:!0}),t.getAlgorithmFromPrivateKey=t.getAlgorithmFromPublicKey=t.getAlgorithmFromKey=void 0,function(e){e[e.NONE=-1]="NONE",e[e.ED25519=237]="ED25519",e[e.SECP256K1_PUB_X=2]="SECP256K1_PUB_X",e[e.SECP256K1_PUB_X_ODD_Y=3]="SECP256K1_PUB_X_ODD_Y",e[e.SECP256K1_PUB_XY=4]="SECP256K1_PUB_XY",e[e.SECP256K1_PRIVATE=0]="SECP256K1_PRIVATE"}(r||(r={}));const n={[`private_${r.NONE}_32`]:"ecdsa-secp256k1",[`private_${r.SECP256K1_PRIVATE}_33`]:"ecdsa-secp256k1",[`private_${r.ED25519}_33`]:"ed25519",[`public_${r.ED25519}_33`]:"ed25519",[`public_${r.SECP256K1_PUB_X}_33`]:"ecdsa-secp256k1",[`public_${r.SECP256K1_PUB_X_ODD_Y}_33`]:"ecdsa-secp256k1",[`public_${r.SECP256K1_PUB_XY}_65`]:"ecdsa-secp256k1"};function s(e){return e===r.NONE?"None":`0x${e.toString(16).padStart(2,"0")}`}function o(e,t){const{prefix:o,len:i}=function(e){return{prefix:e.length<2?r.NONE:parseInt(e.slice(0,2),16),len:e.length/2}}(e),c="private"===t&&32===i?r.NONE:o,a=n[`${t}_${c}_${i}`];if(!a)throw new Error(function({key:e,type:t,prefix:r,len:o}){const i=function(e){return Object.entries(n).filter(([t])=>t.startsWith(e)).map(([e,t])=>{const[,r,n]=e.split("_");return`${t.padEnd(17)} - Prefix: ${s(Number(r)).padEnd(6)} Length: ${n} bytes`}).join("\n")}(t);return`invalid_key:\n\nType: ${t}\nKey: ${e}\nPrefix: ${s(r)} \nLength: ${o} bytes\n\nAcceptable ${t} formats are:\n${i}\n`}({key:e,type:t,len:i,prefix:c}));return a}t.getAlgorithmFromKey=o,t.getAlgorithmFromPublicKey=function(e){return o(e,"public")},t.getAlgorithmFromPrivateKey=function(e){return o(e,"private")}}),he=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const le=he(de),pe=he(ae);var ye=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e,t){const r=(0,ue.derivePrivateKey)(e,t);return{privateKey:"00"+(0,N.bytesToHex)((0,E.numberToBytesBE)(r,32)),publicKey:(0,N.bytesToHex)(b.secp256k1.getPublicKey(r,!0))}},sign(e,t){le.default.ok(66===t.length&&t.startsWith("00")||64===t.length);const r=66===t.length?t.slice(2):t;return b.secp256k1.sign(pe.default.half(e),r,{lowS:!0,extraEntropy:void 0}).toDERHex(!0).toUpperCase()},verify(e,t,r){const n=b.secp256k1.Signature.fromDER(t);return b.secp256k1.verify(n,pe.default.half(e),r)}}},"__esModule",{value:!0}),be=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const ge=be(de),Ae=be(ae);var me=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e){const t=Ae.default.half(e);return{privateKey:"ED"+(0,N.bytesToHex)(t),publicKey:"ED"+(0,N.bytesToHex)(w.ed25519.getPublicKey(t))}},sign:(e,t)=>(ge.default.ok(e instanceof Uint8Array,"message must be array of octets"),ge.default.ok(66===t.length,"private key must be 33 bytes including prefix"),(0,N.bytesToHex)(w.ed25519.sign(e,t.slice(2)))),verify:(e,t,r)=>(ge.default.ok(66===r.length,"public key must be 33 bytes including prefix"),w.ed25519.verify(t,e,r.slice(2),{zip215:!1}))}},"__esModule",{value:!0}),_e=O(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decodeSeed=t.deriveNodeAddress=t.deriveAddress=t.verify=t.sign=t.deriveKeypair=t.generateSeed=void 0,Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return te.decodeSeed}});const n=r(ae),s=r(de),o=r(ye),i=r(me);function c(e){return{"ecdsa-secp256k1":o.default,ed25519:i.default}[e]}function a(e){return(0,te.encodeAccountID)(function(e){return(0,se.ripemd160)((0,J.sha256)(e))}(e))}t.generateSeed=function(e={}){s.default.ok(!e.entropy||e.entropy.length>=16,"entropy too short");const t=e.entropy?e.entropy.slice(0,16):(0,N.randomBytes)(16);return(0,te.encodeSeed)(t,"ed25519"===e.algorithm?"ed25519":"secp256k1")},t.deriveKeypair=function(e,t){var r;const s=(0,te.decodeSeed)(e),o=c("ed25519"===(null!==(r=null==t?void 0:t.algorithm)&&void 0!==r?r:s.type)?"ed25519":"ecdsa-secp256k1"),i=o.deriveKeypair(s.bytes,t),a=n.default.half("This test message should verify."),u=o.sign(a,i.privateKey);if(!o.verify(a,u,i.publicKey))throw new Error("derived keypair did not generate verifiable signature");return i},t.sign=function(e,t){return c((0,fe.getAlgorithmFromPrivateKey)(t)).sign((0,N.hexToBytes)(e),t)},t.verify=function(e,t,r){return c((0,fe.getAlgorithmFromPublicKey)(r)).verify((0,N.hexToBytes)(e),t,r)},t.deriveAddress=function(e){return a((0,N.hexToBytes)(e))},t.deriveNodeAddress=function(e){const t=(0,te.decodeNodePublic)(e);return a((0,ue.accountPublicFromPublicGenerator)(t))}});const xe=["wss://s1.ripple.com","wss://xrplcluster.com/","wss://s2.ripple.com/"];function Ee(e){for(let n=0;n<e.length;n++){var t,r;return null!=(t=null==(r=e[n])||null==(r=r.tx_json)?void 0:r.SigningPubKey)?t:"0x"}throw new Error("No valid pubkey found in the latest transactions")}const we={testnet:{grpcUrl:"https://grpc.testnet.concordium.com:20000",walletProxyUrl:"https://wallet-proxy.testnet.concordium.com"},mainnet:{grpcUrl:"https://grpc.mainnet.concordium.com:20000",walletProxyUrl:"https://wallet-proxy.mainnet.concordium.software"}},He={network:"testnet",timeout:5e4,retries:3,testMode:!0};function Ie(e){try{if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e=>{if("string"==typeof e)return e;if(e&&"object"==typeof e)for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];if("string"==typeof n)return n;if("object"==typeof n){const e=t(n);if(e)return e}}return null},r=t(e);if(r)return r}throw new Error("Unable to extract signature from object")}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw new Error(`Invalid signature format: ${t}`)}}async function ve(e,t){let r=new Error("No attempts made");for(let o=0;o<=t;o++)try{return await e()}catch(e){var n,s;const i=e instanceof Error?e:new Error(String(e));if(r=i,null!=(n=i.message)&&n.includes("Invalid signature")||null!=(s=i.message)&&s.includes("Account not found"))throw i;if(o===t)break;const c=Math.min(1e3*Math.pow(2,o),5e3);await new Promise(e=>setTimeout(e,c))}throw r}async function Se(r,n){switch(r.type){case t.SelfDeclaration:return I({},r,{status:r.confirmed?e.VERIFIED:e.FAILED});case t.Screenshot:return I({},r,{status:r.url?e.FLAGGED:e.FAILED});case t.CIP8:return async function(t){const[r,,n]=t.address.split(/:/),s=t.chainSpecificData&&"cardanoCoseKey"in t.chainSpecificData?t.chainSpecificData.cardanoCoseKey:null;if("cardano"!==r||!s)return I({},t,{status:e.FAILED});try{return I({},t,{status:_(t.proof,s,t.attestation,n)?e.VERIFIED:e.FAILED})}catch(r){return I({},t,{status:e.FAILED})}}(r);case t.EIP191:return async function(t){const[r,,n]=t.address.split(/:/);if("eip155"!==r)return I({},t,{status:e.FAILED});const s=function(e,t,r){try{const n=u.getSignPayload(d.fromString(t)),s=f.fromHex(r),o=h.recoverPublicKey({payload:n,signature:s});return l.checksum(l.fromPublicKey(o)).toString()===l.checksum(e)}catch(e){return!1}}(n,t.attestation,t.proof);return I({},t,{status:s?e.VERIFIED:e.FAILED})}(r);case t.ED25519:return async function(t){const[r,,n]=t.address.split(/:/);if("solana"!==r)return I({},t,{status:e.FAILED});try{const r=c.decode(n),s=(new TextEncoder).encode(t.attestation),o=i.decode(t.proof);return I({},t,{status:m.sign.detached.verify(s,o,r)?e.VERIFIED:e.FAILED})}catch(r){return I({},t,{status:e.FAILED})}}(r);case t.SOL_SIWX:return async function(t){const[r]=t.address.split(/:/);if("solana"!==r)return I({},t,{status:e.FAILED});if(!t.chainSpecificData||!function(e){if(!e||"object"!=typeof e)return!1;const t=e;if(!t.account||"object"!=typeof t.account)return!1;const r=t.account;if("string"!=typeof r.address)return!1;if(!r.publicKey)return!1;if(!(r.publicKey instanceof Uint8Array)){const e=r.publicKey;if("object"!=typeof e)return!1;{const t=Object.keys(e).filter(e=>!isNaN(Number(e))).sort((e,t)=>Number(e)-Number(t));if(32!==t.length)return!1;{const n=t.map(t=>Number(e[t]));if(!n.every(e=>"number"==typeof e&&e>=0&&e<=255))return!1;r.publicKey=new Uint8Array(n)}}}if(!t.signedMessage)return!1;if(!(t.signedMessage instanceof Uint8Array)){const e=t.signedMessage;if("Buffer"!==e.type||!Array.isArray(e.data))return!1;t.signedMessage=new Uint8Array(e.data)}if(!t.signature)return!1;if(!(t.signature instanceof Uint8Array)){const e=t.signature;if("Buffer"!==e.type||!Array.isArray(e.data))return!1;t.signature=new Uint8Array(e.data)}if(!t.message||"object"!=typeof t.message)return!1;const n=t.message;if("object"==typeof n&&null!==n){const e=n;if(!e.address&&t.signedMessage instanceof Uint8Array)try{const r=(new TextDecoder).decode(t.signedMessage).split("\n");if(r.length>=2){const t=r[1].trim();t&&/^[a-zA-Z0-9]{32,44}$/.test(t)&&(e.address=t)}}catch(e){}}return!!function(e){return!(!e||"object"!=typeof e)&&"string"==typeof e.domain&&"string"==typeof e.address&&(void 0===e.statement||"string"==typeof e.statement)&&(void 0===e.uri||"string"==typeof e.uri)&&(void 0===e.version||"string"==typeof e.version)&&(void 0===e.chainId||"string"==typeof e.chainId)&&(void 0===e.nonce||"string"==typeof e.nonce)&&(void 0===e.issuedAt||"string"==typeof e.issuedAt)&&(void 0===e.expirationTime||"string"==typeof e.expirationTime)&&(void 0===e.notBefore||"string"==typeof e.notBefore)&&(void 0===e.requestId||"string"==typeof e.requestId)&&(void 0===e.resources||Array.isArray(e.resources))}(t.message)}(t.chainSpecificData))return I({},t,{status:e.FAILED});try{const r=t.chainSpecificData,n=(new TextDecoder).decode(r.signedMessage),s=function(e){try{const t=e.split("\n"),r=function(e){var t;const r=null==(t=e[0])?void 0:t.match(/^(.+) wants you to sign in with your Solana account:$/);if(!r)return null;const n=r[1],s=e[1];return s&&/^[a-zA-Z0-9]{32,44}$/.test(s)?{domain:n,address:s}:null}(t);if(!r)return null;const n=I({},r);let s=2;const o=function(e,t){let r=t;if(""===e[r]&&e[r+1]&&!e[r+1].includes(":")){r++;const t=e[r];return r++,""===e[r]&&r++,{statement:t,nextIndex:r}}return{nextIndex:r}}(t,s);void 0!==o.statement&&(n.statement=o.statement,s=o.nextIndex);const i=function(e,t){const r={},n=[{prefix:"URI: ",key:"uri"},{prefix:"Version: ",key:"version"},{prefix:"Chain ID: ",key:"chainId"},{prefix:"Nonce: ",key:"nonce"},{prefix:"Issued At: ",key:"issuedAt"},{prefix:"Expiration Time: ",key:"expirationTime"},{prefix:"Not Before: ",key:"notBefore"},{prefix:"Request ID: ",key:"requestId"}];let s=t;for(;s<e.length;){const t=e[s];if(t){if(t.startsWith("Resources:")){const t=k(e,s+1);if(t.length>0){r.resources=t,s+=t.length+1;continue}}for(const{prefix:e,key:s}of n)if(t.startsWith(e)){const n=t.substring(e.length);r[s]=n;break}s++}else s++}return r}(t,s);return Object.assign(n,i),n}catch(e){return null}}(n);return s&&function(e,t){if(e.domain!==t.domain||e.address!==t.address)return!1;const r=[{inputKey:"statement",parsedKey:"statement"},{inputKey:"uri",parsedKey:"uri"},{inputKey:"version",parsedKey:"version"},{inputKey:"chainId",parsedKey:"chainId"},{inputKey:"nonce",parsedKey:"nonce"},{inputKey:"issuedAt",parsedKey:"issuedAt"},{inputKey:"expirationTime",parsedKey:"expirationTime"},{inputKey:"notBefore",parsedKey:"notBefore"},{inputKey:"requestId",parsedKey:"requestId"},{inputKey:"resources",parsedKey:"resources",validator:(e,t)=>!(!Array.isArray(e)||!Array.isArray(t))&&e.length===t.length&&e.every((e,r)=>e===t[r])}];for(const{inputKey:n,parsedKey:s,validator:o}of r){const r=t[n],i=e[s];if(void 0!==r)if(o){if(!o(r,i))return!1}else if(r!==i)return!1}return function(e){const t=Date.now();if(e.issuedAt){const r=new Date(e.issuedAt),n=864e5;if(Math.abs(r.getTime()-t)>n)return!1}return!(e.expirationTime&&new Date(e.expirationTime).getTime()<=t||e.notBefore&&new Date(e.notBefore).getTime()>t)}(e)}(s,r.message)?function(e){let t=`${e.domain} wants you to sign in with your Solana account:\n`;t+=`${e.address}`,e.statement&&(t+=`\n\n${e.statement}`);const r=function(e){const t=[],r=[{key:"uri",prefix:"URI: "},{key:"version",prefix:"Version: "},{key:"chainId",prefix:"Chain ID: "},{key:"nonce",prefix:"Nonce: "},{key:"issuedAt",prefix:"Issued At: "},{key:"expirationTime",prefix:"Expiration Time: "},{key:"notBefore",prefix:"Not Before: "},{key:"requestId",prefix:"Request ID: "},{key:"resources",prefix:"Resources:",formatter:e=>Array.isArray(e)&&e.length>0?["Resources:",...e.map(e=>`- ${e}`)]:[]}];for(const{key:n,prefix:s,formatter:o}of r){const r=e[n];if(void 0!==r)if(o){const e=o(r);t.push(...e)}else"string"==typeof r&&t.push(`${s}${r}`)}return t}(e);return r.length&&(t+=`\n\n${r.join("\n")}`),t}(s)!==n?I({},t,{status:e.FAILED}):I({},t,{status:m.sign.detached.verify(r.signedMessage,r.signature,r.account.publicKey)?e.VERIFIED:e.FAILED}):I({},t,{status:e.FAILED})}catch(r){return I({},t,{status:e.FAILED})}}(r);case t.XRP_ED25519:return async function(t,r){const[n,,s]=t.address.split(/:/);if("xrpl"!==n)return I({},t,{status:e.FAILED});if(r||(r=await async function(e){const t=xe;for(const n of t)try{var r;const t=new x(n);await t.connect();const s=await t.request({command:"account_tx",account:e,binary:!1,limit:2,forward:!1});return await t.disconnect(),Ee(null==(r=s.result)?void 0:r.transactions)}catch(e){let t="Connection to XRPL server failed";e instanceof Error&&(t+=`: ${e.message}`),console.error(t)}}(s)),!r)return I({},t,{status:e.FAILED});const o=function(e,t,r){return _e.verify(Buffer.from(e).toString("hex"),r,t)}(t.attestation,r,t.proof);return I({},t,{status:o?e.VERIFIED:e.FAILED})}(r,n);case t.XLM_ED25519:return function(t){const[r,,n]=t.address.split(/:/);if("stellar"!==r)return I({},t,{status:e.FAILED});try{const r=H.fromPublicKey(n),s=Buffer.from(t.attestation,"utf-8"),o=Buffer.from(t.proof,"base64");return I({},t,{status:r.verify(s,o)?e.VERIFIED:e.FAILED})}catch(r){return console.error(r),I({},t,{status:e.FAILED})}}(r);case t.CONCORDIUM:return(async(t,r={})=>{const n=I({},He,r),[s,o,i]=t.address.split(/:/);if("ccd"!==s)return I({},t,{status:e.FAILED});let c=n.network;o&&(c=o.includes("testnet")?"testnet":"mainnet");try{let r;try{r=JSON.parse(t.proof)}catch(r){return I({},t,{status:e.FAILED})}if(!r||"object"!=typeof r||0===Object.keys(r).length)return I({},t,{status:e.FAILED});if(n.testMode)try{const n=Ie(r);return!n||n.length<64||!/^[0-9a-fA-F]+$/.test(n)?I({},t,{status:e.FAILED}):I({},t,{status:e.VERIFIED})}catch(r){return I({},t,{status:e.FAILED})}const s=await ve(()=>async function(e,t,r){const n=we[t];try{const t=new AbortController,s=setTimeout(()=>t.abort(),r),o=await fetch(`${n.walletProxyUrl}/v0/accEncryptionKey/${e}`,{method:"GET",headers:{Accept:"application/json","User-Agent":"verify-proof/1.6.0"},signal:t.signal});return clearTimeout(s),o.ok}catch(e){if(e instanceof Error&&"AbortError"===e.name)throw new Error(`Account validation timeout after ${r}ms`);throw e}}(i,c,n.timeout),n.retries);if(!s)return I({},t,{status:e.FAILED});const o=await ve(()=>async function(e,t){try{const t=Ie(e);return!(!t||t.length<64)&&t.length>=64&&/^[0-9a-fA-F]+$/.test(t)}catch(e){if(e instanceof Error){var r,n,s;if(null!=(r=e.message)&&r.includes("timeout"))throw new Error(`Signature verification timeout after ${t}ms`);if(null!=(n=e.message)&&n.includes("UNAVAILABLE"))throw new Error("Concordium node unavailable");if(null!=(s=e.message)&&s.includes("NOT_FOUND"))return!1}throw e}}(r,n.timeout),n.retries);return I({},t,o?{status:e.VERIFIED}:{status:e.FAILED})}catch(r){return I({},t,{status:e.FAILED})}})(r);case t.EIP712:case t.BIP137:case t.BIP322:return async function(r){const[n,,s]=r.address.split(/:/);if("bip122"!==n)return I({},r,{status:e.FAILED});const o=function(e){return e.startsWith("1")||e.startsWith("3")||e.startsWith("bc1")?S.bitcoin:e.startsWith("t1")||e.startsWith("t3")?S.zcash:e.startsWith("L")||e.startsWith("M")||e.startsWith("ltc1")?S.litecoin:e.startsWith("D")||e.startsWith("A")?S.dogecoin:e.startsWith("X")||e.startsWith("7")?S.dash:e.startsWith("q")?S.bitcoincash:e.startsWith("tb1")?S.testnet:S.bitcoin}(s);if(!o)return I({},r,{status:e.FAILED});if(s.startsWith("t1")||s.startsWith("t3"))return L(s,r,o);if(o.isTestnet)return P(s,r);try{switch(r.type){case t.BIP137:return L(s,r,o);case t.BIP322:return P(s,r);default:return I({},r,{status:e.FAILED})}}catch(t){return console.error("error verifying proof",t),I({},r,{status:e.FAILED})}}(r);case t.TIP191:return async function(t){const[r,,n]=t.address.split(/:/);return I({},t,"tron"!==r?{status:e.FAILED}:{status:F(n,t.attestation,t.proof)?e.VERIFIED:e.FAILED})}(r)}return r}export{Se as verifyProof};
1
+ import{ProofStatus as e,ProofTypes as t}from"@notabene/javascript-sdk";import{encode as r}from"varuint-bitcoin";import n,{createBase58check as s,bech32 as o,base64 as i,base58 as c}from"@scure/base";import{Hash as a,PersonalMessage as u,Hex as h,Signature as d,Secp256k1 as f,Address as l,PublicKey as p,Bytes as y}from"ox";import b,{secp256k1 as g}from"@noble/curves/secp256k1";import{Verifier as A}from"bip322-js";import m from"tweetnacl";import w from"@cardano-foundation/cardano-verify-datasignature";import{Client as E}from"xrpl";import x from"@noble/curves/abstract/utils";import _ from"@noble/curves/ed25519";import{Keypair as H}from"@stellar/stellar-sdk";import{serializeSignDoc as I}from"@cosmjs/amino";function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},v.apply(null,arguments)}var S;!function(e){e.P2WPKH="p2wpkh",e.P2SH_P2WPKH="p2sh(p2wpkh)"}(S||(S={}));const D={bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc",isTestnet:!1},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc",isTestnet:!1},litecoin:{messagePrefix:"Litecoin Signed Message:\n",pubKeyHashVersion:48,scriptHashVersion:50,bech32Prefix:"ltc",isTestnet:!1},dogecoin:{messagePrefix:"Dogecoin Signed Message:\n",pubKeyHashVersion:30,scriptHashVersion:22,isTestnet:!1},dash:{messagePrefix:"DarkCoin Signed Message:\n",pubKeyHashVersion:76,scriptHashVersion:16,isTestnet:!1},zcash:{messagePrefix:"Zcash Signed Message:\n",pubKeyHashVersion:Uint8Array.from([28,184]),scriptHashVersion:Uint8Array.from([28,189]),isTestnet:!1},testnet:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:111,scriptHashVersion:196,bech32Prefix:"tb",isTestnet:!0}};var L;function P(t,r){const{attestation:n,proof:s}=r;return v({},r,{status:A.verifySignature(t,n,s)?e.VERIFIED:e.FAILED})}function B(t,n,s){const o=function(e){if(e.match("^(bc1|tb1|ltc1).*"))return L.NATIVE;if(e.match("^[32M].*"))return L.SEGWIT;if(e.match("^[1nmL].*"))return L.LEGACY;if(e.match("^(D).*"))return L.DOGECOIN;if(e.match("^(q).*"))return L.BCH;if(e.match("^(t1|t3).*"))return L.LEGACY;if(e.match("^[X7].*"))return L.LEGACY;throw new Error("INVALID ADDRESS: ".concat(e).concat(" is not a valid or a supported address"))}(t),c=Boolean(s.bech32Prefix&&(o===L.NATIVE||o===L.SEGWIT&&!t.startsWith("1"))),u=function(e,t,n,s,o){const{compressed:c,segwitType:u,signature:h}=function(e){const t=i.decode(e);if(65!==t.length)throw new Error("Invalid signature length");const r=t[0]-27;if(r>15||r<0)throw new Error("Invalid signature parameter");const n=!!(12&r),s=3&r,o=g.Signature.fromCompact(t.slice(1));return{compressed:n,segwitType:8&r?4&r?S.P2WPKH:S.P2SH_P2WPKH:void 0,signature:o.addRecoveryBit(s)}}(n);if(s&&!c)throw new Error("checkSegwitAlways can only be used with a compressed pubkey signature flagbyte");const d=function(e,t){const n=(new TextEncoder).encode(t),s=(new TextEncoder).encode(e),o=r(s.length).buffer,i=new Uint8Array(n.length+o.byteLength+s.length);return i.set(n),i.set(new Uint8Array(o),n.length),i.set(s,n.length+o.byteLength),function(e){return a.sha256(a.sha256(e))}(i)}(e,o.messagePrefix),f=k(h.recoverPublicKey(d).toRawBytes(c));let l="";if(t.startsWith("q"))return l=V(o.pubKeyHashVersion,f),l.startsWith("1");if(u)l=u===S.P2SH_P2WPKH?V(o.scriptHashVersion,f):o.bech32Prefix?C(f,o.bech32Prefix):V(o.scriptHashVersion,f);else if(t.startsWith("3")&&!u){const e=new Uint8Array(22);e[0]=0,e[1]=20,e.set(f,2);const r=k(e),n=V(o.scriptHashVersion,r),s=V(o.scriptHashVersion,f);if(t===n||t===s)return!0;l=s}else if(s&&o.bech32Prefix)try{l=C(f,o.bech32Prefix)}catch(e){l=V(o.scriptHashVersion,f)}else l=V(o.pubKeyHashVersion,f);return l===t}(n.attestation,t,n.proof,c,s);return v({},n,{status:u?e.VERIFIED:e.FAILED})}!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"}(L||(L={}));const U=s(a.sha256);function V(e,t){const r="number"==typeof e?Uint8Array.of(e):e,n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),U.encode(n)}function C(e,t="bc"){const r=o.toWords(e);return r.unshift(0),o.encode(t,r)}function k(e){return a.ripemd160(a.sha256(e))}function F(e,t){const r=[];let n=t;for(;n<e.length&&null!=(s=e[n])&&s.startsWith("- ");){var s;r.push(e[n].substring(2)),n++}return r}function O(e,t,r){try{const s=(n=h.fromString(t),a.keccak256(function(e){const t=h.from(e);return h.concat("0x19",h.fromString("TRON Signed Message:\n"+h.size(t)),t)}(n))),o=d.fromHex(r),i=f.recoverPublicKey({payload:s,signature:o}),u=`0x41${a.keccak256(`0x${p.toHex(i).slice(4)}`).substring(26)}`,l=y.from(u),b=y.from(a.sha256(a.sha256(u))).slice(0,4),g=y.concat(l,b);return c.encode(g)===e}catch(e){return!1}var n}var T="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function M(e){var t={exports:{}};return e(t,t.exports),t.exports}var K=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0}),j=M(function(e,t){function r(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function n(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function s(e,...t){if(!r(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function o(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function i(e){for(let t=0;t<e.length;t++)e[t]=o(e[t]);return e}Object.defineProperty(t,"__esModule",{value:!0}),t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.Hash=t.nextTick=t.swap32IfBE=t.byteSwapIfBE=t.swap8IfBE=t.isLE=void 0,t.isBytes=r,t.anumber=n,t.abytes=s,t.ahash=function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");n(e.outputLen),n(e.blockLen)},t.aexists=function(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")},t.aoutput=function(e,t){s(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)},t.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.createView=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)},t.rotr=function(e,t){return e<<32-t|e>>>t},t.rotl=function(e,t){return e<<t|e>>>32-t>>>0},t.byteSwap=o,t.byteSwap32=i,t.bytesToHex=function(e){if(s(e),c)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=a[e[r]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(c)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,s=0;t<r;t++,s+=2){const r=h(e.charCodeAt(s)),o=h(e.charCodeAt(s+1));if(void 0===r||void 0===o)throw new Error('hex string expected, got non-hex character "'+(e[s]+e[s+1])+'" at index '+s);n[t]=16*r+o}return n},t.asyncLoop=async function(e,r,n){let s=Date.now();for(let o=0;o<e;o++){n(o);const e=Date.now()-s;e>=0&&e<r||(await(0,t.nextTick)(),s+=e)}},t.utf8ToBytes=d,t.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},t.toBytes=f,t.kdfInputToBytes=function(e){return"string"==typeof e&&(e=d(e)),s(e),e},t.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];s(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const s=e[t];r.set(s,n),n+=s.length}return r},t.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("options should be object or undefined");return Object.assign(e,t)},t.createHasher=l,t.createOptHasher=p,t.createXOFer=y,t.randomBytes=function(e=32){if(K.crypto&&"function"==typeof K.crypto.getRandomValues)return K.crypto.getRandomValues(new Uint8Array(e));if(K.crypto&&"function"==typeof K.crypto.randomBytes)return Uint8Array.from(K.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")},t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],t.swap8IfBE=t.isLE?e=>e:e=>o(e),t.byteSwapIfBE=t.swap8IfBE,t.swap32IfBE=t.isLE?e=>e:i;const c=/* @__PURE__ */(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),a=/* @__PURE__ */Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),u={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(e){return e>=u._0&&e<=u._9?e-u._0:e>=u.A&&e<=u.F?e-(u.A-10):e>=u.a&&e<=u.f?e-(u.a-10):void 0}function d(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function f(e){return"string"==typeof e&&(e=d(e)),s(e),e}function l(e){const t=t=>e().update(f(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function p(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}function y(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}t.nextTick=async()=>{},t.Hash=class{},t.wrapConstructor=l,t.wrapConstructorWithOpts=p,t.wrapXOFConstructorWithOpts=y}),N=j,R=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.equal=t.concat=t.HEX_REGEX=void 0,t.HEX_REGEX=/^[A-F0-9]*$/iu,t.concat=function(e){return(0,N.concatBytes)(...e)},t.equal=function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Int8Array(e),n=new Int8Array(t);for(let t=0;t!==e.byteLength;t++)if(r[t]!==n[t])return!1;return!0}}),W=M(function(e,t){var r=T&&T.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=T&&T.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.randomBytes=t.stringToHex=t.hexToString=t.hexToBytes=t.bytesToHex=void 0,t.bytesToHex=e=>(0,N.bytesToHex)(e instanceof Uint8Array?e:Uint8Array.from(e)).toUpperCase(),t.hexToBytes=e=>{const t=new Uint8Array(e.length/2);if(!R.HEX_REGEX.test(e))throw new Error("Invalid hex string");for(let r=0;r<t.length;r++){const n=2*r,s=e.slice(n,n+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t},t.hexToString=(e,r="utf8")=>new TextDecoder(r).decode((0,t.hexToBytes)(e)),t.stringToHex=e=>(0,t.bytesToHex)((new TextEncoder).encode(e)),t.randomBytes=N.randomBytes,n(R,t)}),G=M(function(e,t){function r(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const s=BigInt(32),o=BigInt(4294967295),i=Number(r>>s&o),c=Number(r&o),a=n?0:4;e.setUint32(t+(n?4:0),i,n),e.setUint32(t+a,c,n)}Object.defineProperty(t,"__esModule",{value:!0}),t.SHA512_IV=t.SHA384_IV=t.SHA224_IV=t.SHA256_IV=t.HashMD=void 0,t.setBigUint64=r,t.Chi=function(e,t,r){return e&t^~e&r},t.Maj=function(e,t,r){return e&t^e&r^t&r},t.HashMD=class extends N.Hash{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=(0,N.createView)(this.buffer)}update(e){(0,N.aexists)(this),e=(0,N.toBytes)(e),(0,N.abytes)(e);const{view:t,buffer:r,blockLen:n}=this,s=e.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);if(i===n){const t=(0,N.createView)(e);for(;n<=s-o;o+=n)this.process(t,o);continue}r.set(e.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,N.aexists)(this),(0,N.aoutput)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:o}=this;let{pos:i}=this;t[i++]=128,(0,N.clean)(this.buffer.subarray(i)),this.padOffset>s-i&&(this.process(n,0),i=0);for(let e=i;e<s;e++)t[e]=0;r(n,s-8,BigInt(8*this.length),o),this.process(n,0);const c=(0,N.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)c.setUint32(4*e,h[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:s,destroyed:o,pos:i}=this;return e.destroyed=o,e.finished=s,e.length=n,e.pos=i,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}},t.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),t.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),t.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),t.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])}),$=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.toBig=t.shrSL=t.shrSH=t.rotrSL=t.rotrSH=t.rotrBL=t.rotrBH=t.rotr32L=t.rotr32H=t.rotlSL=t.rotlSH=t.rotlBL=t.rotlBH=t.add5L=t.add5H=t.add4L=t.add4H=t.add3L=t.add3H=void 0,t.add=m,t.fromBig=s,t.split=o;const r=/* @__PURE__ */BigInt(2**32-1),n=/* @__PURE__ */BigInt(32);function s(e,t=!1){return t?{h:Number(e&r),l:Number(e>>n&r)}:{h:0|Number(e>>n&r),l:0|Number(e&r)}}function o(e,t=!1){const r=e.length;let n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){const{h:r,l:c}=s(e[i],t);[n[i],o[i]]=[r,c]}return[n,o]}const i=(e,t)=>BigInt(e>>>0)<<n|BigInt(t>>>0);t.toBig=i;const c=(e,t,r)=>e>>>r;t.shrSH=c;const a=(e,t,r)=>e<<32-r|t>>>r;t.shrSL=a;const u=(e,t,r)=>e>>>r|t<<32-r;t.rotrSH=u;const h=(e,t,r)=>e<<32-r|t>>>r;t.rotrSL=h;const d=(e,t,r)=>e<<64-r|t>>>r-32;t.rotrBH=d;const f=(e,t,r)=>e>>>r-32|t<<64-r;t.rotrBL=f;const l=(e,t)=>t;t.rotr32H=l;const p=(e,t)=>e;t.rotr32L=p;const y=(e,t,r)=>e<<r|t>>>32-r;t.rotlSH=y;const b=(e,t,r)=>t<<r|e>>>32-r;t.rotlSL=b;const g=(e,t,r)=>t<<r-32|e>>>64-r;t.rotlBH=g;const A=(e,t,r)=>e<<r-32|t>>>64-r;function m(e,t,r,n){const s=(t>>>0)+(n>>>0);return{h:e+r+(s/2**32|0)|0,l:0|s}}t.rotlBL=A;const w=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);t.add3L=w;const E=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;t.add3H=E;const x=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);t.add4L=x;const _=(e,t,r,n,s)=>t+r+n+s+(e/2**32|0)|0;t.add4H=_;const H=(e,t,r,n,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(s>>>0);t.add5L=H;const I=(e,t,r,n,s,o)=>t+r+n+s+o+(e/2**32|0)|0;t.add5H=I,t.default={fromBig:s,split:o,toBig:i,shrSH:c,shrSL:a,rotrSH:u,rotrSL:h,rotrBH:d,rotrBL:f,rotr32H:l,rotr32L:p,rotlSH:y,rotlSL:b,rotlBH:g,rotlBL:A,add:m,add3L:w,add3H:E,add4L:x,add4H:_,add5H:I,add5L:H}}),X=G,q=$,z=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_224=t.sha512_256=t.sha384=t.sha512=t.sha224=t.sha256=t.SHA512_256=t.SHA512_224=t.SHA384=t.SHA512=t.SHA224=t.SHA256=void 0;const r=/* @__PURE__ */Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),n=/* @__PURE__ */new Uint32Array(64);class s extends X.HashMD{constructor(e=32){super(64,e,8,!1),this.A=0|X.SHA256_IV[0],this.B=0|X.SHA256_IV[1],this.C=0|X.SHA256_IV[2],this.D=0|X.SHA256_IV[3],this.E=0|X.SHA256_IV[4],this.F=0|X.SHA256_IV[5],this.G=0|X.SHA256_IV[6],this.H=0|X.SHA256_IV[7]}get(){const{A:e,B:t,C:r,D:n,E:s,F:o,G:i,H:c}=this;return[e,t,r,n,s,o,i,c]}set(e,t,r,n,s,o,i,c){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|s,this.F=0|o,this.G=0|i,this.H=0|c}process(e,t){for(let r=0;r<16;r++,t+=4)n[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=n[e-15],r=n[e-2],s=(0,N.rotr)(t,7)^(0,N.rotr)(t,18)^t>>>3,o=(0,N.rotr)(r,17)^(0,N.rotr)(r,19)^r>>>10;n[e]=o+n[e-7]+s+n[e-16]|0}let{A:s,B:o,C:i,D:c,E:a,F:u,G:h,H:d}=this;for(let e=0;e<64;e++){const t=d+((0,N.rotr)(a,6)^(0,N.rotr)(a,11)^(0,N.rotr)(a,25))+(0,X.Chi)(a,u,h)+r[e]+n[e]|0,f=((0,N.rotr)(s,2)^(0,N.rotr)(s,13)^(0,N.rotr)(s,22))+(0,X.Maj)(s,o,i)|0;d=h,h=u,u=a,a=c+t|0,c=i,i=o,o=s,s=t+f|0}s=s+this.A|0,o=o+this.B|0,i=i+this.C|0,c=c+this.D|0,a=a+this.E|0,u=u+this.F|0,h=h+this.G|0,d=d+this.H|0,this.set(s,o,i,c,a,u,h,d)}roundClean(){(0,N.clean)(n)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,N.clean)(this.buffer)}}t.SHA256=s;class o extends s{constructor(){super(28),this.A=0|X.SHA224_IV[0],this.B=0|X.SHA224_IV[1],this.C=0|X.SHA224_IV[2],this.D=0|X.SHA224_IV[3],this.E=0|X.SHA224_IV[4],this.F=0|X.SHA224_IV[5],this.G=0|X.SHA224_IV[6],this.H=0|X.SHA224_IV[7]}}t.SHA224=o;const i=/* @__PURE__ */(()=>q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),c=/* @__PURE__ */(()=>i[0])(),a=/* @__PURE__ */(()=>i[1])(),u=/* @__PURE__ */new Uint32Array(80),h=/* @__PURE__ */new Uint32Array(80);class d extends X.HashMD{constructor(e=64){super(128,e,16,!1),this.Ah=0|X.SHA512_IV[0],this.Al=0|X.SHA512_IV[1],this.Bh=0|X.SHA512_IV[2],this.Bl=0|X.SHA512_IV[3],this.Ch=0|X.SHA512_IV[4],this.Cl=0|X.SHA512_IV[5],this.Dh=0|X.SHA512_IV[6],this.Dl=0|X.SHA512_IV[7],this.Eh=0|X.SHA512_IV[8],this.El=0|X.SHA512_IV[9],this.Fh=0|X.SHA512_IV[10],this.Fl=0|X.SHA512_IV[11],this.Gh=0|X.SHA512_IV[12],this.Gl=0|X.SHA512_IV[13],this.Hh=0|X.SHA512_IV[14],this.Hl=0|X.SHA512_IV[15]}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:s,Cl:o,Dh:i,Dl:c,Eh:a,El:u,Fh:h,Fl:d,Gh:f,Gl:l,Hh:p,Hl:y}=this;return[e,t,r,n,s,o,i,c,a,u,h,d,f,l,p,y]}set(e,t,r,n,s,o,i,c,a,u,h,d,f,l,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|s,this.Cl=0|o,this.Dh=0|i,this.Dl=0|c,this.Eh=0|a,this.El=0|u,this.Fh=0|h,this.Fl=0|d,this.Gh=0|f,this.Gl=0|l,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let r=0;r<16;r++,t+=4)u[r]=e.getUint32(t),h[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|u[e-15],r=0|h[e-15],n=q.rotrSH(t,r,1)^q.rotrSH(t,r,8)^q.shrSH(t,r,7),s=q.rotrSL(t,r,1)^q.rotrSL(t,r,8)^q.shrSL(t,r,7),o=0|u[e-2],i=0|h[e-2],c=q.rotrSH(o,i,19)^q.rotrBH(o,i,61)^q.shrSH(o,i,6),a=q.rotrSL(o,i,19)^q.rotrBL(o,i,61)^q.shrSL(o,i,6),d=q.add4L(s,a,h[e-7],h[e-16]),f=q.add4H(d,n,c,u[e-7],u[e-16]);u[e]=0|f,h[e]=0|d}let{Ah:r,Al:n,Bh:s,Bl:o,Ch:i,Cl:d,Dh:f,Dl:l,Eh:p,El:y,Fh:b,Fl:g,Gh:A,Gl:m,Hh:w,Hl:E}=this;for(let e=0;e<80;e++){const t=q.rotrSH(p,y,14)^q.rotrSH(p,y,18)^q.rotrBH(p,y,41),x=q.rotrSL(p,y,14)^q.rotrSL(p,y,18)^q.rotrBL(p,y,41),_=p&b^~p&A,H=q.add5L(E,x,y&g^~y&m,a[e],h[e]),I=q.add5H(H,w,t,_,c[e],u[e]),v=0|H,S=q.rotrSH(r,n,28)^q.rotrBH(r,n,34)^q.rotrBH(r,n,39),D=q.rotrSL(r,n,28)^q.rotrBL(r,n,34)^q.rotrBL(r,n,39),L=r&s^r&i^s&i,P=n&o^n&d^o&d;w=0|A,E=0|m,A=0|b,m=0|g,b=0|p,g=0|y,({h:p,l:y}=q.add(0|f,0|l,0|I,0|v)),f=0|i,l=0|d,i=0|s,d=0|o,s=0|r,o=0|n;const B=q.add3L(v,D,P);r=q.add3H(B,I,S,L),n=0|B}({h:r,l:n}=q.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:s,l:o}=q.add(0|this.Bh,0|this.Bl,0|s,0|o)),({h:i,l:d}=q.add(0|this.Ch,0|this.Cl,0|i,0|d)),({h:f,l}=q.add(0|this.Dh,0|this.Dl,0|f,0|l)),({h:p,l:y}=q.add(0|this.Eh,0|this.El,0|p,0|y)),({h:b,l:g}=q.add(0|this.Fh,0|this.Fl,0|b,0|g)),({h:A,l:m}=q.add(0|this.Gh,0|this.Gl,0|A,0|m)),({h:w,l:E}=q.add(0|this.Hh,0|this.Hl,0|w,0|E)),this.set(r,n,s,o,i,d,f,l,p,y,b,g,A,m,w,E)}roundClean(){(0,N.clean)(u,h)}destroy(){(0,N.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=d;class f extends d{constructor(){super(48),this.Ah=0|X.SHA384_IV[0],this.Al=0|X.SHA384_IV[1],this.Bh=0|X.SHA384_IV[2],this.Bl=0|X.SHA384_IV[3],this.Ch=0|X.SHA384_IV[4],this.Cl=0|X.SHA384_IV[5],this.Dh=0|X.SHA384_IV[6],this.Dl=0|X.SHA384_IV[7],this.Eh=0|X.SHA384_IV[8],this.El=0|X.SHA384_IV[9],this.Fh=0|X.SHA384_IV[10],this.Fl=0|X.SHA384_IV[11],this.Gh=0|X.SHA384_IV[12],this.Gl=0|X.SHA384_IV[13],this.Hh=0|X.SHA384_IV[14],this.Hl=0|X.SHA384_IV[15]}}t.SHA384=f;const l=/* @__PURE__ */Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),p=/* @__PURE__ */Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class y extends d{constructor(){super(28),this.Ah=0|l[0],this.Al=0|l[1],this.Bh=0|l[2],this.Bl=0|l[3],this.Ch=0|l[4],this.Cl=0|l[5],this.Dh=0|l[6],this.Dl=0|l[7],this.Eh=0|l[8],this.El=0|l[9],this.Fh=0|l[10],this.Fl=0|l[11],this.Gh=0|l[12],this.Gl=0|l[13],this.Hh=0|l[14],this.Hl=0|l[15]}}t.SHA512_224=y;class b extends d{constructor(){super(32),this.Ah=0|p[0],this.Al=0|p[1],this.Bh=0|p[2],this.Bl=0|p[3],this.Ch=0|p[4],this.Cl=0|p[5],this.Dh=0|p[6],this.Dl=0|p[7],this.Eh=0|p[8],this.El=0|p[9],this.Fh=0|p[10],this.Fl=0|p[11],this.Gh=0|p[12],this.Gl=0|p[13],this.Hh=0|p[14],this.Hl=0|p[15]}}t.SHA512_256=b,t.sha256=(0,N.createHasher)(()=>new s),t.sha224=(0,N.createHasher)(()=>new o),t.sha512=(0,N.createHasher)(()=>new d),t.sha384=(0,N.createHasher)(()=>new f),t.sha512_256=(0,N.createHasher)(()=>new b),t.sha512_224=(0,N.createHasher)(()=>new y)}),Y=z,Z=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.SHA224=t.sha256=t.SHA256=void 0,t.SHA256=Y.SHA256,t.sha256=Y.sha256,t.SHA224=Y.SHA224,t.sha224=Y.sha224});const J=(T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(/*#__PURE__*/Object.defineProperty({default:function(e){return Array.isArray(e)?new Uint8Array(e):e}},"__esModule",{value:!0}));var Q=/*#__PURE__*/Object.defineProperty({default:function(e){function t(t){return e((0,J.default)(t))}return t.create=()=>{const t=e.create();return{update(e){return t.update((0,J.default)(e)),this},digest:()=>t.digest()}},t}},"__esModule",{value:!0}),ee=Z,te=M(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sha256=void 0;const n=r(Q);t.sha256=(0,n.default)(ee.sha256)}),re=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.concatArgs=t.arrayEqual=void 0,t.arrayEqual=function(e,t){return e.length===t.length&&e.every((e,r)=>e===t[r])},t.concatArgs=function(...e){return e.flatMap(e=>"number"==typeof e?[e]:Array.from(e))}}),ne=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidClassicAddress=t.decodeAccountPublic=t.encodeAccountPublic=t.encodeNodePublic=t.decodeNodePublic=t.decodeAddress=t.decodeAccountID=t.encodeAddress=t.encodeAccountID=t.decodeSeed=t.encodeSeed=t.codec=void 0;const r=[1,225,75],s={sha256:te.sha256},o=new class{constructor(e){this._sha256=e.sha256,this._codec=n.base58xrp}encode(e,t){return this._encodeVersioned(e,t.versions,t.expectedLength)}decode(e,t){var r;const n=t.versions,s=t.versionTypes,o=this.decodeChecked(e);if(n.length>1&&!t.expectedLength)throw new Error("expectedLength is required because there are >= 2 possible versions");const i=null!==(r=t.expectedLength)&&void 0!==r?r:o.length-("number"==typeof n[0]?1:n[0].length),c=o.slice(0,-i),a=o.slice(-i);for(let e=0;e<n.length;e++){const t=Array.isArray(n[e])?n[e]:[n[e]];if((0,re.arrayEqual)(c,t))return{version:t,bytes:a,type:s?s[e]:null}}throw new Error("version_invalid: version bytes do not match any of the provided version(s)")}encodeChecked(e){const t=this._sha256(this._sha256(e)).slice(0,4);return this._encodeRaw(Uint8Array.from((0,re.concatArgs)(e,t)))}decodeChecked(e){const t=this._decodeRaw(e);if(t.byteLength<5)throw new Error("invalid_input_size: decoded data must have length >= 5");if(!this._verifyCheckSum(t))throw new Error("checksum_invalid");return t.slice(0,-4)}_encodeVersioned(e,t,r){if(!a(e,r))throw new Error("unexpected_payload_length: bytes.length does not match expectedLength. Ensure that the bytes are a Uint8Array.");return this.encodeChecked((0,re.concatArgs)(t,e))}_encodeRaw(e){return this._codec.encode(Uint8Array.from(e))}_decodeRaw(e){return this._codec.decode(e)}_verifyCheckSum(e){const t=this._sha256(this._sha256(e.slice(0,-4))).slice(0,4),r=e.slice(-4);return(0,re.arrayEqual)(t,r)}}(s);function i(e){return o.encode(e,{versions:[0],expectedLength:20})}function c(e){return o.decode(e,{versions:[0],expectedLength:20}).bytes}function a(e,t){return"byteLength"in e?e.byteLength===t:e.length===t}t.codec=o,t.encodeSeed=function(e,t){if(!a(e,16))throw new Error("entropy must have length 16");return o.encode(e,{expectedLength:16,versions:"ed25519"===t?r:[33]})},t.decodeSeed=function(e,t={versionTypes:["ed25519","secp256k1"],versions:[r,33],expectedLength:16}){return o.decode(e,t)},t.encodeAccountID=i,t.encodeAddress=i,t.decodeAccountID=c,t.decodeAddress=c,t.decodeNodePublic=function(e){return o.decode(e,{versions:[28],expectedLength:33}).bytes},t.encodeNodePublic=function(e){return o.encode(e,{versions:[28],expectedLength:33})},t.encodeAccountPublic=function(e){return o.encode(e,{versions:[35],expectedLength:33})},t.decodeAccountPublic=function(e){return o.decode(e,{versions:[35],expectedLength:33}).bytes},t.isValidClassicAddress=function(e){try{c(e)}catch(e){return!1}return!0}}),se=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidXAddress=t.decodeXAddress=t.xAddressToClassicAddress=t.encodeXAddress=t.classicAddressToXAddress=t.isValidClassicAddress=t.decodeAccountPublic=t.encodeAccountPublic=t.decodeNodePublic=t.encodeNodePublic=t.decodeAccountID=t.encodeAccountID=t.decodeSeed=t.encodeSeed=t.codec=void 0,Object.defineProperty(t,"codec",{enumerable:!0,get:function(){return ne.codec}}),Object.defineProperty(t,"encodeSeed",{enumerable:!0,get:function(){return ne.encodeSeed}}),Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return ne.decodeSeed}}),Object.defineProperty(t,"encodeAccountID",{enumerable:!0,get:function(){return ne.encodeAccountID}}),Object.defineProperty(t,"decodeAccountID",{enumerable:!0,get:function(){return ne.decodeAccountID}}),Object.defineProperty(t,"encodeNodePublic",{enumerable:!0,get:function(){return ne.encodeNodePublic}}),Object.defineProperty(t,"decodeNodePublic",{enumerable:!0,get:function(){return ne.decodeNodePublic}}),Object.defineProperty(t,"encodeAccountPublic",{enumerable:!0,get:function(){return ne.encodeAccountPublic}}),Object.defineProperty(t,"decodeAccountPublic",{enumerable:!0,get:function(){return ne.decodeAccountPublic}}),Object.defineProperty(t,"isValidClassicAddress",{enumerable:!0,get:function(){return ne.isValidClassicAddress}});const r={main:Uint8Array.from([5,68]),test:Uint8Array.from([4,147])};function n(e,t,n){if(20!==e.length)throw new Error("Account ID must be 20 bytes");if(!1!==t&&t>4294967295)throw new Error("Invalid tag");const s=t||0,o=(0,W.concat)([n?r.test:r.main,e,Uint8Array.from([!1===t||null==t?0:1,255&s,s>>8&255,s>>16&255,s>>24&255,0,0,0,0])]);return ne.codec.encodeChecked(o)}function s(e){const t=ne.codec.decodeChecked(e),n=function(e){const t=e.slice(0,2);if((0,W.equal)(r.main,t))return!1;if((0,W.equal)(r.test,t))return!0;throw new Error("Invalid X-address: bad prefix")}(t);return{accountId:t.slice(2,22),tag:function(e){const t=e[22];if(t>=2)throw new Error("Unsupported X-address");if(1===t)return e[23]+256*e[24]+65536*e[25]+16777216*e[26];if(0!==t)throw new Error("flag must be zero to indicate no tag");if(!(0,W.equal)((0,W.hexToBytes)("0000000000000000"),e.slice(23,31)))throw new Error("remaining bytes must be zero");return!1}(t),test:n}}t.classicAddressToXAddress=function(e,t,r){return n((0,ne.decodeAccountID)(e),t,r)},t.encodeXAddress=n,t.xAddressToClassicAddress=function(e){const{accountId:t,tag:r,test:n}=s(e);return{classicAddress:(0,ne.encodeAccountID)(t),tag:r,test:n}},t.decodeXAddress=s,t.isValidXAddress=function(e){try{s(e)}catch(e){return!1}return!0}}),oe=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=t.md5=t.MD5=t.sha1=t.SHA1=void 0;const r=/* @__PURE__ */Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),n=/* @__PURE__ */new Uint32Array(80);class s extends X.HashMD{constructor(){super(64,20,8,!1),this.A=0|r[0],this.B=0|r[1],this.C=0|r[2],this.D=0|r[3],this.E=0|r[4]}get(){const{A:e,B:t,C:r,D:n,E:s}=this;return[e,t,r,n,s]}set(e,t,r,n,s){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)n[r]=e.getUint32(t,!1);for(let e=16;e<80;e++)n[e]=(0,N.rotl)(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let{A:r,B:s,C:o,D:i,E:c}=this;for(let e=0;e<80;e++){let t,a;e<20?(t=(0,X.Chi)(s,o,i),a=1518500249):e<40?(t=s^o^i,a=1859775393):e<60?(t=(0,X.Maj)(s,o,i),a=2400959708):(t=s^o^i,a=3395469782);const u=(0,N.rotl)(r,5)+t+c+a+n[e]|0;c=i,i=o,o=(0,N.rotl)(s,30),s=r,r=u}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,c=c+this.E|0,this.set(r,s,o,i,c)}roundClean(){(0,N.clean)(n)}destroy(){this.set(0,0,0,0,0),(0,N.clean)(this.buffer)}}t.SHA1=s,t.sha1=(0,N.createHasher)(()=>new s);const o=/* @__PURE__ */Math.pow(2,32),i=/* @__PURE__ */Array.from({length:64},(e,t)=>Math.floor(o*Math.abs(Math.sin(t+1)))),c=/* @__PURE__ */r.slice(0,4),a=/* @__PURE__ */new Uint32Array(16);class u extends X.HashMD{constructor(){super(64,16,8,!0),this.A=0|c[0],this.B=0|c[1],this.C=0|c[2],this.D=0|c[3]}get(){const{A:e,B:t,C:r,D:n}=this;return[e,t,r,n]}set(e,t,r,n){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n}process(e,t){for(let r=0;r<16;r++,t+=4)a[r]=e.getUint32(t,!0);let{A:r,B:n,C:s,D:o}=this;for(let e=0;e<64;e++){let t,c,u;e<16?(t=(0,X.Chi)(n,s,o),c=e,u=[7,12,17,22]):e<32?(t=(0,X.Chi)(o,n,s),c=(5*e+1)%16,u=[5,9,14,20]):e<48?(t=n^s^o,c=(3*e+5)%16,u=[4,11,16,23]):(t=s^(n|~o),c=7*e%16,u=[6,10,15,21]),t=t+r+i[e]+a[c],r=o,o=s,s=n,n+=(0,N.rotl)(t,u[e%4])}r=r+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,this.set(r,n,s,o)}roundClean(){(0,N.clean)(a)}destroy(){this.set(0,0,0,0),(0,N.clean)(this.buffer)}}t.MD5=u,t.md5=(0,N.createHasher)(()=>new u);const h=/* @__PURE__ */Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),d=/* @__PURE__ */(()=>Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)))(),f=/* @__PURE__ */(()=>d.map(e=>(9*e+5)%16))(),l=/* @__PURE__ */(()=>{const e=[[d],[f]];for(let t=0;t<4;t++)for(let r of e)r.push(r[t].map(e=>h[e]));return e})(),p=/* @__PURE__ */(()=>l[0])(),y=/* @__PURE__ */(()=>l[1])(),b=/* @__PURE__ */[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),g=/* @__PURE__ */p.map((e,t)=>e.map(e=>b[t][e])),A=/* @__PURE__ */y.map((e,t)=>e.map(e=>b[t][e])),m=/* @__PURE__ */Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),w=/* @__PURE__ */Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function E(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const x=/* @__PURE__ */new Uint32Array(16);class _ extends X.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:r,h3:n,h4:s}=this;return[e,t,r,n,s]}set(e,t,r,n,s){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)x[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,s=0|this.h1,o=s,i=0|this.h2,c=i,a=0|this.h3,u=a,h=0|this.h4,d=h;for(let e=0;e<5;e++){const t=4-e,f=m[e],l=w[e],b=p[e],_=y[e],H=g[e],I=A[e];for(let t=0;t<16;t++){const n=(0,N.rotl)(r+E(e,s,i,a)+x[b[t]]+f,H[t])+h|0;r=h,h=a,a=0|(0,N.rotl)(i,10),i=s,s=n}for(let e=0;e<16;e++){const r=(0,N.rotl)(n+E(t,o,c,u)+x[_[e]]+l,I[e])+d|0;n=d,d=u,u=0|(0,N.rotl)(c,10),c=o,o=r}}this.set(this.h1+i+u|0,this.h2+a+d|0,this.h3+h+n|0,this.h4+r+o|0,this.h0+s+c|0)}roundClean(){(0,N.clean)(x)}destroy(){this.destroyed=!0,(0,N.clean)(this.buffer),this.set(0,0,0,0,0)}}t.RIPEMD160=_,t.ripemd160=(0,N.createHasher)(()=>new _)}),ie=oe,ce=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=void 0,t.RIPEMD160=ie.RIPEMD160,t.ripemd160=ie.ripemd160}),ae=M(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=void 0;const n=r(Q);t.ripemd160=(0,n.default)(ce.ripemd160)}),ue=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_256=t.SHA512_256=t.sha512_224=t.SHA512_224=t.sha384=t.SHA384=t.sha512=t.SHA512=void 0,t.SHA512=Y.SHA512,t.sha512=Y.sha512,t.SHA384=Y.SHA384,t.sha384=Y.sha384,t.SHA512_224=Y.SHA512_224,t.sha512_224=Y.sha512_224,t.SHA512_256=Y.SHA512_256,t.sha512_256=Y.sha512_256}),he=M(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sha512=void 0;const n=r(Q);t.sha512=(0,n.default)(ue.sha512)});class de{constructor(){this.hash=he.sha512.create()}static half(e){return(new de).add(e).first256()}add(e){return this.hash.update(e),this}addU32(e){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),this.add(t)}finish(){return this.hash.digest()}first256(){return this.finish().slice(0,32)}first256BigInt(){return(0,x.bytesToNumberBE)(this.first256())}}var fe=/*#__PURE__*/Object.defineProperty({default:de},"__esModule",{value:!0}),le=M(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.accountPublicFromPublicGenerator=t.derivePrivateKey=void 0;const n=r(fe),s=BigInt(0);function o(e,t){const r=b.secp256k1.CURVE.n;for(let o=0;o<=4294967295;o++){const i=(new n.default).add(e);void 0!==t&&i.addU32(t),i.addU32(o);const c=i.first256BigInt();if(c>s&&c<r)return c}throw new Error("impossible unicorn ;)")}t.derivePrivateKey=function(e,t={}){const r=t.validator,n=b.secp256k1.CURVE.n,s=o(e);return r?s:(o(b.secp256k1.ProjectivePoint.BASE.multiply(s).toRawBytes(!0),t.accountIndex||0)+s)%n},t.accountPublicFromPublicGenerator=function(e){const t=b.secp256k1.ProjectivePoint.fromHex(e),r=o(e,0),n=b.secp256k1.ProjectivePoint.BASE.multiply(r);return t.add(n).toRawBytes(!0)}}),pe=/*#__PURE__*/Object.defineProperty({default:{ok(e,t){if(!e)throw new Error(t)}}},"__esModule",{value:!0}),ye=M(function(e,t){var r;Object.defineProperty(t,"__esModule",{value:!0}),t.getAlgorithmFromPrivateKey=t.getAlgorithmFromPublicKey=t.getAlgorithmFromKey=void 0,function(e){e[e.NONE=-1]="NONE",e[e.ED25519=237]="ED25519",e[e.SECP256K1_PUB_X=2]="SECP256K1_PUB_X",e[e.SECP256K1_PUB_X_ODD_Y=3]="SECP256K1_PUB_X_ODD_Y",e[e.SECP256K1_PUB_XY=4]="SECP256K1_PUB_XY",e[e.SECP256K1_PRIVATE=0]="SECP256K1_PRIVATE"}(r||(r={}));const n={[`private_${r.NONE}_32`]:"ecdsa-secp256k1",[`private_${r.SECP256K1_PRIVATE}_33`]:"ecdsa-secp256k1",[`private_${r.ED25519}_33`]:"ed25519",[`public_${r.ED25519}_33`]:"ed25519",[`public_${r.SECP256K1_PUB_X}_33`]:"ecdsa-secp256k1",[`public_${r.SECP256K1_PUB_X_ODD_Y}_33`]:"ecdsa-secp256k1",[`public_${r.SECP256K1_PUB_XY}_65`]:"ecdsa-secp256k1"};function s(e){return e===r.NONE?"None":`0x${e.toString(16).padStart(2,"0")}`}function o(e,t){const{prefix:o,len:i}=function(e){return{prefix:e.length<2?r.NONE:parseInt(e.slice(0,2),16),len:e.length/2}}(e),c="private"===t&&32===i?r.NONE:o,a=n[`${t}_${c}_${i}`];if(!a)throw new Error(function({key:e,type:t,prefix:r,len:o}){const i=function(e){return Object.entries(n).filter(([t])=>t.startsWith(e)).map(([e,t])=>{const[,r,n]=e.split("_");return`${t.padEnd(17)} - Prefix: ${s(Number(r)).padEnd(6)} Length: ${n} bytes`}).join("\n")}(t);return`invalid_key:\n\nType: ${t}\nKey: ${e}\nPrefix: ${s(r)} \nLength: ${o} bytes\n\nAcceptable ${t} formats are:\n${i}\n`}({key:e,type:t,len:i,prefix:c}));return a}t.getAlgorithmFromKey=o,t.getAlgorithmFromPublicKey=function(e){return o(e,"public")},t.getAlgorithmFromPrivateKey=function(e){return o(e,"private")}}),be=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const ge=be(pe),Ae=be(fe);var me=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e,t){const r=(0,le.derivePrivateKey)(e,t);return{privateKey:"00"+(0,W.bytesToHex)((0,x.numberToBytesBE)(r,32)),publicKey:(0,W.bytesToHex)(b.secp256k1.getPublicKey(r,!0))}},sign(e,t){ge.default.ok(66===t.length&&t.startsWith("00")||64===t.length);const r=66===t.length?t.slice(2):t;return b.secp256k1.sign(Ae.default.half(e),r,{lowS:!0,extraEntropy:void 0}).toDERHex(!0).toUpperCase()},verify(e,t,r){const n=b.secp256k1.Signature.fromDER(t);return b.secp256k1.verify(n,Ae.default.half(e),r)}}},"__esModule",{value:!0}),we=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Ee=we(pe),xe=we(fe);var _e=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e){const t=xe.default.half(e);return{privateKey:"ED"+(0,W.bytesToHex)(t),publicKey:"ED"+(0,W.bytesToHex)(_.ed25519.getPublicKey(t))}},sign:(e,t)=>(Ee.default.ok(e instanceof Uint8Array,"message must be array of octets"),Ee.default.ok(66===t.length,"private key must be 33 bytes including prefix"),(0,W.bytesToHex)(_.ed25519.sign(e,t.slice(2)))),verify:(e,t,r)=>(Ee.default.ok(66===r.length,"public key must be 33 bytes including prefix"),_.ed25519.verify(t,e,r.slice(2),{zip215:!1}))}},"__esModule",{value:!0}),He=M(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decodeSeed=t.deriveNodeAddress=t.deriveAddress=t.verify=t.sign=t.deriveKeypair=t.generateSeed=void 0,Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return se.decodeSeed}});const n=r(fe),s=r(pe),o=r(me),i=r(_e);function c(e){return{"ecdsa-secp256k1":o.default,ed25519:i.default}[e]}function a(e){return(0,se.encodeAccountID)(function(e){return(0,ae.ripemd160)((0,te.sha256)(e))}(e))}t.generateSeed=function(e={}){s.default.ok(!e.entropy||e.entropy.length>=16,"entropy too short");const t=e.entropy?e.entropy.slice(0,16):(0,W.randomBytes)(16);return(0,se.encodeSeed)(t,"ed25519"===e.algorithm?"ed25519":"secp256k1")},t.deriveKeypair=function(e,t){var r;const s=(0,se.decodeSeed)(e),o=c("ed25519"===(null!==(r=null==t?void 0:t.algorithm)&&void 0!==r?r:s.type)?"ed25519":"ecdsa-secp256k1"),i=o.deriveKeypair(s.bytes,t),a=n.default.half("This test message should verify."),u=o.sign(a,i.privateKey);if(!o.verify(a,u,i.publicKey))throw new Error("derived keypair did not generate verifiable signature");return i},t.sign=function(e,t){return c((0,ye.getAlgorithmFromPrivateKey)(t)).sign((0,W.hexToBytes)(e),t)},t.verify=function(e,t,r){return c((0,ye.getAlgorithmFromPublicKey)(r)).verify((0,W.hexToBytes)(e),t,r)},t.deriveAddress=function(e){return a((0,W.hexToBytes)(e))},t.deriveNodeAddress=function(e){const t=(0,se.decodeNodePublic)(e);return a((0,le.accountPublicFromPublicGenerator)(t))}});const Ie=["wss://s1.ripple.com","wss://xrplcluster.com/","wss://s2.ripple.com/"];function ve(e){for(let n=0;n<e.length;n++){var t,r;return null!=(t=null==(r=e[n])||null==(r=r.tx_json)?void 0:r.SigningPubKey)?t:"0x"}throw new Error("No valid pubkey found in the latest transactions")}const Se={testnet:{grpcUrl:"https://grpc.testnet.concordium.com:20000",walletProxyUrl:"https://wallet-proxy.testnet.concordium.com"},mainnet:{grpcUrl:"https://grpc.mainnet.concordium.com:20000",walletProxyUrl:"https://wallet-proxy.mainnet.concordium.software"}},De={network:"testnet",timeout:5e4,retries:3,testMode:!0};function Le(e){try{if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e=>{if("string"==typeof e)return e;if(e&&"object"==typeof e)for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];if("string"==typeof n)return n;if("object"==typeof n){const e=t(n);if(e)return e}}return null},r=t(e);if(r)return r}throw new Error("Unable to extract signature from object")}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw new Error(`Invalid signature format: ${t}`)}}async function Pe(e,t){let r=new Error("No attempts made");for(let o=0;o<=t;o++)try{return await e()}catch(e){var n,s;const i=e instanceof Error?e:new Error(String(e));if(r=i,null!=(n=i.message)&&n.includes("Invalid signature")||null!=(s=i.message)&&s.includes("Account not found"))throw i;if(o===t)break;const c=Math.min(1e3*Math.pow(2,o),5e3);await new Promise(e=>setTimeout(e,c))}throw r}var Be=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let e=0;e<32;e++){const t=r.charAt(e);n[t]=e}function s(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function o(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=s(t)^n>>5}t=s(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=s(t)^31&n}return t}function i(e,t,r,n){let s=0,o=0;const i=(1<<r)-1,c=[];for(let n=0;n<e.length;++n)for(s=s<<t|e[n],o+=t;o>=r;)o-=r,c.push(s>>o&i);if(n)o>0&&c.push(s<<r-o&i);else{if(o>=t)return"Excess padding";if(s<<r-o&i)return"Non-zero padding"}return c}function c(e){return i(e,8,5,!0)}function a(e){const t=i(e,5,8,!1);if(Array.isArray(t))return t}function u(e){const t=i(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function h(e){let t;function i(e,r){if(e.length<8)return e+" too short";if(e.length>(r=r||90))return"Exceeds length limit";const i=e.toLowerCase(),c=e.toUpperCase();if(e!==i&&e!==c)return"Mixed-case string "+e;const a=(e=i).lastIndexOf("1");if(-1===a)return"No separator character for "+e;if(0===a)return"Missing prefix for "+e;const u=e.slice(0,a),h=e.slice(a+1);if(h.length<6)return"Data too short";let d=o(u);if("string"==typeof d)return d;const f=[];for(let e=0;e<h.length;++e){const t=h.charAt(e),r=n[t];if(void 0===r)return"Unknown character "+t;d=s(d)^r,e+6>=h.length||f.push(r)}return d!==t?"Invalid checksum for "+e:{prefix:u,words:f}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){const r=i(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=i(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(e,n,i){if(e.length+7+n.length>(i=i||90))throw new TypeError("Exceeds length limit");let c=o(e=e.toLowerCase());if("string"==typeof c)throw new Error(c);let a=e+"1";for(let e=0;e<n.length;++e){const t=n[e];if(t>>5)throw new Error("Non 5-bit word");c=s(c)^t,a+=r.charAt(t)}for(let e=0;e<6;++e)c=s(c);c^=t;for(let e=0;e<6;++e)a+=r.charAt(c>>5*(5-e)&31);return a},toWords:c,fromWordsUnsafe:a,fromWords:u}}t.bech32=h("bech32"),t.bech32m=h("bech32m")});function Ue(e,...t){if(!((r=e)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ve(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")}function Ce(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ke(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Fe(e,t){return e<<32-t|e>>>t}function Oe(e,t){return e<<t|e>>>32-t>>>0}function Te(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),Ue(e),e}class Me{}function Ke(e){const t=t=>e().update(Te(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function je(e,t,r){return e&t^~e&r}function Ne(e,t,r){return e&t^e&r^t&r}class Re extends Me{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=ke(this.buffer)}update(e){Ve(this),Ue(e=Te(e));const{view:t,buffer:r,blockLen:n}=this,s=e.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);if(i===n){const t=ke(e);for(;n<=s-o;o+=n)this.process(t,o);continue}r.set(e.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ve(this),function(e,t){Ue(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:s}=this;let{pos:o}=this;t[o++]=128,Ce(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(r,0),o=0);for(let e=o;e<n;e++)t[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const s=BigInt(32),o=BigInt(4294967295),i=Number(r>>s&o),c=Number(r&o),a=n?0:4;e.setUint32(t+(n?4:0),i,n),e.setUint32(t+a,c,n)}(r,n-8,BigInt(8*this.length),s),this.process(r,0);const i=ke(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=c/4,u=this.get();if(a>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<a;e++)i.setUint32(4*e,u[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:s,destroyed:o,pos:i}=this;return e.destroyed=o,e.finished=s,e.length=n,e.pos=i,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const We=/* @__PURE__ */Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ge=/* @__PURE__ */Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),$e=/* @__PURE__ */(()=>Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)))(),Xe=/* @__PURE__ */(()=>$e.map(e=>(9*e+5)%16))(),qe=/* @__PURE__ */(()=>{const e=[[$e],[Xe]];for(let t=0;t<4;t++)for(let r of e)r.push(r[t].map(e=>Ge[e]));return e})(),ze=/* @__PURE__ */(()=>qe[0])(),Ye=/* @__PURE__ */(()=>qe[1])(),Ze=/* @__PURE__ */[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),Je=/* @__PURE__ */ze.map((e,t)=>e.map(e=>Ze[t][e])),Qe=/* @__PURE__ */Ye.map((e,t)=>e.map(e=>Ze[t][e])),et=/* @__PURE__ */Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),tt=/* @__PURE__ */Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function rt(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const nt=/* @__PURE__ */new Uint32Array(16);class st extends Re{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:r,h3:n,h4:s}=this;return[e,t,r,n,s]}set(e,t,r,n,s){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)nt[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,s=0|this.h1,o=s,i=0|this.h2,c=i,a=0|this.h3,u=a,h=0|this.h4,d=h;for(let e=0;e<5;e++){const t=4-e,f=et[e],l=tt[e],p=ze[e],y=Ye[e],b=Je[e],g=Qe[e];for(let t=0;t<16;t++){const n=Oe(r+rt(e,s,i,a)+nt[p[t]]+f,b[t])+h|0;r=h,h=a,a=0|Oe(i,10),i=s,s=n}for(let e=0;e<16;e++){const r=Oe(n+rt(t,o,c,u)+nt[y[e]]+l,g[e])+d|0;n=d,d=u,u=0|Oe(c,10),c=o,o=r}}this.set(this.h1+i+u|0,this.h2+a+d|0,this.h3+h+n|0,this.h4+r+o|0,this.h0+s+c|0)}roundClean(){Ce(nt)}destroy(){this.destroyed=!0,Ce(this.buffer),this.set(0,0,0,0,0)}}const ot=/* @__PURE__ */Ke(()=>new st),it=/* @__PURE__ */Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ct=/* @__PURE__ */new Uint32Array(64);class at extends Re{constructor(e=32){super(64,e,8,!1),this.A=0|We[0],this.B=0|We[1],this.C=0|We[2],this.D=0|We[3],this.E=0|We[4],this.F=0|We[5],this.G=0|We[6],this.H=0|We[7]}get(){const{A:e,B:t,C:r,D:n,E:s,F:o,G:i,H:c}=this;return[e,t,r,n,s,o,i,c]}set(e,t,r,n,s,o,i,c){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|s,this.F=0|o,this.G=0|i,this.H=0|c}process(e,t){for(let r=0;r<16;r++,t+=4)ct[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ct[e-15],r=ct[e-2],n=Fe(t,7)^Fe(t,18)^t>>>3,s=Fe(r,17)^Fe(r,19)^r>>>10;ct[e]=s+ct[e-7]+n+ct[e-16]|0}let{A:r,B:n,C:s,D:o,E:i,F:c,G:a,H:u}=this;for(let e=0;e<64;e++){const t=u+(Fe(i,6)^Fe(i,11)^Fe(i,25))+je(i,c,a)+it[e]+ct[e]|0,h=(Fe(r,2)^Fe(r,13)^Fe(r,22))+Ne(r,n,s)|0;u=a,a=c,c=i,i=o+t|0,o=s,s=n,n=r,r=t+h|0}r=r+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,i=i+this.E|0,c=c+this.F|0,a=a+this.G|0,u=u+this.H|0,this.set(r,n,s,o,i,c,a,u)}roundClean(){Ce(ct)}destroy(){this.set(0,0,0,0,0,0,0,0),Ce(this.buffer)}}const ut=/* @__PURE__ */Ke(()=>new at);function ht(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function dt(e){const t=(new TextEncoder).encode(e);let r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return btoa(r)}async function ft(r,n){switch(r.type){case t.SelfDeclaration:return v({},r,{status:r.confirmed?e.VERIFIED:e.FAILED});case t.Screenshot:return v({},r,{status:r.url?e.FLAGGED:e.FAILED});case t.CIP8:return async function(t){const[r,,n]=t.address.split(/:/),s=t.chainSpecificData&&"cardanoCoseKey"in t.chainSpecificData?t.chainSpecificData.cardanoCoseKey:null;if("cardano"!==r||!s)return v({},t,{status:e.FAILED});try{return v({},t,{status:w(t.proof,s,t.attestation,n)?e.VERIFIED:e.FAILED})}catch(r){return v({},t,{status:e.FAILED})}}(r);case t.EIP191:return async function(t){const[r,,n]=t.address.split(/:/);if("eip155"!==r)return v({},t,{status:e.FAILED});const s=function(e,t,r){try{const n=u.getSignPayload(h.fromString(t)),s=d.fromHex(r),o=f.recoverPublicKey({payload:n,signature:s});return l.checksum(l.fromPublicKey(o)).toString()===l.checksum(e)}catch(e){return!1}}(n,t.attestation,t.proof);return v({},t,{status:s?e.VERIFIED:e.FAILED})}(r);case t.ED25519:return async function(t){const[r,,n]=t.address.split(/:/);if("solana"!==r)return v({},t,{status:e.FAILED});try{const r=c.decode(n),s=(new TextEncoder).encode(t.attestation),o=i.decode(t.proof);return v({},t,{status:m.sign.detached.verify(s,o,r)?e.VERIFIED:e.FAILED})}catch(r){return v({},t,{status:e.FAILED})}}(r);case t.SOL_SIWX:return async function(t){const[r]=t.address.split(/:/);if("solana"!==r)return v({},t,{status:e.FAILED});if(!t.chainSpecificData||!function(e){if(!e||"object"!=typeof e)return!1;const t=e;if(!t.account||"object"!=typeof t.account)return!1;const r=t.account;if("string"!=typeof r.address)return!1;if(!r.publicKey)return!1;if(!(r.publicKey instanceof Uint8Array)){const e=r.publicKey;if("object"!=typeof e)return!1;{const t=Object.keys(e).filter(e=>!isNaN(Number(e))).sort((e,t)=>Number(e)-Number(t));if(32!==t.length)return!1;{const n=t.map(t=>Number(e[t]));if(!n.every(e=>"number"==typeof e&&e>=0&&e<=255))return!1;r.publicKey=new Uint8Array(n)}}}if(!t.signedMessage)return!1;if(!(t.signedMessage instanceof Uint8Array)){const e=t.signedMessage;if("Buffer"!==e.type||!Array.isArray(e.data))return!1;t.signedMessage=new Uint8Array(e.data)}if(!t.signature)return!1;if(!(t.signature instanceof Uint8Array)){const e=t.signature;if("Buffer"!==e.type||!Array.isArray(e.data))return!1;t.signature=new Uint8Array(e.data)}if(!t.message||"object"!=typeof t.message)return!1;const n=t.message;if("object"==typeof n&&null!==n){const e=n;if(!e.address&&t.signedMessage instanceof Uint8Array)try{const r=(new TextDecoder).decode(t.signedMessage).split("\n");if(r.length>=2){const t=r[1].trim();t&&/^[a-zA-Z0-9]{32,44}$/.test(t)&&(e.address=t)}}catch(e){}}return!!function(e){return!(!e||"object"!=typeof e)&&"string"==typeof e.domain&&"string"==typeof e.address&&(void 0===e.statement||"string"==typeof e.statement)&&(void 0===e.uri||"string"==typeof e.uri)&&(void 0===e.version||"string"==typeof e.version)&&(void 0===e.chainId||"string"==typeof e.chainId)&&(void 0===e.nonce||"string"==typeof e.nonce)&&(void 0===e.issuedAt||"string"==typeof e.issuedAt)&&(void 0===e.expirationTime||"string"==typeof e.expirationTime)&&(void 0===e.notBefore||"string"==typeof e.notBefore)&&(void 0===e.requestId||"string"==typeof e.requestId)&&(void 0===e.resources||Array.isArray(e.resources))}(t.message)}(t.chainSpecificData))return v({},t,{status:e.FAILED});try{const r=t.chainSpecificData,n=(new TextDecoder).decode(r.signedMessage),s=function(e){try{const t=e.split("\n"),r=function(e){var t;const r=null==(t=e[0])?void 0:t.match(/^(.+) wants you to sign in with your Solana account:$/);if(!r)return null;const n=r[1],s=e[1];return s&&/^[a-zA-Z0-9]{32,44}$/.test(s)?{domain:n,address:s}:null}(t);if(!r)return null;const n=v({},r);let s=2;const o=function(e,t){let r=t;if(""===e[r]&&e[r+1]&&!e[r+1].includes(":")){r++;const t=e[r];return r++,""===e[r]&&r++,{statement:t,nextIndex:r}}return{nextIndex:r}}(t,s);void 0!==o.statement&&(n.statement=o.statement,s=o.nextIndex);const i=function(e,t){const r={},n=[{prefix:"URI: ",key:"uri"},{prefix:"Version: ",key:"version"},{prefix:"Chain ID: ",key:"chainId"},{prefix:"Nonce: ",key:"nonce"},{prefix:"Issued At: ",key:"issuedAt"},{prefix:"Expiration Time: ",key:"expirationTime"},{prefix:"Not Before: ",key:"notBefore"},{prefix:"Request ID: ",key:"requestId"}];let s=t;for(;s<e.length;){const t=e[s];if(t){if(t.startsWith("Resources:")){const t=F(e,s+1);if(t.length>0){r.resources=t,s+=t.length+1;continue}}for(const{prefix:e,key:s}of n)if(t.startsWith(e)){const n=t.substring(e.length);r[s]=n;break}s++}else s++}return r}(t,s);return Object.assign(n,i),n}catch(e){return null}}(n);return s&&function(e,t){if(e.domain!==t.domain||e.address!==t.address)return!1;const r=[{inputKey:"statement",parsedKey:"statement"},{inputKey:"uri",parsedKey:"uri"},{inputKey:"version",parsedKey:"version"},{inputKey:"chainId",parsedKey:"chainId"},{inputKey:"nonce",parsedKey:"nonce"},{inputKey:"issuedAt",parsedKey:"issuedAt"},{inputKey:"expirationTime",parsedKey:"expirationTime"},{inputKey:"notBefore",parsedKey:"notBefore"},{inputKey:"requestId",parsedKey:"requestId"},{inputKey:"resources",parsedKey:"resources",validator:(e,t)=>!(!Array.isArray(e)||!Array.isArray(t))&&e.length===t.length&&e.every((e,r)=>e===t[r])}];for(const{inputKey:n,parsedKey:s,validator:o}of r){const r=t[n],i=e[s];if(void 0!==r)if(o){if(!o(r,i))return!1}else if(r!==i)return!1}return function(e){const t=Date.now();if(e.issuedAt){const r=new Date(e.issuedAt),n=864e5;if(Math.abs(r.getTime()-t)>n)return!1}return!(e.expirationTime&&new Date(e.expirationTime).getTime()<=t||e.notBefore&&new Date(e.notBefore).getTime()>t)}(e)}(s,r.message)?function(e){let t=`${e.domain} wants you to sign in with your Solana account:\n`;t+=`${e.address}`,e.statement&&(t+=`\n\n${e.statement}`);const r=function(e){const t=[],r=[{key:"uri",prefix:"URI: "},{key:"version",prefix:"Version: "},{key:"chainId",prefix:"Chain ID: "},{key:"nonce",prefix:"Nonce: "},{key:"issuedAt",prefix:"Issued At: "},{key:"expirationTime",prefix:"Expiration Time: "},{key:"notBefore",prefix:"Not Before: "},{key:"requestId",prefix:"Request ID: "},{key:"resources",prefix:"Resources:",formatter:e=>Array.isArray(e)&&e.length>0?["Resources:",...e.map(e=>`- ${e}`)]:[]}];for(const{key:n,prefix:s,formatter:o}of r){const r=e[n];if(void 0!==r)if(o){const e=o(r);t.push(...e)}else"string"==typeof r&&t.push(`${s}${r}`)}return t}(e);return r.length&&(t+=`\n\n${r.join("\n")}`),t}(s)!==n?v({},t,{status:e.FAILED}):v({},t,{status:m.sign.detached.verify(r.signedMessage,r.signature,r.account.publicKey)?e.VERIFIED:e.FAILED}):v({},t,{status:e.FAILED})}catch(r){return v({},t,{status:e.FAILED})}}(r);case t.XRP_ED25519:return async function(t,r){const[n,,s]=t.address.split(/:/);if("xrpl"!==n)return v({},t,{status:e.FAILED});if(r||(r=await async function(e){const t=Ie;for(const n of t)try{var r;const t=new E(n);await t.connect();const s=await t.request({command:"account_tx",account:e,binary:!1,limit:2,forward:!1});return await t.disconnect(),ve(null==(r=s.result)?void 0:r.transactions)}catch(e){let t="Connection to XRPL server failed";e instanceof Error&&(t+=`: ${e.message}`),console.error(t)}}(s)),!r)return v({},t,{status:e.FAILED});const o=function(e,t,r){return He.verify(Buffer.from(e).toString("hex"),r,t)}(t.attestation,r,t.proof);return v({},t,{status:o?e.VERIFIED:e.FAILED})}(r,n);case t.XLM_ED25519:return function(t){const[r,,n]=t.address.split(/:/);if("stellar"!==r)return v({},t,{status:e.FAILED});try{const r=H.fromPublicKey(n),s=Buffer.from(t.attestation,"utf-8"),o=Buffer.from(t.proof,"base64");return v({},t,{status:r.verify(s,o)?e.VERIFIED:e.FAILED})}catch(r){return console.error(r),v({},t,{status:e.FAILED})}}(r);case t.CONCORDIUM:return(async(t,r={})=>{const n=v({},De,r),[s,o,i]=t.address.split(/:/);if("ccd"!==s)return v({},t,{status:e.FAILED});let c=n.network;o&&(c=o.includes("testnet")?"testnet":"mainnet");try{let r;try{r=JSON.parse(t.proof)}catch(r){return v({},t,{status:e.FAILED})}if(!r||"object"!=typeof r||0===Object.keys(r).length)return v({},t,{status:e.FAILED});if(n.testMode)try{const n=Le(r);return!n||n.length<64||!/^[0-9a-fA-F]+$/.test(n)?v({},t,{status:e.FAILED}):v({},t,{status:e.VERIFIED})}catch(r){return v({},t,{status:e.FAILED})}const s=await Pe(()=>async function(e,t,r){const n=Se[t];try{const t=new AbortController,s=setTimeout(()=>t.abort(),r),o=await fetch(`${n.walletProxyUrl}/v0/accEncryptionKey/${e}`,{method:"GET",headers:{Accept:"application/json","User-Agent":"verify-proof/1.6.0"},signal:t.signal});return clearTimeout(s),o.ok}catch(e){if(e instanceof Error&&"AbortError"===e.name)throw new Error(`Account validation timeout after ${r}ms`);throw e}}(i,c,n.timeout),n.retries);if(!s)return v({},t,{status:e.FAILED});const o=await Pe(()=>async function(e,t){try{const t=Le(e);return!(!t||t.length<64)&&t.length>=64&&/^[0-9a-fA-F]+$/.test(t)}catch(e){if(e instanceof Error){var r,n,s;if(null!=(r=e.message)&&r.includes("timeout"))throw new Error(`Signature verification timeout after ${t}ms`);if(null!=(n=e.message)&&n.includes("UNAVAILABLE"))throw new Error("Concordium node unavailable");if(null!=(s=e.message)&&s.includes("NOT_FOUND"))return!1}throw e}}(r,n.timeout),n.retries);return v({},t,o?{status:e.VERIFIED}:{status:e.FAILED})}catch(r){return v({},t,{status:e.FAILED})}})(r);case t.COSMOS:return async function(t){try{const[r,,n]=t.address.split(/:/);if("cosmos"!==r)return v({},t,{status:e.FAILED});const s=ht(t.chainSpecificData.pub_key.value),o=ht(t.proof);if(function(e,t="cosmos"){const r=ut(e),n=ot(r);return Be.bech32.encode(t,Be.bech32.toWords(n))}(s)!==n)return v({},t,{status:e.FAILED});const i={chain_id:"",account_number:"0",sequence:"0",fee:{amount:[],gas:"0"},msgs:[{type:"sign/MsgSignData",value:{signer:n,data:dt(t.attestation)}}],memo:""},c=await I(i),a=ut(c);return v({},t,{status:g.verify(o,a,s)?e.VERIFIED:e.FAILED})}catch(r){return v({},t,{status:e.FAILED})}}(r);case t.EIP712:case t.BIP137:case t.BIP322:return async function(r){const[n,,s]=r.address.split(/:/);if("bip122"!==n)return v({},r,{status:e.FAILED});const o=function(e){return e.startsWith("1")||e.startsWith("3")||e.startsWith("bc1")?D.bitcoin:e.startsWith("t1")||e.startsWith("t3")?D.zcash:e.startsWith("L")||e.startsWith("M")||e.startsWith("ltc1")?D.litecoin:e.startsWith("D")||e.startsWith("A")?D.dogecoin:e.startsWith("X")||e.startsWith("7")?D.dash:e.startsWith("q")?D.bitcoincash:e.startsWith("tb1")?D.testnet:D.bitcoin}(s);if(!o)return v({},r,{status:e.FAILED});if(s.startsWith("t1")||s.startsWith("t3"))return B(s,r,o);if(o.isTestnet)return P(s,r);try{switch(r.type){case t.BIP137:return B(s,r,o);case t.BIP322:return P(s,r);default:return v({},r,{status:e.FAILED})}}catch(t){return console.error("error verifying proof",t),v({},r,{status:e.FAILED})}}(r);case t.TIP191:return async function(t){const[r,,n]=t.address.split(/:/);return v({},t,"tron"!==r?{status:e.FAILED}:{status:O(n,t.attestation,t.proof)?e.VERIFIED:e.FAILED})}(r)}return r}export{ft as verifyProof};
2
2
  //# sourceMappingURL=index.modern.js.map