@secux/app-btc
Version:
SecuX Hardware Wallet BTC API
2 lines • 518 kB
JavaScript
/*! For license information please see index.js.LICENSE.txt */
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("ow"),function(){try{return require("@secux/transport")}catch(t){}}(),require("@secux/utility"),require("@secux/protocol-transaction"));else if("function"==typeof define&&define.amd)define(["ow","@secux/transport","@secux/utility","@secux/protocol-transaction"],e);else{var r="object"==typeof exports?e(require("ow"),function(){try{return require("@secux/transport")}catch(t){}}(),require("@secux/utility"),require("@secux/protocol-transaction")):e(t.ow,t["@secux/transport"],t["@secux/utility"],t["@secux/protocol-transaction"]);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(this,((t,e,r,n)=>(()=>{var i={54:(t,e,r)=>{var n=r(6093),i=r(5636).Buffer,o=r(711),s=o.valueOf(3);function a(t,e,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=t,this.x=e,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(a.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(a.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(a.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),a.fromAffine=function(t,e,r){return new a(t,e,r,o.ONE)},a.prototype.equals=function(t){return t===this||(this.curve.isInfinity(this)?this.curve.isInfinity(t):this.curve.isInfinity(t)?this.curve.isInfinity(this):0===t.y.multiply(this.z).subtract(this.y.multiply(t.z)).mod(this.curve.p).signum()&&0===t.x.multiply(this.z).subtract(this.x.multiply(t.z)).mod(this.curve.p).signum())},a.prototype.negate=function(){var t=this.curve.p.subtract(this.y);return new a(this.curve,this.x,t,this.z)},a.prototype.add=function(t){if(this.curve.isInfinity(this))return t;if(this.curve.isInfinity(t))return this;var e=this.x,r=this.y,n=t.x,i=t.y.multiply(this.z).subtract(r.multiply(t.z)).mod(this.curve.p),o=n.multiply(this.z).subtract(e.multiply(t.z)).mod(this.curve.p);if(0===o.signum())return 0===i.signum()?this.twice():this.curve.infinity;var f=o.square(),u=f.multiply(o),c=e.multiply(f),h=i.square().multiply(this.z),l=h.subtract(c.shiftLeft(1)).multiply(t.z).subtract(u).multiply(o).mod(this.curve.p),d=c.multiply(s).multiply(i).subtract(r.multiply(u)).subtract(h.multiply(i)).multiply(t.z).add(i.multiply(u)).mod(this.curve.p),p=u.multiply(this.z).multiply(t.z).mod(this.curve.p);return new a(this.curve,l,d,p)},a.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var t=this.x,e=this.y,r=e.multiply(this.z).mod(this.curve.p),n=r.multiply(e).mod(this.curve.p),i=this.curve.a,o=t.square().multiply(s);0!==i.signum()&&(o=o.add(this.z.square().multiply(i)));var f=(o=o.mod(this.curve.p)).square().subtract(t.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),u=o.multiply(s).multiply(t).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(o.pow(3)).mod(this.curve.p),c=r.pow(3).shiftLeft(3).mod(this.curve.p);return new a(this.curve,f,u,c)},a.prototype.multiply=function(t){if(this.curve.isInfinity(this))return this;if(0===t.signum())return this.curve.infinity;for(var e=t,r=e.multiply(s),n=this.negate(),i=this,o=r.bitLength()-2;o>0;--o){var a=r.testBit(o),f=e.testBit(o);i=i.twice(),a!==f&&(i=i.add(a?this:n))}return i},a.prototype.multiplyTwo=function(t,e,r){for(var n=Math.max(t.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(e);n>=0;){var s=t.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(e)),--n}return i},a.prototype.getEncoded=function(t){if(null==t&&(t=this.compressed),this.curve.isInfinity(this))return i.alloc(1,0);var e,r=this.affineX,n=this.affineY,o=this.curve.pLength;return t?(e=i.allocUnsafe(1+o)).writeUInt8(n.isEven()?2:3,0):((e=i.allocUnsafe(1+o+o)).writeUInt8(4,0),n.toBuffer(o).copy(e,1+o)),r.toBuffer(o).copy(e,1),e},a.decodeFrom=function(t,e){var r,i=e.readUInt8(0),s=4!==i,f=Math.floor((t.p.bitLength()+7)/8),u=o.fromBuffer(e.slice(1,1+f));if(s){n.equal(e.length,f+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var c=3===i;r=t.pointFromX(c,u)}else{n.equal(e.length,1+f+f,"Invalid sequence length");var h=o.fromBuffer(e.slice(1+f));r=a.fromAffine(t,u,h)}return r.compressed=s,r},a.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},t.exports=a},179:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.taprootVerify=e.taprootConvert=void 0;const n=r(622),i=r(711),o=r(7436),s=o.getCurveByName("secp256k1"),a=s.G,f=s.p,u=s.n,c=i.ZERO,h=i.ONE,l=i.valueOf(2),d=i.valueOf(3),p=i.valueOf(4),b=i.valueOf(7);function y(t){const e=i.fromBuffer(t),r=e.pow(d).add(b).mod(f),n=r.modPow(f.add(h).divide(p),f);if(0!==r.compareTo(n.modPow(l,f)))throw new Error("c is not equal to y^2");let a=o.Point.fromAffine(s,e,n);return g(a)||(a=o.Point.fromAffine(s,e,f.subtract(n))),a}function g(t){return t.affineY.mod(l).equals(c)}e.taprootConvert=function(t,e){const r=y(t),n=i.fromBuffer(e);return r.add(a.multiply(n)).affineX.toBuffer(32)},e.taprootVerify=function(t,e,r){const o=y(r),s=o.affineX.toBuffer(32),c=i.fromBuffer(t.slice(0,32)),h=i.fromBuffer(t.slice(32,64));if(c.compareTo(f)>=0)return!1;if(h.compareTo(u)>=0)return!1;const l=function(t,e,r){const o=(0,n.taggedHash)("BIP0340/challenge",Buffer.concat([t,e,r]));return i.fromBuffer(o).mod(u)}(c.toBuffer(32),s,e),d=function(t,e,r){const n=a.multiply(t),i=r.multiply(e);return n.add(i.negate())}(h,l,o);return!(d.curve.isInfinity(d)||!g(d)||!d.affineX.equals(c))}},183:t=>{"use strict";t.exports={rE:"6.6.1"}},220:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CoinType=e.PaymentGRS=void 0;const n=r(1249);Object.defineProperty(e,"CoinType",{enumerable:!0,get:function(){return n.CoinType}});const i=r(2642),o=r(9981);class s extends n.PaymentBTC{static CoinSupported(t){if(t!==n.CoinType.GROESTL)throw Error("Not supported cointype")}}e.PaymentGRS=s,s.bs58check=new i.bs58Check((function(t){return Buffer.from(o.groestl_2(t,1,1))}))},238:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(2706),i=r(8133);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:n,inputKeyVals:o,outputKeyVals:s}=a({globalMap:t,inputs:e,outputs:r}),f=i.keyValsToBuffer(n),u=t=>0===t.length?[Buffer.from([0])]:t.map(i.keyValsToBuffer),c=u(o),h=u(s),l=Buffer.allocUnsafe(5);return l.writeUIntBE(482972169471,0,5),Buffer.concat([l,f].concat(c,h))};const o=(t,e)=>t.key.compare(e.key);function s(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if("unknownKeyVals"===n)return t;const o=e[n];if(void 0===o)return t;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((t=>t.key.toString("hex"))).forEach((t=>{if(r.has(t))throw new Error("Serialize Error: Duplicate key: "+t);r.add(t)})),t.concat(s)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString("hex")))):[];return n.concat(i).sort(o)}function a({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:s(t,n.globals),inputKeyVals:e.map((t=>s(t,n.inputs))),outputKeyVals:r.map((t=>s(t,n.outputs)))}}e.psbtToKeyVals=a},277:(t,e,r)=>{"use strict";var n=r(1874),i=r(4845),o=r(5615),s=r(5174),a=n.assert;function f(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(f,s),t.exports=f,f.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new i(t.a,16),b:new i(t.b,16)}})):this._getEndoBasis(r)}}},f.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},f.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,f,u,c,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),g=new i(1),m=0;0!==l.cmpn(0);){var v=d.div(l);u=d.sub(v.mul(l)),c=y.sub(v.mul(p));var w=g.sub(v.mul(b));if(!n&&u.cmp(h)<0)e=f.neg(),r=p,n=u.neg(),o=c;else if(n&&2==++m)break;f=u,d=l,l=u,y=p,p=c,g=b,b=w}s=u.neg(),a=c;var S=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(S)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},f.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),f=i.mul(r.b),u=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:f.add(u).neg()}},f.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},f.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},f.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o<t.length;o++){var s=this._endoSplit(e[o]),a=t[o],f=a._getBeta();s.k1.negative&&(s.k1.ineg(),a=a.neg(!0)),s.k2.negative&&(s.k2.ineg(),f=f.neg(!0)),n[2*o]=a,n[2*o+1]=f,i[2*o]=s.k1,i[2*o+1]=s.k2}for(var u=this._wnafMulAdd(1,n,i,2*o,r),c=0;c<2*o;c++)n[c]=null,i[c]=null;return u},o(u,s.BasePoint),f.prototype.point=function(t,e,r){return new u(this,t,e,r)},f.prototype.pointFromJSON=function(t,e){return u.fromJSON(this,t,e)},u.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,n=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(n)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(n)}}}return e}},u.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},u.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var n=t.point(e[0],e[1],r);if(!e[2])return n;function i(e){return t.point(e[0],e[1],r)}var o=e[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(i))}},n},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},u.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},u.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},u.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},u.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(c,s.BasePoint),f.prototype.jpoint=function(t,e,r){return new c(this,t,e,r)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),f=o.redSub(s);if(0===a.cmpn(0))return 0!==f.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),h=n.redMul(u),l=f.redSqr().redIAdd(c).redISub(h).redISub(h),d=f.redMul(h.redISub(l)).redISub(o.redMul(c)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},c.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),u=f.redMul(s),c=r.redMul(f),h=a.redSqr().redIAdd(u).redISub(c).redISub(c),l=a.redMul(c.redISub(h)).redISub(i.redMul(u)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},c.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var n=this.curve.a,i=this.curve.tinv,o=this.x,s=this.y,a=this.z,f=a.redSqr().redSqr(),u=s.redAdd(s);for(e=0;e<t;e++){var c=o.redSqr(),h=u.redSqr(),l=h.redSqr(),d=c.redAdd(c).redIAdd(c).redIAdd(n.redMul(f)),p=o.redMul(h),b=d.redSqr().redISub(p.redAdd(p)),y=p.redISub(b),g=d.redMul(y);g=g.redIAdd(g).redISub(l);var m=u.redMul(a);e+1<t&&(f=f.redMul(l)),o=b,a=m,u=g}return this.curve.jpoint(o,u.redMul(i),a)},c.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},c.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n),f=a.redSqr().redISub(s).redISub(s),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=f,e=a.redMul(s.redISub(f)).redISub(u),r=this.y.redAdd(this.y)}else{var c=this.x.redSqr(),h=this.y.redSqr(),l=h.redSqr(),d=this.x.redAdd(h).redSqr().redISub(c).redISub(l);d=d.redIAdd(d);var p=c.redAdd(c).redIAdd(c),b=p.redSqr(),y=l.redIAdd(l);y=(y=y.redIAdd(y)).redIAdd(y),t=b.redISub(d).redISub(d),e=p.redMul(d.redISub(t)).redISub(y),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},c.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),f=a.redSqr().redISub(s).redISub(s);t=f;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=a.redMul(s.redISub(f)).redISub(u),r=this.y.redAdd(this.y)}else{var c=this.z.redSqr(),h=this.y.redSqr(),l=this.x.redMul(h),d=this.x.redSub(c).redMul(this.x.redAdd(c));d=d.redAdd(d).redIAdd(d);var p=l.redIAdd(l),b=(p=p.redIAdd(p)).redAdd(p);t=d.redSqr().redISub(b),r=this.y.redAdd(this.z).redSqr().redISub(h).redISub(c);var y=h.redSqr();y=(y=(y=y.redIAdd(y)).redIAdd(y)).redIAdd(y),e=d.redMul(p.redISub(t)).redISub(y)}return this.curve.jpoint(t,e,r)},c.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),o=e.redSqr(),s=r.redSqr(),a=o.redAdd(o).redIAdd(o).redIAdd(t.redMul(i)),f=e.redAdd(e),u=(f=f.redIAdd(f)).redMul(s),c=a.redSqr().redISub(u.redAdd(u)),h=u.redISub(c),l=s.redSqr();l=(l=(l=l.redIAdd(l)).redIAdd(l)).redIAdd(l);var d=a.redMul(h).redISub(l),p=r.redAdd(r).redMul(n);return this.curve.jpoint(c,d,p)},c.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),n=e.redSqr(),i=t.redAdd(t).redIAdd(t),o=i.redSqr(),s=this.x.redAdd(e).redSqr().redISub(t).redISub(n),a=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(o)).redSqr(),f=n.redIAdd(n);f=(f=(f=f.redIAdd(f)).redIAdd(f)).redIAdd(f);var u=i.redIAdd(s).redSqr().redISub(o).redISub(a).redISub(f),c=e.redMul(u);c=(c=c.redIAdd(c)).redIAdd(c);var h=this.x.redMul(a).redISub(c);h=(h=h.redIAdd(h)).redIAdd(h);var l=this.y.redMul(u.redMul(f.redISub(u)).redISub(s.redMul(a)));l=(l=(l=l.redIAdd(l)).redIAdd(l)).redIAdd(l);var d=this.z.redAdd(s).redSqr().redISub(r).redISub(a);return this.curve.jpoint(h,l,d)},c.prototype.mul=function(t,e){return t=new i(t,e),this.curve._wnafMul(this,t)},c.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var n=e.redMul(this.z),i=r.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(n)).cmpn(0)},c.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var n=t.clone(),i=this.curve.redN.redMul(e);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},394:(t,e)=>{"use strict";function r(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function n(t){return r(t),t<253?1:t<=65535?3:t<=4294967295?5:9}Object.defineProperty(e,"__esModule",{value:!0}),e.encode=function t(e,i,o){if(r(e),i||(i=Buffer.allocUnsafe(n(e))),!Buffer.isBuffer(i))throw new TypeError("buffer must be a Buffer instance");return o||(o=0),e<253?(i.writeUInt8(e,o),Object.assign(t,{bytes:1})):e<=65535?(i.writeUInt8(253,o),i.writeUInt16LE(e,o+1),Object.assign(t,{bytes:3})):e<=4294967295?(i.writeUInt8(254,o),i.writeUInt32LE(e,o+1),Object.assign(t,{bytes:5})):(i.writeUInt8(255,o),i.writeUInt32LE(e>>>0,o+1),i.writeUInt32LE(e/4294967296|0,o+5),Object.assign(t,{bytes:9})),i},e.decode=function t(e,n){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");n||(n=0);const i=e.readUInt8(n);if(i<253)return Object.assign(t,{bytes:1}),i;if(253===i)return Object.assign(t,{bytes:3}),e.readUInt16LE(n+1);if(254===i)return Object.assign(t,{bytes:5}),e.readUInt32LE(n+1);{Object.assign(t,{bytes:9});const i=e.readUInt32LE(n+1),o=4294967296*e.readUInt32LE(n+5)+i;return r(o),o}},e.encodingLength=n},461:(t,e,r)=>{"use strict";var n=r(7784),i=r(5615);function o(t,e){return 55296==(64512&t.charCodeAt(e))&&!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function f(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=i,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(var n=0,i=0;i<t.length;i++){var s=t.charCodeAt(i);s<128?r[n++]=s:s<2048?(r[n++]=s>>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i<t.length;i++)r[i]=0|t[i];return r},e.toHex=function(t){for(var e="",r=0;r<t.length;r++)e+=a(t[r].toString(16));return e},e.htonl=s,e.toHex32=function(t,e){for(var r="",n=0;n<t.length;n++){var i=t[n];"little"===e&&(i=s(i)),r+=f(i.toString(16))}return r},e.zero2=a,e.zero8=f,e.join32=function(t,e,r,i){var o=r-e;n(o%4==0);for(var s=new Array(o/4),a=0,f=e;a<s.length;a++,f+=4){var u;u="big"===i?t[f]<<24|t[f+1]<<16|t[f+2]<<8|t[f+3]:t[f+3]<<24|t[f+2]<<16|t[f+1]<<8|t[f],s[a]=u>>>0}return s},e.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n<t.length;n++,i+=4){var o=t[n];"big"===e?(r[i]=o>>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,r){return t+e+r>>>0},e.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},e.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},e.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o<n?1:0)+r+i;t[e]=s>>>0,t[e+1]=o},e.sum64_hi=function(t,e,r,n){return(e+n>>>0<e?1:0)+t+r>>>0},e.sum64_lo=function(t,e,r,n){return e+n>>>0},e.sum64_4_hi=function(t,e,r,n,i,o,s,a){var f=0,u=e;return f+=(u=u+n>>>0)<e?1:0,f+=(u=u+o>>>0)<o?1:0,t+r+i+s+(f+=(u=u+a>>>0)<a?1:0)>>>0},e.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},e.sum64_5_hi=function(t,e,r,n,i,o,s,a,f,u){var c=0,h=e;return c+=(h=h+n>>>0)<e?1:0,c+=(h=h+o>>>0)<o?1:0,c+=(h=h+a>>>0)<a?1:0,t+r+i+s+f+(c+=(h=h+u>>>0)<u?1:0)>>>0},e.sum64_5_lo=function(t,e,r,n,i,o,s,a,f,u){return e+n+o+a+u>>>0},e.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},e.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},e.shr64_hi=function(t,e,r){return t>>>r},e.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},470:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TX_SIGN=e.TX_END=e.TX_BEGIN=e.TX_PREPARE=e.SIGN_TYPEDMESSAGE=e.SIGN_MESSAGE=e.SIGN_TX_RAW=e.SIGN_TX=e.GET_ECIES_SECRET=e.GET_XPUBLICKEY=e.GET_PUBLICKEY=void 0,e.GET_PUBLICKEY=[128,193],e.GET_XPUBLICKEY=[128,192],e.GET_ECIES_SECRET=[128,198],e.SIGN_TX=[112,164],e.SIGN_TX_RAW=[112,163],e.SIGN_MESSAGE=[112,165],e.SIGN_TYPEDMESSAGE=[112,166],e.TX_PREPARE=[112,160],e.TX_BEGIN=[128,114],e.TX_END=[128,118],e.TX_SIGN=[128,116]},528:(t,e,r)=>{"use strict";var n,i=r(9629),o=r(9838),s=r(9110),a=r(1155),f=r(4943),u=r(5731),c=r(3468),h=r(2140),l=r(8479),d=r(8449),p=r(8129),b=r(2387),y=r(5865),g=r(1319),m=r(6882),v=Function,w=function(t){try{return v('"use strict"; return ('+t+").constructor;")()}catch(t){}},S=r(9336),E=r(4940),M=function(){throw new c},T=S?function(){try{return M}catch(t){try{return S(arguments,"callee").get}catch(t){return M}}}():M,A=r(3558)(),I=r(6369),P=r(7345),x=r(7859),O=r(6095),_=r(4531),B={},k="undefined"!=typeof Uint8Array&&I?I(Uint8Array):n,R={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":A&&I?I([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":B,"%AsyncGenerator%":B,"%AsyncGeneratorFunction%":B,"%AsyncIteratorPrototype%":B,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":s,"%Float16Array%":"undefined"==typeof Float16Array?n:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":B,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":A&&I?I(I([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&A&&I?I((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":i,"%Object.getOwnPropertyDescriptor%":S,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":a,"%ReferenceError%":f,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&A&&I?I((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":A&&I?I(""[Symbol.iterator]()):n,"%Symbol%":A?Symbol:n,"%SyntaxError%":u,"%ThrowTypeError%":T,"%TypedArray%":k,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":h,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet,"%Function.prototype.call%":_,"%Function.prototype.apply%":O,"%Object.defineProperty%":E,"%Object.getPrototypeOf%":P,"%Math.abs%":l,"%Math.floor%":d,"%Math.max%":p,"%Math.min%":b,"%Math.pow%":y,"%Math.round%":g,"%Math.sign%":m,"%Reflect.getPrototypeOf%":x};if(I)try{null.error}catch(t){var N=I(I(t));R["%Error.prototype%"]=N}var U=function t(e){var r;if("%AsyncFunction%"===e)r=w("async function () {}");else if("%GeneratorFunction%"===e)r=w("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=w("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var i=t("%AsyncGenerator%");i&&I&&(r=I(i.prototype))}return R[e]=r,r},C={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},L=r(9138),D=r(8554),j=L.call(_,Array.prototype.concat),F=L.call(O,Array.prototype.splice),H=L.call(_,String.prototype.replace),q=L.call(_,String.prototype.slice),G=L.call(_,RegExp.prototype.exec),z=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,K=/\\(\\)?/g,V=function(t,e){var r,n=t;if(D(C,n)&&(n="%"+(r=C[n])[0]+"%"),D(R,n)){var i=R[n];if(i===B&&(i=U(n)),void 0===i&&!e)throw new c("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new u("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new c('"allowMissing" argument must be a boolean');if(null===G(/^%?[^%]*%?$/,t))throw new u("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=q(t,0,1),r=q(t,-1);if("%"===e&&"%"!==r)throw new u("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new u("invalid intrinsic syntax, expected opening `%`");var n=[];return H(t,z,(function(t,e,r,i){n[n.length]=r?H(i,K,"$1"):e||t})),n}(t),n=r.length>0?r[0]:"",i=V("%"+n+"%",e),o=i.name,s=i.value,a=!1,f=i.alias;f&&(n=f[0],F(r,j([0,1],f)));for(var h=1,l=!0;h<r.length;h+=1){var d=r[h],p=q(d,0,1),b=q(d,-1);if(('"'===p||"'"===p||"`"===p||'"'===b||"'"===b||"`"===b)&&p!==b)throw new u("property names with quotes must have matching quotes");if("constructor"!==d&&l||(a=!0),D(R,o="%"+(n+="."+d)+"%"))s=R[o];else if(null!=s){if(!(d in s)){if(!e)throw new c("base intrinsic for "+t+" exists, but the property is not available.");return}if(S&&h+1>=r.length){var y=S(s,d);s=(l=!!y)&&"get"in y&&!("originalValue"in y.get)?y.get:s[d]}else l=D(s,d),s=s[d];l&&!a&&(R[o]=s)}}return s}},536:(t,e,r)=>{"use strict";var n=r(461),i=r(2191),o=r(600),s=r(7784),a=n.sum32,f=n.sum32_4,u=n.sum32_5,c=o.ch32,h=o.maj32,l=o.s0_256,d=o.s1_256,p=o.g0_256,b=o.g1_256,y=i.BlockHash,g=[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];function m(){if(!(this instanceof m))return new m;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}n.inherits(m,y),t.exports=m,m.blockSize=512,m.outSize=256,m.hmacStrength=192,m.padLength=64,m.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=f(b(r[n-2]),r[n-7],p(r[n-15]),r[n-16]);var i=this.h[0],o=this.h[1],y=this.h[2],g=this.h[3],m=this.h[4],v=this.h[5],w=this.h[6],S=this.h[7];for(s(this.k.length===r.length),n=0;n<r.length;n++){var E=u(S,d(m),c(m,v,w),this.k[n],r[n]),M=a(l(i),h(i,o,y));S=w,w=v,v=m,m=a(g,E),g=y,y=o,o=i,i=a(E,M)}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],y),this.h[3]=a(this.h[3],g),this.h[4]=a(this.h[4],m),this.h[5]=a(this.h[5],v),this.h[6]=a(this.h[6],w),this.h[7]=a(this.h[7],S)},m.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},600:(t,e,r)=>{"use strict";var n=r(461).rotr32;function i(t,e,r){return t&e^~t&r}function o(t,e,r){return t&e^t&r^e&r}function s(t,e,r){return t^e^r}e.ft_1=function(t,e,r,n){return 0===t?i(e,r,n):1===t||3===t?s(e,r,n):2===t?o(e,r,n):void 0},e.ch32=i,e.maj32=o,e.p32=s,e.s0_256=function(t){return n(t,2)^n(t,13)^n(t,22)},e.s1_256=function(t){return n(t,6)^n(t,11)^n(t,25)},e.g0_256=function(t){return n(t,7)^n(t,18)^t>>>3},e.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},622:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.taggedHash=e.toTweakedPublickey=e.getPublickey=e.scriptWitnessToWitnessStack=e.witnessStackToScriptWitness=e.vectorSize=e.sliceSize=e.getDustThreshold=e.getOutScriptSize=e.getWitnessSize=e.getInScriptSize=e.getSerializer=e.getDefaultScript=e.getPurpose=e.getCoinType=e.getPayment=void 0;const n=r(9942),i=r(7820),o=r(4872),s=r(1249),a=r(9455),f=r(220),u=r(1199),c=r(1722),h=r(1206),l=r(9499),d=r(179);function p(t){const e=t.match(/\d+/g),r=parseInt(e[1],10);for(let t=0;t<o.coinmap.length;t++)if(r===o.coinmap[t].coinType)return t;throw Error(`ArgumentError: unsupport cointype of BIP32 path, got ${t}`)}function b(t,e=u.Transaction.SIGHASH_DEFAULT){switch(t){case o.ScriptType.P2SH_P2WPKH:case o.ScriptType.P2WPKH:return[72,33];case o.ScriptType.P2TR:return e===u.Transaction.SIGHASH_DEFAULT?[64]:[65]}return[]}function y(t){switch(t){case o.ScriptType.P2PKH:return 25;case o.ScriptType.P2SH_P2PKH:case o.ScriptType.P2SH_P2WPKH:return 23;case o.ScriptType.P2WPKH:return 22;case o.ScriptType.P2WSH:case o.ScriptType.P2TR:return 34}return 0}function g(t){return i.encodingLength(t)+t}function m(t){(0,h.default)(t,h.default.any(o.ow_hexString,h.default.buffer));const e="string"==typeof t?Buffer.from(t,"hex"):t;if(!n.publicKeyVerify(e))throw Error(`ArgumentError: invalid secp256k1 publickey, got "${e.toString("hex")}"`);return e}e.getPayment=function(t){switch(t){case o.CoinType.BITCOINCASH:return a.PaymentBCH;case o.CoinType.GROESTL:return f.PaymentGRS;default:return s.PaymentBTC}},e.getCoinType=p,e.getPurpose=function(t){switch(t){case o.ScriptType.P2PKH:return 44;case o.ScriptType.P2SH_P2PKH:case o.ScriptType.P2SH_P2WPKH:return 49;case o.ScriptType.P2WPKH:return 84;case o.ScriptType.P2TR:return 86}throw Error(`ArgumentError: unsupport ScriptType, got ${t}`)},e.getDefaultScript=function(t){const e=t.match(/\d+/g),r=parseInt(e[0],10),n=e[1]?p(t):o.CoinType.BITCOIN;switch(r){case 44:return o.ScriptType.P2PKH;case 49:return n!==o.CoinType.BITCOINCASH?o.ScriptType.P2SH_P2WPKH:o.ScriptType.P2SH_P2PKH;case 84:return o.ScriptType.P2WPKH;case 86:return o.ScriptType.P2TR}throw Error(`ArgumentError: unsupport purpose of path, got "${r}" from ${t}`)},e.getSerializer=function(t){return t===o.CoinType.GROESTL?c.TransactionGRS:u.Transaction},e.getInScriptSize=function(t){switch(t){case o.ScriptType.P2PKH:case o.ScriptType.P2SH_P2PKH:return 107;case o.ScriptType.P2SH_P2WPKH:return 23}return 0},e.getWitnessSize=b,e.getOutScriptSize=y,e.getDustThreshold=function(t,e){return(8+i.encodingLength(1)+y(t)+(0!==b(t).length?67:148))*e},e.sliceSize=g,e.vectorSize=function(t){return i.encodingLength(t.length)+t.reduce(((t,e)=>t+g(e)),0)},e.witnessStackToScriptWitness=function(t){let e=Buffer.allocUnsafe(0);const r=t=>{const r=e.length,n=i.encodingLength(t);e=Buffer.concat([e,Buffer.allocUnsafe(n)]),i.encode(t,e,r)};r(t.length);for(const n of t)r(n.length),e=Buffer.concat([e,Buffer.from(n)]);return e},e.scriptWitnessToWitnessStack=function(t){let e=0;const r=()=>{const r=i.decode(t,e);return e+=i.decode.bytes,r},n=()=>{const n=r();return e+=n,t.slice(e-n,e)},o=r(),s=[];for(let t=0;t<o;t++)s.push(n());return s},e.getPublickey=m,e.toTweakedPublickey=function(t){const e=m(t).slice(1,33),r=w("TapTweak",e);return(0,d.taprootConvert)(e,r)};const v=Object.fromEntries(["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"].map((t=>{const e=function(t){return Buffer.from((0,l.sha256)().update(t).digest())}(t);return[t,Buffer.concat([e,e])]})));function w(t,e){const r=Buffer.concat([v[t],e]);return Buffer.from((0,l.sha256)().update(r).digest())}e.taggedHash=w},630:(t,e,r)=>{"use strict";var n=r(6734),i=r(4864),o=r(5179),s=r(2825),a=s.validate,f=s.ValidationError,u=["bitcoincash","bchtest","bchreg"];function c(t){for(var e=new Uint8Array(t.length),r=0;r<t.length;++r)e[r]=31&t[r].charCodeAt(0);return e}function h(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function l(t){for(var e=[656907472481,522768456162,0xf33e5fb3c4,748107326120,130178868336],r=i(1),n=0;n<t.length;++n){var o=t[n],s=r.shiftRight(35);r=r.and(34359738367).shiftLeft(5).xor(o);for(var a=0;a<e.length;++a)s.shiftRight(a).and(1).equals(1)&&(r=r.xor(e[a]))}return r.xor(1)}function d(t){return t===t.toLowerCase()||t===t.toUpperCase()}t.exports={encode:function(t,e,r){a("string"==typeof t&&function(t){return d(t)&&-1!==u.indexOf(t.toLowerCase())}(t),"Invalid prefix: "+t+"."),a("string"==typeof e,"Invalid type: "+e+"."),a(r instanceof Uint8Array,"Invalid hash: "+r+".");var i,s=h(c(t),new Uint8Array(1)),p=function(t){switch(t){case"P2PKH":return 0;case"P2SH":return 8;default:throw new f("Invalid type: "+t+".")}}(e)+function(t){switch(8*t.length){case 160:return 0;case 192:return 1;case 224:return 2;case 256:return 3;case 320:return 4;case 384:return 5;case 448:return 6;case 512:return 7;default:throw new f("Invalid hash size: "+t.length+".")}}(r),b=(i=h(new Uint8Array([p]),r),o(i,8,5)),y=h(h(s,b),new Uint8Array(8)),g=h(b,function(t){for(var e=new Uint8Array(8),r=0;r<8;++r)e[7-r]=t.and(31).toJSNumber(),t=t.shiftRight(5);return e}(l(y)));return t+":"+n.encode(g)},decode:function(t){a("string"==typeof t&&d(t),"Invalid address: "+t+".");var e=t.toLowerCase().split(":");a(2===e.length,"Missing prefix: "+t+".");var r=e[0],i=n.decode(e[1]);a(function(t,e){var r=h(c(t),new Uint8Array(1));return l(h(r,e)).equals(0)}(r,i),"Invalid checksum: "+t+".");var s,u=(s=i.subarray(0,-8),o(s,5,8,!0)),p=u[0],b=u.subarray(1);a(function(t){switch(7&t){case 0:return 160;case 1:return 192;case 2:return 224;case 3:return 256;case 4:return 320;case 5:return 384;case 6:return 448;case 7:return 512}}(p)===8*b.length,"Invalid hash size: "+t+".");var y=function(t){switch(120&t){case 0:return"P2PKH";case 8:return"P2SH";default:throw new f("Invalid address type in version byte: "+t+".")}}(p);return{prefix:r,type:y,hash:b}},ValidationError:f}},686:(t,e,r)=>{"use strict";var n=r(4940),i=r(5731),o=r(3468),s=r(9336);t.exports=function(t,e,r){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new o("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,f=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,c=arguments.length>6&&arguments[6],h=!!s&&s(t,e);if(n)n(t,e,{configurable:null===u&&h?h.configurable:!u,enumerable:null===a&&h?h.enumerable:!a,value:r,writable:null===f&&h?h.writable:!f});else{if(!c&&(a||f||u))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=r}}},705:(t,e,r)=>{"use strict";var n=r(9617),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){if(!n(e))throw new TypeError("iterator must be a function");var s,a;arguments.length>=3&&(s=r),a=t,"[object Array]"===i.call(a)?function(t,e,r){for(var n=0,i=t.length;n<i;n++)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,s):"string"==typeof t?function(t,e,r){for(var n=0,i=t.length;n<i;n++)null==r?e(t.charAt(n),n,t):e.call(r,t.charAt(n),n,t)}(t,e,s):function(t,e,r){for(var n in t)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,s)}},711:(t,e,r)=>{var n=r(4010);r(5216),t.exports=n},968:t=>{"use strict";var e=Object.prototype.toString;t.exports=function(t){var r=e.call(t),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===e.call(t.callee)),n}},1048:(t,e,r)=>{"use strict";const n=r(7991),i=r(9318),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=f,e.SlowBuffer=function(t){return+t!=t&&(t=0),f.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,f.prototype),e}function f(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|b(t,e);let n=a(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return f.from(n,e,r);const i=function(t){if(f.isBuffer(t)){const e=0|p(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?a(0):l(t):"Buffer"===t.type&&Array.isArray(t.data)?l(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return f.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return c(t),a(t<0?0:0|p(t))}function l(t){const e=t.length<0?0:0|p(t.length),r=a(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function d(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,f.prototype),n}function p(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function b(t,e){if(f.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(i)return n?-1:V(t).length;e=(""+e).toLowerCase(),i=!0}}function y(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return I(this,e,r);case"ascii":return x(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=f.from(e,n)),f.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){let o,s=1,a=t.length,f=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,f/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(u(t,o)===u(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===f)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+f>a&&(r=a-f),o=r;o>=0;o--){let r=!0;for(let n=0;n<f;n++)if(u(t,o+n)!==u(e,n)){r=!1;break}if(r)return o}return-1}function w(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(Y(n))return s;t[r+s]=n}return s}function S(t,e,r,n){return X(V(e,t.length-r),t,r,n)}function E(t,e,r,n){return X(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function M(t,e,r,n){return X(W(e),t,r,n)}function T(t,e,r,n){return X(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function I(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,f;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(f=(31&e)<<6|63&r,f>127&&(o=f));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(f=(15&e)<<12|(63&r)<<6|63&n,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(f=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,f>65535&&f<1114112&&(o=f))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=P)return String.fromCharCode.a