-
Notifications
You must be signed in to change notification settings - Fork 0
/
16.2dfac9af58cbbed62eb9.js
1 lines (1 loc) · 4.95 KB
/
16.2dfac9af58cbbed62eb9.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[16,39],{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)}}}},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,o=i("HEbw"),c=i("b3gk"),s=i("IzB8"),a=n.from("Bitcoin seed","utf8"),p=2147483648,u={private:76066276,public:76067358};function d(e){this.versions=e||u,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=o.createHash("sha256").update(e).digest();return o.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===s.privateKeyVerify(e),"Invalid private key"),this._privateKey=e,this._publicKey=n.from(s.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===s.publicKeyVerify(e),"Invalid public key"),this._publicKey=n.from(s.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],o=parseInt(e,10);r(o<p,"Invalid index"),n&&(o+=p),i=i.deriveChild(o)}else r(/^[mM]{1}/.test(e),'Path must start with "m" or "M"')}),i},d.prototype.deriveChild=function(e){var t,i=e>=p,c=n.allocUnsafe(4);if(c.writeUInt32BE(e,0),i){r(this.privateKey,"Could not derive hardened child key");var a=this.privateKey,u=n.alloc(1,0);a=n.concat([u,a]),t=n.concat([a,c])}else t=n.concat([this.publicKey,c]);var h=o.createHmac("sha512",this.chainCode).update(t).digest(),f=h.slice(0,32),y=h.slice(32),l=new d(this.versions);if(this.privateKey)try{l.privateKey=n.from(s.privateKeyTweakAdd(n.from(this.privateKey),f))}catch(v){return this.deriveChild(e+1)}else try{l.publicKey=n.from(s.publicKeyTweakAdd(n.from(this.publicKey),f,!0))}catch(v){return this.deriveChild(e+1)}return l.chainCode=y,l.depth=this.depth+1,l.parentFingerprint=this.fingerprint,l.index=e,l},d.prototype.sign=function(e){return n.from(s.ecdsaSign(e,this.privateKey).signature)},d.prototype.verify=function(e,t){return s.ecdsaVerify(Uint8Array.from(t),Uint8Array.from(e),Uint8Array.from(this.publicKey))},d.prototype.wipePrivateData=function(){return this._privateKey&&o.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=o.createHmac("sha512",a).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||u),n=c.decode(e),o=n.readUInt32BE(0);r(o===t.private||o===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 s=n.slice(45);return 0===s.readUInt8(0)?(r(o===t.private,"Version mismatch: version does not match private"),i.privateKey=s.slice(1)):(r(o===t.public,"Version mismatch: version does not match public"),i.publicKey=s),i},d.fromJSON=function(e){return d.fromExtendedKey(e.xpriv)},d.HARDENED_OFFSET=p,e.exports=d}}]);