-
Notifications
You must be signed in to change notification settings - Fork 1
/
8.617075ac48e29f1f91c8.js
1 lines (1 loc) · 5.84 KB
/
8.617075ac48e29f1f91c8.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{B3Rj:function(e,t,i){var r=i("QqcV");e.exports=r("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},BumV:function(e,t,i){"use strict";var r=i("B3Rj"),n=i("hwdV").Buffer;e.exports=function(e){function t(t){var i=t.slice(0,-4),r=t.slice(-4),n=e(i);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return i}return{encode:function(t){var i=e(t);return r.encode(n.concat([t,i],t.length+4))},decode:function(e){var i=t(r.decode(e));if(!i)throw new Error("Invalid checksum");return i},decodeUnsafe:function(e){var i=r.decodeUnsafe(e);if(i)return t(i)}}}},QFga:function(e,t,i){"use strict";i.r(t),i.d(t,"generateAddresses",function(){return u}),i.d(t,"isValidPath",function(){return p});var r=i("tnHP"),n=i("vUa2"),a=i.n(n),c=i("tjlA"),o=r.publicToAddress,s=r.toChecksumAddress;function u(e,t){var i=e.publicKey,r=e.chainCode,n=e.path,u=new a.a;u.publicKey=new c.Buffer(i,"hex"),u.chainCode=new c.Buffer(r,"hex");for(var p=[],d=t;d<5+t;d++){var h=u.deriveChild(d),f=o(h.publicKey,!0).toString("hex");p.push({dPath:"".concat(n,"/").concat(d),address:s("0x".concat(f))})}return p}function p(e){var t=e.split("/");if("m"!==t[0])return!1;if("44'"!==t[1])return!1;if(!["60'","1'","73799'","246'"].includes(t[2]))return!1;if(void 0===t[3]||"0'"===t[3])return!0;var i=Number(t[3].slice(0,-1));if(isNaN(i)||i<0||"'"!==t[3].slice(-1))return!1;if(void 0===t[4])return!0;var r=Number(t[4]);if(isNaN(r)||r<0)return!1;if(void 0===t[5])return!0;var n=Number(t[5]);return!(isNaN(n)||n<0)}},b3gk:function(e,t,i){"use strict";var r=i("mObS"),n=i("BumV");e.exports=n(function(e){var t=r("sha256").update(e).digest();return r("sha256").update(t).digest()})},vUa2:function(e,t,i){var r=i("9lTW"),n=i("hwdV").Buffer,a=i("HEbw"),c=i("b3gk"),o=i("IzB8"),s=n.from("Bitcoin seed","utf8"),u=2147483648,p={private:76066276,public:76067358};function d(e){this.versions=e||p,this.depth=0,this.index=0,this._privateKey=null,this._publicKey=null,this.chainCode=null,this._fingerprint=0,this.parentFingerprint=0}function h(e,t,i){var r=n.allocUnsafe(78);return r.writeUInt32BE(t,0),r.writeUInt8(e.depth,4),r.writeUInt32BE(e.depth?e.parentFingerprint:0,5),r.writeUInt32BE(e.index,9),e.chainCode.copy(r,13),i.copy(r,45),r}function f(e){var t=a.createHash("sha256").update(e).digest();return a.createHash("ripemd160").update(t).digest()}Object.defineProperty(d.prototype,"fingerprint",{get:function(){return this._fingerprint}}),Object.defineProperty(d.prototype,"identifier",{get:function(){return this._identifier}}),Object.defineProperty(d.prototype,"pubKeyHash",{get:function(){return this.identifier}}),Object.defineProperty(d.prototype,"privateKey",{get:function(){return this._privateKey},set:function(e){r.equal(e.length,32,"Private key must be 32 bytes."),r(!0===o.privateKeyVerify(e),"Invalid private key"),this._privateKey=e,this._publicKey=n.from(o.publicKeyCreate(e,!0)),this._identifier=f(this.publicKey),this._fingerprint=this._identifier.slice(0,4).readUInt32BE(0)}}),Object.defineProperty(d.prototype,"publicKey",{get:function(){return this._publicKey},set:function(e){r(33===e.length||65===e.length,"Public key must be 33 or 65 bytes."),r(!0===o.publicKeyVerify(e),"Invalid public key"),this._publicKey=n.from(o.publicKeyConvert(e,!0)),this._identifier=f(this.publicKey),this._fingerprint=this._identifier.slice(0,4).readUInt32BE(0),this._privateKey=null}}),Object.defineProperty(d.prototype,"privateExtendedKey",{get:function(){return this._privateKey?c.encode(h(this,this.versions.private,n.concat([n.alloc(1,0),this.privateKey]))):null}}),Object.defineProperty(d.prototype,"publicExtendedKey",{get:function(){return c.encode(h(this,this.versions.public,this.publicKey))}}),d.prototype.derive=function(e){if("m"===e||"M"===e||"m'"===e||"M'"===e)return this;var t=e.split("/"),i=this;return t.forEach(function(e,t){if(0!==t){var n=e.length>1&&"'"===e[e.length-1],a=parseInt(e,10);r(a<u,"Invalid index"),n&&(a+=u),i=i.deriveChild(a)}else r(/^[mM]{1}/.test(e),'Path must start with "m" or "M"')}),i},d.prototype.deriveChild=function(e){var t,i=e>=u,c=n.allocUnsafe(4);if(c.writeUInt32BE(e,0),i){r(this.privateKey,"Could not derive hardened child key");var s=this.privateKey,p=n.alloc(1,0);s=n.concat([p,s]),t=n.concat([s,c])}else t=n.concat([this.publicKey,c]);var h=a.createHmac("sha512",this.chainCode).update(t).digest(),f=h.slice(0,32),l=h.slice(32),y=new d(this.versions);if(this.privateKey)try{y.privateKey=n.from(o.privateKeyTweakAdd(n.from(this.privateKey),f))}catch(v){return this.deriveChild(e+1)}else try{y.publicKey=n.from(o.publicKeyTweakAdd(n.from(this.publicKey),f,!0))}catch(v){return this.deriveChild(e+1)}return y.chainCode=l,y.depth=this.depth+1,y.parentFingerprint=this.fingerprint,y.index=e,y},d.prototype.sign=function(e){return n.from(o.ecdsaSign(e,this.privateKey).signature)},d.prototype.verify=function(e,t){return o.ecdsaVerify(Uint8Array.from(t),Uint8Array.from(e),Uint8Array.from(this.publicKey))},d.prototype.wipePrivateData=function(){return this._privateKey&&a.randomBytes(this._privateKey.length).copy(this._privateKey),this._privateKey=null,this},d.prototype.toJSON=function(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}},d.fromMasterSeed=function(e,t){var i=a.createHmac("sha512",s).update(e).digest(),r=i.slice(0,32),n=i.slice(32),c=new d(t);return c.chainCode=n,c.privateKey=r,c},d.fromExtendedKey=function(e,t){var i=new d(t=t||p),n=c.decode(e),a=n.readUInt32BE(0);r(a===t.private||a===t.public,"Version mismatch: does not match private or public"),i.depth=n.readUInt8(4),i.parentFingerprint=n.readUInt32BE(5),i.index=n.readUInt32BE(9),i.chainCode=n.slice(13,45);var o=n.slice(45);return 0===o.readUInt8(0)?(r(a===t.private,"Version mismatch: version does not match private"),i.privateKey=o.slice(1)):(r(a===t.public,"Version mismatch: version does not match public"),i.publicKey=o),i},d.fromJSON=function(e){return d.fromExtendedKey(e.xpriv)},d.HARDENED_OFFSET=u,e.exports=d}}]);