ethers.js/dist/ethers-wallet.min.js

8 lines
292 KiB
JavaScript
Raw Normal View History

2016-07-29 11:46:59 +03:00
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Wallet=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){(function(c){"use strict";var d=a("rlp"),e=(a("./lib/contract.js"),a("./lib/secret-storage.js")),f=a("./lib/randomish.js"),g=a("./lib/signing-key.js"),h=a("./lib/wallet.js"),i=a("./lib/utils.js"),j=i.BN,k={};i.defineProperty(h,"utils",k),i.defineProperty(k,"BN",j),i.defineProperty(k,"Buffer",c),i.defineProperty(k,"sha3",i.sha3),i.defineProperty(k,"sha256",i.sha256),i.defineProperty(k,"getContractAddress",function(a){return g.getAddress("0x"+i.sha3(d.encode([i.hexOrBuffer(i.getAddress(a.from)),i.hexOrBuffer(i.hexlify(a.nonce,"nonce"))])).slice(12).toString("hex"))}),b.exports=h,i.defineProperty(h,"etherSymbol","𝝣"),i.defineProperty(h,"getAddress",g.getAddress),i.defineProperty(h,"getIcapAddress",g.getIcapAddress),i.defineProperty(h,"isCrowdsaleWallet",e.isCrowdsaleWallet),i.defineProperty(h,"isValidWallet",e.isValidWallet),i.defineProperty(h,"decryptCrowdsale",function(a,b){return new h(e.decryptCrowdsale(a,b))}),i.defineProperty(h,"decrypt",function(a,b,c){if("function"!=typeof c)throw new Error("invalid callback");e.decrypt(a,b,function(a,b,d){return b?c(a,new h(b),d):c(a,b,d)})}),i.defineProperty(h.prototype,"encrypt",function(a,b,c){if("function"!=typeof b||c||(c=b,b={}),"function"!=typeof c)throw new Error("invalid callback");e.encrypt(this.privateKey,a,b,c)}),i.defineProperty(h,"randomish",new f),b.exports=h}).call(this,a("buffer").Buffer)},{"./lib/contract.js":4,"./lib/randomish.js":6,"./lib/secret-storage.js":7,"./lib/signing-key.js":8,"./lib/utils.js":9,"./lib/wallet.js":10,buffer:40,rlp:83}],2:[function(a,b,c){(function(c,d){"use strict";function e(a){if(a<=0||a>1024||parseInt(a)!=a)throw new Error("invalid length");var b=new d(a);return g.getRandomValues(b),b}var f=a("./utils.js"),g=c.crypto||c.msCrypto;g&&g.getRandomValues?console.log("Found strong random number source"):(console.log("WARNING: Missing strong random number source; using weak randomBytes"),g={getRandomValues:function(a){for(var b=0;b<buffer.length;b++)buffer[b]=parseInt(256*Math.random());return buffer},_weakCrypto:!0}),g._weakCrypto===!0&&f.defineProperty(e,"_weakCrypto",!0),b.exports=e}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer)},{"./utils.js":9,buffer:40}],3:[function(a,b,c){"use strict";try{b.exports.XMLHttpRequest=XMLHttpRequest}catch(d){console.log("Warning: XMLHttpRequest is not defined"),b.exports.XMLHttpRequest=null}},{}],4:[function(a,b,c){(function(c){"use strict";function d(a,b,c){var d=JSON.stringify(c);Object.defineProperty(a,b,{enumerable:!0,get:function(){return JSON.parse(d)}})}function e(a,b){if(!Array.isArray(a))throw new Error("invalid params");for(var c=[],d=0;d<a.length;d++){if("string"!=typeof a[d][b])throw new Error("invalid abi");c.push(a[d][b])}return c}function f(a){if(!a.eq){if("number"!=typeof a)throw new Error("invalid number");a=new o.BN(a)}return a}function g(a,b){return{encode:function(d){return d=f(d),b?d=d.toTwos(256):d<0&&(d=d.toTwos(8*a)),d.toArrayLike(c,"be",32)},decode:function(c,d){var e=new o.BN(c.slice(d,d+32));return e=b?e.fromTwos(8*a):e.mod(new o.BN(2).pow(new o.BN(8*a))),{consumed:32,value:e}}}}function h(a){return{encode:function(b){if(b=o.hexOrBuffer(b),32===a)return b;var d=new c(32);return d.fill(0),b.copy(d),d},decode:function(b,c){if(b.length<c+32)throw new E
2016-07-27 10:03:14 +03:00
this.key=f(a),this._prepare()};z.prototype._prepare=function(){var a=j[this.key.length];if(null==a)throw new Error("invalid key size (must be length 16, 24 or 32)");this._Ke=[],this._Kd=[];for(var c=0;c<=a;c++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var d,e=4*(a+1),f=this.key.length/4,g=b(this.key),c=0;c<f;c++)d=c>>2,this._Ke[d][c%4]=g[c],this._Kd[a-d][c%4]=g[c];for(var h,i=0,m=f;m<e;){if(h=g[f-1],g[0]^=l[h>>16&255]<<24^l[h>>8&255]<<16^l[255&h]<<8^l[h>>24&255]^k[i]<<24,i+=1,8!=f)for(var c=1;c<f;c++)g[c]^=g[c-1];else{for(var c=1;c<f/2;c++)g[c]^=g[c-1];h=g[f/2-1],g[f/2]^=l[255&h]^l[h>>8&255]<<8^l[h>>16&255]<<16^l[h>>24&255]<<24;for(var c=f/2+1;c<f;c++)g[c]^=g[c-1]}for(var n,o,c=0;c<f&&m<e;)n=m>>2,o=m%4,this._Ke[n][o]=g[c],this._Kd[a-n][o]=g[c++],m++}for(var n=1;n<a;n++)for(var o=0;o<4;o++)h=this._Kd[n][o],this._Kd[n][o]=v[h>>24&255]^w[h>>16&255]^x[h>>8&255]^y[255&h]},z.prototype.encrypt=function(a){if(16!=a.length)return new Error("plaintext must be a block of size 16");for(var c=this._Ke.length-1,d=[0,0,0,0],e=b(a),g=0;g<4;g++)e[g]^=this._Ke[0][g];for(var h=1;h<c;h++){for(var g=0;g<4;g++)d[g]=n[e[g]>>24&255]^o[e[(g+1)%4]>>16&255]^p[e[(g+2)%4]>>8&255]^q[255&e[(g+3)%4]]^this._Ke[h][g];e=d.slice(0)}for(var i,j=f(16),g=0;g<4;g++)i=this._Ke[c][g],j[4*g]=255&(l[e[g]>>24&255]^i>>24),j[4*g+1]=255&(l[e[(g+1)%4]>>16&255]^i>>16),j[4*g+2]=255&(l[e[(g+2)%4]>>8&255]^i>>8),j[4*g+3]=255&(l[255&e[(g+3)%4]]^i);return j},z.prototype.decrypt=function(a){if(16!=a.length)return new Error("ciphertext must be a block of size 16");for(var c=this._Kd.length-1,d=[0,0,0,0],e=b(a),g=0;g<4;g++)e[g]^=this._Kd[0][g];for(var h=1;h<c;h++){for(var g=0;g<4;g++)d[g]=r[e[g]>>24&255]^s[e[(g+3)%4]>>16&255]^t[e[(g+2)%4]>>8&255]^u[255&e[(g+1)%4]]^this._Kd[h][g];e=d.slice(0)}for(var i,j=f(16),g=0;g<4;g++)i=this._Kd[c][g],j[4*g]=255&(m[e[g]>>24&255]^i>>24),j[4*g+1]=255&(m[e[(g+3)%4]>>16&255]^i>>16),j[4*g+2]=255&(m[e[(g+2)%4]>>8&255]^i>>8),j[4*g+3]=255&(m[255&e[(g+1)%4]]^i);return j};var A=function(a){this.description="Electronic Code Block",this.name="ecb",this._aes=new z(a)};A.prototype.encrypt=function(a){return this._aes.encrypt(a)},A.prototype.decrypt=function(a,b){return this._aes.decrypt(a)};var B=function(a,b){if(this.description="Cipher Block Chaining",this.name="cbc",null===b)b=f([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);else if(16!=b.length)return new Error("initialation vector iv must be of length 16");this._lastCipherblock=f(b),this._aes=new z(a)};B.prototype.encrypt=function(a){if(16!=a.length)return new Error("plaintext must be a block of size 16");for(var b=f(a),c=0;c<16;c++)b[c]^=this._lastCipherblock[c];return this._lastCipherblock=this._aes.encrypt(b),this._lastCipherblock},B.prototype.decrypt=function(a){if(16!=a.length)return new Error("ciphertext must be a block of size 16");for(var b=this._aes.decrypt(a),c=0;c<16;c++)b[c]^=this._lastCipherblock[c];return a.copy(this._lastCipherblock),b};var C=function(a,b,c){if(this.description="Cipher Feedback",this.name="cfb",null===b)b=f([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);else if(16!=b.length)return new Error("initialation vector iv must be of length 16");c||(c=1),this.segmentSize=c,this._shiftRegister=f(b),this._aes=new z(a)};C.prototype.encrypt=function(a){if(a.length%this.segmentSize!=0)return new Error("plaintext must be a block of size module segmentSize ("+this.segmentSize+")");for(var b,c=f(a),d=0;d<c.length;d+=this.segmentSize){b=this._aes.encrypt(this._shiftRegister);for(var e=0;e<this.segmentSize;e++)c[d+e]^=b[e];this._shiftRegister.copy(this._shiftRegister,0,this.segmentSize),c.copy(this._shiftRegister,16-this.segmentSize,d,d+this.segmentSize)}return c},C.prototype.decrypt=function(a){if(a.length%this.segmentSize!=0)return new Error("ciphertext must be a block of size module segmentSize ("+this.segmentSize+")");for(var b,c=f(a),d=0;d<c.length;d+=this.segmentSize){b=this._aes.encrypt(this._shiftRegister);for(var e=0;e<this.segmentSize;e++)c[d+e]^=b[e];this._shiftRegister.copy(this._shiftRegister,0,this.segmentSize),a.copy(this._shiftRegister,16-this.segmentSize,d,d+this.segmentSize)}return
return this.curve.jpoint(l,m,n)},f.prototype.mul=function(a,b){return a=new i(a,b),this.curve._wnafMul(this,a)},f.prototype.eq=function(a){if("affine"===a.type)return this.eq(a.toJ());if(this===a)return!0;var b=this.z.redSqr(),c=a.z.redSqr();if(0!==this.x.redMul(c).redISub(a.x.redMul(b)).cmpn(0))return!1;var d=b.redMul(this.z),e=c.redMul(a.z);return 0===this.y.redMul(e).redISub(a.y.redMul(d)).cmpn(0)},f.prototype.eqXToP=function(a){var b=this.z.redSqr(),c=a.toRed(this.curve.red).redMul(b);if(0===this.x.cmp(c))return!0;for(var d=a.clone(),e=this.curve.redN.redMul(b);;){if(d.iadd(this.curve.n),d.cmp(this.curve.p)>=0)return!1;if(c.redIAdd(e),0===this.x.cmp(c))return!0}return!1},f.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)+">"},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":12,"../curve":15,"bn.js":28,inherits:36}],18:[function(a,b,c){"use strict";function d(a){"short"===a.type?this.curve=new h.curve["short"](a):"edwards"===a.type?this.curve=new h.curve.edwards(a):this.curve=new h.curve.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function e(a,b){Object.defineProperty(f,a,{configurable:!0,enumerable:!0,get:function(){var c=new d(b);return Object.defineProperty(f,a,{configurable:!0,enumerable:!0,value:c}),c}})}var f=c,g=a("hash.js"),h=a("../elliptic"),i=h.utils.assert;f.PresetCurve=d,e("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:g.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),e("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:g.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),e("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:g.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),e("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:g.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),e("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2d
}}},{}],27:[function(a,b,c){"use strict";function d(a,b){if(Array.isArray(a))return a.slice();if(!a)return[];var c=[];if("string"!=typeof a){for(var d=0;d<a.length;d++)c[d]=0|a[d];return c}if(b){if("hex"===b){a=a.replace(/[^a-z0-9]+/gi,""),a.length%2!==0&&(a="0"+a);for(var d=0;d<a.length;d+=2)c.push(parseInt(a[d]+a[d+1],16))}}else for(var d=0;d<a.length;d++){var e=a.charCodeAt(d),f=e>>8,g=255&e;f?c.push(f,g):c.push(g)}return c}function e(a){return 1===a.length?"0"+a:a}function f(a){for(var b="",c=0;c<a.length;c++)b+=e(a[c].toString(16));return b}function g(a,b){for(var c=[],d=1<<b+1,e=a.clone();e.cmpn(1)>=0;){var f;if(e.isOdd()){var g=e.andln(d-1);f=g>(d>>1)-1?(d>>1)-g:g,e.isubn(f)}else f=0;c.push(f);for(var h=0!==e.cmpn(0)&&0===e.andln(d-1)?b+1:1,i=1;i<h;i++)c.push(0);e.iushrn(h)}return c}function h(a,b){var c=[[],[]];a=a.clone(),b=b.clone();for(var d=0,e=0;a.cmpn(-d)>0||b.cmpn(-e)>0;){var f=a.andln(3)+d&3,g=b.andln(3)+e&3;3===f&&(f=-1),3===g&&(g=-1);var h;if(0===(1&f))h=0;else{var i=a.andln(7)+d&7;h=3!==i&&5!==i||2!==g?f:-f}c[0].push(h);var j;if(0===(1&g))j=0;else{var i=b.andln(7)+e&7;j=3!==i&&5!==i||2!==f?g:-g}c[1].push(j),2*d===h+1&&(d=1-d),2*e===j+1&&(e=1-e),a.iushrn(1),b.iushrn(1)}return c}function i(a,b,c){var d="_"+b;a.prototype[b]=function(){return void 0!==this[d]?this[d]:this[d]=c.call(this)}}function j(a){return"string"==typeof a?l.toArray(a,"hex"):a}function k(a){return new m(a,"hex","le")}var l=c,m=a("bn.js");l.assert=function(a,b){if(!a)throw new Error(b||"Assertion failed")},l.toArray=d,l.zero2=e,l.toHex=f,l.encode=function(a,b){return"hex"===b?f(a):a},l.getNAF=g,l.getJSF=h,l.cachedProperty=i,l.parseBytes=j,l.intFromLE=k},{"bn.js":28}],28:[function(a,b,c){!function(b,c){"use strict";function d(a,b){if(!a)throw new Error(b||"Assertion failed")}function e(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}function f(a,b,c){return f.isBN(a)?a:(this.negative=0,this.words=null,this.length=0,this.red=null,void(null!==a&&("le"!==b&&"be"!==b||(c=b,b=10),this._init(a||0,b||10,c||"be"))))}function g(a,b,c){for(var d=0,e=Math.min(a.length,c),f=b;f<e;f++){var g=a.charCodeAt(f)-48;d<<=4,d|=g>=49&&g<=54?g-49+10:g>=17&&g<=22?g-17+10:15&g}return d}function h(a,b,c,d){for(var e=0,f=Math.min(a.length,c),g=b;g<f;g++){var h=a.charCodeAt(g)-48;e*=d,e+=h>=49?h-49+10:h>=17?h-17+10:h}return e}function i(a){for(var b=new Array(a.bitLength()),c=0;c<b.length;c++){var d=c/26|0,e=c%26;b[c]=(a.words[d]&1<<e)>>>e}return b}function j(a,b,c){c.negative=b.negative^a.negative;var d=a.length+b.length|0;c.length=d,d=d-1|0;var e=0|a.words[0],f=0|b.words[0],g=e*f,h=67108863&g,i=g/67108864|0;c.words[0]=h;for(var j=1;j<d;j++){for(var k=i>>>26,l=67108863&i,m=Math.min(j,b.length-1),n=Math.max(0,j-a.length+1);n<=m;n++){var o=j-n|0;e=0|a.words[o],f=0|b.words[n],g=e*f+l,k+=g/67108864|0,l=67108863&g}c.words[j]=0|l,i=0|k}return 0!==i?c.words[j]=0|i:c.length--,c.strip()}function k(a,b,c){c.negative=b.negative^a.negative,c.length=a.length+b.length;for(var d=0,e=0,f=0;f<c.length-1;f++){var g=e;e=0;for(var h=67108863&d,i=Math.min(f,b.length-1),j=Math.max(0,f-a.length+1);j<=i;j++){var k=f-j,l=0|a.words[k],m=0|b.words[j],n=l*m,o=67108863&n;g=g+(n/67108864|0)|0,o=o+h|0,h=67108863&o,g=g+(o>>>26)|0,e+=g>>>26,g&=67108863}c.words[f]=h,d=g,g=e}return 0!==d?c.words[f]=d:c.length--,c.strip()}function l(a,b,c){var d=new m;return d.mulp(a,b,c)}function m(a,b){this.x=a,this.y=b}function n(a,b){this.name=a,this.p=new f(b,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function o(){n.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function p(){n.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function q(){n.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function r(){n.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function s(a){if("string"==typeof a){var b=f._prime(a);this.m=b.p,this.prime=b}else d(a.gtn(1),"modulus must be gre
var i,j=d.length-e.length;if("mod"!==b){i=new f(null),i.length=j+1,i.words=new Array(i.length);for(var k=0;k<i.length;k++)i.words[k]=0}var l=d.clone()._ishlnsubmul(e,1,j);0===l.negative&&(d=l,i&&(i.words[j]=1));for(var m=j-1;m>=0;m--){var n=67108864*(0|d.words[e.length+m])+(0|d.words[e.length+m-1]);for(n=Math.min(n/g|0,67108863),d._ishlnsubmul(e,n,m);0!==d.negative;)n--,d.negative=0,d._ishlnsubmul(e,1,m),d.isZero()||(d.negative^=1);i&&(i.words[m]=n)}return i&&i.strip(),d.strip(),"div"!==b&&0!==c&&d.iushrn(c),{div:i||null,mod:d}},f.prototype.divmod=function(a,b,c){if(d(!a.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var e,g,h;return 0!==this.negative&&0===a.negative?(h=this.neg().divmod(a,b),"mod"!==b&&(e=h.div.neg()),"div"!==b&&(g=h.mod.neg(),c&&0!==g.negative&&g.iadd(a)),{div:e,mod:g}):0===this.negative&&0!==a.negative?(h=this.divmod(a.neg(),b),"mod"!==b&&(e=h.div.neg()),{div:e,mod:h.mod}):0!==(this.negative&a.negative)?(h=this.neg().divmod(a.neg(),b),"div"!==b&&(g=h.mod.neg(),c&&0!==g.negative&&g.isub(a)),{div:h.div,mod:g}):a.length>this.length||this.cmp(a)<0?{div:new f(0),mod:this}:1===a.length?"div"===b?{div:this.divn(a.words[0]),mod:null}:"mod"===b?{div:null,mod:new f(this.modn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new f(this.modn(a.words[0]))}:this._wordDiv(a,b)},f.prototype.div=function(a){return this.divmod(a,"div",!1).div},f.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},f.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},f.prototype.divRound=function(a){var b=this.divmod(a);if(b.mod.isZero())return b.div;var c=0!==b.div.negative?b.mod.isub(a):b.mod,d=a.ushrn(1),e=a.andln(1),f=c.cmp(d);return f<0||1===e&&0===f?b.div:0!==b.div.negative?b.div.isubn(1):b.div.iaddn(1)},f.prototype.modn=function(a){d(a<=67108863);for(var b=(1<<26)%a,c=0,e=this.length-1;e>=0;e--)c=(b*c+(0|this.words[e]))%a;return c},f.prototype.idivn=function(a){d(a<=67108863);for(var b=0,c=this.length-1;c>=0;c--){var e=(0|this.words[c])+67108864*b;this.words[c]=e/a|0,b=e%a}return this.strip()},f.prototype.divn=function(a){return this.clone().idivn(a)},f.prototype.egcd=function(a){d(0===a.negative),d(!a.isZero());var b=this,c=a.clone();b=0!==b.negative?b.umod(a):b.clone();for(var e=new f(1),g=new f(0),h=new f(0),i=new f(1),j=0;b.isEven()&&c.isEven();)b.iushrn(1),c.iushrn(1),++j;for(var k=c.clone(),l=b.clone();!b.isZero();){for(var m=0,n=1;0===(b.words[0]&n)&&m<26;++m,n<<=1);if(m>0)for(b.iushrn(m);m-- >0;)(e.isOdd()||g.isOdd())&&(e.iadd(k),g.isub(l)),e.iushrn(1),g.iushrn(1);for(var o=0,p=1;0===(c.words[0]&p)&&o<26;++o,p<<=1);if(o>0)for(c.iushrn(o);o-- >0;)(h.isOdd()||i.isOdd())&&(h.iadd(k),i.isub(l)),h.iushrn(1),i.iushrn(1);b.cmp(c)>=0?(b.isub(c),e.isub(h),g.isub(i)):(c.isub(b),h.isub(e),i.isub(g))}return{a:h,b:i,gcd:c.iushln(j)}},f.prototype._invmp=function(a){d(0===a.negative),d(!a.isZero());var b=this,c=a.clone();b=0!==b.negative?b.umod(a):b.clone();for(var e=new f(1),g=new f(0),h=c.clone();b.cmpn(1)>0&&c.cmpn(1)>0;){for(var i=0,j=1;0===(b.words[0]&j)&&i<26;++i,j<<=1);if(i>0)for(b.iushrn(i);i-- >0;)e.isOdd()&&e.iadd(h),e.iushrn(1);for(var k=0,l=1;0===(c.words[0]&l)&&k<26;++k,l<<=1);if(k>0)for(c.iushrn(k);k-- >0;)g.isOdd()&&g.iadd(h),g.iushrn(1);b.cmp(c)>=0?(b.isub(c),e.isub(g)):(c.isub(b),g.isub(e))}var m;return m=0===b.cmpn(1)?e:g,m.cmpn(0)<0&&m.iadd(a),m},f.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var b=this.clone(),c=a.clone();b.negative=0,c.negative=0;for(var d=0;b.isEven()&&c.isEven();d++)b.iushrn(1),c.iushrn(1);for(;;){for(;b.isEven();)b.iushrn(1);for(;c.isEven();)c.iushrn(1);var e=b.cmp(c);if(e<0){var f=b;b=c,c=f}else if(0===e||0===c.cmpn(1))break;b.isub(c)}return c.iushln(d)},f.prototype.invm=function(a){return this.egcd(a).a.umod(a)},f.prototype.isEven=function(){return 0===(1&this.words[0])},f.prototype.isOdd=function(){return 1===(1&this.words[0])},f.prototype.andln=function(a){return this.words[0]&a},f.prototype.bincn=function(a){d("number"==typeof a);var b=a%26,c=(a-b)/26,e=1<<b;if(this.length<=c)return this._expand(c+1),this.words[c]|=e,th
}function j(a){return"[object Arguments]"==Object.prototype.toString.call(a)}function k(a,b){if(n.isNullOrUndefined(a)||n.isNullOrUndefined(b))return!1;if(a.prototype!==b.prototype)return!1;if(n.isPrimitive(a)||n.isPrimitive(b))return a===b;var c=j(a),d=j(b);if(c&&!d||!c&&d)return!1;if(c)return a=o.call(a),b=o.call(b),i(a,b);var e,f,g=r(a),h=r(b);if(g.length!=h.length)return!1;for(g.sort(),h.sort(),f=g.length-1;f>=0;f--)if(g[f]!=h[f])return!1;for(f=g.length-1;f>=0;f--)if(e=g[f],!i(a[e],b[e]))return!1;return!0}function l(a,b){return!(!a||!b)&&("[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b||b.call({},a)===!0)}function m(a,b,c,d){var e;n.isString(c)&&(d=c,c=null);try{b()}catch(f){e=f}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&g(e,c,"Missing expected exception"+d),!a&&l(e,c)&&g(e,c,"Got unwanted exception"+d),a&&e&&c&&!l(e,c)||!a&&e)throw e}var n=a("util/"),o=Array.prototype.slice,p=Object.prototype.hasOwnProperty,q=b.exports=h;q.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,a.message?(this.message=a.message,this.generatedMessage=!1):(this.message=f(this),this.generatedMessage=!0);var b=a.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,b);else{var c=new Error;if(c.stack){var d=c.stack,e=b.name,h=d.indexOf("\n"+e);if(h>=0){var i=d.indexOf("\n",h+1);d=d.substring(i+1)}this.stack=d}}},n.inherits(q.AssertionError,Error),q.fail=g,q.ok=h,q.equal=function(a,b,c){a!=b&&g(a,b,c,"==",q.equal)},q.notEqual=function(a,b,c){a==b&&g(a,b,c,"!=",q.notEqual)},q.deepEqual=function(a,b,c){i(a,b)||g(a,b,c,"deepEqual",q.deepEqual)},q.notDeepEqual=function(a,b,c){i(a,b)&&g(a,b,c,"notDeepEqual",q.notDeepEqual)},q.strictEqual=function(a,b,c){a!==b&&g(a,b,c,"===",q.strictEqual)},q.notStrictEqual=function(a,b,c){a===b&&g(a,b,c,"!==",q.notStrictEqual)},q["throws"]=function(a,b,c){m.apply(this,[!0].concat(o.call(arguments)))},q.doesNotThrow=function(a,b){m.apply(this,[!1].concat(o.call(arguments)))},q.ifError=function(a){if(a)throw a};var r=Object.keys||function(a){var b=[];for(var c in a)p.call(a,c)&&b.push(c);return b}},{"util/":66}],39:[function(a,b,c){},{}],40:[function(a,b,c){(function(b){"use strict";function d(){try{var a=new Uint8Array(1);return a.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===a.foo()&&"function"==typeof a.subarray&&0===a.subarray(1,1).byteLength}catch(b){return!1}}function e(){return g.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(a,b){if(e()<b)throw new RangeError("Invalid typed array length");return g.TYPED_ARRAY_SUPPORT?(a=new Uint8Array(b),a.__proto__=g.prototype):(null===a&&(a=new g(b)),a.length=b),a}function g(a,b,c){if(!(g.TYPED_ARRAY_SUPPORT||this instanceof g))return new g(a,b,c);if("number"==typeof a){if("string"==typeof b)throw new Error("If encoding is specified then the first argument must be a string");return k(this,a)}return h(this,a,b,c)}function h(a,b,c,d){if("number"==typeof b)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&b instanceof ArrayBuffer?n(a,b,c,d):"string"==typeof b?l(a,b,c):o(a,b)}function i(a){if("number"!=typeof a)throw new TypeError('"size" argument must be a number')}function j(a,b,c,d){return i(b),b<=0?f(a,b):void 0!==c?"string"==typeof d?f(a,b).fill(c,d):f(a,b).fill(c):f(a,b)}function k(a,b){if(i(b),a=f(a,b<0?0:0|p(b)),!g.TYPED_ARRAY_SUPPORT)for(var c=0;c<b;++c)a[c]=0;return a}function l(a,b,c){if("string"==typeof c&&""!==c||(c="utf8"),!g.isEncoding(c))throw new TypeError('"encoding" must be a valid string encoding');var d=0|r(b,c);return a=f(a,d),a.write(b,c),a}function m(a,b){var c=0|p(b.length);a=f(a,c);for(var d=0;d<c;d+=1)a[d]=255&b[d];return a}function n(a,b,c,d){if(b.byteLength,c<0||b.byteLength<c)throw new RangeError("'offset' is out of bounds");if(b.byteLength<c+(d||0))throw new RangeError("'length' is out of bounds");return b=void 0===c&&void 0===d?new Uint8Array(b):void 0===d?new Uint8Array(b,c):new Uint8Array(b,c,d),g.TYPED_ARRAY_SUPPORT?(a
a|=a>>>2,a|=a>>>4,a|=a>>>8,a|=a>>>16,a++),a}function j(a,b){return 0===b.length&&b.ended?0:b.objectMode?0===a?0:1:null===a||isNaN(a)?b.flowing&&b.buffer.length?b.buffer[0].length:b.length:a<=0?0:(a>b.highWaterMark&&(b.highWaterMark=i(a)),a>b.length?b.ended?b.length:(b.needReadable=!0,0):a)}function k(a,b){var c=null;return F.isBuffer(b)||"string"==typeof b||null===b||void 0===b||a.objectMode||(c=new TypeError("Invalid non-string/buffer chunk")),c}function l(a,b){if(!b.ended){if(b.decoder){var c=b.decoder.end();c&&c.length&&(b.buffer.push(c),b.length+=b.objectMode?1:c.length)}b.ended=!0,m(a)}}function m(a){var b=a._readableState;b.needReadable=!1,b.emittedReadable||(J("emitReadable",b.flowing),b.emittedReadable=!0,b.sync?A(n,a):n(a))}function n(a){J("emit readable"),a.emit("readable"),u(a)}function o(a,b){b.readingMore||(b.readingMore=!0,A(p,a,b))}function p(a,b){for(var c=b.length;!b.reading&&!b.flowing&&!b.ended&&b.length<b.highWaterMark&&(J("maybeReadMore read 0"),a.read(0),c!==b.length);)c=b.length;b.readingMore=!1}function q(a){return function(){var b=a._readableState;J("pipeOnDrain",b.awaitDrain),b.awaitDrain&&b.awaitDrain--,0===b.awaitDrain&&E(a,"data")&&(b.flowing=!0,u(a))}}function r(a){J("readable nexttick read 0"),a.read(0)}function s(a,b){b.resumeScheduled||(b.resumeScheduled=!0,A(t,a,b))}function t(a,b){b.reading||(J("resume read 0"),a.read(0)),b.resumeScheduled=!1,a.emit("resume"),u(a),b.flowing&&!b.reading&&a.read(0)}function u(a){var b=a._readableState;if(J("flow",b.flowing),b.flowing)do var c=a.read();while(null!==c&&b.flowing)}function v(a,b){var c,d=b.buffer,e=b.length,f=!!b.decoder,g=!!b.objectMode;if(0===d.length)return null;if(0===e)c=null;else if(g)c=d.shift();else if(!a||a>=e)c=f?d.join(""):1===d.length?d[0]:F.concat(d,e),d.length=0;else if(a<d[0].length){var h=d[0];c=h.slice(0,a),d[0]=h.slice(a)}else if(a===d[0].length)c=d.shift();else{c=f?"":G.allocUnsafe(a);for(var i=0,j=0,k=d.length;j<k&&i<a;j++){var l=d[0],m=Math.min(a-i,l.length);f?c+=l.slice(0,m):l.copy(c,i,0,m),m<l.length?d[0]=l.slice(m):d.shift(),i+=m}}return c}function w(a){var b=a._readableState;if(b.length>0)throw new Error('"endReadable()" called on non-empty stream');b.endEmitted||(b.ended=!0,A(x,b,a))}function x(a,b){a.endEmitted||0!==a.length||(a.endEmitted=!0,b.readable=!1,b.emit("end"))}function y(a,b){for(var c=0,d=a.length;c<d;c++)b(a[c],c)}function z(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1}b.exports=f;var A=a("process-nextick-args"),B=a("isarray");f.ReadableState=e;var C,D=a("events").EventEmitter,E=function(a,b){return a.listeners(b).length};!function(){try{C=a("stream")}catch(b){}finally{C||(C=a("events").EventEmitter)}}();var F=a("buffer").Buffer,G=a("buffer-shims"),H=a("core-util-is");H.inherits=a("inherits");var I=a("util"),J=void 0;J=I&&I.debuglog?I.debuglog("stream"):function(){};var K;H.inherits(f,C);var L,L,M="function"==typeof D.prototype.prependListener;f.prototype.push=function(a,b){var c=this._readableState;return c.objectMode||"string"!=typeof a||(b=b||c.defaultEncoding,b!==c.encoding&&(a=G.from(a,b),b="")),g(this,c,a,b,!1)},f.prototype.unshift=function(a){var b=this._readableState;return g(this,b,a,"",!0)},f.prototype.isPaused=function(){return this._readableState.flowing===!1},f.prototype.setEncoding=function(b){return K||(K=a("string_decoder/").StringDecoder),this._readableState.decoder=new K(b),this._readableState.encoding=b,this};var N=8388608;f.prototype.read=function(a){J("read",a);var b=this._readableState,c=a;if(("number"!=typeof a||a>0)&&(b.emittedReadable=!1),0===a&&b.needReadable&&(b.length>=b.highWaterMark||b.ended))return J("read: emitReadable",b.length,b.ended),0===b.length&&b.ended?w(this):m(this),null;if(a=j(a,b),0===a&&b.ended)return 0===b.length&&w(this),null;var d=b.needReadable;J("need readable",d),(0===b.length||b.length-a<b.highWaterMark)&&(d=!0,J("length less than watermark",d)),(b.ended||b.reading)&&(d=!1,J("reading or ended",d)),d&&(J("do read"),b.reading=!0,b.sync=!0,0===b.length&&(b.needReadable=!0),this._read(b.highWaterMark),b.sync=!1),d&&!b.reading&&(a=j(c,
for(var r=0;r<i;r++)n[r]^=p[r]}var s=(o-1)*i,t=o===j?m:i;n.copy(k,s,0,t)}return k}var f=a("create-hmac"),g=Math.pow(2,30)-1;c.pbkdf2=d,c.pbkdf2Sync=e}).call(this,a("buffer").Buffer)},{buffer:40,"create-hmac":68}],68:[function(a,b,c){(function(c){"use strict";function d(a,b){g.call(this),a=a.toLowerCase(),"string"==typeof b&&(b=new c(b));var d="sha512"===a||"sha384"===a?128:64;this._alg=a,this._key=b,b.length>d?b=e(a).update(b).digest():b.length<d&&(b=c.concat([b,h],d));for(var f=this._ipad=new c(d),i=this._opad=new c(d),j=0;j<d;j++)f[j]=54^b[j],i[j]=92^b[j];this._hash=e(a).update(f)}var e=a("create-hash/browser"),f=a("inherits"),g=a("stream").Transform,h=new c(128);h.fill(0),f(d,g),d.prototype.update=function(a,b){return this._hash.update(a,b),this},d.prototype._transform=function(a,b,c){this._hash.update(a),c()},d.prototype._flush=function(a){this.push(this.digest()),a()},d.prototype.digest=function(a){var b=this._hash.digest();return e(this._alg).update(this._opad).update(b).digest(a)},b.exports=function(a,b){return new d(a,b)}}).call(this,a("buffer").Buffer)},{buffer:40,"create-hash/browser":69,inherits:82,stream:63}],69:[function(a,b,c){(function(c){"use strict";function d(a){j.call(this,"digest"),this._hash=a,this.buffers=[]}function e(a){j.call(this,"digest"),this._hash=a}var f=a("inherits"),g=a("./md5"),h=a("ripemd160"),i=a("sha.js"),j=a("cipher-base");f(d,j),d.prototype._update=function(a){this.buffers.push(a)},d.prototype._final=function(){var a=c.concat(this.buffers),b=this._hash(a);return this.buffers=null,b},f(e,j),e.prototype._update=function(a){this._hash.update(a)},e.prototype._final=function(){return this._hash.digest()},b.exports=function(a){return a=a.toLowerCase(),"md5"===a?new d(g):"rmd160"===a||"ripemd160"===a?new d(h):new e(i(a))}}).call(this,a("buffer").Buffer)},{"./md5":71,buffer:40,"cipher-base":72,inherits:82,ripemd160:73,"sha.js":75}],70:[function(a,b,c){(function(a){"use strict";function b(b,c){if(b.length%f!==0){var d=b.length+(f-b.length%f);b=a.concat([b,g],d)}for(var e=[],h=c?b.readInt32BE:b.readInt32LE,i=0;i<b.length;i+=f)e.push(h.call(b,i));return e}function d(b,c,d){for(var e=new a(c),f=d?e.writeInt32BE:e.writeInt32LE,g=0;g<b.length;g++)f.call(e,b[g],4*g,!0);return e}function e(c,e,f,g){a.isBuffer(c)||(c=new a(c));var i=e(b(c,g),c.length*h);return d(i,f,g)}var f=4,g=new a(f);g.fill(0);var h=8;c.hash=e}).call(this,a("buffer").Buffer)},{buffer:40}],71:[function(a,b,c){"use strict";function d(a,b){a[b>>5]|=128<<b%32,a[(b+64>>>9<<4)+14]=b;for(var c=1732584193,d=-271733879,e=-1732584194,k=271733878,l=0;l<a.length;l+=16){var m=c,n=d,o=e,p=k;c=f(c,d,e,k,a[l+0],7,-680876936),k=f(k,c,d,e,a[l+1],12,-389564586),e=f(e,k,c,d,a[l+2],17,606105819),d=f(d,e,k,c,a[l+3],22,-1044525330),c=f(c,d,e,k,a[l+4],7,-176418897),k=f(k,c,d,e,a[l+5],12,1200080426),e=f(e,k,c,d,a[l+6],17,-1473231341),d=f(d,e,k,c,a[l+7],22,-45705983),c=f(c,d,e,k,a[l+8],7,1770035416),k=f(k,c,d,e,a[l+9],12,-1958414417),e=f(e,k,c,d,a[l+10],17,-42063),d=f(d,e,k,c,a[l+11],22,-1990404162),c=f(c,d,e,k,a[l+12],7,1804603682),k=f(k,c,d,e,a[l+13],12,-40341101),e=f(e,k,c,d,a[l+14],17,-1502002290),d=f(d,e,k,c,a[l+15],22,1236535329),c=g(c,d,e,k,a[l+1],5,-165796510),k=g(k,c,d,e,a[l+6],9,-1069501632),e=g(e,k,c,d,a[l+11],14,643717713),d=g(d,e,k,c,a[l+0],20,-373897302),c=g(c,d,e,k,a[l+5],5,-701558691),k=g(k,c,d,e,a[l+10],9,38016083),e=g(e,k,c,d,a[l+15],14,-660478335),d=g(d,e,k,c,a[l+4],20,-405537848),c=g(c,d,e,k,a[l+9],5,568446438),k=g(k,c,d,e,a[l+14],9,-1019803690),e=g(e,k,c,d,a[l+3],14,-187363961),d=g(d,e,k,c,a[l+8],20,1163531501),c=g(c,d,e,k,a[l+13],5,-1444681467),k=g(k,c,d,e,a[l+2],9,-51403784),e=g(e,k,c,d,a[l+7],14,1735328473),d=g(d,e,k,c,a[l+12],20,-1926607734),c=h(c,d,e,k,a[l+5],4,-378558),k=h(k,c,d,e,a[l+8],11,-2022574463),e=h(e,k,c,d,a[l+11],16,1839030562),d=h(d,e,k,c,a[l+14],23,-35309556),c=h(c,d,e,k,a[l+1],4,-1530992060),k=h(k,c,d,e,a[l+4],11,1272893353),e=h(e,k,c,d,a[l+7],16,-155497632),d=h(d,e,k,c,a[l+10],23,-1094730640),c=h(c,d,e,k,a[l+13],4,681279174),k=h(k,c,d,e,a[l+0],11,-358537222),e=h(e,k,c,d,a[l+3],16,-722521979),d=h(d,e,k,c,a[l+6],23,