@notabene/verify-proof 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -2
- package/src/tests/index.test.ts +1 -1
- package/src/tests/xrpl.test.ts +9 -9
package/dist/index.modern.js
CHANGED
@@ -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 o,bech32 as s,base64 as i,base58 as c}from"@scure/base";import{Hash as a,PersonalMessage as d,Hex as u,Signature as h,Secp256k1 as f,Address as l,PublicKey as p,Bytes as b}from"ox";import y,{secp256k1 as g}from"@noble/curves/secp256k1";import{Verifier as x}from"bip322-js";import w from"tweetnacl";import A from"@cardano-foundation/cardano-verify-datasignature";import{Client as v}from"xrpl";import E from"@noble/curves/abstract/utils";import m from"@noble/curves/ed25519";function _(){return _=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},_.apply(null,arguments)}var P;!function(e){e.P2WPKH="p2wpkh",e.P2SH_P2WPKH="p2sh(p2wpkh)"}(P||(P={}));const L={messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc"},H={messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5},S={messagePrefix:"Litecoin Signed Message:\n",pubKeyHashVersion:48,scriptHashVersion:50,bech32Prefix:"ltc"},B={messagePrefix:"Dogecoin Signed Message:\n",pubKeyHashVersion:30,scriptHashVersion:22},D={messagePrefix:"DarkCoin Signed Message:\n",pubKeyHashVersion:76,scriptHashVersion:16};var I;!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"}(I||(I={}));const C=o(a.sha256);function U(e,t){const r=new Uint8Array([e,...t]);return C.encode(r)}function O(e,t="bc"){const r=s.toWords(e);return r.unshift(0),s.encode(t,r)}function k(e,t,r){try{const o=(n=u.fromString(t),a.keccak256(function(e){const t=u.from(e);return u.concat("0x19",u.fromString("TRON Signed Message:\n"+u.size(t)),t)}(n))),s=h.fromHex(r),i=f.recoverPublicKey({payload:o,signature:s}),d=`0x41${a.keccak256(`0x${p.toHex(i).slice(4)}`).substring(26)}`,l=b.from(d),y=b.from(a.sha256(a.sha256(d))).slice(0,4),g=b.concat(l,y);return c.encode(g)===e}catch(e){return!1}var n}var F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function T(e){var t={exports:{}};return e(t,t.exports),t.exports}var j=T(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});function K(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function M(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)}var V=/*#__PURE__*/Object.defineProperty({anumber:K,abytes:M,ahash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");K(e.outputLen),K(e.blockLen)},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")},aoutput:function(e,t){M(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}},"__esModule",{value:!0}),N=T(function(e,t){function r(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}Object.defineProperty(t,"__esModule",{value:!0}),t.Hash=t.nextTick=t.byteSwapIfBE=t.isLE=void 0,t.isBytes=function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name},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.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=r,t.byteSwap32=function(e){for(let t=0;t<e.length;t++)e[t]=r(e[t])},t.bytesToHex=function(e){(0,V.abytes)(e);let t="";for(let r=0;r<e.length;r++)t+=n[e[r]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof 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,o=0;t<r;t++,o+=2){const r=s(e.charCodeAt(o)),i=s(e.charCodeAt(o+1));if(void 0===r||void 0===i)throw new Error('hex string expected, got non-hex character "'+(e[o]+e[o+1])+'" at index '+o);n[t]=16*r+i}return n},t.asyncLoop=async function(e,r,n){let o=Date.now();for(let s=0;s<e;s++){n(s);const e=Date.now()-o;e>=0&&e<r||(await(0,t.nextTick)(),o+=e)}},t.utf8ToBytes=i,t.toBytes=c,t.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];(0,V.abytes)(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.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.wrapConstructor=function(e){const t=t=>e().update(c(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t},t.wrapConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(c(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},t.wrapXOFConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(c(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},t.randomBytes=function(e=32){if(j.crypto&&"function"==typeof j.crypto.getRandomValues)return j.crypto.getRandomValues(new Uint8Array(e));if(j.crypto&&"function"==typeof j.crypto.randomBytes)return j.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")},t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],t.byteSwapIfBE=t.isLE?e=>e:e=>r(e);const n=/* @__PURE__ */Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),o={_0:48,_9:57,A:65,F:70,a:97,f:102};function s(e){return e>=o._0&&e<=o._9?e-o._0:e>=o.A&&e<=o.F?e-(o.A-10):e>=o.a&&e<=o.f?e-(o.a-10):void 0}function i(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function c(e){return"string"==typeof e&&(e=i(e)),(0,V.abytes)(e),e}t.nextTick=async()=>{},t.Hash=class{clone(){return this._cloneInto()}}}),G=T(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}}),R=T(function(e,t){var r=F&&F.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=F&&F.__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(!G.HEX_REGEX.test(e))throw new Error("Invalid hex string");for(let r=0;r<t.length;r++){const n=2*r,o=e.slice(n,n+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");t[r]=s}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(G,t)}),W=T(function(e,t){function r(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),c=Number(r&s),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.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.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,N.createView)(this.buffer)}update(e){(0,V.aexists)(this);const{view:t,buffer:r,blockLen:n}=this,o=(e=(0,N.toBytes)(e)).length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);if(i!==n)r.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===n&&(this.process(t,0),this.pos=0);else{const t=(0,N.createView)(e);for(;n<=o-s;s+=n)this.process(t,s)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,V.aexists)(this),(0,V.aoutput)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:o,isLE:s}=this;let{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let e=i;e<o;e++)t[e]=0;r(n,o-8,BigInt(8*this.length),s),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 d=a/4,u=this.get();if(d>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<d;e++)c.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:o,destroyed:s,pos:i}=this;return e.length=n,e.pos=i,e.finished=o,e.destroyed=s,n%t&&e.buffer.set(r),e}}}),X=T(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.sha256=t.SHA256=void 0;const r=/* @__PURE__ */new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),n=/* @__PURE__ */new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),o=/* @__PURE__ */new Uint32Array(64);class s extends W.HashMD{constructor(){super(64,32,8,!1),this.A=0|n[0],this.B=0|n[1],this.C=0|n[2],this.D=0|n[3],this.E=0|n[4],this.F=0|n[5],this.G=0|n[6],this.H=0|n[7]}get(){const{A:e,B:t,C:r,D:n,E:o,F:s,G:i,H:c}=this;return[e,t,r,n,o,s,i,c]}set(e,t,r,n,o,s,i,c){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|c}process(e,t){for(let r=0;r<16;r++,t+=4)o[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=o[e-15],r=o[e-2],n=(0,N.rotr)(t,7)^(0,N.rotr)(t,18)^t>>>3,s=(0,N.rotr)(r,17)^(0,N.rotr)(r,19)^r>>>10;o[e]=s+o[e-7]+n+o[e-16]|0}let{A:n,B:s,C:i,D:c,E:a,F:d,G:u,H:h}=this;for(let e=0;e<64;e++){const t=h+((0,N.rotr)(a,6)^(0,N.rotr)(a,11)^(0,N.rotr)(a,25))+(0,W.Chi)(a,d,u)+r[e]+o[e]|0,f=((0,N.rotr)(n,2)^(0,N.rotr)(n,13)^(0,N.rotr)(n,22))+(0,W.Maj)(n,s,i)|0;h=u,u=d,d=a,a=c+t|0,c=i,i=s,s=n,n=t+f|0}n=n+this.A|0,s=s+this.B|0,i=i+this.C|0,c=c+this.D|0,a=a+this.E|0,d=d+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(n,s,i,c,a,d,u,h)}roundClean(){o.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}t.SHA256=s;class i extends s{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}t.sha256=(0,N.wrapConstructor)(()=>new s),t.sha224=(0,N.wrapConstructor)(()=>new i)});const $=(F&&F.__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,$.default)(t))}return t.create=()=>{const t=e.create();return{update(e){return t.update((0,$.default)(e)),this},digest:()=>t.digest()}},t}},"__esModule",{value:!0}),Y=X,z=T(function(e,t){var r=F&&F.__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)(Y.sha256)}),J=T(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))}}),Q=T(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],o={sha256:z.sha256},s=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,o=t.versionTypes,s=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:s.length-("number"==typeof n[0]?1:n[0].length),c=s.slice(0,-i),a=s.slice(-i);for(let e=0;e<n.length;e++){const t=Array.isArray(n[e])?n[e]:[n[e]];if((0,J.arrayEqual)(c,t))return{version:t,bytes:a,type:o?o[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,J.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,J.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,J.arrayEqual)(t,r)}}(o);function i(e){return s.encode(e,{versions:[0],expectedLength:20})}function c(e){return s.decode(e,{versions:[0],expectedLength:20}).bytes}function a(e,t){return"byteLength"in e?e.byteLength===t:e.length===t}t.codec=s,t.encodeSeed=function(e,t){if(!a(e,16))throw new Error("entropy must have length 16");return s.encode(e,{expectedLength:16,versions:"ed25519"===t?r:[33]})},t.decodeSeed=function(e,t={versionTypes:["ed25519","secp256k1"],versions:[r,33],expectedLength:16}){return s.decode(e,t)},t.encodeAccountID=i,t.encodeAddress=i,t.decodeAccountID=c,t.decodeAddress=c,t.decodeNodePublic=function(e){return s.decode(e,{versions:[28],expectedLength:33}).bytes},t.encodeNodePublic=function(e){return s.encode(e,{versions:[28],expectedLength:33})},t.encodeAccountPublic=function(e){return s.encode(e,{versions:[35],expectedLength:33})},t.decodeAccountPublic=function(e){return s.decode(e,{versions:[35],expectedLength:33}).bytes},t.isValidClassicAddress=function(e){try{c(e)}catch(e){return!1}return!0}}),Z=T(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 Q.codec}}),Object.defineProperty(t,"encodeSeed",{enumerable:!0,get:function(){return Q.encodeSeed}}),Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return Q.decodeSeed}}),Object.defineProperty(t,"encodeAccountID",{enumerable:!0,get:function(){return Q.encodeAccountID}}),Object.defineProperty(t,"decodeAccountID",{enumerable:!0,get:function(){return Q.decodeAccountID}}),Object.defineProperty(t,"encodeNodePublic",{enumerable:!0,get:function(){return Q.encodeNodePublic}}),Object.defineProperty(t,"decodeNodePublic",{enumerable:!0,get:function(){return Q.decodeNodePublic}}),Object.defineProperty(t,"encodeAccountPublic",{enumerable:!0,get:function(){return Q.encodeAccountPublic}}),Object.defineProperty(t,"decodeAccountPublic",{enumerable:!0,get:function(){return Q.decodeAccountPublic}}),Object.defineProperty(t,"isValidClassicAddress",{enumerable:!0,get:function(){return Q.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 o=t||0,s=(0,R.concat)([n?r.test:r.main,e,Uint8Array.from([!1===t||null==t?0:1,255&o,o>>8&255,o>>16&255,o>>24&255,0,0,0,0])]);return Q.codec.encodeChecked(s)}function o(e){const t=Q.codec.decodeChecked(e),n=function(e){const t=e.slice(0,2);if((0,R.equal)(r.main,t))return!1;if((0,R.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,R.equal)((0,R.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,Q.decodeAccountID)(e),t,r)},t.encodeXAddress=n,t.xAddressToClassicAddress=function(e){const{accountId:t,tag:r,test:n}=o(e);return{classicAddress:(0,Q.encodeAccountID)(t),tag:r,test:n}},t.decodeXAddress=o,t.isValidXAddress=function(e){try{o(e)}catch(e){return!1}return!0}}),ee=T(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=void 0;const r=/* @__PURE__ */new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),n=/* @__PURE__ */new Uint8Array(new Array(16).fill(0).map((e,t)=>t));let o=[n],s=[/* @__PURE__ */n.map(e=>(9*e+5)%16)];for(let e=0;e<4;e++)for(let t of[o,s])t.push(t[e].map(e=>r[e]));const i=/* @__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=>new Uint8Array(e)),c=/* @__PURE__ */o.map((e,t)=>e.map(e=>i[t][e])),a=/* @__PURE__ */s.map((e,t)=>e.map(e=>i[t][e])),d=/* @__PURE__ */new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),u=/* @__PURE__ */new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function h(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 f=/* @__PURE__ */new Uint32Array(16);class l extends W.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:o}=this;return[e,t,r,n,o]}set(e,t,r,n,o){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|o}process(e,t){for(let r=0;r<16;r++,t+=4)f[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,i=0|this.h1,l=i,p=0|this.h2,b=p,y=0|this.h3,g=y,x=0|this.h4,w=x;for(let e=0;e<5;e++){const t=4-e,A=d[e],v=u[e],E=o[e],m=s[e],_=c[e],P=a[e];for(let t=0;t<16;t++){const n=(0,N.rotl)(r+h(e,i,p,y)+f[E[t]]+A,_[t])+x|0;r=x,x=y,y=0|(0,N.rotl)(p,10),p=i,i=n}for(let e=0;e<16;e++){const r=(0,N.rotl)(n+h(t,l,b,g)+f[m[e]]+v,P[e])+w|0;n=w,w=g,g=0|(0,N.rotl)(b,10),b=l,l=r}}this.set(this.h1+p+g|0,this.h2+y+w|0,this.h3+x+n|0,this.h4+r+l|0,this.h0+i+b|0)}roundClean(){f.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}t.RIPEMD160=l,t.ripemd160=(0,N.wrapConstructor)(()=>new l)}),te=T(function(e,t){var r=F&&F.__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)(ee.ripemd160)}),re=T(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.add5L=t.add5H=t.add4H=t.add4L=t.add3H=t.add3L=t.rotlBL=t.rotlBH=t.rotlSL=t.rotlSH=t.rotr32L=t.rotr32H=t.rotrBL=t.rotrBH=t.rotrSL=t.rotrSH=t.shrSL=t.shrSH=t.toBig=void 0,t.fromBig=o,t.split=s,t.add=w;const r=/* @__PURE__ */BigInt(2**32-1),n=/* @__PURE__ */BigInt(32);function o(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 s(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:i,l:c}=o(e[s],t);[r[s],n[s]]=[i,c]}return[r,n]}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 d=(e,t,r)=>e>>>r|t<<32-r;t.rotrSH=d;const u=(e,t,r)=>e<<32-r|t>>>r;t.rotrSL=u;const h=(e,t,r)=>e<<64-r|t>>>r-32;t.rotrBH=h;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 b=(e,t,r)=>e<<r|t>>>32-r;t.rotlSH=b;const y=(e,t,r)=>t<<r|e>>>32-r;t.rotlSL=y;const g=(e,t,r)=>t<<r-32|e>>>64-r;t.rotlBH=g;const x=(e,t,r)=>e<<r-32|t>>>64-r;function w(e,t,r,n){const o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:0|o}}t.rotlBL=x;const A=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);t.add3L=A;const v=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;t.add3H=v;const E=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);t.add4L=E;const m=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0;t.add4H=m;const _=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0);t.add5L=_;const P=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;t.add5H=P,t.default={fromBig:o,split:s,toBig:i,shrSH:c,shrSL:a,rotrSH:d,rotrSL:u,rotrBH:h,rotrBL:f,rotr32H:l,rotr32L:p,rotlSH:b,rotlSL:y,rotlBH:g,rotlBL:x,add:w,add3L:A,add3H:v,add4L:E,add4H:m,add5H:P,add5L:_}}),ne=T(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha384=t.sha512_256=t.sha512_224=t.sha512=t.SHA384=t.SHA512_256=t.SHA512_224=t.SHA512=void 0;const[r,n]=/* @__PURE__ */(()=>re.default.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))))(),o=/* @__PURE__ */new Uint32Array(80),s=/* @__PURE__ */new Uint32Array(80);class i extends W.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:o,Cl:s,Dh:i,Dl:c,Eh:a,El:d,Fh:u,Fl:h,Gh:f,Gl:l,Hh:p,Hl:b}=this;return[e,t,r,n,o,s,i,c,a,d,u,h,f,l,p,b]}set(e,t,r,n,o,s,i,c,a,d,u,h,f,l,p,b){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|o,this.Cl=0|s,this.Dh=0|i,this.Dl=0|c,this.Eh=0|a,this.El=0|d,this.Fh=0|u,this.Fl=0|h,this.Gh=0|f,this.Gl=0|l,this.Hh=0|p,this.Hl=0|b}process(e,t){for(let r=0;r<16;r++,t+=4)o[r]=e.getUint32(t),s[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|o[e-15],r=0|s[e-15],n=re.default.rotrSH(t,r,1)^re.default.rotrSH(t,r,8)^re.default.shrSH(t,r,7),i=re.default.rotrSL(t,r,1)^re.default.rotrSL(t,r,8)^re.default.shrSL(t,r,7),c=0|o[e-2],a=0|s[e-2],d=re.default.rotrSH(c,a,19)^re.default.rotrBH(c,a,61)^re.default.shrSH(c,a,6),u=re.default.rotrSL(c,a,19)^re.default.rotrBL(c,a,61)^re.default.shrSL(c,a,6),h=re.default.add4L(i,u,s[e-7],s[e-16]),f=re.default.add4H(h,n,d,o[e-7],o[e-16]);o[e]=0|f,s[e]=0|h}let{Ah:i,Al:c,Bh:a,Bl:d,Ch:u,Cl:h,Dh:f,Dl:l,Eh:p,El:b,Fh:y,Fl:g,Gh:x,Gl:w,Hh:A,Hl:v}=this;for(let e=0;e<80;e++){const t=re.default.rotrSH(p,b,14)^re.default.rotrSH(p,b,18)^re.default.rotrBH(p,b,41),E=re.default.rotrSL(p,b,14)^re.default.rotrSL(p,b,18)^re.default.rotrBL(p,b,41),m=p&y^~p&x,_=re.default.add5L(v,E,b&g^~b&w,n[e],s[e]),P=re.default.add5H(_,A,t,m,r[e],o[e]),L=0|_,H=re.default.rotrSH(i,c,28)^re.default.rotrBH(i,c,34)^re.default.rotrBH(i,c,39),S=re.default.rotrSL(i,c,28)^re.default.rotrBL(i,c,34)^re.default.rotrBL(i,c,39),B=i&a^i&u^a&u,D=c&d^c&h^d&h;A=0|x,v=0|w,x=0|y,w=0|g,y=0|p,g=0|b,({h:p,l:b}=re.default.add(0|f,0|l,0|P,0|L)),f=0|u,l=0|h,u=0|a,h=0|d,a=0|i,d=0|c;const I=re.default.add3L(L,S,D);i=re.default.add3H(I,P,H,B),c=0|I}({h:i,l:c}=re.default.add(0|this.Ah,0|this.Al,0|i,0|c)),({h:a,l:d}=re.default.add(0|this.Bh,0|this.Bl,0|a,0|d)),({h:u,l:h}=re.default.add(0|this.Ch,0|this.Cl,0|u,0|h)),({h:f,l}=re.default.add(0|this.Dh,0|this.Dl,0|f,0|l)),({h:p,l:b}=re.default.add(0|this.Eh,0|this.El,0|p,0|b)),({h:y,l:g}=re.default.add(0|this.Fh,0|this.Fl,0|y,0|g)),({h:x,l:w}=re.default.add(0|this.Gh,0|this.Gl,0|x,0|w)),({h:A,l:v}=re.default.add(0|this.Hh,0|this.Hl,0|A,0|v)),this.set(i,c,a,d,u,h,f,l,p,b,y,g,x,w,A,v)}roundClean(){o.fill(0),s.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=i;class c extends i{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}t.SHA512_224=c;class a extends i{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}t.SHA512_256=a;class d extends i{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}t.SHA384=d,t.sha512=(0,N.wrapConstructor)(()=>new i),t.sha512_224=(0,N.wrapConstructor)(()=>new c),t.sha512_256=(0,N.wrapConstructor)(()=>new a),t.sha384=(0,N.wrapConstructor)(()=>new d)}),oe=T(function(e,t){var r=F&&F.__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)(ne.sha512)});class se{constructor(){this.hash=oe.sha512.create()}static half(e){return(new se).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 ie=/*#__PURE__*/Object.defineProperty({default:se},"__esModule",{value:!0}),ce=T(function(e,t){var r=F&&F.__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(ie),o=BigInt(0);function s(e,t){const r=y.secp256k1.CURVE.n;for(let s=0;s<=4294967295;s++){const i=(new n.default).add(e);void 0!==t&&i.addU32(t),i.addU32(s);const c=i.first256BigInt();if(c>o&&c<r)return c}throw new Error("impossible unicorn ;)")}t.derivePrivateKey=function(e,t={}){const r=t.validator,n=y.secp256k1.CURVE.n,o=s(e);return r?o:(s(y.secp256k1.ProjectivePoint.BASE.multiply(o).toRawBytes(!0),t.accountIndex||0)+o)%n},t.accountPublicFromPublicGenerator=function(e){const t=y.secp256k1.ProjectivePoint.fromHex(e),r=s(e,0),n=y.secp256k1.ProjectivePoint.BASE.multiply(r);return t.add(n).toRawBytes(!0)}}),ae=/*#__PURE__*/Object.defineProperty({default:{ok(e,t){if(!e)throw new Error(t)}}},"__esModule",{value:!0}),de=T(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 o(e){return e===r.NONE?"None":`0x${e.toString(16).padStart(2,"0")}`}function s(e,t){const{prefix:s,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:s,a=n[`${t}_${c}_${i}`];if(!a)throw new Error(function({key:e,type:t,prefix:r,len:s}){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: ${o(Number(r)).padEnd(6)} Length: ${n} bytes`}).join("\n")}(t);return`invalid_key:\n\nType: ${t}\nKey: ${e}\nPrefix: ${o(r)} \nLength: ${s} bytes\n\nAcceptable ${t} formats are:\n${i}\n`}({key:e,type:t,len:i,prefix:c}));return a}t.getAlgorithmFromKey=s,t.getAlgorithmFromPublicKey=function(e){return s(e,"public")},t.getAlgorithmFromPrivateKey=function(e){return s(e,"private")}}),ue=F&&F.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const he=ue(ae),fe=ue(ie);var le=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e,t){const r=(0,ce.derivePrivateKey)(e,t);return{privateKey:"00"+(0,R.bytesToHex)((0,E.numberToBytesBE)(r,32)),publicKey:(0,R.bytesToHex)(y.secp256k1.getPublicKey(r,!0))}},sign(e,t){he.default.ok(66===t.length&&t.startsWith("00")||64===t.length);const r=66===t.length?t.slice(2):t;return y.secp256k1.sign(fe.default.half(e),r,{lowS:!0,extraEntropy:void 0}).toDERHex(!0).toUpperCase()},verify(e,t,r){const n=y.secp256k1.Signature.fromDER(t);return y.secp256k1.verify(n,fe.default.half(e),r)}}},"__esModule",{value:!0}),pe=F&&F.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const be=pe(ae),ye=pe(ie);var ge=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e){const t=ye.default.half(e);return{privateKey:"ED"+(0,R.bytesToHex)(t),publicKey:"ED"+(0,R.bytesToHex)(m.ed25519.getPublicKey(t))}},sign:(e,t)=>(be.default.ok(e instanceof Uint8Array,"message must be array of octets"),be.default.ok(66===t.length,"private key must be 33 bytes including prefix"),(0,R.bytesToHex)(m.ed25519.sign(e,t.slice(2)))),verify:(e,t,r)=>(be.default.ok(66===r.length,"public key must be 33 bytes including prefix"),m.ed25519.verify(t,e,r.slice(2),{zip215:!1}))}},"__esModule",{value:!0}),xe=T(function(e,t){var r=F&&F.__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 Z.decodeSeed}});const n=r(ie),o=r(ae),s=r(le),i=r(ge);function c(e){return{"ecdsa-secp256k1":s.default,ed25519:i.default}[e]}function a(e){return(0,Z.encodeAccountID)(function(e){return(0,te.ripemd160)((0,z.sha256)(e))}(e))}t.generateSeed=function(e={}){o.default.ok(!e.entropy||e.entropy.length>=16,"entropy too short");const t=e.entropy?e.entropy.slice(0,16):(0,R.randomBytes)(16);return(0,Z.encodeSeed)(t,"ed25519"===e.algorithm?"ed25519":"secp256k1")},t.deriveKeypair=function(e,t){var r;const o=(0,Z.decodeSeed)(e),s=c("ed25519"===(null!==(r=null==t?void 0:t.algorithm)&&void 0!==r?r:o.type)?"ed25519":"ecdsa-secp256k1"),i=s.deriveKeypair(o.bytes,t),a=n.default.half("This test message should verify."),d=s.sign(a,i.privateKey);if(!s.verify(a,d,i.publicKey))throw new Error("derived keypair did not generate verifiable signature");return i},t.sign=function(e,t){return c((0,de.getAlgorithmFromPrivateKey)(t)).sign((0,R.hexToBytes)(e),t)},t.verify=function(e,t,r){return c((0,de.getAlgorithmFromPublicKey)(r)).verify((0,R.hexToBytes)(e),t,r)},t.deriveAddress=function(e){return a((0,R.hexToBytes)(e))},t.deriveNodeAddress=function(e){const t=(0,Z.decodeNodePublic)(e);return a((0,ce.accountPublicFromPublicGenerator)(t))}});const we=["wss://s1.ripple.com","wss://xrplcluster.com/","wss://s2.ripple.com/"];function Ae(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")}async function ve(n,o){switch(n.type){case t.SelfDeclaration:return _({},n,{status:n.confirmed?e.VERIFIED:e.FAILED});case t.Screenshot:return _({},n,{status:n.url?e.FLAGGED:e.FAILED});case t.CIP8:return async function(t){var r;const[n,,o]=t.address.split(/:/),s=null==(r=t.chainSpecificData)?void 0:r.cardanoCoseKey;if("cardano"!==n||!s)return _({},t,{status:e.FAILED});try{return _({},t,{status:A(t.proof,s,t.attestation,o)?e.VERIFIED:e.FAILED})}catch(r){return _({},t,{status:e.FAILED})}}(n);case t.EIP191:return async function(t){const[r,,n]=t.address.split(/:/);if("eip155"!==r)return _({},t,{status:e.FAILED});const o=function(e,t,r){try{const n=d.getSignPayload(u.fromString(t)),o=h.fromHex(r),s=f.recoverPublicKey({payload:n,signature:o});return l.checksum(l.fromPublicKey(s)).toString()===l.checksum(e)}catch(e){return!1}}(n,t.attestation,t.proof);return _({},t,{status:o?e.VERIFIED:e.FAILED})}(n);case t.ED25519:return n.address.startsWith("solana")?async function(t){const[r,,n]=t.address.split(/:/);if("solana"!==r)return _({},t,{status:e.FAILED});try{const r=c.decode(n),o=(new TextEncoder).encode(t.attestation),s=i.decode(t.proof);return _({},t,{status:w.sign.detached.verify(o,s,r)?e.VERIFIED:e.FAILED})}catch(r){return _({},t,{status:e.FAILED})}}(n):async function(t,r){const[n,,o]=t.address.split(/:/);if("xrpl"!==n)return _({},t,{status:e.FAILED});if(r||(r=await async function(e){const t=we;for(const n of t)try{var r;const t=new v(n);await t.connect();const o=await t.request({command:"account_tx",account:e,binary:!1,limit:2,forward:!1});return await t.disconnect(),Ae(null==(r=o.result)?void 0:r.transactions)}catch(e){let t="Connection to XRPL server failed";e instanceof Error&&(t+=`: ${e.message}`),console.error(t)}throw new Error("Failed to connect to any XRPL server")}(o)),!r)return _({},t,{status:e.FAILED});const s=function(e,t,r){return xe.verify(Buffer.from(e).toString("hex"),r,t)}(t.attestation,r,t.proof);return _({},t,{status:s?e.VERIFIED:e.FAILED})}(n,o);case t.EIP712:case t.BIP137:case t.BIP322:return async function(n){const[o,,s]=n.address.split(/:/);if("bip122"!==o)return _({},n,{status:e.FAILED});const c=function(e){return e.startsWith("1")||e.startsWith("3")||e.startsWith("bc1")?L:e.startsWith("L")||e.startsWith("M")||e.startsWith("ltc1")?S:e.startsWith("D")||e.startsWith("A")?B:e.startsWith("X")||e.startsWith("7")?D:e.startsWith("q")?H:L}(s);if(!c)return _({},n,{status:e.FAILED});try{switch(n.type){case t.BIP137:return function(t,n,o){const s=Boolean(o.bech32Prefix&&[I.SEGWIT,I.NATIVE].includes(function(e){if(e.match("^(bc1|tb1|ltc1).*"))return I.NATIVE;if(e.match("^[32M].*"))return I.SEGWIT;if(e.match("^[1nmL].*"))return I.LEGACY;if(e.match("^(D).*"))return I.DOGECOIN;if(e.match("^(q).*"))return I.BCH;throw new Error("INVALID ADDRESS: ".concat(e).concat(" is not a valid or a supported address"))}(t))),c=function(e,t,n,o,s){const{compressed:c,segwitType:d,signature:u}=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),o=3&r,s=g.Signature.fromCompact(t.slice(1));return{compressed:n,segwitType:8&r?4&r?P.P2WPKH:P.P2SH_P2WPKH:void 0,signature:s.addRecoveryBit(o)}}(n);if(o&&!c)throw new Error("checkSegwitAlways can only be used with a compressed pubkey signature flagbyte");const h=function(e,t){const n=(new TextEncoder).encode(t),o=(new TextEncoder).encode(e),s=r(o.length).buffer,i=new Uint8Array(n.length+s.byteLength+o.length);return i.set(n),i.set(new Uint8Array(s),n.length),i.set(o,n.length+s.byteLength),function(e){return a.sha256(a.sha256(e))}(i)}(e,s.messagePrefix),f=(l=u.recoverPublicKey(h).toRawBytes(c),a.ripemd160(a.sha256(l)));var l;let p="";if(t.startsWith("q"))return p=U(s.pubKeyHashVersion,f),p.startsWith("1");if(d)p=d===P.P2SH_P2WPKH?U(s.scriptHashVersion,f):s.bech32Prefix?O(f,s.bech32Prefix):U(s.scriptHashVersion,f);else if(o&&s.bech32Prefix)try{p=O(f,s.bech32Prefix)}catch(e){p=U(s.scriptHashVersion,f)}else p=U(s.pubKeyHashVersion,f);return p===t}(n.attestation,t,n.proof,s,o);return _({},n,{status:c?e.VERIFIED:e.FAILED})}(s,n,c);case t.BIP322:return function(t,r){const{attestation:n,proof:o}=r;return _({},r,{status:x.verifySignature(t,n,o)?e.VERIFIED:e.FAILED})}(s,n);default:return _({},n,{status:e.FAILED})}}catch(t){return _({},n,{status:e.FAILED})}}(n);case t.TIP191:return async function(t){const[r,,n]=t.address.split(/:/);return _({},t,"tron"!==r?{status:e.FAILED}:{status:k(n,t.attestation,t.proof)?e.VERIFIED:e.FAILED})}(n)}return n}export{ve 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 o,bech32 as s,base64 as i,base58 as c}from"@scure/base";import{Hash as a,PersonalMessage as d,Hex as u,Signature as h,Secp256k1 as f,Address as l,PublicKey as p,Bytes as b}from"ox";import y,{secp256k1 as g}from"@noble/curves/secp256k1";import{Verifier as x}from"bip322-js";import w from"tweetnacl";import A from"@cardano-foundation/cardano-verify-datasignature";import{Client as v}from"xrpl";import E from"@noble/curves/abstract/utils";import m from"@noble/curves/ed25519";function _(){return _=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},_.apply(null,arguments)}var P;!function(e){e.P2WPKH="p2wpkh",e.P2SH_P2WPKH="p2sh(p2wpkh)"}(P||(P={}));const L={messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc"},H={messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5},S={messagePrefix:"Litecoin Signed Message:\n",pubKeyHashVersion:48,scriptHashVersion:50,bech32Prefix:"ltc"},B={messagePrefix:"Dogecoin Signed Message:\n",pubKeyHashVersion:30,scriptHashVersion:22},D={messagePrefix:"DarkCoin Signed Message:\n",pubKeyHashVersion:76,scriptHashVersion:16};var I;!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"}(I||(I={}));const C=o(a.sha256);function U(e,t){const r=new Uint8Array([e,...t]);return C.encode(r)}function O(e,t="bc"){const r=s.toWords(e);return r.unshift(0),s.encode(t,r)}function k(e,t,r){try{const o=(n=u.fromString(t),a.keccak256(function(e){const t=u.from(e);return u.concat("0x19",u.fromString("TRON Signed Message:\n"+u.size(t)),t)}(n))),s=h.fromHex(r),i=f.recoverPublicKey({payload:o,signature:s}),d=`0x41${a.keccak256(`0x${p.toHex(i).slice(4)}`).substring(26)}`,l=b.from(d),y=b.from(a.sha256(a.sha256(d))).slice(0,4),g=b.concat(l,y);return c.encode(g)===e}catch(e){return!1}var n}var F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function T(e){var t={exports:{}};return e(t,t.exports),t.exports}var j=T(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});function K(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function M(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)}var V=/*#__PURE__*/Object.defineProperty({anumber:K,abytes:M,ahash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");K(e.outputLen),K(e.blockLen)},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")},aoutput:function(e,t){M(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}},"__esModule",{value:!0}),N=T(function(e,t){function r(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}Object.defineProperty(t,"__esModule",{value:!0}),t.Hash=t.nextTick=t.byteSwapIfBE=t.isLE=void 0,t.isBytes=function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name},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.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=r,t.byteSwap32=function(e){for(let t=0;t<e.length;t++)e[t]=r(e[t])},t.bytesToHex=function(e){(0,V.abytes)(e);let t="";for(let r=0;r<e.length;r++)t+=n[e[r]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof 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,o=0;t<r;t++,o+=2){const r=s(e.charCodeAt(o)),i=s(e.charCodeAt(o+1));if(void 0===r||void 0===i)throw new Error('hex string expected, got non-hex character "'+(e[o]+e[o+1])+'" at index '+o);n[t]=16*r+i}return n},t.asyncLoop=async function(e,r,n){let o=Date.now();for(let s=0;s<e;s++){n(s);const e=Date.now()-o;e>=0&&e<r||(await(0,t.nextTick)(),o+=e)}},t.utf8ToBytes=i,t.toBytes=c,t.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];(0,V.abytes)(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.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.wrapConstructor=function(e){const t=t=>e().update(c(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t},t.wrapConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(c(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},t.wrapXOFConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(c(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},t.randomBytes=function(e=32){if(j.crypto&&"function"==typeof j.crypto.getRandomValues)return j.crypto.getRandomValues(new Uint8Array(e));if(j.crypto&&"function"==typeof j.crypto.randomBytes)return j.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")},t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],t.byteSwapIfBE=t.isLE?e=>e:e=>r(e);const n=/* @__PURE__ */Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),o={_0:48,_9:57,A:65,F:70,a:97,f:102};function s(e){return e>=o._0&&e<=o._9?e-o._0:e>=o.A&&e<=o.F?e-(o.A-10):e>=o.a&&e<=o.f?e-(o.a-10):void 0}function i(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function c(e){return"string"==typeof e&&(e=i(e)),(0,V.abytes)(e),e}t.nextTick=async()=>{},t.Hash=class{clone(){return this._cloneInto()}}}),G=T(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}}),R=T(function(e,t){var r=F&&F.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=F&&F.__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(!G.HEX_REGEX.test(e))throw new Error("Invalid hex string");for(let r=0;r<t.length;r++){const n=2*r,o=e.slice(n,n+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");t[r]=s}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(G,t)}),W=T(function(e,t){function r(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),c=Number(r&s),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.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.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,N.createView)(this.buffer)}update(e){(0,V.aexists)(this);const{view:t,buffer:r,blockLen:n}=this,o=(e=(0,N.toBytes)(e)).length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);if(i!==n)r.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===n&&(this.process(t,0),this.pos=0);else{const t=(0,N.createView)(e);for(;n<=o-s;s+=n)this.process(t,s)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,V.aexists)(this),(0,V.aoutput)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:o,isLE:s}=this;let{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let e=i;e<o;e++)t[e]=0;r(n,o-8,BigInt(8*this.length),s),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 d=a/4,u=this.get();if(d>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<d;e++)c.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:o,destroyed:s,pos:i}=this;return e.length=n,e.pos=i,e.finished=o,e.destroyed=s,n%t&&e.buffer.set(r),e}}}),X=T(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.sha256=t.SHA256=void 0;const r=/* @__PURE__ */new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),n=/* @__PURE__ */new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),o=/* @__PURE__ */new Uint32Array(64);class s extends W.HashMD{constructor(){super(64,32,8,!1),this.A=0|n[0],this.B=0|n[1],this.C=0|n[2],this.D=0|n[3],this.E=0|n[4],this.F=0|n[5],this.G=0|n[6],this.H=0|n[7]}get(){const{A:e,B:t,C:r,D:n,E:o,F:s,G:i,H:c}=this;return[e,t,r,n,o,s,i,c]}set(e,t,r,n,o,s,i,c){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|c}process(e,t){for(let r=0;r<16;r++,t+=4)o[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=o[e-15],r=o[e-2],n=(0,N.rotr)(t,7)^(0,N.rotr)(t,18)^t>>>3,s=(0,N.rotr)(r,17)^(0,N.rotr)(r,19)^r>>>10;o[e]=s+o[e-7]+n+o[e-16]|0}let{A:n,B:s,C:i,D:c,E:a,F:d,G:u,H:h}=this;for(let e=0;e<64;e++){const t=h+((0,N.rotr)(a,6)^(0,N.rotr)(a,11)^(0,N.rotr)(a,25))+(0,W.Chi)(a,d,u)+r[e]+o[e]|0,f=((0,N.rotr)(n,2)^(0,N.rotr)(n,13)^(0,N.rotr)(n,22))+(0,W.Maj)(n,s,i)|0;h=u,u=d,d=a,a=c+t|0,c=i,i=s,s=n,n=t+f|0}n=n+this.A|0,s=s+this.B|0,i=i+this.C|0,c=c+this.D|0,a=a+this.E|0,d=d+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(n,s,i,c,a,d,u,h)}roundClean(){o.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}t.SHA256=s;class i extends s{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}t.sha256=(0,N.wrapConstructor)(()=>new s),t.sha224=(0,N.wrapConstructor)(()=>new i)});const $=(F&&F.__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,$.default)(t))}return t.create=()=>{const t=e.create();return{update(e){return t.update((0,$.default)(e)),this},digest:()=>t.digest()}},t}},"__esModule",{value:!0}),Y=X,z=T(function(e,t){var r=F&&F.__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)(Y.sha256)}),J=T(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))}}),Q=T(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],o={sha256:z.sha256},s=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,o=t.versionTypes,s=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:s.length-("number"==typeof n[0]?1:n[0].length),c=s.slice(0,-i),a=s.slice(-i);for(let e=0;e<n.length;e++){const t=Array.isArray(n[e])?n[e]:[n[e]];if((0,J.arrayEqual)(c,t))return{version:t,bytes:a,type:o?o[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,J.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,J.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,J.arrayEqual)(t,r)}}(o);function i(e){return s.encode(e,{versions:[0],expectedLength:20})}function c(e){return s.decode(e,{versions:[0],expectedLength:20}).bytes}function a(e,t){return"byteLength"in e?e.byteLength===t:e.length===t}t.codec=s,t.encodeSeed=function(e,t){if(!a(e,16))throw new Error("entropy must have length 16");return s.encode(e,{expectedLength:16,versions:"ed25519"===t?r:[33]})},t.decodeSeed=function(e,t={versionTypes:["ed25519","secp256k1"],versions:[r,33],expectedLength:16}){return s.decode(e,t)},t.encodeAccountID=i,t.encodeAddress=i,t.decodeAccountID=c,t.decodeAddress=c,t.decodeNodePublic=function(e){return s.decode(e,{versions:[28],expectedLength:33}).bytes},t.encodeNodePublic=function(e){return s.encode(e,{versions:[28],expectedLength:33})},t.encodeAccountPublic=function(e){return s.encode(e,{versions:[35],expectedLength:33})},t.decodeAccountPublic=function(e){return s.decode(e,{versions:[35],expectedLength:33}).bytes},t.isValidClassicAddress=function(e){try{c(e)}catch(e){return!1}return!0}}),Z=T(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 Q.codec}}),Object.defineProperty(t,"encodeSeed",{enumerable:!0,get:function(){return Q.encodeSeed}}),Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return Q.decodeSeed}}),Object.defineProperty(t,"encodeAccountID",{enumerable:!0,get:function(){return Q.encodeAccountID}}),Object.defineProperty(t,"decodeAccountID",{enumerable:!0,get:function(){return Q.decodeAccountID}}),Object.defineProperty(t,"encodeNodePublic",{enumerable:!0,get:function(){return Q.encodeNodePublic}}),Object.defineProperty(t,"decodeNodePublic",{enumerable:!0,get:function(){return Q.decodeNodePublic}}),Object.defineProperty(t,"encodeAccountPublic",{enumerable:!0,get:function(){return Q.encodeAccountPublic}}),Object.defineProperty(t,"decodeAccountPublic",{enumerable:!0,get:function(){return Q.decodeAccountPublic}}),Object.defineProperty(t,"isValidClassicAddress",{enumerable:!0,get:function(){return Q.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 o=t||0,s=(0,R.concat)([n?r.test:r.main,e,Uint8Array.from([!1===t||null==t?0:1,255&o,o>>8&255,o>>16&255,o>>24&255,0,0,0,0])]);return Q.codec.encodeChecked(s)}function o(e){const t=Q.codec.decodeChecked(e),n=function(e){const t=e.slice(0,2);if((0,R.equal)(r.main,t))return!1;if((0,R.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,R.equal)((0,R.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,Q.decodeAccountID)(e),t,r)},t.encodeXAddress=n,t.xAddressToClassicAddress=function(e){const{accountId:t,tag:r,test:n}=o(e);return{classicAddress:(0,Q.encodeAccountID)(t),tag:r,test:n}},t.decodeXAddress=o,t.isValidXAddress=function(e){try{o(e)}catch(e){return!1}return!0}}),ee=T(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=void 0;const r=/* @__PURE__ */new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),n=/* @__PURE__ */new Uint8Array(new Array(16).fill(0).map((e,t)=>t));let o=[n],s=[/* @__PURE__ */n.map(e=>(9*e+5)%16)];for(let e=0;e<4;e++)for(let t of[o,s])t.push(t[e].map(e=>r[e]));const i=/* @__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=>new Uint8Array(e)),c=/* @__PURE__ */o.map((e,t)=>e.map(e=>i[t][e])),a=/* @__PURE__ */s.map((e,t)=>e.map(e=>i[t][e])),d=/* @__PURE__ */new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),u=/* @__PURE__ */new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function h(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 f=/* @__PURE__ */new Uint32Array(16);class l extends W.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:o}=this;return[e,t,r,n,o]}set(e,t,r,n,o){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|o}process(e,t){for(let r=0;r<16;r++,t+=4)f[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,i=0|this.h1,l=i,p=0|this.h2,b=p,y=0|this.h3,g=y,x=0|this.h4,w=x;for(let e=0;e<5;e++){const t=4-e,A=d[e],v=u[e],E=o[e],m=s[e],_=c[e],P=a[e];for(let t=0;t<16;t++){const n=(0,N.rotl)(r+h(e,i,p,y)+f[E[t]]+A,_[t])+x|0;r=x,x=y,y=0|(0,N.rotl)(p,10),p=i,i=n}for(let e=0;e<16;e++){const r=(0,N.rotl)(n+h(t,l,b,g)+f[m[e]]+v,P[e])+w|0;n=w,w=g,g=0|(0,N.rotl)(b,10),b=l,l=r}}this.set(this.h1+p+g|0,this.h2+y+w|0,this.h3+x+n|0,this.h4+r+l|0,this.h0+i+b|0)}roundClean(){f.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}t.RIPEMD160=l,t.ripemd160=(0,N.wrapConstructor)(()=>new l)}),te=T(function(e,t){var r=F&&F.__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)(ee.ripemd160)}),re=T(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.add5L=t.add5H=t.add4H=t.add4L=t.add3H=t.add3L=t.rotlBL=t.rotlBH=t.rotlSL=t.rotlSH=t.rotr32L=t.rotr32H=t.rotrBL=t.rotrBH=t.rotrSL=t.rotrSH=t.shrSL=t.shrSH=t.toBig=void 0,t.fromBig=o,t.split=s,t.add=w;const r=/* @__PURE__ */BigInt(2**32-1),n=/* @__PURE__ */BigInt(32);function o(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 s(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:i,l:c}=o(e[s],t);[r[s],n[s]]=[i,c]}return[r,n]}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 d=(e,t,r)=>e>>>r|t<<32-r;t.rotrSH=d;const u=(e,t,r)=>e<<32-r|t>>>r;t.rotrSL=u;const h=(e,t,r)=>e<<64-r|t>>>r-32;t.rotrBH=h;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 b=(e,t,r)=>e<<r|t>>>32-r;t.rotlSH=b;const y=(e,t,r)=>t<<r|e>>>32-r;t.rotlSL=y;const g=(e,t,r)=>t<<r-32|e>>>64-r;t.rotlBH=g;const x=(e,t,r)=>e<<r-32|t>>>64-r;function w(e,t,r,n){const o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:0|o}}t.rotlBL=x;const A=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);t.add3L=A;const v=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;t.add3H=v;const E=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);t.add4L=E;const m=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0;t.add4H=m;const _=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0);t.add5L=_;const P=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;t.add5H=P,t.default={fromBig:o,split:s,toBig:i,shrSH:c,shrSL:a,rotrSH:d,rotrSL:u,rotrBH:h,rotrBL:f,rotr32H:l,rotr32L:p,rotlSH:b,rotlSL:y,rotlBH:g,rotlBL:x,add:w,add3L:A,add3H:v,add4L:E,add4H:m,add5H:P,add5L:_}}),ne=T(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha384=t.sha512_256=t.sha512_224=t.sha512=t.SHA384=t.SHA512_256=t.SHA512_224=t.SHA512=void 0;const[r,n]=/* @__PURE__ */(()=>re.default.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))))(),o=/* @__PURE__ */new Uint32Array(80),s=/* @__PURE__ */new Uint32Array(80);class i extends W.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:o,Cl:s,Dh:i,Dl:c,Eh:a,El:d,Fh:u,Fl:h,Gh:f,Gl:l,Hh:p,Hl:b}=this;return[e,t,r,n,o,s,i,c,a,d,u,h,f,l,p,b]}set(e,t,r,n,o,s,i,c,a,d,u,h,f,l,p,b){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|o,this.Cl=0|s,this.Dh=0|i,this.Dl=0|c,this.Eh=0|a,this.El=0|d,this.Fh=0|u,this.Fl=0|h,this.Gh=0|f,this.Gl=0|l,this.Hh=0|p,this.Hl=0|b}process(e,t){for(let r=0;r<16;r++,t+=4)o[r]=e.getUint32(t),s[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|o[e-15],r=0|s[e-15],n=re.default.rotrSH(t,r,1)^re.default.rotrSH(t,r,8)^re.default.shrSH(t,r,7),i=re.default.rotrSL(t,r,1)^re.default.rotrSL(t,r,8)^re.default.shrSL(t,r,7),c=0|o[e-2],a=0|s[e-2],d=re.default.rotrSH(c,a,19)^re.default.rotrBH(c,a,61)^re.default.shrSH(c,a,6),u=re.default.rotrSL(c,a,19)^re.default.rotrBL(c,a,61)^re.default.shrSL(c,a,6),h=re.default.add4L(i,u,s[e-7],s[e-16]),f=re.default.add4H(h,n,d,o[e-7],o[e-16]);o[e]=0|f,s[e]=0|h}let{Ah:i,Al:c,Bh:a,Bl:d,Ch:u,Cl:h,Dh:f,Dl:l,Eh:p,El:b,Fh:y,Fl:g,Gh:x,Gl:w,Hh:A,Hl:v}=this;for(let e=0;e<80;e++){const t=re.default.rotrSH(p,b,14)^re.default.rotrSH(p,b,18)^re.default.rotrBH(p,b,41),E=re.default.rotrSL(p,b,14)^re.default.rotrSL(p,b,18)^re.default.rotrBL(p,b,41),m=p&y^~p&x,_=re.default.add5L(v,E,b&g^~b&w,n[e],s[e]),P=re.default.add5H(_,A,t,m,r[e],o[e]),L=0|_,H=re.default.rotrSH(i,c,28)^re.default.rotrBH(i,c,34)^re.default.rotrBH(i,c,39),S=re.default.rotrSL(i,c,28)^re.default.rotrBL(i,c,34)^re.default.rotrBL(i,c,39),B=i&a^i&u^a&u,D=c&d^c&h^d&h;A=0|x,v=0|w,x=0|y,w=0|g,y=0|p,g=0|b,({h:p,l:b}=re.default.add(0|f,0|l,0|P,0|L)),f=0|u,l=0|h,u=0|a,h=0|d,a=0|i,d=0|c;const I=re.default.add3L(L,S,D);i=re.default.add3H(I,P,H,B),c=0|I}({h:i,l:c}=re.default.add(0|this.Ah,0|this.Al,0|i,0|c)),({h:a,l:d}=re.default.add(0|this.Bh,0|this.Bl,0|a,0|d)),({h:u,l:h}=re.default.add(0|this.Ch,0|this.Cl,0|u,0|h)),({h:f,l}=re.default.add(0|this.Dh,0|this.Dl,0|f,0|l)),({h:p,l:b}=re.default.add(0|this.Eh,0|this.El,0|p,0|b)),({h:y,l:g}=re.default.add(0|this.Fh,0|this.Fl,0|y,0|g)),({h:x,l:w}=re.default.add(0|this.Gh,0|this.Gl,0|x,0|w)),({h:A,l:v}=re.default.add(0|this.Hh,0|this.Hl,0|A,0|v)),this.set(i,c,a,d,u,h,f,l,p,b,y,g,x,w,A,v)}roundClean(){o.fill(0),s.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=i;class c extends i{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}t.SHA512_224=c;class a extends i{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}t.SHA512_256=a;class d extends i{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}t.SHA384=d,t.sha512=(0,N.wrapConstructor)(()=>new i),t.sha512_224=(0,N.wrapConstructor)(()=>new c),t.sha512_256=(0,N.wrapConstructor)(()=>new a),t.sha384=(0,N.wrapConstructor)(()=>new d)}),oe=T(function(e,t){var r=F&&F.__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)(ne.sha512)});class se{constructor(){this.hash=oe.sha512.create()}static half(e){return(new se).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 ie=/*#__PURE__*/Object.defineProperty({default:se},"__esModule",{value:!0}),ce=T(function(e,t){var r=F&&F.__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(ie),o=BigInt(0);function s(e,t){const r=y.secp256k1.CURVE.n;for(let s=0;s<=4294967295;s++){const i=(new n.default).add(e);void 0!==t&&i.addU32(t),i.addU32(s);const c=i.first256BigInt();if(c>o&&c<r)return c}throw new Error("impossible unicorn ;)")}t.derivePrivateKey=function(e,t={}){const r=t.validator,n=y.secp256k1.CURVE.n,o=s(e);return r?o:(s(y.secp256k1.ProjectivePoint.BASE.multiply(o).toRawBytes(!0),t.accountIndex||0)+o)%n},t.accountPublicFromPublicGenerator=function(e){const t=y.secp256k1.ProjectivePoint.fromHex(e),r=s(e,0),n=y.secp256k1.ProjectivePoint.BASE.multiply(r);return t.add(n).toRawBytes(!0)}}),ae=/*#__PURE__*/Object.defineProperty({default:{ok(e,t){if(!e)throw new Error(t)}}},"__esModule",{value:!0}),de=T(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 o(e){return e===r.NONE?"None":`0x${e.toString(16).padStart(2,"0")}`}function s(e,t){const{prefix:s,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:s,a=n[`${t}_${c}_${i}`];if(!a)throw new Error(function({key:e,type:t,prefix:r,len:s}){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: ${o(Number(r)).padEnd(6)} Length: ${n} bytes`}).join("\n")}(t);return`invalid_key:\n\nType: ${t}\nKey: ${e}\nPrefix: ${o(r)} \nLength: ${s} bytes\n\nAcceptable ${t} formats are:\n${i}\n`}({key:e,type:t,len:i,prefix:c}));return a}t.getAlgorithmFromKey=s,t.getAlgorithmFromPublicKey=function(e){return s(e,"public")},t.getAlgorithmFromPrivateKey=function(e){return s(e,"private")}}),ue=F&&F.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const he=ue(ae),fe=ue(ie);var le=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e,t){const r=(0,ce.derivePrivateKey)(e,t);return{privateKey:"00"+(0,R.bytesToHex)((0,E.numberToBytesBE)(r,32)),publicKey:(0,R.bytesToHex)(y.secp256k1.getPublicKey(r,!0))}},sign(e,t){he.default.ok(66===t.length&&t.startsWith("00")||64===t.length);const r=66===t.length?t.slice(2):t;return y.secp256k1.sign(fe.default.half(e),r,{lowS:!0,extraEntropy:void 0}).toDERHex(!0).toUpperCase()},verify(e,t,r){const n=y.secp256k1.Signature.fromDER(t);return y.secp256k1.verify(n,fe.default.half(e),r)}}},"__esModule",{value:!0}),pe=F&&F.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const be=pe(ae),ye=pe(ie);var ge=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e){const t=ye.default.half(e);return{privateKey:"ED"+(0,R.bytesToHex)(t),publicKey:"ED"+(0,R.bytesToHex)(m.ed25519.getPublicKey(t))}},sign:(e,t)=>(be.default.ok(e instanceof Uint8Array,"message must be array of octets"),be.default.ok(66===t.length,"private key must be 33 bytes including prefix"),(0,R.bytesToHex)(m.ed25519.sign(e,t.slice(2)))),verify:(e,t,r)=>(be.default.ok(66===r.length,"public key must be 33 bytes including prefix"),m.ed25519.verify(t,e,r.slice(2),{zip215:!1}))}},"__esModule",{value:!0}),xe=T(function(e,t){var r=F&&F.__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 Z.decodeSeed}});const n=r(ie),o=r(ae),s=r(le),i=r(ge);function c(e){return{"ecdsa-secp256k1":s.default,ed25519:i.default}[e]}function a(e){return(0,Z.encodeAccountID)(function(e){return(0,te.ripemd160)((0,z.sha256)(e))}(e))}t.generateSeed=function(e={}){o.default.ok(!e.entropy||e.entropy.length>=16,"entropy too short");const t=e.entropy?e.entropy.slice(0,16):(0,R.randomBytes)(16);return(0,Z.encodeSeed)(t,"ed25519"===e.algorithm?"ed25519":"secp256k1")},t.deriveKeypair=function(e,t){var r;const o=(0,Z.decodeSeed)(e),s=c("ed25519"===(null!==(r=null==t?void 0:t.algorithm)&&void 0!==r?r:o.type)?"ed25519":"ecdsa-secp256k1"),i=s.deriveKeypair(o.bytes,t),a=n.default.half("This test message should verify."),d=s.sign(a,i.privateKey);if(!s.verify(a,d,i.publicKey))throw new Error("derived keypair did not generate verifiable signature");return i},t.sign=function(e,t){return c((0,de.getAlgorithmFromPrivateKey)(t)).sign((0,R.hexToBytes)(e),t)},t.verify=function(e,t,r){return c((0,de.getAlgorithmFromPublicKey)(r)).verify((0,R.hexToBytes)(e),t,r)},t.deriveAddress=function(e){return a((0,R.hexToBytes)(e))},t.deriveNodeAddress=function(e){const t=(0,Z.decodeNodePublic)(e);return a((0,ce.accountPublicFromPublicGenerator)(t))}});const we=["wss://s1.ripple.com","wss://xrplcluster.com/","wss://s2.ripple.com/"];function Ae(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")}async function ve(n,o){switch(n.type){case t.SelfDeclaration:return _({},n,{status:n.confirmed?e.VERIFIED:e.FAILED});case t.Screenshot:return _({},n,{status:n.url?e.FLAGGED:e.FAILED});case t.CIP8:return async function(t){var r;const[n,,o]=t.address.split(/:/),s=null==(r=t.chainSpecificData)?void 0:r.cardanoCoseKey;if("cardano"!==n||!s)return _({},t,{status:e.FAILED});try{return _({},t,{status:A(t.proof,s,t.attestation,o)?e.VERIFIED:e.FAILED})}catch(r){return _({},t,{status:e.FAILED})}}(n);case t.EIP191:return async function(t){const[r,,n]=t.address.split(/:/);if("eip155"!==r)return _({},t,{status:e.FAILED});const o=function(e,t,r){try{const n=d.getSignPayload(u.fromString(t)),o=h.fromHex(r),s=f.recoverPublicKey({payload:n,signature:o});return l.checksum(l.fromPublicKey(s)).toString()===l.checksum(e)}catch(e){return!1}}(n,t.attestation,t.proof);return _({},t,{status:o?e.VERIFIED:e.FAILED})}(n);case t.ED25519:return async function(t){const[r,,n]=t.address.split(/:/);if("solana"!==r)return _({},t,{status:e.FAILED});try{const r=c.decode(n),o=(new TextEncoder).encode(t.attestation),s=i.decode(t.proof);return _({},t,{status:w.sign.detached.verify(o,s,r)?e.VERIFIED:e.FAILED})}catch(r){return _({},t,{status:e.FAILED})}}(n);case t.XRP_ED25519:return async function(t,r){const[n,,o]=t.address.split(/:/);if("xrpl"!==n)return _({},t,{status:e.FAILED});if(r||(r=await async function(e){const t=we;for(const n of t)try{var r;const t=new v(n);await t.connect();const o=await t.request({command:"account_tx",account:e,binary:!1,limit:2,forward:!1});return await t.disconnect(),Ae(null==(r=o.result)?void 0:r.transactions)}catch(e){let t="Connection to XRPL server failed";e instanceof Error&&(t+=`: ${e.message}`),console.error(t)}throw new Error("Failed to connect to any XRPL server")}(o)),!r)return _({},t,{status:e.FAILED});const s=function(e,t,r){return xe.verify(Buffer.from(e).toString("hex"),r,t)}(t.attestation,r,t.proof);return _({},t,{status:s?e.VERIFIED:e.FAILED})}(n,o);case t.EIP712:case t.BIP137:case t.BIP322:return async function(n){const[o,,s]=n.address.split(/:/);if("bip122"!==o)return _({},n,{status:e.FAILED});const c=function(e){return e.startsWith("1")||e.startsWith("3")||e.startsWith("bc1")?L:e.startsWith("L")||e.startsWith("M")||e.startsWith("ltc1")?S:e.startsWith("D")||e.startsWith("A")?B:e.startsWith("X")||e.startsWith("7")?D:e.startsWith("q")?H:L}(s);if(!c)return _({},n,{status:e.FAILED});try{switch(n.type){case t.BIP137:return function(t,n,o){const s=Boolean(o.bech32Prefix&&[I.SEGWIT,I.NATIVE].includes(function(e){if(e.match("^(bc1|tb1|ltc1).*"))return I.NATIVE;if(e.match("^[32M].*"))return I.SEGWIT;if(e.match("^[1nmL].*"))return I.LEGACY;if(e.match("^(D).*"))return I.DOGECOIN;if(e.match("^(q).*"))return I.BCH;throw new Error("INVALID ADDRESS: ".concat(e).concat(" is not a valid or a supported address"))}(t))),c=function(e,t,n,o,s){const{compressed:c,segwitType:d,signature:u}=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),o=3&r,s=g.Signature.fromCompact(t.slice(1));return{compressed:n,segwitType:8&r?4&r?P.P2WPKH:P.P2SH_P2WPKH:void 0,signature:s.addRecoveryBit(o)}}(n);if(o&&!c)throw new Error("checkSegwitAlways can only be used with a compressed pubkey signature flagbyte");const h=function(e,t){const n=(new TextEncoder).encode(t),o=(new TextEncoder).encode(e),s=r(o.length).buffer,i=new Uint8Array(n.length+s.byteLength+o.length);return i.set(n),i.set(new Uint8Array(s),n.length),i.set(o,n.length+s.byteLength),function(e){return a.sha256(a.sha256(e))}(i)}(e,s.messagePrefix),f=(l=u.recoverPublicKey(h).toRawBytes(c),a.ripemd160(a.sha256(l)));var l;let p="";if(t.startsWith("q"))return p=U(s.pubKeyHashVersion,f),p.startsWith("1");if(d)p=d===P.P2SH_P2WPKH?U(s.scriptHashVersion,f):s.bech32Prefix?O(f,s.bech32Prefix):U(s.scriptHashVersion,f);else if(o&&s.bech32Prefix)try{p=O(f,s.bech32Prefix)}catch(e){p=U(s.scriptHashVersion,f)}else p=U(s.pubKeyHashVersion,f);return p===t}(n.attestation,t,n.proof,s,o);return _({},n,{status:c?e.VERIFIED:e.FAILED})}(s,n,c);case t.BIP322:return function(t,r){const{attestation:n,proof:o}=r;return _({},r,{status:x.verifySignature(t,n,o)?e.VERIFIED:e.FAILED})}(s,n);default:return _({},n,{status:e.FAILED})}}catch(t){return _({},n,{status:e.FAILED})}}(n);case t.TIP191:return async function(t){const[r,,n]=t.address.split(/:/);return _({},t,"tron"!==r?{status:e.FAILED}:{status:k(n,t.attestation,t.proof)?e.VERIFIED:e.FAILED})}(n)}return n}export{ve as verifyProof};
|
2
2
|
//# sourceMappingURL=index.modern.js.map
|