From 175fe093849ea460370c0b4a81110c52a66592e7 Mon Sep 17 00:00:00 2001 From: Emilio Almansi Date: Tue, 2 Jan 2018 04:24:45 -0300 Subject: [PATCH] Bump version to v0.1.1 --- README.md | 2 +- dist/bitcoincashjs.0.1.0.min.js | 21 -- dist/bitcoincashjs.0.1.1.min.js | 1 + gulpfile.js | 4 +- package-lock.json | 370 +++++++++++++++++++++++++++++++- package.json | 5 +- 6 files changed, 376 insertions(+), 27 deletions(-) delete mode 100644 dist/bitcoincashjs.0.1.0.min.js create mode 100644 dist/bitcoincashjs.0.1.1.min.js diff --git a/README.md b/README.md index 9a37ee1..83986c7 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ $ bower install --save bitcoincashjs ### Manually -You may also download the distribution file manually and place it within your third-party scripts directory: [dist/bitcoincashjs.0.1.0.min.js](https://cdn.rawgit.com/bitcoincashjs/bitcoincashjs/1d3c14da/dist/bitcoincashjs.0.1.0.min.js). +You may also download the distribution file manually and place it within your third-party scripts directory: [dist/bitcoincashjs.0.1.1.min.js](https://cdn.rawgit.com/bitcoincashjs/bitcoincashjs/1d3c14da/dist/bitcoincashjs.0.1.1.min.js). ## Examples diff --git a/dist/bitcoincashjs.0.1.0.min.js b/dist/bitcoincashjs.0.1.0.min.js deleted file mode 100644 index f1f0169..0000000 --- a/dist/bitcoincashjs.0.1.0.min.js +++ /dev/null @@ -1,21 +0,0 @@ -!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).bitcoinCash=f()}}(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o>6],primitive=0==(32&tag);if(31==(31&tag)){var oct=tag;for(tag=0;128==(128&oct);){if(oct=buf.readUInt8(fail),buf.isError(oct))return oct;tag<<=7,tag|=127&oct}}else tag&=31;return{cls:cls,primitive:primitive,tag:tag,tagStr:der.tag[tag]}}function derDecodeLen(buf,primitive,fail){var len=buf.readUInt8(fail);if(buf.isError(len))return len;if(!primitive&&128===len)return null;if(0==(128&len))return len;var num=127&len;if(num>4)return buf.error("length octect is too long");len=0;for(var i=0;i=31)return reporter.error("Multi-octet tag encoding unsupported");primitive||(res|=32);return res|=der.tagClassByName[cls||"universal"]<<6}(tag,primitive,cls,this.reporter);if(content.length<128){return(header=new Buffer(2))[0]=encodedTag,header[1]=content.length,this._createEncoderBuffer([header,content])}for(var lenOctets=1,i=content.length;i>=256;i>>=8)lenOctets++;var header;(header=new Buffer(2+lenOctets))[0]=encodedTag,header[1]=128|lenOctets;i=1+lenOctets;for(var j=content.length;j>0;i--,j>>=8)header[i]=255&j;return this._createEncoderBuffer([header,content])},DERNode.prototype._encodeStr=function(str,tag){if("bitstr"===tag)return this._createEncoderBuffer([0|str.unused,str.data]);if("bmpstr"===tag){for(var buf=new Buffer(2*str.length),i=0;i=40)return this.reporter.error("Second objid identifier OOB");id.splice(0,2,40*id[0]+id[1])}var size=0;for(i=0;i=128;ident>>=7)size++}var objid=new Buffer(size),offset=objid.length-1;for(i=id.length-1;i>=0;i--){ident=id[i];for(objid[offset--]=127&ident;(ident>>=7)>0;)objid[offset--]=128|127&ident}return this._createEncoderBuffer(objid)};function two(num){return num<10?"0"+num:num}DERNode.prototype._encodeTime=function(time,tag){var str,date=new Date(time);return"gentime"===tag?str=[two(date.getFullYear()),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),"Z"].join(""):"utctime"===tag?str=[two(date.getFullYear()%100),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+tag+" time is not supported yet"),this._encodeStr(str,"octstr")},DERNode.prototype._encodeNull=function(){return this._createEncoderBuffer("")},DERNode.prototype._encodeInt=function(num,values){if("string"==typeof num){if(!values)return this.reporter.error("String int or enum given, but no values map");if(!values.hasOwnProperty(num))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(num));num=values[num]}if("number"!=typeof num&&!Buffer.isBuffer(num)){var numArray=num.toArray();!num.sign&&128&numArray[0]&&numArray.unshift(0),num=new Buffer(numArray)}if(Buffer.isBuffer(num)){var size=num.length;0===num.length&&size++;var out=new Buffer(size);return num.copy(out),0===num.length&&(out[0]=0),this._createEncoderBuffer(out)}if(num<128)return this._createEncoderBuffer(num);if(num<256)return this._createEncoderBuffer([0,num]);size=1;for(var i=num;i>=256;i>>=8)size++;for(i=(out=new Array(size)).length-1;i>=0;i--)out[i]=255&num,num>>=8;return 128&out[0]&&out.unshift(0),this._createEncoderBuffer(new Buffer(out))},DERNode.prototype._encodeBool=function(value){return this._createEncoderBuffer(value?255:0)},DERNode.prototype._use=function(entity,obj){return"function"==typeof entity&&(entity=entity(obj)),entity._getEncoder("der").tree},DERNode.prototype._skipDefault=function(dataBuffer,reporter,parent){var i,state=this._baseState;if(null===state.default)return!1;var data=dataBuffer.join();if(void 0===state.defaultBuffer&&(state.defaultBuffer=this._encodeValue(state.default,reporter,parent).join()),data.length!==state.defaultBuffer.length)return!1;for(i=0;i0?left:right},BN.min=function(left,right){return left.cmp(right)<0?left:right},BN.prototype._init=function(number,base,endian){if("number"==typeof number)return this._initNumber(number,base,endian);if("object"==typeof number)return this._initArray(number,base,endian);"hex"===base&&(base=16),assert(base===(0|base)&&base>=2&&base<=36);var start=0;"-"===(number=number.toString().replace(/\s+/g,""))[0]&&start++,16===base?this._parseHex(number,start):this._parseBase(number,base,start),"-"===number[0]&&(this.negative=1),this.strip(),"le"===endian&&this._initArray(this.toArray(),base,endian)},BN.prototype._initNumber=function(number,base,endian){number<0&&(this.negative=1,number=-number),number<67108864?(this.words=[67108863&number],this.length=1):number<4503599627370496?(this.words=[67108863&number,number/67108864&67108863],this.length=2):(assert(number<9007199254740992),this.words=[67108863&number,number/67108864&67108863,1],this.length=3),"le"===endian&&this._initArray(this.toArray(),base,endian)},BN.prototype._initArray=function(number,base,endian){if(assert("number"==typeof number.length),number.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(number.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)w=number[i]|number[i-1]<<8|number[i-2]<<16,this.words[j]|=w<>>26-off&67108863,(off+=24)>=26&&(off-=26,j++);else if("le"===endian)for(i=0,j=0;i>>26-off&67108863,(off+=24)>=26&&(off-=26,j++);return this.strip()};function parseHex(str,start,end){for(var r=0,len=Math.min(str.length,end),i=start;i=49&&c<=54?c-49+10:c>=17&&c<=22?c-17+10:15&c}return r}BN.prototype._parseHex=function(number,start){this.length=Math.ceil((number.length-start)/6),this.words=new Array(this.length);for(var i=0;i=start;i-=6)w=parseHex(number,i,i+6),this.words[j]|=w<>>26-off&4194303,(off+=24)>=26&&(off-=26,j++);i+6!==start&&(w=parseHex(number,start,i+6),this.words[j]|=w<>>26-off&4194303),this.strip()};function parseBase(str,start,end,mul){for(var r=0,len=Math.min(str.length,end),i=start;i=49?c-49+10:c>=17?c-17+10:c}return r}BN.prototype._parseBase=function(number,base,start){this.words=[0],this.length=1;for(var limbLen=0,limbPow=1;limbPow<=67108863;limbPow*=base)limbLen++;limbLen--,limbPow=limbPow/base|0;for(var total=number.length-start,mod=total%limbLen,end=Math.min(total,total-mod)+start,word=0,i=start;i1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},BN.prototype.inspect=function(){return(this.red?""};var zeros=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],groupSizes=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],groupBases=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];BN.prototype.toString=function(base,padding){base=base||10,padding=0|padding||1;var out;if(16===base||"hex"===base){out="";for(var off=0,carry=0,i=0;i>>24-off&16777215)||i!==this.length-1?zeros[6-word.length]+word+out:word+out,(off+=2)>=26&&(off-=26,i--)}for(0!==carry&&(out=carry.toString(16)+out);out.length%padding!=0;)out="0"+out;return 0!==this.negative&&(out="-"+out),out}if(base===(0|base)&&base>=2&&base<=36){var groupSize=groupSizes[base],groupBase=groupBases[base];out="";var c=this.clone();for(c.negative=0;!c.isZero();){var r=c.modn(groupBase).toString(base);out=(c=c.idivn(groupBase)).isZero()?r+out:zeros[groupSize-r.length]+r+out}for(this.isZero()&&(out="0"+out);out.length%padding!=0;)out="0"+out;return 0!==this.negative&&(out="-"+out),out}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function(){var ret=this.words[0];return 2===this.length?ret+=67108864*this.words[1]:3===this.length&&1===this.words[2]?ret+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-ret:ret},BN.prototype.toJSON=function(){return this.toString(16)},BN.prototype.toBuffer=function(endian,length){return assert(void 0!==Buffer),this.toArrayLike(Buffer,endian,length)},BN.prototype.toArray=function(endian,length){return this.toArrayLike(Array,endian,length)},BN.prototype.toArrayLike=function(ArrayType,endian,length){var byteLength=this.byteLength(),reqLength=length||Math.max(1,byteLength);assert(byteLength<=reqLength,"byte array longer than desired length"),assert(reqLength>0,"Requested array length <= 0"),this.strip();var b,i,littleEndian="le"===endian,res=new ArrayType(reqLength),q=this.clone();if(littleEndian){for(i=0;!q.isZero();i++)b=q.andln(255),q.iushrn(8),res[i]=b;for(;i=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},BN.prototype._zeroBits=function(w){if(0===w)return 26;var t=w,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},BN.prototype.bitLength=function(){var w=this.words[this.length-1],hi=this._countBits(w);return 26*(this.length-1)+hi};BN.prototype.zeroBits=function(){if(this.isZero())return 0;for(var r=0,i=0;inum.length?this.clone().ior(num):num.clone().ior(this)},BN.prototype.uor=function(num){return this.length>num.length?this.clone().iuor(num):num.clone().iuor(this)},BN.prototype.iuand=function(num){var b;b=this.length>num.length?num:this;for(var i=0;inum.length?this.clone().iand(num):num.clone().iand(this)},BN.prototype.uand=function(num){return this.length>num.length?this.clone().iuand(num):num.clone().iuand(this)},BN.prototype.iuxor=function(num){var a,b;this.length>num.length?(a=this,b=num):(a=num,b=this);for(var i=0;inum.length?this.clone().ixor(num):num.clone().ixor(this)},BN.prototype.uxor=function(num){return this.length>num.length?this.clone().iuxor(num):num.clone().iuxor(this)},BN.prototype.inotn=function(width){assert("number"==typeof width&&width>=0);var bytesNeeded=0|Math.ceil(width/26),bitsLeft=width%26;this._expand(bytesNeeded),bitsLeft>0&&bytesNeeded--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-bitsLeft),this.strip()},BN.prototype.notn=function(width){return this.clone().inotn(width)},BN.prototype.setn=function(bit,val){assert("number"==typeof bit&&bit>=0);var off=bit/26|0,wbit=bit%26;return this._expand(off+1),this.words[off]=val?this.words[off]|1<num.length?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>>26;for(;0!==carry&&i>>26;if(this.length=a.length,0!==carry)this.words[this.length]=carry,this.length++;else if(a!==this)for(;inum.length?this.clone().iadd(num):num.clone().iadd(this)},BN.prototype.isub=function(num){if(0!==num.negative){num.negative=0;var r=this.iadd(num);return num.negative=1,r._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(num),this.negative=1,this._normSign();var cmp=this.cmp(num);if(0===cmp)return this.negative=0,this.length=1,this.words[0]=0,this;var a,b;cmp>0?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>26,this.words[i]=67108863&r;for(;0!==carry&&i>26,this.words[i]=67108863&r;if(0===carry&&i>>26,rword=67108863&carry,maxJ=Math.min(k,num.length-1),j=Math.max(0,k-self.length+1);j<=maxJ;j++){var i=k-j|0;ncarry+=(r=(a=0|self.words[i])*(b=0|num.words[j])+rword)/67108864|0,rword=67108863&r}out.words[k]=0|rword,carry=0|ncarry}return 0!==carry?out.words[k]=0|carry:out.length--,out.strip()}var comb10MulTo=function(self,num,out){var lo,mid,hi,a=self.words,b=num.words,o=out.words,c=0,a0=0|a[0],al0=8191&a0,ah0=a0>>>13,a1=0|a[1],al1=8191&a1,ah1=a1>>>13,a2=0|a[2],al2=8191&a2,ah2=a2>>>13,a3=0|a[3],al3=8191&a3,ah3=a3>>>13,a4=0|a[4],al4=8191&a4,ah4=a4>>>13,a5=0|a[5],al5=8191&a5,ah5=a5>>>13,a6=0|a[6],al6=8191&a6,ah6=a6>>>13,a7=0|a[7],al7=8191&a7,ah7=a7>>>13,a8=0|a[8],al8=8191&a8,ah8=a8>>>13,a9=0|a[9],al9=8191&a9,ah9=a9>>>13,b0=0|b[0],bl0=8191&b0,bh0=b0>>>13,b1=0|b[1],bl1=8191&b1,bh1=b1>>>13,b2=0|b[2],bl2=8191&b2,bh2=b2>>>13,b3=0|b[3],bl3=8191&b3,bh3=b3>>>13,b4=0|b[4],bl4=8191&b4,bh4=b4>>>13,b5=0|b[5],bl5=8191&b5,bh5=b5>>>13,b6=0|b[6],bl6=8191&b6,bh6=b6>>>13,b7=0|b[7],bl7=8191&b7,bh7=b7>>>13,b8=0|b[8],bl8=8191&b8,bh8=b8>>>13,b9=0|b[9],bl9=8191&b9,bh9=b9>>>13;out.negative=self.negative^num.negative,out.length=19;var w0=(c+(lo=Math.imul(al0,bl0))|0)+((8191&(mid=(mid=Math.imul(al0,bh0))+Math.imul(ah0,bl0)|0))<<13)|0;c=((hi=Math.imul(ah0,bh0))+(mid>>>13)|0)+(w0>>>26)|0,w0&=67108863,lo=Math.imul(al1,bl0),mid=(mid=Math.imul(al1,bh0))+Math.imul(ah1,bl0)|0,hi=Math.imul(ah1,bh0);var w1=(c+(lo=lo+Math.imul(al0,bl1)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh1)|0)+Math.imul(ah0,bl1)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh1)|0)+(mid>>>13)|0)+(w1>>>26)|0,w1&=67108863,lo=Math.imul(al2,bl0),mid=(mid=Math.imul(al2,bh0))+Math.imul(ah2,bl0)|0,hi=Math.imul(ah2,bh0),lo=lo+Math.imul(al1,bl1)|0,mid=(mid=mid+Math.imul(al1,bh1)|0)+Math.imul(ah1,bl1)|0,hi=hi+Math.imul(ah1,bh1)|0;var w2=(c+(lo=lo+Math.imul(al0,bl2)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh2)|0)+Math.imul(ah0,bl2)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh2)|0)+(mid>>>13)|0)+(w2>>>26)|0,w2&=67108863,lo=Math.imul(al3,bl0),mid=(mid=Math.imul(al3,bh0))+Math.imul(ah3,bl0)|0,hi=Math.imul(ah3,bh0),lo=lo+Math.imul(al2,bl1)|0,mid=(mid=mid+Math.imul(al2,bh1)|0)+Math.imul(ah2,bl1)|0,hi=hi+Math.imul(ah2,bh1)|0,lo=lo+Math.imul(al1,bl2)|0,mid=(mid=mid+Math.imul(al1,bh2)|0)+Math.imul(ah1,bl2)|0,hi=hi+Math.imul(ah1,bh2)|0;var w3=(c+(lo=lo+Math.imul(al0,bl3)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh3)|0)+Math.imul(ah0,bl3)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh3)|0)+(mid>>>13)|0)+(w3>>>26)|0,w3&=67108863,lo=Math.imul(al4,bl0),mid=(mid=Math.imul(al4,bh0))+Math.imul(ah4,bl0)|0,hi=Math.imul(ah4,bh0),lo=lo+Math.imul(al3,bl1)|0,mid=(mid=mid+Math.imul(al3,bh1)|0)+Math.imul(ah3,bl1)|0,hi=hi+Math.imul(ah3,bh1)|0,lo=lo+Math.imul(al2,bl2)|0,mid=(mid=mid+Math.imul(al2,bh2)|0)+Math.imul(ah2,bl2)|0,hi=hi+Math.imul(ah2,bh2)|0,lo=lo+Math.imul(al1,bl3)|0,mid=(mid=mid+Math.imul(al1,bh3)|0)+Math.imul(ah1,bl3)|0,hi=hi+Math.imul(ah1,bh3)|0;var w4=(c+(lo=lo+Math.imul(al0,bl4)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh4)|0)+Math.imul(ah0,bl4)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh4)|0)+(mid>>>13)|0)+(w4>>>26)|0,w4&=67108863,lo=Math.imul(al5,bl0),mid=(mid=Math.imul(al5,bh0))+Math.imul(ah5,bl0)|0,hi=Math.imul(ah5,bh0),lo=lo+Math.imul(al4,bl1)|0,mid=(mid=mid+Math.imul(al4,bh1)|0)+Math.imul(ah4,bl1)|0,hi=hi+Math.imul(ah4,bh1)|0,lo=lo+Math.imul(al3,bl2)|0,mid=(mid=mid+Math.imul(al3,bh2)|0)+Math.imul(ah3,bl2)|0,hi=hi+Math.imul(ah3,bh2)|0,lo=lo+Math.imul(al2,bl3)|0,mid=(mid=mid+Math.imul(al2,bh3)|0)+Math.imul(ah2,bl3)|0,hi=hi+Math.imul(ah2,bh3)|0,lo=lo+Math.imul(al1,bl4)|0,mid=(mid=mid+Math.imul(al1,bh4)|0)+Math.imul(ah1,bl4)|0,hi=hi+Math.imul(ah1,bh4)|0;var w5=(c+(lo=lo+Math.imul(al0,bl5)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh5)|0)+Math.imul(ah0,bl5)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh5)|0)+(mid>>>13)|0)+(w5>>>26)|0,w5&=67108863,lo=Math.imul(al6,bl0),mid=(mid=Math.imul(al6,bh0))+Math.imul(ah6,bl0)|0,hi=Math.imul(ah6,bh0),lo=lo+Math.imul(al5,bl1)|0,mid=(mid=mid+Math.imul(al5,bh1)|0)+Math.imul(ah5,bl1)|0,hi=hi+Math.imul(ah5,bh1)|0,lo=lo+Math.imul(al4,bl2)|0,mid=(mid=mid+Math.imul(al4,bh2)|0)+Math.imul(ah4,bl2)|0,hi=hi+Math.imul(ah4,bh2)|0,lo=lo+Math.imul(al3,bl3)|0,mid=(mid=mid+Math.imul(al3,bh3)|0)+Math.imul(ah3,bl3)|0,hi=hi+Math.imul(ah3,bh3)|0,lo=lo+Math.imul(al2,bl4)|0,mid=(mid=mid+Math.imul(al2,bh4)|0)+Math.imul(ah2,bl4)|0,hi=hi+Math.imul(ah2,bh4)|0,lo=lo+Math.imul(al1,bl5)|0,mid=(mid=mid+Math.imul(al1,bh5)|0)+Math.imul(ah1,bl5)|0,hi=hi+Math.imul(ah1,bh5)|0;var w6=(c+(lo=lo+Math.imul(al0,bl6)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh6)|0)+Math.imul(ah0,bl6)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh6)|0)+(mid>>>13)|0)+(w6>>>26)|0,w6&=67108863,lo=Math.imul(al7,bl0),mid=(mid=Math.imul(al7,bh0))+Math.imul(ah7,bl0)|0,hi=Math.imul(ah7,bh0),lo=lo+Math.imul(al6,bl1)|0,mid=(mid=mid+Math.imul(al6,bh1)|0)+Math.imul(ah6,bl1)|0,hi=hi+Math.imul(ah6,bh1)|0,lo=lo+Math.imul(al5,bl2)|0,mid=(mid=mid+Math.imul(al5,bh2)|0)+Math.imul(ah5,bl2)|0,hi=hi+Math.imul(ah5,bh2)|0,lo=lo+Math.imul(al4,bl3)|0,mid=(mid=mid+Math.imul(al4,bh3)|0)+Math.imul(ah4,bl3)|0,hi=hi+Math.imul(ah4,bh3)|0,lo=lo+Math.imul(al3,bl4)|0,mid=(mid=mid+Math.imul(al3,bh4)|0)+Math.imul(ah3,bl4)|0,hi=hi+Math.imul(ah3,bh4)|0,lo=lo+Math.imul(al2,bl5)|0,mid=(mid=mid+Math.imul(al2,bh5)|0)+Math.imul(ah2,bl5)|0,hi=hi+Math.imul(ah2,bh5)|0,lo=lo+Math.imul(al1,bl6)|0,mid=(mid=mid+Math.imul(al1,bh6)|0)+Math.imul(ah1,bl6)|0,hi=hi+Math.imul(ah1,bh6)|0;var w7=(c+(lo=lo+Math.imul(al0,bl7)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh7)|0)+Math.imul(ah0,bl7)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh7)|0)+(mid>>>13)|0)+(w7>>>26)|0,w7&=67108863,lo=Math.imul(al8,bl0),mid=(mid=Math.imul(al8,bh0))+Math.imul(ah8,bl0)|0,hi=Math.imul(ah8,bh0),lo=lo+Math.imul(al7,bl1)|0,mid=(mid=mid+Math.imul(al7,bh1)|0)+Math.imul(ah7,bl1)|0,hi=hi+Math.imul(ah7,bh1)|0,lo=lo+Math.imul(al6,bl2)|0,mid=(mid=mid+Math.imul(al6,bh2)|0)+Math.imul(ah6,bl2)|0,hi=hi+Math.imul(ah6,bh2)|0,lo=lo+Math.imul(al5,bl3)|0,mid=(mid=mid+Math.imul(al5,bh3)|0)+Math.imul(ah5,bl3)|0,hi=hi+Math.imul(ah5,bh3)|0,lo=lo+Math.imul(al4,bl4)|0,mid=(mid=mid+Math.imul(al4,bh4)|0)+Math.imul(ah4,bl4)|0,hi=hi+Math.imul(ah4,bh4)|0,lo=lo+Math.imul(al3,bl5)|0,mid=(mid=mid+Math.imul(al3,bh5)|0)+Math.imul(ah3,bl5)|0,hi=hi+Math.imul(ah3,bh5)|0,lo=lo+Math.imul(al2,bl6)|0,mid=(mid=mid+Math.imul(al2,bh6)|0)+Math.imul(ah2,bl6)|0,hi=hi+Math.imul(ah2,bh6)|0,lo=lo+Math.imul(al1,bl7)|0,mid=(mid=mid+Math.imul(al1,bh7)|0)+Math.imul(ah1,bl7)|0,hi=hi+Math.imul(ah1,bh7)|0;var w8=(c+(lo=lo+Math.imul(al0,bl8)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh8)|0)+Math.imul(ah0,bl8)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh8)|0)+(mid>>>13)|0)+(w8>>>26)|0,w8&=67108863,lo=Math.imul(al9,bl0),mid=(mid=Math.imul(al9,bh0))+Math.imul(ah9,bl0)|0,hi=Math.imul(ah9,bh0),lo=lo+Math.imul(al8,bl1)|0,mid=(mid=mid+Math.imul(al8,bh1)|0)+Math.imul(ah8,bl1)|0,hi=hi+Math.imul(ah8,bh1)|0,lo=lo+Math.imul(al7,bl2)|0,mid=(mid=mid+Math.imul(al7,bh2)|0)+Math.imul(ah7,bl2)|0,hi=hi+Math.imul(ah7,bh2)|0,lo=lo+Math.imul(al6,bl3)|0,mid=(mid=mid+Math.imul(al6,bh3)|0)+Math.imul(ah6,bl3)|0,hi=hi+Math.imul(ah6,bh3)|0,lo=lo+Math.imul(al5,bl4)|0,mid=(mid=mid+Math.imul(al5,bh4)|0)+Math.imul(ah5,bl4)|0,hi=hi+Math.imul(ah5,bh4)|0,lo=lo+Math.imul(al4,bl5)|0,mid=(mid=mid+Math.imul(al4,bh5)|0)+Math.imul(ah4,bl5)|0,hi=hi+Math.imul(ah4,bh5)|0,lo=lo+Math.imul(al3,bl6)|0,mid=(mid=mid+Math.imul(al3,bh6)|0)+Math.imul(ah3,bl6)|0,hi=hi+Math.imul(ah3,bh6)|0,lo=lo+Math.imul(al2,bl7)|0,mid=(mid=mid+Math.imul(al2,bh7)|0)+Math.imul(ah2,bl7)|0,hi=hi+Math.imul(ah2,bh7)|0,lo=lo+Math.imul(al1,bl8)|0,mid=(mid=mid+Math.imul(al1,bh8)|0)+Math.imul(ah1,bl8)|0,hi=hi+Math.imul(ah1,bh8)|0;var w9=(c+(lo=lo+Math.imul(al0,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh9)|0)+Math.imul(ah0,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh9)|0)+(mid>>>13)|0)+(w9>>>26)|0,w9&=67108863,lo=Math.imul(al9,bl1),mid=(mid=Math.imul(al9,bh1))+Math.imul(ah9,bl1)|0,hi=Math.imul(ah9,bh1),lo=lo+Math.imul(al8,bl2)|0,mid=(mid=mid+Math.imul(al8,bh2)|0)+Math.imul(ah8,bl2)|0,hi=hi+Math.imul(ah8,bh2)|0,lo=lo+Math.imul(al7,bl3)|0,mid=(mid=mid+Math.imul(al7,bh3)|0)+Math.imul(ah7,bl3)|0,hi=hi+Math.imul(ah7,bh3)|0,lo=lo+Math.imul(al6,bl4)|0,mid=(mid=mid+Math.imul(al6,bh4)|0)+Math.imul(ah6,bl4)|0,hi=hi+Math.imul(ah6,bh4)|0,lo=lo+Math.imul(al5,bl5)|0,mid=(mid=mid+Math.imul(al5,bh5)|0)+Math.imul(ah5,bl5)|0,hi=hi+Math.imul(ah5,bh5)|0,lo=lo+Math.imul(al4,bl6)|0,mid=(mid=mid+Math.imul(al4,bh6)|0)+Math.imul(ah4,bl6)|0,hi=hi+Math.imul(ah4,bh6)|0,lo=lo+Math.imul(al3,bl7)|0,mid=(mid=mid+Math.imul(al3,bh7)|0)+Math.imul(ah3,bl7)|0,hi=hi+Math.imul(ah3,bh7)|0,lo=lo+Math.imul(al2,bl8)|0,mid=(mid=mid+Math.imul(al2,bh8)|0)+Math.imul(ah2,bl8)|0,hi=hi+Math.imul(ah2,bh8)|0;var w10=(c+(lo=lo+Math.imul(al1,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al1,bh9)|0)+Math.imul(ah1,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah1,bh9)|0)+(mid>>>13)|0)+(w10>>>26)|0,w10&=67108863,lo=Math.imul(al9,bl2),mid=(mid=Math.imul(al9,bh2))+Math.imul(ah9,bl2)|0,hi=Math.imul(ah9,bh2),lo=lo+Math.imul(al8,bl3)|0,mid=(mid=mid+Math.imul(al8,bh3)|0)+Math.imul(ah8,bl3)|0,hi=hi+Math.imul(ah8,bh3)|0,lo=lo+Math.imul(al7,bl4)|0,mid=(mid=mid+Math.imul(al7,bh4)|0)+Math.imul(ah7,bl4)|0,hi=hi+Math.imul(ah7,bh4)|0,lo=lo+Math.imul(al6,bl5)|0,mid=(mid=mid+Math.imul(al6,bh5)|0)+Math.imul(ah6,bl5)|0,hi=hi+Math.imul(ah6,bh5)|0,lo=lo+Math.imul(al5,bl6)|0,mid=(mid=mid+Math.imul(al5,bh6)|0)+Math.imul(ah5,bl6)|0,hi=hi+Math.imul(ah5,bh6)|0,lo=lo+Math.imul(al4,bl7)|0,mid=(mid=mid+Math.imul(al4,bh7)|0)+Math.imul(ah4,bl7)|0,hi=hi+Math.imul(ah4,bh7)|0,lo=lo+Math.imul(al3,bl8)|0,mid=(mid=mid+Math.imul(al3,bh8)|0)+Math.imul(ah3,bl8)|0,hi=hi+Math.imul(ah3,bh8)|0;var w11=(c+(lo=lo+Math.imul(al2,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al2,bh9)|0)+Math.imul(ah2,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah2,bh9)|0)+(mid>>>13)|0)+(w11>>>26)|0,w11&=67108863,lo=Math.imul(al9,bl3),mid=(mid=Math.imul(al9,bh3))+Math.imul(ah9,bl3)|0,hi=Math.imul(ah9,bh3),lo=lo+Math.imul(al8,bl4)|0,mid=(mid=mid+Math.imul(al8,bh4)|0)+Math.imul(ah8,bl4)|0,hi=hi+Math.imul(ah8,bh4)|0,lo=lo+Math.imul(al7,bl5)|0,mid=(mid=mid+Math.imul(al7,bh5)|0)+Math.imul(ah7,bl5)|0,hi=hi+Math.imul(ah7,bh5)|0,lo=lo+Math.imul(al6,bl6)|0,mid=(mid=mid+Math.imul(al6,bh6)|0)+Math.imul(ah6,bl6)|0,hi=hi+Math.imul(ah6,bh6)|0,lo=lo+Math.imul(al5,bl7)|0,mid=(mid=mid+Math.imul(al5,bh7)|0)+Math.imul(ah5,bl7)|0,hi=hi+Math.imul(ah5,bh7)|0,lo=lo+Math.imul(al4,bl8)|0,mid=(mid=mid+Math.imul(al4,bh8)|0)+Math.imul(ah4,bl8)|0,hi=hi+Math.imul(ah4,bh8)|0;var w12=(c+(lo=lo+Math.imul(al3,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al3,bh9)|0)+Math.imul(ah3,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah3,bh9)|0)+(mid>>>13)|0)+(w12>>>26)|0,w12&=67108863,lo=Math.imul(al9,bl4),mid=(mid=Math.imul(al9,bh4))+Math.imul(ah9,bl4)|0,hi=Math.imul(ah9,bh4),lo=lo+Math.imul(al8,bl5)|0,mid=(mid=mid+Math.imul(al8,bh5)|0)+Math.imul(ah8,bl5)|0,hi=hi+Math.imul(ah8,bh5)|0,lo=lo+Math.imul(al7,bl6)|0,mid=(mid=mid+Math.imul(al7,bh6)|0)+Math.imul(ah7,bl6)|0,hi=hi+Math.imul(ah7,bh6)|0,lo=lo+Math.imul(al6,bl7)|0,mid=(mid=mid+Math.imul(al6,bh7)|0)+Math.imul(ah6,bl7)|0,hi=hi+Math.imul(ah6,bh7)|0,lo=lo+Math.imul(al5,bl8)|0,mid=(mid=mid+Math.imul(al5,bh8)|0)+Math.imul(ah5,bl8)|0,hi=hi+Math.imul(ah5,bh8)|0;var w13=(c+(lo=lo+Math.imul(al4,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al4,bh9)|0)+Math.imul(ah4,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah4,bh9)|0)+(mid>>>13)|0)+(w13>>>26)|0,w13&=67108863,lo=Math.imul(al9,bl5),mid=(mid=Math.imul(al9,bh5))+Math.imul(ah9,bl5)|0,hi=Math.imul(ah9,bh5),lo=lo+Math.imul(al8,bl6)|0,mid=(mid=mid+Math.imul(al8,bh6)|0)+Math.imul(ah8,bl6)|0,hi=hi+Math.imul(ah8,bh6)|0,lo=lo+Math.imul(al7,bl7)|0,mid=(mid=mid+Math.imul(al7,bh7)|0)+Math.imul(ah7,bl7)|0,hi=hi+Math.imul(ah7,bh7)|0,lo=lo+Math.imul(al6,bl8)|0,mid=(mid=mid+Math.imul(al6,bh8)|0)+Math.imul(ah6,bl8)|0,hi=hi+Math.imul(ah6,bh8)|0;var w14=(c+(lo=lo+Math.imul(al5,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al5,bh9)|0)+Math.imul(ah5,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah5,bh9)|0)+(mid>>>13)|0)+(w14>>>26)|0,w14&=67108863,lo=Math.imul(al9,bl6),mid=(mid=Math.imul(al9,bh6))+Math.imul(ah9,bl6)|0,hi=Math.imul(ah9,bh6),lo=lo+Math.imul(al8,bl7)|0,mid=(mid=mid+Math.imul(al8,bh7)|0)+Math.imul(ah8,bl7)|0,hi=hi+Math.imul(ah8,bh7)|0,lo=lo+Math.imul(al7,bl8)|0,mid=(mid=mid+Math.imul(al7,bh8)|0)+Math.imul(ah7,bl8)|0,hi=hi+Math.imul(ah7,bh8)|0;var w15=(c+(lo=lo+Math.imul(al6,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al6,bh9)|0)+Math.imul(ah6,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah6,bh9)|0)+(mid>>>13)|0)+(w15>>>26)|0,w15&=67108863,lo=Math.imul(al9,bl7),mid=(mid=Math.imul(al9,bh7))+Math.imul(ah9,bl7)|0,hi=Math.imul(ah9,bh7),lo=lo+Math.imul(al8,bl8)|0,mid=(mid=mid+Math.imul(al8,bh8)|0)+Math.imul(ah8,bl8)|0,hi=hi+Math.imul(ah8,bh8)|0;var w16=(c+(lo=lo+Math.imul(al7,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al7,bh9)|0)+Math.imul(ah7,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah7,bh9)|0)+(mid>>>13)|0)+(w16>>>26)|0,w16&=67108863,lo=Math.imul(al9,bl8),mid=(mid=Math.imul(al9,bh8))+Math.imul(ah9,bl8)|0,hi=Math.imul(ah9,bh8);var w17=(c+(lo=lo+Math.imul(al8,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al8,bh9)|0)+Math.imul(ah8,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah8,bh9)|0)+(mid>>>13)|0)+(w17>>>26)|0,w17&=67108863;var w18=(c+(lo=Math.imul(al9,bl9))|0)+((8191&(mid=(mid=Math.imul(al9,bh9))+Math.imul(ah9,bl9)|0))<<13)|0;return c=((hi=Math.imul(ah9,bh9))+(mid>>>13)|0)+(w18>>>26)|0,w18&=67108863,o[0]=w0,o[1]=w1,o[2]=w2,o[3]=w3,o[4]=w4,o[5]=w5,o[6]=w6,o[7]=w7,o[8]=w8,o[9]=w9,o[10]=w10,o[11]=w11,o[12]=w12,o[13]=w13,o[14]=w14,o[15]=w15,o[16]=w16,o[17]=w17,o[18]=w18,0!==c&&(o[19]=c,out.length++),out};Math.imul||(comb10MulTo=smallMulTo);function jumboMulTo(self,num,out){return(new FFTM).mulp(self,num,out)}BN.prototype.mulTo=function(num,out){var len=this.length+num.length;return 10===this.length&&10===num.length?comb10MulTo(this,num,out):len<63?smallMulTo(this,num,out):len<1024?function(self,num,out){out.negative=num.negative^self.negative,out.length=self.length+num.length;for(var carry=0,hncarry=0,k=0;k>>26)|0)>>>26,ncarry&=67108863}out.words[k]=rword,carry=ncarry,ncarry=hncarry}return 0!==carry?out.words[k]=carry:out.length--,out.strip()}(this,num,out):jumboMulTo(this,num,out)};function FFTM(x,y){this.x=x,this.y=y}FFTM.prototype.makeRBT=function(N){for(var t=new Array(N),l=BN.prototype._countBits(N)-1,i=0;i>=1;return rb},FFTM.prototype.permute=function(rbt,rws,iws,rtws,itws,N){for(var i=0;i>>=1)i++;return 1<>>=13,rws[2*i+1]=8191&carry,carry>>>=13;for(i=2*len;i>=26,carry+=w/67108864|0,carry+=lo>>>26,this.words[i]=67108863&lo}return 0!==carry&&(this.words[i]=carry,this.length++),this},BN.prototype.muln=function(num){return this.clone().imuln(num)},BN.prototype.sqr=function(){return this.mul(this)},BN.prototype.isqr=function(){return this.imul(this.clone())},BN.prototype.pow=function(num){var w=function(num){for(var w=new Array(num.bitLength()),bit=0;bit>>wbit}return w}(num);if(0===w.length)return new BN(1);for(var res=this,i=0;i=0);var i,r=bits%26,s=(bits-r)/26,carryMask=67108863>>>26-r<<26-r;if(0!==r){var carry=0;for(i=0;i>>26-r}carry&&(this.words[i]=carry,this.length++)}if(0!==s){for(i=this.length-1;i>=0;i--)this.words[i+s]=this.words[i];for(i=0;i=0);var h;h=hint?(hint-hint%26)/26:0;var r=bits%26,s=Math.min((bits-r)/26,this.length),mask=67108863^67108863>>>r<s)for(this.length-=s,i=0;i=0&&(0!==carry||i>=h);i--){var word=0|this.words[i];this.words[i]=carry<<26-r|word>>>r,carry=word&mask}return maskedWords&&0!==carry&&(maskedWords.words[maskedWords.length++]=carry),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function(bits,hint,extended){return assert(0===this.negative),this.iushrn(bits,hint,extended)},BN.prototype.shln=function(bits){return this.clone().ishln(bits)},BN.prototype.ushln=function(bits){return this.clone().iushln(bits)},BN.prototype.shrn=function(bits){return this.clone().ishrn(bits)},BN.prototype.ushrn=function(bits){return this.clone().iushrn(bits)},BN.prototype.testn=function(bit){assert("number"==typeof bit&&bit>=0);var r=bit%26,s=(bit-r)/26,q=1<=0);var r=bits%26,s=(bits-r)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=s)return this;if(0!==r&&s++,this.length=Math.min(s,this.length),0!==r){var mask=67108863^67108863>>>r<=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},BN.prototype.isubn=function(num){if(assert("number"==typeof num),assert(num<67108864),num<0)return this.iaddn(-num);if(0!==this.negative)return this.negative=0,this.iaddn(num),this.negative=1,this;if(this.words[0]-=num,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(right/67108864|0),this.words[i+shift]=67108863&w}for(;i>26,this.words[i+shift]=67108863&w;if(0===carry)return this.strip();for(assert(-1===carry),carry=0,i=0;i>26,this.words[i]=67108863&w;return this.negative=1,this.strip()},BN.prototype._wordDiv=function(num,mode){var shift=this.length-num.length,a=this.clone(),b=num,bhi=0|b.words[b.length-1];0!==(shift=26-this._countBits(bhi))&&(b=b.ushln(shift),a.iushln(shift),bhi=0|b.words[b.length-1]);var q,m=a.length-b.length;if("mod"!==mode){(q=new BN(null)).length=m+1,q.words=new Array(q.length);for(var i=0;i=0;j--){var qj=67108864*(0|a.words[b.length+j])+(0|a.words[b.length+j-1]);for(qj=Math.min(qj/bhi|0,67108863),a._ishlnsubmul(b,qj,j);0!==a.negative;)qj--,a.negative=0,a._ishlnsubmul(b,1,j),a.isZero()||(a.negative^=1);q&&(q.words[j]=qj)}return q&&q.strip(),a.strip(),"div"!==mode&&0!==shift&&a.iushrn(shift),{div:q||null,mod:a}},BN.prototype.divmod=function(num,mode,positive){if(assert(!num.isZero()),this.isZero())return{div:new BN(0),mod:new BN(0)};var div,mod,res;return 0!==this.negative&&0===num.negative?(res=this.neg().divmod(num,mode),"mod"!==mode&&(div=res.div.neg()),"div"!==mode&&(mod=res.mod.neg(),positive&&0!==mod.negative&&mod.iadd(num)),{div:div,mod:mod}):0===this.negative&&0!==num.negative?(res=this.divmod(num.neg(),mode),"mod"!==mode&&(div=res.div.neg()),{div:div,mod:res.mod}):0!=(this.negative&num.negative)?(res=this.neg().divmod(num.neg(),mode),"div"!==mode&&(mod=res.mod.neg(),positive&&0!==mod.negative&&mod.isub(num)),{div:res.div,mod:mod}):num.length>this.length||this.cmp(num)<0?{div:new BN(0),mod:this}:1===num.length?"div"===mode?{div:this.divn(num.words[0]),mod:null}:"mod"===mode?{div:null,mod:new BN(this.modn(num.words[0]))}:{div:this.divn(num.words[0]),mod:new BN(this.modn(num.words[0]))}:this._wordDiv(num,mode)},BN.prototype.div=function(num){return this.divmod(num,"div",!1).div},BN.prototype.mod=function(num){return this.divmod(num,"mod",!1).mod},BN.prototype.umod=function(num){return this.divmod(num,"mod",!0).mod},BN.prototype.divRound=function(num){var dm=this.divmod(num);if(dm.mod.isZero())return dm.div;var mod=0!==dm.div.negative?dm.mod.isub(num):dm.mod,half=num.ushrn(1),r2=num.andln(1),cmp=mod.cmp(half);return cmp<0||1===r2&&0===cmp?dm.div:0!==dm.div.negative?dm.div.isubn(1):dm.div.iaddn(1)},BN.prototype.modn=function(num){assert(num<=67108863);for(var p=(1<<26)%num,acc=0,i=this.length-1;i>=0;i--)acc=(p*acc+(0|this.words[i]))%num;return acc},BN.prototype.idivn=function(num){assert(num<=67108863);for(var carry=0,i=this.length-1;i>=0;i--){var w=(0|this.words[i])+67108864*carry;this.words[i]=w/num|0,carry=w%num}return this.strip()},BN.prototype.divn=function(num){return this.clone().idivn(num)},BN.prototype.egcd=function(p){assert(0===p.negative),assert(!p.isZero());var x=this,y=p.clone();x=0!==x.negative?x.umod(p):x.clone();for(var A=new BN(1),B=new BN(0),C=new BN(0),D=new BN(1),g=0;x.isEven()&&y.isEven();)x.iushrn(1),y.iushrn(1),++g;for(var yp=y.clone(),xp=x.clone();!x.isZero();){for(var i=0,im=1;0==(x.words[0]&im)&&i<26;++i,im<<=1);if(i>0)for(x.iushrn(i);i-- >0;)(A.isOdd()||B.isOdd())&&(A.iadd(yp),B.isub(xp)),A.iushrn(1),B.iushrn(1);for(var j=0,jm=1;0==(y.words[0]&jm)&&j<26;++j,jm<<=1);if(j>0)for(y.iushrn(j);j-- >0;)(C.isOdd()||D.isOdd())&&(C.iadd(yp),D.isub(xp)),C.iushrn(1),D.iushrn(1);x.cmp(y)>=0?(x.isub(y),A.isub(C),B.isub(D)):(y.isub(x),C.isub(A),D.isub(B))}return{a:C,b:D,gcd:y.iushln(g)}},BN.prototype._invmp=function(p){assert(0===p.negative),assert(!p.isZero());var a=this,b=p.clone();a=0!==a.negative?a.umod(p):a.clone();for(var x1=new BN(1),x2=new BN(0),delta=b.clone();a.cmpn(1)>0&&b.cmpn(1)>0;){for(var i=0,im=1;0==(a.words[0]&im)&&i<26;++i,im<<=1);if(i>0)for(a.iushrn(i);i-- >0;)x1.isOdd()&&x1.iadd(delta),x1.iushrn(1);for(var j=0,jm=1;0==(b.words[0]&jm)&&j<26;++j,jm<<=1);if(j>0)for(b.iushrn(j);j-- >0;)x2.isOdd()&&x2.iadd(delta),x2.iushrn(1);a.cmp(b)>=0?(a.isub(b),x1.isub(x2)):(b.isub(a),x2.isub(x1))}var res;return(res=0===a.cmpn(1)?x1:x2).cmpn(0)<0&&res.iadd(p),res},BN.prototype.gcd=function(num){if(this.isZero())return num.abs();if(num.isZero())return this.abs();var a=this.clone(),b=num.clone();a.negative=0,b.negative=0;for(var shift=0;a.isEven()&&b.isEven();shift++)a.iushrn(1),b.iushrn(1);for(;;){for(;a.isEven();)a.iushrn(1);for(;b.isEven();)b.iushrn(1);var r=a.cmp(b);if(r<0){var t=a;a=b,b=t}else if(0===r||0===b.cmpn(1))break;a.isub(b)}return b.iushln(shift)},BN.prototype.invm=function(num){return this.egcd(num).a.umod(num)},BN.prototype.isEven=function(){return 0==(1&this.words[0])},BN.prototype.isOdd=function(){return 1==(1&this.words[0])},BN.prototype.andln=function(num){return this.words[0]&num},BN.prototype.bincn=function(bit){assert("number"==typeof bit);var r=bit%26,s=(bit-r)/26,q=1<>>26,w&=67108863,this.words[i]=w}return 0!==carry&&(this.words[i]=carry,this.length++),this},BN.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function(num){var negative=num<0;if(0!==this.negative&&!negative)return-1;if(0===this.negative&&negative)return 1;this.strip();var res;if(this.length>1)res=1;else{negative&&(num=-num),assert(num<=67108863,"Number is too big");var w=0|this.words[0];res=w===num?0:wnum.length)return 1;if(this.length=0;i--){var a=0|this.words[i],b=0|num.words[i];if(a!==b){ab&&(res=1);break}}return res},BN.prototype.gtn=function(num){return 1===this.cmpn(num)},BN.prototype.gt=function(num){return 1===this.cmp(num)},BN.prototype.gten=function(num){return this.cmpn(num)>=0},BN.prototype.gte=function(num){return this.cmp(num)>=0},BN.prototype.ltn=function(num){return-1===this.cmpn(num)},BN.prototype.lt=function(num){return-1===this.cmp(num)},BN.prototype.lten=function(num){return this.cmpn(num)<=0},BN.prototype.lte=function(num){return this.cmp(num)<=0},BN.prototype.eqn=function(num){return 0===this.cmpn(num)},BN.prototype.eq=function(num){return 0===this.cmp(num)},BN.red=function(num){return new Red(num)},BN.prototype.toRed=function(ctx){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),ctx.convertTo(this)._forceRed(ctx)},BN.prototype.fromRed=function(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function(ctx){return this.red=ctx,this},BN.prototype.forceRed=function(ctx){return assert(!this.red,"Already a number in reduction context"),this._forceRed(ctx)},BN.prototype.redAdd=function(num){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,num)},BN.prototype.redIAdd=function(num){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,num)},BN.prototype.redSub=function(num){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,num)},BN.prototype.redISub=function(num){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,num)},BN.prototype.redShl=function(num){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,num)},BN.prototype.redMul=function(num){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,num),this.red.mul(this,num)},BN.prototype.redIMul=function(num){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,num),this.red.imul(this,num)},BN.prototype.redSqr=function(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function(num){return assert(this.red&&!num.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,num)};var primes={k256:null,p224:null,p192:null,p25519:null};function MPrime(name,p){this.name=name,this.p=new BN(p,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}MPrime.prototype._tmp=function(){var tmp=new BN(null);return tmp.words=new Array(Math.ceil(this.n/13)),tmp},MPrime.prototype.ireduce=function(num){var rlen,r=num;do{this.split(r,this.tmp),rlen=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(rlen>this.n);var cmp=rlen0?r.isub(this.p):r.strip(),r},MPrime.prototype.split=function(input,out){input.iushrn(this.n,0,out)},MPrime.prototype.imulK=function(num){return num.imul(this.k)};function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}inherits(K256,MPrime),K256.prototype.split=function(input,output){for(var outLen=Math.min(input.length,9),i=0;i>>22,prev=next}prev>>>=22,input.words[i-10]=prev,0===prev&&input.length>10?input.length-=10:input.length-=9},K256.prototype.imulK=function(num){num.words[num.length]=0,num.words[num.length+1]=0,num.length+=2;for(var lo=0,i=0;i>>=26,num.words[i]=lo,carry=hi}return 0!==carry&&(num.words[num.length++]=carry),num},BN._prime=function(name){if(primes[name])return primes[name];var prime;if("k256"===name)prime=new K256;else if("p224"===name)prime=new P224;else if("p192"===name)prime=new P192;else{if("p25519"!==name)throw new Error("Unknown prime "+name);prime=new P25519}return primes[name]=prime,prime};function Red(m){if("string"==typeof m){var prime=BN._prime(m);this.m=prime.p,this.prime=prime}else assert(m.gtn(1),"modulus must be greater than 1"),this.m=m,this.prime=null}Red.prototype._verify1=function(a){assert(0===a.negative,"red works only with positives"),assert(a.red,"red works only with red numbers")},Red.prototype._verify2=function(a,b){assert(0==(a.negative|b.negative),"red works only with positives"),assert(a.red&&a.red===b.red,"red works only with red numbers")},Red.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):a.umod(this.m)._forceRed(this)},Red.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},Red.prototype.add=function(a,b){this._verify2(a,b);var res=a.add(b);return res.cmp(this.m)>=0&&res.isub(this.m),res._forceRed(this)},Red.prototype.iadd=function(a,b){this._verify2(a,b);var res=a.iadd(b);return res.cmp(this.m)>=0&&res.isub(this.m),res},Red.prototype.sub=function(a,b){this._verify2(a,b);var res=a.sub(b);return res.cmpn(0)<0&&res.iadd(this.m),res._forceRed(this)},Red.prototype.isub=function(a,b){this._verify2(a,b);var res=a.isub(b);return res.cmpn(0)<0&&res.iadd(this.m),res},Red.prototype.shl=function(a,num){return this._verify1(a),this.imod(a.ushln(num))},Red.prototype.imul=function(a,b){return this._verify2(a,b),this.imod(a.imul(b))},Red.prototype.mul=function(a,b){return this._verify2(a,b),this.imod(a.mul(b))},Red.prototype.isqr=function(a){return this.imul(a,a.clone())},Red.prototype.sqr=function(a){return this.mul(a,a)},Red.prototype.sqrt=function(a){if(a.isZero())return a.clone();var mod3=this.m.andln(3);if(assert(mod3%2==1),3===mod3){var pow=this.m.add(new BN(1)).iushrn(2);return this.pow(a,pow)}for(var q=this.m.subn(1),s=0;!q.isZero()&&0===q.andln(1);)s++,q.iushrn(1);assert(!q.isZero());var one=new BN(1).toRed(this),nOne=one.redNeg(),lpow=this.m.subn(1).iushrn(1),z=this.m.bitLength();for(z=new BN(2*z*z).toRed(this);0!==this.pow(z,lpow).cmp(nOne);)z.redIAdd(nOne);for(var c=this.pow(z,q),r=this.pow(a,q.addn(1).iushrn(1)),t=this.pow(a,q),m=s;0!==t.cmp(one);){for(var tmp=t,i=0;0!==tmp.cmp(one);i++)tmp=tmp.redSqr();assert(i=0;i--){for(var word=num.words[i],j=start-1;j>=0;j--){var bit=word>>j&1;res!==wnd[0]&&(res=this.sqr(res)),0!==bit||0!==current?(current<<=1,current|=bit,(4===++currentLen||0===i&&0===j)&&(res=this.mul(res,wnd[current]),currentLen=0,current=0)):currentLen=0}start=26}return res},Red.prototype.convertTo=function(num){var r=num.umod(this.m);return r===num?r.clone():r},Red.prototype.convertFrom=function(num){var res=num.clone();return res.red=null,res},BN.mont=function(num){return new Mont(num)};function Mont(m){Red.call(this,m),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new BN(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}inherits(Mont,Red),Mont.prototype.convertTo=function(num){return this.imod(num.ushln(this.shift))},Mont.prototype.convertFrom=function(num){var r=this.imod(num.mul(this.rinv));return r.red=null,r},Mont.prototype.imul=function(a,b){if(a.isZero()||b.isZero())return a.words[0]=0,a.length=1,a;var t=a.imul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.mul=function(a,b){if(a.isZero()||b.isZero())return new BN(0)._forceRed(this);var t=a.mul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.invm=function(a){return this.imod(a._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===module||module,this)},{buffer:21}],17:[function(require,module,exports){(function(global){"use strict"; -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */function compare(a,b){if(a===b)return 0;for(var x=a.length,y=b.length,i=0,len=Math.min(x,y);i=0){var next_line=out.indexOf("\n",idx+1);out=out.substring(next_line+1)}this.stack=out}}},util.inherits(assert.AssertionError,Error);function truncate(s,n){return"string"==typeof s?s.length=0;i--)if(ka[i]!==kb[i])return!1;for(i=ka.length-1;i>=0;i--)if(key=ka[i],!_deepEqual(a[key],b[key],strict,actualVisitedObjects))return!1;return!0}(actual,expected,strict,memos))}return strict?actual===expected:actual==expected}function isArguments(object){return"[object Arguments]"==Object.prototype.toString.call(object)}assert.notDeepEqual=function(actual,expected,message){_deepEqual(actual,expected,!1)&&fail(actual,expected,message,"notDeepEqual",assert.notDeepEqual)},assert.notDeepStrictEqual=function notDeepStrictEqual(actual,expected,message){_deepEqual(actual,expected,!0)&&fail(actual,expected,message,"notDeepStrictEqual",notDeepStrictEqual)};assert.strictEqual=function(actual,expected,message){actual!==expected&&fail(actual,expected,message,"===",assert.strictEqual)},assert.notStrictEqual=function(actual,expected,message){actual===expected&&fail(actual,expected,message,"!==",assert.notStrictEqual)};function expectedException(actual,expected){if(!actual||!expected)return!1;if("[object RegExp]"==Object.prototype.toString.call(expected))return expected.test(actual);try{if(actual instanceof expected)return!0}catch(e){}return!Error.isPrototypeOf(expected)&&!0===expected.call({},actual)}function _throws(shouldThrow,block,expected,message){var actual;if("function"!=typeof block)throw new TypeError('"block" argument must be a function');"string"==typeof expected&&(message=expected,expected=null),actual=function(block){var error;try{block()}catch(e){error=e}return error}(block),message=(expected&&expected.name?" ("+expected.name+").":".")+(message?" "+message:"."),shouldThrow&&!actual&&fail(actual,expected,"Missing expected exception"+message);var userProvidedMessage="string"==typeof message,isUnwantedException=!shouldThrow&&util.isError(actual),isUnexpectedException=!shouldThrow&&actual&&!expected;if((isUnwantedException&&userProvidedMessage&&expectedException(actual,expected)||isUnexpectedException)&&fail(actual,expected,"Got unwanted exception"+message),shouldThrow&&actual&&expected&&!expectedException(actual,expected)||!shouldThrow&&actual)throw actual}assert.throws=function(block,error,message){_throws(!0,block,error,message)},assert.doesNotThrow=function(block,error,message){_throws(!1,block,error,message)},assert.ifError=function(err){if(err)throw err};var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)hasOwn.call(obj,key)&&keys.push(key);return keys}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":206}],18:[function(require,module,exports){"use strict";exports.byteLength=function(b64){return 3*b64.length/4-placeHoldersCount(b64)},exports.toByteArray=function(b64){var i,l,tmp,placeHolders,arr,len=b64.length;placeHolders=placeHoldersCount(b64),arr=new Arr(3*len/4-placeHolders),l=placeHolders>0?len-4:len;var L=0;for(i=0;i>16&255,arr[L++]=tmp>>8&255,arr[L++]=255&tmp;2===placeHolders?(tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4,arr[L++]=255&tmp):1===placeHolders&&(tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2,arr[L++]=tmp>>8&255,arr[L++]=255&tmp);return arr},exports.fromByteArray=function(uint8){for(var tmp,len=uint8.length,extraBytes=len%3,output="",parts=[],i=0,len2=len-extraBytes;ilen2?len2:i+16383));1===extraBytes?(tmp=uint8[len-1],output+=lookup[tmp>>2],output+=lookup[tmp<<4&63],output+="=="):2===extraBytes&&(tmp=(uint8[len-2]<<8)+uint8[len-1],output+=lookup[tmp>>10],output+=lookup[tmp>>4&63],output+=lookup[tmp<<2&63],output+="=");return parts.push(output),parts.join("")};for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===b64[len-2]?2:"="===b64[len-1]?1:0}function encodeChunk(uint8,start,end){for(var tmp,output=[],i=start;i>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[63&num]);var num;return output.join("")}},{}],19:[function(require,module,exports){!function(module,exports){"use strict";function assert(val,msg){if(!val)throw new Error(msg||"Assertion failed")}function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}function BN(number,base,endian){if(null!==number&&"object"==typeof number&&Array.isArray(number.words))return number;this.sign=!1,this.words=null,this.length=0,this.red=null,"le"!==base&&"be"!==base||(endian=base,base=10),null!==number&&this._init(number||0,base||10,endian||"be")}"object"==typeof module?module.exports=BN:exports.BN=BN,BN.BN=BN,BN.wordSize=26,BN.prototype._init=function(number,base,endian){if("number"==typeof number)return number<0&&(this.sign=!0,number=-number),void(number<67108864?(this.words=[67108863&number],this.length=1):number<4503599627370496?(this.words=[67108863&number,number/67108864&67108863],this.length=2):(assert(number<9007199254740992),this.words=[67108863&number,number/67108864&67108863,1],this.length=3));if("object"==typeof number)return this._initArray(number,base,endian);"hex"===base&&(base=16),assert(base===(0|base)&&base>=2&&base<=36);var start=0;"-"===(number=number.toString().replace(/\s+/g,""))[0]&&start++,16===base?this._parseHex(number,start):this._parseBase(number,base,start),"-"===number[0]&&(this.sign=!0),this.strip()},BN.prototype._initArray=function(number,base,endian){if(assert("number"==typeof number.length),number.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(number.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var w=number[i]|number[i-1]<<8|number[i-2]<<16;this.words[j]|=w<>>26-off&67108863,(off+=24)>=26&&(off-=26,j++)}}else if("le"===endian)for(i=0,j=0;i>>26-off&67108863,(off+=24)>=26&&(off-=26,j++)}return this.strip()};function parseHex(str,start,end){for(var r=0,len=Math.min(str.length,end),i=start;i=49&&c<=54?c-49+10:c>=17&&c<=22?c-17+10:15&c}return r}BN.prototype._parseHex=function(number,start){this.length=Math.ceil((number.length-start)/6),this.words=new Array(this.length);for(var i=0;i=start;i-=6){var w=parseHex(number,i,i+6);this.words[j]|=w<>>26-off&4194303,(off+=24)>=26&&(off-=26,j++)}if(i+6!==start){w=parseHex(number,start,i+6);this.words[j]|=w<>>26-off&4194303}this.strip()};function parseBase(str,start,end,mul){for(var r=0,len=Math.min(str.length,end),i=start;i=49?c-49+10:c>=17?c-17+10:c}return r}BN.prototype._parseBase=function(number,base,start){this.words=[0],this.length=1;for(var limbLen=0,limbPow=1;limbPow<=67108863;limbPow*=base)limbLen++;limbLen--,limbPow=limbPow/base|0;for(var total=number.length-start,mod=total%limbLen,end=Math.min(total,total-mod)+start,word=0,i=start;i1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},BN.prototype.inspect=function(){return(this.red?""};var zeros=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],groupSizes=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],groupBases=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];BN.prototype.toString=function(base,padding){if(16===(base=base||10)||"hex"===base){for(var out="",off=0,carry=(padding=0|padding||1,0),i=0;i>>24-off&16777215)||i!==this.length-1?zeros[6-word.length]+word+out:word+out,(off+=2)>=26&&(off-=26,i--)}for(0!==carry&&(out=carry.toString(16)+out);out.length%padding!=0;)out="0"+out;return this.sign&&(out="-"+out),out}if(base===(0|base)&&base>=2&&base<=36){var groupSize=groupSizes[base],groupBase=groupBases[base],c=(out="",this.clone());for(c.sign=!1;0!==c.cmpn(0);){var r=c.modn(groupBase).toString(base);out=0!==(c=c.idivn(groupBase)).cmpn(0)?zeros[groupSize-r.length]+r+out:r+out}return 0===this.cmpn(0)&&(out="0"+out),this.sign&&(out="-"+out),out}assert(!1,"Base should be between 2 and 36")},BN.prototype.toJSON=function(){return this.toString(16)},BN.prototype.toArray=function(){this.strip();var res=new Array(this.byteLength());res[0]=0;for(var q=this.clone(),i=0;0!==q.cmpn(0);i++){var b=q.andln(255);q.ishrn(8),res[res.length-i-1]=b}return res},Math.clz32?BN.prototype._countBits=function(w){return 32-Math.clz32(w)}:BN.prototype._countBits=function(w){var t=w,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},BN.prototype._zeroBits=function(w){if(0===w)return 26;var t=w,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},BN.prototype.bitLength=function(){var hi=0,w=this.words[this.length-1];hi=this._countBits(w);return 26*(this.length-1)+hi},BN.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var r=0,i=0;inum.length?this.clone().ior(num):num.clone().ior(this)},BN.prototype.iand=function(num){this.sign=this.sign&&num.sign;var b;b=this.length>num.length?num:this;for(var i=0;inum.length?this.clone().iand(num):num.clone().iand(this)},BN.prototype.ixor=function(num){this.sign=this.sign||num.sign;var a,b;this.length>num.length?(a=this,b=num):(a=num,b=this);for(var i=0;inum.length?this.clone().ixor(num):num.clone().ixor(this)},BN.prototype.setn=function(bit,val){assert("number"==typeof bit&&bit>=0);for(var off=bit/26|0,wbit=bit%26;this.length<=off;)this.words[this.length++]=0;return this.words[off]=val?this.words[off]|1<num.length?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>>26}for(;0!==carry&&i>>26}if(this.length=a.length,0!==carry)this.words[this.length]=carry,this.length++;else if(a!==this)for(;inum.length?this.clone().iadd(num):num.clone().iadd(this)},BN.prototype.isub=function(num){if(num.sign){num.sign=!1;var r=this.iadd(num);return num.sign=!0,r._normSign()}if(this.sign)return this.sign=!1,this.iadd(num),this.sign=!0,this._normSign();var cmp=this.cmp(num);if(0===cmp)return this.sign=!1,this.length=1,this.words[0]=0,this;var a,b;cmp>0?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>26,this.words[i]=67108863&r}for(;0!==carry&&i>26,this.words[i]=67108863&r}if(0===carry&&i>>26,rword=67108863&carry,maxJ=Math.min(k,num.length-1),j=Math.max(0,k-this.length+1);j<=maxJ;j++){var i=k-j,r=(0|this.words[i])*(0|num.words[j]),lo=67108863&r;rword=67108863&(lo=lo+rword|0),ncarry=(ncarry=ncarry+(r/67108864|0)|0)+(lo>>>26)|0}out.words[k]=rword,carry=ncarry}return 0!==carry?out.words[k]=carry:out.length--,out.strip()},BN.prototype._bigMulTo=function(num,out){out.sign=num.sign!==this.sign,out.length=this.length+num.length;for(var carry=0,hncarry=0,k=0;k>>26)|0)>>>26,ncarry&=67108863}out.words[k]=rword,carry=ncarry,ncarry=hncarry}return 0!==carry?out.words[k]=carry:out.length--,out.strip()},BN.prototype.mulTo=function(num,out){return this.length+num.length<63?this._smallMulTo(num,out):this._bigMulTo(num,out)},BN.prototype.mul=function(num){var out=new BN(null);return out.words=new Array(this.length+num.length),this.mulTo(num,out)},BN.prototype.imul=function(num){if(0===this.cmpn(0)||0===num.cmpn(0))return this.words[0]=0,this.length=1,this;var tlen=this.length,nlen=num.length;this.sign=num.sign!==this.sign,this.length=this.length+num.length,this.words[this.length-1]=0;for(var k=this.length-2;k>=0;k--){for(var carry=0,rword=0,maxJ=Math.min(k,nlen-1),j=Math.max(0,k-tlen+1);j<=maxJ;j++){var i=k-j,r=this.words[i]*num.words[j],lo=67108863&r;carry+=r/67108864|0,rword=67108863&(lo+=rword),carry+=lo>>>26}this.words[k]=rword,this.words[k+1]+=carry,carry=0}for(carry=0,i=1;i>>26}return this.strip()},BN.prototype.imuln=function(num){assert("number"==typeof num);for(var carry=0,i=0;i>=26,carry+=w/67108864|0,carry+=lo>>>26,this.words[i]=67108863&lo}return 0!==carry&&(this.words[i]=carry,this.length++),this},BN.prototype.sqr=function(){return this.mul(this)},BN.prototype.isqr=function(){return this.mul(this)},BN.prototype.ishln=function(bits){assert("number"==typeof bits&&bits>=0);var r=bits%26,s=(bits-r)/26,carryMask=67108863>>>26-r<<26-r;if(0!==r){for(var carry=0,i=0;i>>26-r}carry&&(this.words[i]=carry,this.length++)}if(0!==s){for(i=this.length-1;i>=0;i--)this.words[i+s]=this.words[i];for(i=0;i=0);var h;h=hint?(hint-hint%26)/26:0;var r=bits%26,s=Math.min((bits-r)/26,this.length),mask=67108863^67108863>>>r<s){this.length-=s;for(i=0;i=0&&(0!==carry||i>=h);i--){var word=this.words[i];this.words[i]=carry<<26-r|word>>>r,carry=word&mask}return maskedWords&&0!==carry&&(maskedWords.words[maskedWords.length++]=carry),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},BN.prototype.shln=function(bits){return this.clone().ishln(bits)},BN.prototype.shrn=function(bits){return this.clone().ishrn(bits)},BN.prototype.testn=function(bit){assert("number"==typeof bit&&bit>=0);var r=bit%26,s=(bit-r)/26,q=1<=0);var r=bits%26,s=(bits-r)/26;if(assert(!this.sign,"imaskn works only with positive numbers"),0!==r&&s++,this.length=Math.min(s,this.length),0!==r){var mask=67108863^67108863>>>r<=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},BN.prototype.isubn=function(num){if(assert("number"==typeof num),num<0)return this.iaddn(-num);if(this.sign)return this.sign=!1,this.iaddn(num),this.sign=!0,this;this.words[0]-=num;for(var i=0;i>26)-(right/67108864|0),this.words[i+shift]=67108863&w}for(;i>26,this.words[i+shift]=67108863&w}if(0===carry)return this.strip();assert(-1===carry),carry=0;for(i=0;i>26,this.words[i]=67108863&w}return this.sign=!0,this.strip()},BN.prototype._wordDiv=function(num,mode){var shift=this.length-num.length,a=this.clone(),b=num,bhi=b.words[b.length-1];0!==(shift=26-this._countBits(bhi))&&(b=b.shln(shift),a.ishln(shift),bhi=b.words[b.length-1]);var q,m=a.length-b.length;if("mod"!==mode){(q=new BN(null)).length=m+1,q.words=new Array(q.length);for(var i=0;i=0;j--){var qj=67108864*a.words[b.length+j]+a.words[b.length+j-1];for(qj=Math.min(qj/bhi|0,67108863),a._ishlnsubmul(b,qj,j);a.sign;)qj--,a.sign=!1,a._ishlnsubmul(b,1,j),0!==a.cmpn(0)&&(a.sign=!a.sign);q&&(q.words[j]=qj)}return q&&q.strip(),a.strip(),"div"!==mode&&0!==shift&&a.ishrn(shift),{div:q||null,mod:a}},BN.prototype.divmod=function(num,mode){if(assert(0!==num.cmpn(0)),this.sign&&!num.sign){var mod,res=this.neg().divmod(num,mode);return"mod"!==mode&&(div=res.div.neg()),"div"!==mode&&(mod=0===res.mod.cmpn(0)?res.mod:num.sub(res.mod)),{div:div,mod:mod}}if(!this.sign&&num.sign){var div;res=this.divmod(num.neg(),mode);return"mod"!==mode&&(div=res.div.neg()),{div:div,mod:res.mod}}return this.sign&&num.sign?this.neg().divmod(num.neg(),mode):num.length>this.length||this.cmp(num)<0?{div:new BN(0),mod:this}:1===num.length?"div"===mode?{div:this.divn(num.words[0]),mod:null}:"mod"===mode?{div:null,mod:new BN(this.modn(num.words[0]))}:{div:this.divn(num.words[0]),mod:new BN(this.modn(num.words[0]))}:this._wordDiv(num,mode)},BN.prototype.div=function(num){return this.divmod(num,"div").div},BN.prototype.mod=function(num){return this.divmod(num,"mod").mod},BN.prototype.divRound=function(num){var dm=this.divmod(num);if(0===dm.mod.cmpn(0))return dm.div;var mod=dm.div.sign?dm.mod.isub(num):dm.mod,half=num.shrn(1),r2=num.andln(1),cmp=mod.cmp(half);return cmp<0||1===r2&&0===cmp?dm.div:dm.div.sign?dm.div.isubn(1):dm.div.iaddn(1)},BN.prototype.modn=function(num){assert(num<=67108863);for(var p=(1<<26)%num,acc=0,i=this.length-1;i>=0;i--)acc=(p*acc+this.words[i])%num;return acc},BN.prototype.idivn=function(num){assert(num<=67108863);for(var carry=0,i=this.length-1;i>=0;i--){var w=this.words[i]+67108864*carry;this.words[i]=w/num|0,carry=w%num}return this.strip()},BN.prototype.divn=function(num){return this.clone().idivn(num)},BN.prototype.egcd=function(p){assert(!p.sign),assert(0!==p.cmpn(0));var x=this,y=p.clone();x=x.sign?x.mod(p):x.clone();for(var A=new BN(1),B=new BN(0),C=new BN(0),D=new BN(1),g=0;x.isEven()&&y.isEven();)x.ishrn(1),y.ishrn(1),++g;for(var yp=y.clone(),xp=x.clone();0!==x.cmpn(0);){for(;x.isEven();)x.ishrn(1),A.isEven()&&B.isEven()?(A.ishrn(1),B.ishrn(1)):(A.iadd(yp).ishrn(1),B.isub(xp).ishrn(1));for(;y.isEven();)y.ishrn(1),C.isEven()&&D.isEven()?(C.ishrn(1),D.ishrn(1)):(C.iadd(yp).ishrn(1),D.isub(xp).ishrn(1));x.cmp(y)>=0?(x.isub(y),A.isub(C),B.isub(D)):(y.isub(x),C.isub(A),D.isub(B))}return{a:C,b:D,gcd:y.ishln(g)}},BN.prototype._invmp=function(p){assert(!p.sign),assert(0!==p.cmpn(0));var a=this,b=p.clone();a=a.sign?a.mod(p):a.clone();for(var x1=new BN(1),x2=new BN(0),delta=b.clone();a.cmpn(1)>0&&b.cmpn(1)>0;){for(;a.isEven();)a.ishrn(1),x1.isEven()?x1.ishrn(1):x1.iadd(delta).ishrn(1);for(;b.isEven();)b.ishrn(1),x2.isEven()?x2.ishrn(1):x2.iadd(delta).ishrn(1);a.cmp(b)>=0?(a.isub(b),x1.isub(x2)):(b.isub(a),x2.isub(x1))}return 0===a.cmpn(1)?x1:x2},BN.prototype.gcd=function(num){if(0===this.cmpn(0))return num.clone();if(0===num.cmpn(0))return this.clone();var a=this.clone(),b=num.clone();a.sign=!1,b.sign=!1;for(var shift=0;a.isEven()&&b.isEven();shift++)a.ishrn(1),b.ishrn(1);for(;;){for(;a.isEven();)a.ishrn(1);for(;b.isEven();)b.ishrn(1);var r=a.cmp(b);if(r<0){var t=a;a=b,b=t}else if(0===r||0===b.cmpn(1))break;a.isub(b)}return b.ishln(shift)},BN.prototype.invm=function(num){return this.egcd(num).a.mod(num)},BN.prototype.isEven=function(){return 0==(1&this.words[0])},BN.prototype.isOdd=function(){return 1==(1&this.words[0])},BN.prototype.andln=function(num){return this.words[0]&num},BN.prototype.bincn=function(bit){assert("number"==typeof bit);var r=bit%26,s=(bit-r)/26,q=1<>>26,w&=67108863,this.words[i]=w}return 0!==carry&&(this.words[i]=carry,this.length++),this},BN.prototype.cmpn=function(num){var sign=num<0;if(sign&&(num=-num),this.sign&&!sign)return-1;if(!this.sign&&sign)return 1;num&=67108863,this.strip();var res;if(this.length>1)res=1;else{var w=this.words[0];res=w===num?0:wnum.length)return 1;if(this.length=0;i--){var a=this.words[i],b=num.words[i];if(a!==b){ab&&(res=1);break}}return res},BN.red=function(num){return new Red(num)},BN.prototype.toRed=function(ctx){return assert(!this.red,"Already a number in reduction context"),assert(!this.sign,"red works only with positives"),ctx.convertTo(this)._forceRed(ctx)},BN.prototype.fromRed=function(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function(ctx){return this.red=ctx,this},BN.prototype.forceRed=function(ctx){return assert(!this.red,"Already a number in reduction context"),this._forceRed(ctx)},BN.prototype.redAdd=function(num){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,num)},BN.prototype.redIAdd=function(num){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,num)},BN.prototype.redSub=function(num){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,num)},BN.prototype.redISub=function(num){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,num)},BN.prototype.redShl=function(num){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,num)},BN.prototype.redMul=function(num){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,num),this.red.mul(this,num)},BN.prototype.redIMul=function(num){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,num),this.red.imul(this,num)},BN.prototype.redSqr=function(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function(num){return assert(this.red&&!num.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,num)};var primes={k256:null,p224:null,p192:null,p25519:null};function MPrime(name,p){this.name=name,this.p=new BN(p,16),this.n=this.p.bitLength(),this.k=new BN(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}MPrime.prototype._tmp=function(){var tmp=new BN(null);return tmp.words=new Array(Math.ceil(this.n/13)),tmp},MPrime.prototype.ireduce=function(num){var rlen,r=num;do{this.split(r,this.tmp),rlen=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(rlen>this.n);var cmp=rlen0?r.isub(this.p):r.strip(),r},MPrime.prototype.split=function(input,out){input.ishrn(this.n,0,out)},MPrime.prototype.imulK=function(num){return num.imul(this.k)};function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}inherits(K256,MPrime),K256.prototype.split=function(input,output){for(var outLen=Math.min(input.length,9),i=0;i>>22,prev=next}input.words[i-10]=prev>>>22,input.length-=9},K256.prototype.imulK=function(num){num.words[num.length]=0,num.words[num.length+1]=0,num.length+=2;for(var hi,lo=0,i=0;i>>=26,num.words[i]=lo,carry=hi}return 0!==carry&&(num.words[num.length++]=carry),num},BN._prime=function(name){if(primes[name])return primes[name];var prime;if("k256"===name)prime=new K256;else if("p224"===name)prime=new P224;else if("p192"===name)prime=new P192;else{if("p25519"!==name)throw new Error("Unknown prime "+name);prime=new P25519}return primes[name]=prime,prime};function Red(m){if("string"==typeof m){var prime=BN._prime(m);this.m=prime.p,this.prime=prime}else this.m=m,this.prime=null}Red.prototype._verify1=function(a){assert(!a.sign,"red works only with positives"),assert(a.red,"red works only with red numbers")},Red.prototype._verify2=function(a,b){assert(!a.sign&&!b.sign,"red works only with positives"),assert(a.red&&a.red===b.red,"red works only with red numbers")},Red.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):a.mod(this.m)._forceRed(this)},Red.prototype.neg=function(a){var r=a.clone();return r.sign=!r.sign,r.iadd(this.m)._forceRed(this)},Red.prototype.add=function(a,b){this._verify2(a,b);var res=a.add(b);return res.cmp(this.m)>=0&&res.isub(this.m),res._forceRed(this)},Red.prototype.iadd=function(a,b){this._verify2(a,b);var res=a.iadd(b);return res.cmp(this.m)>=0&&res.isub(this.m),res},Red.prototype.sub=function(a,b){this._verify2(a,b);var res=a.sub(b);return res.cmpn(0)<0&&res.iadd(this.m),res._forceRed(this)},Red.prototype.isub=function(a,b){this._verify2(a,b);var res=a.isub(b);return res.cmpn(0)<0&&res.iadd(this.m),res},Red.prototype.shl=function(a,num){return this._verify1(a),this.imod(a.shln(num))},Red.prototype.imul=function(a,b){return this._verify2(a,b),this.imod(a.imul(b))},Red.prototype.mul=function(a,b){return this._verify2(a,b),this.imod(a.mul(b))},Red.prototype.isqr=function(a){return this.imul(a,a)},Red.prototype.sqr=function(a){return this.mul(a,a)},Red.prototype.sqrt=function(a){if(0===a.cmpn(0))return a.clone();var mod3=this.m.andln(3);if(assert(mod3%2==1),3===mod3){var pow=this.m.add(new BN(1)).ishrn(2);return r=this.pow(a,pow)}for(var q=this.m.subn(1),s=0;0!==q.cmpn(0)&&0===q.andln(1);)s++,q.ishrn(1);assert(0!==q.cmpn(0));var one=new BN(1).toRed(this),nOne=one.redNeg(),lpow=this.m.subn(1).ishrn(1),z=this.m.bitLength();for(z=new BN(2*z*z).toRed(this);0!==this.pow(z,lpow).cmp(nOne);)z.redIAdd(nOne);for(var c=this.pow(z,q),r=this.pow(a,q.addn(1).ishrn(1)),t=this.pow(a,q),m=s;0!==t.cmp(one);){for(var tmp=t,i=0;0!==tmp.cmp(one);i++)tmp=tmp.redSqr();assert(i=0?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.mul=function(a,b){if(0===a.cmpn(0)||0===b.cmpn(0))return new BN(0)._forceRed(this);var t=a.mul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).ishrn(this.shift),res=u;return u.cmp(this.m)>=0?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.invm=function(a){return this.imod(a._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===module||module,this)},{}],20:[function(require,module,exports){var r;module.exports=function(len){return r||(r=new Rand(null)),r.generate(len)};function Rand(rand){this.rand=rand}if(module.exports.Rand=Rand,Rand.prototype.generate=function(len){return this._rand(len)},Rand.prototype._rand=function(n){if(this.rand.getBytes)return this.rand.getBytes(n);for(var res=new Uint8Array(n),i=0;i>>24]^SUB_MIX1[s1>>>16&255]^SUB_MIX2[s2>>>8&255]^SUB_MIX3[255&s3]^keySchedule[ksRow++],t1=SUB_MIX0[s1>>>24]^SUB_MIX1[s2>>>16&255]^SUB_MIX2[s3>>>8&255]^SUB_MIX3[255&s0]^keySchedule[ksRow++],t2=SUB_MIX0[s2>>>24]^SUB_MIX1[s3>>>16&255]^SUB_MIX2[s0>>>8&255]^SUB_MIX3[255&s1]^keySchedule[ksRow++],t3=SUB_MIX0[s3>>>24]^SUB_MIX1[s0>>>16&255]^SUB_MIX2[s1>>>8&255]^SUB_MIX3[255&s2]^keySchedule[ksRow++],s0=t0,s1=t1,s2=t2,s3=t3;return t0=(SBOX[s0>>>24]<<24|SBOX[s1>>>16&255]<<16|SBOX[s2>>>8&255]<<8|SBOX[255&s3])^keySchedule[ksRow++],t1=(SBOX[s1>>>24]<<24|SBOX[s2>>>16&255]<<16|SBOX[s3>>>8&255]<<8|SBOX[255&s0])^keySchedule[ksRow++],t2=(SBOX[s2>>>24]<<24|SBOX[s3>>>16&255]<<16|SBOX[s0>>>8&255]<<8|SBOX[255&s1])^keySchedule[ksRow++],t3=(SBOX[s3>>>24]<<24|SBOX[s0>>>16&255]<<16|SBOX[s1>>>8&255]<<8|SBOX[255&s2])^keySchedule[ksRow++],[t0>>>=0,t1>>>=0,t2>>>=0,t3>>>=0]}var RCON=[0,1,2,4,8,16,32,64,128,27,54],G=function(){for(var d=new Array(256),j=0;j<256;j++)d[j]=j<128?j<<1:j<<1^283;for(var SBOX=[],INV_SBOX=[],SUB_MIX=[[],[],[],[]],INV_SUB_MIX=[[],[],[],[]],x=0,xi=0,i=0;i<256;++i){var sx=xi^xi<<1^xi<<2^xi<<3^xi<<4;sx=sx>>>8^255&sx^99,SBOX[x]=sx,INV_SBOX[sx]=x;var x2=d[x],x4=d[x2],x8=d[x4],t=257*d[sx]^16843008*sx;SUB_MIX[0][x]=t<<24|t>>>8,SUB_MIX[1][x]=t<<16|t>>>16,SUB_MIX[2][x]=t<<8|t>>>24,SUB_MIX[3][x]=t,t=16843009*x8^65537*x4^257*x2^16843008*x,INV_SUB_MIX[0][sx]=t<<24|t>>>8,INV_SUB_MIX[1][sx]=t<<16|t>>>16,INV_SUB_MIX[2][sx]=t<<8|t>>>24,INV_SUB_MIX[3][sx]=t,0===x?x=xi=1:(x=x2^d[d[d[x8^x2]]],xi^=d[d[xi]])}return{SBOX:SBOX,INV_SBOX:INV_SBOX,SUB_MIX:SUB_MIX,INV_SUB_MIX:INV_SUB_MIX}}();function AES(key){this._key=asUInt32Array(key),this._reset()}AES.blockSize=16,AES.keySize=32,AES.prototype.blockSize=AES.blockSize,AES.prototype.keySize=AES.keySize,AES.prototype._reset=function(){for(var keyWords=this._key,keySize=keyWords.length,nRounds=keySize+6,ksRows=4*(nRounds+1),keySchedule=[],k=0;k>>24,t=G.SBOX[t>>>24]<<24|G.SBOX[t>>>16&255]<<16|G.SBOX[t>>>8&255]<<8|G.SBOX[255&t],t^=RCON[k/keySize|0]<<24):keySize>6&&k%keySize==4&&(t=G.SBOX[t>>>24]<<24|G.SBOX[t>>>16&255]<<16|G.SBOX[t>>>8&255]<<8|G.SBOX[255&t]),keySchedule[k]=keySchedule[k-keySize]^t}for(var invKeySchedule=[],ik=0;ik>>24]]^G.INV_SUB_MIX[1][G.SBOX[tt>>>16&255]]^G.INV_SUB_MIX[2][G.SBOX[tt>>>8&255]]^G.INV_SUB_MIX[3][G.SBOX[255&tt]]}this._nRounds=nRounds,this._keySchedule=keySchedule,this._invKeySchedule=invKeySchedule},AES.prototype.encryptBlockRaw=function(M){return cryptBlock(M=asUInt32Array(M),this._keySchedule,G.SUB_MIX,G.SBOX,this._nRounds)},AES.prototype.encryptBlock=function(M){var out=this.encryptBlockRaw(M),buf=Buffer.allocUnsafe(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[1],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[3],12),buf},AES.prototype.decryptBlock=function(M){var m1=(M=asUInt32Array(M))[1];M[1]=M[3],M[3]=m1;var out=cryptBlock(M,this._invKeySchedule,G.INV_SUB_MIX,G.INV_SBOX,this._nRounds),buf=Buffer.allocUnsafe(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[3],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[1],12),buf},AES.prototype.scrub=function(){scrubVec(this._keySchedule),scrubVec(this._invKeySchedule),scrubVec(this._key)},module.exports.AES=AES},{"safe-buffer":191}],23:[function(require,module,exports){var aes=require("./aes"),Buffer=require("safe-buffer").Buffer,Transform=require("cipher-base"),inherits=require("inherits"),GHASH=require("./ghash"),xor=require("buffer-xor"),incr32=require("./incr32");function StreamCipher(mode,key,iv,decrypt){Transform.call(this);var h=Buffer.alloc(4,0);this._cipher=new aes.AES(key);var ck=this._cipher.encryptBlock(h);this._ghash=new GHASH(ck),iv=function(self,iv,ck){if(12===iv.length)return self._finID=Buffer.concat([iv,Buffer.from([0,0,0,1])]),Buffer.concat([iv,Buffer.from([0,0,0,2])]);var ghash=new GHASH(ck),len=iv.length,toPad=len%16;ghash.update(iv),toPad&&(toPad=16-toPad,ghash.update(Buffer.alloc(toPad,0))),ghash.update(Buffer.alloc(8,0));var ivBits=8*len,tail=Buffer.alloc(8);tail.writeUIntBE(ivBits,0,8),ghash.update(tail),self._finID=ghash.state;var out=Buffer.from(self._finID);return incr32(out),out}(this,iv,ck),this._prev=Buffer.from(iv),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=decrypt,this._alen=0,this._len=0,this._mode=mode,this._authTag=null,this._called=!1}inherits(StreamCipher,Transform),StreamCipher.prototype._update=function(chunk){if(!this._called&&this._alen){var rump=16-this._alen%16;rump<16&&(rump=Buffer.alloc(rump,0),this._ghash.update(rump))}this._called=!0;var out=this._mode.encrypt(this,chunk);return this._decrypt?this._ghash.update(chunk):this._ghash.update(out),this._len+=chunk.length,out},StreamCipher.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var tag=xor(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(a,b){var out=0;a.length!==b.length&&out++;for(var len=Math.min(a.length,b.length),i=0;i16)return out=this.cache.slice(0,16),this.cache=this.cache.slice(16),out}else if(this.cache.length>=16)return out=this.cache.slice(0,16),this.cache=this.cache.slice(16),out;return null},Splitter.prototype.flush=function(){if(this.cache.length)return this.cache};function createDecipheriv(suite,password,iv){var config=MODES[suite.toLowerCase()];if(!config)throw new TypeError("invalid suite type");if("string"==typeof iv&&(iv=Buffer.from(iv)),"GCM"!==config.mode&&iv.length!==config.iv)throw new TypeError("invalid iv length "+iv.length);if("string"==typeof password&&(password=Buffer.from(password)),password.length!==config.key/8)throw new TypeError("invalid key length "+password.length);return"stream"===config.type?new StreamCipher(config.module,password,iv,!0):"auth"===config.type?new AuthCipher(config.module,password,iv,!0):new Decipher(config.module,password,iv)}exports.createDecipher=function(suite,password){var config=MODES[suite.toLowerCase()];if(!config)throw new TypeError("invalid suite type");var keys=ebtk(password,!1,config.key,config.iv);return createDecipheriv(suite,keys.key,keys.iv)},exports.createDecipheriv=createDecipheriv},{"./aes":22,"./authCipher":23,"./modes":35,"./streamCipher":38,"cipher-base":71,evp_bytestokey:123,inherits:141,"safe-buffer":191}],26:[function(require,module,exports){var MODES=require("./modes"),AuthCipher=require("./authCipher"),Buffer=require("safe-buffer").Buffer,StreamCipher=require("./streamCipher"),Transform=require("cipher-base"),aes=require("./aes"),ebtk=require("evp_bytestokey");function Cipher(mode,key,iv){Transform.call(this),this._cache=new Splitter,this._cipher=new aes.AES(key),this._prev=Buffer.from(iv),this._mode=mode,this._autopadding=!0}require("inherits")(Cipher,Transform),Cipher.prototype._update=function(data){this._cache.add(data);for(var chunk,thing,out=[];chunk=this._cache.get();)thing=this._mode.encrypt(this,chunk),out.push(thing);return Buffer.concat(out)};var PADDING=Buffer.alloc(16,16);Cipher.prototype._final=function(){var chunk=this._cache.flush();if(this._autopadding)return chunk=this._mode.encrypt(this,chunk),this._cipher.scrub(),chunk;if(!chunk.equals(PADDING))throw this._cipher.scrub(),new Error("data not multiple of block length")},Cipher.prototype.setAutoPadding=function(setTo){return this._autopadding=!!setTo,this};function Splitter(){this.cache=Buffer.allocUnsafe(0)}Splitter.prototype.add=function(data){this.cache=Buffer.concat([this.cache,data])},Splitter.prototype.get=function(){if(this.cache.length>15){var out=this.cache.slice(0,16);return this.cache=this.cache.slice(16),out}return null},Splitter.prototype.flush=function(){for(var len=16-this.cache.length,padBuff=Buffer.allocUnsafe(len),i=-1;++i>>0,0),buf.writeUInt32BE(out[1]>>>0,4),buf.writeUInt32BE(out[2]>>>0,8),buf.writeUInt32BE(out[3]>>>0,12),buf}function GHASH(key){this.h=key,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}GHASH.prototype.ghash=function(block){for(var i=-1;++i0;j--)Vi[j]=Vi[j]>>>1|(1&Vi[j-1])<<31;Vi[0]=Vi[0]>>>1,lsbVi&&(Vi[0]=Vi[0]^225<<24)}this.state=fromArray(Zi)},GHASH.prototype.update=function(buf){this.cache=Buffer.concat([this.cache,buf]);for(var chunk;this.cache.length>=16;)chunk=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(chunk)},GHASH.prototype.final=function(abl,bl){return this.cache.length&&this.ghash(Buffer.concat([this.cache,ZEROES],16)),this.ghash(fromArray([0,abl,0,bl])),this.state},module.exports=GHASH},{"safe-buffer":191}],28:[function(require,module,exports){module.exports=function(iv){for(var item,len=iv.length;len--;){if(255!==(item=iv.readUInt8(len))){item++,iv.writeUInt8(item,len);break}iv.writeUInt8(0,len)}}},{}],29:[function(require,module,exports){var xor=require("buffer-xor");exports.encrypt=function(self,block){var data=xor(block,self._prev);return self._prev=self._cipher.encryptBlock(data),self._prev},exports.decrypt=function(self,block){var pad=self._prev;self._prev=block;var out=self._cipher.decryptBlock(block);return xor(out,pad)}},{"buffer-xor":69}],30:[function(require,module,exports){var Buffer=require("safe-buffer").Buffer,xor=require("buffer-xor");function encryptStart(self,data,decrypt){var len=data.length,out=xor(data,self._cache);return self._cache=self._cache.slice(len),self._prev=Buffer.concat([self._prev,decrypt?data:out]),out}exports.encrypt=function(self,data,decrypt){for(var len,out=Buffer.allocUnsafe(0);data.length;){if(0===self._cache.length&&(self._cache=self._cipher.encryptBlock(self._prev),self._prev=Buffer.allocUnsafe(0)),!(self._cache.length<=data.length)){out=Buffer.concat([out,encryptStart(self,data,decrypt)]);break}len=self._cache.length,out=Buffer.concat([out,encryptStart(self,data.slice(0,len),decrypt)]),data=data.slice(len)}return out}},{"buffer-xor":69,"safe-buffer":191}],31:[function(require,module,exports){var Buffer=require("safe-buffer").Buffer;function encryptByte(self,byteParam,decrypt){for(var pad,bit,value,i=-1,out=0;++i<8;)pad=self._cipher.encryptBlock(self._prev),bit=byteParam&1<<7-i?128:0,out+=(128&(value=pad[0]^bit))>>i%8,self._prev=shiftIn(self._prev,decrypt?bit:value);return out}function shiftIn(buffer,value){var len=buffer.length,i=-1,out=Buffer.allocUnsafe(buffer.length);for(buffer=Buffer.concat([buffer,Buffer.from([value])]);++i>7;return out}exports.encrypt=function(self,chunk,decrypt){for(var len=chunk.length,out=Buffer.allocUnsafe(len),i=-1;++i=0||!r.umod(priv.prime1)||!r.umod(priv.prime2);)r=new bn(randomBytes(len));return r}}).call(this,require("buffer").Buffer)},{"bn.js":43,buffer:70,randombytes:174}],43:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{buffer:21,dup:16}],44:[function(require,module,exports){module.exports=require("./browser/algorithms.json")},{"./browser/algorithms.json":45}],45:[function(require,module,exports){module.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],46:[function(require,module,exports){module.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],47:[function(require,module,exports){(function(Buffer){var createHash=require("create-hash"),stream=require("stream"),inherits=require("inherits"),sign=require("./sign"),verify=require("./verify"),algorithms=require("./algorithms.json");Object.keys(algorithms).forEach(function(key){algorithms[key].id=new Buffer(algorithms[key].id,"hex"),algorithms[key.toLowerCase()]=algorithms[key]});function Sign(algorithm){stream.Writable.call(this);var data=algorithms[algorithm];if(!data)throw new Error("Unknown message digest");this._hashType=data.hash,this._hash=createHash(data.hash),this._tag=data.id,this._signType=data.sign}inherits(Sign,stream.Writable),Sign.prototype._write=function(data,_,done){this._hash.update(data),done()},Sign.prototype.update=function(data,enc){return"string"==typeof data&&(data=new Buffer(data,enc)),this._hash.update(data),this},Sign.prototype.sign=function(key,enc){this.end();var hash=this._hash.digest(),sig=sign(hash,key,this._hashType,this._signType,this._tag);return enc?sig.toString(enc):sig};function Verify(algorithm){stream.Writable.call(this);var data=algorithms[algorithm];if(!data)throw new Error("Unknown message digest");this._hash=createHash(data.hash),this._tag=data.id,this._signType=data.sign}inherits(Verify,stream.Writable),Verify.prototype._write=function(data,_,done){this._hash.update(data),done()},Verify.prototype.update=function(data,enc){return"string"==typeof data&&(data=new Buffer(data,enc)),this._hash.update(data),this},Verify.prototype.verify=function(key,sig,enc){"string"==typeof sig&&(sig=new Buffer(sig,enc)),this.end();var hash=this._hash.digest();return verify(sig,hash,key,this._signType,this._tag)};function createSign(algorithm){return new Sign(algorithm)}function createVerify(algorithm){return new Verify(algorithm)}module.exports={Sign:createSign,Verify:createVerify,createSign:createSign,createVerify:createVerify}}).call(this,require("buffer").Buffer)},{"./algorithms.json":45,"./sign":48,"./verify":49,buffer:70,"create-hash":91,inherits:141,stream:200}],48:[function(require,module,exports){(function(Buffer){var createHmac=require("create-hmac"),crt=require("browserify-rsa"),EC=require("elliptic").ec,BN=require("bn.js"),parseKeys=require("parse-asn1"),curves=require("./curves.json");function getKey(x,q,hash,algo){if((x=new Buffer(x.toArray())).length0&&bits.ishrn(shift),bits}function makeKey(q,kv,algo){var t,k;do{for(t=new Buffer(0);8*t.length=q)throw new Error("invalid sig")}module.exports=function(sig,hash,key,signType,tag){var pub=parseKeys(key);if("ec"===pub.type){if("ecdsa"!==signType&&"ecdsa/rsa"!==signType)throw new Error("wrong public key type");return function(sig,hash,pub){var curveId=curves[pub.data.algorithm.curve.join(".")];if(!curveId)throw new Error("unknown curve "+pub.data.algorithm.curve.join("."));var curve=new EC(curveId),pubkey=pub.data.subjectPrivateKey.data;return curve.verify(hash,sig,pubkey)}(sig,hash,pub)}if("dsa"===pub.type){if("dsa"!==signType)throw new Error("wrong public key type");return function(sig,hash,pub){var p=pub.data.p,q=pub.data.q,g=pub.data.g,y=pub.data.pub_key,unpacked=parseKeys.signature.decode(sig,"der"),s=unpacked.s,r=unpacked.r;checkValue(s,q),checkValue(r,q);var montp=BN.mont(p),w=s.invm(q);return 0===g.toRed(montp).redPow(new BN(hash).mul(w).mod(q)).fromRed().mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()).mod(p).mod(q).cmp(r)}(sig,hash,pub)}if("rsa"!==signType&&"ecdsa/rsa"!==signType)throw new Error("wrong public key type");hash=Buffer.concat([tag,hash]);for(var len=pub.modulus.byteLength(),pad=[1],padNum=0;hash.length+pad.length+20?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}module.exports=BaseCurve,BaseCurve.prototype.point=function(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function(p,k){assert(p.precomputed);var doubles=p._getDoubles(),naf=getNAF(k,1),I=(1<=j;k--)nafW=(nafW<<1)+naf[k];repr.push(nafW)}for(var a=this.jpoint(null,null,null),b=this.jpoint(null,null,null),i=I;i>0;i--){for(j=0;j=0;i--){for(k=0;i>=0&&0===naf[i];i--)k++;if(i>=0&&k++,acc=acc.dblp(k),i<0)break;var z=naf[i];assert(0!==z),acc="affine"===p.type?z>0?acc.mixedAdd(wnd[z-1>>1]):acc.mixedAdd(wnd[-z-1>>1].neg()):z>0?acc.add(wnd[z-1>>1]):acc.add(wnd[-z-1>>1].neg())}return"affine"===p.type?acc.toP():acc},BaseCurve.prototype._wnafMulAdd=function(defW,points,coeffs,len,jacobianResult){for(var wndWidth=this._wnafT1,wnd=this._wnafT2,naf=this._wnafT3,max=0,i=0;i=1;i-=2){var a=i-1,b=i;if(1===wndWidth[a]&&1===wndWidth[b]){var comb=[points[a],null,null,points[b]];0===points[a].y.cmp(points[b].y)?(comb[1]=points[a].add(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg())):0===points[a].y.cmp(points[b].y.redNeg())?(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].add(points[b].neg())):(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg()));var index=[-3,-1,-5,-7,0,7,5,1,3],jsf=getJSF(coeffs[a],coeffs[b]);max=Math.max(jsf[0].length,max),naf[a]=new Array(max),naf[b]=new Array(max);for(var j=0;j=0;i--){for(var k=0;i>=0;){var zero=!0;for(j=0;j=0&&k++,acc=acc.dblp(k),i<0)break;for(j=0;j0?p=wnd[j][z-1>>1]:z<0&&(p=wnd[j][-z-1>>1].neg()),acc="affine"===p.type?acc.mixedAdd(p):acc.add(p))}}for(i=0;i=Math.ceil((k.bitLength()+1)/doubles.step)},BasePoint.prototype._getDoubles=function(step,power){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var doubles=[this],acc=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},Point.prototype._extDbl=function(){var a=this.x.redSqr(),b=this.y.redSqr(),c=this.z.redSqr();c=c.redIAdd(c);var d=this.curve._mulA(a),e=this.x.redAdd(this.y).redSqr().redISub(a).redISub(b),g=d.redAdd(b),f=g.redSub(c),h=d.redSub(b),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projDbl=function(){var nx,ny,nz,b=this.x.redAdd(this.y).redSqr(),c=this.x.redSqr(),d=this.y.redSqr();if(this.curve.twisted){var f=(e=this.curve._mulA(c)).redAdd(d);if(this.zOne)nx=b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)),ny=f.redMul(e.redSub(d)),nz=f.redSqr().redSub(f).redSub(f);else{var h=this.z.redSqr(),j=f.redSub(h).redISub(h);nx=b.redSub(c).redISub(d).redMul(j),ny=f.redMul(e.redSub(d)),nz=f.redMul(j)}}else{var e=c.redAdd(d);h=this.curve._mulC(this.c.redMul(this.z)).redSqr(),j=e.redSub(h).redSub(h);nx=this.curve._mulC(b.redISub(e)).redMul(j),ny=this.curve._mulC(e).redMul(c.redISub(d)),nz=e.redMul(j)}return this.curve.point(nx,ny,nz)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(p){var a=this.y.redSub(this.x).redMul(p.y.redSub(p.x)),b=this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)),c=this.t.redMul(this.curve.dd).redMul(p.t),d=this.z.redMul(p.z.redAdd(p.z)),e=b.redSub(a),f=d.redSub(c),g=d.redAdd(c),h=b.redAdd(a),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projAdd=function(p){var ny,nz,a=this.z.redMul(p.z),b=a.redSqr(),c=this.x.redMul(p.x),d=this.y.redMul(p.y),e=this.curve.d.redMul(c).redMul(d),f=b.redSub(e),g=b.redAdd(e),tmp=this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d),nx=a.redMul(f).redMul(tmp);return this.curve.twisted?(ny=a.redMul(g).redMul(d.redSub(this.curve._mulA(c))),nz=f.redMul(g)):(ny=a.redMul(g).redMul(d.redSub(c)),nz=this.curve._mulC(f).redMul(g)),this.curve.point(nx,ny,nz)},Point.prototype.add=function(p){return this.isInfinity()?p:p.isInfinity()?this:this.curve.extended?this._extAdd(p):this._projAdd(p)},Point.prototype.mul=function(k){return this._hasDoubles(k)?this.curve._fixedNafMul(this,k):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2,!1)},Point.prototype.jmulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var zi=this.z.redInvm();return this.x=this.x.redMul(zi),this.y=this.y.redMul(zi),this.t&&(this.t=this.t.redMul(zi)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(other){return this===other||0===this.getX().cmp(other.getX())&&0===this.getY().cmp(other.getY())},Point.prototype.eqXToP=function(x){var rx=x.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(rx))return!0;for(var xc=x.clone(),t=this.curve.redN.redMul(this.z);;){if(xc.iadd(this.curve.n),xc.cmp(this.curve.p)>=0)return!1;if(rx.redIAdd(t),0===this.x.cmp(rx))return!0}return!1},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../../elliptic":51,"../curve":54,"bn.js":50,inherits:141}],54:[function(require,module,exports){"use strict";var curve=exports;curve.base=require("./base"),curve.short=require("./short"),curve.mont=require("./mont"),curve.edwards=require("./edwards")},{"./base":52,"./edwards":53,"./mont":55,"./short":56}],55:[function(require,module,exports){"use strict";var curve=require("../curve"),BN=require("bn.js"),inherits=require("inherits"),Base=curve.base,utils=require("../../elliptic").utils;function MontCurve(conf){Base.call(this,"mont",conf),this.a=new BN(conf.a,16).toRed(this.red),this.b=new BN(conf.b,16).toRed(this.red),this.i4=new BN(4).toRed(this.red).redInvm(),this.two=new BN(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}inherits(MontCurve,Base),module.exports=MontCurve,MontCurve.prototype.validate=function(point){var x=point.normalize().x,x2=x.redSqr(),rhs=x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);return 0===rhs.redSqrt().redSqr().cmp(rhs)};function Point(curve,x,z){Base.BasePoint.call(this,curve,"projective"),null===x&&null===z?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new BN(x,16),this.z=new BN(z,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}inherits(Point,Base.BasePoint),MontCurve.prototype.decodePoint=function(bytes,enc){return this.point(utils.toArray(bytes,enc),1)},MontCurve.prototype.point=function(x,z){return new Point(this,x,z)},MontCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1]||curve.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var aa=this.x.redAdd(this.z).redSqr(),bb=this.x.redSub(this.z).redSqr(),c=aa.redSub(bb),nx=aa.redMul(bb),nz=c.redMul(bb.redAdd(this.curve.a24.redMul(c)));return this.curve.point(nx,nz)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(p,diff){var a=this.x.redAdd(this.z),b=this.x.redSub(this.z),c=p.x.redAdd(p.z),da=p.x.redSub(p.z).redMul(a),cb=c.redMul(b),nx=diff.z.redMul(da.redAdd(cb).redSqr()),nz=diff.x.redMul(da.redISub(cb).redSqr());return this.curve.point(nx,nz)},Point.prototype.mul=function(k){for(var t=k.clone(),a=this,b=this.curve.point(null,null),bits=[];0!==t.cmpn(0);t.iushrn(1))bits.push(t.andln(1));for(var i=bits.length-1;i>=0;i--)0===bits[i]?(a=a.diffAdd(b,this),b=b.dbl()):(b=a.diffAdd(b,this),a=a.dbl());return b},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(other){return 0===this.getX().cmp(other.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":51,"../curve":54,"bn.js":50,inherits:141}],56:[function(require,module,exports){"use strict";var curve=require("../curve"),elliptic=require("../../elliptic"),BN=require("bn.js"),inherits=require("inherits"),Base=curve.base,assert=elliptic.utils.assert;function ShortCurve(conf){Base.call(this,"short",conf),this.a=new BN(conf.a,16).toRed(this.red),this.b=new BN(conf.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(conf),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}inherits(ShortCurve,Base),module.exports=ShortCurve,ShortCurve.prototype._getEndomorphism=function(conf){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var beta,lambda;if(conf.beta)beta=new BN(conf.beta,16).toRed(this.red);else{var betas=this._getEndoRoots(this.p);beta=(beta=betas[0].cmp(betas[1])<0?betas[0]:betas[1]).toRed(this.red)}if(conf.lambda)lambda=new BN(conf.lambda,16);else{var lambdas=this._getEndoRoots(this.n);0===this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta))?lambda=lambdas[0]:(lambda=lambdas[1],assert(0===this.g.mul(lambda).x.cmp(this.g.x.redMul(beta))))}return{beta:beta,lambda:lambda,basis:conf.basis?conf.basis.map(function(vec){return{a:new BN(vec.a,16),b:new BN(vec.b,16)}}):this._getEndoBasis(lambda)}}},ShortCurve.prototype._getEndoRoots=function(num){var red=num===this.p?this.red:BN.mont(num),tinv=new BN(2).toRed(red).redInvm(),ntinv=tinv.redNeg(),s=new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);return[ntinv.redAdd(s).fromRed(),ntinv.redSub(s).fromRed()]},ShortCurve.prototype._getEndoBasis=function(lambda){for(var a0,b0,a1,b1,a2,b2,prevR,r,x,aprxSqrt=this.n.ushrn(Math.floor(this.n.bitLength()/2)),u=lambda,v=this.n.clone(),x1=new BN(1),y1=new BN(0),x2=new BN(0),y2=new BN(1),i=0;0!==u.cmpn(0);){var q=v.div(u);r=v.sub(q.mul(u)),x=x2.sub(q.mul(x1));var y=y2.sub(q.mul(y1));if(!a1&&r.cmp(aprxSqrt)<0)a0=prevR.neg(),b0=x1,a1=r.neg(),b1=x;else if(a1&&2==++i)break;prevR=r,v=u,u=r,x2=x1,x1=x,y2=y1,y1=y}a2=r.neg(),b2=x;var len1=a1.sqr().add(b1.sqr());return a2.sqr().add(b2.sqr()).cmp(len1)>=0&&(a2=a0,b2=b0),a1.negative&&(a1=a1.neg(),b1=b1.neg()),a2.negative&&(a2=a2.neg(),b2=b2.neg()),[{a:a1,b:b1},{a:a2,b:b2}]},ShortCurve.prototype._endoSplit=function(k){var basis=this.endo.basis,v1=basis[0],v2=basis[1],c1=v2.b.mul(k).divRound(this.n),c2=v1.b.neg().mul(k).divRound(this.n),p1=c1.mul(v1.a),p2=c2.mul(v2.a),q1=c1.mul(v1.b),q2=c2.mul(v2.b);return{k1:k.sub(p1).sub(p2),k2:q1.add(q2).neg()}},ShortCurve.prototype.pointFromX=function(x,odd){(x=new BN(x,16)).red||(x=x.toRed(this.red));var y2=x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b),y=y2.redSqrt();if(0!==y.redSqr().redSub(y2).cmp(this.zero))throw new Error("invalid point");var isOdd=y.fromRed().isOdd();return(odd&&!isOdd||!odd&&isOdd)&&(y=y.redNeg()),this.point(x,y)},ShortCurve.prototype.validate=function(point){if(point.inf)return!0;var x=point.x,y=point.y,ax=this.a.redMul(x),rhs=x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);return 0===y.redSqr().redISub(rhs).cmpn(0)},ShortCurve.prototype._endoWnafMulAdd=function(points,coeffs,jacobianResult){for(var npoints=this._endoWnafT1,ncoeffs=this._endoWnafT2,i=0;i":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(p){if(this.inf)return p;if(p.inf)return this;if(this.eq(p))return this.dbl();if(this.neg().eq(p))return this.curve.point(null,null);if(0===this.x.cmp(p.x))return this.curve.point(null,null);var c=this.y.redSub(p.y);0!==c.cmpn(0)&&(c=c.redMul(this.x.redSub(p.x).redInvm()));var nx=c.redSqr().redISub(this.x).redISub(p.x),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.dbl=function(){if(this.inf)return this;var ys1=this.y.redAdd(this.y);if(0===ys1.cmpn(0))return this.curve.point(null,null);var a=this.curve.a,x2=this.x.redSqr(),dyinv=ys1.redInvm(),c=x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv),nx=c.redSqr().redISub(this.x.redAdd(this.x)),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(k){return k=new BN(k,16),this._hasDoubles(k)?this.curve._fixedNafMul(this,k):this.curve.endo?this.curve._endoWnafMulAdd([this],[k]):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo?this.curve._endoWnafMulAdd(points,coeffs):this.curve._wnafMulAdd(1,points,coeffs,2)},Point.prototype.jmulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo?this.curve._endoWnafMulAdd(points,coeffs,!0):this.curve._wnafMulAdd(1,points,coeffs,2,!0)},Point.prototype.eq=function(p){return this===p||this.inf===p.inf&&(this.inf||0===this.x.cmp(p.x)&&0===this.y.cmp(p.y))},Point.prototype.neg=function(_precompute){if(this.inf)return this;var res=this.curve.point(this.x,this.y.redNeg());if(_precompute&&this.precomputed){var pre=this.precomputed,negate=function(p){return p.neg()};res.precomputed={naf:pre.naf&&{wnd:pre.naf.wnd,points:pre.naf.points.map(negate)},doubles:pre.doubles&&{step:pre.doubles.step,points:pre.doubles.points.map(negate)}}}return res},Point.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);return this.curve.jpoint(this.x,this.y,this.curve.one)};function JPoint(curve,x,y,z){Base.BasePoint.call(this,curve,"jacobian"),null===x&&null===y&&null===z?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN(0)):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=new BN(z,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}inherits(JPoint,Base.BasePoint),ShortCurve.prototype.jpoint=function(x,y,z){return new JPoint(this,x,y,z)},JPoint.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var zinv=this.z.redInvm(),zinv2=zinv.redSqr(),ax=this.x.redMul(zinv2),ay=this.y.redMul(zinv2).redMul(zinv);return this.curve.point(ax,ay)},JPoint.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.prototype.add=function(p){if(this.isInfinity())return p;if(p.isInfinity())return this;var pz2=p.z.redSqr(),z2=this.z.redSqr(),u1=this.x.redMul(pz2),u2=p.x.redMul(z2),s1=this.y.redMul(pz2.redMul(p.z)),s2=p.y.redMul(z2.redMul(this.z)),h=u1.redSub(u2),r=s1.redSub(s2);if(0===h.cmpn(0))return 0!==r.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(p.z).redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.mixedAdd=function(p){if(this.isInfinity())return p.toJ();if(p.isInfinity())return this;var z2=this.z.redSqr(),u1=this.x,u2=p.x.redMul(z2),s1=this.y,s2=p.y.redMul(z2).redMul(this.z),h=u1.redSub(u2),r=s1.redSub(s2);if(0===h.cmpn(0))return 0!==r.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.dblp=function(pow){if(0===pow)return this;if(this.isInfinity())return this;if(!pow)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var r=this,i=0;i=0)return!1;if(rx.redIAdd(t),0===this.x.cmp(rx))return!0}return!1},JPoint.prototype.inspect=function(){return this.isInfinity()?"":""},JPoint.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":51,"../curve":54,"bn.js":50,inherits:141}],57:[function(require,module,exports){"use strict";var curves=exports,hash=require("hash.js"),elliptic=require("../elliptic"),assert=elliptic.utils.assert;function PresetCurve(options){"short"===options.type?this.curve=new elliptic.curve.short(options):"edwards"===options.type?this.curve=new elliptic.curve.edwards(options):this.curve=new elliptic.curve.mont(options),this.g=this.curve.g,this.n=this.curve.n,this.hash=options.hash,assert(this.g.validate(),"Invalid curve"),assert(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}curves.PresetCurve=PresetCurve;function defineCurve(name,options){Object.defineProperty(curves,name,{configurable:!0,enumerable:!0,get:function(){var curve=new PresetCurve(options);return Object.defineProperty(curves,name,{configurable:!0,enumerable:!0,value:curve}),curve}})}defineCurve("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:hash.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("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:hash.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("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:hash.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("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:hash.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"]}),defineCurve("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 a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:hash.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var pre;try{pre=require("./precomputed/secp256k1")}catch(e){pre=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:hash.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",pre]})},{"../elliptic":51,"./precomputed/secp256k1":64,"hash.js":125}],58:[function(require,module,exports){"use strict";var BN=require("bn.js"),HmacDRBG=require("hmac-drbg"),elliptic=require("../../elliptic"),assert=elliptic.utils.assert,KeyPair=require("./key"),Signature=require("./signature");function EC(options){if(!(this instanceof EC))return new EC(options);"string"==typeof options&&(assert(elliptic.curves.hasOwnProperty(options),"Unknown curve "+options),options=elliptic.curves[options]),options instanceof elliptic.curves.PresetCurve&&(options={curve:options}),this.curve=options.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=options.curve.g,this.g.precompute(options.curve.n.bitLength()+1),this.hash=options.hash||options.curve.hash}module.exports=EC,EC.prototype.keyPair=function(options){return new KeyPair(this,options)},EC.prototype.keyFromPrivate=function(priv,enc){return KeyPair.fromPrivate(this,priv,enc)},EC.prototype.keyFromPublic=function(pub,enc){return KeyPair.fromPublic(this,pub,enc)},EC.prototype.genKeyPair=function(options){options||(options={});for(var drbg=new HmacDRBG({hash:this.hash,pers:options.pers,persEnc:options.persEnc||"utf8",entropy:options.entropy||elliptic.rand(this.hash.hmacStrength),entropyEnc:options.entropy&&options.entropyEnc||"utf8",nonce:this.n.toArray()}),bytes=this.n.byteLength(),ns2=this.n.sub(new BN(2));;){var priv=new BN(drbg.generate(bytes));if(!(priv.cmp(ns2)>0))return priv.iaddn(1),this.keyFromPrivate(priv)}},EC.prototype._truncateToN=function(msg,truncOnly){var delta=8*msg.byteLength()-this.n.bitLength();return delta>0&&(msg=msg.ushrn(delta)),!truncOnly&&msg.cmp(this.n)>=0?msg.sub(this.n):msg},EC.prototype.sign=function(msg,key,enc,options){"object"==typeof enc&&(options=enc,enc=null),options||(options={}),key=this.keyFromPrivate(key,enc),msg=this._truncateToN(new BN(msg,16));for(var bytes=this.n.byteLength(),bkey=key.getPrivate().toArray("be",bytes),nonce=msg.toArray("be",bytes),drbg=new HmacDRBG({hash:this.hash,entropy:bkey,nonce:nonce,pers:options.pers,persEnc:options.persEnc||"utf8"}),ns1=this.n.sub(new BN(1)),iter=0;;iter++){var k=options.k?options.k(iter):new BN(drbg.generate(this.n.byteLength()));if(!((k=this._truncateToN(k,!0)).cmpn(1)<=0||k.cmp(ns1)>=0)){var kp=this.g.mul(k);if(!kp.isInfinity()){var kpX=kp.getX(),r=kpX.umod(this.n);if(0!==r.cmpn(0)){var s=k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));if(0!==(s=s.umod(this.n)).cmpn(0)){var recoveryParam=(kp.getY().isOdd()?1:0)|(0!==kpX.cmp(r)?2:0);return options.canonical&&s.cmp(this.nh)>0&&(s=this.n.sub(s),recoveryParam^=1),new Signature({r:r,s:s,recoveryParam:recoveryParam})}}}}}},EC.prototype.verify=function(msg,signature,key,enc){msg=this._truncateToN(new BN(msg,16)),key=this.keyFromPublic(key,enc);var r=(signature=new Signature(signature,"hex")).r,s=signature.s;if(r.cmpn(1)<0||r.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var sinv=s.invm(this.n),u1=sinv.mul(msg).umod(this.n),u2=sinv.mul(r).umod(this.n);if(!this.curve._maxwellTrick){return!(p=this.g.mulAdd(u1,key.getPublic(),u2)).isInfinity()&&0===p.getX().umod(this.n).cmp(r)}var p;return!(p=this.g.jmulAdd(u1,key.getPublic(),u2)).isInfinity()&&p.eqXToP(r)},EC.prototype.recoverPubKey=function(msg,signature,j,enc){assert((3&j)===j,"The recovery param is more than two bits"),signature=new Signature(signature,enc);var n=this.n,e=new BN(msg),r=signature.r,s=signature.s,isYOdd=1&j,isSecondKey=j>>1;if(r.cmp(this.curve.p.umod(this.curve.n))>=0&&isSecondKey)throw new Error("Unable to find sencond key candinate");r=isSecondKey?this.curve.pointFromX(r.add(this.curve.n),isYOdd):this.curve.pointFromX(r,isYOdd);var rInv=signature.r.invm(n),s1=n.sub(e).mul(rInv).umod(n),s2=s.mul(rInv).umod(n);return this.g.mulAdd(s1,r,s2)},EC.prototype.getKeyRecoveryParam=function(e,signature,Q,enc){if(null!==(signature=new Signature(signature,enc)).recoveryParam)return signature.recoveryParam;for(var i=0;i<4;i++){var Qprime;try{Qprime=this.recoverPubKey(e,signature,i)}catch(e){continue}if(Qprime.eq(Q))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":51,"./key":59,"./signature":60,"bn.js":50,"hmac-drbg":138}],59:[function(require,module,exports){"use strict";var BN=require("bn.js"),assert=require("../../elliptic").utils.assert;function KeyPair(ec,options){this.ec=ec,this.priv=null,this.pub=null,options.priv&&this._importPrivate(options.priv,options.privEnc),options.pub&&this._importPublic(options.pub,options.pubEnc)}module.exports=KeyPair,KeyPair.fromPublic=function(ec,pub,enc){return pub instanceof KeyPair?pub:new KeyPair(ec,{pub:pub,pubEnc:enc})},KeyPair.fromPrivate=function(ec,priv,enc){return priv instanceof KeyPair?priv:new KeyPair(ec,{priv:priv,privEnc:enc})},KeyPair.prototype.validate=function(){var pub=this.getPublic();return pub.isInfinity()?{result:!1,reason:"Invalid public key"}:pub.validate()?pub.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},KeyPair.prototype.getPublic=function(compact,enc){return"string"==typeof compact&&(enc=compact,compact=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),enc?this.pub.encode(enc,compact):this.pub},KeyPair.prototype.getPrivate=function(enc){return"hex"===enc?this.priv.toString(16,2):this.priv},KeyPair.prototype._importPrivate=function(key,enc){this.priv=new BN(key,enc||16),this.priv=this.priv.umod(this.ec.curve.n)},KeyPair.prototype._importPublic=function(key,enc){if(key.x||key.y)return"mont"===this.ec.curve.type?assert(key.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||assert(key.x&&key.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(key.x,key.y));this.pub=this.ec.curve.decodePoint(key,enc)},KeyPair.prototype.derive=function(pub){return pub.mul(this.priv).getX()},KeyPair.prototype.sign=function(msg,enc,options){return this.ec.sign(msg,this,enc,options)},KeyPair.prototype.verify=function(msg,signature){return this.ec.verify(msg,signature,this)},KeyPair.prototype.inspect=function(){return""}},{"../../elliptic":51,"bn.js":50}],60:[function(require,module,exports){"use strict";var BN=require("bn.js"),utils=require("../../elliptic").utils,assert=utils.assert;function Signature(options,enc){if(options instanceof Signature)return options;this._importDER(options,enc)||(assert(options.r&&options.s,"Signature without r or s"),this.r=new BN(options.r,16),this.s=new BN(options.s,16),void 0===options.recoveryParam?this.recoveryParam=null:this.recoveryParam=options.recoveryParam)}module.exports=Signature;function getLength(buf,p){var initial=buf[p.place++];if(!(128&initial))return initial;for(var octetLen=15&initial,val=0,i=0,off=p.place;i>>3);for(arr.push(128|octets);--octets;)arr.push(len>>>(octets<<3)&255);arr.push(len)}}Signature.prototype.toDER=function(enc){var r=this.r.toArray(),s=this.s.toArray();for(128&r[0]&&(r=[0].concat(r)),128&s[0]&&(s=[0].concat(s)),r=rmPadding(r),s=rmPadding(s);!(s[0]||128&s[1]);)s=s.slice(1);var arr=[2];constructLength(arr,r.length),(arr=arr.concat(r)).push(2),constructLength(arr,s.length);var backHalf=arr.concat(s),res=[48];return constructLength(res,backHalf.length),res=res.concat(backHalf),utils.encode(res,enc)}},{"../../elliptic":51,"bn.js":50}],61:[function(require,module,exports){"use strict";var hash=require("hash.js"),elliptic=require("../../elliptic"),utils=elliptic.utils,assert=utils.assert,parseBytes=utils.parseBytes,KeyPair=require("./key"),Signature=require("./signature");function EDDSA(curve){if(assert("ed25519"===curve,"only tested with ed25519 so far"),!(this instanceof EDDSA))return new EDDSA(curve);curve=elliptic.curves[curve].curve;this.curve=curve,this.g=curve.g,this.g.precompute(curve.n.bitLength()+1),this.pointClass=curve.point().constructor,this.encodingLength=Math.ceil(curve.n.bitLength()/8),this.hash=hash.sha512}module.exports=EDDSA,EDDSA.prototype.sign=function(message,secret){message=parseBytes(message);var key=this.keyFromSecret(secret),r=this.hashInt(key.messagePrefix(),message),R=this.g.mul(r),Rencoded=this.encodePoint(R),s_=this.hashInt(Rencoded,key.pubBytes(),message).mul(key.priv()),S=r.add(s_).umod(this.curve.n);return this.makeSignature({R:R,S:S,Rencoded:Rencoded})},EDDSA.prototype.verify=function(message,sig,pub){message=parseBytes(message),sig=this.makeSignature(sig);var key=this.keyFromPublic(pub),h=this.hashInt(sig.Rencoded(),key.pubBytes(),message),SG=this.g.mul(sig.S());return sig.R().add(key.pub().mul(h)).eq(SG)},EDDSA.prototype.hashInt=function(){for(var hash=this.hash(),i=0;i=0;){var z;if(k.isOdd()){var mod=k.andln(ws-1);z=mod>(ws>>1)-1?(ws>>1)-mod:mod,k.isubn(z)}else z=0;naf.push(z);for(var shift=0!==k.cmpn(0)&&0===k.andln(ws-1)?w+1:1,i=1;i0||k2.cmpn(-d2)>0;){var m14=k1.andln(3)+d1&3,m24=k2.andln(3)+d2&3;3===m14&&(m14=-1),3===m24&&(m24=-1);var u1;u1=0==(1&m14)?0:3!=(m8=k1.andln(7)+d1&7)&&5!==m8||2!==m24?m14:-m14,jsf[0].push(u1);var u2;if(0==(1&m24))u2=0;else{var m8;u2=3!=(m8=k2.andln(7)+d2&7)&&5!==m8||2!==m14?m24:-m24}jsf[1].push(u2),2*d1===u1+1&&(d1=1-d1),2*d2===u2+1&&(d2=1-d2),k1.iushrn(1),k2.iushrn(1)}return jsf};utils.cachedProperty=function(obj,name,computer){var key="_"+name;obj.prototype[name]=function(){return void 0!==this[key]?this[key]:this[key]=computer.call(this)}};utils.parseBytes=function(bytes){return"string"==typeof bytes?utils.toArray(bytes,"hex"):bytes};utils.intFromLE=function(bytes){return new BN(bytes,"hex","le")}},{"bn.js":50,"minimalistic-assert":149,"minimalistic-crypto-utils":150}],66:[function(require,module,exports){module.exports={_from:"elliptic@^6.0.0",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/browserify-sign/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.0.0",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.0.0",saveSpec:null,fetchSpec:"^6.0.0"},_requiredBy:["/browserify-sign"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.0.0",_where:"/home/emilio/dev/bitcoincashjs/bitcoincashjs/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},{}],67:[function(require,module,exports){for(var ALPHABET="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ALPHABET_MAP={},i=0;i>8,bytes[j]&=255;for(;carry;)bytes.push(255&carry),carry>>=8}for(i=0;"1"===string[i]&&ito[i]?1:0);++i);return 0==c&&(to.length>cmp.length?c=-1:cmp.length>to.length&&(c=1)),c}},{}],69:[function(require,module,exports){(function(Buffer){module.exports=function(a,b){for(var length=Math.min(a.length,b.length),buffer=new Buffer(length),i=0;i - * @license MIT - */ -"use strict";var base64=require("base64-js"),ieee754=require("ieee754");exports.Buffer=Buffer,exports.SlowBuffer=function(length){+length!=length&&(length=0);return Buffer.alloc(+length)},exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH,Buffer.TYPED_ARRAY_SUPPORT=function(){try{var arr=new Uint8Array(1);return arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===arr.foo()}catch(e){return!1}}(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function createBuffer(length){if(length>K_MAX_LENGTH)throw new RangeError("Invalid typed array length");var buf=new Uint8Array(length);return buf.__proto__=Buffer.prototype,buf}function Buffer(arg,encodingOrOffset,length){if("number"==typeof arg){if("string"==typeof encodingOrOffset)throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if("number"==typeof value)throw new TypeError('"value" argument must not be a number');return isArrayBuffer(value)?function(array,byteOffset,length){if(byteOffset<0||array.byteLength=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return 0|length}Buffer.isBuffer=function(b){return null!=b&&!0===b._isBuffer},Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var x=a.length,y=b.length,i=0,len=Math.min(x,y);i>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase(),loweredCase=!0}}Buffer.byteLength=byteLength;Buffer.prototype._isBuffer=!0;function swap(b,n,m){var i=b[n];b[n]=b[m],b[m]=i}Buffer.prototype.swap16=function(){var len=this.length;if(len%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var i=0;ithis.length)return"";if((void 0===end||end>this.length)&&(end=this.length),end<=0)return"";if((end>>>=0)<=(start>>>=0))return"";for(encoding||(encoding="utf8");;)switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase(),loweredCase=!0}}.apply(this,arguments)},Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b||0===Buffer.compare(this,b)},Buffer.prototype.inspect=function(){var str="",max=exports.INSPECT_MAX_BYTES;return this.length>0&&(str=this.toString("hex",0,max).match(/.{2}/g).join(" "),this.length>max&&(str+=" ... ")),""},Buffer.prototype.compare=function(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target))throw new TypeError("Argument must be a Buffer");if(void 0===start&&(start=0),void 0===end&&(end=target?target.length:0),void 0===thisStart&&(thisStart=0),void 0===thisEnd&&(thisEnd=this.length),start<0||end>target.length||thisStart<0||thisEnd>this.length)throw new RangeError("out of range index");if(thisStart>=thisEnd&&start>=end)return 0;if(thisStart>=thisEnd)return-1;if(start>=end)return 1;if(start>>>=0,end>>>=0,thisStart>>>=0,thisEnd>>>=0,this===target)return 0;for(var x=thisEnd-thisStart,y=end-start,len=Math.min(x,y),thisCopy=this.slice(thisStart,thisEnd),targetCopy=target.slice(start,end),i=0;i2147483647?byteOffset=2147483647:byteOffset<-2147483648&&(byteOffset=-2147483648),numberIsNaN(byteOffset=+byteOffset)&&(byteOffset=dir?0:buffer.length-1),byteOffset<0&&(byteOffset=buffer.length+byteOffset),byteOffset>=buffer.length){if(dir)return-1;byteOffset=buffer.length-1}else if(byteOffset<0){if(!dir)return-1;byteOffset=0}if("string"==typeof val&&(val=Buffer.from(val,encoding)),Buffer.isBuffer(val))return 0===val.length?-1:arrayIndexOf(buffer,val,byteOffset,encoding,dir);if("number"==typeof val)return val&=255,"function"==typeof Uint8Array.prototype.indexOf?dir?Uint8Array.prototype.indexOf.call(buffer,val,byteOffset):Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset):arrayIndexOf(buffer,[val],byteOffset,encoding,dir);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1,arrLength=arr.length,valLength=val.length;if(void 0!==encoding&&("ucs2"===(encoding=String(encoding).toLowerCase())||"ucs-2"===encoding||"utf16le"===encoding||"utf-16le"===encoding)){if(arr.length<2||val.length<2)return-1;indexSize=2,arrLength/=2,valLength/=2,byteOffset/=2}function read(buf,i){return 1===indexSize?buf[i]:buf.readUInt16BE(i*indexSize)}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength&&(byteOffset=arrLength-valLength),i=byteOffset;i>=0;i--){for(var found=!0,j=0;jremaining&&(length=remaining):length=remaining;var strLen=string.length;if(strLen%2!=0)throw new TypeError("Invalid hex string");length>strLen/2&&(length=strLen/2);for(var i=0;i>8,lo=c%256,byteArray.push(lo),byteArray.push(hi);return byteArray}(string,buf.length-offset),buf,offset,length)}Buffer.prototype.write=function(string,offset,length,encoding){if(void 0===offset)encoding="utf8",length=this.length,offset=0;else if(void 0===length&&"string"==typeof offset)encoding=offset,length=this.length,offset=0;else{if(!isFinite(offset))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");offset>>>=0,isFinite(length)?(length>>>=0,void 0===encoding&&(encoding="utf8")):(encoding=length,length=void 0)}var remaining=this.length-offset;if((void 0===length||length>remaining)&&(length=remaining),string.length>0&&(length<0||offset<0)||offset>this.length)throw new RangeError("Attempt to write outside buffer bounds");encoding||(encoding="utf8");for(var loweredCase=!1;;)switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase(),loweredCase=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){return 0===start&&end===buf.length?base64.fromByteArray(buf):base64.fromByteArray(buf.slice(start,end))}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);for(var res=[],i=start;i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:firstByte<128&&(codePoint=firstByte);break;case 2:128==(192&(secondByte=buf[i+1]))&&(tempCodePoint=(31&firstByte)<<6|63&secondByte)>127&&(codePoint=tempCodePoint);break;case 3:secondByte=buf[i+1],thirdByte=buf[i+2],128==(192&secondByte)&&128==(192&thirdByte)&&(tempCodePoint=(15&firstByte)<<12|(63&secondByte)<<6|63&thirdByte)>2047&&(tempCodePoint<55296||tempCodePoint>57343)&&(codePoint=tempCodePoint);break;case 4:secondByte=buf[i+1],thirdByte=buf[i+2],fourthByte=buf[i+3],128==(192&secondByte)&&128==(192&thirdByte)&&128==(192&fourthByte)&&(tempCodePoint=(15&firstByte)<<18|(63&secondByte)<<12|(63&thirdByte)<<6|63&fourthByte)>65535&&tempCodePoint<1114112&&(codePoint=tempCodePoint)}}null===codePoint?(codePoint=65533,bytesPerSequence=1):codePoint>65535&&(codePoint-=65536,res.push(codePoint>>>10&1023|55296),codePoint=56320|1023&codePoint),res.push(codePoint),i+=bytesPerSequence}return function(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,codePoints);var res="",i=0;for(;ilen)&&(end=len);for(var out="",i=start;ilen&&(start=len),end<0?(end+=len)<0&&(end=0):end>len&&(end=len),endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset+--byteLength],mul=1;byteLength>0&&(mul*=256);)val+=this[offset+--byteLength]*mul;return val},Buffer.prototype.readUInt8=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,1,this.length),this[offset]},Buffer.prototype.readUInt16LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,2,this.length),this[offset]|this[offset+1]<<8},Buffer.prototype.readUInt16BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,2,this.length),this[offset]<<8|this[offset+1]},Buffer.prototype.readUInt32LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+16777216*this[offset+3]},Buffer.prototype.readUInt32BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),16777216*this[offset]+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])},Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i=(mul*=128)&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var i=byteLength,mul=1,val=this[offset+--i];i>0&&(mul*=256);)val+=this[offset+--i]*mul;return val>=(mul*=128)&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readInt8=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,1,this.length),128&this[offset]?-1*(255-this[offset]+1):this[offset]},Buffer.prototype.readInt16LE=function(offset,noAssert){offset>>>=0,noAssert||checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt16BE=function(offset,noAssert){offset>>>=0,noAssert||checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt32LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24},Buffer.prototype.readInt32BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]},Buffer.prototype.readFloatLE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!0,23,4)},Buffer.prototype.readFloatBE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!1,23,4)},Buffer.prototype.readDoubleLE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!0,52,8)},Buffer.prototype.readDoubleBE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!1,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){if(value=+value,offset>>>=0,byteLength>>>=0,!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength)-1,0)}var mul=1,i=0;for(this[offset]=255&value;++i>>=0,byteLength>>>=0,!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength)-1,0)}var i=byteLength-1,mul=1;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUInt8=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,1,255,0),this[offset]=255&value,offset+1},Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,65535,0),this[offset]=255&value,this[offset+1]=value>>>8,offset+2},Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,65535,0),this[offset]=value>>>8,this[offset+1]=255&value,offset+2},Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,4294967295,0),this[offset+3]=value>>>24,this[offset+2]=value>>>16,this[offset+1]=value>>>8,this[offset]=255&value,offset+4},Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,4294967295,0),this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=255&value,offset+4},Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){if(value=+value,offset>>>=0,!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0,mul=1,sub=0;for(this[offset]=255&value;++i>0)-sub&255;return offset+byteLength},Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){if(value=+value,offset>>>=0,!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1,mul=1,sub=0;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)value<0&&0===sub&&0!==this[offset+i+1]&&(sub=1),this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeInt8=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,1,127,-128),value<0&&(value=255+value+1),this[offset]=255&value,offset+1},Buffer.prototype.writeInt16LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,32767,-32768),this[offset]=255&value,this[offset+1]=value>>>8,offset+2},Buffer.prototype.writeInt16BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,32767,-32768),this[offset]=value>>>8,this[offset+1]=255&value,offset+2},Buffer.prototype.writeInt32LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),this[offset]=255&value,this[offset+1]=value>>>8,this[offset+2]=value>>>16,this[offset+3]=value>>>24,offset+4},Buffer.prototype.writeInt32BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),value<0&&(value=4294967295+value+1),this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=255&value,offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){return value=+value,offset>>>=0,noAssert||checkIEEE754(buf,0,offset,4),ieee754.write(buf,value,offset,littleEndian,23,4),offset+4}Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,!0,noAssert)},Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,!1,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){return value=+value,offset>>>=0,noAssert||checkIEEE754(buf,0,offset,8),ieee754.write(buf,value,offset,littleEndian,52,8),offset+8}Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,!0,noAssert)},Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,!1,noAssert)},Buffer.prototype.copy=function(target,targetStart,start,end){if(start||(start=0),end||0===end||(end=this.length),targetStart>=target.length&&(targetStart=target.length),targetStart||(targetStart=0),end>0&&end=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");end>this.length&&(end=this.length),target.length-targetStart=0;--i)target[i+targetStart]=this[i+start];else if(len<1e3)for(i=0;i>>=0,end=void 0===end?this.length:end>>>0,val||(val=0);var i;if("number"==typeof val)for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){(units-=3)>-1&&bytes.push(239,191,189);continue}if(i+1===length){(units-=3)>-1&&bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){(units-=3)>-1&&bytes.push(239,191,189),leadSurrogate=codePoint;continue}codePoint=65536+(leadSurrogate-55296<<10|codePoint-56320)}else leadSurrogate&&(units-=3)>-1&&bytes.push(239,191,189);if(leadSurrogate=null,codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,63&codePoint|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,63&codePoint|128)}else{if(!(codePoint<1114112))throw new Error("Invalid code point");if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,63&codePoint|128)}}return bytes}function base64ToBytes(str){return base64.toByteArray(function(str){if((str=str.trim().replace(INVALID_BASE64_RE,"")).length<2)return"";for(;str.length%4!=0;)str+="=";return str}(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length);++i)dst[i+offset]=src[i];return i}function isArrayBuffer(obj){return obj instanceof ArrayBuffer||null!=obj&&null!=obj.constructor&&"ArrayBuffer"===obj.constructor.name&&"number"==typeof obj.byteLength}function isArrayBufferView(obj){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(obj)}function numberIsNaN(obj){return obj!=obj}},{"base64-js":18,ieee754:139}],71:[function(require,module,exports){var Buffer=require("safe-buffer").Buffer,Transform=require("stream").Transform,StringDecoder=require("string_decoder").StringDecoder;function CipherBase(hashMode){Transform.call(this),this.hashMode="string"==typeof hashMode,this.hashMode?this[hashMode]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}require("inherits")(CipherBase,Transform),CipherBase.prototype.update=function(data,inputEnc,outputEnc){"string"==typeof data&&(data=Buffer.from(data,inputEnc));var outData=this._update(data);return this.hashMode?this:(outputEnc&&(outData=this._toString(outData,outputEnc)),outData)},CipherBase.prototype.setAutoPadding=function(){},CipherBase.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},CipherBase.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},CipherBase.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},CipherBase.prototype._transform=function(data,_,next){var err;try{this.hashMode?this._update(data):this.push(this._update(data))}catch(e){err=e}finally{next(err)}},CipherBase.prototype._flush=function(done){var err;try{this.push(this.__final())}catch(e){err=e}done(err)},CipherBase.prototype._finalOrDigest=function(outputEnc){var outData=this.__final()||Buffer.alloc(0);return outputEnc&&(outData=this._toString(outData,outputEnc,!0)),outData},CipherBase.prototype._toString=function(value,enc,fin){if(this._decoder||(this._decoder=new StringDecoder(enc),this._encoding=enc),this._encoding!==enc)throw new Error("can't switch encodings");var out=this._decoder.write(value);return fin&&(out+=this._decoder.end()),out},module.exports=CipherBase},{inherits:141,"safe-buffer":191,stream:200,string_decoder:201}],72:[function(require,module,exports){(function(Buffer){exports.isArray=function(arg){return Array.isArray?Array.isArray(arg):"[object Array]"===objectToString(arg)};exports.isBoolean=function(arg){return"boolean"==typeof arg};exports.isNull=function(arg){return null===arg};exports.isNullOrUndefined=function(arg){return null==arg};exports.isNumber=function(arg){return"number"==typeof arg};exports.isString=function(arg){return"string"==typeof arg};exports.isSymbol=function(arg){return"symbol"==typeof arg};exports.isUndefined=function(arg){return void 0===arg};exports.isRegExp=function(re){return"[object RegExp]"===objectToString(re)};exports.isObject=function(arg){return"object"==typeof arg&&null!==arg};exports.isDate=function(d){return"[object Date]"===objectToString(d)};exports.isError=function(e){return"[object Error]"===objectToString(e)||e instanceof Error};exports.isFunction=function(arg){return"function"==typeof arg};exports.isPrimitive=function(arg){return null===arg||"boolean"==typeof arg||"number"==typeof arg||"string"==typeof arg||"symbol"==typeof arg||void 0===arg},exports.isBuffer=Buffer.isBuffer;function objectToString(o){return Object.prototype.toString.call(o)}}).call(this,{isBuffer:require("../../is-buffer/index.js")})},{"../../is-buffer/index.js":142}],73:[function(require,module,exports){(function(Buffer){var elliptic=require("elliptic"),BN=require("bn.js");module.exports=function(curve){return new ECDH(curve)};var aliases={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};aliases.p224=aliases.secp224r1,aliases.p256=aliases.secp256r1=aliases.prime256v1,aliases.p192=aliases.secp192r1=aliases.prime192v1,aliases.p384=aliases.secp384r1,aliases.p521=aliases.secp521r1;function ECDH(curve){this.curveType=aliases[curve],this.curveType||(this.curveType={name:curve}),this.curve=new elliptic.ec(this.curveType.name),this.keys=void 0}ECDH.prototype.generateKeys=function(enc,format){return this.keys=this.curve.genKeyPair(),this.getPublicKey(enc,format)},ECDH.prototype.computeSecret=function(other,inenc,enc){inenc=inenc||"utf8",Buffer.isBuffer(other)||(other=new Buffer(other,inenc));return formatReturnValue(this.curve.keyFromPublic(other).getPublic().mul(this.keys.getPrivate()).getX(),enc,this.curveType.byteLength)},ECDH.prototype.getPublicKey=function(enc,format){var key=this.keys.getPublic("compressed"===format,!0);return"hybrid"===format&&(key[key.length-1]%2?key[0]=7:key[0]=6),formatReturnValue(key,enc)},ECDH.prototype.getPrivateKey=function(enc){return formatReturnValue(this.keys.getPrivate(),enc)},ECDH.prototype.setPublicKey=function(pub,enc){return enc=enc||"utf8",Buffer.isBuffer(pub)||(pub=new Buffer(pub,enc)),this.keys._importPublic(pub),this},ECDH.prototype.setPrivateKey=function(priv,enc){enc=enc||"utf8",Buffer.isBuffer(priv)||(priv=new Buffer(priv,enc));var _priv=new BN(priv);return _priv=_priv.toString(16),this.keys._importPrivate(_priv),this};function formatReturnValue(bn,enc,len){Array.isArray(bn)||(bn=bn.toArray());var buf=new Buffer(bn);if(len&&buf.length>>2),i=0,j=0;i>5]|=128<>>9<<4)]=len;for(var a=1732584193,b=-271733879,c=-1732584194,d=271733878,i=0;i>>32-cnt,b);var num,cnt}function md5_ff(a,b,c,d,x,s,t){return md5_cmn(b&c|~b&d,a,b,x,s,t)}function md5_gg(a,b,c,d,x,s,t){return md5_cmn(b&d|c&~d,a,b,x,s,t)}function md5_hh(a,b,c,d,x,s,t){return md5_cmn(b^c^d,a,b,x,s,t)}function md5_ii(a,b,c,d,x,s,t){return md5_cmn(c^(b|~d),a,b,x,s,t)}function safe_add(x,y){var lsw=(65535&x)+(65535&y);return(x>>16)+(y>>16)+(lsw>>16)<<16|65535&lsw}module.exports=function(buf){return makeHash(buf,core_md5)}},{"./make-hash":92}],94:[function(require,module,exports){"use strict";var inherits=require("inherits"),Legacy=require("./legacy"),Base=require("cipher-base"),Buffer=require("safe-buffer").Buffer,md5=require("create-hash/md5"),RIPEMD160=require("ripemd160"),sha=require("sha.js"),ZEROS=Buffer.alloc(128);function Hmac(alg,key){Base.call(this,"digest"),"string"==typeof key&&(key=Buffer.from(key));var blocksize="sha512"===alg||"sha384"===alg?128:64;if(this._alg=alg,this._key=key,key.length>blocksize){key=("rmd160"===alg?new RIPEMD160:sha(alg)).update(key).digest()}else key.lengthblocksize?key=alg(key):key.length0;count--)inputOff+=this._buffer(data,inputOff),outputOff+=this._flushBuffer(out,outputOff);return inputOff+=this._buffer(data,inputOff),out},Cipher.prototype.final=function(buffer){var first;buffer&&(first=this.update(buffer));var last;return last="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),first?first.concat(last):last},Cipher.prototype._pad=function(buffer,off){if(0===off)return!1;for(;off>>1];kL=utils.r28shl(kL,shift),kR=utils.r28shl(kR,shift),utils.pc2(kL,kR,state.keys,i)}},DES.prototype._update=function(inp,inOff,out,outOff){var state=this._desState,l=utils.readUInt32BE(inp,inOff),r=utils.readUInt32BE(inp,inOff+4);utils.ip(l,r,state.tmp,0),l=state.tmp[0],r=state.tmp[1],"encrypt"===this.type?this._encrypt(state,l,r,state.tmp,0):this._decrypt(state,l,r,state.tmp,0),l=state.tmp[0],r=state.tmp[1],utils.writeUInt32BE(out,l,outOff),utils.writeUInt32BE(out,r,outOff+4)},DES.prototype._pad=function(buffer,off){for(var value=buffer.length-off,i=off;i>>0,l=t}utils.rip(r,l,out,off)},DES.prototype._decrypt=function(state,lStart,rStart,out,off){for(var l=rStart,r=lStart,i=state.keys.length-2;i>=0;i-=2){var keyL=state.keys[i],keyR=state.keys[i+1];utils.expand(l,state.tmp,0),keyL^=state.tmp[0],keyR^=state.tmp[1];var s=utils.substitute(keyL,keyR),t=l;l=(r^utils.permute(s))>>>0,r=t}utils.rip(l,r,out,off)}},{"../des":97,inherits:141,"minimalistic-assert":149}],101:[function(require,module,exports){"use strict";var assert=require("minimalistic-assert"),inherits=require("inherits"),des=require("../des"),Cipher=des.Cipher,DES=des.DES;function EDE(options){Cipher.call(this,options);var state=new function(type,key){assert.equal(key.length,24,"Invalid key length");var k1=key.slice(0,8),k2=key.slice(8,16),k3=key.slice(16,24);this.ciphers="encrypt"===type?[DES.create({type:"encrypt",key:k1}),DES.create({type:"decrypt",key:k2}),DES.create({type:"encrypt",key:k3})]:[DES.create({type:"decrypt",key:k3}),DES.create({type:"encrypt",key:k2}),DES.create({type:"decrypt",key:k1})]}(this.type,this.options.key);this._edeState=state}inherits(EDE,Cipher),module.exports=EDE,EDE.create=function(options){return new EDE(options)},EDE.prototype._update=function(inp,inOff,out,outOff){var state=this._edeState;state.ciphers[0]._update(inp,inOff,out,outOff),state.ciphers[1]._update(out,outOff,out,outOff),state.ciphers[2]._update(out,outOff,out,outOff)},EDE.prototype._pad=DES.prototype._pad,EDE.prototype._unpad=DES.prototype._unpad},{"../des":97,inherits:141,"minimalistic-assert":149}],102:[function(require,module,exports){"use strict";exports.readUInt32BE=function(bytes,off){return(bytes[0+off]<<24|bytes[1+off]<<16|bytes[2+off]<<8|bytes[3+off])>>>0},exports.writeUInt32BE=function(bytes,value,off){bytes[0+off]=value>>>24,bytes[1+off]=value>>>16&255,bytes[2+off]=value>>>8&255,bytes[3+off]=255&value},exports.ip=function(inL,inR,out,off){for(var outL=0,outR=0,i=6;i>=0;i-=2){for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>>j+i&1;for(j=0;j<=24;j+=8)outL<<=1,outL|=inL>>>j+i&1}for(i=6;i>=0;i-=2){for(j=1;j<=25;j+=8)outR<<=1,outR|=inR>>>j+i&1;for(j=1;j<=25;j+=8)outR<<=1,outR|=inL>>>j+i&1}out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.rip=function(inL,inR,out,off){for(var outL=0,outR=0,i=0;i<4;i++)for(var j=24;j>=0;j-=8)outL<<=1,outL|=inR>>>j+i&1,outL<<=1,outL|=inL>>>j+i&1;for(i=4;i<8;i++)for(j=24;j>=0;j-=8)outR<<=1,outR|=inR>>>j+i&1,outR<<=1,outR|=inL>>>j+i&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.pc1=function(inL,inR,out,off){for(var outL=0,outR=0,i=7;i>=5;i--){for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>j+i&1;for(j=0;j<=24;j+=8)outL<<=1,outL|=inL>>j+i&1}for(j=0;j<=24;j+=8)outL<<=1,outL|=inR>>j+i&1;for(i=1;i<=3;i++){for(j=0;j<=24;j+=8)outR<<=1,outR|=inR>>j+i&1;for(j=0;j<=24;j+=8)outR<<=1,outR|=inL>>j+i&1}for(j=0;j<=24;j+=8)outR<<=1,outR|=inL>>j+i&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.r28shl=function(num,shift){return num<>>28-shift};var pc2table=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];exports.pc2=function(inL,inR,out,off){for(var outL=0,outR=0,len=pc2table.length>>>1,i=0;i>>pc2table[i]&1;for(i=len;i>>pc2table[i]&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.expand=function(r,out,off){var outL=0,outR=0;outL=(1&r)<<5|r>>>27;for(var i=23;i>=15;i-=4)outL<<=6,outL|=r>>>i&63;for(i=11;i>=3;i-=4)outR|=r>>>i&63,outR<<=6;outR|=(31&r)<<1|r>>>31,out[off+0]=outL>>>0,out[off+1]=outR>>>0};var sTable=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];exports.substitute=function(inL,inR){for(var out=0,i=0;i<4;i++){out<<=4,out|=sTable[64*i+(inL>>>18-6*i&63)]}for(i=0;i<4;i++){out<<=4,out|=sTable[256+64*i+(inR>>>18-6*i&63)]}return out>>>0};var permuteTable=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];exports.permute=function(num){for(var out=0,i=0;i>>permuteTable[i]&1;return out>>>0},exports.padSplit=function(num,size,group){for(var str=num.toString(2);str.lengthbits;)num.ishrn(1);if(num.isEven()&&num.iadd(ONE),num.testn(1)||num.iadd(TWO),gen.cmp(TWO)){if(!gen.cmp(FIVE))for(;num.mod(TEN).cmp(THREE);)num.iadd(FOUR)}else for(;num.mod(TWENTYFOUR).cmp(ELEVEN);)num.iadd(FOUR);if(simpleSieve(n2=num.shrn(1))&&simpleSieve(num)&&fermatTest(n2)&&fermatTest(num)&&millerRabin.test(n2)&&millerRabin.test(num))return num}}},{"bn.js":107,"miller-rabin":147,randombytes:174}],106:[function(require,module,exports){module.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],107:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{buffer:21,dup:16}],108:[function(require,module,exports){"use strict";var elliptic=exports;elliptic.version=require("../package.json").version,elliptic.utils=require("./elliptic/utils"),elliptic.rand=require("brorand"),elliptic.hmacDRBG=require("./elliptic/hmac-drbg"),elliptic.curve=require("./elliptic/curve"),elliptic.curves=require("./elliptic/curves"),elliptic.ec=require("./elliptic/ec")},{"../package.json":121,"./elliptic/curve":111,"./elliptic/curves":114,"./elliptic/ec":115,"./elliptic/hmac-drbg":118,"./elliptic/utils":120,brorand:20}],109:[function(require,module,exports){"use strict";var bn=require("bn.js"),elliptic=require("../../elliptic"),getNAF=elliptic.utils.getNAF,getJSF=elliptic.utils.getJSF,assert=elliptic.utils.assert;function BaseCurve(type,conf){this.type=type,this.p=new bn(conf.p,16),this.red=conf.prime?bn.red(conf.prime):bn.mont(this.p),this.zero=new bn(0).toRed(this.red),this.one=new bn(1).toRed(this.red),this.two=new bn(2).toRed(this.red),this.n=conf.n&&new bn(conf.n,16),this.g=conf.g&&this.pointFromJSON(conf.g,conf.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4)}module.exports=BaseCurve,BaseCurve.prototype.point=function(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function(p,k){var doubles=p._getDoubles(),naf=getNAF(k,1),I=(1<=j;k--)nafW=(nafW<<1)+naf[k];repr.push(nafW)}for(var a=this.jpoint(null,null,null),b=this.jpoint(null,null,null),i=I;i>0;i--){for(j=0;j=0;i--){for(k=0;i>=0&&0===naf[i];i--)k++;if(i>=0&&k++,acc=acc.dblp(k),i<0)break;var z=naf[i];assert(0!==z),acc="affine"===p.type?z>0?acc.mixedAdd(wnd[z-1>>1]):acc.mixedAdd(wnd[-z-1>>1].neg()):z>0?acc.add(wnd[z-1>>1]):acc.add(wnd[-z-1>>1].neg())}return"affine"===p.type?acc.toP():acc},BaseCurve.prototype._wnafMulAdd=function(defW,points,coeffs,len){for(var wndWidth=this._wnafT1,wnd=this._wnafT2,naf=this._wnafT3,max=0,i=0;i=1;i-=2){var a=i-1,b=i;if(1===wndWidth[a]&&1===wndWidth[b]){var comb=[points[a],null,null,points[b]];0===points[a].y.cmp(points[b].y)?(comb[1]=points[a].add(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg())):0===points[a].y.cmp(points[b].y.redNeg())?(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].add(points[b].neg())):(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg()));var index=[-3,-1,-5,-7,0,7,5,1,3],jsf=getJSF(coeffs[a],coeffs[b]);max=Math.max(jsf[0].length,max),naf[a]=new Array(max),naf[b]=new Array(max);for(var j=0;j=0;i--){for(var k=0;i>=0;){var zero=!0;for(j=0;j=0&&k++,acc=acc.dblp(k),i<0)break;for(j=0;j0?p=wnd[j][z-1>>1]:z<0&&(p=wnd[j][-z-1>>1].neg()),acc="affine"===p.type?acc.mixedAdd(p):acc.add(p))}}for(i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},Point.prototype._extDbl=function(){var a=this.x.redSqr(),b=this.y.redSqr(),c=this.z.redSqr();c=c.redIAdd(c);var d=this.curve._mulA(a),e=this.x.redAdd(this.y).redSqr().redISub(a).redISub(b),g=d.redAdd(b),f=g.redSub(c),h=d.redSub(b),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projDbl=function(){var nx,ny,nz,b=this.x.redAdd(this.y).redSqr(),c=this.x.redSqr(),d=this.y.redSqr();if(this.curve.twisted){var f=(e=this.curve._mulA(c)).redAdd(d);if(this.zOne)nx=b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)),ny=f.redMul(e.redSub(d)),nz=f.redSqr().redSub(f).redSub(f);else{var h=this.z.redSqr(),j=f.redSub(h).redISub(h);nx=b.redSub(c).redISub(d).redMul(j),ny=f.redMul(e.redSub(d)),nz=f.redMul(j)}}else{var e=c.redAdd(d);h=this.curve._mulC(this.c.redMul(this.z)).redSqr(),j=e.redSub(h).redSub(h);nx=this.curve._mulC(b.redISub(e)).redMul(j),ny=this.curve._mulC(e).redMul(c.redISub(d)),nz=e.redMul(j)}return this.curve.point(nx,ny,nz)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(p){var a=this.y.redSub(this.x).redMul(p.y.redSub(p.x)),b=this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)),c=this.t.redMul(this.curve.dd).redMul(p.t),d=this.z.redMul(p.z.redAdd(p.z)),e=b.redSub(a),f=d.redSub(c),g=d.redAdd(c),h=b.redAdd(a),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projAdd=function(p){var ny,nz,a=this.z.redMul(p.z),b=a.redSqr(),c=this.x.redMul(p.x),d=this.y.redMul(p.y),e=this.curve.d.redMul(c).redMul(d),f=b.redSub(e),g=b.redAdd(e),tmp=this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d),nx=a.redMul(f).redMul(tmp);return this.curve.twisted?(ny=a.redMul(g).redMul(d.redSub(this.curve._mulA(c))),nz=f.redMul(g)):(ny=a.redMul(g).redMul(d.redSub(c)),nz=this.curve._mulC(f).redMul(g)),this.curve.point(nx,ny,nz)},Point.prototype.add=function(p){return this.isInfinity()?p:p.isInfinity()?this:this.curve.extended?this._extAdd(p):this._projAdd(p)},Point.prototype.mul=function(k){return this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,k):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2)},Point.prototype.normalize=function(){if(this.zOne)return this;var zi=this.z.redInvm();return this.x=this.x.redMul(zi),this.y=this.y.redMul(zi),this.t&&(this.t=this.t.redMul(zi)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../../elliptic":108,"../curve":111,"bn.js":19,inherits:141}],111:[function(require,module,exports){arguments[4][54][0].apply(exports,arguments)},{"./base":109,"./edwards":110,"./mont":112,"./short":113,dup:54}],112:[function(require,module,exports){"use strict";var curve=require("../curve"),bn=require("bn.js"),inherits=require("inherits"),Base=curve.base;function MontCurve(conf){Base.call(this,"mont",conf),this.a=new bn(conf.a,16).toRed(this.red),this.b=new bn(conf.b,16).toRed(this.red),this.i4=new bn(4).toRed(this.red).redInvm(),this.two=new bn(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}inherits(MontCurve,Base),module.exports=MontCurve,MontCurve.prototype.validate=function(point){var x=point.normalize().x,x2=x.redSqr(),rhs=x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);return 0===rhs.redSqrt().redSqr().cmp(rhs)};function Point(curve,x,z){Base.BasePoint.call(this,curve,"projective"),null===x&&null===z?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new bn(x,16),this.z=new bn(z,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}inherits(Point,Base.BasePoint),MontCurve.prototype.point=function(x,z){return new Point(this,x,z)},MontCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},Point.prototype.precompute=function(){},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1]||curve.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var aa=this.x.redAdd(this.z).redSqr(),bb=this.x.redSub(this.z).redSqr(),c=aa.redSub(bb),nx=aa.redMul(bb),nz=c.redMul(bb.redAdd(this.curve.a24.redMul(c)));return this.curve.point(nx,nz)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(p,diff){var a=this.x.redAdd(this.z),b=this.x.redSub(this.z),c=p.x.redAdd(p.z),da=p.x.redSub(p.z).redMul(a),cb=c.redMul(b),nx=diff.z.redMul(da.redAdd(cb).redSqr()),nz=diff.x.redMul(da.redISub(cb).redSqr());return this.curve.point(nx,nz)},Point.prototype.mul=function(k){for(var t=k.clone(),a=this,b=this.curve.point(null,null),bits=[];0!==t.cmpn(0);t.ishrn(1))bits.push(t.andln(1));for(var i=bits.length-1;i>=0;i--)0===bits[i]?(a=a.diffAdd(b,this),b=b.dbl()):(b=a.diffAdd(b,this),a=a.dbl());return b},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../curve":111,"bn.js":19,inherits:141}],113:[function(require,module,exports){"use strict";var curve=require("../curve"),elliptic=require("../../elliptic"),bn=require("bn.js"),inherits=require("inherits"),Base=curve.base,assert=elliptic.utils.assert;function ShortCurve(conf){Base.call(this,"short",conf),this.a=new bn(conf.a,16).toRed(this.red),this.b=new bn(conf.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(conf),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}inherits(ShortCurve,Base),module.exports=ShortCurve,ShortCurve.prototype._getEndomorphism=function(conf){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var beta,lambda;if(conf.beta)beta=new bn(conf.beta,16).toRed(this.red);else{var betas=this._getEndoRoots(this.p);beta=(beta=betas[0].cmp(betas[1])<0?betas[0]:betas[1]).toRed(this.red)}if(conf.lambda)lambda=new bn(conf.lambda,16);else{var lambdas=this._getEndoRoots(this.n);0===this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta))?lambda=lambdas[0]:(lambda=lambdas[1],assert(0===this.g.mul(lambda).x.cmp(this.g.x.redMul(beta))))}return{beta:beta,lambda:lambda,basis:conf.basis?conf.basis.map(function(vec){return{a:new bn(vec.a,16),b:new bn(vec.b,16)}}):this._getEndoBasis(lambda)}}},ShortCurve.prototype._getEndoRoots=function(num){var red=num===this.p?this.red:bn.mont(num),tinv=new bn(2).toRed(red).redInvm(),ntinv=tinv.redNeg(),s=new bn(3).toRed(red).redNeg().redSqrt().redMul(tinv);return[ntinv.redAdd(s).fromRed(),ntinv.redSub(s).fromRed()]},ShortCurve.prototype._getEndoBasis=function(lambda){for(var a0,b0,a1,b1,a2,b2,prevR,r,x,aprxSqrt=this.n.shrn(Math.floor(this.n.bitLength()/2)),u=lambda,v=this.n.clone(),x1=new bn(1),y1=new bn(0),x2=new bn(0),y2=new bn(1),i=0;0!==u.cmpn(0);){var q=v.div(u);r=v.sub(q.mul(u)),x=x2.sub(q.mul(x1));var y=y2.sub(q.mul(y1));if(!a1&&r.cmp(aprxSqrt)<0)a0=prevR.neg(),b0=x1,a1=r.neg(),b1=x;else if(a1&&2==++i)break;prevR=r,v=u,u=r,x2=x1,x1=x,y2=y1,y1=y}a2=r.neg(),b2=x;var len1=a1.sqr().add(b1.sqr());return a2.sqr().add(b2.sqr()).cmp(len1)>=0&&(a2=a0,b2=b0),a1.sign&&(a1=a1.neg(),b1=b1.neg()),a2.sign&&(a2=a2.neg(),b2=b2.neg()),[{a:a1,b:b1},{a:a2,b:b2}]},ShortCurve.prototype._endoSplit=function(k){var basis=this.endo.basis,v1=basis[0],v2=basis[1],c1=v2.b.mul(k).divRound(this.n),c2=v1.b.neg().mul(k).divRound(this.n),p1=c1.mul(v1.a),p2=c2.mul(v2.a),q1=c1.mul(v1.b),q2=c2.mul(v2.b);return{k1:k.sub(p1).sub(p2),k2:q1.add(q2).neg()}},ShortCurve.prototype.pointFromX=function(odd,x){(x=new bn(x,16)).red||(x=x.toRed(this.red));var y=x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b).redSqrt(),isOdd=y.fromRed().isOdd();return(odd&&!isOdd||!odd&&isOdd)&&(y=y.redNeg()),this.point(x,y)},ShortCurve.prototype.validate=function(point){if(point.inf)return!0;var x=point.x,y=point.y,ax=this.a.redMul(x),rhs=x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);return 0===y.redSqr().redISub(rhs).cmpn(0)},ShortCurve.prototype._endoWnafMulAdd=function(points,coeffs){for(var npoints=this._endoWnafT1,ncoeffs=this._endoWnafT2,i=0;i":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(p){if(this.inf)return p;if(p.inf)return this;if(this.eq(p))return this.dbl();if(this.neg().eq(p))return this.curve.point(null,null);if(0===this.x.cmp(p.x))return this.curve.point(null,null);var c=this.y.redSub(p.y);0!==c.cmpn(0)&&(c=c.redMul(this.x.redSub(p.x).redInvm()));var nx=c.redSqr().redISub(this.x).redISub(p.x),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.dbl=function(){if(this.inf)return this;var ys1=this.y.redAdd(this.y);if(0===ys1.cmpn(0))return this.curve.point(null,null);var a=this.curve.a,x2=this.x.redSqr(),dyinv=ys1.redInvm(),c=x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv),nx=c.redSqr().redISub(this.x.redAdd(this.x)),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(k){return k=new bn(k,16),this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,k):this.curve.endo?this.curve._endoWnafMulAdd([this],[k]):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo?this.curve._endoWnafMulAdd(points,coeffs):this.curve._wnafMulAdd(1,points,coeffs,2)},Point.prototype.eq=function(p){return this===p||this.inf===p.inf&&(this.inf||0===this.x.cmp(p.x)&&0===this.y.cmp(p.y))},Point.prototype.neg=function(_precompute){if(this.inf)return this;var res=this.curve.point(this.x,this.y.redNeg());if(_precompute&&this.precomputed){var pre=this.precomputed,negate=function(p){return p.neg()};res.precomputed={naf:pre.naf&&{wnd:pre.naf.wnd,points:pre.naf.points.map(negate)},doubles:pre.doubles&&{step:pre.doubles.step,points:pre.doubles.points.map(negate)}}}return res},Point.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);return this.curve.jpoint(this.x,this.y,this.curve.one)};function JPoint(curve,x,y,z){Base.BasePoint.call(this,curve,"jacobian"),null===x&&null===y&&null===z?(this.x=this.curve.one,this.y=this.curve.one,this.z=new bn(0)):(this.x=new bn(x,16),this.y=new bn(y,16),this.z=new bn(z,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}inherits(JPoint,Base.BasePoint),ShortCurve.prototype.jpoint=function(x,y,z){return new JPoint(this,x,y,z)},JPoint.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var zinv=this.z.redInvm(),zinv2=zinv.redSqr(),ax=this.x.redMul(zinv2),ay=this.y.redMul(zinv2).redMul(zinv);return this.curve.point(ax,ay)},JPoint.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.prototype.add=function(p){if(this.isInfinity())return p;if(p.isInfinity())return this;var pz2=p.z.redSqr(),z2=this.z.redSqr(),u1=this.x.redMul(pz2),u2=p.x.redMul(z2),s1=this.y.redMul(pz2.redMul(p.z)),s2=p.y.redMul(z2.redMul(this.z)),h=u1.redSub(u2),r=s1.redSub(s2);if(0===h.cmpn(0))return 0!==r.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(p.z).redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.mixedAdd=function(p){if(this.isInfinity())return p.toJ();if(p.isInfinity())return this;var z2=this.z.redSqr(),u1=this.x,u2=p.x.redMul(z2),s1=this.y,s2=p.y.redMul(z2).redMul(this.z),h=u1.redSub(u2),r=s1.redSub(s2);if(0===h.cmpn(0))return 0!==r.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.dblp=function(pow){if(0===pow)return this;if(this.isInfinity())return this;if(!pow)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var r=this,i=0;i":""},JPoint.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":108,"../curve":111,"bn.js":19,inherits:141}],114:[function(require,module,exports){"use strict";var curves=exports,hash=require("hash.js"),elliptic=require("../elliptic"),assert=elliptic.utils.assert;function PresetCurve(options){"short"===options.type?this.curve=new elliptic.curve.short(options):"edwards"===options.type?this.curve=new elliptic.curve.edwards(options):this.curve=new elliptic.curve.mont(options),this.g=this.curve.g,this.n=this.curve.n,this.hash=options.hash,assert(this.g.validate(),"Invalid curve"),assert(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}curves.PresetCurve=PresetCurve;function defineCurve(name,options){Object.defineProperty(curves,name,{configurable:!0,enumerable:!0,get:function(){var curve=new PresetCurve(options);return Object.defineProperty(curves,name,{configurable:!0,enumerable:!0,value:curve}),curve}})}defineCurve("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:hash.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("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:hash.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("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:hash.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var pre;try{pre=require("./precomputed/secp256k1")}catch(e){pre=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:hash.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",pre]})},{"../elliptic":108,"./precomputed/secp256k1":119,"hash.js":125}],115:[function(require,module,exports){"use strict";var bn=require("bn.js"),elliptic=require("../../elliptic"),assert=elliptic.utils.assert,KeyPair=require("./key"),Signature=require("./signature");function EC(options){if(!(this instanceof EC))return new EC(options);"string"==typeof options&&(assert(elliptic.curves.hasOwnProperty(options),"Unknown curve "+options),options=elliptic.curves[options]),options instanceof elliptic.curves.PresetCurve&&(options={curve:options}),this.curve=options.curve.curve,this.n=this.curve.n,this.nh=this.n.shrn(1),this.g=this.curve.g,this.g=options.curve.g,this.g.precompute(options.curve.n.bitLength()+1),this.hash=options.hash||options.curve.hash}module.exports=EC,EC.prototype.keyPair=function(options){return new KeyPair(this,options)},EC.prototype.keyFromPrivate=function(priv,enc){return KeyPair.fromPrivate(this,priv,enc)},EC.prototype.keyFromPublic=function(pub,enc){return KeyPair.fromPublic(this,pub,enc)},EC.prototype.genKeyPair=function(options){options||(options={});for(var drbg=new elliptic.hmacDRBG({hash:this.hash,pers:options.pers,entropy:options.entropy||elliptic.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),bytes=this.n.byteLength(),ns2=this.n.sub(new bn(2));;){var priv=new bn(drbg.generate(bytes));if(!(priv.cmp(ns2)>0))return priv.iaddn(1),this.keyFromPrivate(priv)}},EC.prototype._truncateToN=function(msg,truncOnly){var delta=8*msg.byteLength()-this.n.bitLength();return delta>0&&(msg=msg.shrn(delta)),!truncOnly&&msg.cmp(this.n)>=0?msg.sub(this.n):msg},EC.prototype.sign=function(msg,key,enc,options){"object"==typeof enc&&(options=enc,enc=null),options||(options={}),key=this.keyFromPrivate(key,enc),msg=this._truncateToN(new bn(msg,16));for(var bytes=this.n.byteLength(),bkey=key.getPrivate().toArray(),i=bkey.length;i<21;i++)bkey.unshift(0);var nonce=msg.toArray();for(i=nonce.length;i=0)){var kp=this.g.mul(k);if(!kp.isInfinity()){var r=kp.getX().mod(this.n);if(0!==r.cmpn(0)){var s=k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)).mod(this.n);if(0!==s.cmpn(0))return options.canonical&&s.cmp(this.nh)>0&&(s=this.n.sub(s)),new Signature({r:r,s:s})}}}}},EC.prototype.verify=function(msg,signature,key,enc){msg=this._truncateToN(new bn(msg,16)),key=this.keyFromPublic(key,enc);var r=(signature=new Signature(signature,"hex")).r,s=signature.s;if(r.cmpn(1)<0||r.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var sinv=s.invm(this.n),u1=sinv.mul(msg).mod(this.n),u2=sinv.mul(r).mod(this.n),p=this.g.mulAdd(u1,key.getPublic(),u2);return!p.isInfinity()&&0===p.getX().mod(this.n).cmp(r)}},{"../../elliptic":108,"./key":116,"./signature":117,"bn.js":19}],116:[function(require,module,exports){"use strict";var bn=require("bn.js"),utils=require("../../elliptic").utils;function KeyPair(ec,options){this.ec=ec,this.priv=null,this.pub=null,options.priv&&this._importPrivate(options.priv,options.privEnc),options.pub&&this._importPublic(options.pub,options.pubEnc)}module.exports=KeyPair,KeyPair.fromPublic=function(ec,pub,enc){return pub instanceof KeyPair?pub:new KeyPair(ec,{pub:pub,pubEnc:enc})},KeyPair.fromPrivate=function(ec,priv,enc){return priv instanceof KeyPair?priv:new KeyPair(ec,{priv:priv,privEnc:enc})},KeyPair.prototype.validate=function(){var pub=this.getPublic();return pub.isInfinity()?{result:!1,reason:"Invalid public key"}:pub.validate()?pub.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},KeyPair.prototype.getPublic=function(compact,enc){if(this.pub||(this.pub=this.ec.g.mul(this.priv)),"string"==typeof compact&&(enc=compact,compact=null),!enc)return this.pub;for(var len=this.ec.curve.p.byteLength(),x=this.pub.getX().toArray(),i=x.length;i"}},{"../../elliptic":108,"bn.js":19}],117:[function(require,module,exports){"use strict";var bn=require("bn.js"),utils=require("../../elliptic").utils,assert=utils.assert;function Signature(options,enc){if(options instanceof Signature)return options;this._importDER(options,enc)||(assert(options.r&&options.s,"Signature without r or s"),this.r=new bn(options.r,16),this.s=new bn(options.s,16))}module.exports=Signature,Signature.prototype._importDER=function(data,enc){if((data=utils.toArray(data,enc)).length<6||48!==data[0]||2!==data[2])return!1;if(1+data[1]>data.length)return!1;var rlen=data[3];if(rlen>=128)return!1;if(4+rlen+2>=data.length)return!1;if(2!==data[4+rlen])return!1;var slen=data[5+rlen];return!(slen>=128)&&(!(4+rlen+2+slen>data.length)&&(this.r=new bn(data.slice(4,4+rlen)),this.s=new bn(data.slice(4+rlen+2,4+rlen+2+slen)),!0))},Signature.prototype.toDER=function(enc){var r=this.r.toArray(),s=this.s.toArray();128&r[0]&&(r=[0].concat(r)),128&s[0]&&(s=[0].concat(s));var res=[48,r.length+s.length+4,2,r.length];return res=res.concat(r,[2,s.length],s),utils.encode(res,enc)}},{"../../elliptic":108,"bn.js":19}],118:[function(require,module,exports){"use strict";var hash=require("hash.js"),utils=require("../elliptic").utils,assert=utils.assert;function HmacDRBG(options){if(!(this instanceof HmacDRBG))return new HmacDRBG(options);this.hash=options.hash,this.predResist=!!options.predResist,this.outLen=this.hash.outSize,this.minEntropy=options.minEntropy||this.hash.hmacStrength,this.reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var entropy=utils.toArray(options.entropy,options.entropyEnc),nonce=utils.toArray(options.nonce,options.nonceEnc),pers=utils.toArray(options.pers,options.persEnc);assert(entropy.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(entropy,nonce,pers)}module.exports=HmacDRBG,HmacDRBG.prototype._init=function(entropy,nonce,pers){var seed=entropy.concat(nonce).concat(pers);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(entropy.concat(add||[])),this.reseed=1},HmacDRBG.prototype.generate=function(len,enc,add,addEnc){if(this.reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof enc&&(addEnc=add,add=enc,enc=null),add&&(add=utils.toArray(add,addEnc),this._update(add));for(var temp=[];temp.length>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}return res};function zero2(word){return 1===word.length?"0"+word:word}utils.zero2=zero2;function toHex(msg){for(var res="",i=0;i=0;){var z;if(k.isOdd()){var mod=k.andln(ws-1);z=mod>(ws>>1)-1?(ws>>1)-mod:mod,k.isubn(z)}else z=0;naf.push(z);for(var shift=0!==k.cmpn(0)&&0===k.andln(ws-1)?w+1:1,i=1;i0||k2.cmpn(-d2)>0;){var m14=k1.andln(3)+d1&3,m24=k2.andln(3)+d2&3;3===m14&&(m14=-1),3===m24&&(m24=-1);var u1;u1=0==(1&m14)?0:3!=(m8=k1.andln(7)+d1&7)&&5!==m8||2!==m24?m14:-m14,jsf[0].push(u1);var u2;if(0==(1&m24))u2=0;else{var m8;u2=3!=(m8=k2.andln(7)+d2&7)&&5!==m8||2!==m14?m24:-m24}jsf[1].push(u2),2*d1===u1+1&&(d1=1-d1),2*d2===u2+1&&(d2=1-d2),k1.ishrn(1),k2.ishrn(1)}return jsf}},{}],121:[function(require,module,exports){module.exports={_from:"elliptic@=3.0.3",_id:"elliptic@3.0.3",_inBundle:!1,_integrity:"sha1-hlybQgv75VAGuflp+XoNLESWZZU=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@=3.0.3",name:"elliptic",escapedName:"elliptic",rawSpec:"=3.0.3",saveSpec:null,fetchSpec:"=3.0.3"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-3.0.3.tgz",_shasum:"865c9b420bfbe55006b9f969f97a0d2c44966595",_spec:"elliptic@=3.0.3",_where:"/home/emilio/dev/bitcoincashjs/bitcoincashjs",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^2.0.0",brorand:"^1.0.1","hash.js":"^1.0.0",inherits:"^2.0.1"},deprecated:!1,description:"EC cryptography",devDependencies:{browserify:"^3.44.2",jscs:"^1.11.3",jshint:"^2.6.0",mocha:"^2.1.0","uglify-js":"^2.4.13"},homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{test:"make lint && mocha --reporter=spec test/*-test.js"},version:"3.0.3"}},{}],122:[function(require,module,exports){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if("number"!=typeof n||n<0||isNaN(n))throw TypeError("n must be a positive number");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(this._events||(this._events={}),"error"===type&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if((er=arguments[1])instanceof Error)throw er;var err=new Error('Uncaught, unspecified "error" event. ('+er+")");throw err.context=er,err}if(isUndefined(handler=this._events[type]))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:args=Array.prototype.slice.call(arguments,1),handler.apply(this,args)}else if(isObject(handler))for(args=Array.prototype.slice.call(arguments,1),len=(listeners=handler.slice()).length,i=0;i0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[type].length),"function"==typeof console.trace&&console.trace()),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=!1;function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}return g.listener=listener,this.on(type,g),this},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;if(length=(list=this._events[type]).length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit("removeListener",type,listener);else if(isObject(list)){for(i=length;i-- >0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(position<0)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit("removeListener",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)"removeListener"!==key&&this.removeAllListeners(key);return this.removeAllListeners("removeListener"),this._events={},this}if(isFunction(listeners=this._events[type]))this.removeListener(type,listeners);else if(listeners)for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){return this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.prototype.listenerCount=function(type){if(this._events){var evlistener=this._events[type];if(isFunction(evlistener))return 1;if(evlistener)return evlistener.length}return 0},EventEmitter.listenerCount=function(emitter,type){return emitter.listenerCount(type)};function isFunction(arg){return"function"==typeof arg}function isObject(arg){return"object"==typeof arg&&null!==arg}function isUndefined(arg){return void 0===arg}},{}],123:[function(require,module,exports){var Buffer=require("safe-buffer").Buffer,MD5=require("md5.js");module.exports=function(password,salt,keyBits,ivLen){if(Buffer.isBuffer(password)||(password=Buffer.from(password,"binary")),salt&&(Buffer.isBuffer(salt)||(salt=Buffer.from(salt,"binary")),8!==salt.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var keyLen=keyBits/8,key=Buffer.alloc(keyLen),iv=Buffer.alloc(ivLen||0),tmp=Buffer.alloc(0);keyLen>0||ivLen>0;){var hash=new MD5;hash.update(tmp),hash.update(password),salt&&hash.update(salt),tmp=hash.digest();var used=0;if(keyLen>0){var keyStart=key.length-keyLen;used=Math.min(keyLen,tmp.length),tmp.copy(key,keyStart,0,used),keyLen-=used}if(used0){var ivStart=iv.length-ivLen,length=Math.min(ivLen,tmp.length-used);tmp.copy(iv,ivStart,used,used+length),ivLen-=length}}return tmp.fill(0),{key:key,iv:iv}}},{"md5.js":145,"safe-buffer":191}],124:[function(require,module,exports){(function(Buffer){"use strict";var Transform=require("stream").Transform;function HashBase(blockSize){Transform.call(this),this._block=new Buffer(blockSize),this._blockSize=blockSize,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}require("inherits")(HashBase,Transform),HashBase.prototype._transform=function(chunk,encoding,callback){var error=null;try{"buffer"!==encoding&&(chunk=new Buffer(chunk,encoding)),this.update(chunk)}catch(err){error=err}callback(error)},HashBase.prototype._flush=function(callback){var error=null;try{this.push(this._digest())}catch(err){error=err}callback(error)},HashBase.prototype.update=function(data,encoding){if(!Buffer.isBuffer(data)&&"string"!=typeof data)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");Buffer.isBuffer(data)||(data=new Buffer(data,encoding||"binary"));for(var block=this._block,offset=0;this._blockOffset+data.length-offset>=this._blockSize;){for(var i=this._blockOffset;i0;++j)this._length[j]+=carry,(carry=this._length[j]/4294967296|0)>0&&(this._length[j]-=4294967296*carry);return this},HashBase.prototype._update=function(data){throw new Error("_update is not implemented")},HashBase.prototype.digest=function(encoding){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var digest=this._digest();return void 0!==encoding&&(digest=digest.toString(encoding)),digest},HashBase.prototype._digest=function(){throw new Error("_digest is not implemented")},module.exports=HashBase}).call(this,require("buffer").Buffer)},{buffer:70,inherits:141,stream:200}],125:[function(require,module,exports){var hash=exports;hash.utils=require("./hash/utils"),hash.common=require("./hash/common"),hash.sha=require("./hash/sha"),hash.ripemd=require("./hash/ripemd"),hash.hmac=require("./hash/hmac"),hash.sha1=hash.sha.sha1,hash.sha256=hash.sha.sha256,hash.sha224=hash.sha.sha224,hash.sha384=hash.sha.sha384,hash.sha512=hash.sha.sha512,hash.ripemd160=hash.ripemd.ripemd160},{"./hash/common":126,"./hash/hmac":127,"./hash/ripemd":128,"./hash/sha":129,"./hash/utils":136}],126:[function(require,module,exports){"use strict";var utils=require("./utils"),assert=require("minimalistic-assert");function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}exports.BlockHash=BlockHash,BlockHash.prototype.update=function(msg,enc){if(msg=utils.toArray(msg,enc),this.pending?this.pending=this.pending.concat(msg):this.pending=msg,this.pendingTotal+=msg.length,this.pending.length>=this._delta8){var r=(msg=this.pending).length%this._delta8;this.pending=msg.slice(msg.length-r,msg.length),0===this.pending.length&&(this.pending=null),msg=utils.join32(msg,0,msg.length-r,this.endian);for(var i=0;i>>24&255,res[i++]=len>>>16&255,res[i++]=len>>>8&255,res[i++]=255&len}else for(res[i++]=255&len,res[i++]=len>>>8&255,res[i++]=len>>>16&255,res[i++]=len>>>24&255,res[i++]=0,res[i++]=0,res[i++]=0,res[i++]=0,t=8;tthis.blockSize&&(key=(new this.Hash).update(key).digest()),assert(key.length<=this.blockSize);for(var i=key.length;i>>3};exports.g1_256=function(x){return rotr32(x,17)^rotr32(x,19)^x>>>10}},{"../utils":136}],136:[function(require,module,exports){"use strict";var assert=require("minimalistic-assert"),inherits=require("inherits");exports.inherits=inherits;exports.toArray=function(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if("string"==typeof msg)if(enc){if("hex"===enc)for((msg=msg.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(msg="0"+msg),i=0;i>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}else for(i=0;i>>24|w>>>8&65280|w<<8&16711680|(255&w)<<24)>>>0}exports.htonl=htonl;exports.toHex32=function(msg,endian){for(var res="",i=0;i>>0}return res};exports.split32=function(msg,endian){for(var res=new Array(4*msg.length),i=0,k=0;i>>24,res[k+1]=m>>>16&255,res[k+2]=m>>>8&255,res[k+3]=255&m):(res[k+3]=m>>>24,res[k+2]=m>>>16&255,res[k+1]=m>>>8&255,res[k]=255&m)}return res};exports.rotr32=function(w,b){return w>>>b|w<<32-b};exports.rotl32=function(w,b){return w<>>32-b};exports.sum32=function(a,b){return a+b>>>0};exports.sum32_3=function(a,b,c){return a+b+c>>>0};exports.sum32_4=function(a,b,c,d){return a+b+c+d>>>0};exports.sum32_5=function(a,b,c,d,e){return a+b+c+d+e>>>0};exports.sum64=function(buf,pos,ah,al){var bh=buf[pos],lo=al+buf[pos+1]>>>0,hi=(lo>>0,buf[pos+1]=lo};exports.sum64_hi=function(ah,al,bh,bl){return(al+bl>>>0>>0};exports.sum64_lo=function(ah,al,bh,bl){return al+bl>>>0};exports.sum64_4_hi=function(ah,al,bh,bl,ch,cl,dh,dl){var carry=0,lo=al;return carry+=(lo=lo+bl>>>0)>>0)>>0)>>0};exports.sum64_4_lo=function(ah,al,bh,bl,ch,cl,dh,dl){return al+bl+cl+dl>>>0};exports.sum64_5_hi=function(ah,al,bh,bl,ch,cl,dh,dl,eh,el){var carry=0,lo=al;return carry+=(lo=lo+bl>>>0)>>0)>>0)>>0)>>0};exports.sum64_5_lo=function(ah,al,bh,bl,ch,cl,dh,dl,eh,el){return al+bl+cl+dl+el>>>0};exports.rotr64_hi=function(ah,al,num){return(al<<32-num|ah>>>num)>>>0};exports.rotr64_lo=function(ah,al,num){return(ah<<32-num|al>>>num)>>>0};exports.shr64_hi=function(ah,al,num){return ah>>>num};exports.shr64_lo=function(ah,al,num){return(ah<<32-num|al>>>num)>>>0}},{inherits:137,"minimalistic-assert":149}],137:[function(require,module,exports){"function"==typeof Object.create?module.exports=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}},{}],138:[function(require,module,exports){"use strict";var hash=require("hash.js"),utils=require("minimalistic-crypto-utils"),assert=require("minimalistic-assert");function HmacDRBG(options){if(!(this instanceof HmacDRBG))return new HmacDRBG(options);this.hash=options.hash,this.predResist=!!options.predResist,this.outLen=this.hash.outSize,this.minEntropy=options.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var entropy=utils.toArray(options.entropy,options.entropyEnc||"hex"),nonce=utils.toArray(options.nonce,options.nonceEnc||"hex"),pers=utils.toArray(options.pers,options.persEnc||"hex");assert(entropy.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(entropy,nonce,pers)}module.exports=HmacDRBG,HmacDRBG.prototype._init=function(entropy,nonce,pers){var seed=entropy.concat(nonce).concat(pers);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(entropy.concat(add||[])),this._reseed=1},HmacDRBG.prototype.generate=function(len,enc,add,addEnc){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof enc&&(addEnc=add,add=enc,enc=null),add&&(add=utils.toArray(add,addEnc||"hex"),this._update(add));for(var temp=[];temp.length>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];for(i+=d,e=s&(1<<-nBits)-1,s>>=-nBits,nBits+=eLen;nBits>0;e=256*e+buffer[offset+i],i+=d,nBits-=8);for(m=e&(1<<-nBits)-1,e>>=-nBits,nBits+=mLen;nBits>0;m=256*m+buffer[offset+i],i+=d,nBits-=8);if(0===e)e=1-eBias;else{if(e===eMax)return m?NaN:1/0*(s?-1:1);m+=Math.pow(2,mLen),e-=eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)},exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=8*nBytes-mLen-1,eMax=(1<>1,rt=23===mLen?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||0===value&&1/value<0?1:0;for(value=Math.abs(value),isNaN(value)||value===1/0?(m=isNaN(value)?1:0,e=eMax):(e=Math.floor(Math.log(value)/Math.LN2),value*(c=Math.pow(2,-e))<1&&(e--,c*=2),(value+=e+eBias>=1?rt/c:rt*Math.pow(2,1-eBias))*c>=2&&(e++,c/=2),e+eBias>=eMax?(m=0,e=eMax):e+eBias>=1?(m=(value*c-1)*Math.pow(2,mLen),e+=eBias):(m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen),e=0));mLen>=8;buffer[offset+i]=255&m,i+=d,m/=256,mLen-=8);for(e=e<0;buffer[offset+i]=255&e,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=128*s}},{}],140:[function(require,module,exports){var indexOf=[].indexOf;module.exports=function(arr,obj){if(indexOf)return arr.indexOf(obj);for(var i=0;i - * @license MIT - */ -module.exports=function(obj){return null!=obj&&(isBuffer(obj)||function(obj){return"function"==typeof obj.readFloatLE&&"function"==typeof obj.slice&&isBuffer(obj.slice(0,0))}(obj)||!!obj._isBuffer)};function isBuffer(obj){return!!obj.constructor&&"function"==typeof obj.constructor.isBuffer&&obj.constructor.isBuffer(obj)}},{}],143:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return"[object Array]"==toString.call(arr)}},{}],144:[function(require,module,exports){(function(global){(function(){var undefined,LARGE_ARRAY_SIZE=200,CORE_ERROR_TEXT="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",FUNC_ERROR_TEXT="Expected a function",HASH_UNDEFINED="__lodash_hash_undefined__",MAX_MEMOIZE_SIZE=500,PLACEHOLDER="__lodash_placeholder__",CLONE_DEEP_FLAG=1,CLONE_FLAT_FLAG=2,CLONE_SYMBOLS_FLAG=4,COMPARE_PARTIAL_FLAG=1,COMPARE_UNORDERED_FLAG=2,WRAP_BIND_FLAG=1,WRAP_BIND_KEY_FLAG=2,WRAP_CURRY_BOUND_FLAG=4,WRAP_CURRY_FLAG=8,WRAP_CURRY_RIGHT_FLAG=16,WRAP_PARTIAL_FLAG=32,WRAP_PARTIAL_RIGHT_FLAG=64,WRAP_ARY_FLAG=128,WRAP_REARG_FLAG=256,WRAP_FLIP_FLAG=512,DEFAULT_TRUNC_LENGTH=30,DEFAULT_TRUNC_OMISSION="...",HOT_COUNT=800,HOT_SPAN=16,LAZY_FILTER_FLAG=1,LAZY_MAP_FLAG=2,INFINITY=1/0,MAX_SAFE_INTEGER=9007199254740991,MAX_INTEGER=1.7976931348623157e308,NAN=NaN,MAX_ARRAY_LENGTH=4294967295,MAX_ARRAY_INDEX=MAX_ARRAY_LENGTH-1,HALF_MAX_ARRAY_LENGTH=MAX_ARRAY_LENGTH>>>1,wrapFlags=[["ary",WRAP_ARY_FLAG],["bind",WRAP_BIND_FLAG],["bindKey",WRAP_BIND_KEY_FLAG],["curry",WRAP_CURRY_FLAG],["curryRight",WRAP_CURRY_RIGHT_FLAG],["flip",WRAP_FLIP_FLAG],["partial",WRAP_PARTIAL_FLAG],["partialRight",WRAP_PARTIAL_RIGHT_FLAG],["rearg",WRAP_REARG_FLAG]],argsTag="[object Arguments]",arrayTag="[object Array]",asyncTag="[object AsyncFunction]",boolTag="[object Boolean]",dateTag="[object Date]",domExcTag="[object DOMException]",errorTag="[object Error]",funcTag="[object Function]",genTag="[object GeneratorFunction]",mapTag="[object Map]",numberTag="[object Number]",nullTag="[object Null]",objectTag="[object Object]",proxyTag="[object Proxy]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",symbolTag="[object Symbol]",undefinedTag="[object Undefined]",weakMapTag="[object WeakMap]",weakSetTag="[object WeakSet]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",reEmptyStringLeading=/\b__p \+= '';/g,reEmptyStringMiddle=/\b(__p \+=) '' \+/g,reEmptyStringTrailing=/(__e\(.*?\)|\b__t\)) \+\n'';/g,reEscapedHtml=/&(?:amp|lt|gt|quot|#39);/g,reUnescapedHtml=/[&<>"']/g,reHasEscapedHtml=RegExp(reEscapedHtml.source),reHasUnescapedHtml=RegExp(reUnescapedHtml.source),reEscape=/<%-([\s\S]+?)%>/g,reEvaluate=/<%([\s\S]+?)%>/g,reInterpolate=/<%=([\s\S]+?)%>/g,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/,reLeadingDot=/^\./,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reHasRegExpChar=RegExp(reRegExpChar.source),reTrim=/^\s+|\s+$/g,reTrimStart=/^\s+/,reTrimEnd=/\s+$/,reWrapComment=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,reWrapDetails=/\{\n\/\* \[wrapped with (.+)\] \*/,reSplitDetails=/,? & /,reAsciiWord=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,reEscapeChar=/\\(\\)?/g,reEsTemplate=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,reFlags=/\w*$/,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsHostCtor=/^\[object .+?Constructor\]$/,reIsOctal=/^0o[0-7]+$/i,reIsUint=/^(?:0|[1-9]\d*)$/,reLatin=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,reNoMatch=/($^)/,reUnescapedString=/['\n\r\u2028\u2029\\]/g,rsComboRange="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",rsBreakRange="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",rsAstral="[\\ud800-\\udfff]",rsBreak="["+rsBreakRange+"]",rsCombo="["+rsComboRange+"]",rsDigits="\\d+",rsDingbat="[\\u2700-\\u27bf]",rsLower="[a-z\\xdf-\\xf6\\xf8-\\xff]",rsMisc="[^\\ud800-\\udfff"+rsBreakRange+rsDigits+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",rsFitz="\\ud83c[\\udffb-\\udfff]",rsNonAstral="[^\\ud800-\\udfff]",rsRegional="(?:\\ud83c[\\udde6-\\uddff]){2}",rsSurrPair="[\\ud800-\\udbff][\\udc00-\\udfff]",rsUpper="[A-Z\\xc0-\\xd6\\xd8-\\xde]",rsMiscLower="(?:"+rsLower+"|"+rsMisc+")",rsMiscUpper="(?:"+rsUpper+"|"+rsMisc+")",reOptMod="(?:"+rsCombo+"|"+rsFitz+")"+"?",rsSeq="[\\ufe0e\\ufe0f]?"+reOptMod+("(?:\\u200d(?:"+[rsNonAstral,rsRegional,rsSurrPair].join("|")+")[\\ufe0e\\ufe0f]?"+reOptMod+")*"),rsEmoji="(?:"+[rsDingbat,rsRegional,rsSurrPair].join("|")+")"+rsSeq,rsSymbol="(?:"+[rsNonAstral+rsCombo+"?",rsCombo,rsRegional,rsSurrPair,rsAstral].join("|")+")",reApos=RegExp("['’]","g"),reComboMark=RegExp(rsCombo,"g"),reUnicode=RegExp(rsFitz+"(?="+rsFitz+")|"+rsSymbol+rsSeq,"g"),reUnicodeWord=RegExp([rsUpper+"?"+rsLower+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[rsBreak,rsUpper,"$"].join("|")+")",rsMiscUpper+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[rsBreak,rsUpper+rsMiscLower,"$"].join("|")+")",rsUpper+"?"+rsMiscLower+"+(?:['’](?:d|ll|m|re|s|t|ve))?",rsUpper+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",rsDigits,rsEmoji].join("|"),"g"),reHasUnicode=RegExp("[\\u200d\\ud800-\\udfff"+rsComboRange+"\\ufe0e\\ufe0f]"),reHasUnicodeWord=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,contextProps=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],templateCounter=-1,typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var cloneableTags={};cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[dataViewTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[mapTag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[setTag]=cloneableTags[stringTag]=cloneableTags[symbolTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=!0,cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[weakMapTag]=!1;var stringEscapes={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},freeParseFloat=parseFloat,freeParseInt=parseInt,freeGlobal="object"==typeof global&&global&&global.Object===Object&&global,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,freeProcess=moduleExports&&freeGlobal.process,nodeUtil=function(){try{return freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}(),nodeIsArrayBuffer=nodeUtil&&nodeUtil.isArrayBuffer,nodeIsDate=nodeUtil&&nodeUtil.isDate,nodeIsMap=nodeUtil&&nodeUtil.isMap,nodeIsRegExp=nodeUtil&&nodeUtil.isRegExp,nodeIsSet=nodeUtil&&nodeUtil.isSet,nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray;function addMapEntry(map,pair){return map.set(pair[0],pair[1]),map}function addSetEntry(set,value){return set.add(value),set}function apply(func,thisArg,args){switch(args.length){case 0:return func.call(thisArg);case 1:return func.call(thisArg,args[0]);case 2:return func.call(thisArg,args[0],args[1]);case 3:return func.call(thisArg,args[0],args[1],args[2])}return func.apply(thisArg,args)}function arrayAggregator(array,setter,iteratee,accumulator){for(var index=-1,length=null==array?0:array.length;++index-1}function arrayIncludesWith(array,value,comparator){for(var index=-1,length=null==array?0:array.length;++index-1;);return index}function charsEndIndex(strSymbols,chrSymbols){for(var index=strSymbols.length;index--&&baseIndexOf(chrSymbols,strSymbols[index],0)>-1;);return index}var deburrLetter=basePropertyOf({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),escapeHtmlChar=basePropertyOf({"&":"&","<":"<",">":">",'"':""","'":"'"});function escapeStringChar(chr){return"\\"+stringEscapes[chr]}function hasUnicode(string){return reHasUnicode.test(string)}function mapToArray(map){var index=-1,result=Array(map.size);return map.forEach(function(value,key){result[++index]=[key,value]}),result}function overArg(func,transform){return function(arg){return func(transform(arg))}}function replaceHolders(array,placeholder){for(var index=-1,length=array.length,resIndex=0,result=[];++index",""":'"',"'":"'"});var _=function runInContext(context){var Array=(context=null==context?root:_.defaults(root.Object(),context,_.pick(root,contextProps))).Array,Date=context.Date,Error=context.Error,Function=context.Function,Math=context.Math,Object=context.Object,RegExp=context.RegExp,String=context.String,TypeError=context.TypeError,arrayProto=Array.prototype,funcProto=Function.prototype,objectProto=Object.prototype,coreJsData=context["__core-js_shared__"],funcToString=funcProto.toString,hasOwnProperty=objectProto.hasOwnProperty,idCounter=0,maskSrcKey=function(){var uid=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return uid?"Symbol(src)_1."+uid:""}(),nativeObjectToString=objectProto.toString,objectCtorString=funcToString.call(Object),oldDash=root._,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=moduleExports?context.Buffer:undefined,Symbol=context.Symbol,Uint8Array=context.Uint8Array,allocUnsafe=Buffer?Buffer.allocUnsafe:undefined,getPrototype=overArg(Object.getPrototypeOf,Object),objectCreate=Object.create,propertyIsEnumerable=objectProto.propertyIsEnumerable,splice=arrayProto.splice,spreadableSymbol=Symbol?Symbol.isConcatSpreadable:undefined,symIterator=Symbol?Symbol.iterator:undefined,symToStringTag=Symbol?Symbol.toStringTag:undefined,defineProperty=function(){try{var func=getNative(Object,"defineProperty");return func({},"",{}),func}catch(e){}}(),ctxClearTimeout=context.clearTimeout!==root.clearTimeout&&context.clearTimeout,ctxNow=Date&&Date.now!==root.Date.now&&Date.now,ctxSetTimeout=context.setTimeout!==root.setTimeout&&context.setTimeout,nativeCeil=Math.ceil,nativeFloor=Math.floor,nativeGetSymbols=Object.getOwnPropertySymbols,nativeIsBuffer=Buffer?Buffer.isBuffer:undefined,nativeIsFinite=context.isFinite,nativeJoin=arrayProto.join,nativeKeys=overArg(Object.keys,Object),nativeMax=Math.max,nativeMin=Math.min,nativeNow=Date.now,nativeParseInt=context.parseInt,nativeRandom=Math.random,nativeReverse=arrayProto.reverse,DataView=getNative(context,"DataView"),Map=getNative(context,"Map"),Promise=getNative(context,"Promise"),Set=getNative(context,"Set"),WeakMap=getNative(context,"WeakMap"),nativeCreate=getNative(Object,"create"),metaMap=WeakMap&&new WeakMap,realNames={},dataViewCtorString=toSource(DataView),mapCtorString=toSource(Map),promiseCtorString=toSource(Promise),setCtorString=toSource(Set),weakMapCtorString=toSource(WeakMap),symbolProto=Symbol?Symbol.prototype:undefined,symbolValueOf=symbolProto?symbolProto.valueOf:undefined,symbolToString=symbolProto?symbolProto.toString:undefined;function lodash(value){if(isObjectLike(value)&&!isArray(value)&&!(value instanceof LazyWrapper)){if(value instanceof LodashWrapper)return value;if(hasOwnProperty.call(value,"__wrapped__"))return wrapperClone(value)}return new LodashWrapper(value)}var baseCreate=function(){function object(){}return function(proto){if(!isObject(proto))return{};if(objectCreate)return objectCreate(proto);object.prototype=proto;var result=new object;return object.prototype=undefined,result}}();function baseLodash(){}function LodashWrapper(value,chainAll){this.__wrapped__=value,this.__actions__=[],this.__chain__=!!chainAll,this.__index__=0,this.__values__=undefined}lodash.templateSettings={escape:reEscape,evaluate:reEvaluate,interpolate:reInterpolate,variable:"",imports:{_:lodash}},lodash.prototype=baseLodash.prototype,lodash.prototype.constructor=lodash,LodashWrapper.prototype=baseCreate(baseLodash.prototype),LodashWrapper.prototype.constructor=LodashWrapper;function LazyWrapper(value){this.__wrapped__=value,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=MAX_ARRAY_LENGTH,this.__views__=[]}LazyWrapper.prototype=baseCreate(baseLodash.prototype),LazyWrapper.prototype.constructor=LazyWrapper;function Hash(entries){var index=-1,length=null==entries?0:entries.length;for(this.clear();++index-1},ListCache.prototype.set=function(key,value){var data=this.__data__,index=assocIndexOf(data,key);return index<0?(++this.size,data.push([key,value])):data[index][1]=value,this};function MapCache(entries){var index=-1,length=null==entries?0:entries.length;for(this.clear();++index=lower?number:lower)),number}function baseClone(value,bitmask,customizer,key,object,stack){var result,isDeep=bitmask&CLONE_DEEP_FLAG,isFlat=bitmask&CLONE_FLAT_FLAG,isFull=bitmask&CLONE_SYMBOLS_FLAG;if(customizer&&(result=object?customizer(value,key,object,stack):customizer(value)),result!==undefined)return result;if(!isObject(value))return value;var isArr=isArray(value);if(isArr){if(result=function(array){var length=array.length,result=array.constructor(length);return length&&"string"==typeof array[0]&&hasOwnProperty.call(array,"index")&&(result.index=array.index,result.input=array.input),result}(value),!isDeep)return copyArray(value,result)}else{var tag=getTag(value),isFunc=tag==funcTag||tag==genTag;if(isBuffer(value))return cloneBuffer(value,isDeep);if(tag==objectTag||tag==argsTag||isFunc&&!object){if(result=isFlat||isFunc?{}:initCloneObject(value),!isDeep)return isFlat?function(source,object){return copyObject(source,getSymbolsIn(source),object)}(value,function(object,source){return object&©Object(source,keysIn(source),object)}(result,value)):function(source,object){return copyObject(source,getSymbols(source),object)}(value,baseAssign(result,value))}else{if(!cloneableTags[tag])return object?value:{};result=function(object,tag,cloneFunc,isDeep){var Ctor=object.constructor;switch(tag){case arrayBufferTag:return cloneArrayBuffer(object);case boolTag:case dateTag:return new Ctor(+object);case dataViewTag:return function(dataView,isDeep){var buffer=isDeep?cloneArrayBuffer(dataView.buffer):dataView.buffer;return new dataView.constructor(buffer,dataView.byteOffset,dataView.byteLength)}(object,isDeep);case float32Tag:case float64Tag:case int8Tag:case int16Tag:case int32Tag:case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag:return cloneTypedArray(object,isDeep);case mapTag:return function(map,isDeep,cloneFunc){return arrayReduce(isDeep?cloneFunc(mapToArray(map),CLONE_DEEP_FLAG):mapToArray(map),addMapEntry,new map.constructor)}(object,isDeep,cloneFunc);case numberTag:case stringTag:return new Ctor(object);case regexpTag:return function(regexp){var result=new regexp.constructor(regexp.source,reFlags.exec(regexp));return result.lastIndex=regexp.lastIndex,result}(object);case setTag:return function(set,isDeep,cloneFunc){return arrayReduce(isDeep?cloneFunc(setToArray(set),CLONE_DEEP_FLAG):setToArray(set),addSetEntry,new set.constructor)}(object,isDeep,cloneFunc);case symbolTag:return symbol=object,symbolValueOf?Object(symbolValueOf.call(symbol)):{}}var symbol}(value,tag,baseClone,isDeep)}}stack||(stack=new Stack);var stacked=stack.get(value);if(stacked)return stacked;stack.set(value,result);var props=isArr?undefined:(isFull?isFlat?getAllKeysIn:getAllKeys:isFlat?keysIn:keys)(value);return arrayEach(props||value,function(subValue,key){props&&(subValue=value[key=subValue]),assignValue(result,key,baseClone(subValue,bitmask,customizer,key,value,stack))}),result}function baseConformsTo(object,source,props){var length=props.length;if(null==object)return!length;for(object=Object(object);length--;){var key=props[length],predicate=source[key],value=object[key];if(value===undefined&&!(key in object)||!predicate(value))return!1}return!0}function baseDelay(func,wait,args){if("function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return setTimeout(function(){func.apply(undefined,args)},wait)}function baseDifference(array,values,iteratee,comparator){var index=-1,includes=arrayIncludes,isCommon=!0,length=array.length,result=[],valuesLength=values.length;if(!length)return result;iteratee&&(values=arrayMap(values,baseUnary(iteratee))),comparator?(includes=arrayIncludesWith,isCommon=!1):values.length>=LARGE_ARRAY_SIZE&&(includes=cacheHas,isCommon=!1,values=new SetCache(values));outer:for(;++index0&&predicate(value)?depth>1?baseFlatten(value,depth-1,predicate,isStrict,result):arrayPush(result,value):isStrict||(result[result.length]=value)}return result}var baseFor=createBaseFor(),baseForRight=createBaseFor(!0);function baseForOwn(object,iteratee){return object&&baseFor(object,iteratee,keys)}function baseForOwnRight(object,iteratee){return object&&baseForRight(object,iteratee,keys)}function baseFunctions(object,props){return arrayFilter(props,function(key){return isFunction(object[key])})}function baseGet(object,path){for(var index=0,length=(path=castPath(path,object)).length;null!=object&&indexother}function baseHas(object,key){return null!=object&&hasOwnProperty.call(object,key)}function baseHasIn(object,key){return null!=object&&key in Object(object)}function baseIntersection(arrays,iteratee,comparator){for(var includes=comparator?arrayIncludesWith:arrayIncludes,length=arrays[0].length,othLength=arrays.length,othIndex=othLength,caches=Array(othLength),maxLength=1/0,result=[];othIndex--;){var array=arrays[othIndex];othIndex&&iteratee&&(array=arrayMap(array,baseUnary(iteratee))),maxLength=nativeMin(array.length,maxLength),caches[othIndex]=!comparator&&(iteratee||length>=120&&array.length>=120)?new SetCache(othIndex&&array):undefined}array=arrays[0];var index=-1,seen=caches[0];outer:for(;++index=ordersLength)return result;var order=orders[index];return result*("desc"==order?-1:1)}}return object.index-other.index}(object,other,orders)})}function basePickBy(object,paths,predicate){for(var index=-1,length=paths.length,result={};++index-1;)seen!==array&&splice.call(seen,fromIndex,1),splice.call(array,fromIndex,1);return array}function basePullAt(array,indexes){for(var length=array?indexes.length:0,lastIndex=length-1;length--;){var index=indexes[length];if(length==lastIndex||index!==previous){var previous=index;isIndex(index)?splice.call(array,index,1):baseUnset(array,index)}}return array}function baseRandom(lower,upper){return lower+nativeFloor(nativeRandom()*(upper-lower+1))}function baseRepeat(string,n){var result="";if(!string||n<1||n>MAX_SAFE_INTEGER)return result;do{n%2&&(result+=string),(n=nativeFloor(n/2))&&(string+=string)}while(n);return result}function baseRest(func,start){return setToString(overRest(func,start,identity),func+"")}function baseSample(collection){return arraySample(values(collection))}function baseSampleSize(collection,n){var array=values(collection);return shuffleSelf(array,baseClamp(n,0,array.length))}function baseSet(object,path,value,customizer){if(!isObject(object))return object;for(var index=-1,length=(path=castPath(path,object)).length,lastIndex=length-1,nested=object;null!=nested&&++indexlength?0:length+start),(end=end>length?length:end)<0&&(end+=length),length=start>end?0:end-start>>>0,start>>>=0;for(var result=Array(length);++index>>1,computed=array[mid];null!==computed&&!isSymbol(computed)&&(retHighest?computed<=value:computed=LARGE_ARRAY_SIZE){var set=iteratee?null:createSet(array);if(set)return setToArray(set);isCommon=!1,includes=cacheHas,seen=new SetCache}else seen=iteratee?[]:result;outer:for(;++index=length?array:baseSlice(array,start,end)}var clearTimeout=ctxClearTimeout||function(id){return root.clearTimeout(id)};function cloneBuffer(buffer,isDeep){if(isDeep)return buffer.slice();var length=buffer.length,result=allocUnsafe?allocUnsafe(length):new buffer.constructor(length);return buffer.copy(result),result}function cloneArrayBuffer(arrayBuffer){var result=new arrayBuffer.constructor(arrayBuffer.byteLength);return new Uint8Array(result).set(new Uint8Array(arrayBuffer)),result}function cloneTypedArray(typedArray,isDeep){var buffer=isDeep?cloneArrayBuffer(typedArray.buffer):typedArray.buffer;return new typedArray.constructor(buffer,typedArray.byteOffset,typedArray.length)}function compareAscending(value,other){if(value!==other){var valIsDefined=value!==undefined,valIsNull=null===value,valIsReflexive=value==value,valIsSymbol=isSymbol(value),othIsDefined=other!==undefined,othIsNull=null===other,othIsReflexive=other==other,othIsSymbol=isSymbol(other);if(!othIsNull&&!othIsSymbol&&!valIsSymbol&&value>other||valIsSymbol&&othIsDefined&&othIsReflexive&&!othIsNull&&!othIsSymbol||valIsNull&&othIsDefined&&othIsReflexive||!valIsDefined&&othIsReflexive||!valIsReflexive)return 1;if(!valIsNull&&!valIsSymbol&&!othIsSymbol&&value1?sources[length-1]:undefined,guard=length>2?sources[2]:undefined;for(customizer=assigner.length>3&&"function"==typeof customizer?(length--,customizer):undefined,guard&&isIterateeCall(sources[0],sources[1],guard)&&(customizer=length<3?undefined:customizer,length=1),object=Object(object);++index-1?iterable[iteratee?collection[index]:index]:undefined}}function createFlow(fromRight){return flatRest(function(funcs){var length=funcs.length,index=length,prereq=LodashWrapper.prototype.thru;for(fromRight&&funcs.reverse();index--;){var func=funcs[index];if("function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);if(prereq&&!wrapper&&"wrapper"==getFuncName(func))var wrapper=new LodashWrapper([],!0)}for(index=wrapper?index:length;++index1&&args.reverse(),isAry&&aryarrLength))return!1;var stacked=stack.get(array);if(stacked&&stack.get(other))return stacked==other;var index=-1,result=!0,seen=bitmask&COMPARE_UNORDERED_FLAG?new SetCache:undefined;for(stack.set(array,other),stack.set(other,array);++index-1&&value%1==0&&value1?"& ":"")+details[lastIndex],details=details.join(length>2?", ":" "),source.replace(reWrapComment,"{\n/* [wrapped with "+details+"] */\n")}(source,function(details,bitmask){return arrayEach(wrapFlags,function(pair){var value="_."+pair[0];bitmask&pair[1]&&!arrayIncludes(details,value)&&details.push(value)}),details.sort()}(function(source){var match=source.match(reWrapDetails);return match?match[1].split(reSplitDetails):[]}(source),bitmask)))}function shortOut(func){var count=0,lastCalled=0;return function(){var stamp=nativeNow(),remaining=HOT_SPAN-(stamp-lastCalled);if(lastCalled=stamp,remaining>0){if(++count>=HOT_COUNT)return arguments[0]}else count=0;return func.apply(undefined,arguments)}}function shuffleSelf(array,size){var index=-1,length=array.length,lastIndex=length-1;for(size=size===undefined?length:size;++index1?arrays[length-1]:undefined;return unzipWith(arrays,iteratee="function"==typeof iteratee?(arrays.pop(),iteratee):undefined)});function chain(value){var result=lodash(value);return result.__chain__=!0,result}function thru(value,interceptor){return interceptor(value)}var wrapperAt=flatRest(function(paths){var length=paths.length,start=length?paths[0]:0,value=this.__wrapped__,interceptor=function(object){return baseAt(object,paths)};return!(length>1||this.__actions__.length)&&value instanceof LazyWrapper&&isIndex(start)?((value=value.slice(start,+start+(length?1:0))).__actions__.push({func:thru,args:[interceptor],thisArg:undefined}),new LodashWrapper(value,this.__chain__).thru(function(array){return length&&!array.length&&array.push(undefined),array})):this.thru(interceptor)});var countBy=createAggregator(function(result,value,key){hasOwnProperty.call(result,key)?++result[key]:baseAssignValue(result,key,1)});var find=createFind(findIndex),findLast=createFind(findLastIndex);function forEach(collection,iteratee){return(isArray(collection)?arrayEach:baseEach)(collection,getIteratee(iteratee,3))}function forEachRight(collection,iteratee){return(isArray(collection)?arrayEachRight:baseEachRight)(collection,getIteratee(iteratee,3))}var groupBy=createAggregator(function(result,value,key){hasOwnProperty.call(result,key)?result[key].push(value):baseAssignValue(result,key,[value])});var invokeMap=baseRest(function(collection,path,args){var index=-1,isFunc="function"==typeof path,result=isArrayLike(collection)?Array(collection.length):[];return baseEach(collection,function(value){result[++index]=isFunc?apply(path,value,args):baseInvoke(value,path,args)}),result}),keyBy=createAggregator(function(result,value,key){baseAssignValue(result,key,value)});function map(collection,iteratee){return(isArray(collection)?arrayMap:baseMap)(collection,getIteratee(iteratee,3))}var partition=createAggregator(function(result,value,key){result[key?0:1].push(value)},function(){return[[],[]]});var sortBy=baseRest(function(collection,iteratees){if(null==collection)return[];var length=iteratees.length;return length>1&&isIterateeCall(collection,iteratees[0],iteratees[1])?iteratees=[]:length>2&&isIterateeCall(iteratees[0],iteratees[1],iteratees[2])&&(iteratees=[iteratees[0]]),baseOrderBy(collection,baseFlatten(iteratees,1),[])}),now=ctxNow||function(){return root.Date.now()};function ary(func,n,guard){return n=guard?undefined:n,n=func&&null==n?func.length:n,createWrap(func,WRAP_ARY_FLAG,undefined,undefined,undefined,undefined,n)}function before(n,func){var result;if("function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return n=toInteger(n),function(){return--n>0&&(result=func.apply(this,arguments)),n<=1&&(func=undefined),result}}var bind=baseRest(function(func,thisArg,partials){var bitmask=WRAP_BIND_FLAG;if(partials.length){var holders=replaceHolders(partials,getHolder(bind));bitmask|=WRAP_PARTIAL_FLAG}return createWrap(func,bitmask,thisArg,partials,holders)}),bindKey=baseRest(function(object,key,partials){var bitmask=WRAP_BIND_FLAG|WRAP_BIND_KEY_FLAG;if(partials.length){var holders=replaceHolders(partials,getHolder(bindKey));bitmask|=WRAP_PARTIAL_FLAG}return createWrap(key,bitmask,object,partials,holders)});function debounce(func,wait,options){var lastArgs,lastThis,maxWait,result,timerId,lastCallTime,lastInvokeTime=0,leading=!1,maxing=!1,trailing=!0;if("function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);wait=toNumber(wait)||0,isObject(options)&&(leading=!!options.leading,maxWait=(maxing="maxWait"in options)?nativeMax(toNumber(options.maxWait)||0,wait):maxWait,trailing="trailing"in options?!!options.trailing:trailing);function invokeFunc(time){var args=lastArgs,thisArg=lastThis;return lastArgs=lastThis=undefined,lastInvokeTime=time,result=func.apply(thisArg,args)}function shouldInvoke(time){var timeSinceLastCall=time-lastCallTime;return lastCallTime===undefined||timeSinceLastCall>=wait||timeSinceLastCall<0||maxing&&time-lastInvokeTime>=maxWait}function timerExpired(){var time=now();if(shouldInvoke(time))return trailingEdge(time);timerId=setTimeout(timerExpired,function(time){var result=wait-(time-lastCallTime);return maxing?nativeMin(result,maxWait-(time-lastInvokeTime)):result}(time))}function trailingEdge(time){return timerId=undefined,trailing&&lastArgs?invokeFunc(time):(lastArgs=lastThis=undefined,result)}function debounced(){var time=now(),isInvoking=shouldInvoke(time);if(lastArgs=arguments,lastThis=this,lastCallTime=time,isInvoking){if(timerId===undefined)return function(time){return lastInvokeTime=time,timerId=setTimeout(timerExpired,wait),leading?invokeFunc(time):result}(lastCallTime);if(maxing)return timerId=setTimeout(timerExpired,wait),invokeFunc(lastCallTime)}return timerId===undefined&&(timerId=setTimeout(timerExpired,wait)),result}return debounced.cancel=function(){timerId!==undefined&&clearTimeout(timerId),lastInvokeTime=0,lastArgs=lastCallTime=lastThis=timerId=undefined},debounced.flush=function(){return timerId===undefined?result:trailingEdge(now())},debounced}var defer=baseRest(function(func,args){return baseDelay(func,1,args)}),delay=baseRest(function(func,wait,args){return baseDelay(func,toNumber(wait)||0,args)});function memoize(func,resolver){if("function"!=typeof func||null!=resolver&&"function"!=typeof resolver)throw new TypeError(FUNC_ERROR_TEXT);var memoized=function(){var args=arguments,key=resolver?resolver.apply(this,args):args[0],cache=memoized.cache;if(cache.has(key))return cache.get(key);var result=func.apply(this,args);return memoized.cache=cache.set(key,result)||cache,result};return memoized.cache=new(memoize.Cache||MapCache),memoized}memoize.Cache=MapCache;function negate(predicate){if("function"!=typeof predicate)throw new TypeError(FUNC_ERROR_TEXT);return function(){var args=arguments;switch(args.length){case 0:return!predicate.call(this);case 1:return!predicate.call(this,args[0]);case 2:return!predicate.call(this,args[0],args[1]);case 3:return!predicate.call(this,args[0],args[1],args[2])}return!predicate.apply(this,args)}}var overArgs=castRest(function(func,transforms){var funcsLength=(transforms=1==transforms.length&&isArray(transforms[0])?arrayMap(transforms[0],baseUnary(getIteratee())):arrayMap(baseFlatten(transforms,1),baseUnary(getIteratee()))).length;return baseRest(function(args){for(var index=-1,length=nativeMin(args.length,funcsLength);++index=other}),isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(value){return isObjectLike(value)&&hasOwnProperty.call(value,"callee")&&!propertyIsEnumerable.call(value,"callee")},isArray=Array.isArray,isArrayBuffer=nodeIsArrayBuffer?baseUnary(nodeIsArrayBuffer):function(value){return isObjectLike(value)&&baseGetTag(value)==arrayBufferTag};function isArrayLike(value){return null!=value&&isLength(value.length)&&!isFunction(value)}function isArrayLikeObject(value){return isObjectLike(value)&&isArrayLike(value)}var isBuffer=nativeIsBuffer||stubFalse,isDate=nodeIsDate?baseUnary(nodeIsDate):function(value){return isObjectLike(value)&&baseGetTag(value)==dateTag};function isError(value){if(!isObjectLike(value))return!1;var tag=baseGetTag(value);return tag==errorTag||tag==domExcTag||"string"==typeof value.message&&"string"==typeof value.name&&!isPlainObject(value)}function isFunction(value){if(!isObject(value))return!1;var tag=baseGetTag(value);return tag==funcTag||tag==genTag||tag==asyncTag||tag==proxyTag}function isInteger(value){return"number"==typeof value&&value==toInteger(value)}function isLength(value){return"number"==typeof value&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isObject(value){var type=typeof value;return null!=value&&("object"==type||"function"==type)}function isObjectLike(value){return null!=value&&"object"==typeof value}var isMap=nodeIsMap?baseUnary(nodeIsMap):function(value){return isObjectLike(value)&&getTag(value)==mapTag};function isNumber(value){return"number"==typeof value||isObjectLike(value)&&baseGetTag(value)==numberTag}function isPlainObject(value){if(!isObjectLike(value)||baseGetTag(value)!=objectTag)return!1;var proto=getPrototype(value);if(null===proto)return!0;var Ctor=hasOwnProperty.call(proto,"constructor")&&proto.constructor;return"function"==typeof Ctor&&Ctor instanceof Ctor&&funcToString.call(Ctor)==objectCtorString}var isRegExp=nodeIsRegExp?baseUnary(nodeIsRegExp):function(value){return isObjectLike(value)&&baseGetTag(value)==regexpTag};var isSet=nodeIsSet?baseUnary(nodeIsSet):function(value){return isObjectLike(value)&&getTag(value)==setTag};function isString(value){return"string"==typeof value||!isArray(value)&&isObjectLike(value)&&baseGetTag(value)==stringTag}function isSymbol(value){return"symbol"==typeof value||isObjectLike(value)&&baseGetTag(value)==symbolTag}var isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):function(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[baseGetTag(value)]};var lt=createRelationalOperation(baseLt),lte=createRelationalOperation(function(value,other){return value<=other});function toArray(value){if(!value)return[];if(isArrayLike(value))return isString(value)?stringToArray(value):copyArray(value);if(symIterator&&value[symIterator])return function(iterator){for(var data,result=[];!(data=iterator.next()).done;)result.push(data.value);return result}(value[symIterator]());var tag=getTag(value);return(tag==mapTag?mapToArray:tag==setTag?setToArray:values)(value)}function toFinite(value){return value?(value=toNumber(value))===INFINITY||value===-INFINITY?(value<0?-1:1)*MAX_INTEGER:value==value?value:0:0===value?value:0}function toInteger(value){var result=toFinite(value),remainder=result%1;return result==result?remainder?result-remainder:result:0}function toLength(value){return value?baseClamp(toInteger(value),0,MAX_ARRAY_LENGTH):0}function toNumber(value){if("number"==typeof value)return value;if(isSymbol(value))return NAN;if(isObject(value)){var other="function"==typeof value.valueOf?value.valueOf():value;value=isObject(other)?other+"":other}if("string"!=typeof value)return 0===value?value:+value;value=value.replace(reTrim,"");var isBinary=reIsBinary.test(value);return isBinary||reIsOctal.test(value)?freeParseInt(value.slice(2),isBinary?2:8):reIsBadHex.test(value)?NAN:+value}function toPlainObject(value){return copyObject(value,keysIn(value))}function toString(value){return null==value?"":baseToString(value)}var assign=createAssigner(function(object,source){if(isPrototype(source)||isArrayLike(source))copyObject(source,keys(source),object);else for(var key in source)hasOwnProperty.call(source,key)&&assignValue(object,key,source[key])}),assignIn=createAssigner(function(object,source){copyObject(source,keysIn(source),object)}),assignInWith=createAssigner(function(object,source,srcIndex,customizer){copyObject(source,keysIn(source),object,customizer)}),assignWith=createAssigner(function(object,source,srcIndex,customizer){copyObject(source,keys(source),object,customizer)}),at=flatRest(baseAt);var defaults=baseRest(function(args){return args.push(undefined,customDefaultsAssignIn),apply(assignInWith,undefined,args)}),defaultsDeep=baseRest(function(args){return args.push(undefined,customDefaultsMerge),apply(mergeWith,undefined,args)});function get(object,path,defaultValue){var result=null==object?undefined:baseGet(object,path);return result===undefined?defaultValue:result}function hasIn(object,path){return null!=object&&hasPath(object,path,baseHasIn)}var invert=createInverter(function(result,value,key){result[value]=key},constant(identity)),invertBy=createInverter(function(result,value,key){hasOwnProperty.call(result,value)?result[value].push(key):result[value]=[key]},getIteratee),invoke=baseRest(baseInvoke);function keys(object){return isArrayLike(object)?arrayLikeKeys(object):baseKeys(object)}function keysIn(object){return isArrayLike(object)?arrayLikeKeys(object,!0):baseKeysIn(object)}var merge=createAssigner(function(object,source,srcIndex){baseMerge(object,source,srcIndex)}),mergeWith=createAssigner(function(object,source,srcIndex,customizer){baseMerge(object,source,srcIndex,customizer)}),omit=flatRest(function(object,paths){var result={};if(null==object)return result;var isDeep=!1;paths=arrayMap(paths,function(path){return path=castPath(path,object),isDeep||(isDeep=path.length>1),path}),copyObject(object,getAllKeysIn(object),result),isDeep&&(result=baseClone(result,CLONE_DEEP_FLAG|CLONE_FLAT_FLAG|CLONE_SYMBOLS_FLAG,customOmitClone));for(var length=paths.length;length--;)baseUnset(result,paths[length]);return result});var pick=flatRest(function(object,paths){return null==object?{}:function(object,paths){return basePickBy(object,paths,function(value,path){return hasIn(object,path)})}(object,paths)});function pickBy(object,predicate){if(null==object)return{};var props=arrayMap(getAllKeysIn(object),function(prop){return[prop]});return predicate=getIteratee(predicate),basePickBy(object,props,function(value,path){return predicate(value,path[0])})}var toPairs=createToPairs(keys),toPairsIn=createToPairs(keysIn);function values(object){return null==object?[]:baseValues(object,keys(object))}var camelCase=createCompounder(function(result,word,index){return word=word.toLowerCase(),result+(index?capitalize(word):word)});function capitalize(string){return upperFirst(toString(string).toLowerCase())}function deburr(string){return(string=toString(string))&&string.replace(reLatin,deburrLetter).replace(reComboMark,"")}var kebabCase=createCompounder(function(result,word,index){return result+(index?"-":"")+word.toLowerCase()}),lowerCase=createCompounder(function(result,word,index){return result+(index?" ":"")+word.toLowerCase()}),lowerFirst=createCaseFirst("toLowerCase");var snakeCase=createCompounder(function(result,word,index){return result+(index?"_":"")+word.toLowerCase()});var startCase=createCompounder(function(result,word,index){return result+(index?" ":"")+upperFirst(word)});var upperCase=createCompounder(function(result,word,index){return result+(index?" ":"")+word.toUpperCase()}),upperFirst=createCaseFirst("toUpperCase");function words(string,pattern,guard){return string=toString(string),(pattern=guard?undefined:pattern)===undefined?function(string){return reHasUnicodeWord.test(string)}(string)?function(string){return string.match(reUnicodeWord)||[]}(string):function(string){return string.match(reAsciiWord)||[]}(string):string.match(pattern)||[]}var attempt=baseRest(function(func,args){try{return apply(func,undefined,args)}catch(e){return isError(e)?e:new Error(e)}}),bindAll=flatRest(function(object,methodNames){return arrayEach(methodNames,function(key){key=toKey(key),baseAssignValue(object,key,bind(object[key],object))}),object});function constant(value){return function(){return value}}var flow=createFlow(),flowRight=createFlow(!0);function identity(value){return value}function iteratee(func){return baseIteratee("function"==typeof func?func:baseClone(func,CLONE_DEEP_FLAG))}var method=baseRest(function(path,args){return function(object){return baseInvoke(object,path,args)}}),methodOf=baseRest(function(object,args){return function(path){return baseInvoke(object,path,args)}});function mixin(object,source,options){var props=keys(source),methodNames=baseFunctions(source,props);null!=options||isObject(source)&&(methodNames.length||!props.length)||(options=source,source=object,object=this,methodNames=baseFunctions(source,keys(source)));var chain=!(isObject(options)&&"chain"in options&&!options.chain),isFunc=isFunction(object);return arrayEach(methodNames,function(methodName){var func=source[methodName];object[methodName]=func,isFunc&&(object.prototype[methodName]=function(){var chainAll=this.__chain__;if(chain||chainAll){var result=object(this.__wrapped__);return(result.__actions__=copyArray(this.__actions__)).push({func:func,args:arguments,thisArg:object}),result.__chain__=chainAll,result}return func.apply(object,arrayPush([this.value()],arguments))})}),object}function noop(){}var over=createOver(arrayMap),overEvery=createOver(arrayEvery),overSome=createOver(arraySome);function property(path){return isKey(path)?baseProperty(toKey(path)):function(path){return function(object){return baseGet(object,path)}}(path)}var range=createRange(),rangeRight=createRange(!0);function stubArray(){return[]}function stubFalse(){return!1}var add=createMathOperation(function(augend,addend){return augend+addend},0),ceil=createRound("ceil"),divide=createMathOperation(function(dividend,divisor){return dividend/divisor},1),floor=createRound("floor");var multiply=createMathOperation(function(multiplier,multiplicand){return multiplier*multiplicand},1),round=createRound("round"),subtract=createMathOperation(function(minuend,subtrahend){return minuend-subtrahend},0);return lodash.after=function(n,func){if("function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return n=toInteger(n),function(){if(--n<1)return func.apply(this,arguments)}},lodash.ary=ary,lodash.assign=assign,lodash.assignIn=assignIn,lodash.assignInWith=assignInWith,lodash.assignWith=assignWith,lodash.at=at,lodash.before=before,lodash.bind=bind,lodash.bindAll=bindAll,lodash.bindKey=bindKey,lodash.castArray=function(){if(!arguments.length)return[];var value=arguments[0];return isArray(value)?value:[value]},lodash.chain=chain,lodash.chunk=function(array,size,guard){size=(guard?isIterateeCall(array,size,guard):size===undefined)?1:nativeMax(toInteger(size),0);var length=null==array?0:array.length;if(!length||size<1)return[];for(var index=0,resIndex=0,result=Array(nativeCeil(length/size));indexlength?0:length+start),(end=end===undefined||end>length?length:toInteger(end))<0&&(end+=length),end=start>end?0:toLength(end);start>>0)?(string=toString(string))&&("string"==typeof separator||null!=separator&&!isRegExp(separator))&&!(separator=baseToString(separator))&&hasUnicode(string)?castSlice(stringToArray(string),0,limit):string.split(separator,limit):[]},lodash.spread=function(func,start){if("function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return start=null==start?0:nativeMax(toInteger(start),0),baseRest(function(args){var array=args[start],otherArgs=castSlice(args,0,start);return array&&arrayPush(otherArgs,array),apply(func,this,otherArgs)})},lodash.tail=function(array){var length=null==array?0:array.length;return length?baseSlice(array,1,length):[]},lodash.take=function(array,n,guard){return array&&array.length?baseSlice(array,0,(n=guard||n===undefined?1:toInteger(n))<0?0:n):[]},lodash.takeRight=function(array,n,guard){var length=null==array?0:array.length;return length?baseSlice(array,(n=length-(n=guard||n===undefined?1:toInteger(n)))<0?0:n,length):[]},lodash.takeRightWhile=function(array,predicate){return array&&array.length?baseWhile(array,getIteratee(predicate,3),!1,!0):[]},lodash.takeWhile=function(array,predicate){return array&&array.length?baseWhile(array,getIteratee(predicate,3)):[]},lodash.tap=function(value,interceptor){return interceptor(value),value},lodash.throttle=function(func,wait,options){var leading=!0,trailing=!0;if("function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return isObject(options)&&(leading="leading"in options?!!options.leading:leading,trailing="trailing"in options?!!options.trailing:trailing),debounce(func,wait,{leading:leading,maxWait:wait,trailing:trailing})},lodash.thru=thru,lodash.toArray=toArray,lodash.toPairs=toPairs,lodash.toPairsIn=toPairsIn,lodash.toPath=function(value){return isArray(value)?arrayMap(value,toKey):isSymbol(value)?[value]:copyArray(stringToPath(toString(value)))},lodash.toPlainObject=toPlainObject,lodash.transform=function(object,iteratee,accumulator){var isArr=isArray(object),isArrLike=isArr||isBuffer(object)||isTypedArray(object);if(iteratee=getIteratee(iteratee,4),null==accumulator){var Ctor=object&&object.constructor;accumulator=isArrLike?isArr?new Ctor:[]:isObject(object)&&isFunction(Ctor)?baseCreate(getPrototype(object)):{}}return(isArrLike?arrayEach:baseForOwn)(object,function(value,index,object){return iteratee(accumulator,value,index,object)}),accumulator},lodash.unary=function(func){return ary(func,1)},lodash.union=union,lodash.unionBy=unionBy,lodash.unionWith=unionWith,lodash.uniq=function(array){return array&&array.length?baseUniq(array):[]},lodash.uniqBy=function(array,iteratee){return array&&array.length?baseUniq(array,getIteratee(iteratee,2)):[]},lodash.uniqWith=function(array,comparator){return comparator="function"==typeof comparator?comparator:undefined,array&&array.length?baseUniq(array,undefined,comparator):[]},lodash.unset=function(object,path){return null==object||baseUnset(object,path)},lodash.unzip=unzip,lodash.unzipWith=unzipWith,lodash.update=function(object,path,updater){return null==object?object:baseUpdate(object,path,castFunction(updater))},lodash.updateWith=function(object,path,updater,customizer){return customizer="function"==typeof customizer?customizer:undefined,null==object?object:baseUpdate(object,path,castFunction(updater),customizer)},lodash.values=values,lodash.valuesIn=function(object){return null==object?[]:baseValues(object,keysIn(object))},lodash.without=without,lodash.words=words,lodash.wrap=function(value,wrapper){return partial(castFunction(wrapper),value)},lodash.xor=xor,lodash.xorBy=xorBy,lodash.xorWith=xorWith,lodash.zip=zip,lodash.zipObject=function(props,values){return baseZipObject(props||[],values||[],assignValue)},lodash.zipObjectDeep=function(props,values){return baseZipObject(props||[],values||[],baseSet)},lodash.zipWith=zipWith,lodash.entries=toPairs,lodash.entriesIn=toPairsIn,lodash.extend=assignIn,lodash.extendWith=assignInWith,mixin(lodash,lodash),lodash.add=add,lodash.attempt=attempt,lodash.camelCase=camelCase,lodash.capitalize=capitalize,lodash.ceil=ceil,lodash.clamp=function(number,lower,upper){return upper===undefined&&(upper=lower,lower=undefined),upper!==undefined&&(upper=(upper=toNumber(upper))==upper?upper:0),lower!==undefined&&(lower=(lower=toNumber(lower))==lower?lower:0),baseClamp(toNumber(number),lower,upper)},lodash.clone=function(value){return baseClone(value,CLONE_SYMBOLS_FLAG)},lodash.cloneDeep=function(value){return baseClone(value,CLONE_DEEP_FLAG|CLONE_SYMBOLS_FLAG)},lodash.cloneDeepWith=function(value,customizer){return baseClone(value,CLONE_DEEP_FLAG|CLONE_SYMBOLS_FLAG,customizer="function"==typeof customizer?customizer:undefined)},lodash.cloneWith=function(value,customizer){return baseClone(value,CLONE_SYMBOLS_FLAG,customizer="function"==typeof customizer?customizer:undefined)},lodash.conformsTo=function(object,source){return null==source||baseConformsTo(object,source,keys(source))},lodash.deburr=deburr,lodash.defaultTo=function(value,defaultValue){return null==value||value!=value?defaultValue:value},lodash.divide=divide,lodash.endsWith=function(string,target,position){string=toString(string),target=baseToString(target);var length=string.length,end=position=position===undefined?length:baseClamp(toInteger(position),0,length);return(position-=target.length)>=0&&string.slice(position,end)==target},lodash.eq=eq,lodash.escape=function(string){return(string=toString(string))&&reHasUnescapedHtml.test(string)?string.replace(reUnescapedHtml,escapeHtmlChar):string},lodash.escapeRegExp=function(string){return(string=toString(string))&&reHasRegExpChar.test(string)?string.replace(reRegExpChar,"\\$&"):string},lodash.every=function(collection,predicate,guard){var func=isArray(collection)?arrayEvery:baseEvery;return guard&&isIterateeCall(collection,predicate,guard)&&(predicate=undefined),func(collection,getIteratee(predicate,3))},lodash.find=find,lodash.findIndex=findIndex,lodash.findKey=function(object,predicate){return baseFindKey(object,getIteratee(predicate,3),baseForOwn)},lodash.findLast=findLast,lodash.findLastIndex=findLastIndex,lodash.findLastKey=function(object,predicate){return baseFindKey(object,getIteratee(predicate,3),baseForOwnRight)},lodash.floor=floor,lodash.forEach=forEach,lodash.forEachRight=forEachRight,lodash.forIn=function(object,iteratee){return null==object?object:baseFor(object,getIteratee(iteratee,3),keysIn)},lodash.forInRight=function(object,iteratee){return null==object?object:baseForRight(object,getIteratee(iteratee,3),keysIn)},lodash.forOwn=function(object,iteratee){return object&&baseForOwn(object,getIteratee(iteratee,3))},lodash.forOwnRight=function(object,iteratee){return object&&baseForOwnRight(object,getIteratee(iteratee,3))},lodash.get=get,lodash.gt=gt,lodash.gte=gte,lodash.has=function(object,path){return null!=object&&hasPath(object,path,baseHas)},lodash.hasIn=hasIn,lodash.head=head,lodash.identity=identity,lodash.includes=function(collection,value,fromIndex,guard){collection=isArrayLike(collection)?collection:values(collection),fromIndex=fromIndex&&!guard?toInteger(fromIndex):0;var length=collection.length;return fromIndex<0&&(fromIndex=nativeMax(length+fromIndex,0)),isString(collection)?fromIndex<=length&&collection.indexOf(value,fromIndex)>-1:!!length&&baseIndexOf(collection,value,fromIndex)>-1},lodash.indexOf=function(array,value,fromIndex){var length=null==array?0:array.length;if(!length)return-1;var index=null==fromIndex?0:toInteger(fromIndex);return index<0&&(index=nativeMax(length+index,0)),baseIndexOf(array,value,index)},lodash.inRange=function(number,start,end){return start=toFinite(start),end===undefined?(end=start,start=0):end=toFinite(end),function(number,start,end){return number>=nativeMin(start,end)&&number=-MAX_SAFE_INTEGER&&value<=MAX_SAFE_INTEGER},lodash.isSet=isSet,lodash.isString=isString,lodash.isSymbol=isSymbol,lodash.isTypedArray=isTypedArray,lodash.isUndefined=function(value){return value===undefined},lodash.isWeakMap=function(value){return isObjectLike(value)&&getTag(value)==weakMapTag},lodash.isWeakSet=function(value){return isObjectLike(value)&&baseGetTag(value)==weakSetTag},lodash.join=function(array,separator){return null==array?"":nativeJoin.call(array,separator)},lodash.kebabCase=kebabCase,lodash.last=last,lodash.lastIndexOf=function(array,value,fromIndex){var length=null==array?0:array.length;if(!length)return-1;var index=length;return fromIndex!==undefined&&(index=(index=toInteger(fromIndex))<0?nativeMax(length+index,0):nativeMin(index,length-1)),value==value?function(array,value,fromIndex){for(var index=fromIndex+1;index--;)if(array[index]===value)return index;return index}(array,value,index):baseFindIndex(array,baseIsNaN,index,!0)},lodash.lowerCase=lowerCase,lodash.lowerFirst=lowerFirst,lodash.lt=lt,lodash.lte=lte,lodash.max=function(array){return array&&array.length?baseExtremum(array,identity,baseGt):undefined},lodash.maxBy=function(array,iteratee){return array&&array.length?baseExtremum(array,getIteratee(iteratee,2),baseGt):undefined},lodash.mean=function(array){return baseMean(array,identity)},lodash.meanBy=function(array,iteratee){return baseMean(array,getIteratee(iteratee,2))},lodash.min=function(array){return array&&array.length?baseExtremum(array,identity,baseLt):undefined},lodash.minBy=function(array,iteratee){return array&&array.length?baseExtremum(array,getIteratee(iteratee,2),baseLt):undefined},lodash.stubArray=stubArray,lodash.stubFalse=stubFalse,lodash.stubObject=function(){return{}},lodash.stubString=function(){return""},lodash.stubTrue=function(){return!0},lodash.multiply=multiply,lodash.nth=function(array,n){return array&&array.length?baseNth(array,toInteger(n)):undefined},lodash.noConflict=function(){return root._===this&&(root._=oldDash),this},lodash.noop=noop,lodash.now=now,lodash.pad=function(string,length,chars){string=toString(string);var strLength=(length=toInteger(length))?stringSize(string):0;if(!length||strLength>=length)return string;var mid=(length-strLength)/2;return createPadding(nativeFloor(mid),chars)+string+createPadding(nativeCeil(mid),chars)},lodash.padEnd=function(string,length,chars){string=toString(string);var strLength=(length=toInteger(length))?stringSize(string):0;return length&&strLengthupper){var temp=lower;lower=upper,upper=temp}if(floating||lower%1||upper%1){var rand=nativeRandom();return nativeMin(lower+rand*(upper-lower+freeParseFloat("1e-"+((rand+"").length-1))),upper)}return baseRandom(lower,upper)},lodash.reduce=function(collection,iteratee,accumulator){var func=isArray(collection)?arrayReduce:baseReduce,initAccum=arguments.length<3;return func(collection,getIteratee(iteratee,4),accumulator,initAccum,baseEach)},lodash.reduceRight=function(collection,iteratee,accumulator){var func=isArray(collection)?arrayReduceRight:baseReduce,initAccum=arguments.length<3;return func(collection,getIteratee(iteratee,4),accumulator,initAccum,baseEachRight)},lodash.repeat=function(string,n,guard){return n=(guard?isIterateeCall(string,n,guard):n===undefined)?1:toInteger(n),baseRepeat(toString(string),n)},lodash.replace=function(){var args=arguments,string=toString(args[0]);return args.length<3?string:string.replace(args[1],args[2])},lodash.result=function(object,path,defaultValue){var index=-1,length=(path=castPath(path,object)).length;for(length||(length=1,object=undefined);++indexMAX_SAFE_INTEGER)return[];var index=MAX_ARRAY_LENGTH,length=nativeMin(n,MAX_ARRAY_LENGTH);iteratee=getIteratee(iteratee),n-=MAX_ARRAY_LENGTH;for(var result=baseTimes(length,iteratee);++index=strLength)return string;var end=length-stringSize(omission);if(end<1)return omission;var result=strSymbols?castSlice(strSymbols,0,end).join(""):string.slice(0,end);if(separator===undefined)return result+omission;if(strSymbols&&(end+=result.length-end),isRegExp(separator)){if(string.slice(end).search(separator)){var match,substring=result;for(separator.global||(separator=RegExp(separator.source,toString(reFlags.exec(separator))+"g")),separator.lastIndex=0;match=separator.exec(substring);)var newEnd=match.index;result=result.slice(0,newEnd===undefined?end:newEnd)}}else if(string.indexOf(baseToString(separator),end)!=end){var index=result.lastIndexOf(separator);index>-1&&(result=result.slice(0,index))}return result+omission},lodash.unescape=function(string){return(string=toString(string))&&reHasEscapedHtml.test(string)?string.replace(reEscapedHtml,unescapeHtmlChar):string},lodash.uniqueId=function(prefix){var id=++idCounter;return toString(prefix)+id},lodash.upperCase=upperCase,lodash.upperFirst=upperFirst,lodash.each=forEach,lodash.eachRight=forEachRight,lodash.first=head,mixin(lodash,function(){var source={};return baseForOwn(lodash,function(func,methodName){hasOwnProperty.call(lodash.prototype,methodName)||(source[methodName]=func)}),source}(),{chain:!1}),lodash.VERSION="4.17.4",arrayEach(["bind","bindKey","curry","curryRight","partial","partialRight"],function(methodName){lodash[methodName].placeholder=lodash}),arrayEach(["drop","take"],function(methodName,index){LazyWrapper.prototype[methodName]=function(n){n=n===undefined?1:nativeMax(toInteger(n),0);var result=this.__filtered__&&!index?new LazyWrapper(this):this.clone();return result.__filtered__?result.__takeCount__=nativeMin(n,result.__takeCount__):result.__views__.push({size:nativeMin(n,MAX_ARRAY_LENGTH),type:methodName+(result.__dir__<0?"Right":"")}),result},LazyWrapper.prototype[methodName+"Right"]=function(n){return this.reverse()[methodName](n).reverse()}}),arrayEach(["filter","map","takeWhile"],function(methodName,index){var type=index+1,isFilter=type==LAZY_FILTER_FLAG||3==type;LazyWrapper.prototype[methodName]=function(iteratee){var result=this.clone();return result.__iteratees__.push({iteratee:getIteratee(iteratee,3),type:type}),result.__filtered__=result.__filtered__||isFilter,result}}),arrayEach(["head","last"],function(methodName,index){var takeName="take"+(index?"Right":"");LazyWrapper.prototype[methodName]=function(){return this[takeName](1).value()[0]}}),arrayEach(["initial","tail"],function(methodName,index){var dropName="drop"+(index?"":"Right");LazyWrapper.prototype[methodName]=function(){return this.__filtered__?new LazyWrapper(this):this[dropName](1)}}),LazyWrapper.prototype.compact=function(){return this.filter(identity)},LazyWrapper.prototype.find=function(predicate){return this.filter(predicate).head()},LazyWrapper.prototype.findLast=function(predicate){return this.reverse().find(predicate)},LazyWrapper.prototype.invokeMap=baseRest(function(path,args){return"function"==typeof path?new LazyWrapper(this):this.map(function(value){return baseInvoke(value,path,args)})}),LazyWrapper.prototype.reject=function(predicate){return this.filter(negate(getIteratee(predicate)))},LazyWrapper.prototype.slice=function(start,end){start=toInteger(start);var result=this;return result.__filtered__&&(start>0||end<0)?new LazyWrapper(result):(start<0?result=result.takeRight(-start):start&&(result=result.drop(start)),end!==undefined&&(result=(end=toInteger(end))<0?result.dropRight(-end):result.take(end-start)),result)},LazyWrapper.prototype.takeRightWhile=function(predicate){return this.reverse().takeWhile(predicate).reverse()},LazyWrapper.prototype.toArray=function(){return this.take(MAX_ARRAY_LENGTH)},baseForOwn(LazyWrapper.prototype,function(func,methodName){var checkIteratee=/^(?:filter|find|map|reject)|While$/.test(methodName),isTaker=/^(?:head|last)$/.test(methodName),lodashFunc=lodash[isTaker?"take"+("last"==methodName?"Right":""):methodName],retUnwrapped=isTaker||/^find/.test(methodName);lodashFunc&&(lodash.prototype[methodName]=function(){var value=this.__wrapped__,args=isTaker?[1]:arguments,isLazy=value instanceof LazyWrapper,iteratee=args[0],useLazy=isLazy||isArray(value),interceptor=function(value){var result=lodashFunc.apply(lodash,arrayPush([value],args));return isTaker&&chainAll?result[0]:result};useLazy&&checkIteratee&&"function"==typeof iteratee&&1!=iteratee.length&&(isLazy=useLazy=!1);var chainAll=this.__chain__,isHybrid=!!this.__actions__.length,isUnwrapped=retUnwrapped&&!chainAll,onlyLazy=isLazy&&!isHybrid;if(!retUnwrapped&&useLazy){value=onlyLazy?value:new LazyWrapper(this);var result=func.apply(value,args);return result.__actions__.push({func:thru,args:[interceptor],thisArg:undefined}),new LodashWrapper(result,chainAll)}return isUnwrapped&&onlyLazy?func.apply(this,args):(result=this.thru(interceptor),isUnwrapped?isTaker?result.value()[0]:result.value():result)})}),arrayEach(["pop","push","shift","sort","splice","unshift"],function(methodName){var func=arrayProto[methodName],chainName=/^(?:push|sort|unshift)$/.test(methodName)?"tap":"thru",retUnwrapped=/^(?:pop|shift)$/.test(methodName);lodash.prototype[methodName]=function(){var args=arguments;if(retUnwrapped&&!this.__chain__){var value=this.value();return func.apply(isArray(value)?value:[],args)}return this[chainName](function(value){return func.apply(isArray(value)?value:[],args)})}}),baseForOwn(LazyWrapper.prototype,function(func,methodName){var lodashFunc=lodash[methodName];if(lodashFunc){var key=lodashFunc.name+"";(realNames[key]||(realNames[key]=[])).push({name:methodName,func:lodashFunc})}}),realNames[createHybrid(undefined,WRAP_BIND_KEY_FLAG).name]=[{name:"wrapper",func:undefined}],LazyWrapper.prototype.clone=function(){var result=new LazyWrapper(this.__wrapped__);return result.__actions__=copyArray(this.__actions__),result.__dir__=this.__dir__,result.__filtered__=this.__filtered__,result.__iteratees__=copyArray(this.__iteratees__),result.__takeCount__=this.__takeCount__,result.__views__=copyArray(this.__views__),result},LazyWrapper.prototype.reverse=function(){if(this.__filtered__){var result=new LazyWrapper(this);result.__dir__=-1,result.__filtered__=!0}else(result=this.clone()).__dir__*=-1;return result},LazyWrapper.prototype.value=function(){var array=this.__wrapped__.value(),dir=this.__dir__,isArr=isArray(array),isRight=dir<0,arrLength=isArr?array.length:0,view=function(start,end,transforms){for(var index=-1,length=transforms.length;++index=this.__values__.length;return{done:done,value:done?undefined:this.__values__[this.__index__++]}},lodash.prototype.plant=function(value){for(var result,parent=this;parent instanceof baseLodash;){var clone=wrapperClone(parent);clone.__index__=0,clone.__values__=undefined,result?previous.__wrapped__=clone:result=clone;var previous=clone;parent=parent.__wrapped__}return previous.__wrapped__=value,result},lodash.prototype.reverse=function(){var value=this.__wrapped__;if(value instanceof LazyWrapper){var wrapped=value;return this.__actions__.length&&(wrapped=new LazyWrapper(this)),(wrapped=wrapped.reverse()).__actions__.push({func:thru,args:[reverse],thisArg:undefined}),new LodashWrapper(wrapped,this.__chain__)}return this.thru(reverse)},lodash.prototype.toJSON=lodash.prototype.valueOf=lodash.prototype.value=function(){return baseWrapperValue(this.__wrapped__,this.__actions__)},lodash.prototype.first=lodash.prototype.head,symIterator&&(lodash.prototype[symIterator]=function(){return this}),lodash}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(root._=_,define(function(){return _})):freeModule?((freeModule.exports=_)._=_,freeExports._=_):root._=_}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],145:[function(require,module,exports){(function(Buffer){"use strict";var inherits=require("inherits"),HashBase=require("hash-base"),ARRAY16=new Array(16);function MD5(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}inherits(MD5,HashBase),MD5.prototype._update=function(){for(var M=ARRAY16,i=0;i<16;++i)M[i]=this._block.readInt32LE(4*i);var a=this._a,b=this._b,c=this._c,d=this._d;b=fnI(b=fnI(b=fnI(b=fnI(b=fnH(b=fnH(b=fnH(b=fnH(b=fnG(b=fnG(b=fnG(b=fnG(b=fnF(b=fnF(b=fnF(b=fnF(b,c=fnF(c,d=fnF(d,a=fnF(a,b,c,d,M[0],3614090360,7),b,c,M[1],3905402710,12),a,b,M[2],606105819,17),d,a,M[3],3250441966,22),c=fnF(c,d=fnF(d,a=fnF(a,b,c,d,M[4],4118548399,7),b,c,M[5],1200080426,12),a,b,M[6],2821735955,17),d,a,M[7],4249261313,22),c=fnF(c,d=fnF(d,a=fnF(a,b,c,d,M[8],1770035416,7),b,c,M[9],2336552879,12),a,b,M[10],4294925233,17),d,a,M[11],2304563134,22),c=fnF(c,d=fnF(d,a=fnF(a,b,c,d,M[12],1804603682,7),b,c,M[13],4254626195,12),a,b,M[14],2792965006,17),d,a,M[15],1236535329,22),c=fnG(c,d=fnG(d,a=fnG(a,b,c,d,M[1],4129170786,5),b,c,M[6],3225465664,9),a,b,M[11],643717713,14),d,a,M[0],3921069994,20),c=fnG(c,d=fnG(d,a=fnG(a,b,c,d,M[5],3593408605,5),b,c,M[10],38016083,9),a,b,M[15],3634488961,14),d,a,M[4],3889429448,20),c=fnG(c,d=fnG(d,a=fnG(a,b,c,d,M[9],568446438,5),b,c,M[14],3275163606,9),a,b,M[3],4107603335,14),d,a,M[8],1163531501,20),c=fnG(c,d=fnG(d,a=fnG(a,b,c,d,M[13],2850285829,5),b,c,M[2],4243563512,9),a,b,M[7],1735328473,14),d,a,M[12],2368359562,20),c=fnH(c,d=fnH(d,a=fnH(a,b,c,d,M[5],4294588738,4),b,c,M[8],2272392833,11),a,b,M[11],1839030562,16),d,a,M[14],4259657740,23),c=fnH(c,d=fnH(d,a=fnH(a,b,c,d,M[1],2763975236,4),b,c,M[4],1272893353,11),a,b,M[7],4139469664,16),d,a,M[10],3200236656,23),c=fnH(c,d=fnH(d,a=fnH(a,b,c,d,M[13],681279174,4),b,c,M[0],3936430074,11),a,b,M[3],3572445317,16),d,a,M[6],76029189,23),c=fnH(c,d=fnH(d,a=fnH(a,b,c,d,M[9],3654602809,4),b,c,M[12],3873151461,11),a,b,M[15],530742520,16),d,a,M[2],3299628645,23),c=fnI(c,d=fnI(d,a=fnI(a,b,c,d,M[0],4096336452,6),b,c,M[7],1126891415,10),a,b,M[14],2878612391,15),d,a,M[5],4237533241,21),c=fnI(c,d=fnI(d,a=fnI(a,b,c,d,M[12],1700485571,6),b,c,M[3],2399980690,10),a,b,M[10],4293915773,15),d,a,M[1],2240044497,21),c=fnI(c,d=fnI(d,a=fnI(a,b,c,d,M[8],1873313359,6),b,c,M[15],4264355552,10),a,b,M[6],2734768916,15),d,a,M[13],1309151649,21),c=fnI(c,d=fnI(d,a=fnI(a,b,c,d,M[4],4149444226,6),b,c,M[11],3174756917,10),a,b,M[2],718787259,15),d,a,M[9],3951481745,21),this._a=this._a+a|0,this._b=this._b+b|0,this._c=this._c+c|0,this._d=this._d+d|0},MD5.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=new Buffer(16);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer};function rotl(x,n){return x<>>32-n}function fnF(a,b,c,d,m,k,s){return rotl(a+(b&c|~b&d)+m+k|0,s)+b|0}function fnG(a,b,c,d,m,k,s){return rotl(a+(b&d|c&~d)+m+k|0,s)+b|0}function fnH(a,b,c,d,m,k,s){return rotl(a+(b^c^d)+m+k|0,s)+b|0}function fnI(a,b,c,d,m,k,s){return rotl(a+(c^(b|~d))+m+k|0,s)+b|0}module.exports=MD5}).call(this,require("buffer").Buffer)},{buffer:70,"hash-base":146,inherits:141}],146:[function(require,module,exports){"use strict";var Buffer=require("safe-buffer").Buffer,Transform=require("stream").Transform;function HashBase(blockSize){Transform.call(this),this._block=Buffer.allocUnsafe(blockSize),this._blockSize=blockSize,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}require("inherits")(HashBase,Transform),HashBase.prototype._transform=function(chunk,encoding,callback){var error=null;try{this.update(chunk,encoding)}catch(err){error=err}callback(error)},HashBase.prototype._flush=function(callback){var error=null;try{this.push(this.digest())}catch(err){error=err}callback(error)},HashBase.prototype.update=function(data,encoding){if(function(val,prefix){if(!Buffer.isBuffer(val)&&"string"!=typeof val)throw new TypeError(prefix+" must be a string or a buffer")}(data,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(data)||(data=Buffer.from(data,encoding));for(var block=this._block,offset=0;this._blockOffset+data.length-offset>=this._blockSize;){for(var i=this._blockOffset;i0;++j)this._length[j]+=carry,(carry=this._length[j]/4294967296|0)>0&&(this._length[j]-=4294967296*carry);return this},HashBase.prototype._update=function(){throw new Error("_update is not implemented")},HashBase.prototype.digest=function(encoding){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var digest=this._digest();void 0!==encoding&&(digest=digest.toString(encoding)),this._block.fill(0),this._blockOffset=0;for(var i=0;i<4;++i)this._length[i]=0;return digest},HashBase.prototype._digest=function(){throw new Error("_digest is not implemented")},module.exports=HashBase},{inherits:141,"safe-buffer":191,stream:200}],147:[function(require,module,exports){var bn=require("bn.js"),brorand=require("brorand");function MillerRabin(rand){this.rand=rand||new brorand.Rand}module.exports=MillerRabin,MillerRabin.create=function(rand){return new MillerRabin(rand)},MillerRabin.prototype._randbelow=function(n){var len=n.bitLength(),min_bytes=Math.ceil(len/8);do{var a=new bn(this.rand.generate(min_bytes))}while(a.cmp(n)>=0);return a},MillerRabin.prototype._randrange=function(start,stop){var size=stop.sub(start);return start.add(this._randbelow(size))},MillerRabin.prototype.test=function(n,k,cb){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=Math.max(1,len/48|0));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red);k>0;k--){var a=this._randrange(new bn(2),n1);cb&&cb(a);var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;i0;k--){var a=this._randrange(new bn(2),n1),g=n.gcd(a);if(0!==g.cmpn(1))return g;var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;i>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}return res};function zero2(word){return 1===word.length?"0"+word:word}utils.zero2=zero2;function toHex(msg){for(var res="",i=0;i=6?"utf-8":"binary"}module.exports=defaultEncoding}).call(this,require("_process"))},{_process:162}],159:[function(require,module,exports){var MAX_ALLOC=Math.pow(2,30)-1;module.exports=function(iterations,keylen){if("number"!=typeof iterations)throw new TypeError("Iterations not a number");if(iterations<0)throw new TypeError("Bad iterations");if("number"!=typeof keylen)throw new TypeError("Key length not a number");if(keylen<0||keylen>MAX_ALLOC||keylen!=keylen)throw new TypeError("Bad key length")}},{}],160:[function(require,module,exports){var md5=require("create-hash/md5"),rmd160=require("ripemd160"),sha=require("sha.js"),checkParameters=require("./precondition"),defaultEncoding=require("./default-encoding"),Buffer=require("safe-buffer").Buffer,ZEROS=Buffer.alloc(128),sizes={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Hmac(alg,key,saltLen){var hash=function(alg){return"rmd160"===alg||"ripemd160"===alg?rmd160:"md5"===alg?md5:function(data){return sha(alg).update(data).digest()}}(alg),blocksize="sha512"===alg||"sha384"===alg?128:64;key.length>blocksize?key=hash(key):key.length1)for(var i=1;ik||new bn(enc).cmp(key.modulus)>=0)throw new Error("decryption error");var msg;msg=reverse?withPublic(new bn(enc),key):crt(enc,key);var zBuffer=new Buffer(k-msg.length);if(zBuffer.fill(0),msg=Buffer.concat([zBuffer,msg],k),4===padding)return function(key,msg){key.modulus;var k=key.modulus.byteLength(),iHash=(msg.length,createHash("sha1").update(new Buffer("")).digest()),hLen=iHash.length;if(0!==msg[0])throw new Error("decryption error");var maskedSeed=msg.slice(1,hLen+1),maskedDb=msg.slice(hLen+1),seed=xor(maskedSeed,mgf(maskedDb,hLen)),db=xor(maskedDb,mgf(seed,k-hLen-1));if(function(a,b){a=new Buffer(a),b=new Buffer(b);var dif=0,len=a.length;a.length!==b.length&&(dif++,len=Math.min(a.length,b.length));var i=-1;for(;++i=msg.length){status++;break}var ps=msg.slice(2,i-1);msg.slice(i-1,i);("0002"!==p1.toString("hex")&&!reverse||"0001"!==p1.toString("hex")&&reverse)&&status++;ps.length<8&&status++;if(status)throw new Error("decryption error");return msg.slice(i)}(0,msg,reverse);if(3===padding)return msg;throw new Error("unknown padding")}}).call(this,require("buffer").Buffer)},{"./mgf":164,"./withPublic":168,"./xor":169,"bn.js":165,"browserify-rsa":42,buffer:70,"create-hash":91,"parse-asn1":155}],167:[function(require,module,exports){(function(Buffer){var parseKeys=require("parse-asn1"),randomBytes=require("randombytes"),createHash=require("create-hash"),mgf=require("./mgf"),xor=require("./xor"),bn=require("bn.js"),withPublic=require("./withPublic"),crt=require("browserify-rsa");module.exports=function(public_key,msg,reverse){var padding;padding=public_key.padding?public_key.padding:reverse?1:4;var paddedMsg,key=parseKeys(public_key);if(4===padding)paddedMsg=function(key,msg){var k=key.modulus.byteLength(),mLen=msg.length,iHash=createHash("sha1").update(new Buffer("")).digest(),hLen=iHash.length,hLen2=2*hLen;if(mLen>k-hLen2-2)throw new Error("message too long");var ps=new Buffer(k-mLen-hLen2-2);ps.fill(0);var dblen=k-hLen-1,seed=randomBytes(hLen),maskedDb=xor(Buffer.concat([iHash,ps,new Buffer([1]),msg],dblen),mgf(seed,dblen)),maskedSeed=xor(seed,mgf(maskedDb,hLen));return new bn(Buffer.concat([new Buffer([0]),maskedSeed,maskedDb],k))}(key,msg);else if(1===padding)paddedMsg=function(key,msg,reverse){var mLen=msg.length,k=key.modulus.byteLength();if(mLen>k-11)throw new Error("message too long");var ps;reverse?(ps=new Buffer(k-mLen-3)).fill(255):ps=function(len,crypto){var num,out=new Buffer(len),i=0,cache=randomBytes(2*len),cur=0;for(;i=0)throw new Error("data too long for modulus")}return reverse?crt(paddedMsg,key):withPublic(paddedMsg,key)}}).call(this,require("buffer").Buffer)},{"./mgf":164,"./withPublic":168,"./xor":169,"bn.js":165,"browserify-rsa":42,buffer:70,"create-hash":91,"parse-asn1":155,randombytes:174}],168:[function(require,module,exports){(function(Buffer){var bn=require("bn.js");module.exports=function(paddedMsg,key){return new Buffer(paddedMsg.toRed(bn.mont(key.modulus)).redPow(new bn(key.publicExponent)).fromRed().toArray())}}).call(this,require("buffer").Buffer)},{"bn.js":165,buffer:70}],169:[function(require,module,exports){module.exports=function(a,b){for(var len=a.length,i=-1;++i= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(type){throw new RangeError(errors[type])}function map(array,fn){for(var length=array.length,result=[];length--;)result[length]=fn(array[length]);return result}function mapDomain(string,fn){var parts=string.split("@"),result="";parts.length>1&&(result=parts[0]+"@",string=parts[1]);return result+map((string=string.replace(regexSeparators,".")).split("."),fn).join(".")}function ucs2decode(string){for(var value,extra,output=[],counter=0,length=string.length;counter=55296&&value<=56319&&counter65535&&(output+=stringFromCharCode((value-=65536)>>>10&1023|55296),value=56320|1023&value),output+=stringFromCharCode(value)}).join("")}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((0!=flag)<<5)}function adapt(delta,numPoints,firstTime){var k=0;for(delta=firstTime?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var out,basic,j,index,oldi,w,k,digit,t,baseMinusT,output=[],inputLength=input.length,i=0,n=initialN,bias=initialBias;for((basic=input.lastIndexOf(delimiter))<0&&(basic=0),j=0;j=128&&error("not-basic"),output.push(input.charCodeAt(j));for(index=basic>0?basic+1:0;index=inputLength&&error("invalid-input"),((digit=(codePoint=input.charCodeAt(index++))-48<10?codePoint-22:codePoint-65<26?codePoint-65:codePoint-97<26?codePoint-97:base)>=base||digit>floor((maxInt-i)/w))&&error("overflow"),i+=digit*w,!(digit<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)w>floor(maxInt/(baseMinusT=base-t))&&error("overflow"),w*=baseMinusT;bias=adapt(i-oldi,out=output.length+1,0==oldi),floor(i/out)>maxInt-n&&error("overflow"),n+=floor(i/out),i%=out,output.splice(i++,0,n)}var codePoint;return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,inputLength,handledCPCountPlusOne,baseMinusT,qMinusT,output=[];for(inputLength=(input=ucs2decode(input)).length,n=initialN,delta=0,bias=initialBias,j=0;j=n&¤tValuefloor((maxInt-delta)/(handledCPCountPlusOne=handledCPCount+1))&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;jmaxInt&&error("overflow"),currentValue==n){for(q=delta,k=base;!(q<(t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias));k+=base)qMinusT=q-t,baseMinusT=base-t,output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0))),q=floor(qMinusT/baseMinusT);output.push(stringFromCharCode(digitToBasic(q,0))),bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength),delta=0,++handledCPCount}++delta,++n}return output.join("")}if(punycode={version:"1.4.1",ucs2:{decode:ucs2decode,encode:ucs2encode},decode:decode,encode:encode,toASCII:function(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})},toUnicode:function(input){return mapDomain(input,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return punycode});else if(freeExports&&freeModule)if(module.exports==freeExports)freeModule.exports=punycode;else for(key in punycode)punycode.hasOwnProperty(key)&&(freeExports[key]=punycode[key]);else root.punycode=punycode}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],171:[function(require,module,exports){"use strict";function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}module.exports=function(qs,sep,eq,options){sep=sep||"&",eq=eq||"=";var obj={};if("string"!=typeof qs||0===qs.length)return obj;var regexp=/\+/g;qs=qs.split(sep);var maxKeys=1e3;options&&"number"==typeof options.maxKeys&&(maxKeys=options.maxKeys);var len=qs.length;maxKeys>0&&len>maxKeys&&(len=maxKeys);for(var i=0;i=0?(kstr=x.substr(0,idx),vstr=x.substr(idx+1)):(kstr=x,vstr=""),k=decodeURIComponent(kstr),v=decodeURIComponent(vstr),hasOwnProperty(obj,k)?isArray(obj[k])?obj[k].push(v):obj[k]=[obj[k],v]:obj[k]=v}return obj};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)}},{}],172:[function(require,module,exports){"use strict";var stringifyPrimitive=function(v){switch(typeof v){case"string":return v;case"boolean":return v?"true":"false";case"number":return isFinite(v)?v:"";default:return""}};module.exports=function(obj,sep,eq,name){return sep=sep||"&",eq=eq||"=",null===obj&&(obj=void 0),"object"==typeof obj?map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;return isArray(obj[k])?map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v))}).join(sep):ks+encodeURIComponent(stringifyPrimitive(obj[k]))}).join(sep):name?encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj)):""};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)};function map(xs,f){if(xs.map)return xs.map(f);for(var res=[],i=0;i65536)throw new Error("requested too many random bytes");var rawBytes=new global.Uint8Array(size);size>0&&crypto.getRandomValues(rawBytes);var bytes=Buffer.from(rawBytes.buffer);if("function"==typeof cb)return process.nextTick(function(){cb(null,bytes)});return bytes}:module.exports=function(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:162,"safe-buffer":191}],175:[function(require,module,exports){(function(process,global){"use strict";function oldBrowser(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var safeBuffer=require("safe-buffer"),randombytes=require("randombytes"),Buffer=safeBuffer.Buffer,kBufferMaxLength=safeBuffer.kMaxLength,crypto=global.crypto||global.msCrypto,kMaxUint32=Math.pow(2,32)-1;function assertOffset(offset,length){if("number"!=typeof offset||offset!=offset)throw new TypeError("offset must be a number");if(offset>kMaxUint32||offset<0)throw new TypeError("offset must be a uint32");if(offset>kBufferMaxLength||offset>length)throw new RangeError("offset out of range")}function assertSize(size,offset,length){if("number"!=typeof size||size!=size)throw new TypeError("size must be a number");if(size>kMaxUint32||size<0)throw new TypeError("size must be a uint32");if(size+offset>length||size>kBufferMaxLength)throw new RangeError("buffer too small")}crypto&&crypto.getRandomValues||!process.browser?(exports.randomFill=function(buf,offset,size,cb){if(!(Buffer.isBuffer(buf)||buf instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof offset)cb=offset,offset=0,size=buf.length;else if("function"==typeof size)cb=size,size=buf.length-offset;else if("function"!=typeof cb)throw new TypeError('"cb" argument must be a function');return assertOffset(offset,buf.length),assertSize(size,offset,buf.length),actualFill(buf,offset,size,cb)},exports.randomFillSync=function(buf,offset,size){void 0===offset&&(offset=0);if(!(Buffer.isBuffer(buf)||buf instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');assertOffset(offset,buf.length),void 0===size&&(size=buf.length-offset);return assertSize(size,offset,buf.length),actualFill(buf,offset,size)}):(exports.randomFill=oldBrowser,exports.randomFillSync=oldBrowser);function actualFill(buf,offset,size,cb){if(process.browser){var ourBuf=buf.buffer,uint=new Uint8Array(ourBuf,offset,size);return crypto.getRandomValues(uint),cb?void process.nextTick(function(){cb(null,buf)}):buf}{if(!cb){return randombytes(size).copy(buf,offset),buf}randombytes(size,function(err,bytes){if(err)return cb(err);bytes.copy(buf,offset),cb(null,buf)})}}}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:162,randombytes:174,"safe-buffer":191}],176:[function(require,module,exports){module.exports=require("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":177}],177:[function(require,module,exports){"use strict";var processNextTick=require("process-nextick-args"),objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};module.exports=Duplex;var util=require("core-util-is");util.inherits=require("inherits");var Readable=require("./_stream_readable"),Writable=require("./_stream_writable");util.inherits(Duplex,Readable);for(var keys=objectKeys(Writable.prototype),v=0;v0?("string"==typeof chunk||state.objectMode||Object.getPrototypeOf(chunk)===Buffer.prototype||(chunk=function(chunk){return Buffer.from(chunk)}(chunk)),addToFront?state.endEmitted?stream.emit("error",new Error("stream.unshift() after end event")):addChunk(stream,state,chunk,!0):state.ended?stream.emit("error",new Error("stream.push() after EOF")):(state.reading=!1,state.decoder&&!encoding?(chunk=state.decoder.write(chunk),state.objectMode||0!==chunk.length?addChunk(stream,state,chunk,!1):maybeReadMore(stream,state)):addChunk(stream,state,chunk,!1))):addToFront||(state.reading=!1)}return function(state){return!state.ended&&(state.needReadable||state.lengthstate.highWaterMark&&(state.highWaterMark=function(n){return n>=MAX_HWM?n=MAX_HWM:(n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++),n}(n)),n<=state.length?n:state.ended?state.length:(state.needReadable=!0,0))}Readable.prototype.read=function(n){debug("read",n),n=parseInt(n,10);var state=this._readableState,nOrig=n;if(0!==n&&(state.emittedReadable=!1),0===n&&state.needReadable&&(state.length>=state.highWaterMark||state.ended))return debug("read: emitReadable",state.length,state.ended),0===state.length&&state.ended?endReadable(this):emitReadable(this),null;if(0===(n=howMuchToRead(n,state))&&state.ended)return 0===state.length&&endReadable(this),null;var doRead=state.needReadable;debug("need readable",doRead),(0===state.length||state.length-n0?fromList(n,state):null)?(state.needReadable=!0,n=0):state.length-=n,0===state.length&&(state.ended||(state.needReadable=!0),nOrig!==n&&state.ended&&endReadable(this)),null!==ret&&this.emit("data",ret),ret};function emitReadable(stream){var state=stream._readableState;state.needReadable=!1,state.emittedReadable||(debug("emitReadable",state.flowing),state.emittedReadable=!0,state.sync?processNextTick(emitReadable_,stream):emitReadable_(stream))}function emitReadable_(stream){debug("emit readable"),stream.emit("readable"),flow(stream)}function maybeReadMore(stream,state){state.readingMore||(state.readingMore=!0,processNextTick(maybeReadMore_,stream,state))}function maybeReadMore_(stream,state){for(var len=state.length;!state.reading&&!state.flowing&&!state.ended&&state.length1&&-1!==indexOf(state.pipes,dest))&&!cleanedUp&&(debug("false write response, pause",src._readableState.awaitDrain),src._readableState.awaitDrain++,increasedAwaitDrain=!0),src.pause())}function onerror(er){debug("onerror",er),unpipe(),dest.removeListener("error",onerror),0===EElistenerCount(dest,"error")&&dest.emit("error",er)}!function(emitter,event,fn){if("function"==typeof emitter.prependListener)return emitter.prependListener(event,fn);emitter._events&&emitter._events[event]?isArray(emitter._events[event])?emitter._events[event].unshift(fn):emitter._events[event]=[fn,emitter._events[event]]:emitter.on(event,fn)}(dest,"error",onerror);function onclose(){dest.removeListener("finish",onfinish),unpipe()}dest.once("close",onclose);function onfinish(){debug("onfinish"),dest.removeListener("close",onclose),unpipe()}dest.once("finish",onfinish);function unpipe(){debug("unpipe"),src.unpipe(dest)}return dest.emit("pipe",src),state.flowing||(debug("pipe resume"),src.resume()),dest};Readable.prototype.unpipe=function(dest){var state=this._readableState,unpipeInfo={hasUnpiped:!1};if(0===state.pipesCount)return this;if(1===state.pipesCount)return dest&&dest!==state.pipes?this:(dest||(dest=state.pipes),state.pipes=null,state.pipesCount=0,state.flowing=!1,dest&&dest.emit("unpipe",this,unpipeInfo),this);if(!dest){var dests=state.pipes,len=state.pipesCount;state.pipes=null,state.pipesCount=0,state.flowing=!1;for(var i=0;i=state.length?(ret=state.decoder?state.buffer.join(""):1===state.buffer.length?state.buffer.head.data:state.buffer.concat(state.length),state.buffer.clear()):ret=function(n,list,hasStrings){var ret;nstr.length?str.length:n;if(nb===str.length?ret+=str:ret+=str.slice(0,n),0===(n-=nb)){nb===str.length?(++c,p.next?list.head=p.next:list.head=list.tail=null):(list.head=p,p.data=str.slice(nb));break}++c}return list.length-=c,ret}(n,list):function(n,list){var ret=Buffer.allocUnsafe(n),p=list.head,c=1;p.data.copy(ret),n-=p.data.length;for(;p=p.next;){var buf=p.data,nb=n>buf.length?buf.length:n;if(buf.copy(ret,ret.length-n,0,nb),0===(n-=nb)){nb===buf.length?(++c,p.next?list.head=p.next:list.head=list.tail=null):(list.head=p,p.data=buf.slice(nb));break}++c}return list.length-=c,ret}(n,list);return ret}(n,state.buffer,state.decoder),ret}function endReadable(stream){var state=stream._readableState;if(state.length>0)throw new Error('"endReadable()" called on non-empty stream');state.endEmitted||(state.ended=!0,processNextTick(endReadableNT,state,stream))}function endReadableNT(state,stream){state.endEmitted||0!==state.length||(state.endEmitted=!0,stream.readable=!1,stream.emit("end"))}function indexOf(xs,x){for(var i=0,l=xs.length;i-1?setImmediate:processNextTick;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var internalUtil={deprecate:require("util-deprecate")},Stream=require("./internal/streams/stream"),Buffer=require("safe-buffer").Buffer,OurUint8Array=global.Uint8Array||function(){};var destroyImpl=require("./internal/streams/destroy");util.inherits(Writable,Stream);function nop(){}function WritableState(options,stream){Duplex=Duplex||require("./_stream_duplex"),options=options||{},this.objectMode=!!options.objectMode,stream instanceof Duplex&&(this.objectMode=this.objectMode||!!options.writableObjectMode);var hwm=options.highWaterMark,defaultHwm=this.objectMode?16:16384;this.highWaterMark=hwm||0===hwm?hwm:defaultHwm,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var noDecode=!1===options.decodeStrings;this.decodeStrings=!noDecode,this.defaultEncoding=options.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(er){!function(stream,er){var state=stream._writableState,sync=state.sync,cb=state.writecb;if(function(state){state.writing=!1,state.writecb=null,state.length-=state.writelen,state.writelen=0}(state),er)!function(stream,state,sync,er,cb){--state.pendingcb,sync?(processNextTick(cb,er),processNextTick(finishMaybe,stream,state),stream._writableState.errorEmitted=!0,stream.emit("error",er)):(cb(er),stream._writableState.errorEmitted=!0,stream.emit("error",er),finishMaybe(stream,state))}(stream,state,sync,er,cb);else{var finished=needFinish(state);finished||state.corked||state.bufferProcessing||!state.bufferedRequest||clearBuffer(stream,state),sync?asyncWrite(afterWrite,stream,state,finished,cb):afterWrite(stream,state,finished,cb)}}(stream,er)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new CorkedRequest(this)}WritableState.prototype.getBuffer=function(){for(var current=this.bufferedRequest,out=[];current;)out.push(current),current=current.next;return out},function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(_){}}();var realHasInstance;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(realHasInstance=Function.prototype[Symbol.hasInstance],Object.defineProperty(Writable,Symbol.hasInstance,{value:function(object){return!!realHasInstance.call(this,object)||object&&object._writableState instanceof WritableState}})):realHasInstance=function(object){return object instanceof this};function Writable(options){if(Duplex=Duplex||require("./_stream_duplex"),!(realHasInstance.call(Writable,this)||this instanceof Duplex))return new Writable(options);this._writableState=new WritableState(options,this),this.writable=!0,options&&("function"==typeof options.write&&(this._write=options.write),"function"==typeof options.writev&&(this._writev=options.writev),"function"==typeof options.destroy&&(this._destroy=options.destroy),"function"==typeof options.final&&(this._final=options.final)),Stream.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};Writable.prototype.write=function(chunk,encoding,cb){var obj,state=this._writableState,ret=!1,isBuf=(obj=chunk,(Buffer.isBuffer(obj)||obj instanceof OurUint8Array)&&!state.objectMode);return isBuf&&!Buffer.isBuffer(chunk)&&(chunk=function(chunk){return Buffer.from(chunk)}(chunk)),"function"==typeof encoding&&(cb=encoding,encoding=null),isBuf?encoding="buffer":encoding||(encoding=state.defaultEncoding),"function"!=typeof cb&&(cb=nop),state.ended?function(stream,cb){var er=new Error("write after end");stream.emit("error",er),processNextTick(cb,er)}(this,cb):(isBuf||function(stream,state,chunk,cb){var valid=!0,er=!1;return null===chunk?er=new TypeError("May not write null values to stream"):"string"==typeof chunk||void 0===chunk||state.objectMode||(er=new TypeError("Invalid non-string/buffer chunk")),er&&(stream.emit("error",er),processNextTick(cb,er),valid=!1),valid}(this,state,chunk,cb))&&(state.pendingcb++,ret=function(stream,state,isBuf,chunk,encoding,cb){if(!isBuf){var newChunk=function(state,chunk,encoding){state.objectMode||!1===state.decodeStrings||"string"!=typeof chunk||(chunk=Buffer.from(chunk,encoding));return chunk}(state,chunk,encoding);chunk!==newChunk&&(isBuf=!0,encoding="buffer",chunk=newChunk)}var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length-1))throw new TypeError("Unknown encoding: "+encoding);return this._writableState.defaultEncoding=encoding,this};function doWrite(stream,state,writev,len,chunk,encoding,cb){state.writelen=len,state.writecb=cb,state.writing=!0,state.sync=!0,writev?stream._writev(chunk,state.onwrite):stream._write(chunk,encoding,state.onwrite),state.sync=!1}function afterWrite(stream,state,finished,cb){finished||function(stream,state){0===state.length&&state.needDrain&&(state.needDrain=!1,stream.emit("drain"))}(stream,state),state.pendingcb--,cb(),finishMaybe(stream,state)}function clearBuffer(stream,state){state.bufferProcessing=!0;var entry=state.bufferedRequest;if(stream._writev&&entry&&entry.next){var l=state.bufferedRequestCount,buffer=new Array(l),holder=state.corkedRequestsFree;holder.entry=entry;for(var count=0,allBuffers=!0;entry;)buffer[count]=entry,entry.isBuf||(allBuffers=!1),entry=entry.next,count+=1;buffer.allBuffers=allBuffers,doWrite(stream,state,!0,state.length,buffer,"",holder.finish),state.pendingcb++,state.lastBufferedRequest=null,holder.next?(state.corkedRequestsFree=holder.next,holder.next=null):state.corkedRequestsFree=new CorkedRequest(state)}else{for(;entry;){var chunk=entry.chunk,encoding=entry.encoding,cb=entry.callback;if(doWrite(stream,state,!1,state.objectMode?1:chunk.length,chunk,encoding,cb),entry=entry.next,state.writing)break}null===entry&&(state.lastBufferedRequest=null)}state.bufferedRequestCount=0,state.bufferedRequest=entry,state.bufferProcessing=!1}Writable.prototype._write=function(chunk,encoding,cb){cb(new Error("_write() is not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(chunk,encoding,cb){var state=this._writableState;"function"==typeof chunk?(cb=chunk,chunk=null,encoding=null):"function"==typeof encoding&&(cb=encoding,encoding=null),null!==chunk&&void 0!==chunk&&this.write(chunk,encoding),state.corked&&(state.corked=1,this.uncork()),state.ending||state.finished||function(stream,state,cb){state.ending=!0,finishMaybe(stream,state),cb&&(state.finished?processNextTick(cb):stream.once("finish",cb));state.ended=!0,stream.writable=!1}(this,state,cb)};function needFinish(state){return state.ending&&0===state.length&&null===state.bufferedRequest&&!state.finished&&!state.writing}function callFinal(stream,state){stream._final(function(err){state.pendingcb--,err&&stream.emit("error",err),state.prefinished=!0,stream.emit("prefinish"),finishMaybe(stream,state)})}function finishMaybe(stream,state){var need=needFinish(state);return need&&(!function(stream,state){state.prefinished||state.finalCalled||("function"==typeof stream._final?(state.pendingcb++,state.finalCalled=!0,processNextTick(callFinal,stream,state)):(state.prefinished=!0,stream.emit("prefinish")))}(stream,state),0===state.pendingcb&&(state.finished=!0,stream.emit("finish"))),need}Object.defineProperty(Writable.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(value){this._writableState&&(this._writableState.destroyed=value)}}),Writable.prototype.destroy=destroyImpl.destroy,Writable.prototype._undestroy=destroyImpl.undestroy,Writable.prototype._destroy=function(err,cb){this.end(),cb(err)}}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":177,"./internal/streams/destroy":183,"./internal/streams/stream":184,_process:162,"core-util-is":72,inherits:185,"process-nextick-args":161,"safe-buffer":191,"util-deprecate":204}],182:[function(require,module,exports){"use strict";var Buffer=require("safe-buffer").Buffer;module.exports=function(){function BufferList(){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,BufferList),this.head=null,this.tail=null,this.length=0}return BufferList.prototype.push=function(v){var entry={data:v,next:null};this.length>0?this.tail.next=entry:this.head=entry,this.tail=entry,++this.length},BufferList.prototype.unshift=function(v){var entry={data:v,next:this.head};0===this.length&&(this.tail=entry),this.head=entry,++this.length},BufferList.prototype.shift=function(){if(0!==this.length){var ret=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,ret}},BufferList.prototype.clear=function(){this.head=this.tail=null,this.length=0},BufferList.prototype.join=function(s){if(0===this.length)return"";for(var p=this.head,ret=""+p.data;p=p.next;)ret+=s+p.data;return ret},BufferList.prototype.concat=function(n){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var ret=Buffer.allocUnsafe(n>>>0),p=this.head,i=0;p;)src=p.data,target=ret,offset=i,src.copy(target,offset),i+=p.data.length,p=p.next;var src,target,offset;return ret},BufferList}()},{"safe-buffer":191}],183:[function(require,module,exports){"use strict";var processNextTick=require("process-nextick-args");function emitErrorNT(self,err){self.emit("error",err)}module.exports={destroy:function(err,cb){var _this=this,readableDestroyed=this._readableState&&this._readableState.destroyed,writableDestroyed=this._writableState&&this._writableState.destroyed;readableDestroyed||writableDestroyed?cb?cb(err):!err||this._writableState&&this._writableState.errorEmitted||processNextTick(emitErrorNT,this,err):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(err||null,function(err){!cb&&err?(processNextTick(emitErrorNT,_this,err),_this._writableState&&(_this._writableState.errorEmitted=!0)):cb&&cb(err)}))},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":161}],184:[function(require,module,exports){module.exports=require("events").EventEmitter},{events:122}],185:[function(require,module,exports){arguments[4][137][0].apply(exports,arguments)},{dup:137}],186:[function(require,module,exports){module.exports=require("./readable").PassThrough},{"./readable":187}],187:[function(require,module,exports){(exports=module.exports=require("./lib/_stream_readable.js")).Stream=exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":177,"./lib/_stream_passthrough.js":178,"./lib/_stream_readable.js":179,"./lib/_stream_transform.js":180,"./lib/_stream_writable.js":181}],188:[function(require,module,exports){module.exports=require("./readable").Transform},{"./readable":187}],189:[function(require,module,exports){module.exports=require("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":181}],190:[function(require,module,exports){(function(Buffer){"use strict";var inherits=require("inherits"),HashBase=require("hash-base");function RIPEMD160(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}inherits(RIPEMD160,HashBase),RIPEMD160.prototype._update=function(){for(var m=new Array(16),i=0;i<16;++i)m[i]=this._block.readInt32LE(4*i);var al=this._a,bl=this._b,cl=this._c,dl=this._d,el=this._e;el=fn1(el,al=fn1(al,bl,cl,dl,el,m[0],0,11),bl,cl=rotl(cl,10),dl,m[1],0,14),bl=fn1(bl=rotl(bl,10),cl=fn1(cl,dl=fn1(dl,el,al,bl,cl,m[2],0,15),el,al=rotl(al,10),bl,m[3],0,12),dl,el=rotl(el,10),al,m[4],0,5),dl=fn1(dl=rotl(dl,10),el=fn1(el,al=fn1(al,bl,cl,dl,el,m[5],0,8),bl,cl=rotl(cl,10),dl,m[6],0,7),al,bl=rotl(bl,10),cl,m[7],0,9),al=fn1(al=rotl(al,10),bl=fn1(bl,cl=fn1(cl,dl,el,al,bl,m[8],0,11),dl,el=rotl(el,10),al,m[9],0,13),cl,dl=rotl(dl,10),el,m[10],0,14),cl=fn1(cl=rotl(cl,10),dl=fn1(dl,el=fn1(el,al,bl,cl,dl,m[11],0,15),al,bl=rotl(bl,10),cl,m[12],0,6),el,al=rotl(al,10),bl,m[13],0,7),el=fn2(el=rotl(el,10),al=fn1(al,bl=fn1(bl,cl,dl,el,al,m[14],0,9),cl,dl=rotl(dl,10),el,m[15],0,8),bl,cl=rotl(cl,10),dl,m[7],1518500249,7),bl=fn2(bl=rotl(bl,10),cl=fn2(cl,dl=fn2(dl,el,al,bl,cl,m[4],1518500249,6),el,al=rotl(al,10),bl,m[13],1518500249,8),dl,el=rotl(el,10),al,m[1],1518500249,13),dl=fn2(dl=rotl(dl,10),el=fn2(el,al=fn2(al,bl,cl,dl,el,m[10],1518500249,11),bl,cl=rotl(cl,10),dl,m[6],1518500249,9),al,bl=rotl(bl,10),cl,m[15],1518500249,7),al=fn2(al=rotl(al,10),bl=fn2(bl,cl=fn2(cl,dl,el,al,bl,m[3],1518500249,15),dl,el=rotl(el,10),al,m[12],1518500249,7),cl,dl=rotl(dl,10),el,m[0],1518500249,12),cl=fn2(cl=rotl(cl,10),dl=fn2(dl,el=fn2(el,al,bl,cl,dl,m[9],1518500249,15),al,bl=rotl(bl,10),cl,m[5],1518500249,9),el,al=rotl(al,10),bl,m[2],1518500249,11),el=fn2(el=rotl(el,10),al=fn2(al,bl=fn2(bl,cl,dl,el,al,m[14],1518500249,7),cl,dl=rotl(dl,10),el,m[11],1518500249,13),bl,cl=rotl(cl,10),dl,m[8],1518500249,12),bl=fn3(bl=rotl(bl,10),cl=fn3(cl,dl=fn3(dl,el,al,bl,cl,m[3],1859775393,11),el,al=rotl(al,10),bl,m[10],1859775393,13),dl,el=rotl(el,10),al,m[14],1859775393,6),dl=fn3(dl=rotl(dl,10),el=fn3(el,al=fn3(al,bl,cl,dl,el,m[4],1859775393,7),bl,cl=rotl(cl,10),dl,m[9],1859775393,14),al,bl=rotl(bl,10),cl,m[15],1859775393,9),al=fn3(al=rotl(al,10),bl=fn3(bl,cl=fn3(cl,dl,el,al,bl,m[8],1859775393,13),dl,el=rotl(el,10),al,m[1],1859775393,15),cl,dl=rotl(dl,10),el,m[2],1859775393,14),cl=fn3(cl=rotl(cl,10),dl=fn3(dl,el=fn3(el,al,bl,cl,dl,m[7],1859775393,8),al,bl=rotl(bl,10),cl,m[0],1859775393,13),el,al=rotl(al,10),bl,m[6],1859775393,6),el=fn3(el=rotl(el,10),al=fn3(al,bl=fn3(bl,cl,dl,el,al,m[13],1859775393,5),cl,dl=rotl(dl,10),el,m[11],1859775393,12),bl,cl=rotl(cl,10),dl,m[5],1859775393,7),bl=fn4(bl=rotl(bl,10),cl=fn4(cl,dl=fn3(dl,el,al,bl,cl,m[12],1859775393,5),el,al=rotl(al,10),bl,m[1],2400959708,11),dl,el=rotl(el,10),al,m[9],2400959708,12),dl=fn4(dl=rotl(dl,10),el=fn4(el,al=fn4(al,bl,cl,dl,el,m[11],2400959708,14),bl,cl=rotl(cl,10),dl,m[10],2400959708,15),al,bl=rotl(bl,10),cl,m[0],2400959708,14),al=fn4(al=rotl(al,10),bl=fn4(bl,cl=fn4(cl,dl,el,al,bl,m[8],2400959708,15),dl,el=rotl(el,10),al,m[12],2400959708,9),cl,dl=rotl(dl,10),el,m[4],2400959708,8),cl=fn4(cl=rotl(cl,10),dl=fn4(dl,el=fn4(el,al,bl,cl,dl,m[13],2400959708,9),al,bl=rotl(bl,10),cl,m[3],2400959708,14),el,al=rotl(al,10),bl,m[7],2400959708,5),el=fn4(el=rotl(el,10),al=fn4(al,bl=fn4(bl,cl,dl,el,al,m[15],2400959708,6),cl,dl=rotl(dl,10),el,m[14],2400959708,8),bl,cl=rotl(cl,10),dl,m[5],2400959708,6),bl=fn5(bl=rotl(bl,10),cl=fn4(cl,dl=fn4(dl,el,al,bl,cl,m[6],2400959708,5),el,al=rotl(al,10),bl,m[2],2400959708,12),dl,el=rotl(el,10),al,m[4],2840853838,9),dl=fn5(dl=rotl(dl,10),el=fn5(el,al=fn5(al,bl,cl,dl,el,m[0],2840853838,15),bl,cl=rotl(cl,10),dl,m[5],2840853838,5),al,bl=rotl(bl,10),cl,m[9],2840853838,11),al=fn5(al=rotl(al,10),bl=fn5(bl,cl=fn5(cl,dl,el,al,bl,m[7],2840853838,6),dl,el=rotl(el,10),al,m[12],2840853838,8),cl,dl=rotl(dl,10),el,m[2],2840853838,13),cl=fn5(cl=rotl(cl,10),dl=fn5(dl,el=fn5(el,al,bl,cl,dl,m[10],2840853838,12),al,bl=rotl(bl,10),cl,m[14],2840853838,5),el,al=rotl(al,10),bl,m[1],2840853838,12),el=fn5(el=rotl(el,10),al=fn5(al,bl=fn5(bl,cl,dl,el,al,m[3],2840853838,13),cl,dl=rotl(dl,10),el,m[8],2840853838,14),bl,cl=rotl(cl,10),dl,m[11],2840853838,11),bl=fn5(bl=rotl(bl,10),cl=fn5(cl,dl=fn5(dl,el,al,bl,cl,m[6],2840853838,8),el,al=rotl(al,10),bl,m[15],2840853838,5),dl,el=rotl(el,10),al,m[13],2840853838,6),dl=rotl(dl,10);var ar=this._a,br=this._b,cr=this._c,dr=this._d,er=this._e;er=fn5(er,ar=fn5(ar,br,cr,dr,er,m[5],1352829926,8),br,cr=rotl(cr,10),dr,m[14],1352829926,9),br=fn5(br=rotl(br,10),cr=fn5(cr,dr=fn5(dr,er,ar,br,cr,m[7],1352829926,9),er,ar=rotl(ar,10),br,m[0],1352829926,11),dr,er=rotl(er,10),ar,m[9],1352829926,13),dr=fn5(dr=rotl(dr,10),er=fn5(er,ar=fn5(ar,br,cr,dr,er,m[2],1352829926,15),br,cr=rotl(cr,10),dr,m[11],1352829926,15),ar,br=rotl(br,10),cr,m[4],1352829926,5),ar=fn5(ar=rotl(ar,10),br=fn5(br,cr=fn5(cr,dr,er,ar,br,m[13],1352829926,7),dr,er=rotl(er,10),ar,m[6],1352829926,7),cr,dr=rotl(dr,10),er,m[15],1352829926,8),cr=fn5(cr=rotl(cr,10),dr=fn5(dr,er=fn5(er,ar,br,cr,dr,m[8],1352829926,11),ar,br=rotl(br,10),cr,m[1],1352829926,14),er,ar=rotl(ar,10),br,m[10],1352829926,14),er=fn4(er=rotl(er,10),ar=fn5(ar,br=fn5(br,cr,dr,er,ar,m[3],1352829926,12),cr,dr=rotl(dr,10),er,m[12],1352829926,6),br,cr=rotl(cr,10),dr,m[6],1548603684,9),br=fn4(br=rotl(br,10),cr=fn4(cr,dr=fn4(dr,er,ar,br,cr,m[11],1548603684,13),er,ar=rotl(ar,10),br,m[3],1548603684,15),dr,er=rotl(er,10),ar,m[7],1548603684,7),dr=fn4(dr=rotl(dr,10),er=fn4(er,ar=fn4(ar,br,cr,dr,er,m[0],1548603684,12),br,cr=rotl(cr,10),dr,m[13],1548603684,8),ar,br=rotl(br,10),cr,m[5],1548603684,9),ar=fn4(ar=rotl(ar,10),br=fn4(br,cr=fn4(cr,dr,er,ar,br,m[10],1548603684,11),dr,er=rotl(er,10),ar,m[14],1548603684,7),cr,dr=rotl(dr,10),er,m[15],1548603684,7),cr=fn4(cr=rotl(cr,10),dr=fn4(dr,er=fn4(er,ar,br,cr,dr,m[8],1548603684,12),ar,br=rotl(br,10),cr,m[12],1548603684,7),er,ar=rotl(ar,10),br,m[4],1548603684,6),er=fn4(er=rotl(er,10),ar=fn4(ar,br=fn4(br,cr,dr,er,ar,m[9],1548603684,15),cr,dr=rotl(dr,10),er,m[1],1548603684,13),br,cr=rotl(cr,10),dr,m[2],1548603684,11),br=fn3(br=rotl(br,10),cr=fn3(cr,dr=fn3(dr,er,ar,br,cr,m[15],1836072691,9),er,ar=rotl(ar,10),br,m[5],1836072691,7),dr,er=rotl(er,10),ar,m[1],1836072691,15),dr=fn3(dr=rotl(dr,10),er=fn3(er,ar=fn3(ar,br,cr,dr,er,m[3],1836072691,11),br,cr=rotl(cr,10),dr,m[7],1836072691,8),ar,br=rotl(br,10),cr,m[14],1836072691,6),ar=fn3(ar=rotl(ar,10),br=fn3(br,cr=fn3(cr,dr,er,ar,br,m[6],1836072691,6),dr,er=rotl(er,10),ar,m[9],1836072691,14),cr,dr=rotl(dr,10),er,m[11],1836072691,12),cr=fn3(cr=rotl(cr,10),dr=fn3(dr,er=fn3(er,ar,br,cr,dr,m[8],1836072691,13),ar,br=rotl(br,10),cr,m[12],1836072691,5),er,ar=rotl(ar,10),br,m[2],1836072691,14),er=fn3(er=rotl(er,10),ar=fn3(ar,br=fn3(br,cr,dr,er,ar,m[10],1836072691,13),cr,dr=rotl(dr,10),er,m[0],1836072691,13),br,cr=rotl(cr,10),dr,m[4],1836072691,7),br=fn2(br=rotl(br,10),cr=fn2(cr,dr=fn3(dr,er,ar,br,cr,m[13],1836072691,5),er,ar=rotl(ar,10),br,m[8],2053994217,15),dr,er=rotl(er,10),ar,m[6],2053994217,5),dr=fn2(dr=rotl(dr,10),er=fn2(er,ar=fn2(ar,br,cr,dr,er,m[4],2053994217,8),br,cr=rotl(cr,10),dr,m[1],2053994217,11),ar,br=rotl(br,10),cr,m[3],2053994217,14),ar=fn2(ar=rotl(ar,10),br=fn2(br,cr=fn2(cr,dr,er,ar,br,m[11],2053994217,14),dr,er=rotl(er,10),ar,m[15],2053994217,6),cr,dr=rotl(dr,10),er,m[0],2053994217,14),cr=fn2(cr=rotl(cr,10),dr=fn2(dr,er=fn2(er,ar,br,cr,dr,m[5],2053994217,6),ar,br=rotl(br,10),cr,m[12],2053994217,9),er,ar=rotl(ar,10),br,m[2],2053994217,12),er=fn2(er=rotl(er,10),ar=fn2(ar,br=fn2(br,cr,dr,er,ar,m[13],2053994217,9),cr,dr=rotl(dr,10),er,m[9],2053994217,12),br,cr=rotl(cr,10),dr,m[7],2053994217,5),br=fn1(br=rotl(br,10),cr=fn2(cr,dr=fn2(dr,er,ar,br,cr,m[10],2053994217,15),er,ar=rotl(ar,10),br,m[14],2053994217,8),dr,er=rotl(er,10),ar,m[12],0,8),dr=fn1(dr=rotl(dr,10),er=fn1(er,ar=fn1(ar,br,cr,dr,er,m[15],0,5),br,cr=rotl(cr,10),dr,m[10],0,12),ar,br=rotl(br,10),cr,m[4],0,9),ar=fn1(ar=rotl(ar,10),br=fn1(br,cr=fn1(cr,dr,er,ar,br,m[1],0,12),dr,er=rotl(er,10),ar,m[5],0,5),cr,dr=rotl(dr,10),er,m[8],0,14),cr=fn1(cr=rotl(cr,10),dr=fn1(dr,er=fn1(er,ar,br,cr,dr,m[7],0,6),ar,br=rotl(br,10),cr,m[6],0,8),er,ar=rotl(ar,10),br,m[2],0,13),er=fn1(er=rotl(er,10),ar=fn1(ar,br=fn1(br,cr,dr,er,ar,m[13],0,6),cr,dr=rotl(dr,10),er,m[14],0,5),br,cr=rotl(cr,10),dr,m[0],0,15),br=fn1(br=rotl(br,10),cr=fn1(cr,dr=fn1(dr,er,ar,br,cr,m[3],0,13),er,ar=rotl(ar,10),br,m[9],0,11),dr,er=rotl(er,10),ar,m[11],0,11),dr=rotl(dr,10);var t=this._b+cl+dr|0;this._b=this._c+dl+er|0,this._c=this._d+el+ar|0,this._d=this._e+al+br|0,this._e=this._a+bl+cr|0,this._a=t},RIPEMD160.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=new Buffer(20);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer.writeInt32LE(this._e,16),buffer};function rotl(x,n){return x<>>32-n}function fn1(a,b,c,d,e,m,k,s){return rotl(a+(b^c^d)+m+k|0,s)+e|0}function fn2(a,b,c,d,e,m,k,s){return rotl(a+(b&c|~b&d)+m+k|0,s)+e|0}function fn3(a,b,c,d,e,m,k,s){return rotl(a+((b|~c)^d)+m+k|0,s)+e|0}function fn4(a,b,c,d,e,m,k,s){return rotl(a+(b&d|c&~d)+m+k|0,s)+e|0}function fn5(a,b,c,d,e,m,k,s){return rotl(a+(b^(c|~d))+m+k|0,s)+e|0}module.exports=RIPEMD160}).call(this,require("buffer").Buffer)},{buffer:70,"hash-base":124,inherits:141}],191:[function(require,module,exports){var buffer=require("buffer"),Buffer=buffer.Buffer;function copyProps(src,dst){for(var key in src)dst[key]=src[key]}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer);function SafeBuffer(arg,encodingOrOffset,length){return Buffer(arg,encodingOrOffset,length)}copyProps(Buffer,SafeBuffer),SafeBuffer.from=function(arg,encodingOrOffset,length){if("number"==typeof arg)throw new TypeError("Argument must not be a number");return Buffer(arg,encodingOrOffset,length)},SafeBuffer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("Argument must be a number");var buf=Buffer(size);return void 0!==fill?"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill):buf.fill(0),buf},SafeBuffer.allocUnsafe=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return Buffer(size)},SafeBuffer.allocUnsafeSlow=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return buffer.SlowBuffer(size)}},{buffer:70}],192:[function(require,module,exports){var Buffer=require("safe-buffer").Buffer;function Hash(blockSize,finalSize){this._block=Buffer.alloc(blockSize),this._finalSize=finalSize,this._blockSize=blockSize,this._len=0}Hash.prototype.update=function(data,enc){"string"==typeof data&&(enc=enc||"utf8",data=Buffer.from(data,enc));for(var block=this._block,blockSize=this._blockSize,length=data.length,accum=this._len,offset=0;offset=this._finalSize&&(this._update(this._block),this._block.fill(0));var bits=8*this._len;if(bits<=4294967295)this._block.writeUInt32BE(bits,this._blockSize-4);else{var lowBits=4294967295&bits,highBits=(bits-lowBits)/4294967296;this._block.writeUInt32BE(highBits,this._blockSize-8),this._block.writeUInt32BE(lowBits,this._blockSize-4)}this._update(this._block);var hash=this._hash();return enc?hash.toString(enc):hash},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},module.exports=Hash},{"safe-buffer":191}],193:[function(require,module,exports){(exports=module.exports=function(algorithm){algorithm=algorithm.toLowerCase();var Algorithm=exports[algorithm];if(!Algorithm)throw new Error(algorithm+" is not supported (we accept pull requests)");return new Algorithm}).sha=require("./sha"),exports.sha1=require("./sha1"),exports.sha224=require("./sha224"),exports.sha256=require("./sha256"),exports.sha384=require("./sha384"),exports.sha512=require("./sha512")},{"./sha":194,"./sha1":195,"./sha224":196,"./sha256":197,"./sha384":198,"./sha512":199}],194:[function(require,module,exports){var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}Sha.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;i<16;++i)W[i]=M.readInt32BE(4*i);for(;i<80;++i)W[i]=W[i-3]^W[i-8]^W[i-14]^W[i-16];for(var j=0;j<80;++j){var s=~~(j/20),t=0|(num=a,(num<<5|num>>>27)+ft(s,b,c,d)+e+W[j]+K[s]);e=d,d=c,c=rotl30(b),b=a,a=t}var num;this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0},Sha.prototype._hash=function(){var H=Buffer.allocUnsafe(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha},{"./hash":192,inherits:141,"safe-buffer":191}],195:[function(require,module,exports){var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}Sha1.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;i<16;++i)W[i]=M.readInt32BE(4*i);for(;i<80;++i)W[i]=(num=W[i-3]^W[i-8]^W[i-14]^W[i-16],num<<1|num>>>31);for(var num,j=0;j<80;++j){var s=~~(j/20),t=rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s]|0;e=d,d=c,c=rotl30(b),b=a,a=t}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0},Sha1.prototype._hash=function(){var H=Buffer.allocUnsafe(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha1},{"./hash":192,inherits:141,"safe-buffer":191}],196:[function(require,module,exports){var inherits=require("inherits"),Sha256=require("./sha256"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=new Array(64);function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var H=Buffer.allocUnsafe(28);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H},module.exports=Sha224},{"./hash":192,"./sha256":197,inherits:141,"safe-buffer":191}],197:[function(require,module,exports){var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[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],W=new Array(64);function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function sigma1(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function gamma0(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}Sha256.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,f=0|this._f,g=0|this._g,h=0|this._h,i=0;i<16;++i)W[i]=M.readInt32BE(4*i);for(;i<64;++i)W[i]=0|(x=W[i-2],((x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10)+W[i-7]+gamma0(W[i-15])+W[i-16]);for(var x,j=0;j<64;++j){var T1=h+sigma1(e)+ch(e,f,g)+K[j]+W[j]|0,T2=sigma0(a)+maj(a,b,c)|0;h=g,g=f,f=e,e=d+T1|0,d=c,c=b,b=a,a=T1+T2|0}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0,this._f=f+this._f|0,this._g=g+this._g|0,this._h=h+this._h|0},Sha256.prototype._hash=function(){var H=Buffer.allocUnsafe(32);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H.writeInt32BE(this._h,28),H},module.exports=Sha256},{"./hash":192,inherits:141,"safe-buffer":191}],198:[function(require,module,exports){var inherits=require("inherits"),SHA512=require("./sha512"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=new Array(160);function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){var H=Buffer.allocUnsafe(48);function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),H},module.exports=Sha384},{"./hash":192,"./sha512":199,inherits:141,"safe-buffer":191}],199:[function(require,module,exports){var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=new Array(160);function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x,xl){return(x>>>28|xl<<4)^(xl>>>2|x<<30)^(xl>>>7|x<<25)}function sigma1(x,xl){return(x>>>14|xl<<18)^(x>>>18|xl<<14)^(xl>>>9|x<<23)}function Gamma0(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^x>>>7}function Gamma0l(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^(x>>>7|xl<<25)}function Gamma1(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^x>>>6}function Gamma1l(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^(x>>>6|xl<<26)}function getCarry(a,b){return a>>>0>>0?1:0}Sha512.prototype._update=function(M){for(var W=this._w,ah=0|this._ah,bh=0|this._bh,ch=0|this._ch,dh=0|this._dh,eh=0|this._eh,fh=0|this._fh,gh=0|this._gh,hh=0|this._hh,al=0|this._al,bl=0|this._bl,cl=0|this._cl,dl=0|this._dl,el=0|this._el,fl=0|this._fl,gl=0|this._gl,hl=0|this._hl,i=0;i<32;i+=2)W[i]=M.readInt32BE(4*i),W[i+1]=M.readInt32BE(4*i+4);for(;i<160;i+=2){var xh=W[i-30],xl=W[i-30+1],gamma0=Gamma0(xh,xl),gamma0l=Gamma0l(xl,xh),gamma1=Gamma1(xh=W[i-4],xl=W[i-4+1]),gamma1l=Gamma1l(xl,xh),Wi7h=W[i-14],Wi7l=W[i-14+1],Wi16h=W[i-32],Wi16l=W[i-32+1],Wil=gamma0l+Wi7l|0,Wih=gamma0+Wi7h+getCarry(Wil,gamma0l)|0;Wih=(Wih=Wih+gamma1+getCarry(Wil=Wil+gamma1l|0,gamma1l)|0)+Wi16h+getCarry(Wil=Wil+Wi16l|0,Wi16l)|0,W[i]=Wih,W[i+1]=Wil}for(var j=0;j<160;j+=2){Wih=W[j],Wil=W[j+1];var majh=maj(ah,bh,ch),majl=maj(al,bl,cl),sigma0h=sigma0(ah,al),sigma0l=sigma0(al,ah),sigma1h=sigma1(eh,el),sigma1l=sigma1(el,eh),Kih=K[j],Kil=K[j+1],chh=Ch(eh,fh,gh),chl=Ch(el,fl,gl),t1l=hl+sigma1l|0,t1h=hh+sigma1h+getCarry(t1l,hl)|0;t1h=(t1h=(t1h=t1h+chh+getCarry(t1l=t1l+chl|0,chl)|0)+Kih+getCarry(t1l=t1l+Kil|0,Kil)|0)+Wih+getCarry(t1l=t1l+Wil|0,Wil)|0;var t2l=sigma0l+majl|0,t2h=sigma0h+majh+getCarry(t2l,sigma0l)|0;hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,eh=dh+t1h+getCarry(el=dl+t1l|0,dl)|0,dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,ah=t1h+t2h+getCarry(al=t1l+t2l|0,t1l)|0}this._al=this._al+al|0,this._bl=this._bl+bl|0,this._cl=this._cl+cl|0,this._dl=this._dl+dl|0,this._el=this._el+el|0,this._fl=this._fl+fl|0,this._gl=this._gl+gl|0,this._hl=this._hl+hl|0,this._ah=this._ah+ah+getCarry(this._al,al)|0,this._bh=this._bh+bh+getCarry(this._bl,bl)|0,this._ch=this._ch+ch+getCarry(this._cl,cl)|0,this._dh=this._dh+dh+getCarry(this._dl,dl)|0,this._eh=this._eh+eh+getCarry(this._el,el)|0,this._fh=this._fh+fh+getCarry(this._fl,fl)|0,this._gh=this._gh+gh+getCarry(this._gl,gl)|0,this._hh=this._hh+hh+getCarry(this._hl,hl)|0},Sha512.prototype._hash=function(){var H=Buffer.allocUnsafe(64);function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),writeInt64BE(this._gh,this._gl,48),writeInt64BE(this._hh,this._hl,56),H},module.exports=Sha512},{"./hash":192,inherits:141,"safe-buffer":191}],200:[function(require,module,exports){module.exports=Stream;var EE=require("events").EventEmitter;require("inherits")(Stream,EE),Stream.Readable=require("readable-stream/readable.js"),Stream.Writable=require("readable-stream/writable.js"),Stream.Duplex=require("readable-stream/duplex.js"),Stream.Transform=require("readable-stream/transform.js"),Stream.PassThrough=require("readable-stream/passthrough.js"),Stream.Stream=Stream;function Stream(){EE.call(this)}Stream.prototype.pipe=function(dest,options){var source=this;function ondata(chunk){dest.writable&&!1===dest.write(chunk)&&source.pause&&source.pause()}source.on("data",ondata);function ondrain(){source.readable&&source.resume&&source.resume()}dest.on("drain",ondrain),dest._isStdio||options&&!1===options.end||(source.on("end",onend),source.on("close",onclose));var didOnEnd=!1;function onend(){didOnEnd||(didOnEnd=!0,dest.end())}function onclose(){didOnEnd||(didOnEnd=!0,"function"==typeof dest.destroy&&dest.destroy())}function onerror(er){if(cleanup(),0===EE.listenerCount(this,"error"))throw er}source.on("error",onerror),dest.on("error",onerror);function cleanup(){source.removeListener("data",ondata),dest.removeListener("drain",ondrain),source.removeListener("end",onend),source.removeListener("close",onclose),source.removeListener("error",onerror),dest.removeListener("error",onerror),source.removeListener("end",cleanup),source.removeListener("close",cleanup),dest.removeListener("close",cleanup)}return source.on("end",cleanup),source.on("close",cleanup),dest.on("close",cleanup),dest.emit("pipe",source),dest}},{events:122,inherits:141,"readable-stream/duplex.js":176,"readable-stream/passthrough.js":186,"readable-stream/readable.js":187,"readable-stream/transform.js":188,"readable-stream/writable.js":189}],201:[function(require,module,exports){"use strict";var Buffer=require("safe-buffer").Buffer,isEncoding=Buffer.isEncoding||function(encoding){switch((encoding=""+encoding)&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};exports.StringDecoder=StringDecoder;function StringDecoder(encoding){this.encoding=function(enc){var nenc=function(enc){if(!enc)return"utf8";for(var retried;;)switch(enc){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return enc;default:if(retried)return;enc=(""+enc).toLowerCase(),retried=!0}}(enc);if("string"!=typeof nenc&&(Buffer.isEncoding===isEncoding||!isEncoding(enc)))throw new Error("Unknown encoding: "+enc);return nenc||enc}(encoding);var nb;switch(this.encoding){case"utf16le":this.text=utf16Text,this.end=utf16End,nb=4;break;case"utf8":this.fillLast=utf8FillLast,nb=4;break;case"base64":this.text=base64Text,this.end=base64End,nb=3;break;default:return this.write=simpleWrite,void(this.end=simpleEnd)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(nb)}StringDecoder.prototype.write=function(buf){if(0===buf.length)return"";var r,i;if(this.lastNeed){if(void 0===(r=this.fillLast(buf)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i=0)return nb>0&&(self.lastNeed=nb-1),nb;if(--j=0)return nb>0&&(self.lastNeed=nb-2),nb;if(--j=0)return nb>0&&(2===nb?nb=0:self.lastNeed=nb-3),nb;return 0}(this,buf,i);if(!this.lastNeed)return buf.toString("utf8",i);this.lastTotal=total;var end=buf.length-(total-this.lastNeed);return buf.copy(this.lastChar,0,end),buf.toString("utf8",i,end)},StringDecoder.prototype.fillLast=function(buf){if(this.lastNeed<=buf.length)return buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,buf.length),this.lastNeed-=buf.length};function utf8CheckByte(byte){return byte<=127?0:byte>>5==6?2:byte>>4==14?3:byte>>3==30?4:-1}function utf8FillLast(buf){var p=this.lastTotal-this.lastNeed,r=function(self,buf,p){if(128!=(192&buf[0]))return self.lastNeed=0,"�".repeat(p);if(self.lastNeed>1&&buf.length>1){if(128!=(192&buf[1]))return self.lastNeed=1,"�".repeat(p+1);if(self.lastNeed>2&&buf.length>2&&128!=(192&buf[2]))return self.lastNeed=2,"�".repeat(p+2)}}(this,buf,p);return void 0!==r?r:this.lastNeed<=buf.length?(buf.copy(this.lastChar,p,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(buf.copy(this.lastChar,p,0,buf.length),void(this.lastNeed-=buf.length))}function utf16Text(buf,i){if((buf.length-i)%2==0){var r=buf.toString("utf16le",i);if(r){var c=r.charCodeAt(r.length-1);if(c>=55296&&c<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=buf[buf.length-1],buf.toString("utf16le",i,buf.length-1)}function utf16End(buf){var r=buf&&buf.length?this.write(buf):"";if(this.lastNeed){var end=this.lastTotal-this.lastNeed;return r+this.lastChar.toString("utf16le",0,end)}return r}function base64Text(buf,i){var n=(buf.length-i)%3;return 0===n?buf.toString("base64",i):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=buf[buf.length-1]:(this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1]),buf.toString("base64",i,buf.length-n))}function base64End(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+this.lastChar.toString("base64",0,3-this.lastNeed):r}function simpleWrite(buf){return buf.toString(this.encoding)}function simpleEnd(buf){return buf&&buf.length?this.write(buf):""}},{"safe-buffer":191}],202:[function(require,module,exports){"use strict";var punycode=require("punycode"),util=require("./util");exports.parse=urlParse,exports.resolve=function(source,relative){return urlParse(source,!1,!0).resolve(relative)},exports.resolveObject=function(source,relative){return source?urlParse(source,!1,!0).resolveObject(relative):relative},exports.format=function(obj){util.isString(obj)&&(obj=urlParse(obj));return obj instanceof Url?obj.format():Url.prototype.format.call(obj)},exports.Url=Url;function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,simplePathPattern=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,unwise=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require("querystring");function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&util.isObject(url)&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!util.isString(url))throw new TypeError("Parameter 'url' must be a string, not "+typeof url);var queryIndex=url.indexOf("?"),splitter=-1!==queryIndex&&queryIndex127?newpart+="x":newpart+=part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(hostnamePartStart);bit&&(validParts.push(bit[1]),notHost.unshift(bit[2])),notHost.length&&(rest="/"+notHost.join(".")+rest),this.hostname=validParts.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),ipv6Hostname||(this.hostname=punycode.toASCII(this.hostname));var p=this.port?":"+this.port:"",h=this.hostname||"";this.host=h+p,this.href+=this.host,ipv6Hostname&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==rest[0]&&(rest="/"+rest))}if(!unsafeProtocol[lowerProto])for(i=0,l=autoEscape.length;i0)&&result.host.split("@"))&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return result.search=relative.search,result.query=relative.query,util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.href=result.format(),result}if(!srcPath.length)return result.pathname=null,result.search?result.path="/"+result.search:result.path=null,result.href=result.format(),result;for(var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||srcPath.length>1)&&("."===last||".."===last)||""===last,up=0,i=srcPath.length;i>=0;i--)"."===(last=srcPath[i])?srcPath.splice(i,1):".."===last?(srcPath.splice(i,1),up++):up&&(srcPath.splice(i,1),up--);if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift("..");!mustEndAbs||""===srcPath[0]||srcPath[0]&&"/"===srcPath[0].charAt(0)||srcPath.unshift(""),hasTrailingSlash&&"/"!==srcPath.join("/").substr(-1)&&srcPath.push("");var isAbsolute=""===srcPath[0]||srcPath[0]&&"/"===srcPath[0].charAt(0);if(psychotic){result.hostname=result.host=isAbsolute?"":srcPath.length?srcPath.shift():"";var authInHost;(authInHost=!!(result.host&&result.host.indexOf("@")>0)&&result.host.split("@"))&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return(mustEndAbs=mustEndAbs||result.host&&srcPath.length)&&!isAbsolute&&srcPath.unshift(""),srcPath.length?result.pathname=srcPath.join("/"):(result.pathname=null,result.path=null),util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result},Url.prototype.parseHost=function(){var host=this.host,port=portPattern.exec(host);port&&(":"!==(port=port[0])&&(this.port=port.substr(1)),host=host.substr(0,host.length-port.length)),host&&(this.hostname=host)}},{"./util":203,punycode:170,querystring:173}],203:[function(require,module,exports){"use strict";module.exports={isString:function(arg){return"string"==typeof arg},isObject:function(arg){return"object"==typeof arg&&null!==arg},isNull:function(arg){return null===arg},isNullOrUndefined:function(arg){return null==arg}}},{}],204:[function(require,module,exports){(function(global){module.exports=function(fn,msg){if(config("noDeprecation"))return fn;var warned=!1;return function(){if(!warned){if(config("throwDeprecation"))throw new Error(msg);config("traceDeprecation")?console.trace(msg):console.warn(msg),warned=!0}return fn.apply(this,arguments)}};function config(name){try{if(!global.localStorage)return!1}catch(_){return!1}var val=global.localStorage[name];return null!=val&&"true"===String(val).toLowerCase()}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],205:[function(require,module,exports){module.exports=function(arg){return arg&&"object"==typeof arg&&"function"==typeof arg.copy&&"function"==typeof arg.fill&&"function"==typeof arg.readUInt8}},{}],206:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){for(var objects=[],i=0;i=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}}),x=args[i];i=3&&(ctx.depth=arguments[2]),arguments.length>=4&&(ctx.colors=arguments[3]),isBoolean(opts)?ctx.showHidden=opts:opts&&exports._extend(ctx,opts),isUndefined(ctx.showHidden)&&(ctx.showHidden=!1),isUndefined(ctx.depth)&&(ctx.depth=2),isUndefined(ctx.colors)&&(ctx.colors=!1),isUndefined(ctx.customInspect)&&(ctx.customInspect=!0),ctx.colors&&(ctx.stylize=stylizeWithColor),formatValue(ctx,obj,ctx.depth)}exports.inspect=inspect,inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];return style?"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m":str}function stylizeNoColor(str,styleType){return str}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&(!value.constructor||value.constructor.prototype!==value)){var ret=value.inspect(recurseTimes,ctx);return isString(ret)||(ret=formatValue(ctx,ret,recurseTimes)),ret}var primitive=function(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(isNull(value))return ctx.stylize("null","null")}(ctx,value);if(primitive)return primitive;var keys=Object.keys(value),visibleKeys=function(array){var hash={};return array.forEach(function(val,idx){hash[val]=!0}),hash}(keys);if(ctx.showHidden&&(keys=Object.getOwnPropertyNames(value)),isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0))return formatError(value);if(0===keys.length){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),"regexp");if(isDate(value))return ctx.stylize(Date.prototype.toString.call(value),"date");if(isError(value))return formatError(value)}var base="",array=!1,braces=["{","}"];if(isArray(value)&&(array=!0,braces=["[","]"]),isFunction(value)){base=" [Function"+(value.name?": "+value.name:"")+"]"}if(isRegExp(value)&&(base=" "+RegExp.prototype.toString.call(value)),isDate(value)&&(base=" "+Date.prototype.toUTCString.call(value)),isError(value)&&(base=" "+formatError(value)),0===keys.length&&(!array||0==value.length))return braces[0]+base+braces[1];if(recurseTimes<0)return isRegExp(value)?ctx.stylize(RegExp.prototype.toString.call(value),"regexp"):ctx.stylize("[Object]","special");ctx.seen.push(value);var output;return output=array?function(ctx,value,recurseTimes,visibleKeys,keys){for(var output=[],i=0,l=value.length;i=0&&0,prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return braces[0]+(""===base?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1];return braces[0]+base+" "+output.join(", ")+" "+braces[1]}(output,base,braces)}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;if((desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]}).get?str=desc.set?ctx.stylize("[Getter/Setter]","special"):ctx.stylize("[Getter]","special"):desc.set&&(str=ctx.stylize("[Setter]","special")),hasOwnProperty(visibleKeys,key)||(name="["+key+"]"),str||(ctx.seen.indexOf(desc.value)<0?(str=isNull(recurseTimes)?formatValue(ctx,desc.value,null):formatValue(ctx,desc.value,recurseTimes-1)).indexOf("\n")>-1&&(str=array?str.split("\n").map(function(line){return" "+line}).join("\n").substr(2):"\n"+str.split("\n").map(function(line){return" "+line}).join("\n")):str=ctx.stylize("[Circular]","special")),isUndefined(name)){if(array&&key.match(/^\d+$/))return str;(name=JSON.stringify(""+key)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(name=name.substr(1,name.length-2),name=ctx.stylize(name,"name")):(name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),name=ctx.stylize(name,"string"))}return name+": "+str}function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return"boolean"==typeof arg}exports.isBoolean=isBoolean;function isNull(arg){return null===arg}exports.isNull=isNull;exports.isNullOrUndefined=function(arg){return null==arg};function isNumber(arg){return"number"==typeof arg}exports.isNumber=isNumber;function isString(arg){return"string"==typeof arg}exports.isString=isString;exports.isSymbol=function(arg){return"symbol"==typeof arg};function isUndefined(arg){return void 0===arg}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&"[object RegExp]"===objectToString(re)}exports.isRegExp=isRegExp;function isObject(arg){return"object"==typeof arg&&null!==arg}exports.isObject=isObject;function isDate(d){return isObject(d)&&"[object Date]"===objectToString(d)}exports.isDate=isDate;function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}exports.isError=isError;function isFunction(arg){return"function"==typeof arg}exports.isFunction=isFunction;exports.isPrimitive=function(arg){return null===arg||"boolean"==typeof arg||"number"==typeof arg||"string"==typeof arg||"symbol"==typeof arg||void 0===arg},exports.isBuffer=require("./support/isBuffer");function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];exports.log=function(){console.log("%s - %s",function(){var d=new Date,time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}(),exports.format.apply(exports,arguments))},exports.inherits=require("inherits"),exports._extend=function(origin,add){if(!add||!isObject(add))return origin;for(var keys=Object.keys(add),i=keys.length;i--;)origin[keys[i]]=add[keys[i]];return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":205,_process:162,inherits:141}],207:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(obj){if(Object.keys)return Object.keys(obj);var res=[];for(var key in obj)res.push(key);return res},forEach=function(xs,fn){if(xs.forEach)return xs.forEach(fn);for(var i=0;i",main:"index.js",scripts:{start:"npm install && npx gulp build",test:"npm install && npx gulp test",lint:"npm install && npx gulp lint",coveralls:"npm install && npx gulp coveralls"},contributors:[{name:"Emilio Almansi",email:"hi@ealmansi.com"}],keywords:["bitcoin","transaction","address","p2p","ecies","cryptocurrency","blockchain","payment","bip21","bip32","bip37","bip69","bip70","multisig"],repository:{type:"git",url:"https://github.com/bitcoincashjs/bitcoincashjs.git"},browser:{request:"browser-request"},dependencies:{"big-integer":"^1.6.26","bitcore-message":"^1.0.4","bn.js":"=2.0.4",bs58:"=2.0.0","buffer-compare":"=1.0.0",elliptic:"=3.0.3",inherits:"=2.0.1",lodash:"^4.17.4"},devDependencies:{"babel-core":"^6.26.0","babel-preset-env":"^1.6.1",babelify:"^8.0.0",brfs:"^1.4.3",browserify:"^14.5.0",chai:"^1.10.0",coveralls:"^3.0.0",gulp:"^3.8.10","gulp-shell":"^0.6.5",jsdoc:"^3.5.5",jshint:"^2.9.5",karma:"^2.0.0","karma-chrome-launcher":"^2.2.0","karma-detect-browsers":"^2.2.6","karma-firefox-launcher":"^1.1.0","karma-mocha":"^1.3.0",mocha:"^4.1.0",nyc:"^11.4.1","run-sequence":"^2.2.0",sinon:"^1.13.0","uglify-js":"^3.3.4"},license:"MIT"}},{}],209:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),$=require("./util/preconditions"),errors=require("./errors"),Base58Check=require("./encoding/base58check"),Networks=require("./networks"),Hash=require("./crypto/hash"),JSUtil=require("./util/js"),PublicKey=require("./publickey");function Address(data,network,type){if(!(this instanceof Address))return new Address(data,network,type);if(_.isArray(data)&&_.isNumber(network))return Address.createMultisig(data,network,type);if(data instanceof Address)return data;if($.checkArgument(data,"First argument is required, please include address data.","guide/address.html"),network&&!Networks.get(network))throw new TypeError('Second argument must be "livenet" or "testnet".');if(type&&type!==Address.PayToPublicKeyHash&&type!==Address.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var info=this._classifyArguments(data,network,type);return info.network=info.network||Networks.get(network)||Networks.defaultNetwork,info.type=info.type||type||Address.PayToPublicKeyHash,JSUtil.defineImmutable(this,{hashBuffer:info.hashBuffer,network:info.network,type:info.type}),this}Address.prototype._classifyArguments=function(data,network,type){if((data instanceof Buffer||data instanceof Uint8Array)&&20===data.length)return Address._transformHash(data);if((data instanceof Buffer||data instanceof Uint8Array)&&21===data.length)return Address._transformBuffer(data,network,type);if(data instanceof PublicKey)return Address._transformPublicKey(data);if(data instanceof Script)return Address._transformScript(data,network);if("string"==typeof data)return Address._transformString(data,network,type);if(_.isObject(data))return Address._transformObject(data);throw new TypeError("First argument is an unrecognized data format.")},Address.PayToPublicKeyHash="pubkeyhash",Address.PayToScriptHash="scripthash",Address._transformHash=function(hash){var info={};if(!(hash instanceof Buffer||hash instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(20!==hash.length)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return info.hashBuffer=hash,info},Address._transformObject=function(data){return $.checkArgument(data.hash||data.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),$.checkArgument(data.type,"Must provide a `type` property"),{hashBuffer:data.hash?new Buffer(data.hash,"hex"):data.hashBuffer,network:Networks.get(data.network)||Networks.defaultNetwork,type:data.type}},Address._classifyFromVersion=function(buffer){var version={},pubkeyhashNetwork=Networks.get(buffer[0],"pubkeyhash"),scripthashNetwork=Networks.get(buffer[0],"scripthash");return pubkeyhashNetwork?(version.network=pubkeyhashNetwork,version.type=Address.PayToPublicKeyHash):scripthashNetwork&&(version.network=scripthashNetwork,version.type=Address.PayToScriptHash),version},Address._transformBuffer=function(buffer,network,type){var info={};if(!(buffer instanceof Buffer||buffer instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(21!==buffer.length)throw new TypeError("Address buffers must be exactly 21 bytes.");network=Networks.get(network);var bufferVersion=Address._classifyFromVersion(buffer);if(!bufferVersion.network||network&&network!==bufferVersion.network)throw new TypeError("Address has mismatched network type.");if(!bufferVersion.type||type&&type!==bufferVersion.type)throw new TypeError("Address has mismatched type.");return info.hashBuffer=buffer.slice(1),info.network=bufferVersion.network,info.type=bufferVersion.type,info},Address._transformPublicKey=function(pubkey){var info={};if(!(pubkey instanceof PublicKey))throw new TypeError("Address must be an instance of PublicKey.");return info.hashBuffer=Hash.sha256ripemd160(pubkey.toBuffer()),info.type=Address.PayToPublicKeyHash,info},Address._transformScript=function(script,network){$.checkArgument(script instanceof Script,"script must be a Script instance");var info=script.getAddressInfo(network);if(!info)throw new errors.Script.CantDeriveAddress(script);return info},Address.createMultisig=function(publicKeys,threshold,network){return network=network||publicKeys[0].network||Networks.defaultNetwork,Address.payingTo(Script.buildMultisigOut(publicKeys,threshold),network)},Address._transformString=function(data,network,type){if("string"!=typeof data)throw new TypeError("data parameter supplied is not a string.");data=data.trim();var addressBuffer=Base58Check.decode(data);return Address._transformBuffer(addressBuffer,network,type)},Address.fromPublicKey=function(data,network){var info=Address._transformPublicKey(data);return network=network||Networks.defaultNetwork,new Address(info.hashBuffer,network,info.type)},Address.fromPublicKeyHash=function(hash,network){return new Address(Address._transformHash(hash).hashBuffer,network,Address.PayToPublicKeyHash)},Address.fromScriptHash=function(hash,network){$.checkArgument(hash,"hash parameter is required");return new Address(Address._transformHash(hash).hashBuffer,network,Address.PayToScriptHash)},Address.payingTo=function(script,network){return $.checkArgument(script,"script is required"),$.checkArgument(script instanceof Script,"script must be instance of Script"),Address.fromScriptHash(Hash.sha256ripemd160(script.toBuffer()),network)},Address.fromScript=function(script,network){$.checkArgument(script instanceof Script,"script must be a Script instance");var info=Address._transformScript(script,network);return new Address(info.hashBuffer,network,info.type)},Address.fromBuffer=function(buffer,network,type){var info=Address._transformBuffer(buffer,network,type);return new Address(info.hashBuffer,info.network,info.type)},Address.fromString=function(str,network,type){var info=Address._transformString(str,network,type);return new Address(info.hashBuffer,info.network,info.type)},Address.fromObject=function(obj){$.checkState(JSUtil.isHexa(obj.hash),'Unexpected hash property, "'+obj.hash+'", expected to be hex.');return new Address(new Buffer(obj.hash,"hex"),obj.network,obj.type)},Address.getValidationError=function(data,network,type){var error;try{new Address(data,network,type)}catch(e){error=e}return error},Address.isValid=function(data,network,type){return!Address.getValidationError(data,network,type)},Address.prototype.isPayToPublicKeyHash=function(){return this.type===Address.PayToPublicKeyHash},Address.prototype.isPayToScriptHash=function(){return this.type===Address.PayToScriptHash},Address.prototype.toBuffer=function(){var version=new Buffer([this.network[this.type]]);return Buffer.concat([version,this.hashBuffer])},Address.prototype.toObject=Address.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}},Address.prototype.toString=function(){return Base58Check.encode(this.toBuffer())},Address.prototype.inspect=function(){return""},module.exports=Address;var Script=require("./script")}).call(this,require("buffer").Buffer)},{"./crypto/hash":216,"./encoding/base58check":221,"./errors":225,"./networks":229,"./publickey":232,"./script":233,"./util/js":251,"./util/preconditions":252,buffer:70,lodash:144}],210:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),BlockHeader=require("./blockheader"),BN=require("../crypto/bn"),BufferUtil=require("../util/buffer"),BufferReader=require("../encoding/bufferreader"),BufferWriter=require("../encoding/bufferwriter"),Hash=require("../crypto/hash"),Transaction=require("../transaction"),$=require("../util/preconditions");function Block(arg){return this instanceof Block?(_.extend(this,Block._from(arg)),this):new Block(arg)}Block.MAX_BLOCK_SIZE=1e6,Block._from=function(arg){var info={};if(BufferUtil.isBuffer(arg))info=Block._fromBufferReader(BufferReader(arg));else{if(!_.isObject(arg))throw new TypeError("Unrecognized argument for Block");info=Block._fromObject(arg)}return info},Block._fromObject=function(data){var transactions=[];data.transactions.forEach(function(tx){tx instanceof Transaction?transactions.push(tx):transactions.push(Transaction().fromObject(tx))});return{header:BlockHeader.fromObject(data.header),transactions:transactions}},Block.fromObject=function(obj){return new Block(Block._fromObject(obj))},Block._fromBufferReader=function(br){var info={};$.checkState(!br.finished(),"No block data received"),info.header=BlockHeader.fromBufferReader(br);var transactions=br.readVarintNum();info.transactions=[];for(var i=0;i1;size=Math.floor((size+1)/2)){for(var i=0;i"},Block.Values={START_OF_BLOCK:8,NULL_HASH:new Buffer("0000000000000000000000000000000000000000000000000000000000000000","hex")},module.exports=Block}).call(this,require("buffer").Buffer)},{"../crypto/bn":214,"../crypto/hash":216,"../encoding/bufferreader":222,"../encoding/bufferwriter":223,"../transaction":236,"../util/buffer":250,"../util/preconditions":252,"./blockheader":211,buffer:70,lodash:144}],211:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),BN=require("../crypto/bn"),BufferUtil=require("../util/buffer"),BufferReader=require("../encoding/bufferreader"),BufferWriter=require("../encoding/bufferwriter"),Hash=require("../crypto/hash"),$=(require("../util/js"),require("../util/preconditions")),BlockHeader=function BlockHeader(arg){if(!(this instanceof BlockHeader))return new BlockHeader(arg);var info=BlockHeader._from(arg);return this.version=info.version,this.prevHash=info.prevHash,this.merkleRoot=info.merkleRoot,this.time=info.time,this.timestamp=info.time,this.bits=info.bits,this.nonce=info.nonce,info.hash&&$.checkState(this.hash===info.hash,"Argument object hash property does not match block hash."),this};BlockHeader._from=function(arg){var info={};if(BufferUtil.isBuffer(arg))info=BlockHeader._fromBufferReader(BufferReader(arg));else{if(!_.isObject(arg))throw new TypeError("Unrecognized argument for BlockHeader");info=BlockHeader._fromObject(arg)}return info},BlockHeader._fromObject=function(data){$.checkArgument(data,"data is required");var prevHash=data.prevHash,merkleRoot=data.merkleRoot;_.isString(data.prevHash)&&(prevHash=BufferUtil.reverse(new Buffer(data.prevHash,"hex"))),_.isString(data.merkleRoot)&&(merkleRoot=BufferUtil.reverse(new Buffer(data.merkleRoot,"hex")));return{hash:data.hash,version:data.version,prevHash:prevHash,merkleRoot:merkleRoot,time:data.time,timestamp:data.time,bits:data.bits,nonce:data.nonce}},BlockHeader.fromObject=function(obj){var info=BlockHeader._fromObject(obj);return new BlockHeader(info)},BlockHeader.fromRawBlock=function(data){BufferUtil.isBuffer(data)||(data=new Buffer(data,"binary"));var br=BufferReader(data);br.pos=BlockHeader.Constants.START_OF_HEADER;var info=BlockHeader._fromBufferReader(br);return new BlockHeader(info)},BlockHeader.fromBuffer=function(buf){var info=BlockHeader._fromBufferReader(BufferReader(buf));return new BlockHeader(info)},BlockHeader.fromString=function(str){var buf=new Buffer(str,"hex");return BlockHeader.fromBuffer(buf)},BlockHeader._fromBufferReader=function(br){var info={};return info.version=br.readInt32LE(),info.prevHash=br.read(32),info.merkleRoot=br.read(32),info.time=br.readUInt32LE(),info.bits=br.readUInt32LE(),info.nonce=br.readUInt32LE(),info},BlockHeader.fromBufferReader=function(br){var info=BlockHeader._fromBufferReader(br);return new BlockHeader(info)},BlockHeader.prototype.toObject=BlockHeader.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:BufferUtil.reverse(this.prevHash).toString("hex"),merkleRoot:BufferUtil.reverse(this.merkleRoot).toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}},BlockHeader.prototype.toBuffer=function(){return this.toBufferWriter().concat()},BlockHeader.prototype.toString=function(){return this.toBuffer().toString("hex")},BlockHeader.prototype.toBufferWriter=function(bw){return bw||(bw=new BufferWriter),bw.writeInt32LE(this.version),bw.write(this.prevHash),bw.write(this.merkleRoot),bw.writeUInt32LE(this.time),bw.writeUInt32LE(this.bits),bw.writeUInt32LE(this.nonce),bw},BlockHeader.prototype.getTargetDifficulty=function(bits){bits=bits||this.bits;for(var target=new BN(16777215&bits),mov=8*((bits>>>24)-3);mov-- >0;)target=target.mul(new BN(2));return target},BlockHeader.prototype.getDifficulty=function(){var difficulty1TargetBN=this.getTargetDifficulty(486604799).mul(new BN(Math.pow(10,8))),currentTargetBN=this.getTargetDifficulty(),difficultyString=difficulty1TargetBN.div(currentTargetBN).toString(10),decimalPos=difficultyString.length-8;return difficultyString=difficultyString.slice(0,decimalPos)+"."+difficultyString.slice(decimalPos),parseFloat(difficultyString)},BlockHeader.prototype._getHash=function(){var buf=this.toBuffer();return Hash.sha256sha256(buf)};var idProperty={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=BufferReader(this._getHash()).readReverse().toString("hex")),this._id},set:_.noop};Object.defineProperty(BlockHeader.prototype,"id",idProperty),Object.defineProperty(BlockHeader.prototype,"hash",idProperty),BlockHeader.prototype.validTimestamp=function(){var currentTime=Math.round((new Date).getTime()/1e3);return!(this.time>currentTime+BlockHeader.Constants.MAX_TIME_OFFSET)},BlockHeader.prototype.validProofOfWork=function(){var pow=new BN(this.id,"hex"),target=this.getTargetDifficulty();return!(pow.cmp(target)>0)},BlockHeader.prototype.inspect=function(){return""},BlockHeader.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new BN("10000000000000000000000000000000000000000000000000000000000000000","hex")},module.exports=BlockHeader}).call(this,require("buffer").Buffer)},{"../crypto/bn":214,"../crypto/hash":216,"../encoding/bufferreader":222,"../encoding/bufferwriter":223,"../util/buffer":250,"../util/js":251,"../util/preconditions":252,buffer:70,lodash:144}],212:[function(require,module,exports){"use strict";module.exports=require("./block"),module.exports.BlockHeader=require("./blockheader"),module.exports.MerkleBlock=require("./merkleblock")},{"./block":210,"./blockheader":211,"./merkleblock":213}],213:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),BlockHeader=require("./blockheader"),BufferUtil=require("../util/buffer"),BufferReader=require("../encoding/bufferreader"),BufferWriter=require("../encoding/bufferwriter"),Hash=require("../crypto/hash"),Transaction=(require("../util/js"),require("../transaction")),$=require("../util/preconditions");function MerkleBlock(arg){if(!(this instanceof MerkleBlock))return new MerkleBlock(arg);var info={};if(BufferUtil.isBuffer(arg))info=MerkleBlock._fromBufferReader(BufferReader(arg));else{if(!_.isObject(arg))throw new TypeError("Unrecognized argument for MerkleBlock");info={header:arg.header instanceof BlockHeader?arg.header:BlockHeader.fromObject(arg.header),numTransactions:arg.numTransactions,hashes:arg.hashes,flags:arg.flags}}return _.extend(this,info),this._flagBitsUsed=0,this._hashesUsed=0,this}MerkleBlock.fromBuffer=function(buf){return MerkleBlock.fromBufferReader(BufferReader(buf))},MerkleBlock.fromBufferReader=function(br){return new MerkleBlock(MerkleBlock._fromBufferReader(br))},MerkleBlock.prototype.toBuffer=function(){return this.toBufferWriter().concat()},MerkleBlock.prototype.toBufferWriter=function(bw){bw||(bw=new BufferWriter),bw.write(this.header.toBuffer()),bw.writeUInt32LE(this.numTransactions),bw.writeVarintNum(this.hashes.length);for(var i=0;ithis.numTransactions)return!1;if(8*this.flags.length8*this.flags.length)return null;var isParentOfMatch=this.flags[opts.flagBitsUsed>>3]>>>(7&opts.flagBitsUsed++)&1;if(0!==depth&&isParentOfMatch){var left=this._traverseMerkleTree(depth-1,2*pos,opts),right=left;return 2*pos+1=this.hashes.length)return null;var hash=this.hashes[opts.hashesUsed++];return 0===depth&&isParentOfMatch&&opts.txs.push(hash),new Buffer(hash,"hex")},MerkleBlock.prototype._calcTreeWidth=function(height){return this.numTransactions+(1<>height},MerkleBlock.prototype._calcTreeHeight=function(){for(var height=0;this._calcTreeWidth(height)>1;)height++;return height},MerkleBlock.prototype.hasTransaction=function(tx){$.checkArgument(!_.isUndefined(tx),"tx cannot be undefined"),$.checkArgument(tx instanceof Transaction||"string"==typeof tx,'Invalid tx given, tx must be a "string" or "Transaction"');var hash=tx;tx instanceof Transaction&&(hash=BufferUtil.reverse(new Buffer(tx.id,"hex")).toString("hex"));var txs=[],height=this._calcTreeHeight();return this._traverseMerkleTree(height,0,{txs:txs}),-1!==txs.indexOf(hash)},MerkleBlock._fromBufferReader=function(br){$.checkState(!br.finished(),"No merkleblock data received");var info={};info.header=BlockHeader.fromBufferReader(br),info.numTransactions=br.readUInt32LE();var numHashes=br.readVarintNum();info.hashes=[];for(var i=0;iopts.size?buf=BN.trim(buf,natlen):natlen0&&0==(127&buf[buf.length-1])&&(buf.length<=1||0==(128&buf[buf.length-2])))throw new Error("non-minimally encoded script number");return BN.fromSM(buf,{endian:"little"})},BN.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},BN.prototype.gt=function(b){return this.cmp(b)>0},BN.prototype.gte=function(b){return this.cmp(b)>=0},BN.prototype.lt=function(b){return this.cmp(b)<0},BN.trim=function(buf,natlen){return buf.slice(natlen-buf.length,buf.length)},BN.pad=function(buf,natlen,size){for(var rbuf=new Buffer(size),i=0;i>1,n=Point.getN(),G=Point.getG(),x=isSecondKey?r.add(n):r,R=Point.fromX(isYOdd,x);if(!R.mul(n).isInfinity())throw new Error("nR is not a valid curve point");var eNeg=e.neg().mod(n),rInv=r.invm(n),Q=R.mul(s).add(G.mul(eNeg)).mul(rInv);return PublicKey.fromPoint(Q,this.sig.compressed)},ECDSA.prototype.sigError=function(){if(!BufferUtil.isBuffer(this.hashbuf)||32!==this.hashbuf.length)return"hashbuf must be a 32 byte buffer";var r=this.sig.r,s=this.sig.s;if(!(r.gt(BN.Zero)&&r.lt(Point.getN())&&s.gt(BN.Zero)&&s.lt(Point.getN())))return"r and s not in range";var e=BN.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),n=Point.getN(),sinv=s.invm(n),u1=sinv.mul(e).mod(n),u2=sinv.mul(r).mod(n),p=Point.getG().mulAdd(u1,this.pubkey.point,u2);return p.isInfinity()?"p is infinity":0!==p.getX().mod(n).cmp(r)&&"Invalid signature"},ECDSA.toLowS=function(s){return s.gt(BN.fromBuffer(new Buffer("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(s=Point.getN().sub(s)),s},ECDSA.prototype._findSignature=function(d,e){var k,r,s,N=Point.getN(),G=Point.getG(),badrs=0;do{(!this.k||badrs>0)&&this.deterministicK(badrs),badrs++,k=this.k,r=G.mul(k).x.mod(N),s=k.invm(N).mul(e.add(d.mul(r))).mod(N)}while(r.cmp(BN.Zero)<=0||s.cmp(BN.Zero)<=0);return{s:s=ECDSA.toLowS(s),r:r}},ECDSA.prototype.sign=function(){var hashbuf=this.hashbuf,privkey=this.privkey,d=privkey.bn;$.checkState(hashbuf&&privkey&&d,new Error("invalid parameters")),$.checkState(BufferUtil.isBuffer(hashbuf)&&32===hashbuf.length,new Error("hashbuf must be a 32 byte buffer"));var e=BN.fromBuffer(hashbuf,this.endian?{endian:this.endian}:void 0),obj=this._findSignature(d,e);return obj.compressed=this.pubkey.compressed,this.sig=new Signature(obj),this},ECDSA.prototype.signRandomK=function(){return this.randomK(),this.sign()},ECDSA.prototype.toString=function(){var obj={};return this.hashbuf&&(obj.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(obj.privkey=this.privkey.toString()),this.pubkey&&(obj.pubkey=this.pubkey.toString()),this.sig&&(obj.sig=this.sig.toString()),this.k&&(obj.k=this.k.toString()),JSON.stringify(obj)},ECDSA.prototype.verify=function(){return this.sigError()?this.verified=!1:this.verified=!0,this},ECDSA.sign=function(hashbuf,privkey,endian){return ECDSA().set({hashbuf:hashbuf,endian:endian,privkey:privkey}).sign().sig},ECDSA.verify=function(hashbuf,sig,pubkey,endian){return ECDSA().set({hashbuf:hashbuf,endian:endian,sig:sig,pubkey:pubkey}).verify().verified},module.exports=ECDSA}).call(this,require("buffer").Buffer)},{"../publickey":232,"../util/buffer":250,"../util/preconditions":252,"./bn":214,"./hash":216,"./point":217,"./random":218,"./signature":219,buffer:70,lodash:144}],216:[function(require,module,exports){(function(Buffer){"use strict";var crypto=require("crypto"),BufferUtil=require("../util/buffer"),$=require("../util/preconditions"),Hash=module.exports;Hash.sha1=function(buf){return $.checkArgument(BufferUtil.isBuffer(buf)),crypto.createHash("sha1").update(buf).digest()},Hash.sha1.blocksize=512,Hash.sha256=function(buf){return $.checkArgument(BufferUtil.isBuffer(buf)),crypto.createHash("sha256").update(buf).digest()},Hash.sha256.blocksize=512,Hash.sha256sha256=function(buf){return $.checkArgument(BufferUtil.isBuffer(buf)),Hash.sha256(Hash.sha256(buf))},Hash.ripemd160=function(buf){return $.checkArgument(BufferUtil.isBuffer(buf)),crypto.createHash("ripemd160").update(buf).digest()},Hash.sha256ripemd160=function(buf){return $.checkArgument(BufferUtil.isBuffer(buf)),Hash.ripemd160(Hash.sha256(buf))},Hash.sha512=function(buf){return $.checkArgument(BufferUtil.isBuffer(buf)),crypto.createHash("sha512").update(buf).digest()},Hash.sha512.blocksize=1024,Hash.hmac=function(hashf,data,key){$.checkArgument(BufferUtil.isBuffer(data)),$.checkArgument(BufferUtil.isBuffer(key)),$.checkArgument(hashf.blocksize);var blocksize=hashf.blocksize/8;if(key.length>blocksize)key=hashf(key);else if(key>>=8)}return b},module.exports=Random}).call(this,require("_process"),require("buffer").Buffer)},{_process:162,buffer:70,crypto:96}],219:[function(require,module,exports){(function(Buffer){"use strict";var BN=require("./bn"),_=require("lodash"),$=require("../util/preconditions"),BufferUtil=require("../util/buffer"),JSUtil=require("../util/js"),Signature=function Signature(r,s){if(!(this instanceof Signature))return new Signature(r,s);if(r instanceof BN)this.set({r:r,s:s});else if(r){var obj=r;this.set(obj)}};Signature.prototype.set=function(obj){return this.r=obj.r||this.r||void 0,this.s=obj.s||this.s||void 0,this.i=void 0!==obj.i?obj.i:this.i,this.compressed=void 0!==obj.compressed?obj.compressed:this.compressed,this.nhashtype=obj.nhashtype||this.nhashtype||void 0,this},Signature.fromCompact=function(buf){$.checkArgument(BufferUtil.isBuffer(buf),"Argument is expected to be a Buffer");var sig=new Signature,compressed=!0,i=buf.slice(0,1)[0]-27-4;i<0&&(compressed=!1,i+=4);var b2=buf.slice(1,33),b3=buf.slice(33,65);return $.checkArgument(0===i||1===i||2===i||3===i,new Error("i must be 0, 1, 2, or 3")),$.checkArgument(32===b2.length,new Error("r must be 32 bytes")),$.checkArgument(32===b3.length,new Error("s must be 32 bytes")),sig.compressed=compressed,sig.i=i,sig.r=BN.fromBuffer(b2),sig.s=BN.fromBuffer(b3),sig},Signature.fromDER=Signature.fromBuffer=function(buf,strict){var obj=Signature.parseDER(buf,strict),sig=new Signature;return sig.r=obj.r,sig.s=obj.s,sig},Signature.fromTxFormat=function(buf){var nhashtype=buf.readUInt8(buf.length-1),derbuf=buf.slice(0,buf.length-1),sig=new Signature.fromDER(derbuf,!1);return sig.nhashtype=nhashtype,sig},Signature.fromString=function(str){var buf=new Buffer(str,"hex");return Signature.fromDER(buf)},Signature.parseDER=function(buf,strict){$.checkArgument(BufferUtil.isBuffer(buf),new Error("DER formatted signature should be a buffer")),_.isUndefined(strict)&&(strict=!0);var header=buf[0];$.checkArgument(48===header,new Error("Header byte should be 0x30"));var length=buf[1],buflength=buf.slice(2).length;$.checkArgument(!strict||length===buflength,new Error("Length byte should length of what follows")),length=length73)return!1;if(48!==buf[0])return!1;if(buf[1]!==buf.length-3)return!1;var nLenR=buf[3];if(5+nLenR>=buf.length)return!1;var nLenS=buf[5+nLenR];if(nLenR+nLenS+7!==buf.length)return!1;var R=buf.slice(4);if(2!==buf[2])return!1;if(0===nLenR)return!1;if(128&R[0])return!1;if(nLenR>1&&0===R[0]&&!(128&R[1]))return!1;var S=buf.slice(6+nLenR);return 2===buf[6+nLenR-2]&&(0!==nLenS&&(!(128&S[0])&&!(nLenS>1&&0===S[0]&&!(128&S[1]))))},Signature.prototype.hasLowS=function(){return!this.s.lt(new BN(1))&&!this.s.gt(new BN("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))},Signature.prototype.hasDefinedHashtype=function(){if(!JSUtil.isNaturalNumber(this.nhashtype))return!1;var temp=this.nhashtype&~Signature.SIGHASH_ANYONECANPAY;return!(tempSignature.SIGHASH_SINGLE)},Signature.prototype.toTxFormat=function(){var derbuf=this.toDER(),buf=new Buffer(1);return buf.writeUInt8(this.nhashtype,0),Buffer.concat([derbuf,buf])},Signature.SIGHASH_ALL=1,Signature.SIGHASH_NONE=2,Signature.SIGHASH_SINGLE=3,Signature.SIGHASH_FORKID=64,Signature.SIGHASH_ANYONECANPAY=128,module.exports=Signature}).call(this,require("buffer").Buffer)},{"../util/buffer":250,"../util/js":251,"../util/preconditions":252,"./bn":214,buffer:70,lodash:144}],220:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),bs58=require("bs58"),buffer=require("buffer"),ALPHABET="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),Base58=function Base58(obj){if(!(this instanceof Base58))return new Base58(obj);if(Buffer.isBuffer(obj)){var buf=obj;this.fromBuffer(buf)}else if("string"==typeof obj){var str=obj;this.fromString(str)}else obj&&this.set(obj)};Base58.validCharacters=function(chars){return buffer.Buffer.isBuffer(chars)&&(chars=chars.toString()),_.every(_.map(chars,function(char){return _.includes(ALPHABET,char)}))},Base58.prototype.set=function(obj){return this.buf=obj.buf||this.buf||void 0,this},Base58.encode=function(buf){if(!buffer.Buffer.isBuffer(buf))throw new Error("Input should be a buffer");return bs58.encode(buf)},Base58.decode=function(str){if("string"!=typeof str)throw new Error("Input should be a string");return new Buffer(bs58.decode(str))},Base58.prototype.fromBuffer=function(buf){return this.buf=buf,this},Base58.prototype.fromString=function(str){var buf=Base58.decode(str);return this.buf=buf,this},Base58.prototype.toBuffer=function(){return this.buf},Base58.prototype.toString=function(){return Base58.encode(this.buf)},module.exports=Base58}).call(this,require("buffer").Buffer)},{bs58:67,buffer:70,lodash:144}],221:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),Base58=require("./base58"),buffer=require("buffer"),sha256sha256=require("../crypto/hash").sha256sha256,Base58Check=function Base58Check(obj){if(!(this instanceof Base58Check))return new Base58Check(obj);if(Buffer.isBuffer(obj)){var buf=obj;this.fromBuffer(buf)}else if("string"==typeof obj){var str=obj;this.fromString(str)}else obj&&this.set(obj)};Base58Check.prototype.set=function(obj){return this.buf=obj.buf||this.buf||void 0,this},Base58Check.validChecksum=function(data,checksum){return _.isString(data)&&(data=new buffer.Buffer(Base58.decode(data))),_.isString(checksum)&&(checksum=new buffer.Buffer(Base58.decode(checksum))),checksum||(checksum=data.slice(-4),data=data.slice(0,-4)),Base58Check.checksum(data).toString("hex")===checksum.toString("hex")},Base58Check.decode=function(s){if("string"!=typeof s)throw new Error("Input must be a string");var buf=new Buffer(Base58.decode(s));if(buf.length<4)throw new Error("Input string too short");var data=buf.slice(0,-4),csum=buf.slice(-4),hash4=sha256sha256(data).slice(0,4);if(csum.toString("hex")!==hash4.toString("hex"))throw new Error("Checksum mismatch");return data},Base58Check.checksum=function(buffer){return sha256sha256(buffer).slice(0,4)},Base58Check.encode=function(buf){if(!Buffer.isBuffer(buf))throw new Error("Input must be a buffer");var checkedBuf=new Buffer(buf.length+4),hash=Base58Check.checksum(buf);return buf.copy(checkedBuf),hash.copy(checkedBuf,buf.length),Base58.encode(checkedBuf)},Base58Check.prototype.fromBuffer=function(buf){return this.buf=buf,this},Base58Check.prototype.fromString=function(str){var buf=Base58Check.decode(str);return this.buf=buf,this},Base58Check.prototype.toBuffer=function(){return this.buf},Base58Check.prototype.toString=function(){return Base58Check.encode(this.buf)},module.exports=Base58Check}).call(this,require("buffer").Buffer)},{"../crypto/hash":216,"./base58":220,buffer:70,lodash:144}],222:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),$=require("../util/preconditions"),BufferUtil=require("../util/buffer"),BN=require("../crypto/bn"),BufferReader=function BufferReader(buf){if(!(this instanceof BufferReader))return new BufferReader(buf);if(!_.isUndefined(buf))if(Buffer.isBuffer(buf))this.set({buf:buf});else if(_.isString(buf)){var b=new Buffer(buf,"hex");if(2*b.length!=buf.length)throw new TypeError("Invalid hex string");this.set({buf:b})}else{if(!_.isObject(buf))throw new TypeError("Unrecognized argument for BufferReader");var obj=buf;this.set(obj)}};BufferReader.prototype.set=function(obj){return this.buf=obj.buf||this.buf||void 0,this.pos=obj.pos||this.pos||0,this},BufferReader.prototype.eof=function(){return this.pos>=this.buf.length},BufferReader.prototype.finished=BufferReader.prototype.eof,BufferReader.prototype.read=function(len){$.checkArgument(!_.isUndefined(len),"Must specify a length");var buf=this.buf.slice(this.pos,this.pos+len);return this.pos=this.pos+len,buf},BufferReader.prototype.readAll=function(){var buf=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,buf},BufferReader.prototype.readUInt8=function(){var val=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,val},BufferReader.prototype.readUInt16BE=function(){var val=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,val},BufferReader.prototype.readUInt16LE=function(){var val=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,val},BufferReader.prototype.readUInt32BE=function(){var val=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,val},BufferReader.prototype.readUInt32LE=function(){var val=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,val},BufferReader.prototype.readInt32LE=function(){var val=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,val},BufferReader.prototype.readUInt64BEBN=function(){var buf=this.buf.slice(this.pos,this.pos+8),bn=BN.fromBuffer(buf);return this.pos=this.pos+8,bn},BufferReader.prototype.readUInt64LEBN=function(){var bn,second=this.buf.readUInt32LE(this.pos),combined=4294967296*this.buf.readUInt32LE(this.pos+4)+second;if(combined<=9007199254740991)bn=new BN(combined);else{var data=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);bn=new BN(data,10,"le")}return this.pos=this.pos+8,bn},BufferReader.prototype.readVarintNum=function(){var first=this.readUInt8();switch(first){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var n=this.readUInt64LEBN().toNumber();if(n<=Math.pow(2,53))return n;throw new Error("number too large to retain precision - use readVarintBN");default:return first}},BufferReader.prototype.readVarLengthBuffer=function(){var len=this.readVarintNum(),buf=this.read(len);return $.checkState(buf.length===len,"Invalid length while reading varlength buffer. Expected to read: "+len+" and read "+buf.length),buf},BufferReader.prototype.readVarintBuf=function(){switch(this.buf.readUInt8(this.pos)){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}},BufferReader.prototype.readVarintBN=function(){var first=this.readUInt8();switch(first){case 253:return new BN(this.readUInt16LE());case 254:return new BN(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new BN(first)}},BufferReader.prototype.reverse=function(){for(var buf=new Buffer(this.buf.length),i=0;i=0&&arg=HDPrivateKey.Hardened||hardened,index64)throw new hdErrors.InvalidEntropyArgument.TooMuchEntropy(hexa);var hash=Hash.sha512hmac(hexa,new buffer.Buffer("Bitcoin seed"));return new HDPrivateKey({network:Network.get(network)||Network.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:hash.slice(0,32),chainCode:hash.slice(32,64)})},HDPrivateKey.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var HDPublicKey=require("./hdpublickey");this._hdPublicKey=new HDPublicKey(this)}},HDPrivateKey.prototype._buildFromBuffers=function(arg){HDPrivateKey._validateBufferArguments(arg),JSUtil.defineImmutable(this,{_buffers:arg});var sequence=[arg.version,arg.depth,arg.parentFingerPrint,arg.childIndex,arg.chainCode,BufferUtil.emptyBuffer(1),arg.privateKey],concat=buffer.Buffer.concat(sequence);if(arg.checksum&&arg.checksum.length){if(arg.checksum.toString()!==Base58Check.checksum(concat).toString())throw new errors.InvalidB58Checksum(concat)}else arg.checksum=Base58Check.checksum(concat);var xprivkey,network=Network.get(BufferUtil.integerFromBuffer(arg.version));xprivkey=Base58Check.encode(buffer.Buffer.concat(sequence)),arg.xprivkey=new Buffer(xprivkey);var privateKey=new PrivateKey(BN.fromBuffer(arg.privateKey),network),publicKey=privateKey.toPublicKey(),size=HDPrivateKey.ParentFingerPrintSize,fingerPrint=Hash.sha256ripemd160(publicKey.toBuffer()).slice(0,size);return JSUtil.defineImmutable(this,{xprivkey:xprivkey,network:network,depth:BufferUtil.integerFromSingleByteBuffer(arg.depth),privateKey:privateKey,publicKey:publicKey,fingerPrint:fingerPrint}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},HDPrivateKey._validateBufferArguments=function(arg){var checkBuffer=function(name,size){var buff=arg[name];assert(BufferUtil.isBuffer(buff),name+" argument is not a buffer"),assert(buff.length===size,name+" has not the expected size: found "+buff.length+", expected "+size)};checkBuffer("version",HDPrivateKey.VersionSize),checkBuffer("depth",HDPrivateKey.DepthSize),checkBuffer("parentFingerPrint",HDPrivateKey.ParentFingerPrintSize),checkBuffer("childIndex",HDPrivateKey.ChildIndexSize),checkBuffer("chainCode",HDPrivateKey.ChainCodeSize),checkBuffer("privateKey",HDPrivateKey.PrivateKeySize),arg.checksum&&arg.checksum.length&&checkBuffer("checksum",HDPrivateKey.CheckSumSize)},HDPrivateKey.prototype.toString=function(){return this.xprivkey},HDPrivateKey.prototype.inspect=function(){return""},HDPrivateKey.prototype.toObject=HDPrivateKey.prototype.toJSON=function(){return{network:Network.get(BufferUtil.integerFromBuffer(this._buffers.version),"xprivkey").name,depth:BufferUtil.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:BufferUtil.integerFromBuffer(this.fingerPrint),parentFingerPrint:BufferUtil.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:BufferUtil.integerFromBuffer(this._buffers.childIndex),chainCode:BufferUtil.bufferToHex(this._buffers.chainCode),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:BufferUtil.integerFromBuffer(this._buffers.checksum),xprivkey:this.xprivkey}},HDPrivateKey.fromBuffer=function(arg){return new HDPrivateKey(arg.toString())},HDPrivateKey.prototype.toBuffer=function(){return BufferUtil.copy(this._buffers.xprivkey)},HDPrivateKey.DefaultDepth=0,HDPrivateKey.DefaultFingerprint=0,HDPrivateKey.DefaultChildIndex=0,HDPrivateKey.Hardened=2147483648,HDPrivateKey.MaxIndex=2*HDPrivateKey.Hardened,HDPrivateKey.RootElementAlias=["m","M","m'","M'"],HDPrivateKey.VersionSize=4,HDPrivateKey.DepthSize=1,HDPrivateKey.ParentFingerPrintSize=4,HDPrivateKey.ChildIndexSize=4,HDPrivateKey.ChainCodeSize=32,HDPrivateKey.PrivateKeySize=32,HDPrivateKey.CheckSumSize=4,HDPrivateKey.DataLength=78,HDPrivateKey.SerializedByteSize=82,HDPrivateKey.VersionStart=0,HDPrivateKey.VersionEnd=HDPrivateKey.VersionStart+HDPrivateKey.VersionSize,HDPrivateKey.DepthStart=HDPrivateKey.VersionEnd,HDPrivateKey.DepthEnd=HDPrivateKey.DepthStart+HDPrivateKey.DepthSize,HDPrivateKey.ParentFingerPrintStart=HDPrivateKey.DepthEnd,HDPrivateKey.ParentFingerPrintEnd=HDPrivateKey.ParentFingerPrintStart+HDPrivateKey.ParentFingerPrintSize,HDPrivateKey.ChildIndexStart=HDPrivateKey.ParentFingerPrintEnd,HDPrivateKey.ChildIndexEnd=HDPrivateKey.ChildIndexStart+HDPrivateKey.ChildIndexSize,HDPrivateKey.ChainCodeStart=HDPrivateKey.ChildIndexEnd,HDPrivateKey.ChainCodeEnd=HDPrivateKey.ChainCodeStart+HDPrivateKey.ChainCodeSize,HDPrivateKey.PrivateKeyStart=HDPrivateKey.ChainCodeEnd+1,HDPrivateKey.PrivateKeyEnd=HDPrivateKey.PrivateKeyStart+HDPrivateKey.PrivateKeySize,HDPrivateKey.ChecksumStart=HDPrivateKey.PrivateKeyEnd,HDPrivateKey.ChecksumEnd=HDPrivateKey.ChecksumStart+HDPrivateKey.CheckSumSize,assert(HDPrivateKey.ChecksumEnd===HDPrivateKey.SerializedByteSize),module.exports=HDPrivateKey}).call(this,require("buffer").Buffer)},{"./crypto/bn":214,"./crypto/hash":216,"./crypto/point":217,"./crypto/random":218,"./encoding/base58":220,"./encoding/base58check":221,"./errors":225,"./hdpublickey":228,"./networks":229,"./privatekey":231,"./util/buffer":250,"./util/js":251,"./util/preconditions":252,assert:17,buffer:70,lodash:144}],228:[function(require,module,exports){(function(Buffer){"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_=require("lodash"),$=require("./util/preconditions"),BN=require("./crypto/bn"),Base58=require("./encoding/base58"),Base58Check=require("./encoding/base58check"),Hash=require("./crypto/hash"),HDPrivateKey=require("./hdprivatekey"),Network=require("./networks"),Point=require("./crypto/point"),PublicKey=require("./publickey"),bitcoreErrors=require("./errors"),errors=bitcoreErrors,hdErrors=bitcoreErrors.HDPublicKey,assert=require("assert"),JSUtil=require("./util/js"),BufferUtil=require("./util/buffer");function HDPublicKey(arg){if(arg instanceof HDPublicKey)return arg;if(!(this instanceof HDPublicKey))return new HDPublicKey(arg);if(arg){if(_.isString(arg)||BufferUtil.isBuffer(arg)){var error=HDPublicKey.getSerializedError(arg);if(error){if(BufferUtil.isBuffer(arg)&&!HDPublicKey.getSerializedError(arg.toString()))return this._buildFromSerialized(arg.toString());if(error instanceof hdErrors.ArgumentIsPrivateExtended)return new HDPrivateKey(arg).hdPublicKey;throw error}return this._buildFromSerialized(arg)}if(_.isObject(arg))return arg instanceof HDPrivateKey?this._buildFromPrivate(arg):this._buildFromObject(arg);throw new hdErrors.UnrecognizedArgument(arg)}throw new hdErrors.MustSupplyArgument}HDPublicKey.isValidPath=function(arg){if(_.isString(arg)){var indexes=HDPrivateKey._getDerivationIndexes(arg);return null!==indexes&&_.every(indexes,HDPublicKey.isValidPath)}return!!_.isNumber(arg)&&(arg>=0&&arg=HDPublicKey.Hardened||hardened)throw new hdErrors.InvalidIndexCantDeriveHardened;if(index<0)throw new hdErrors.InvalidPath(index);var publicKey,indexBuffer=BufferUtil.integerAsBuffer(index),data=BufferUtil.concat([this.publicKey.toBuffer(),indexBuffer]),hash=Hash.sha512hmac(data,this._buffers.chainCode),leftPart=BN.fromBuffer(hash.slice(0,32),{size:32}),chainCode=hash.slice(32,64);try{publicKey=PublicKey.fromPoint(Point.getG().mul(leftPart).add(this.publicKey.point))}catch(e){return this._deriveWithNumber(index+1)}return new HDPublicKey({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:index,chainCode:chainCode,publicKey:publicKey})},HDPublicKey.prototype._deriveFromString=function(path){if(_.includes(path,"'"))throw new hdErrors.InvalidIndexCantDeriveHardened;if(!HDPublicKey.isValidPath(path))throw new hdErrors.InvalidPath(path);return HDPrivateKey._getDerivationIndexes(path).reduce(function(prev,index){return prev._deriveWithNumber(index)},this)},HDPublicKey.isValidSerialized=function(data,network){return _.isNull(HDPublicKey.getSerializedError(data,network))},HDPublicKey.getSerializedError=function(data,network){if(!_.isString(data)&&!BufferUtil.isBuffer(data))return new hdErrors.UnrecognizedArgument("expected buffer or string");if(!Base58.validCharacters(data))return new errors.InvalidB58Char("(unknown)",data);try{data=Base58Check.decode(data)}catch(e){return new errors.InvalidB58Checksum(data)}if(data.length!==HDPublicKey.DataSize)return new hdErrors.InvalidLength(data);if(!_.isUndefined(network)){var error=HDPublicKey._validateNetwork(data,network);if(error)return error}var version=BufferUtil.integerFromBuffer(data.slice(0,4));return version===Network.livenet.xprivkey||version===Network.testnet.xprivkey?new hdErrors.ArgumentIsPrivateExtended:null},HDPublicKey._validateNetwork=function(data,networkArg){var network=Network.get(networkArg);if(!network)return new errors.InvalidNetworkArgument(networkArg);var version=data.slice(HDPublicKey.VersionStart,HDPublicKey.VersionEnd);return BufferUtil.integerFromBuffer(version)!==network.xpubkey?new errors.InvalidNetwork(version):null},HDPublicKey.prototype._buildFromPrivate=function(arg){var args=_.clone(arg._buffers),point=Point.getG().mul(BN.fromBuffer(args.privateKey));return args.publicKey=Point.pointToCompressed(point),args.version=BufferUtil.integerAsBuffer(Network.get(BufferUtil.integerFromBuffer(args.version)).xpubkey),args.privateKey=void 0,args.checksum=void 0,args.xprivkey=void 0,this._buildFromBuffers(args)},HDPublicKey.prototype._buildFromObject=function(arg){var buffers={version:arg.network?BufferUtil.integerAsBuffer(Network.get(arg.network).xpubkey):arg.version,depth:_.isNumber(arg.depth)?BufferUtil.integerAsSingleByteBuffer(arg.depth):arg.depth,parentFingerPrint:_.isNumber(arg.parentFingerPrint)?BufferUtil.integerAsBuffer(arg.parentFingerPrint):arg.parentFingerPrint,childIndex:_.isNumber(arg.childIndex)?BufferUtil.integerAsBuffer(arg.childIndex):arg.childIndex,chainCode:_.isString(arg.chainCode)?BufferUtil.hexToBuffer(arg.chainCode):arg.chainCode,publicKey:_.isString(arg.publicKey)?BufferUtil.hexToBuffer(arg.publicKey):BufferUtil.isBuffer(arg.publicKey)?arg.publicKey:arg.publicKey.toBuffer(),checksum:_.isNumber(arg.checksum)?BufferUtil.integerAsBuffer(arg.checksum):arg.checksum};return this._buildFromBuffers(buffers)},HDPublicKey.prototype._buildFromSerialized=function(arg){var decoded=Base58Check.decode(arg),buffers={version:decoded.slice(HDPublicKey.VersionStart,HDPublicKey.VersionEnd),depth:decoded.slice(HDPublicKey.DepthStart,HDPublicKey.DepthEnd),parentFingerPrint:decoded.slice(HDPublicKey.ParentFingerPrintStart,HDPublicKey.ParentFingerPrintEnd),childIndex:decoded.slice(HDPublicKey.ChildIndexStart,HDPublicKey.ChildIndexEnd),chainCode:decoded.slice(HDPublicKey.ChainCodeStart,HDPublicKey.ChainCodeEnd),publicKey:decoded.slice(HDPublicKey.PublicKeyStart,HDPublicKey.PublicKeyEnd),checksum:decoded.slice(HDPublicKey.ChecksumStart,HDPublicKey.ChecksumEnd),xpubkey:arg};return this._buildFromBuffers(buffers)},HDPublicKey.prototype._buildFromBuffers=function(arg){HDPublicKey._validateBufferArguments(arg),JSUtil.defineImmutable(this,{_buffers:arg});var sequence=[arg.version,arg.depth,arg.parentFingerPrint,arg.childIndex,arg.chainCode,arg.publicKey],concat=BufferUtil.concat(sequence),checksum=Base58Check.checksum(concat);if(arg.checksum&&arg.checksum.length){if(arg.checksum.toString("hex")!==checksum.toString("hex"))throw new errors.InvalidB58Checksum(concat,checksum)}else arg.checksum=checksum;var xpubkey,network=Network.get(BufferUtil.integerFromBuffer(arg.version));xpubkey=Base58Check.encode(BufferUtil.concat(sequence)),arg.xpubkey=new Buffer(xpubkey);var publicKey=new PublicKey(arg.publicKey,{network:network}),size=HDPublicKey.ParentFingerPrintSize,fingerPrint=Hash.sha256ripemd160(publicKey.toBuffer()).slice(0,size);return JSUtil.defineImmutable(this,{xpubkey:xpubkey,network:network,depth:BufferUtil.integerFromSingleByteBuffer(arg.depth),publicKey:publicKey,fingerPrint:fingerPrint}),this},HDPublicKey._validateBufferArguments=function(arg){var checkBuffer=function(name,size){var buff=arg[name];assert(BufferUtil.isBuffer(buff),name+" argument is not a buffer, it's "+(void 0===buff?"undefined":_typeof(buff))),assert(buff.length===size,name+" has not the expected size: found "+buff.length+", expected "+size)};checkBuffer("version",HDPublicKey.VersionSize),checkBuffer("depth",HDPublicKey.DepthSize),checkBuffer("parentFingerPrint",HDPublicKey.ParentFingerPrintSize),checkBuffer("childIndex",HDPublicKey.ChildIndexSize),checkBuffer("chainCode",HDPublicKey.ChainCodeSize),checkBuffer("publicKey",HDPublicKey.PublicKeySize),arg.checksum&&arg.checksum.length&&checkBuffer("checksum",HDPublicKey.CheckSumSize)},HDPublicKey.fromString=function(arg){return $.checkArgument(_.isString(arg),"No valid string was provided"),new HDPublicKey(arg)},HDPublicKey.fromObject=function(arg){return $.checkArgument(_.isObject(arg),"No valid argument was provided"),new HDPublicKey(arg)},HDPublicKey.prototype.toString=function(){return this.xpubkey},HDPublicKey.prototype.inspect=function(){return""},HDPublicKey.prototype.toObject=HDPublicKey.prototype.toJSON=function(){return{network:Network.get(BufferUtil.integerFromBuffer(this._buffers.version)).name,depth:BufferUtil.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:BufferUtil.integerFromBuffer(this.fingerPrint),parentFingerPrint:BufferUtil.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:BufferUtil.integerFromBuffer(this._buffers.childIndex),chainCode:BufferUtil.bufferToHex(this._buffers.chainCode),publicKey:this.publicKey.toString(),checksum:BufferUtil.integerFromBuffer(this._buffers.checksum),xpubkey:this.xpubkey}},HDPublicKey.fromBuffer=function(arg){return new HDPublicKey(arg)},HDPublicKey.prototype.toBuffer=function(){return BufferUtil.copy(this._buffers.xpubkey)},HDPublicKey.Hardened=2147483648,HDPublicKey.RootElementAlias=["m","M"],HDPublicKey.VersionSize=4,HDPublicKey.DepthSize=1,HDPublicKey.ParentFingerPrintSize=4,HDPublicKey.ChildIndexSize=4,HDPublicKey.ChainCodeSize=32,HDPublicKey.PublicKeySize=33,HDPublicKey.CheckSumSize=4,HDPublicKey.DataSize=78,HDPublicKey.SerializedByteSize=82,HDPublicKey.VersionStart=0,HDPublicKey.VersionEnd=HDPublicKey.VersionStart+HDPublicKey.VersionSize,HDPublicKey.DepthStart=HDPublicKey.VersionEnd,HDPublicKey.DepthEnd=HDPublicKey.DepthStart+HDPublicKey.DepthSize,HDPublicKey.ParentFingerPrintStart=HDPublicKey.DepthEnd,HDPublicKey.ParentFingerPrintEnd=HDPublicKey.ParentFingerPrintStart+HDPublicKey.ParentFingerPrintSize,HDPublicKey.ChildIndexStart=HDPublicKey.ParentFingerPrintEnd,HDPublicKey.ChildIndexEnd=HDPublicKey.ChildIndexStart+HDPublicKey.ChildIndexSize,HDPublicKey.ChainCodeStart=HDPublicKey.ChildIndexEnd,HDPublicKey.ChainCodeEnd=HDPublicKey.ChainCodeStart+HDPublicKey.ChainCodeSize,HDPublicKey.PublicKeyStart=HDPublicKey.ChainCodeEnd,HDPublicKey.PublicKeyEnd=HDPublicKey.PublicKeyStart+HDPublicKey.PublicKeySize,HDPublicKey.ChecksumStart=HDPublicKey.PublicKeyEnd,HDPublicKey.ChecksumEnd=HDPublicKey.ChecksumStart+HDPublicKey.CheckSumSize,assert(HDPublicKey.PublicKeyEnd===HDPublicKey.DataSize),assert(HDPublicKey.ChecksumEnd===HDPublicKey.SerializedByteSize),module.exports=HDPublicKey}).call(this,require("buffer").Buffer)},{"./crypto/bn":214,"./crypto/hash":216,"./crypto/point":217,"./encoding/base58":220,"./encoding/base58check":221,"./errors":225,"./hdprivatekey":227,"./networks":229,"./publickey":232,"./util/buffer":250,"./util/js":251,"./util/preconditions":252,assert:17,buffer:70,lodash:144}],229:[function(require,module,exports){"use strict";var _=require("lodash"),BufferUtil=require("./util/buffer"),JSUtil=require("./util/js"),networks=[],networkMaps={};function Network(){}Network.prototype.toString=function(){return this.name};function get(arg,keys){if(~networks.indexOf(arg))return arg;{if(!keys)return networkMaps[arg];_.isArray(keys)||(keys=[keys]);var containsArg=function(key){return networks[index][key]===arg};for(var index in networks)if(_.some(keys,containsArg))return networks[index]}}function addNetwork(data){var network=new Network;return JSUtil.defineImmutable(network,{name:data.name,alias:data.alias,pubkeyhash:data.pubkeyhash,privatekey:data.privatekey,scripthash:data.scripthash,xpubkey:data.xpubkey,xprivkey:data.xprivkey}),data.networkMagic&&JSUtil.defineImmutable(network,{networkMagic:BufferUtil.integerAsBuffer(data.networkMagic)}),data.port&&JSUtil.defineImmutable(network,{port:data.port}),data.dnsSeeds&&JSUtil.defineImmutable(network,{dnsSeeds:data.dnsSeeds}),_.each(network,function(value){_.isUndefined(value)||_.isObject(value)||(networkMaps[value]=network)}),networks.push(network),network}addNetwork({name:"livenet",alias:"mainnet",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:4190024921,port:8333,dnsSeeds:["seed.bitcoin.sipa.be","dnsseed.bluematt.me","dnsseed.bitcoin.dashjr.org","seed.bitcoinstats.com","seed.bitnodes.io","bitseed.xf2.org"]});var livenet=get("livenet");addNetwork({name:"testnet",alias:"regtest",pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956});var testnet=get("testnet"),TESTNET={PORT:18333,NETWORK_MAGIC:BufferUtil.integerAsBuffer(185665799),DNS_SEEDS:["testnet-seed.bitcoin.petertodd.org","testnet-seed.bluematt.me","testnet-seed.alexykot.me","testnet-seed.bitcoin.schildbach.de"]};for(var key in TESTNET)_.isObject(TESTNET[key])||(networkMaps[TESTNET[key]]=testnet);var REGTEST={PORT:18444,NETWORK_MAGIC:BufferUtil.integerAsBuffer(4206867930),DNS_SEEDS:[]};for(var key in REGTEST)_.isObject(REGTEST[key])||(networkMaps[REGTEST[key]]=testnet);Object.defineProperty(testnet,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?REGTEST.PORT:TESTNET.PORT}}),Object.defineProperty(testnet,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?REGTEST.NETWORK_MAGIC:TESTNET.NETWORK_MAGIC}}),Object.defineProperty(testnet,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?REGTEST.DNS_SEEDS:TESTNET.DNS_SEEDS}});module.exports={add:addNetwork,remove:function(network){for(var i=0;i=0&&n<=16,"Invalid Argument: n must be between 0 and 16"),0===n?Opcode("OP_0"):new Opcode(Opcode.map.OP_1+n-1)},Opcode.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},Opcode.reverseMap=[];for(var k in Opcode.map)Opcode.reverseMap[Opcode.map[k]]=k;_.extend(Opcode,Opcode.map),Opcode.isSmallIntOp=function(opcode){return opcode instanceof Opcode&&(opcode=opcode.toNumber()),opcode===Opcode.map.OP_0||opcode>=Opcode.map.OP_1&&opcode<=Opcode.map.OP_16},Opcode.prototype.inspect=function(){return""},module.exports=Opcode}).call(this,require("buffer").Buffer)},{"./util/buffer":250,"./util/js":251,"./util/preconditions":252,buffer:70,lodash:144}],231:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),Address=require("./address"),Base58Check=require("./encoding/base58check"),BN=require("./crypto/bn"),JSUtil=require("./util/js"),Networks=require("./networks"),Point=require("./crypto/point"),PublicKey=require("./publickey"),Random=require("./crypto/random"),$=require("./util/preconditions");function PrivateKey(data,network){if(!(this instanceof PrivateKey))return new PrivateKey(data,network);if(data instanceof PrivateKey)return data;var info=this._classifyArguments(data,network);if(!info.bn||0===info.bn.cmp(new BN(0)))throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!info.bn.lt(Point.getN()))throw new TypeError("Number must be less than N");if(void 0===info.network)throw new TypeError('Must specify the network ("livenet" or "testnet")');return JSUtil.defineImmutable(this,{bn:info.bn,compressed:info.compressed,network:info.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}PrivateKey.prototype._classifyArguments=function(data,network){var info={compressed:!0,network:network?Networks.get(network):Networks.defaultNetwork};if(_.isUndefined(data)||_.isNull(data))info.bn=PrivateKey._getRandomBN();else if(data instanceof BN)info.bn=data;else if(data instanceof Buffer||data instanceof Uint8Array)info=PrivateKey._transformBuffer(data,network);else if(data.bn&&data.network)info=PrivateKey._transformObject(data);else if(!network&&Networks.get(data))info.bn=PrivateKey._getRandomBN(),info.network=Networks.get(data);else{if("string"!=typeof data)throw new TypeError("First argument is an unrecognized data type.");JSUtil.isHexa(data)?info.bn=new BN(new Buffer(data,"hex")):info=PrivateKey._transformWIF(data,network)}return info},PrivateKey._getRandomBN=function(){var condition,bn;do{var privbuf=Random.getRandomBuffer(32);condition=(bn=BN.fromBuffer(privbuf)).lt(Point.getN())}while(!condition);return bn},PrivateKey._transformBuffer=function(buf,network){var info={};if(32===buf.length)return PrivateKey._transformBNBuffer(buf,network);if(info.network=Networks.get(buf[0],"privatekey"),!info.network)throw new Error("Invalid network");if(network&&info.network!==Networks.get(network))throw new TypeError("Private key network mismatch");if(34===buf.length&&1===buf[33])info.compressed=!0;else{if(33!==buf.length)throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");info.compressed=!1}return info.bn=BN.fromBuffer(buf.slice(1,33)),info},PrivateKey._transformBNBuffer=function(buf,network){var info={};return info.network=Networks.get(network)||Networks.defaultNetwork,info.bn=BN.fromBuffer(buf),info.compressed=!1,info},PrivateKey._transformWIF=function(str,network){return PrivateKey._transformBuffer(Base58Check.decode(str),network)},PrivateKey.fromBuffer=function(arg,network){return new PrivateKey(arg,network)},PrivateKey._transformObject=function(json){return{bn:new BN(json.bn,"hex"),network:Networks.get(json.network),compressed:json.compressed}},PrivateKey.fromString=PrivateKey.fromWIF=function(str){return $.checkArgument(_.isString(str),"First argument is expected to be a string."),new PrivateKey(str)},PrivateKey.fromObject=function(obj){return $.checkArgument(_.isObject(obj),"First argument is expected to be an object."),new PrivateKey(obj)},PrivateKey.fromRandom=function(network){return new PrivateKey(PrivateKey._getRandomBN(),network)},PrivateKey.getValidationError=function(data,network){var error;try{new PrivateKey(data,network)}catch(e){error=e}return error},PrivateKey.isValid=function(data,network){return!!data&&!PrivateKey.getValidationError(data,network)},PrivateKey.prototype.toString=function(){return this.toBuffer().toString("hex")},PrivateKey.prototype.toWIF=function(){var buf,network=this.network;return buf=this.compressed?Buffer.concat([new Buffer([network.privatekey]),this.bn.toBuffer({size:32}),new Buffer([1])]):Buffer.concat([new Buffer([network.privatekey]),this.bn.toBuffer({size:32})]),Base58Check.encode(buf)},PrivateKey.prototype.toBigNumber=function(){return this.bn},PrivateKey.prototype.toBuffer=function(){return this.bn.toBuffer()},PrivateKey.prototype.toBufferNoPadding=function(){return this.bn.toBuffer()},PrivateKey.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=PublicKey.fromPrivateKey(this)),this._pubkey},PrivateKey.prototype.toAddress=function(network){var pubkey=this.toPublicKey();return Address.fromPublicKey(pubkey,network||this.network)},PrivateKey.prototype.toObject=PrivateKey.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},PrivateKey.prototype.inspect=function(){var uncompressed=this.compressed?"":", uncompressed";return""},module.exports=PrivateKey}).call(this,require("buffer").Buffer)},{"./address":209,"./crypto/bn":214,"./crypto/point":217,"./crypto/random":218,"./encoding/base58check":221,"./networks":229,"./publickey":232,"./util/js":251,"./util/preconditions":252,buffer:70,lodash:144}],232:[function(require,module,exports){(function(Buffer){"use strict";var BN=require("./crypto/bn"),Point=require("./crypto/point"),Hash=require("./crypto/hash"),JSUtil=require("./util/js"),Network=require("./networks"),_=require("lodash"),$=require("./util/preconditions");function PublicKey(data,extra){if(!(this instanceof PublicKey))return new PublicKey(data,extra);if($.checkArgument(data,"First argument is required, please include public key data."),data instanceof PublicKey)return data;extra=extra||{};var info=this._classifyArgs(data,extra);return info.point.validate(),JSUtil.defineImmutable(this,{point:info.point,compressed:info.compressed,network:info.network||Network.defaultNetwork}),this}PublicKey.prototype._classifyArgs=function(data,extra){var info={compressed:_.isUndefined(extra.compressed)||extra.compressed};if(data instanceof Point)info.point=data;else if(data.x&&data.y)info=PublicKey._transformObject(data);else if("string"==typeof data)info=PublicKey._transformDER(new Buffer(data,"hex"));else if(PublicKey._isBuffer(data))info=PublicKey._transformDER(data);else{if(!PublicKey._isPrivateKey(data))throw new TypeError("First argument is an unrecognized data format.");info=PublicKey._transformPrivateKey(data)}return info.network||(info.network=_.isUndefined(extra.network)?void 0:Network.get(extra.network)),info},PublicKey._isPrivateKey=function(param){return param instanceof require("./privatekey")},PublicKey._isBuffer=function(param){return param instanceof Buffer||param instanceof Uint8Array},PublicKey._transformPrivateKey=function(privkey){$.checkArgument(PublicKey._isPrivateKey(privkey),"Must be an instance of PrivateKey");var info={};return info.point=Point.getG().mul(privkey.bn),info.compressed=privkey.compressed,info.network=privkey.network,info},PublicKey._transformDER=function(buf,strict){$.checkArgument(PublicKey._isBuffer(buf),"Must be a hex buffer of DER encoded public key");var info={};strict=!!_.isUndefined(strict)||strict;var x,y,xbuf,ybuf;if(4!==buf[0]&&(strict||6!==buf[0]&&7!==buf[0]))if(3===buf[0])xbuf=buf.slice(1),x=new BN(xbuf),(info=PublicKey._transformX(!0,x)).compressed=!0;else{if(2!==buf[0])throw new TypeError("Invalid DER format public key");xbuf=buf.slice(1),x=new BN(xbuf),(info=PublicKey._transformX(!1,x)).compressed=!0}else{if(xbuf=buf.slice(1,33),ybuf=buf.slice(33,65),32!==xbuf.length||32!==ybuf.length||65!==buf.length)throw new TypeError("Length of x and y must be 32 bytes");x=new BN(xbuf),y=new BN(ybuf),info.point=new Point(x,y),info.compressed=!1}return info},PublicKey._transformX=function(odd,x){$.checkArgument("boolean"==typeof odd,"Must specify whether y is odd or not (true or false)");var info={};return info.point=Point.fromX(odd,x),info},PublicKey._transformObject=function(json){var x=new BN(json.x,"hex"),y=new BN(json.y,"hex");return new PublicKey(new Point(x,y),{compressed:json.compressed})},PublicKey.fromPrivateKey=function(privkey){$.checkArgument(PublicKey._isPrivateKey(privkey),"Must be an instance of PrivateKey");var info=PublicKey._transformPrivateKey(privkey);return new PublicKey(info.point,{compressed:info.compressed,network:info.network})},PublicKey.fromDER=PublicKey.fromBuffer=function(buf,strict){$.checkArgument(PublicKey._isBuffer(buf),"Must be a hex buffer of DER encoded public key");var info=PublicKey._transformDER(buf,strict);return new PublicKey(info.point,{compressed:info.compressed})},PublicKey.fromPoint=function(point,compressed){return $.checkArgument(point instanceof Point,"First argument must be an instance of Point."),new PublicKey(point,{compressed:compressed})},PublicKey.fromString=function(str,encoding){var buf=new Buffer(str,encoding||"hex"),info=PublicKey._transformDER(buf);return new PublicKey(info.point,{compressed:info.compressed})},PublicKey.fromX=function(odd,x){var info=PublicKey._transformX(odd,x);return new PublicKey(info.point,{compressed:info.compressed})},PublicKey.getValidationError=function(data){var error;try{new PublicKey(data)}catch(e){error=e}return error},PublicKey.isValid=function(data){return!PublicKey.getValidationError(data)},PublicKey.prototype.toObject=PublicKey.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},PublicKey.prototype.toBuffer=PublicKey.prototype.toDER=function(){var prefix,x=this.point.getX(),y=this.point.getY(),xbuf=x.toBuffer({size:32}),ybuf=y.toBuffer({size:32});if(this.compressed){var odd=ybuf[ybuf.length-1]%2;return prefix=new Buffer(odd?[3]:[2]),Buffer.concat([prefix,xbuf])}return prefix=new Buffer([4]),Buffer.concat([prefix,xbuf,ybuf])},PublicKey.prototype._getID=function(){return Hash.sha256ripemd160(this.toBuffer())},PublicKey.prototype.toAddress=function(network){return require("./address").fromPublicKey(this,network||this.network)},PublicKey.prototype.toString=function(){return this.toDER().toString("hex")},PublicKey.prototype.inspect=function(){return""},module.exports=PublicKey}).call(this,require("buffer").Buffer)},{"./address":209,"./crypto/bn":214,"./crypto/hash":216,"./crypto/point":217,"./networks":229,"./privatekey":231,"./util/js":251,"./util/preconditions":252,buffer:70,lodash:144}],233:[function(require,module,exports){"use strict";module.exports=require("./script"),module.exports.Interpreter=require("./interpreter")},{"./interpreter":234,"./script":235}],234:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),Script=require("./script"),Opcode=require("../opcode"),BN=require("../crypto/bn"),Hash=require("../crypto/hash"),Signature=require("../crypto/signature"),PublicKey=require("../publickey"),Interpreter=function Interpreter(obj){if(!(this instanceof Interpreter))return new Interpreter(obj);obj?(this.initialize(),this.set(obj)):this.initialize()};Interpreter.prototype.verify=function(scriptSig,scriptPubkey,tx,nin,flags){var Transaction=require("../transaction");_.isUndefined(tx)&&(tx=new Transaction),_.isUndefined(nin)&&(nin=0),_.isUndefined(flags)&&(flags=0),this.set({script:scriptSig,tx:tx,nin:nin,flags:flags});var stackCopy;if(0!=(flags&Interpreter.SCRIPT_VERIFY_SIGPUSHONLY)&&!scriptSig.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;flags&Interpreter.SCRIPT_VERIFY_P2SH&&(stackCopy=this.stack.slice());var stack=this.stack;if(this.initialize(),this.set({script:scriptPubkey,stack:stack,tx:tx,nin:nin,flags:flags}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var buf=this.stack[this.stack.length-1];if(!Interpreter.castToBool(buf))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(flags&Interpreter.SCRIPT_VERIFY_P2SH&&scriptPubkey.isScriptHashOut()){if(!scriptSig.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===stackCopy.length)throw new Error("internal error - stack copy empty");var redeemScriptSerialized=stackCopy[stackCopy.length-1],redeemScript=Script.fromBuffer(redeemScriptSerialized);return stackCopy.pop(),this.initialize(),this.set({script:redeemScript,stack:stackCopy,tx:tx,nin:nin,flags:flags}),!!this.evaluate()&&(0===stackCopy.length?(this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1):!!Interpreter.castToBool(stackCopy[stackCopy.length-1])||(this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1))}return!0},module.exports=Interpreter,Interpreter.prototype.initialize=function(obj){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},Interpreter.prototype.set=function(obj){this.script=obj.script||this.script,this.tx=obj.tx||this.tx,this.nin=void 0!==obj.nin?obj.nin:this.nin,this.stack=obj.stack||this.stack,this.altstack=obj.altack||this.altstack,this.pc=void 0!==obj.pc?obj.pc:this.pc,this.pbegincodehash=void 0!==obj.pbegincodehash?obj.pbegincodehash:this.pbegincodehash,this.nOpCount=void 0!==obj.nOpCount?obj.nOpCount:this.nOpCount,this.vfExec=obj.vfExec||this.vfExec,this.errstr=obj.errstr||this.errstr,this.flags=void 0!==obj.flags?obj.flags:this.flags},Interpreter.true=new Buffer([1]),Interpreter.false=new Buffer([]),Interpreter.MAX_SCRIPT_ELEMENT_SIZE=520,Interpreter.LOCKTIME_THRESHOLD_BN=new BN(Interpreter.LOCKTIME_THRESHOLD=5e8),Interpreter.SCRIPT_VERIFY_NONE=0,Interpreter.SCRIPT_VERIFY_P2SH=1,Interpreter.SCRIPT_VERIFY_STRICTENC=2,Interpreter.SCRIPT_VERIFY_DERSIG=4,Interpreter.SCRIPT_VERIFY_LOW_S=8,Interpreter.SCRIPT_VERIFY_NULLDUMMY=16,Interpreter.SCRIPT_VERIFY_SIGPUSHONLY=32,Interpreter.SCRIPT_VERIFY_MINIMALDATA=64,Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,Interpreter.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,Interpreter.castToBool=function(buf){for(var i=0;i1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(e){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+e,!1}return!(this.vfExec.length>0)||(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1)},Interpreter.prototype.checkLockTime=function(nLockTime){return!!(this.tx.nLockTime=Interpreter.LOCKTIME_THRESHOLD&&nLockTime.gte(Interpreter.LOCKTIME_THRESHOLD_BN))&&(!nLockTime.gt(new BN(this.tx.nLockTime))&&!!this.tx.inputs[this.nin].isFinal())},Interpreter.prototype.step=function(){var buf,buf1,buf2,spliced,n,x1,x2,bn,bn1,bn2,bufSig,bufPubkey,subscript,sig,pubkey,fValue,fSuccess,fRequireMinimal=0!=(this.flags&Interpreter.SCRIPT_VERIFY_MINIMALDATA),fExec=-1===this.vfExec.indexOf(!1),chunk=this.script.chunks[this.pc];this.pc++;var opcodenum=chunk.opcodenum;if(_.isUndefined(opcodenum))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(chunk.buf&&chunk.buf.length>Interpreter.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(opcodenum>Opcode.OP_16&&++this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(opcodenum===Opcode.OP_CAT||opcodenum===Opcode.OP_SUBSTR||opcodenum===Opcode.OP_LEFT||opcodenum===Opcode.OP_RIGHT||opcodenum===Opcode.OP_INVERT||opcodenum===Opcode.OP_AND||opcodenum===Opcode.OP_OR||opcodenum===Opcode.OP_XOR||opcodenum===Opcode.OP_2MUL||opcodenum===Opcode.OP_2DIV||opcodenum===Opcode.OP_MUL||opcodenum===Opcode.OP_DIV||opcodenum===Opcode.OP_MOD||opcodenum===Opcode.OP_LSHIFT||opcodenum===Opcode.OP_RSHIFT)return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(fExec&&0<=opcodenum&&opcodenum<=Opcode.OP_PUSHDATA4){if(fRequireMinimal&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(chunk.buf){if(chunk.len!==chunk.buf.length)throw new Error("Length of push value not equal to length of data");this.stack.push(chunk.buf)}else this.stack.push(Interpreter.false)}else if(fExec||Opcode.OP_IF<=opcodenum&&opcodenum<=Opcode.OP_ENDIF)switch(opcodenum){case Opcode.OP_1NEGATE:case Opcode.OP_1:case Opcode.OP_2:case Opcode.OP_3:case Opcode.OP_4:case Opcode.OP_5:case Opcode.OP_6:case Opcode.OP_7:case Opcode.OP_8:case Opcode.OP_9:case Opcode.OP_10:case Opcode.OP_11:case Opcode.OP_12:case Opcode.OP_13:case Opcode.OP_14:case Opcode.OP_15:case Opcode.OP_16:n=opcodenum-(Opcode.OP_1-1),buf=new BN(n).toScriptNumBuffer(),this.stack.push(buf);break;case Opcode.OP_NOP:break;case Opcode.OP_NOP2:case Opcode.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&Interpreter.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var nLockTime=BN.fromScriptNumBuffer(this.stack[this.stack.length-1],fRequireMinimal,5);if(nLockTime.lt(new BN(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(nLockTime))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case Opcode.OP_NOP1:case Opcode.OP_NOP3:case Opcode.OP_NOP4:case Opcode.OP_NOP5:case Opcode.OP_NOP6:case Opcode.OP_NOP7:case Opcode.OP_NOP8:case Opcode.OP_NOP9:case Opcode.OP_NOP10:if(this.flags&Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case Opcode.OP_IF:case Opcode.OP_NOTIF:if(fValue=!1,fExec){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;buf=this.stack.pop(),fValue=Interpreter.castToBool(buf),opcodenum===Opcode.OP_NOTIF&&(fValue=!fValue)}this.vfExec.push(fValue);break;case Opcode.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case Opcode.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case Opcode.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(buf=this.stack[this.stack.length-1],!(fValue=Interpreter.castToBool(buf)))return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case Opcode.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case Opcode.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case Opcode.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case Opcode.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case Opcode.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;buf1=this.stack[this.stack.length-2],buf2=this.stack[this.stack.length-1],this.stack.push(buf1),this.stack.push(buf2);break;case Opcode.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;buf1=this.stack[this.stack.length-3],buf2=this.stack[this.stack.length-2];var buf3=this.stack[this.stack.length-1];this.stack.push(buf1),this.stack.push(buf2),this.stack.push(buf3);break;case Opcode.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;buf1=this.stack[this.stack.length-4],buf2=this.stack[this.stack.length-3],this.stack.push(buf1),this.stack.push(buf2);break;case Opcode.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;spliced=this.stack.splice(this.stack.length-6,2),this.stack.push(spliced[0]),this.stack.push(spliced[1]);break;case Opcode.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;spliced=this.stack.splice(this.stack.length-4,2),this.stack.push(spliced[0]),this.stack.push(spliced[1]);break;case Opcode.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;buf=this.stack[this.stack.length-1],(fValue=Interpreter.castToBool(buf))&&this.stack.push(buf);break;case Opcode.OP_DEPTH:buf=new BN(this.stack.length).toScriptNumBuffer(),this.stack.push(buf);break;case Opcode.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case Opcode.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-1]);break;case Opcode.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case Opcode.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-2]);break;case Opcode.OP_PICK:case Opcode.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(buf=this.stack[this.stack.length-1],n=(bn=BN.fromScriptNumBuffer(buf,fRequireMinimal)).toNumber(),this.stack.pop(),n<0||n>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;buf=this.stack[this.stack.length-n-1],opcodenum===Opcode.OP_ROLL&&this.stack.splice(this.stack.length-n-1,1),this.stack.push(buf);break;case Opcode.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;x1=this.stack[this.stack.length-3],x2=this.stack[this.stack.length-2];var x3=this.stack[this.stack.length-1];this.stack[this.stack.length-3]=x2,this.stack[this.stack.length-2]=x3,this.stack[this.stack.length-1]=x1;break;case Opcode.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;x1=this.stack[this.stack.length-2],x2=this.stack[this.stack.length-1],this.stack[this.stack.length-2]=x2,this.stack[this.stack.length-1]=x1;break;case Opcode.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,this.stack[this.stack.length-1]);break;case Opcode.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;bn=new BN(this.stack[this.stack.length-1].length),this.stack.push(bn.toScriptNumBuffer());break;case Opcode.OP_EQUAL:case Opcode.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;buf1=this.stack[this.stack.length-2],buf2=this.stack[this.stack.length-1];var fEqual=buf1.toString("hex")===buf2.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(fEqual?Interpreter.true:Interpreter.false),opcodenum===Opcode.OP_EQUALVERIFY){if(!fEqual)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case Opcode.OP_1ADD:case Opcode.OP_1SUB:case Opcode.OP_NEGATE:case Opcode.OP_ABS:case Opcode.OP_NOT:case Opcode.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(buf=this.stack[this.stack.length-1],bn=BN.fromScriptNumBuffer(buf,fRequireMinimal),opcodenum){case Opcode.OP_1ADD:bn=bn.add(BN.One);break;case Opcode.OP_1SUB:bn=bn.sub(BN.One);break;case Opcode.OP_NEGATE:bn=bn.neg();break;case Opcode.OP_ABS:bn.cmp(BN.Zero)<0&&(bn=bn.neg());break;case Opcode.OP_NOT:bn=new BN((0===bn.cmp(BN.Zero))+0);break;case Opcode.OP_0NOTEQUAL:bn=new BN((0!==bn.cmp(BN.Zero))+0)}this.stack.pop(),this.stack.push(bn.toScriptNumBuffer());break;case Opcode.OP_ADD:case Opcode.OP_SUB:case Opcode.OP_BOOLAND:case Opcode.OP_BOOLOR:case Opcode.OP_NUMEQUAL:case Opcode.OP_NUMEQUALVERIFY:case Opcode.OP_NUMNOTEQUAL:case Opcode.OP_LESSTHAN:case Opcode.OP_GREATERTHAN:case Opcode.OP_LESSTHANOREQUAL:case Opcode.OP_GREATERTHANOREQUAL:case Opcode.OP_MIN:case Opcode.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(bn1=BN.fromScriptNumBuffer(this.stack[this.stack.length-2],fRequireMinimal),bn2=BN.fromScriptNumBuffer(this.stack[this.stack.length-1],fRequireMinimal),bn=new BN(0),opcodenum){case Opcode.OP_ADD:bn=bn1.add(bn2);break;case Opcode.OP_SUB:bn=bn1.sub(bn2);break;case Opcode.OP_BOOLAND:bn=new BN((0!==bn1.cmp(BN.Zero)&&0!==bn2.cmp(BN.Zero))+0);break;case Opcode.OP_BOOLOR:bn=new BN((0!==bn1.cmp(BN.Zero)||0!==bn2.cmp(BN.Zero))+0);break;case Opcode.OP_NUMEQUAL:case Opcode.OP_NUMEQUALVERIFY:bn=new BN((0===bn1.cmp(bn2))+0);break;case Opcode.OP_NUMNOTEQUAL:bn=new BN((0!==bn1.cmp(bn2))+0);break;case Opcode.OP_LESSTHAN:bn=new BN((bn1.cmp(bn2)<0)+0);break;case Opcode.OP_GREATERTHAN:bn=new BN((bn1.cmp(bn2)>0)+0);break;case Opcode.OP_LESSTHANOREQUAL:bn=new BN((bn1.cmp(bn2)<=0)+0);break;case Opcode.OP_GREATERTHANOREQUAL:bn=new BN((bn1.cmp(bn2)>=0)+0);break;case Opcode.OP_MIN:bn=bn1.cmp(bn2)<0?bn1:bn2;break;case Opcode.OP_MAX:bn=bn1.cmp(bn2)>0?bn1:bn2}if(this.stack.pop(),this.stack.pop(),this.stack.push(bn.toScriptNumBuffer()),opcodenum===Opcode.OP_NUMEQUALVERIFY){if(!Interpreter.castToBool(this.stack[this.stack.length-1]))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case Opcode.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;bn1=BN.fromScriptNumBuffer(this.stack[this.stack.length-3],fRequireMinimal),bn2=BN.fromScriptNumBuffer(this.stack[this.stack.length-2],fRequireMinimal);var bn3=BN.fromScriptNumBuffer(this.stack[this.stack.length-1],fRequireMinimal);fValue=bn2.cmp(bn1)<=0&&bn1.cmp(bn3)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(fValue?Interpreter.true:Interpreter.false);break;case Opcode.OP_RIPEMD160:case Opcode.OP_SHA1:case Opcode.OP_SHA256:case Opcode.OP_HASH160:case Opcode.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;buf=this.stack[this.stack.length-1];var bufHash;opcodenum===Opcode.OP_RIPEMD160?bufHash=Hash.ripemd160(buf):opcodenum===Opcode.OP_SHA1?bufHash=Hash.sha1(buf):opcodenum===Opcode.OP_SHA256?bufHash=Hash.sha256(buf):opcodenum===Opcode.OP_HASH160?bufHash=Hash.sha256ripemd160(buf):opcodenum===Opcode.OP_HASH256&&(bufHash=Hash.sha256sha256(buf)),this.stack.pop(),this.stack.push(bufHash);break;case Opcode.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case Opcode.OP_CHECKSIG:case Opcode.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;bufSig=this.stack[this.stack.length-2],bufPubkey=this.stack[this.stack.length-1],subscript=(new Script).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var tmpScript=(new Script).add(bufSig);if(subscript.findAndDelete(tmpScript),!this.checkSignatureEncoding(bufSig)||!this.checkPubkeyEncoding(bufPubkey))return!1;try{sig=Signature.fromTxFormat(bufSig),pubkey=PublicKey.fromBuffer(bufPubkey,!1),fSuccess=this.tx.verifySignature(sig,pubkey,this.nin,subscript)}catch(e){fSuccess=!1}if(this.stack.pop(),this.stack.pop(),this.stack.push(fSuccess?Interpreter.true:Interpreter.false),opcodenum===Opcode.OP_CHECKSIGVERIFY){if(!fSuccess)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case Opcode.OP_CHECKMULTISIG:case Opcode.OP_CHECKMULTISIGVERIFY:var i=1;if(this.stack.length20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=nKeysCount,this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var ikey=++i;if(i+=nKeysCount,this.stack.lengthnKeysCount)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var isig=++i;if(i+=nSigsCount,this.stack.length0;){if(bufSig=this.stack[this.stack.length-isig],bufPubkey=this.stack[this.stack.length-ikey],!this.checkSignatureEncoding(bufSig)||!this.checkPubkeyEncoding(bufPubkey))return!1;var fOk;try{sig=Signature.fromTxFormat(bufSig),pubkey=PublicKey.fromBuffer(bufPubkey,!1),fOk=this.tx.verifySignature(sig,pubkey,this.nin,subscript)}catch(e){fOk=!1}fOk&&(isig++,nSigsCount--),ikey++,nSigsCount>--nKeysCount&&(fSuccess=!1)}for(;i-- >1;)this.stack.pop();if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&Interpreter.SCRIPT_VERIFY_NULLDUMMY&&this.stack[this.stack.length-1].length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(fSuccess?Interpreter.true:Interpreter.false),opcodenum===Opcode.OP_CHECKMULTISIGVERIFY){if(!fSuccess)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}}).call(this,require("buffer").Buffer)},{"../crypto/bn":214,"../crypto/hash":216,"../crypto/signature":219,"../opcode":230,"../publickey":232,"../transaction":236,"./script":235,buffer:70,lodash:144}],235:[function(require,module,exports){(function(Buffer){"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},Address=require("../address"),BufferReader=require("../encoding/bufferreader"),BufferWriter=require("../encoding/bufferwriter"),Hash=require("../crypto/hash"),Opcode=require("../opcode"),PublicKey=require("../publickey"),Signature=require("../crypto/signature"),Networks=require("../networks"),$=require("../util/preconditions"),_=require("lodash"),errors=require("../errors"),buffer=require("buffer"),BufferUtil=require("../util/buffer"),JSUtil=require("../util/js"),Script=function Script(from){return this instanceof Script?(this.chunks=[],BufferUtil.isBuffer(from)?Script.fromBuffer(from):from instanceof Address?Script.fromAddress(from):from instanceof Script?Script.fromBuffer(from.toBuffer()):"string"==typeof from?Script.fromString(from):void(void 0!==from&&this.set(from))):new Script(from)};Script.prototype.set=function(obj){return this.chunks=obj.chunks||this.chunks,this},Script.fromBuffer=function(buffer){var script=new Script;script.chunks=[];for(var br=new BufferReader(buffer);!br.finished();)try{var len,buf,opcodenum=br.readUInt8();opcodenum>0&&opcodenum0&&opcodenum0&&(str=asm?str+" "+chunk.buf.toString("hex"):str+" "+chunk.len+" 0x"+chunk.buf.toString("hex"));else if(void 0!==Opcode.reverseMap[opcodenum])str=str+" "+Opcode(opcodenum).toString();else{var numstr=opcodenum.toString(16);numstr.length%2!=0&&(numstr="0"+numstr),str=asm?str+" "+numstr:str+" 0x"+numstr}return str},Script.prototype.toASM=function(){for(var str="",i=0;i"},Script.prototype.isPublicKeyHashOut=function(){return!(5!==this.chunks.length||this.chunks[0].opcodenum!==Opcode.OP_DUP||this.chunks[1].opcodenum!==Opcode.OP_HASH160||!this.chunks[2].buf||20!==this.chunks[2].buf.length||this.chunks[3].opcodenum!==Opcode.OP_EQUALVERIFY||this.chunks[4].opcodenum!==Opcode.OP_CHECKSIG)},Script.prototype.isPublicKeyHashIn=function(){if(2===this.chunks.length){var signatureBuf=this.chunks[0].buf,pubkeyBuf=this.chunks[1].buf;if(signatureBuf&&signatureBuf.length&&48===signatureBuf[0]&&pubkeyBuf&&pubkeyBuf.length){var version=pubkeyBuf[0];if((4===version||6===version||7===version)&&65===pubkeyBuf.length)return!0;if((3===version||2===version)&&33===pubkeyBuf.length)return!0}}return!1},Script.prototype.getPublicKey=function(){return $.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf},Script.prototype.getPublicKeyHash=function(){return $.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf},Script.prototype.isPublicKeyOut=function(){if(2===this.chunks.length&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===Opcode.OP_CHECKSIG){var pubkeyBuf=this.chunks[0].buf,version=pubkeyBuf[0],isVersion=!1;if(4!==version&&6!==version&&7!==version||65!==pubkeyBuf.length?3!==version&&2!==version||33!==pubkeyBuf.length||(isVersion=!0):isVersion=!0,isVersion)return PublicKey.isValid(pubkeyBuf)}return!1},Script.prototype.isPublicKeyIn=function(){if(1===this.chunks.length){var signatureBuf=this.chunks[0].buf;if(signatureBuf&&signatureBuf.length&&48===signatureBuf[0])return!0}return!1},Script.prototype.isScriptHashOut=function(){var buf=this.toBuffer();return 23===buf.length&&buf[0]===Opcode.OP_HASH160&&20===buf[1]&&buf[buf.length-1]===Opcode.OP_EQUAL},Script.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var redeemBuf=this.chunks[this.chunks.length-1].buf;if(!redeemBuf)return!1;var redeemScript;try{redeemScript=Script.fromBuffer(redeemBuf)}catch(e){if(e instanceof errors.Script.InvalidBuffer)return!1;throw e}return redeemScript.classify()!==Script.types.UNKNOWN},Script.prototype.isMultisigOut=function(){return this.chunks.length>3&&Opcode.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(obj){return obj.buf&&BufferUtil.isBuffer(obj.buf)})&&Opcode.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===Opcode.OP_CHECKMULTISIG},Script.prototype.isMultisigIn=function(){return this.chunks.length>=2&&0===this.chunks[0].opcodenum&&this.chunks.slice(1,this.chunks.length).every(function(obj){return obj.buf&&BufferUtil.isBuffer(obj.buf)&&Signature.isTxDER(obj.buf)})},Script.prototype.isDataOut=function(){return this.chunks.length>=1&&this.chunks[0].opcodenum===Opcode.OP_RETURN&&(1===this.chunks.length||2===this.chunks.length&&this.chunks[1].buf&&this.chunks[1].buf.length<=Script.OP_RETURN_STANDARD_SIZE&&this.chunks[1].length===this.chunks.len)},Script.prototype.getData=function(){if(this.isDataOut()||this.isScriptHashOut())return _.isUndefined(this.chunks[1])?new Buffer(0):new Buffer(this.chunks[1].buf);if(this.isPublicKeyHashOut())return new Buffer(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")},Script.prototype.isPushOnly=function(){return _.every(this.chunks,function(chunk){return chunk.opcodenum<=Opcode.OP_16})},(Script.types={}).UNKNOWN="Unknown",Script.types.PUBKEY_OUT="Pay to public key",Script.types.PUBKEY_IN="Spend from public key",Script.types.PUBKEYHASH_OUT="Pay to public key hash",Script.types.PUBKEYHASH_IN="Spend from public key hash",Script.types.SCRIPTHASH_OUT="Pay to script hash",Script.types.SCRIPTHASH_IN="Spend from script hash",Script.types.MULTISIG_OUT="Pay to multisig",Script.types.MULTISIG_IN="Spend from multisig",Script.types.DATA_OUT="Data push",Script.OP_RETURN_STANDARD_SIZE=80,Script.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var outputType=this.classifyOutput();return outputType!=Script.types.UNKNOWN?outputType:this.classifyInput()},(Script.outputIdentifiers={}).PUBKEY_OUT=Script.prototype.isPublicKeyOut,Script.outputIdentifiers.PUBKEYHASH_OUT=Script.prototype.isPublicKeyHashOut,Script.outputIdentifiers.MULTISIG_OUT=Script.prototype.isMultisigOut,Script.outputIdentifiers.SCRIPTHASH_OUT=Script.prototype.isScriptHashOut,Script.outputIdentifiers.DATA_OUT=Script.prototype.isDataOut,Script.prototype.classifyOutput=function(){for(var type in Script.outputIdentifiers)if(Script.outputIdentifiers[type].bind(this)())return Script.types[type];return Script.types.UNKNOWN},(Script.inputIdentifiers={}).PUBKEY_IN=Script.prototype.isPublicKeyIn,Script.inputIdentifiers.PUBKEYHASH_IN=Script.prototype.isPublicKeyHashIn,Script.inputIdentifiers.MULTISIG_IN=Script.prototype.isMultisigIn,Script.inputIdentifiers.SCRIPTHASH_IN=Script.prototype.isScriptHashIn,Script.prototype.classifyInput=function(){for(var type in Script.inputIdentifiers)if(Script.inputIdentifiers[type].bind(this)())return Script.types[type];return Script.types.UNKNOWN},Script.prototype.isStandard=function(){return this.classify()!==Script.types.UNKNOWN},Script.prototype.prepend=function(obj){return this._addByType(obj,!0),this},Script.prototype.equals=function(script){if($.checkState(script instanceof Script,"Must provide another script"),this.chunks.length!==script.chunks.length)return!1;var i;for(i=0;i=0&&len=1&&buf[0]<=16?opcodenum===Opcode.OP_1+(buf[0]-1):1===buf.length&&129===buf[0]?opcodenum===Opcode.OP_1NEGATE:buf.length<=75?opcodenum===buf.length:buf.length<=255?opcodenum===Opcode.OP_PUSHDATA1:!(buf.length<=65535)||opcodenum===Opcode.OP_PUSHDATA2)},Script.prototype._decodeOP_N=function(opcode){if(opcode===Opcode.OP_0)return 0;if(opcode>=Opcode.OP_1&&opcode<=Opcode.OP_16)return opcode-(Opcode.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(opcode))},Script.prototype.getSignatureOperationsCount=function(accurate){accurate=!!_.isUndefined(accurate)||accurate;var self=this,n=0,lastOpcode=Opcode.OP_INVALIDOPCODE;return _.each(self.chunks,function(chunk){var opcode=chunk.opcodenum;opcode==Opcode.OP_CHECKSIG||opcode==Opcode.OP_CHECKSIGVERIFY?n++:opcode!=Opcode.OP_CHECKMULTISIG&&opcode!=Opcode.OP_CHECKMULTISIGVERIFY||(accurate&&lastOpcode>=Opcode.OP_1&&lastOpcode<=Opcode.OP_16?n+=self._decodeOP_N(lastOpcode):n+=20),lastOpcode=opcode}),n},module.exports=Script}).call(this,require("buffer").Buffer)},{"../address":209,"../crypto/hash":216,"../crypto/signature":219,"../encoding/bufferreader":222,"../encoding/bufferwriter":223,"../errors":225,"../networks":229,"../opcode":230,"../publickey":232,"../util/buffer":250,"../util/js":251,"../util/preconditions":252,buffer:70,lodash:144}],236:[function(require,module,exports){"use strict";module.exports=require("./transaction"),module.exports.Input=require("./input"),module.exports.Output=require("./output"),module.exports.UnspentOutput=require("./unspentoutput"),module.exports.Signature=require("./signature"),module.exports.Sighash=require("./sighash")},{"./input":237,"./output":243,"./sighash":244,"./signature":245,"./transaction":246,"./unspentoutput":247}],237:[function(require,module,exports){"use strict";module.exports=require("./input"),module.exports.PublicKey=require("./publickey"),module.exports.PublicKeyHash=require("./publickeyhash"),module.exports.MultiSig=require("./multisig.js"),module.exports.MultiSigScriptHash=require("./multisigscripthash.js")},{"./input":238,"./multisig.js":239,"./multisigscripthash.js":240,"./publickey":241,"./publickeyhash":242}],238:[function(require,module,exports){"use strict";var _=require("lodash"),$=require("../../util/preconditions"),errors=require("../../errors"),BufferWriter=require("../../encoding/bufferwriter"),buffer=require("buffer"),BufferUtil=require("../../util/buffer"),JSUtil=require("../../util/js"),Script=require("../../script"),Sighash=require("../sighash"),Output=require("../output");function Input(params){return this instanceof Input?params?this._fromObject(params):void 0:new Input(params)}Input.MAXINT=4294967295,Input.DEFAULT_SEQNUMBER=4294967295,Input.DEFAULT_LOCKTIME_SEQNUMBER=4294967294,Input.DEFAULT_RBF_SEQNUMBER=4294967293,Object.defineProperty(Input.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new Script(this._scriptBuffer),this._script._isInput=!0),this._script)}}),Input.fromObject=function(obj){$.checkArgument(_.isObject(obj));return(new Input)._fromObject(obj)},Input.prototype._fromObject=function(params){var prevTxId;if(prevTxId=_.isString(params.prevTxId)&&JSUtil.isHexa(params.prevTxId)?new buffer.Buffer(params.prevTxId,"hex"):params.prevTxId,this.output=params.output?params.output instanceof Output?params.output:new Output(params.output):void 0,this.prevTxId=prevTxId||params.txidbuf,this.outputIndex=_.isUndefined(params.outputIndex)?params.txoutnum:params.outputIndex,this.sequenceNumber=_.isUndefined(params.sequenceNumber)?_.isUndefined(params.seqnum)?4294967295:params.seqnum:params.sequenceNumber,_.isUndefined(params.script)&&_.isUndefined(params.scriptBuffer))throw new errors.Transaction.Input.MissingScript;return this.setScript(params.scriptBuffer||params.script),this},Input.prototype.toObject=Input.prototype.toJSON=function(){var obj={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(obj.scriptString=this.script.toString()),this.output&&(obj.output=this.output.toObject()),obj},Input.fromBufferReader=function(br){var input=new Input;return input.prevTxId=br.readReverse(32),input.outputIndex=br.readUInt32LE(),input._scriptBuffer=br.readVarLengthBuffer(),input.sequenceNumber=br.readUInt32LE(),input},Input.prototype.toBufferWriter=function(writer){writer||(writer=new BufferWriter),writer.writeReverse(this.prevTxId),writer.writeUInt32LE(this.outputIndex);var script=this._scriptBuffer;return writer.writeVarintNum(script.length),writer.write(script),writer.writeUInt32LE(this.sequenceNumber),writer},Input.prototype.setScript=function(script){if(this._script=null,script instanceof Script)this._script=script,this._script._isInput=!0,this._scriptBuffer=script.toBuffer();else if(JSUtil.isHexa(script))this._scriptBuffer=new buffer.Buffer(script,"hex");else if(_.isString(script))this._script=new Script(script),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else{if(!BufferUtil.isBuffer(script))throw new TypeError("Invalid argument type: script");this._scriptBuffer=new buffer.Buffer(script)}return this},Input.prototype.getSignatures=function(){throw new errors.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))},Input.prototype.isFullySigned=function(){throw new errors.AbstractMethodInvoked("Input#isFullySigned")},Input.prototype.isFinal=function(){return 4294967295!==this.sequenceNumber},Input.prototype.addSignature=function(){throw new errors.AbstractMethodInvoked("Input#addSignature")},Input.prototype.clearSignatures=function(){throw new errors.AbstractMethodInvoked("Input#clearSignatures")},Input.prototype.isValidSignature=function(transaction,signature){return signature.signature.nhashtype=signature.sigtype,Sighash.verify(transaction,signature.signature,signature.publicKey,signature.inputIndex,this.output.script,this.output.satoshisBN)},Input.prototype.isNull=function(){return"0000000000000000000000000000000000000000000000000000000000000000"===this.prevTxId.toString("hex")&&4294967295===this.outputIndex},Input.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length},module.exports=Input},{"../../encoding/bufferwriter":223,"../../errors":225,"../../script":233,"../../util/buffer":250,"../../util/js":251,"../../util/preconditions":252,"../output":243,"../sighash":244,buffer:70,lodash:144}],239:[function(require,module,exports){"use strict";var _=require("lodash"),inherits=require("inherits"),Input=(require("../transaction"),require("./input")),Output=require("../output"),$=require("../../util/preconditions"),Script=require("../../script"),Signature=require("../../crypto/signature"),Sighash=require("../sighash"),BufferUtil=(require("../../publickey"),require("../../util/buffer")),TransactionSignature=require("../signature");function MultiSigInput(input,pubkeys,threshold,signatures){Input.apply(this,arguments);var self=this;pubkeys=pubkeys||input.publicKeys,threshold=threshold||input.threshold,signatures=signatures||input.signatures,this.publicKeys=_.sortBy(pubkeys,function(publicKey){return publicKey.toString("hex")}),$.checkState(Script.buildMultisigOut(this.publicKeys,threshold).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},_.each(this.publicKeys,function(publicKey,index){self.publicKeyIndex[publicKey.toString()]=index}),this.threshold=threshold,this.signatures=signatures?this._deserializeSignatures(signatures):new Array(this.publicKeys.length)}inherits(MultiSigInput,Input),MultiSigInput.prototype.toObject=function(){var obj=Input.prototype.toObject.apply(this,arguments);return obj.threshold=this.threshold,obj.publicKeys=_.map(this.publicKeys,function(publicKey){return publicKey.toString()}),obj.signatures=this._serializeSignatures(),obj},MultiSigInput.prototype._deserializeSignatures=function(signatures){return _.map(signatures,function(signature){if(signature)return new TransactionSignature(signature)})},MultiSigInput.prototype._serializeSignatures=function(){return _.map(this.signatures,function(signature){if(signature)return signature.toObject()})},MultiSigInput.prototype.getSignatures=function(transaction,privateKey,index,sigtype){$.checkState(this.output instanceof Output),sigtype=sigtype||Signature.SIGHASH_ALL|Signature.SIGHASH_FORKID;var self=this,results=[];return _.each(this.publicKeys,function(publicKey){publicKey.toString()===privateKey.publicKey.toString()&&results.push(new TransactionSignature({publicKey:privateKey.publicKey,prevTxId:self.prevTxId,outputIndex:self.outputIndex,inputIndex:index,signature:Sighash.sign(transaction,privateKey,sigtype,index,self.output.script,self.output.satoshisBN),sigtype:sigtype}))}),results},MultiSigInput.prototype.addSignature=function(transaction,signature){return $.checkState(!this.isFullySigned(),"All needed signatures have already been added"),$.checkArgument(!_.isUndefined(this.publicKeyIndex[signature.publicKey.toString()]),"Signature has no matching public key"),$.checkState(this.isValidSignature(transaction,signature)),this.signatures[this.publicKeyIndex[signature.publicKey.toString()]]=signature,this._updateScript(),this},MultiSigInput.prototype._updateScript=function(){return this.setScript(Script.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},MultiSigInput.prototype._createSignatures=function(){return _.map(_.filter(this.signatures,function(signature){return!_.isUndefined(signature)}),function(signature){return BufferUtil.concat([signature.signature.toDER(),BufferUtil.integerAsSingleByteBuffer(signature.sigtype)])})},MultiSigInput.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},MultiSigInput.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},MultiSigInput.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},MultiSigInput.prototype.countSignatures=function(){return _.reduce(this.signatures,function(sum,signature){return sum+!!signature},0)},MultiSigInput.prototype.publicKeysWithoutSignature=function(){var self=this;return _.filter(this.publicKeys,function(publicKey){return!self.signatures[self.publicKeyIndex[publicKey.toString()]]})},MultiSigInput.prototype.isValidSignature=function(transaction,signature){return signature.signature.nhashtype=signature.sigtype,Sighash.verify(transaction,signature.signature,signature.publicKey,signature.inputIndex,this.output.script,this.output.satoshisBN)},MultiSigInput.normalizeSignatures=function(transaction,input,inputIndex,signatures,publicKeys){return publicKeys.map(function(pubKey){var signatureMatch=null;return signatures=signatures.filter(function(signatureBuffer){if(signatureMatch)return!0;var signature=new TransactionSignature({signature:Signature.fromTxFormat(signatureBuffer),publicKey:pubKey,prevTxId:input.prevTxId,outputIndex:input.outputIndex,inputIndex:inputIndex,sigtype:Signature.SIGHASH_ALL});signature.signature.nhashtype=signature.sigtype;return!Sighash.verify(transaction,signature.signature,signature.publicKey,signature.inputIndex,input.output.script)||(signatureMatch=signature,!1)}),signatureMatch||null})},MultiSigInput.OPCODES_SIZE=1,MultiSigInput.SIGNATURE_SIZE=73,MultiSigInput.prototype._estimateSize=function(){return MultiSigInput.OPCODES_SIZE+this.threshold*MultiSigInput.SIGNATURE_SIZE},module.exports=MultiSigInput},{"../../crypto/signature":219,"../../publickey":232,"../../script":233,"../../util/buffer":250,"../../util/preconditions":252,"../output":243,"../sighash":244,"../signature":245,"../transaction":246,"./input":238,inherits:141,lodash:144}],240:[function(require,module,exports){"use strict";var _=require("lodash"),inherits=require("inherits"),Input=require("./input"),Output=require("../output"),$=require("../../util/preconditions"),Script=require("../../script"),Signature=require("../../crypto/signature"),Sighash=require("../sighash"),BufferUtil=(require("../../publickey"),require("../../util/buffer")),TransactionSignature=require("../signature");function MultiSigScriptHashInput(input,pubkeys,threshold,signatures){Input.apply(this,arguments);var self=this;pubkeys=pubkeys||input.publicKeys,threshold=threshold||input.threshold,signatures=signatures||input.signatures,this.publicKeys=_.sortBy(pubkeys,function(publicKey){return publicKey.toString("hex")}),this.redeemScript=Script.buildMultisigOut(this.publicKeys,threshold),$.checkState(Script.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},_.each(this.publicKeys,function(publicKey,index){self.publicKeyIndex[publicKey.toString()]=index}),this.threshold=threshold,this.signatures=signatures?this._deserializeSignatures(signatures):new Array(this.publicKeys.length)}inherits(MultiSigScriptHashInput,Input),MultiSigScriptHashInput.prototype.toObject=function(){var obj=Input.prototype.toObject.apply(this,arguments);return obj.threshold=this.threshold,obj.publicKeys=_.map(this.publicKeys,function(publicKey){return publicKey.toString()}),obj.signatures=this._serializeSignatures(),obj},MultiSigScriptHashInput.prototype._deserializeSignatures=function(signatures){return _.map(signatures,function(signature){if(signature)return new TransactionSignature(signature)})},MultiSigScriptHashInput.prototype._serializeSignatures=function(){return _.map(this.signatures,function(signature){if(signature)return signature.toObject()})},MultiSigScriptHashInput.prototype.getSignatures=function(transaction,privateKey,index,sigtype){$.checkState(this.output instanceof Output),sigtype=sigtype||Signature.SIGHASH_ALL|Signature.SIGHASH_FORKID;var self=this,results=[];return _.each(this.publicKeys,function(publicKey){publicKey.toString()===privateKey.publicKey.toString()&&results.push(new TransactionSignature({publicKey:privateKey.publicKey,prevTxId:self.prevTxId,outputIndex:self.outputIndex,inputIndex:index,signature:Sighash.sign(transaction,privateKey,sigtype,index,self.redeemScript,self.output.satoshisBN),sigtype:sigtype}))}),results},MultiSigScriptHashInput.prototype.addSignature=function(transaction,signature){return $.checkState(!this.isFullySigned(),"All needed signatures have already been added"),$.checkArgument(!_.isUndefined(this.publicKeyIndex[signature.publicKey.toString()]),"Signature has no matching public key"),$.checkState(this.isValidSignature(transaction,signature)),this.signatures[this.publicKeyIndex[signature.publicKey.toString()]]=signature,this._updateScript(),this},MultiSigScriptHashInput.prototype._updateScript=function(){return this.setScript(Script.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},MultiSigScriptHashInput.prototype._createSignatures=function(){return _.map(_.filter(this.signatures,function(signature){return!_.isUndefined(signature)}),function(signature){return BufferUtil.concat([signature.signature.toDER(),BufferUtil.integerAsSingleByteBuffer(signature.sigtype)])})},MultiSigScriptHashInput.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},MultiSigScriptHashInput.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},MultiSigScriptHashInput.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},MultiSigScriptHashInput.prototype.countSignatures=function(){return _.reduce(this.signatures,function(sum,signature){return sum+!!signature},0)},MultiSigScriptHashInput.prototype.publicKeysWithoutSignature=function(){var self=this;return _.filter(this.publicKeys,function(publicKey){return!self.signatures[self.publicKeyIndex[publicKey.toString()]]})},MultiSigScriptHashInput.prototype.isValidSignature=function(transaction,signature){return signature.signature.nhashtype=signature.sigtype,Sighash.verify(transaction,signature.signature,signature.publicKey,signature.inputIndex,this.redeemScript,this.output.satoshisBN)},MultiSigScriptHashInput.OPCODES_SIZE=7,MultiSigScriptHashInput.SIGNATURE_SIZE=74,MultiSigScriptHashInput.PUBKEY_SIZE=34,MultiSigScriptHashInput.prototype._estimateSize=function(){return MultiSigScriptHashInput.OPCODES_SIZE+this.threshold*MultiSigScriptHashInput.SIGNATURE_SIZE+this.publicKeys.length*MultiSigScriptHashInput.PUBKEY_SIZE},module.exports=MultiSigScriptHashInput},{"../../crypto/signature":219,"../../publickey":232,"../../script":233,"../../util/buffer":250,"../../util/preconditions":252,"../output":243,"../sighash":244,"../signature":245,"./input":238,inherits:141,lodash:144}],241:[function(require,module,exports){"use strict";var inherits=require("inherits"),$=require("../../util/preconditions"),Input=(require("../../util/buffer"),require("./input")),Output=require("../output"),Sighash=require("../sighash"),Script=require("../../script"),Signature=require("../../crypto/signature"),TransactionSignature=require("../signature");function PublicKeyInput(){Input.apply(this,arguments)}inherits(PublicKeyInput,Input),PublicKeyInput.prototype.getSignatures=function(transaction,privateKey,index,sigtype){$.checkState(this.output instanceof Output),sigtype=sigtype||Signature.SIGHASH_ALL|Signature.SIGHASH_FORKID;var publicKey=privateKey.toPublicKey();return publicKey.toString()===this.output.script.getPublicKey().toString("hex")?[new TransactionSignature({publicKey:publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:index,signature:Sighash.sign(transaction,privateKey,sigtype,index,this.output.script,this.output.satoshisBN),sigtype:sigtype})]:[]},PublicKeyInput.prototype.addSignature=function(transaction,signature){return $.checkState(this.isValidSignature(transaction,signature),"Signature is invalid"),this.setScript(Script.buildPublicKeyIn(signature.signature.toDER(),signature.sigtype)),this},PublicKeyInput.prototype.clearSignatures=function(){return this.setScript(Script.empty()),this},PublicKeyInput.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},PublicKeyInput.SCRIPT_MAX_SIZE=73,PublicKeyInput.prototype._estimateSize=function(){return PublicKeyInput.SCRIPT_MAX_SIZE},module.exports=PublicKeyInput},{"../../crypto/signature":219,"../../script":233,"../../util/buffer":250,"../../util/preconditions":252,"../output":243,"../sighash":244,"../signature":245,"./input":238,inherits:141}],242:[function(require,module,exports){"use strict";var inherits=require("inherits"),$=require("../../util/preconditions"),BufferUtil=require("../../util/buffer"),Hash=require("../../crypto/hash"),Input=require("./input"),Output=require("../output"),Sighash=require("../sighash"),Script=require("../../script"),Signature=require("../../crypto/signature"),TransactionSignature=require("../signature");function PublicKeyHashInput(){Input.apply(this,arguments)}inherits(PublicKeyHashInput,Input),PublicKeyHashInput.prototype.getSignatures=function(transaction,privateKey,index,sigtype,hashData){return $.checkState(this.output instanceof Output),hashData=hashData||Hash.sha256ripemd160(privateKey.publicKey.toBuffer()),sigtype=sigtype||Signature.SIGHASH_ALL|Signature.SIGHASH_FORKID,BufferUtil.equals(hashData,this.output.script.getPublicKeyHash())?[new TransactionSignature({publicKey:privateKey.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:index,signature:Sighash.sign(transaction,privateKey,sigtype,index,this.output.script,this.output.satoshisBN),sigtype:sigtype})]:[]},PublicKeyHashInput.prototype.addSignature=function(transaction,signature){return $.checkState(this.isValidSignature(transaction,signature),"Signature is invalid"),this.setScript(Script.buildPublicKeyHashIn(signature.publicKey,signature.signature.toDER(),signature.sigtype)),this},PublicKeyHashInput.prototype.clearSignatures=function(){return this.setScript(Script.empty()),this},PublicKeyHashInput.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},PublicKeyHashInput.SCRIPT_MAX_SIZE=107,PublicKeyHashInput.prototype._estimateSize=function(){return PublicKeyHashInput.SCRIPT_MAX_SIZE},module.exports=PublicKeyHashInput},{"../../crypto/hash":216,"../../crypto/signature":219,"../../script":233,"../../util/buffer":250,"../../util/preconditions":252,"../output":243,"../sighash":244,"../signature":245,"./input":238,inherits:141}],243:[function(require,module,exports){"use strict";var _=require("lodash"),BN=require("../crypto/bn"),buffer=require("buffer"),bufferUtil=require("../util/buffer"),JSUtil=require("../util/js"),BufferWriter=require("../encoding/bufferwriter"),Script=require("../script"),$=require("../util/preconditions"),errors=require("../errors");function Output(args){if(!(this instanceof Output))return new Output(args);if(!_.isObject(args))throw new TypeError("Unrecognized argument for Output");if(this.satoshis=args.satoshis,bufferUtil.isBuffer(args.script))this._scriptBuffer=args.script;else{var script;script=_.isString(args.script)&&JSUtil.isHexa(args.script)?new buffer.Buffer(args.script,"hex"):args.script,this.setScript(script)}}Object.defineProperty(Output.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}}),Object.defineProperty(Output.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(num){num instanceof BN?(this._satoshisBN=num,this._satoshis=num.toNumber()):_.isString(num)?(this._satoshis=parseInt(num),this._satoshisBN=BN.fromNumber(this._satoshis)):($.checkArgument(JSUtil.isNaturalNumber(num),"Output satoshis is not a natural number"),this._satoshisBN=BN.fromNumber(num),this._satoshis=num),$.checkState(JSUtil.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),Output.prototype.invalidSatoshis=function(){return this._satoshis>9007199254740991?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0&&"transaction txout negative"},Object.defineProperty(Output.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(num){this._satoshisBN=num,this._satoshis=num.toNumber(),$.checkState(JSUtil.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),Output.prototype.toObject=Output.prototype.toJSON=function(){var obj={satoshis:this.satoshis};return obj.script=this._scriptBuffer.toString("hex"),obj},Output.fromObject=function(data){return new Output(data)},Output.prototype.setScriptFromBuffer=function(buffer){this._scriptBuffer=buffer;try{this._script=Script.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(e){if(!(e instanceof errors.Script.InvalidBuffer))throw e;this._script=null}},Output.prototype.setScript=function(script){if(script instanceof Script)this._scriptBuffer=script.toBuffer(),this._script=script,this._script._isOutput=!0;else if(_.isString(script))this._script=Script.fromString(script),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else{if(!bufferUtil.isBuffer(script))throw new TypeError("Invalid argument type: script");this.setScriptFromBuffer(script)}return this},Output.prototype.inspect=function(){var scriptStr;return scriptStr=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),""},Output.fromBufferReader=function(br){var obj={};obj.satoshis=br.readUInt64LEBN();var size=br.readVarintNum();return obj.script=0!==size?br.read(size):new buffer.Buffer([]),new Output(obj)},Output.prototype.toBufferWriter=function(writer){writer||(writer=new BufferWriter),writer.writeUInt64LEBN(this._satoshisBN);var script=this._scriptBuffer;return writer.writeVarintNum(script.length),writer.write(script),writer},module.exports=Output},{"../crypto/bn":214,"../encoding/bufferwriter":223,"../errors":225,"../script":233,"../util/buffer":250,"../util/js":251,"../util/preconditions":252,buffer:70,lodash:144}],244:[function(require,module,exports){(function(Buffer){"use strict";var buffer=require("buffer"),Signature=require("../crypto/signature"),Script=require("../script"),Output=require("./output"),BufferReader=require("../encoding/bufferreader"),BufferWriter=require("../encoding/bufferwriter"),BN=require("../crypto/bn"),Hash=require("../crypto/hash"),ECDSA=require("../crypto/ecdsa"),$=require("../util/preconditions"),BufferUtil=require("../util/buffer"),_=require("lodash"),sighash=function(transaction,sighashType,inputNumber,subscript,satoshisBN){var Transaction=require("./transaction"),Input=require("./input"),txcopy=Transaction.shallowCopy(transaction);if(subscript=new Script(subscript),sighashType&Signature.SIGHASH_FORKID)return function(transaction,sighashType,inputNumber,subscript,satoshisBN){var input=transaction.inputs[inputNumber];$.checkArgument(satoshisBN instanceof BN,"For ForkId=0 signatures, satoshis or complete input must be provided");function GetOutputsHash(tx,n){var writer=new BufferWriter;_.isUndefined(n)?_.each(tx.outputs,function(output){output.toBufferWriter(writer)}):tx.outputs[n].toBufferWriter(writer);var buf=writer.toBuffer();return Hash.sha256sha256(buf)}var hashPrevouts=BufferUtil.emptyBuffer(32),hashSequence=BufferUtil.emptyBuffer(32),hashOutputs=BufferUtil.emptyBuffer(32);sighashType&Signature.SIGHASH_ANYONECANPAY||(hashPrevouts=function(tx){var writer=new BufferWriter;_.each(tx.inputs,function(input){writer.writeReverse(input.prevTxId),writer.writeUInt32LE(input.outputIndex)});var buf=writer.toBuffer();return Hash.sha256sha256(buf)}(transaction)),sighashType&Signature.SIGHASH_ANYONECANPAY||(31&sighashType)==Signature.SIGHASH_SINGLE||(31&sighashType)==Signature.SIGHASH_NONE||(hashSequence=function(tx){var writer=new BufferWriter;_.each(tx.inputs,function(input){writer.writeUInt32LE(input.sequenceNumber)});var buf=writer.toBuffer();return Hash.sha256sha256(buf)}(transaction)),(31&sighashType)!=Signature.SIGHASH_SINGLE&&(31&sighashType)!=Signature.SIGHASH_NONE?hashOutputs=GetOutputsHash(transaction):(31&sighashType)==Signature.SIGHASH_SINGLE&&inputNumber>>0);var buf=writer.toBuffer(),ret=Hash.sha256sha256(buf);return ret=new BufferReader(ret).readReverse()}(txcopy,sighashType,inputNumber,subscript,satoshisBN);subscript.removeCodeseparators();var i;for(i=0;i=txcopy.outputs.length)return new Buffer("0000000000000000000000000000000000000000000000000000000000000001","hex");for(txcopy.outputs.length=inputNumber+1,i=0;imaximumFee)return this._missingChange()?new errors.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new errors.Transaction.FeeError.TooLarge("expected less than "+maximumFee+" but got "+unspent)}if(!opts.disableSmallFees){var minimumFee=Math.ceil(this._estimateFee()/Transaction.FEE_SECURITY_MARGIN);if(unspent"},Transaction.prototype.toBuffer=function(){var writer=new BufferWriter;return this.toBufferWriter(writer).toBuffer()},Transaction.prototype.toBufferWriter=function(writer){return writer.writeInt32LE(this.version),writer.writeVarintNum(this.inputs.length),_.each(this.inputs,function(input){input.toBufferWriter(writer)}),writer.writeVarintNum(this.outputs.length),_.each(this.outputs,function(output){output.toBufferWriter(writer)}),writer.writeUInt32LE(this.nLockTime),writer},Transaction.prototype.fromBuffer=function(buffer){var reader=new BufferReader(buffer);return this.fromBufferReader(reader)},Transaction.prototype.fromBufferReader=function(reader){$.checkArgument(!reader.finished(),"No transaction data received");var i,sizeTxIns,sizeTxOuts;for(this.version=reader.readInt32LE(),sizeTxIns=reader.readVarintNum(),i=0;i=Transaction.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new errors.Transaction.BlockHeightTooHigh;if(height<0)throw new errors.Transaction.NLockTimeOutOfRange;for(var i=0;i0?(this._changeIndex=this.outputs.length,this._addOutput(new Output({script:this._changeScript,satoshis:changeAmount}))):this._changeIndex=void 0}},Transaction.prototype.getFee=function(){return this.isCoinbase()?0:_.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee},Transaction.prototype._estimateFee=function(){var estimatedSize=this._estimateSize(),available=this._getUnspentValue();return Transaction._estimateFee(estimatedSize,available,this._feePerKb)},Transaction.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()},Transaction.prototype._clearSignatures=function(){_.each(this.inputs,function(input){input.clearSignatures()})},Transaction._estimateFee=function(size,amountAvailable,feePerKb){return amountAvailable>Math.ceil(size/1e3)*(feePerKb||Transaction.FEE_PER_KB)&&(size+=Transaction.CHANGE_OUTPUT_MAX_SIZE),Math.ceil(size/1e3)*(feePerKb||Transaction.FEE_PER_KB)},Transaction.prototype._estimateSize=function(){var result=Transaction.MAXIMUM_EXTRA_SIZE;return _.each(this.inputs,function(input){result+=input._estimateSize()}),_.each(this.outputs,function(output){result+=output.script.toBuffer().length+9}),result},Transaction.prototype._removeOutput=function(index){var output=this.outputs[index];this.outputs=_.without(this.outputs,output),this._outputAmount=void 0},Transaction.prototype.removeOutput=function(index){this._removeOutput(index),this._updateChangeOutput()},Transaction.prototype.sort=function(){return this.sortInputs(function(inputs){var copy=Array.prototype.concat.apply([],inputs);return copy.sort(function(first,second){return compare(first.prevTxId,second.prevTxId)||first.outputIndex-second.outputIndex}),copy}),this.sortOutputs(function(outputs){var copy=Array.prototype.concat.apply([],outputs);return copy.sort(function(first,second){return first.satoshis-second.satoshis||compare(first.script.toBuffer(),second.script.toBuffer())}),copy}),this},Transaction.prototype.shuffleOutputs=function(){return this.sortOutputs(_.shuffle)},Transaction.prototype.sortOutputs=function(sortingFunction){var outs=sortingFunction(this.outputs);return this._newOutputOrder(outs)},Transaction.prototype.sortInputs=function(sortingFunction){return this.inputs=sortingFunction(this.inputs),this._clearSignatures(),this},Transaction.prototype._newOutputOrder=function(newOutputs){if(this.outputs.length!==newOutputs.length||0!==_.difference(this.outputs,newOutputs).length)throw new errors.Transaction.InvalidSorting;if(!_.isUndefined(this._changeIndex)){var changeOutput=this.outputs[this._changeIndex];this._changeIndex=_.findIndex(newOutputs,changeOutput)}return this.outputs=newOutputs,this},Transaction.prototype.removeInput=function(txId,outputIndex){var index;if((index=!outputIndex&&_.isNumber(txId)?txId:_.findIndex(this.inputs,function(input){return input.prevTxId.toString("hex")===txId&&input.outputIndex===outputIndex}))<0||index>=this.inputs.length)throw new errors.Transaction.InvalidIndex(index,this.inputs.length);var input=this.inputs[index];this.inputs=_.without(this.inputs,input),this._inputAmount=void 0,this._updateChangeOutput()},Transaction.prototype.sign=function(privateKey,sigtype){$.checkState(this.hasAllUtxoInfo());var self=this;return _.isArray(privateKey)?(_.each(privateKey,function(privateKey){self.sign(privateKey,sigtype)}),this):(_.each(this.getSignatures(privateKey,sigtype),function(signature){self.applySignature(signature)}),this)},Transaction.prototype.getSignatures=function(privKey,sigtype){privKey=new PrivateKey(privKey),sigtype=sigtype||Signature.SIGHASH_ALL|Signature.SIGHASH_FORKID;var transaction=this,results=[],hashData=Hash.sha256ripemd160(privKey.publicKey.toBuffer());return _.each(this.inputs,function(input,index){_.each(input.getSignatures(transaction,privKey,index,sigtype,hashData),function(signature){results.push(signature)})}),results},Transaction.prototype.applySignature=function(signature){return this.inputs[signature.inputIndex].addSignature(this,signature),this},Transaction.prototype.isFullySigned=function(){return _.each(this.inputs,function(input){if(input.isFullySigned===Input.prototype.isFullySigned)throw new errors.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),_.every(_.map(this.inputs,function(input){return input.isFullySigned()}))},Transaction.prototype.isValidSignature=function(signature){if(this.inputs[signature.inputIndex].isValidSignature===Input.prototype.isValidSignature)throw new errors.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[signature.inputIndex].isValidSignature(this,signature)},Transaction.prototype.verifySignature=function(sig,pubkey,nin,subscript){return Sighash.verify(this,sig,pubkey,nin,subscript)},Transaction.prototype.verify=function(){if(0===this.inputs.length)return"transaction txins empty";if(0===this.outputs.length)return"transaction txouts empty";for(var valueoutbn=new BN(0),i=0;i1e6)return"transaction over the maximum block size";var txinmap={};for(i=0;i100)return"coinbase transaction script size invalid"}else for(i=0;i=Input.MAXINT-1&&(input.sequenceNumber=Input.DEFAULT_RBF_SEQNUMBER)}return this},module.exports=Transaction}).call(this,require("buffer").Buffer)},{"../address":209,"../crypto/bn":214,"../crypto/hash":216,"../crypto/signature":219,"../encoding/bufferreader":222,"../encoding/bufferwriter":223,"../errors":225,"../privatekey":231,"../script":233,"../util/buffer":250,"../util/js":251,"../util/preconditions":252,"./input":237,"./output":243,"./sighash":244,"./unspentoutput":247,buffer:70,"buffer-compare":68,lodash:144}],247:[function(require,module,exports){"use strict";var _=require("lodash"),$=require("../util/preconditions"),JSUtil=require("../util/js"),Script=require("../script"),Address=require("../address"),Unit=require("../unit");function UnspentOutput(data){if(!(this instanceof UnspentOutput))return new UnspentOutput(data);$.checkArgument(_.isObject(data),"Must provide an object from where to extract data");var address=data.address?new Address(data.address):void 0,txId=data.txid?data.txid:data.txId;if(!txId||!JSUtil.isHexaString(txId)||txId.length>64)throw new Error("Invalid TXID in object",data);var outputIndex=_.isUndefined(data.vout)?data.outputIndex:data.vout;if(!_.isNumber(outputIndex))throw new Error("Invalid outputIndex, received "+outputIndex);$.checkArgument(!_.isUndefined(data.scriptPubKey)||!_.isUndefined(data.script),"Must provide the scriptPubKey for that output!");var script=new Script(data.scriptPubKey||data.script);$.checkArgument(!_.isUndefined(data.amount)||!_.isUndefined(data.satoshis),"Must provide an amount for the output");var amount=_.isUndefined(data.amount)?data.satoshis:new Unit.fromBTC(data.amount).toSatoshis();$.checkArgument(_.isNumber(amount),"Amount must be a number"),JSUtil.defineImmutable(this,{address:address,txId:txId,outputIndex:outputIndex,script:script,satoshis:amount})}UnspentOutput.prototype.inspect=function(){return""},UnspentOutput.prototype.toString=function(){return this.txId+":"+this.outputIndex},UnspentOutput.fromObject=function(data){return new UnspentOutput(data)},UnspentOutput.prototype.toObject=UnspentOutput.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Unit.fromSatoshis(this.satoshis).toBTC()}},module.exports=UnspentOutput},{"../address":209,"../script":233,"../unit":248,"../util/js":251,"../util/preconditions":252,lodash:144}],248:[function(require,module,exports){"use strict";var _=require("lodash"),errors=require("./errors"),$=require("./util/preconditions"),UNITS={BTC:[1e8,8],mBTC:[1e5,5],uBTC:[100,2],bits:[100,2],satoshis:[1,0]};function Unit(amount,code){if(!(this instanceof Unit))return new Unit(amount,code);if(_.isNumber(code)){if(code<=0)throw new errors.Unit.InvalidRate(code);amount/=code,code=Unit.BTC}this._value=this._from(amount,code);var self=this;Object.keys(UNITS).forEach(function(key){Object.defineProperty(self,key,{get:function(){return self.to(key)},enumerable:!0})})}Object.keys(UNITS).forEach(function(key){Unit[key]=key}),Unit.fromObject=function(data){return $.checkArgument(_.isObject(data),"Argument is expected to be an object"),new Unit(data.amount,data.code)},Unit.fromBTC=function(amount){return new Unit(amount,Unit.BTC)},Unit.fromMillis=Unit.fromMilis=function(amount){return new Unit(amount,Unit.mBTC)},Unit.fromMicros=Unit.fromBits=function(amount){return new Unit(amount,Unit.bits)},Unit.fromSatoshis=function(amount){return new Unit(amount,Unit.satoshis)},Unit.fromFiat=function(amount,rate){return new Unit(amount,rate)},Unit.prototype._from=function(amount,code){if(!UNITS[code])throw new errors.Unit.UnknownCode(code);return parseInt((amount*UNITS[code][0]).toFixed())},Unit.prototype.to=function(code){if(_.isNumber(code)){if(code<=0)throw new errors.Unit.InvalidRate(code);return parseFloat((this.BTC*code).toFixed(2))}if(!UNITS[code])throw new errors.Unit.UnknownCode(code);var value=this._value/UNITS[code][0];return parseFloat(value.toFixed(UNITS[code][1]))},Unit.prototype.toBTC=function(){return this.to(Unit.BTC)},Unit.prototype.toMillis=Unit.prototype.toMilis=function(){return this.to(Unit.mBTC)},Unit.prototype.toMicros=Unit.prototype.toBits=function(){return this.to(Unit.bits)},Unit.prototype.toSatoshis=function(){return this.to(Unit.satoshis)},Unit.prototype.atRate=function(rate){return this.to(rate)},Unit.prototype.toString=function(){return this.satoshis+" satoshis"},Unit.prototype.toObject=Unit.prototype.toJSON=function(){return{amount:this.BTC,code:Unit.BTC}},Unit.prototype.inspect=function(){return""},module.exports=Unit},{"./errors":225,"./util/preconditions":252,lodash:144}],249:[function(require,module,exports){"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_=require("lodash"),URL=require("url"),Address=require("./address"),Unit=require("./unit"),URI=function URI(data,knownParams){if(!(this instanceof URI))return new URI(data,knownParams);if(this.extras={},this.knownParams=knownParams||[],this.address=this.network=this.amount=this.message=null,"string"==typeof data){var params=URI.parse(data);params.amount&&(params.amount=this._parseAmount(params.amount)),this._fromObject(params)}else{if("object"!==(void 0===data?"undefined":_typeof(data)))throw new TypeError("Unrecognized data format.");this._fromObject(data)}};URI.fromString=function(str){if("string"!=typeof str)throw new TypeError("Expected a string");return new URI(str)},URI.fromObject=function(json){return new URI(json)},URI.isValid=function(arg,knownParams){try{new URI(arg,knownParams)}catch(err){return!1}return!0},URI.parse=function(uri){var info=URL.parse(uri,!0);if("bitcoincash:"!==info.protocol)throw new TypeError("Invalid bitcoin cash URI");var group=/[^:]*:\/?\/?([^?]*)/.exec(uri);return info.query.address=group&&group[1]||void 0,info.query},URI.Members=["address","amount","message","label","r"],URI.prototype._fromObject=function(obj){if(!Address.isValid(obj.address))throw new TypeError("Invalid bitcoin address");this.address=new Address(obj.address),this.network=this.address.network,this.amount=obj.amount;for(var key in obj)if("address"!==key&&"amount"!==key){if(/^req-/.exec(key)&&-1===this.knownParams.indexOf(key))throw Error("Unknown required argument "+key);(URI.Members.indexOf(key)>-1?this:this.extras)[key]=obj[key]}},URI.prototype._parseAmount=function(amount){if(amount=Number(amount),isNaN(amount))throw new TypeError("Invalid amount");return Unit.fromBTC(amount).toSatoshis()},URI.prototype.toObject=URI.prototype.toJSON=function(){for(var json={},i=0;i"},module.exports=URI},{"./address":209,"./unit":248,lodash:144,url:202}],250:[function(require,module,exports){(function(Buffer){"use strict";var buffer=require("buffer"),assert=require("assert"),js=require("./js"),$=require("./preconditions");function equals(a,b){if(a.length!==b.length)return!1;for(var length=a.length,i=0;i>24&255),bytes.push(integer>>16&255),bytes.push(integer>>8&255),bytes.push(255&integer),new Buffer(bytes)},integerFromBuffer:function(buffer){return $.checkArgumentType(buffer,"Buffer","buffer"),buffer[0]<<24|buffer[1]<<16|buffer[2]<<8|buffer[3]},integerFromSingleByteBuffer:function(buffer){return $.checkArgumentType(buffer,"Buffer","buffer"),buffer[0]},bufferToHex:function(buffer){return $.checkArgumentType(buffer,"Buffer","buffer"),buffer.toString("hex")},reverse:function(param){for(var ret=new buffer.Buffer(param.length),i=0;i=0}}},{lodash:144}],252:[function(require,module,exports){"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},errors=require("../errors"),_=require("lodash");module.exports={checkState:function(condition,message){if(!condition)throw new errors.InvalidState(message)},checkArgument:function(condition,argumentName,message,docsPath){if(!condition)throw new errors.InvalidArgument(argumentName,message,docsPath)},checkArgumentType:function(argument,type,argumentName){if(argumentName=argumentName||"(unknown name)",_.isString(type)){if("Buffer"===type){if(!require("buffer").Buffer.isBuffer(argument))throw new errors.InvalidArgumentType(argument,type,argumentName)}else if((void 0===argument?"undefined":_typeof(argument))!==type)throw new errors.InvalidArgumentType(argument,type,argumentName)}else if(!(argument instanceof type))throw new errors.InvalidArgumentType(argument,type.name,argumentName)}}},{"../errors":225,buffer:70,lodash:144}]},{},[1])(1)}); \ No newline at end of file diff --git a/dist/bitcoincashjs.0.1.1.min.js b/dist/bitcoincashjs.0.1.1.min.js new file mode 100644 index 0000000..b646fa2 --- /dev/null +++ b/dist/bitcoincashjs.0.1.1.min.js @@ -0,0 +1 @@ +(function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,t.bitcoinCash=e()}})(function(){var t=Math.LN2,r=Math.log,o=Math.pow,s=Math.abs,f=Math.floor,e=Math.round,n=Math.clz32,p=Math.max,u=Math.min,h=Math.ceil,d=String.fromCharCode,i,a,c;return function d(c,e,t){function r(i,o){if(!e[i]){if(!c[i]){var s="function"==typeof require&&require;if(!o&&s)return s(i,!0);if(n)return n(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var f=e[i]={exports:{}};c[i][0].call(f.exports,function(t){var e=c[i][1][t];return r(e?e:t)},f,f.exports,d,c,e,t)}return e[i].exports}for(var n="function"==typeof require&&require,i=0;i=e))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=a.byteLength(e);else if(a.isBuffer(e))this.value=e,this.length=e.length;else return t.error("Unsupported type: "+typeof e)}var o=e("inherits"),d=e("../base").Reporter,a=e("buffer").Buffer;o(n,d),r.DecoderBuffer=n,n.prototype.save=function(){return{offset:this.offset,reporter:d.prototype.save.call(this)}},n.prototype.restore=function(e){var t=new n(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,d.prototype.restore.call(this,e.reporter),t},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},n.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},n.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=i,i.prototype.join=function(e,t){return(e||(e=new a(this.length)),t||(t=0),0===this.length)?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):a.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":5,buffer:71,inherits:146}],5:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":4,"./node":6,"./reporter":7}],6:[function(e,t){function r(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r["default"]=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,d=e("minimalistic-assert"),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],s=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);t.exports=r;var f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];r.prototype.clone=function(){var e=this._baseState,t={};f.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},r.prototype._wrap=function(){var e=this._baseState;s.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},r.prototype._init=function(e){var t=this._baseState;d(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),d.equal(t.children.length,1,"Root node can have only one child")},r.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(d(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(d(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){r.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),a.forEach(function(e){r.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return d(null===t.tag),t.tag=e,this._useArgs(r),this}}),r.prototype.use=function(e){d(e);var t=this._baseState;return d(null===t.use),t.use=e,this},r.prototype.optional=function(){var e=this._baseState;return e.optional=!0,this},r.prototype.def=function(e){var t=this._baseState;return d(null===t["default"]),t["default"]=e,t.optional=!0,this},r.prototype.explicit=function(e){var t=this._baseState;return d(null===t.explicit&&null===t.implicit),t.explicit=e,this},r.prototype.implicit=function(e){var t=this._baseState;return d(null===t.explicit&&null===t.implicit),t.implicit=e,this},r.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},r.prototype.key=function(e){var t=this._baseState;return d(null===t.key),t.key=e,this},r.prototype.any=function(){var e=this._baseState;return e.any=!0,this},r.prototype.choice=function(e){var t=this._baseState;return d(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},r.prototype.contains=function(e){var t=this._baseState;return d(null===t.use),t.contains=e,this},r.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n=r["default"],i=!0,d=null;if(null!==r.key&&(d=e.enterKey(r.key)),r.optional){var a=null;if(null===r.explicit?null===r.implicit?null!==r.tag&&(a=r.tag):a=r.implicit:a=r.explicit,null===a&&!r.any){var s=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),i=!0}catch(t){i=!1}e.restore(s)}else if(i=this._peekTag(e,a,r.any),e.isError(i))return i}var f;if(r.obj&&i&&(f=e.enterObject()),i){if(null!==r.explicit){var c=this._decodeTag(e,r.explicit);if(e.isError(c))return c;e=c}var p=e.offset;if(null===r.use&&null===r.choice){if(r.any)var s=e.save();var u=this._decodeTag(e,null===r.implicit?r.tag:r.implicit,r.any);if(e.isError(u))return u;r.any?n=e.raw(s):e=u}if(t&&t.track&&null!==r.tag&&t.track(e.path(),p,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),n=r.any?n:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(n))return n;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var l=new o(n);n=this._getUse(r.contains,e._reporterState.obj)._decode(l,t)}}return r.obj&&i&&(n=e.leaveObject(f)),null!==r.key&&(null!==n||!0===i)?e.leaveKey(d,r.key,n):null!==d&&e.exitKey(d),n},r.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;if("seq"===e||"set"===e)return null;return"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null===n.use?t.error("unknown tag: "+e):this._getUse(n.use,t._reporterState.obj)._decode(t,r)},r.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),d(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},r.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var d=e.save(),a=r.choice[o];try{var s=a._decode(e,t);if(e.isError(s))return!1;n={type:o,value:s},i=!0}catch(t){return e.restore(d),!1}return!0},this),i?n:e.error("Choice not matched")},r.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},r.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n["default"]||n["default"]!==e){var i=this._encodeValue(e,t,r);return void 0===i||this._skipDefault(i,t,r)?void 0:i}},r.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e)if(null!==i["default"])e=i["default"];else return;var d=null,a=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)d=this._getUse(i.contains,r)._encode(e,t),a=!0;else if(i.children)d=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),d=this._createEncoderBuffer(d);else if("seqof"===i.tag||"setof"===i.tag){if(!(i.args&&1===i.args.length))return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var s=this.clone();s._baseState.implicit=null,d=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},s))}else null===i.use?(d=this._encodePrimitive(i.tag,e),a=!0):o=this._getUse(i.use,r)._encode(e,t);var o;if(!i.any&&null===i.choice){var f=null===i.implicit?i.tag:i.implicit,c=null===i.implicit?"universal":"context";null===f?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(f,a,c,d))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},r.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||d(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},r.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},r.prototype._isNumstr=function(e){return /^[0-9 ]*$/.test(e)},r.prototype._isPrintstr=function(e){return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":5,"minimalistic-assert":154}],7:[function(e,t,r){function n(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function i(e,t){this.path=e,this.rethrow(t)}var o=e("inherits");r.Reporter=n,n.prototype.isError=function(e){return e instanceof i},n.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},n.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},n.prototype.enterKey=function(e){return this._reporterState.path.push(e)},n.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},n.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},n.prototype.path=function(){return this._reporterState.path.join("/")},n.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},n.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},n.prototype.error=function(e){var t=this._reporterState,r=e instanceof i,n;if(n=r?e:new i(t.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!t.options.partial)throw n;return r||t.errors.push(n),n},n.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e};o(i,Error),i.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,i),!this.stack)try{throw new Error(this.message)}catch(t){this.stack=t.stack}return this}},{inherits:146}],8:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":9}],9:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":8}],10:[function(e,t){function r(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new n,this.tree._init(e.body)}function n(e){f.Node.call(this,"der",e)}function i(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=p.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;var d=p.tag[r];return{cls:n,primitive:i,tag:r,tagStr:d}}function o(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var o=127&n;if(4n?2e3+n:1900+n}else return e.error("Decoding "+t+" time is not supported yet");return Date.UTC(n,i-1,o,d,a,s,0)},n.prototype._decodeNull=function(){return null},n.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},n.prototype._decodeInt=function(e,t){var r=e.raw(),n=new c(r);return t&&(n=t[n.toString(10)]||n),n},n.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree}},{"../../asn1":2,inherits:146}],11:[function(e,t,r){var n=r;n.der=e("./der"),n.pem=e("./pem")},{"./der":10,"./pem":12}],12:[function(e,t){function r(e){d.call(this,e),this.enc="pem"}var n=e("inherits"),o=e("buffer").Buffer,d=e("./der");n(r,d),t.exports=r,r.prototype.decode=function(e,t){for(var r=e.toString().split(/[\r\n]+/g),n=t.label.toUpperCase(),a=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,f=-1,c=0,i;ce?"0"+e:e}function o(e,t,r,n){var i;if("seqof"===e?e="seq":"setof"===e&&(e="set"),c.tagByName.hasOwnProperty(e))i=c.tagByName[e];else if("number"==typeof e&&(0|e)===e)i=e;else return n.error("Unknown tag: "+e);return 31<=i?n.error("Multi-octet tag encoding unsupported"):(t||(i|=32),i|=c.tagClassByName[r||"universal"]<<6,i)}var d=e("inherits"),a=e("buffer").Buffer,s=e("../../asn1"),f=s.base,c=s.constants.der;t.exports=r,r.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},d(n,f.Node),n.prototype._encodeComposite=function(e,t,r,n){var d=o(e,t,r,this.reporter);if(128>n.length){var s=new a(2);return s[0]=d,s[1]=n.length,this._createEncoderBuffer([s,n])}for(var f=1,c=n.length;256<=c;c>>=8)f++;var s=new a(2+f);s[0]=d,s[1]=128|f;for(var c=1+f,i=n.length;0>=8)s[c]=255&i;return this._createEncoderBuffer([s,n])},n.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new a(2*e.length),n=0;n>=7)i++;for(var d=new a(i),s=d.length-1,n=e.length-1,o;0<=n;n--)for(o=e[n],d[s--]=127&o;0<(o>>=7);)d[s--]=128|127&o;return this._createEncoderBuffer(d)},n.prototype._encodeTime=function(e,t){var r=new Date(e),n;return"gentime"===t?n=[i(r.getFullYear()),i(r.getUTCMonth()+1),i(r.getUTCDate()),i(r.getUTCHours()),i(r.getUTCMinutes()),i(r.getUTCSeconds()),"Z"].join(""):"utctime"===t?n=[i(r.getFullYear()%100),i(r.getUTCMonth()+1),i(r.getUTCDate()),i(r.getUTCHours()),i(r.getUTCMinutes()),i(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(n,"octstr")},n.prototype._encodeNull=function(){return this._createEncoderBuffer("")},n.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!a.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new a(r)}if(a.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new a(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(128>e)return this._createEncoderBuffer(e);if(256>e)return this._createEncoderBuffer([0,e]);for(var n=1,d=e;256<=d;d>>=8)n++;for(var o=Array(n),d=o.length-1;0<=d;d--)o[d]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new a(o))},n.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},n.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},n.prototype._skipDefault=function(e,t,r){var n=this._baseState,o;if(null===n["default"])return!1;var i=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n["default"],t,r).join()),i.length!==n.defaultBuffer.length)return!1;for(o=0;o=i?i-49+10:17<=i&&22>=i?i-17+10:15&i;return o}function s(e,t,n,o){for(var d=0,r=u(e.length,n),a=t,i;a>>i}return t}function l(e,t,n){n.negative=t.negative^e.negative;var o=0|e.length+t.length;n.length=o,o=0|o-1;var d=0|e.words[0],a=0|t.words[0],s=d*a,r=67108863&s,f=0|s/67108864;n.words[0]=r;for(var c=1;c>>26,h=67108863&f,b=u(c,t.length-1),g=p(0,c-e.length+1),y;g<=b;g++)y=0|c-g,d=0|e.words[y],a=0|t.words[g],s=d*a+h,l+=0|s/67108864,h=67108863&s;n.words[c]=0|h,f=0|l}return 0==f?n.length--:n.words[c]=0|f,n.strip()}function b(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var o=0,d=0,s=0,f;s>>26),d+=f>>>26,f&=67108863}n.words[s]=c,o=f,f=d}return 0==o?n.length--:n.words[s]=o,n.strip()}function g(e,t,r){var n=new y;return n.mulp(e,t,r)}function y(e,t){this.x=e,this.y=t}function m(e,t){this.name=e,this.p=new f(t,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function S(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function v(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function I(e){if("string"==typeof e){var t=f._prime(e);this.m=t.p,this.prime=t}else o(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function x(e){I.call(this,e),this.shift=this.m.bitLength(),0!=this.shift%26&&(this.shift+=26-this.shift%26),this.r=new f(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}var A=Math.imul;"object"==typeof r?r.exports=f:i.BN=f,f.BN=f,f.wordSize=26;var w;try{w=t("buffer").Buffer}catch(t){}f.isBN=function(e){return!!(e instanceof f)||null!==e&&"object"==typeof e&&e.constructor.wordSize===f.wordSize&&Array.isArray(e.words)},f.max=function(e,t){return 0e.cmp(t)?e:t},f.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),o(t===(0|t)&&2<=t&&36>=t),e=e.toString().replace(/\s+/g,"");var n=0;"-"===e[0]&&n++,16===t?this._parseHex(e,n):this._parseBase(e,t,n),"-"===e[0]&&(this.negative=1),this.strip();"le"!==r||this._initArray(this.toArray(),t,r)},f.prototype._initNumber=function(e,t,r){0>e&&(this.negative=1,e=-e),67108864>e?(this.words=[67108863&e],this.length=1):4503599627370496>e?(this.words=[67108863&e,67108863&e/67108864],this.length=2):(o(9007199254740992>e),this.words=[67108863&e,67108863&e/67108864,1],this.length=3);"le"!==r||this._initArray(this.toArray(),t,r)},f.prototype._initArray=function(e,t,r){if(o("number"==typeof e.length),0>=e.length)return this.words=[0],this.length=1,this;this.length=h(e.length/3),this.words=Array(this.length);for(var n=0;n>>26-i,i+=24,26<=i&&(i-=26,d++);else if("le"===r)for(n=0,d=0;n>>26-i,i+=24,26<=i&&(i-=26,d++);return this.strip()},f.prototype._parseHex=function(e,t){this.length=h((e.length-t)/6),this.words=Array(this.length);for(var r=0;r=t;r-=6)o=a(e,r,r+6),this.words[i]|=67108863&o<>>26-n,n+=24,26<=n&&(n-=26,i++);r+6!==t&&(o=a(e,t,r+6),this.words[i]|=67108863&o<>>26-n),this.strip()},f.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,o=1;67108863>=o;o*=t)n++;n--,o=0|o/t;for(var d=e.length-r,a=d%n,f=u(d,d-a)+r,c=0,p=r;pthis.words[0]+c?this.words[0]+=c:this._iaddn(c);if(0!=a){var i=1;for(c=s(e,p,e.length,t),p=0;pthis.words[0]+c?this.words[0]+=c:this._iaddn(c)}},f.prototype.copy=function(e){e.words=Array(this.length);for(var t=0;t"};var E=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],P=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],B=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,10000000,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];f.prototype.toString=function(e,t){e=e||10,t=0|t||1;var n;if(16===e||"hex"===e){n="";for(var d=0,a=0,s=0;s>>24-d,n=0!=a||s!==this.length-1?E[6-f.length]+f+n:f+n,d+=2,26<=d&&(d-=26,s--)}for(0!=a&&(n=a.toString(16)+n);0!=n.length%t;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&2<=e&&36>=e){var p=P[e],u=B[e];n="";var l=this.clone();for(l.negative=0;!l.isZero();){var c=l.modn(u).toString(e);l=l.idivn(u),n=l.isZero()?c+n:E[p-c.length]+c+n}for(this.isZero()&&(n="0"+n);0!=n.length%t;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}o(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:2>>=13),64<=n&&(t+=7,n>>>=7),8<=n&&(t+=4,n>>>=4),2<=n&&(t+=2,n>>>=2),t+n},f.prototype._zeroBits=function(e){if(0===e)return 26;var n=e,t=0;return 0==(8191&n)&&(t+=13,n>>>=13),0==(127&n)&&(t+=7,n>>>=7),0==(15&n)&&(t+=4,n>>>=4),0==(3&n)&&(t+=2,n>>>=2),0==(1&n)&&t++,t},f.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0,r;te.length?this.clone().ior(e):e.clone().ior(this)},f.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},f.prototype.iuand=function(e){var t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},f.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},f.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},f.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},f.prototype.inotn=function(e){o("number"==typeof e&&0<=e);var t=0|h(e/26),r=e%26;this._expand(t),0>26-r),this.strip()},f.prototype.notn=function(e){return this.clone().inotn(e)},f.prototype.setn=function(e,t){o("number"==typeof e&&0<=e);var r=0|e/26,n=e%26;return this._expand(r+1),t?this.words[r]|=1<e.length?(r=this,n=e):(r=e,n=this);for(var o=0,d=0;d>>26;for(;0!=o&&d>>26;if(this.length=r.length,0!=o)this.words[this.length]=o,this.length++;else if(r!==this)for(;de.length?this.clone().iadd(e):e.clone().iadd(this)},f.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r=this.cmp(e);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;var n,o;0>26,this.words[a]=67108863&t;for(;0!=d&&a>26,this.words[a]=67108863&t;if(0==d&&a>>13,c=0|n[1],p=8191&c,u=c>>>13,l=0|n[2],h=8191&l,b=l>>>13,g=0|n[3],y=8191&g,m=g>>>13,_=0|n[4],S=8191&_,v=_>>>13,k=0|n[5],I=8191&k,x=k>>>13,w=0|n[6],E=8191&w,P=w>>>13,B=0|n[7],O=8191&B,R=B>>>13,T=0|n[8],N=8191&T,C=T>>>13,j=0|n[9],M=8191&j,U=j>>>13,L=0|i[0],D=8191&L,z=L>>>13,H=0|i[1],K=8191&H,F=H>>>13,q=0|i[2],V=8191&q,G=q>>>13,W=0|i[3],Y=8191&W,X=W>>>13,Z=0|i[4],J=8191&Z,Q=Z>>>13,$=0|i[5],ee=8191&$,te=$>>>13,re=0|i[6],ne=8191&re,ie=re>>>13,oe=0|i[7],de=8191&oe,ae=oe>>>13,se=0|i[8],fe=8191&se,ce=se>>>13,pe=0|i[9],ue=8191&pe,le=pe>>>13,he,be,ge;r.negative=e.negative^t.negative,r.length=19,he=A(s,D),be=A(s,z),be=0|be+A(f,D),ge=A(f,z);var ye=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(ye>>>26),ye&=67108863,he=A(p,D),be=A(p,z),be=0|be+A(u,D),ge=A(u,z),he=0|he+A(s,K),be=0|be+A(s,F),be=0|be+A(f,K),ge=0|ge+A(f,F);var me=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(me>>>26),me&=67108863,he=A(h,D),be=A(h,z),be=0|be+A(b,D),ge=A(b,z),he=0|he+A(p,K),be=0|be+A(p,F),be=0|be+A(u,K),ge=0|ge+A(u,F),he=0|he+A(s,V),be=0|be+A(s,G),be=0|be+A(f,V),ge=0|ge+A(f,G);var _e=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(_e>>>26),_e&=67108863,he=A(y,D),be=A(y,z),be=0|be+A(m,D),ge=A(m,z),he=0|he+A(h,K),be=0|be+A(h,F),be=0|be+A(b,K),ge=0|ge+A(b,F),he=0|he+A(p,V),be=0|be+A(p,G),be=0|be+A(u,V),ge=0|ge+A(u,G),he=0|he+A(s,Y),be=0|be+A(s,X),be=0|be+A(f,Y),ge=0|ge+A(f,X);var Se=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Se>>>26),Se&=67108863,he=A(S,D),be=A(S,z),be=0|be+A(v,D),ge=A(v,z),he=0|he+A(y,K),be=0|be+A(y,F),be=0|be+A(m,K),ge=0|ge+A(m,F),he=0|he+A(h,V),be=0|be+A(h,G),be=0|be+A(b,V),ge=0|ge+A(b,G),he=0|he+A(p,Y),be=0|be+A(p,X),be=0|be+A(u,Y),ge=0|ge+A(u,X),he=0|he+A(s,J),be=0|be+A(s,Q),be=0|be+A(f,J),ge=0|ge+A(f,Q);var ve=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(ve>>>26),ve&=67108863,he=A(I,D),be=A(I,z),be=0|be+A(x,D),ge=A(x,z),he=0|he+A(S,K),be=0|be+A(S,F),be=0|be+A(v,K),ge=0|ge+A(v,F),he=0|he+A(y,V),be=0|be+A(y,G),be=0|be+A(m,V),ge=0|ge+A(m,G),he=0|he+A(h,Y),be=0|be+A(h,X),be=0|be+A(b,Y),ge=0|ge+A(b,X),he=0|he+A(p,J),be=0|be+A(p,Q),be=0|be+A(u,J),ge=0|ge+A(u,Q),he=0|he+A(s,ee),be=0|be+A(s,te),be=0|be+A(f,ee),ge=0|ge+A(f,te);var ke=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(ke>>>26),ke&=67108863,he=A(E,D),be=A(E,z),be=0|be+A(P,D),ge=A(P,z),he=0|he+A(I,K),be=0|be+A(I,F),be=0|be+A(x,K),ge=0|ge+A(x,F),he=0|he+A(S,V),be=0|be+A(S,G),be=0|be+A(v,V),ge=0|ge+A(v,G),he=0|he+A(y,Y),be=0|be+A(y,X),be=0|be+A(m,Y),ge=0|ge+A(m,X),he=0|he+A(h,J),be=0|be+A(h,Q),be=0|be+A(b,J),ge=0|ge+A(b,Q),he=0|he+A(p,ee),be=0|be+A(p,te),be=0|be+A(u,ee),ge=0|ge+A(u,te),he=0|he+A(s,ne),be=0|be+A(s,ie),be=0|be+A(f,ne),ge=0|ge+A(f,ie);var Ie=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Ie>>>26),Ie&=67108863,he=A(O,D),be=A(O,z),be=0|be+A(R,D),ge=A(R,z),he=0|he+A(E,K),be=0|be+A(E,F),be=0|be+A(P,K),ge=0|ge+A(P,F),he=0|he+A(I,V),be=0|be+A(I,G),be=0|be+A(x,V),ge=0|ge+A(x,G),he=0|he+A(S,Y),be=0|be+A(S,X),be=0|be+A(v,Y),ge=0|ge+A(v,X),he=0|he+A(y,J),be=0|be+A(y,Q),be=0|be+A(m,J),ge=0|ge+A(m,Q),he=0|he+A(h,ee),be=0|be+A(h,te),be=0|be+A(b,ee),ge=0|ge+A(b,te),he=0|he+A(p,ne),be=0|be+A(p,ie),be=0|be+A(u,ne),ge=0|ge+A(u,ie),he=0|he+A(s,de),be=0|be+A(s,ae),be=0|be+A(f,de),ge=0|ge+A(f,ae);var xe=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(xe>>>26),xe&=67108863,he=A(N,D),be=A(N,z),be=0|be+A(C,D),ge=A(C,z),he=0|he+A(O,K),be=0|be+A(O,F),be=0|be+A(R,K),ge=0|ge+A(R,F),he=0|he+A(E,V),be=0|be+A(E,G),be=0|be+A(P,V),ge=0|ge+A(P,G),he=0|he+A(I,Y),be=0|be+A(I,X),be=0|be+A(x,Y),ge=0|ge+A(x,X),he=0|he+A(S,J),be=0|be+A(S,Q),be=0|be+A(v,J),ge=0|ge+A(v,Q),he=0|he+A(y,ee),be=0|be+A(y,te),be=0|be+A(m,ee),ge=0|ge+A(m,te),he=0|he+A(h,ne),be=0|be+A(h,ie),be=0|be+A(b,ne),ge=0|ge+A(b,ie),he=0|he+A(p,de),be=0|be+A(p,ae),be=0|be+A(u,de),ge=0|ge+A(u,ae),he=0|he+A(s,fe),be=0|be+A(s,ce),be=0|be+A(f,fe),ge=0|ge+A(f,ce);var Ae=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Ae>>>26),Ae&=67108863,he=A(M,D),be=A(M,z),be=0|be+A(U,D),ge=A(U,z),he=0|he+A(N,K),be=0|be+A(N,F),be=0|be+A(C,K),ge=0|ge+A(C,F),he=0|he+A(O,V),be=0|be+A(O,G),be=0|be+A(R,V),ge=0|ge+A(R,G),he=0|he+A(E,Y),be=0|be+A(E,X),be=0|be+A(P,Y),ge=0|ge+A(P,X),he=0|he+A(I,J),be=0|be+A(I,Q),be=0|be+A(x,J),ge=0|ge+A(x,Q),he=0|he+A(S,ee),be=0|be+A(S,te),be=0|be+A(v,ee),ge=0|ge+A(v,te),he=0|he+A(y,ne),be=0|be+A(y,ie),be=0|be+A(m,ne),ge=0|ge+A(m,ie),he=0|he+A(h,de),be=0|be+A(h,ae),be=0|be+A(b,de),ge=0|ge+A(b,ae),he=0|he+A(p,fe),be=0|be+A(p,ce),be=0|be+A(u,fe),ge=0|ge+A(u,ce),he=0|he+A(s,ue),be=0|be+A(s,le),be=0|be+A(f,ue),ge=0|ge+A(f,le);var we=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(we>>>26),we&=67108863,he=A(M,K),be=A(M,F),be=0|be+A(U,K),ge=A(U,F),he=0|he+A(N,V),be=0|be+A(N,G),be=0|be+A(C,V),ge=0|ge+A(C,G),he=0|he+A(O,Y),be=0|be+A(O,X),be=0|be+A(R,Y),ge=0|ge+A(R,X),he=0|he+A(E,J),be=0|be+A(E,Q),be=0|be+A(P,J),ge=0|ge+A(P,Q),he=0|he+A(I,ee),be=0|be+A(I,te),be=0|be+A(x,ee),ge=0|ge+A(x,te),he=0|he+A(S,ne),be=0|be+A(S,ie),be=0|be+A(v,ne),ge=0|ge+A(v,ie),he=0|he+A(y,de),be=0|be+A(y,ae),be=0|be+A(m,de),ge=0|ge+A(m,ae),he=0|he+A(h,fe),be=0|be+A(h,ce),be=0|be+A(b,fe),ge=0|ge+A(b,ce),he=0|he+A(p,ue),be=0|be+A(p,le),be=0|be+A(u,ue),ge=0|ge+A(u,le);var Ee=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Ee>>>26),Ee&=67108863,he=A(M,V),be=A(M,G),be=0|be+A(U,V),ge=A(U,G),he=0|he+A(N,Y),be=0|be+A(N,X),be=0|be+A(C,Y),ge=0|ge+A(C,X),he=0|he+A(O,J),be=0|be+A(O,Q),be=0|be+A(R,J),ge=0|ge+A(R,Q),he=0|he+A(E,ee),be=0|be+A(E,te),be=0|be+A(P,ee),ge=0|ge+A(P,te),he=0|he+A(I,ne),be=0|be+A(I,ie),be=0|be+A(x,ne),ge=0|ge+A(x,ie),he=0|he+A(S,de),be=0|be+A(S,ae),be=0|be+A(v,de),ge=0|ge+A(v,ae),he=0|he+A(y,fe),be=0|be+A(y,ce),be=0|be+A(m,fe),ge=0|ge+A(m,ce),he=0|he+A(h,ue),be=0|be+A(h,le),be=0|be+A(b,ue),ge=0|ge+A(b,le);var Pe=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Pe>>>26),Pe&=67108863,he=A(M,Y),be=A(M,X),be=0|be+A(U,Y),ge=A(U,X),he=0|he+A(N,J),be=0|be+A(N,Q),be=0|be+A(C,J),ge=0|ge+A(C,Q),he=0|he+A(O,ee),be=0|be+A(O,te),be=0|be+A(R,ee),ge=0|ge+A(R,te),he=0|he+A(E,ne),be=0|be+A(E,ie),be=0|be+A(P,ne),ge=0|ge+A(P,ie),he=0|he+A(I,de),be=0|be+A(I,ae),be=0|be+A(x,de),ge=0|ge+A(x,ae),he=0|he+A(S,fe),be=0|be+A(S,ce),be=0|be+A(v,fe),ge=0|ge+A(v,ce),he=0|he+A(y,ue),be=0|be+A(y,le),be=0|be+A(m,ue),ge=0|ge+A(m,le);var Be=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Be>>>26),Be&=67108863,he=A(M,J),be=A(M,Q),be=0|be+A(U,J),ge=A(U,Q),he=0|he+A(N,ee),be=0|be+A(N,te),be=0|be+A(C,ee),ge=0|ge+A(C,te),he=0|he+A(O,ne),be=0|be+A(O,ie),be=0|be+A(R,ne),ge=0|ge+A(R,ie),he=0|he+A(E,de),be=0|be+A(E,ae),be=0|be+A(P,de),ge=0|ge+A(P,ae),he=0|he+A(I,fe),be=0|be+A(I,ce),be=0|be+A(x,fe),ge=0|ge+A(x,ce),he=0|he+A(S,ue),be=0|be+A(S,le),be=0|be+A(v,ue),ge=0|ge+A(v,le);var Oe=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Oe>>>26),Oe&=67108863,he=A(M,ee),be=A(M,te),be=0|be+A(U,ee),ge=A(U,te),he=0|he+A(N,ne),be=0|be+A(N,ie),be=0|be+A(C,ne),ge=0|ge+A(C,ie),he=0|he+A(O,de),be=0|be+A(O,ae),be=0|be+A(R,de),ge=0|ge+A(R,ae),he=0|he+A(E,fe),be=0|be+A(E,ce),be=0|be+A(P,fe),ge=0|ge+A(P,ce),he=0|he+A(I,ue),be=0|be+A(I,le),be=0|be+A(x,ue),ge=0|ge+A(x,le);var Re=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Re>>>26),Re&=67108863,he=A(M,ne),be=A(M,ie),be=0|be+A(U,ne),ge=A(U,ie),he=0|he+A(N,de),be=0|be+A(N,ae),be=0|be+A(C,de),ge=0|ge+A(C,ae),he=0|he+A(O,fe),be=0|be+A(O,ce),be=0|be+A(R,fe),ge=0|ge+A(R,ce),he=0|he+A(E,ue),be=0|be+A(E,le),be=0|be+A(P,ue),ge=0|ge+A(P,le);var Te=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Te>>>26),Te&=67108863,he=A(M,de),be=A(M,ae),be=0|be+A(U,de),ge=A(U,ae),he=0|he+A(N,fe),be=0|be+A(N,ce),be=0|be+A(C,fe),ge=0|ge+A(C,ce),he=0|he+A(O,ue),be=0|be+A(O,le),be=0|be+A(R,ue),ge=0|ge+A(R,le);var Ne=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Ne>>>26),Ne&=67108863,he=A(M,fe),be=A(M,ce),be=0|be+A(U,fe),ge=A(U,ce),he=0|he+A(N,ue),be=0|be+A(N,le),be=0|be+A(C,ue),ge=0|ge+A(C,le);var Ce=0|(0|o+he)+((8191&be)<<13);o=0|(0|ge+(be>>>13))+(Ce>>>26),Ce&=67108863,he=A(M,ue),be=A(M,le),be=0|be+A(U,ue),ge=A(U,le);var je=0|(0|o+he)+((8191&be)<<13);return o=0|(0|ge+(be>>>13))+(je>>>26),je&=67108863,d[0]=ye,d[1]=me,d[2]=_e,d[3]=Se,d[4]=ve,d[5]=ke,d[6]=Ie,d[7]=xe,d[8]=Ae,d[9]=we,d[10]=Ee,d[11]=Pe,d[12]=Be,d[13]=Oe,d[14]=Re,d[15]=Te,d[16]=Ne,d[17]=Ce,d[18]=je,0!=o&&(d[19]=o,r.length++),r};A||(O=l),f.prototype.mulTo=function(e,t){var r=this.length+e.length,n;return n=10===this.length&&10===e.length?O(this,e,t):63>r?l(this,e,t):1024>r?b(this,e,t):g(this,e,t),n},y.prototype.makeRBT=function(e){for(var r=Array(e),t=f.prototype._countBits(e)-1,n=0;n>=1;return n},y.prototype.permute=function(e,t,r,n,o,d){for(var a=0;a>>=1)o++;return 1<=n))for(var o=0,i;oi?0:0|i/67108864;return t},y.prototype.convert13b=function(e,t,r,n){for(var d=0,a=0;a>>=13,r[2*a+1]=8191&d,d>>>=13;for(a=2*t;ae);for(var t=0,r=0;r>=26,t+=0|n/67108864,t+=i>>>26,this.words[r]=67108863&i}return 0!=t&&(this.words[r]=t,this.length++),this},f.prototype.muln=function(e){return this.clone().imuln(e)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(e){var t=c(e);if(0===t.length)return new f(1);for(var r=this,n=0;n>>26-t<<26-t,a=(0|this.words[n])-d<>>26-t}i&&(this.words[n]=i,this.length++)}if(0!=r){for(n=this.length-1;0<=n;n--)this.words[n+r]=this.words[n];for(n=0;nr)for(this.length-=r,f=0;f=d);f--){var c=0|this.words[f];this.words[f]=i<<26-a|c>>>a,i=c&(67108863^67108863>>>a<>>t<e),0>e?this.isubn(-e):0===this.negative?this._iaddn(e):1===this.length&&(0|this.words[0])e),0>e)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&0>this.words[0])this.words[0]=-this.words[0],this.negative=1;else for(var t=0;tthis.words[t];t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},f.prototype.addn=function(e){return this.clone().iaddn(e)},f.prototype.subn=function(e){return this.clone().isubn(e)},f.prototype.iabs=function(){return this.negative=0,this},f.prototype.abs=function(){return this.clone().iabs()},f.prototype._ishlnsubmul=function(e,t,r){var n=e.length+r,d;this._expand(n);var i=0,a;for(d=0;d>26)-(0|s/67108864),this.words[d+r]=67108863&a}for(;d>26,this.words[d+r]=67108863&a;if(0==i)return this.strip();for(o(-1==i),i=0,d=0;d>26,this.words[d]=67108863&a;return this.negative=1,this.strip()},f.prototype._wordDiv=function(e,t){var r=this.length-e.length,n=this.clone(),o=e,d=0|o.words[o.length-1],s=this._countBits(d);r=26-s,0!=r&&(o=o.ushln(r),n.iushln(r),d=0|o.words[o.length-1]);var c=n.length-o.length,p;if("mod"!==t){p=new f(null),p.length=c+1,p.words=Array(p.length);for(var l=0;lthis.length||0>this.cmp(e)?{div:new f(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new f(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new f(this.modn(e.words[0]))}:this._wordDiv(e,t):(d=this.neg().divmod(e.neg(),t),"div"!==t&&(i=d.mod.neg(),r&&0!==i.negative&&i.isub(e)),{div:d.div,mod:i})},f.prototype.div=function(e){return this.divmod(e,"div",!1).div},f.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},f.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},f.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0===t.div.negative?t.mod:t.mod.isub(e),n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return 0>o||1===i&&0===o?t.div:0===t.div.negative?t.div.iaddn(1):t.div.isubn(1)},f.prototype.modn=function(e){o(67108863>=e);for(var t=0,r=this.length-1;0<=r;r--)t=(67108864%e*t+(0|this.words[r]))%e;return t},f.prototype.idivn=function(e){o(67108863>=e);for(var t=0,r=this.length-1,n;0<=r;r--)n=(0|this.words[r])+67108864*t,this.words[r]=0|n/e,t=n%e;return this.strip()},f.prototype.divn=function(e){return this.clone().idivn(e)},f.prototype.egcd=function(e){o(0===e.negative),o(!e.isZero());var t=this,r=e.clone();t=0===t.negative?t.clone():t.umod(e);for(var n=new f(1),d=new f(0),a=new f(0),s=new f(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var p=r.clone(),u=t.clone();!t.isZero();){for(var l=0,i=1;0==(t.words[0]&i)&&26>l;++l,i<<=1);if(0h;++h,b<<=1);if(0s;++s,i<<=1);if(0c;++c,p<<=1);if(0u.cmpn(0)&&u.iadd(e),u},f.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var n=this.clone(),i=e.clone();n.negative=0,i.negative=0;for(var o=0;n.isEven()&&i.isEven();o++)n.iushrn(1),i.iushrn(1);do{for(;n.isEven();)n.iushrn(1);for(;i.isEven();)i.iushrn(1);var d=n.cmp(i);if(0>d){var r=n;n=i,i=r}else if(0===d||0===i.cmpn(1))break;n.isub(i)}while(!0);return i.iushln(o)},f.prototype.invm=function(e){return this.egcd(e).a.umod(e)},f.prototype.isEven=function(){return 0==(1&this.words[0])},f.prototype.isOdd=function(){return 1==(1&this.words[0])},f.prototype.andln=function(e){return this.words[0]&e},f.prototype.bincn=function(e){o("number"==typeof e);var t=e%26,r=(e-t)/26,n=1<>>26,i&=67108863,this.words[a]=i;return 0!=d&&(this.words[a]=d,this.length++),this},f.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},f.prototype.cmpn=function(e){var t=0>e;if(0!==this.negative&&!t)return-1;if(0===this.negative&&t)return 1;this.strip();var r;if(1=e,"Number is too big");var n=0|this.words[0];r=n===e?0:ne.length)return 1;if(this.lengthi&&(t=1);break}}return t},f.prototype.gtn=function(e){return 1===this.cmpn(e)},f.prototype.gt=function(e){return 1===this.cmp(e)},f.prototype.gten=function(e){return 0<=this.cmpn(e)},f.prototype.gte=function(e){return 0<=this.cmp(e)},f.prototype.ltn=function(e){return-1===this.cmpn(e)},f.prototype.lt=function(e){return-1===this.cmp(e)},f.prototype.lten=function(e){return 0>=this.cmpn(e)},f.prototype.lte=function(e){return 0>=this.cmp(e)},f.prototype.eqn=function(e){return 0===this.cmpn(e)},f.prototype.eq=function(e){return 0===this.cmp(e)},f.red=function(e){return new I(e)},f.prototype.toRed=function(e){return o(!this.red,"Already a number in reduction context"),o(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},f.prototype.fromRed=function(){return o(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(e){return this.red=e,this},f.prototype.forceRed=function(e){return o(!this.red,"Already a number in reduction context"),this._forceRed(e)},f.prototype.redAdd=function(e){return o(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},f.prototype.redIAdd=function(e){return o(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},f.prototype.redSub=function(e){return o(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},f.prototype.redISub=function(e){return o(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},f.prototype.redShl=function(e){return o(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},f.prototype.redMul=function(e){return o(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},f.prototype.redIMul=function(e){return o(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},f.prototype.redSqr=function(){return o(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return o(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return o(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return o(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return o(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(e){return o(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var R={k256:null,p224:null,p192:null,p25519:null};m.prototype._tmp=function(){var e=new f(null);return e.words=Array(h(this.n/13)),e},m.prototype.ireduce=function(e){var t=e,r;do this.split(t,this.tmp),t=this.imulK(t),t=t.iadd(this.tmp),r=t.bitLength();while(r>this.n);var n=r=e.length)return e.words[0]=0,void(e.length=1);var i=e.words[9];for(t.words[t.length++]=i&r,o=10;o>>22,i=d}i>>>=22,e.words[o-10]=i,e.length-=0===i&&10>>=26,e.words[r]=i,t=n}return 0!=t&&(e.words[e.length++]=t),e},f._prime=function(e){if(R[e])return R[e];var t;if("k256"===e)t=new _;else if("p224"===e)t=new S;else if("p192"===e)t=new v;else if("p25519"===e)t=new k;else throw new Error("Unknown prime "+e);return R[e]=t,t},I.prototype._verify1=function(e){o(0===e.negative,"red works only with positives"),o(e.red,"red works only with red numbers")},I.prototype._verify2=function(e,t){o(0==(e.negative|t.negative),"red works only with positives"),o(e.red&&e.red===t.red,"red works only with red numbers")},I.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},I.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},I.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return 0<=r.cmp(this.m)&&r.isub(this.m),r._forceRed(this)},I.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return 0<=r.cmp(this.m)&&r.isub(this.m),r},I.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return 0>r.cmpn(0)&&r.iadd(this.m),r._forceRed(this)},I.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return 0>r.cmpn(0)&&r.iadd(this.m),r},I.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},I.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},I.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},I.prototype.isqr=function(e){return this.imul(e,e.clone())},I.prototype.sqr=function(e){return this.mul(e,e)},I.prototype.sqrt=function(e){if(e.isZero())return e.clone();var n=this.m.andln(3);if(o(1==n%2),3===n){var d=this.m.add(new f(1)).iushrn(2);return this.pow(e,d)}for(var a=this.m.subn(1),p=0;!a.isZero()&&0===a.andln(1);)p++,a.iushrn(1);o(!a.isZero());var s=new f(1).toRed(this),u=s.redNeg(),l=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new f(2*h*h).toRed(this);0!==this.pow(h,l).cmp(u);)h.redIAdd(u);for(var g=this.pow(h,a),c=this.pow(e,a.addn(1).iushrn(1)),r=this.pow(e,a),t=p;0!==r.cmp(s);){for(var y=r,m=0;0!==y.cmp(s);m++)y=y.redSqr();o(m>p,i!==n[0]&&(i=this.sqr(i)),0==u&&0==d){a=0;continue}d<<=1,d|=u,a++,a!=r&&(0!==o||0!==p)||(i=this.mul(i,n[d]),a=0,d=0)}s=26}return i},I.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},I.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},f.mont=function(e){return new x(e)},d(x,I),x.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},x.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},x.prototype.imul=function(e,r){if(e.isZero()||r.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(r),t=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(t).iushrn(this.shift),o=i;return 0<=i.cmp(this.m)?o=i.isub(this.m):0>i.cmpn(0)&&(o=i.iadd(this.m)),o._forceRed(this)},x.prototype.mul=function(e,r){if(e.isZero()||r.isZero())return new f(0)._forceRed(this);var n=e.mul(r),t=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(t).iushrn(this.shift),o=i;return 0<=i.cmp(this.m)?o=i.isub(this.m):0>i.cmpn(0)&&(o=i.iadd(this.m)),o._forceRed(this)},x.prototype.invm=function(e){var t=this.imod(e._invmp(this.m).mul(this.r2));return t._forceRed(this)}})("undefined"==typeof r||r,this)},{buffer:22}],17:[function(e,t){(function(r){"use strict";function n(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=u(r,n);o>18]+a[63&e>>12]+a[63&e>>6]+a[63&e]}function d(e,t,r){for(var n=[],d=t,i;d>16,a[c++]=255&o>>8,a[c++]=255&o;return 2===d?(o=s[e.charCodeAt(r)]<<2|s[e.charCodeAt(r+1)]>>4,a[c++]=255&o):1===d&&(o=s[e.charCodeAt(r)]<<10|s[e.charCodeAt(r+1)]<<4|s[e.charCodeAt(r+2)]>>2,a[c++]=255&o>>8,a[c++]=255&o),a},r.fromByteArray=function(e){for(var t=e.length,r=t%3,n="",o=[],s=16383,f=0,i=t-r,c;fi?i:f+s));return 1==r?(c=e[t-1],n+=a[c>>2],n+=a[63&c<<4],n+="=="):2==r&&(c=(e[t-2]<<8)+e[t-1],n+=a[c>>10],n+=a[63&c>>4],n+=a[63&c<<2],n+="="),o.push(n),o.join("")};for(var a=[],s=[],f="undefined"==typeof Uint8Array?Array:Uint8Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,i=c.length;pe,this.isSmall=!0}function g(e){return-Je?[e]:1e14>e?[e%1e7,f(e/1e7)]:[e%1e7,f(e/1e7)%1e7,f(e/1e14)]}function y(e){m(e);var t=e.length;return 4>t&&0>j(e,Q)?0===t?0:1===t?e[0]:2===t?e[0]+e[1]*X:e[0]+(e[1]+e[2]*X)*X:e}function m(e){for(var t=e.length;0===e[--t];);e.length=t+1}function n(e){for(var t=Array(e),r=-1;++r=a?1:0,d[f]=s-r*a;for(;f=t.length?S(e,t):S(t,e)}function I(e,t){var n=e.length,o=Array(n),r=X,d,a;for(a=0;ai?(i+=a,r=1):r=0,d[s]=i;for(s=o;si)i+=a;else{d[s++]=i;break}d[s]=i}for(;si?i+p:i;return s=y(s),"number"==typeof s?(o&&(s=-s),new d(s)):new t(s,o)}function w(e,t){var o=e.length,d=t.length,a=n(o+d),r=X,s,c,p,i,u;for(p=0;p=r)return w(e,t);r=h(r/2);var n=e.slice(r),i=e.slice(0,r),o=t.slice(r),d=t.slice(0,r),a=B(i,d),s=B(n,o),f=B(k(i,n),k(d,o)),c=k(k(a,P(v(v(f,a),s),r)),P(s,2*r));return m(c),c}function O(e,t){return 0<-0.012*e-0.012*t+1.5e-5*e*t}function b(e,r,n){return e_?(p[g+S]=_+d,_=-1):(p[g+S]=_,_=0);for(;0!==_;){for(b-=1,m=0,S=0;Sm?(p[g+S]=m+d,m=0):(p[g+S]=m,m=1);_+=m}a[g]=b}return p=N(p,c)[0],[y(a),y(p)]}function T(e,t){for(var r=e.length,n=t.length,i=[],o=[],d=X,a,s,f,c,p;r;){if(o.unshift(e[--r]),m(o),0>j(o,t)){i.push(0);continue}s=o.length,f=o[s-1]*d+o[s-2],c=t[n-1]*d+t[n-2],s>n&&(f=(f+1)*d),a=h(f/c);do{if(p=E(t,a),0>=j(p,o))break;a--}while(a);i.push(a),o=v(o,p)}return i.reverse(),[y(i),y(o)]}function N(e,t){var r=e.length,o=n(r),d,i,a,s;for(a=0,d=r-1;0<=d;--d)s=a*X+e[d],i=_(s/t),a=s-i*t,o[d]=0|i;return[o,0|a]}function C(r,i){var o=Y(i),n=r.value,a=o.value,f,c;if(0===a)throw new Error("Cannot divide by zero");if(r.isSmall)return o.isSmall?[new d(_(n/a)),new d(n%a)]:[e[0],r];if(o.isSmall){if(1===a)return[r,e[0]];if(-1==a)return[r.negate(),e[0]];var p=s(a);if(p=n.length+a.length?R(n,a):T(n,a),c=f[0];var b=r.sign!==o.sign,g=f[1],m=r.sign;return"number"==typeof c?(b&&(c=-c),c=new d(c)):c=new t(c,b),"number"==typeof g?(m&&(g=-g),g=new d(g)):g=new t(g,m),[c,g]}function j(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var r=e.length-1;0<=r;r--)if(e[r]!==t[r])return e[r]>t[r]?1:-1;return 0}function M(e){var t=e.abs();return!t.isUnit()&&(t.equals(2)||t.equals(3)||t.equals(5)||(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5)?!1:!!t.lesser(25)||void 0))}function U(e){return("number"==typeof e||"string"==typeof e)&&+s(e)<=X||e instanceof t&&1>=e.value.length}function L(e,t,r){t=Y(t);for(var n=e.isNegative(),o=t.isNegative(),d=n?e.not():e,a=o?t.not():t,s=0,f=0,p=null,u=null,l=[];!d.isZero()||!a.isZero();)p=C(d,te),s=p[1].toJSNumber(),n&&(s=te-1-s),u=C(a,te),f=u[1].toJSNumber(),o&&(f=te-1-f),d=p[0],a=u[0],l.push(r(s,f));for(var h=0===r(n?1:0,o?1:0)?c(0):c(-1),b=l.length-1;0<=b;b-=1)h=h.multiply(te).add(c(l[b]));return h}function D(e){var t=e.value,r="number"==typeof t?t|re:t[0]+t[1]*X|ne;return r&-r}function z(e,t){return e=Y(e),t=Y(t),e.greater(t)?e:t}function H(e,t){return e=Y(e),t=Y(t),e.lesser(t)?e:t}function K(r,n){if(r=Y(r).abs(),n=Y(n).abs(),r.equals(n))return r;if(r.isZero())return n;if(n.isZero())return r;for(var i=e[1],o,d;r.isEven()&&n.isEven();)o=u(D(r),D(n)),r=r.divide(o),n=n.divide(o),i=i.multiply(o);for(;r.isEven();)r=r.divide(D(r));do{for(;n.isEven();)n=n.divide(D(n));r.greater(n)&&(d=n,n=r,r=d),n=n.subtract(r)}while(!n.isZero());return i.isUnit()?r:r.multiply(i)}function F(t,r,n){var o=e[0],d=e[1],a;for(a=t.length-1;0<=a;a--)o=o.add(t[a].times(d)),d=d.times(r);return n?o.negate():o}function q(e){var t=e.value;return"number"==typeof t&&(t=[t]),1===t.length&&35>=t[0]?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t[0]):"<"+t+">"}function V(e,t){if(t=c(t),t.isZero()){if(e.isZero())return"0";throw new Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1))return e.isZero()?"0":e.isNegative()?Array(1-e).join("10"):"1"+Array(+e).join("01");var r="";if(e.isNegative()&&t.isPositive()&&(r="-",e=e.abs()),t.equals(1))return e.isZero()?"0":r+Array(+e+1).join(1);for(var i=[],o=e,d;o.isNegative()||0<=o.compareAbs(t);){d=o.divmod(t),o=d.quotient;var a=d.remainder;a.isNegative()&&(a=t.minus(a).abs(),o=o.next()),i.push(q(a))}return i.push(q(o)),r+i.reverse().join("")}function G(e){if(g(+e)){var n=+e;if(n===_(n))return new d(n);throw"Invalid integer: "+e}var i="-"===e[0];i&&(e=e.slice(1));var o=e.split(/e/i);if(2a)throw new Error("Cannot include negative exponent part for integers");s+=Array(a+1).join("0"),e=s}var c=/^([0-9][0-9]*)$/.test(e);if(!c)throw new Error("Invalid integer: "+e);for(var p=[],r=e.length,u=Z,l=r-u;0l&&(l=0),r-=u;return m(p),new t(p,i)}function W(e){if(g(e)){if(e!==_(e))throw new Error(e+" is not an integer.");return new d(e)}return G(e.toString())}function Y(e){return"number"==typeof e?W(e):"string"==typeof e?G(e):e}var X=1e7,Z=7,J=9007199254740992,Q=l(J);t.prototype=Object.create(e.prototype),d.prototype=Object.create(e.prototype),t.prototype.add=function(e){var r=Y(e);if(this.sign!==r.sign)return this.subtract(r.negate());var n=this.value,i=r.value;return r.isSmall?new t(I(n,s(i)),this.sign):new t(k(n,i),this.sign)},t.prototype.plus=t.prototype.add,d.prototype.add=function(e){var r=Y(e),n=this.value;if(0>n!==r.sign)return this.subtract(r.negate());var i=r.value;if(r.isSmall){if(g(n+i))return new d(n+i);i=l(s(i))}return new t(I(i,s(n)),0>n)},d.prototype.plus=d.prototype.add,t.prototype.subtract=function(e){var t=Y(e);if(this.sign!==t.sign)return this.add(t.negate());var r=this.value,n=t.value;return t.isSmall?A(r,s(n),this.sign):x(r,n,this.sign)},t.prototype.minus=t.prototype.subtract,d.prototype.subtract=function(e){var t=Y(e),r=this.value;if(0>r!==t.sign)return this.add(t.negate());var n=t.value;return t.isSmall?new d(r-n):A(n,s(r),0<=r)},d.prototype.minus=d.prototype.subtract,t.prototype.negate=function(){return new t(this.value,!this.sign)},d.prototype.negate=function(){var e=this.sign,t=new d(-this.value);return t.sign=!e,t},t.prototype.abs=function(){return new t(this.value,!1)},d.prototype.abs=function(){return new d(s(this.value))},t.prototype.multiply=function(r){var i=Y(r),n=this.value,o=i.value,d=this.sign!==i.sign,a;if(i.isSmall){if(0===o)return e[0];if(1===o)return this;if(-1===o)return this.negate();if(a=s(o),an?1:-1):-1},t.prototype.compare=function(e){if(e===Infinity)return-1;if(e===-Infinity)return 1;var t=Y(e),r=this.value,n=t.value;return this.sign===t.sign?t.isSmall?this.sign?-1:1:j(r,n)*(this.sign?-1:1):t.sign?1:-1},t.prototype.compareTo=t.prototype.compare,d.prototype.compare=function(e){if(e===Infinity)return-1;if(e===-Infinity)return 1;var t=Y(e),r=this.value,n=t.value;return t.isSmall?r==n?0:r>n?1:-1:0>r===t.sign?0>r?1:-1:0>r?-1:1},d.prototype.compareTo=d.prototype.compare,t.prototype.equals=function(e){return 0===this.compare(e)},d.prototype.eq=d.prototype.equals=t.prototype.eq=t.prototype.equals,t.prototype.notEquals=function(e){return 0!==this.compare(e)},d.prototype.neq=d.prototype.notEquals=t.prototype.neq=t.prototype.notEquals,t.prototype.greater=function(e){return 0this.compare(e)},d.prototype.lt=d.prototype.lesser=t.prototype.lt=t.prototype.lesser,t.prototype.greaterOrEquals=function(e){return 0<=this.compare(e)},d.prototype.geq=d.prototype.greaterOrEquals=t.prototype.geq=t.prototype.greaterOrEquals,t.prototype.lesserOrEquals=function(e){return 0>=this.compare(e)},d.prototype.leq=d.prototype.lesserOrEquals=t.prototype.leq=t.prototype.lesserOrEquals,t.prototype.isEven=function(){return 0==(1&this.value[0])},d.prototype.isEven=function(){return 0==(1&this.value)},t.prototype.isOdd=function(){return 1==(1&this.value[0])},d.prototype.isOdd=function(){return 1==(1&this.value)},t.prototype.isPositive=function(){return!this.sign},d.prototype.isPositive=function(){return 0this.value},t.prototype.isUnit=function(){return!1},d.prototype.isUnit=function(){return 1===s(this.value)},t.prototype.isZero=function(){return!1},d.prototype.isZero=function(){return 0===this.value},t.prototype.isDivisibleBy=function(t){var r=Y(t),n=r.value;return 0!==n&&(1===n||(2===n?this.isEven():this.mod(r).equals(e[0])))},d.prototype.isDivisibleBy=t.prototype.isDivisibleBy,t.prototype.isPrime=function(){var r=M(this);if(void 0!==r)return r;for(var o=this.abs(),n=o.prev(),s=[2,3,5,7,11,13,17,19],a=n,f,d,t,i;a.isEven();)a=a.divide(2);for(t=0;t-J?new d(e-1):new t(Q,!0)};for(var $=[1];2*$[$.length-1]<=X;)$.push(2*$[$.length-1]);var ee=$.length,te=$[ee-1];t.prototype.shiftLeft=function(e){if(!U(e))throw new Error(e+" is too large for shifting.");if(e=+e,0>e)return this.shiftRight(-e);for(var t=this;e>=ee;)t=t.multiply(te),e-=ee-1;return t.multiply($[e])},d.prototype.shiftLeft=t.prototype.shiftLeft,t.prototype.shiftRight=function(e){var t;if(!U(e))throw new Error(e+" is too large for shifting.");if(e=+e,0>e)return this.shiftLeft(-e);for(var r=this;e>=ee;){if(r.isZero())return r;t=C(r,te),r=t[1].isNegative()?t[0].prev():t[0],e-=ee-1}return t=C(r,$[e]),t[1].isNegative()?t[0].prev():t[0]},d.prototype.shiftRight=t.prototype.shiftRight,t.prototype.not=function(){return this.negate().prev()},d.prototype.not=t.prototype.not,t.prototype.and=function(e){return L(this,e,function(e,t){return e&t})},d.prototype.and=t.prototype.and,t.prototype.or=function(e){return L(this,e,function(e,t){return e|t})},d.prototype.or=t.prototype.or,t.prototype.xor=function(e){return L(this,e,function(e,t){return e^t})},d.prototype.xor=t.prototype.xor;var re=1073741824,ne=(X&-X)*(X&-X)|re,ie=function(e,t){for(var n=e.length,o=s(t),a=0,a,i;a=o){if("1"===i&&1===o)continue;throw new Error(i+" is not a valid digit in base "+t+".")}else if(i.charCodeAt(0)-87>=o)throw new Error(i+" is not a valid digit in base "+t+".");if(2<=t&&36>=t&&n<=36.7368005696771/r(t)){var f=parseInt(e,t);if(isNaN(f))throw new Error(i+" is not a valid digit in base "+t+".");return new d(parseInt(e,t))}t=Y(t);var p=[],u="-"===e[0];for(a=u?1:0;a=l)p.push(Y(i));else if(97<=l&&122>=l)p.push(Y(i.charCodeAt(0)-87));else if("<"===i){var h=a;do a++;while(">"!==e[a]);p.push(Y(e.slice(h+1,a)))}else throw new Error(i+" is not a valid character")}return F(p,t,u)};t.prototype.toString=function(e){if(void 0===e&&(e=10),10!==e)return V(this,e);for(var t=this.value,r=t.length,n=t[--r]+"",i;0<=--r;)i=t[r]+"",n+="0000000".slice(i.length)+i;var o=this.sign?"-":"";return o+n},d.prototype.toString=function(e){return void 0===e&&(e=10),10==e?this.value+"":V(this,e)},t.prototype.toJSON=d.prototype.toJSON=function(){return this.toString()},t.prototype.valueOf=function(){return+this.toString()},t.prototype.toJSNumber=t.prototype.valueOf,d.prototype.valueOf=function(){return this.value},d.prototype.toJSNumber=d.prototype.valueOf;for(var oe=0;1e3>oe;oe++)e[oe]=new d(oe),0=i?i-49+10:17<=i&&22>=i?i-17+10:15&i;return o}function s(e,t,n,o){for(var d=0,r=u(e.length,n),a=t,i;ae&&(this.sign=!0,e=-e),void(67108864>e?(this.words=[67108863&e],this.length=1):4503599627370496>e?(this.words=[67108863&e,67108863&e/67108864],this.length=2):(o(9007199254740992>e),this.words=[67108863&e,67108863&e/67108864,1],this.length=3));if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),o(t===(0|t)&&2<=t&&36>=t),e=e.toString().replace(/\s+/g,"");var n=0;"-"===e[0]&&n++,16===t?this._parseHex(e,n):this._parseBase(e,t,n),"-"===e[0]&&(this.sign=!0),this.strip()},d.prototype._initArray=function(e,t,r){if(o("number"==typeof e.length),0>=e.length)return this.words=[0],this.length=1,this;this.length=h(e.length/3),this.words=Array(this.length);for(var n=0;n>>26-i,i+=24,26<=i&&(i-=26,d++);else if("le"===r)for(var n=0,d=0,a;n>>26-i,i+=24,26<=i&&(i-=26,d++);return this.strip()},d.prototype._parseHex=function(e,t){this.length=h((e.length-t)/6),this.words=Array(this.length);for(var r=0;r=t;r-=6)o=a(e,r,r+6),this.words[i]|=67108863&o<>>26-n,n+=24,26<=n&&(n-=26,i++);if(r+6!==t){var o=a(e,t,r+6);this.words[i]|=67108863&o<>>26-n}this.strip()},d.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,o=1;67108863>=o;o*=t)n++;n--,o=0|o/t;for(var d=e.length-r,a=d%n,f=u(d,d-a)+r,c=0,p=r;pthis.words[0]+c?this.words[0]+=c:this._iaddn(c);if(0!=a){for(var i=1,c=s(e,p,e.length,t),p=0;pthis.words[0]+c?this.words[0]+=c:this._iaddn(c)}},d.prototype.copy=function(e){e.words=Array(this.length);for(var t=0;t"};var m=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],_=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],S=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,10000000,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];d.prototype.toString=function(e,t){if(e=e||10,16===e||"hex"===e){for(var n="",d=0,t=0|t||1,a=0,s=0;s>>24-d,n=0!=a||s!==this.length-1?m[6-f.length]+f+n:f+n,d+=2,26<=d&&(d-=26,s--)}for(0!=a&&(n=a.toString(16)+n);0!=n.length%t;)n="0"+n;return this.sign&&(n="-"+n),n}if(e===(0|e)&&2<=e&&36>=e){var p=_[e],u=S[e],n="",l=this.clone();for(l.sign=!1;0!==l.cmpn(0);){var c=l.modn(u).toString(e);l=l.idivn(u),n=0===l.cmpn(0)?c+n:m[p-c.length]+c+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}o(!1,"Base should be between 2 and 36")},d.prototype.toJSON=function(){return this.toString(16)},d.prototype.toArray=function(){this.strip();var e=Array(this.byteLength());e[0]=0;for(var t=this.clone(),r=0,n;0!==t.cmpn(0);r++)n=t.andln(255),t.ishrn(8),e[e.length-r-1]=n;return e},d.prototype._countBits=n?function(e){return 32-n(e)}:function(e){var n=e,t=0;return 4096<=n&&(t+=13,n>>>=13),64<=n&&(t+=7,n>>>=7),8<=n&&(t+=4,n>>>=4),2<=n&&(t+=2,n>>>=2),t+n},d.prototype._zeroBits=function(e){if(0===e)return 26;var n=e,t=0;return 0==(8191&n)&&(t+=13,n>>>=13),0==(127&n)&&(t+=7,n>>>=7),0==(15&n)&&(t+=4,n>>>=4),0==(3&n)&&(t+=2,n>>>=2),0==(1&n)&&t++,t},d.prototype.bitLength=function(){var e=0,t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},d.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var e=0,t=0,r;te.length?this.clone().ior(e):e.clone().ior(this)},d.prototype.iand=function(e){this.sign=this.sign&&e.sign;var t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},d.prototype.ixor=function(e){this.sign=this.sign||e.sign;var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},d.prototype.setn=function(e,t){o("number"==typeof e&&0<=e);for(var r=0|e/26,n=e%26;this.length<=r;)this.words[this.length++]=0;return t?this.words[r]|=1<e.length?(r=this,n=e):(r=e,n=this);for(var o=0,d=0,t;d>>26;for(;0!=o&&d>>26}if(this.length=r.length,0!=o)this.words[this.length]=o,this.length++;else if(r!==this)for(;de.length?this.clone().iadd(e):e.clone().iadd(this)},d.prototype.isub=function(e){if(e.sign){e.sign=!1;var t=this.iadd(e);return e.sign=!0,t._normSign()}if(this.sign)return this.sign=!1,this.iadd(e),this.sign=!0,this._normSign();var r=this.cmp(e);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var n,o;0>26,this.words[a]=67108863&t;for(;0!=d&&a>26,this.words[a]=67108863&t}if(0==d&&a>>26,s=67108863&n,f=u(o,e.length-1),c=p(0,o-this.length+1);c<=f;c++){var l=o-c,i=0|this.words[l],a=0|e.words[c],h=i*a,r=67108863&h;d=0|d+(0|h/67108864),r=0|r+s,s=67108863&r,d=0|d+(r>>>26)}t.words[o]=s,n=d}return 0==n?t.length--:t.words[o]=n,t.strip()},d.prototype._bigMulTo=function(e,t){t.sign=e.sign!==this.sign,t.length=this.length+e.length;for(var n=0,o=0,d=0,s;d>>26),o+=s>>>26,s&=67108863}t.words[d]=f,n=s,s=o}return 0==n?t.length--:t.words[d]=n,t.strip()},d.prototype.mulTo=function(e,t){var r;return r=63>this.length+e.length?this._smallMulTo(e,t):this._bigMulTo(e,t),r},d.prototype.mul=function(e){var t=new d(null);return t.words=Array(this.length+e.length),this.mulTo(e,t)},d.prototype.imul=function(e){if(0===this.cmpn(0)||0===e.cmpn(0))return this.words[0]=0,this.length=1,this;var t=this.length,n=e.length;this.sign=e.sign!==this.sign,this.length+=e.length,this.words[this.length-1]=0;for(var o=this.length-2;0<=o;o--){for(var d=0,s=0,f=u(o,n-1),c=p(0,o-t+1);c<=f;c++){var l=o-c,i=this.words[l],a=e.words[c],h=i*a,r=67108863&h;d+=0|h/67108864,r+=s,s=67108863&r,d+=r>>>26}this.words[o]=s,this.words[o+1]+=d,d=0}for(var d=0,l=1,b;l>>26;return this.strip()},d.prototype.imuln=function(e){o("number"==typeof e);for(var t=0,r=0;r>=26,t+=0|n/67108864,t+=i>>>26,this.words[r]=67108863&i}return 0!=t&&(this.words[r]=t,this.length++),this},d.prototype.sqr=function(){return this.mul(this)},d.prototype.isqr=function(){return this.mul(this)},d.prototype.ishln=function(e){o("number"==typeof e&&0<=e);var t=e%26,r=(e-t)/26;if(0!=t){for(var n=0,d=0;d>>26-t<<26-t,a=this.words[d]-i<>>26-t}n&&(this.words[d]=n,this.length++)}if(0!=r){for(var d=this.length-1;0<=d;d--)this.words[d+r]=this.words[d];for(var d=0;dr){this.length-=r;for(var f=0;f=d);f--)c=this.words[f],this.words[f]=i<<26-a|c>>>a,i=c&(67108863^67108863>>>a<>>t<e?this.isubn(-e):this.sign?1===this.length&&this.words[0]e)return this.iaddn(-e);if(this.sign)return this.sign=!1,this.iaddn(e),this.sign=!0,this;this.words[0]-=e;for(var t=0;tthis.words[t];t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},d.prototype.addn=function(e){return this.clone().iaddn(e)},d.prototype.subn=function(e){return this.clone().isubn(e)},d.prototype.iabs=function(){return this.sign=!1,this},d.prototype.abs=function(){return this.clone().iabs()},d.prototype._ishlnsubmul=function(e,r,n){var d=e.length+n,a;if(this.words.length>26)-(0|f/67108864),this.words[a+n]=67108863&s}for(;a>26,this.words[a+n]=67108863&s}if(0==t)return this.strip();o(-1==t),t=0;for(var a=0,s;a>26,this.words[a]=67108863&s;return this.sign=!0,this.strip()},d.prototype._wordDiv=function(e,t){var r=this.length-e.length,n=this.clone(),o=e,s=o.words[o.length-1],f=this._countBits(s);r=26-f,0!=r&&(o=o.shln(r),n.ishln(r),s=o.words[o.length-1]);var c=n.length-o.length,p;if("mod"!==t){p=new d(null),p.length=c+1,p.words=Array(p.length);for(var l=0;lthis.length||0>this.cmp(e)?{div:new d(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new d(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new d(this.modn(e.words[0]))}:this._wordDiv(e,t)},d.prototype.div=function(e){return this.divmod(e,"div").div},d.prototype.mod=function(e){return this.divmod(e,"mod").mod},d.prototype.divRound=function(e){var t=this.divmod(e);if(0===t.mod.cmpn(0))return t.div;var r=t.div.sign?t.mod.isub(e):t.mod,n=e.shrn(1),i=e.andln(1),o=r.cmp(n);return 0>o||1===i&&0===o?t.div:t.div.sign?t.div.isubn(1):t.div.iaddn(1)},d.prototype.modn=function(e){o(67108863>=e);for(var t=0,r=this.length-1;0<=r;r--)t=(67108864%e*t+this.words[r])%e;return t},d.prototype.idivn=function(e){o(67108863>=e);for(var t=0,r=this.length-1,n;0<=r;r--)n=this.words[r]+67108864*t,this.words[r]=0|n/e,t=n%e;return this.strip()},d.prototype.divn=function(e){return this.clone().idivn(e)},d.prototype.egcd=function(e){o(!e.sign),o(0!==e.cmpn(0));var t=this,r=e.clone();t=t.sign?t.mod(e):t.clone();for(var n=new d(1),i=new d(0),a=new d(0),s=new d(1),f=0;t.isEven()&&r.isEven();)t.ishrn(1),r.ishrn(1),++f;for(var c=r.clone(),p=t.clone();0!==t.cmpn(0);){for(;t.isEven();)t.ishrn(1),n.isEven()&&i.isEven()?(n.ishrn(1),i.ishrn(1)):(n.iadd(c).ishrn(1),i.isub(p).ishrn(1));for(;r.isEven();)r.ishrn(1),a.isEven()&&s.isEven()?(a.ishrn(1),s.ishrn(1)):(a.iadd(c).ishrn(1),s.isub(p).ishrn(1));0<=t.cmp(r)?(t.isub(r),n.isub(a),i.isub(s)):(r.isub(t),a.isub(n),s.isub(i))}return{a:a,b:s,gcd:r.ishln(f)}},d.prototype._invmp=function(e){o(!e.sign),o(0!==e.cmpn(0));var t=this,r=e.clone();t=t.sign?t.mod(e):t.clone();for(var n=new d(1),i=new d(0),a=r.clone();0d){var r=n;n=i,i=r}else if(0===d||0===i.cmpn(1))break;n.isub(i)}while(!0);return i.ishln(o)},d.prototype.invm=function(e){return this.egcd(e).a.mod(e)},d.prototype.isEven=function(){return 0==(1&this.words[0])},d.prototype.isOdd=function(){return 1==(1&this.words[0])},d.prototype.andln=function(e){return this.words[0]&e},d.prototype.bincn=function(e){o("number"==typeof e);var t=e%26,r=(e-t)/26,n=1<>>26,a&=67108863,this.words[d]=a;return 0!=i&&(this.words[d]=i,this.length++),this},d.prototype.cmpn=function(e){var t=0>e;if(t&&(e=-e),this.sign&&!t)return-1;if(!this.sign&&t)return 1;e&=67108863,this.strip();var r;if(1e.length)return 1;if(this.lengthi&&(t=1);break}}return t},d.red=function(e){return new g(e)},d.prototype.toRed=function(e){return o(!this.red,"Already a number in reduction context"),o(!this.sign,"red works only with positives"),e.convertTo(this)._forceRed(e)},d.prototype.fromRed=function(){return o(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},d.prototype._forceRed=function(e){return this.red=e,this},d.prototype.forceRed=function(e){return o(!this.red,"Already a number in reduction context"),this._forceRed(e)},d.prototype.redAdd=function(e){return o(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},d.prototype.redIAdd=function(e){return o(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},d.prototype.redSub=function(e){return o(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},d.prototype.redISub=function(e){return o(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},d.prototype.redShl=function(e){return o(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},d.prototype.redMul=function(e){return o(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},d.prototype.redIMul=function(e){return o(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},d.prototype.redSqr=function(){return o(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},d.prototype.redISqr=function(){return o(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},d.prototype.redSqrt=function(){return o(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},d.prototype.redInvm=function(){return o(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},d.prototype.redNeg=function(){return o(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},d.prototype.redPow=function(e){return o(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var v={k256:null,p224:null,p192:null,p25519:null};i.prototype._tmp=function(){var e=new d(null);return e.words=Array(h(this.n/13)),e},i.prototype.ireduce=function(e){var t=e,r;do this.split(t,this.tmp),t=this.imulK(t),t=t.iadd(this.tmp),r=t.bitLength();while(r>this.n);var n=r=e.length)return e.words[0]=0,void(e.length=1);var i=e.words[9];t.words[t.length++]=i&r;for(var o=10,d;o>>22,i=d;e.words[o-10]=i>>>22,e.length-=9},f.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0,n,i;r>>=26,e.words[r]=i,t=n}return 0!=t&&(e.words[e.length++]=t),e},d._prime=function(e){if(v[e])return v[e];var t;if("k256"===e)t=new f;else if("p224"===e)t=new c;else if("p192"===e)t=new l;else if("p25519"===e)t=new b;else throw new Error("Unknown prime "+e);return v[e]=t,t},g.prototype._verify1=function(e){o(!e.sign,"red works only with positives"),o(e.red,"red works only with red numbers")},g.prototype._verify2=function(e,t){o(!e.sign&&!t.sign,"red works only with positives"),o(e.red&&e.red===t.red,"red works only with red numbers")},g.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.mod(this.m)._forceRed(this)},g.prototype.neg=function(e){var t=e.clone();return t.sign=!t.sign,t.iadd(this.m)._forceRed(this)},g.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return 0<=r.cmp(this.m)&&r.isub(this.m),r._forceRed(this)},g.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return 0<=r.cmp(this.m)&&r.isub(this.m),r},g.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return 0>r.cmpn(0)&&r.iadd(this.m),r._forceRed(this)},g.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return 0>r.cmpn(0)&&r.iadd(this.m),r},g.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.shln(t))},g.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},g.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},g.prototype.isqr=function(e){return this.imul(e,e)},g.prototype.sqr=function(e){return this.mul(e,e)},g.prototype.sqrt=function(e){if(0===e.cmpn(0))return e.clone();var n=this.m.andln(3);if(o(1==n%2),3===n){var a=this.m.add(new d(1)).ishrn(2),f=this.pow(e,a);return f}for(var r=this.m.subn(1),p=0;0!==r.cmpn(0)&&0===r.andln(1);)p++,r.ishrn(1);o(0!==r.cmpn(0));var s=new d(1).toRed(this),u=s.redNeg(),l=this.m.subn(1).ishrn(1),h=this.m.bitLength();for(h=new d(2*h*h).toRed(this);0!==this.pow(h,l).cmp(u);)h.redIAdd(u);for(var g=this.pow(h,r),f=this.pow(e,r.addn(1).ishrn(1)),c=this.pow(e,r),t=p;0!==c.cmp(s);){for(var y=c,m=0;0!==y.cmp(s);m++)y=y.redSqr();o(mi.cmpn(0)&&(o=i.iadd(this.m)),o._forceRed(this)},y.prototype.mul=function(e,r){if(0===e.cmpn(0)||0===r.cmpn(0))return new d(0)._forceRed(this);var n=e.mul(r),t=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(t).ishrn(this.shift),o=i;return 0<=i.cmp(this.m)?o=i.isub(this.m):0>i.cmpn(0)&&(o=i.iadd(this.m)),o._forceRed(this)},y.prototype.invm=function(e){var t=this.imod(e._invmp(this.m).mul(this.r2));return t._forceRed(this)}})("undefined"==typeof t||t,this)},{}],21:[function(e,t){function n(e){this.rand=e}var i;if(t.exports=function(e){return i||(i=new n(null)),i.generate(e)},t.exports.Rand=n,n.prototype.generate=function(e){return this._rand(e)},n.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^d[255&c>>>16]^a[255&p>>>8]^s[255&u]^t[l++],g=o[c>>>24]^d[255&p>>>16]^a[255&u>>>8]^s[255&f]^t[l++],y=o[p>>>24]^d[255&u>>>16]^a[255&f>>>8]^s[255&c]^t[l++],m=o[u>>>24]^d[255&f>>>16]^a[255&c>>>8]^s[255&p]^t[l++],f=b,c=g,p=y,u=m;return b=(n[f>>>24]<<24|n[255&c>>>16]<<16|n[255&p>>>8]<<8|n[255&u])^t[l++],g=(n[c>>>24]<<24|n[255&p>>>16]<<16|n[255&u>>>8]<<8|n[255&f])^t[l++],y=(n[p>>>24]<<24|n[255&u>>>16]<<16|n[255&f>>>8]<<8|n[255&c])^t[l++],m=(n[u>>>24]<<24|n[255&f>>>16]<<16|n[255&c>>>8]<<8|n[255&p])^t[l++],b>>>=0,g>>>=0,y>>>=0,m>>>=0,[b,g,y,m]}function o(e){this._key=r(e),this._reset()}var d=e("safe-buffer").Buffer,a=[0,1,2,4,8,16,32,64,128,27,54],s=function(){for(var e=Array(256),r=0;256>r;r++)e[r]=128>r?r<<1:283^r<<1;for(var n=[],o=[],d=[[],[],[],[]],a=[[],[],[],[]],s=0,f=0,c=0,i;256>c;++c){i=f^f<<1^f<<2^f<<3^f<<4,i=99^(i>>>8^255&i),n[s]=i,o[i]=s;var p=e[s],u=e[p],l=e[u],h=257*e[i]^16843008*i;d[0][s]=h<<24|h>>>8,d[1][s]=h<<16|h>>>16,d[2][s]=h<<8|h>>>24,d[3][s]=h,h=16843009*l^65537*u^257*p^16843008*s,a[0][i]=h<<24|h>>>8,a[1][i]=h<<16|h>>>16,a[2][i]=h<<8|h>>>24,a[3][i]=h,0==s?s=f=1:(s=p^e[e[e[l^p]]],f^=e[e[f]])}return{SBOX:n,INV_SBOX:o,SUB_MIX:d,INV_SUB_MIX:a}}();o.blockSize=16,o.keySize=32,o.prototype.blockSize=o.blockSize,o.prototype.keySize=o.keySize,o.prototype._reset=function(){for(var e=this._key,r=e.length,n=r+6,i=4*(n+1),o=[],d=0;d>>24,f=s.SBOX[f>>>24]<<24|s.SBOX[255&f>>>16]<<16|s.SBOX[255&f>>>8]<<8|s.SBOX[255&f],f^=a[0|d/r]<<24):6>>24]<<24|s.SBOX[255&f>>>16]<<16|s.SBOX[255&f>>>8]<<8|s.SBOX[255&f]),o[d]=o[d-r]^f}for(var t=[],c=0;cc||4>=p?u:s.INV_SUB_MIX[0][s.SBOX[u>>>24]]^s.INV_SUB_MIX[1][s.SBOX[255&u>>>16]]^s.INV_SUB_MIX[2][s.SBOX[255&u>>>8]]^s.INV_SUB_MIX[3][s.SBOX[255&u]]}this._nRounds=n,this._keySchedule=o,this._invKeySchedule=t},o.prototype.encryptBlockRaw=function(e){return e=r(e),i(e,this._keySchedule,s.SUB_MIX,s.SBOX,this._nRounds)},o.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=d.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},o.prototype.decryptBlock=function(e){e=r(e);var t=e[1];e[1]=e[3],e[3]=t;var n=i(e,this._invKeySchedule,s.INV_SUB_MIX,s.INV_SBOX,this._nRounds),o=d.allocUnsafe(16);return o.writeUInt32BE(n[0],0),o.writeUInt32BE(n[3],4),o.writeUInt32BE(n[2],8),o.writeUInt32BE(n[1],12),o},o.prototype.scrub=function(){n(this._keySchedule),n(this._invKeySchedule),n(this._key)},t.exports.AES=o},{"safe-buffer":196}],24:[function(e,t){function r(e,t){var r=0;e.length!==t.length&&r++;for(var n=u(e.length,t.length),o=0;ot&&(t=d.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},i.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=c(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&r(e,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=e,this._cipher.scrub()},i.prototype.getAuthTag=function(){if(this._decrypt||!d.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},i.prototype.setAuthTag=function(e){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=e},i.prototype.setAAD=function(e){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(e),this._alen+=e.length},t.exports=i},{"./aes":23,"./ghash":28,"./incr32":29,"buffer-xor":70,"cipher-base":76,inherits:146,"safe-buffer":196}],25:[function(e,t,r){var n=e("./encrypter"),i=e("./decrypter"),o=e("./modes/list.json");r.createCipher=r.Cipher=n.createCipher,r.createCipheriv=r.Cipheriv=n.createCipheriv,r.createDecipher=r.Decipher=i.createDecipher,r.createDecipheriv=r.Decipheriv=i.createDecipheriv,r.listCiphers=r.getCiphers=function(){return Object.keys(o)}},{"./decrypter":26,"./encrypter":27,"./modes/list.json":37}],26:[function(e,t,r){function n(e,t,r){p.call(this),this._cache=new i,this._last=void 0,this._cipher=new u.AES(t),this._prev=s.from(r),this._mode=e,this._autopadding=!0}function i(){this.cache=s.allocUnsafe(0)}function o(e){for(var t=e[15],r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function i(e){this.h=e,this.state=o.alloc(16,0),this.cache=o.allocUnsafe(0)}var o=e("safe-buffer").Buffer,d=o.alloc(16,0);i.prototype.ghash=function(e){for(var t=-1;++t++o;){for(d=0!=(this.state[~~(o/8)]&1<<7-o%8),d&&(t[0]^=e[0],t[1]^=e[1],t[2]^=e[2],t[3]^=e[3]),a=0!=(1&e[3]),i=3;0>>1|(1&e[i-1])<<31;e[0]>>>=1,a&&(e[0]^=-520093696)}this.state=n(t)},i.prototype.update=function(e){this.cache=o.concat([this.cache,e]);for(var t;16<=this.cache.length;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},i.prototype.final=function(e,t){return this.cache.length&&this.ghash(o.concat([this.cache,d],16)),this.ghash(n([0,e,0,t])),this.state},t.exports=i},{"safe-buffer":196}],29:[function(e,t){t.exports=function(e){for(var t=e.length,r;t--;)if(r=e.readUInt8(t),255===r)e.writeUInt8(0,t);else{r++,e.writeUInt8(r,t);break}}},{}],30:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":70}],31:[function(e,t,r){function n(e,t,r){var n=t.length,d=o(t,e._cache);return e._cache=e._cache.slice(n),e._prev=i.concat([e._prev,r?t:d]),d}var i=e("safe-buffer").Buffer,o=e("buffer-xor");r.encrypt=function(e,t,r){for(var o=i.allocUnsafe(0),d;t.length;)if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=i.allocUnsafe(0)),e._cache.length<=t.length)d=e._cache.length,o=i.concat([o,n(e,t.slice(0,d),r)]),t=t.slice(d);else{o=i.concat([o,n(e,t,r)]);break}return o}},{"buffer-xor":70,"safe-buffer":196}],32:[function(e,t,r){function n(e,t,r){for(var n=-1,i=0,d,a,s;++n<8;)d=e._cipher.encryptBlock(e._prev),a=t&1<<7-n?128:0,s=d[0]^a,i+=(128&s)>>n%8,e._prev=o(e._prev,r?a:s);return i}function o(e,t){var r=e.length,n=-1,i=d.allocUnsafe(e.length);for(e=d.concat([e,d.from([t])]);++n>7;return i}var d=e("safe-buffer").Buffer;r.encrypt=function(e,t,r){for(var o=t.length,a=d.allocUnsafe(o),s=-1;++s=e.cmpn(0))throw new Error("invalid sig");if(e.cmp(t)>=t)throw new Error("invalid sig")}var d=e("bn.js"),a=e("elliptic").ec,f=e("parse-asn1"),s=e("./curves.json");t.exports=function(e,t,o,a,s){var c=f(o);if("ec"===c.type){if("ecdsa"!==a&&"ecdsa/rsa"!==a)throw new Error("wrong public key type");return n(e,t,c)}if("dsa"===c.type){if("dsa"!==a)throw new Error("wrong public key type");return i(e,t,c)}if("rsa"!==a&&"ecdsa/rsa"!==a)throw new Error("wrong public key type");t=r.concat([s,t]);for(var p=c.modulus.byteLength(),l=[1],h=0;t.length+l.length+2h?1:0;for(p=u(e.length,l.length),e.length!==l.length&&(y=1),b=-1;++b=f;t--)p=(p<<1)+n[t];d.push(p)}for(var u=this.jpoint(null,null,null),a=this.jpoint(null,null,null),l=o;0f)break;var i=d[f];c(0!==i),a="affine"===e.type?0>1]):a.mixedAdd(o[-i-1>>1].neg()):0>1]):a.add(o[-i-1>>1].neg())}return"affine"===e.type?a.toP():a},r.prototype._wnafMulAdd=function(e,t,r,n,o){for(var d=this._wnafT1,c=this._wnafT2,u=this._wnafT3,l=0,h=0;hh)break;for(var S=0;S>1]:0>E&&(i=c[S][-E-1>>1].neg());x="affine"===i.type?x.mixedAdd(i):x.add(i)}}for(var h=0;h=h((e.bitLength()+1)/t.step)},n.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,o=0;o":""},n.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},n.prototype._extDbl=function(){var t=this.x.redSqr(),r=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var i=this.curve._mulA(t),o=this.x.redAdd(this.y).redSqr().redISub(t).redISub(r),e=i.redAdd(r),d=e.redSub(n),a=i.redSub(r),s=o.redMul(d),f=e.redMul(a),c=o.redMul(a),p=d.redMul(e);return this.curve.point(s,f,p,c)},n.prototype._projDbl=function(){var t=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),n=this.y.redSqr(),i,o,d;if(this.curve.twisted){var a=this.curve._mulA(r),e=a.redAdd(n);if(this.zOne)i=t.redSub(r).redSub(n).redMul(e.redSub(this.curve.two)),o=e.redMul(a.redSub(n)),d=e.redSqr().redSub(e).redSub(e);else{var s=this.z.redSqr(),f=e.redSub(s).redISub(s);i=t.redSub(r).redISub(n).redMul(f),o=e.redMul(a.redSub(n)),d=e.redMul(f)}}else{var a=r.redAdd(n),s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),f=a.redSub(s).redSub(s);i=this.curve._mulC(t.redISub(a)).redMul(f),o=this.curve._mulC(a).redMul(r.redISub(n)),d=a.redMul(f)}return this.curve.point(i,o,d)},n.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},n.prototype._extAdd=function(t){var r=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),n=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),o=this.z.redMul(t.z.redAdd(t.z)),d=n.redSub(r),e=o.redSub(i),a=o.redAdd(i),s=n.redAdd(r),f=d.redMul(e),c=a.redMul(s),p=d.redMul(s),u=e.redMul(a);return this.curve.point(f,c,u,p)},n.prototype._projAdd=function(t){var r=this.z.redMul(t.z),n=r.redSqr(),i=this.x.redMul(t.x),o=this.y.redMul(t.y),d=this.curve.d.redMul(i).redMul(o),e=n.redSub(d),a=n.redAdd(d),s=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(i).redISub(o),f=r.redMul(e).redMul(s),c,p;return this.curve.twisted?(c=r.redMul(a).redMul(o.redSub(this.curve._mulA(i))),p=e.redMul(a)):(c=r.redMul(a).redMul(o.redSub(i)),p=this.curve._mulC(e).redMul(a)),this.curve.point(f,c,p)},n.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},n.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},n.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},n.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},n.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},n.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},n.prototype.getX=function(){return this.normalize(),this.x.fromRed()},n.prototype.getY=function(){return this.normalize(),this.y.fromRed()},n.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},n.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(r))return!0;for(var n=e.clone(),i=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),0<=n.cmp(this.curve.p))return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},n.prototype.toP=n.prototype.normalize,n.prototype.mixedAdd=n.prototype.add},{"../../elliptic":52,"../curve":55,"bn.js":51,inherits:146}],55:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":53,"./edwards":54,"./mont":56,"./short":57}],56:[function(e,t){"use strict";function r(e){a.call(this,"mont",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.i4=new o(4).toRed(this.red).redInvm(),this.two=new o(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function n(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new o(t,16),this.z=new o(r,16),!this.x.red&&(this.x=this.x.toRed(this.curve.red)),!this.z.red&&(this.z=this.z.toRed(this.curve.red)))}var i=e("../curve"),o=e("bn.js"),d=e("inherits"),a=i.base,s=e("../../elliptic"),f=s.utils;d(r,a),t.exports=r,r.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t),i=n.redSqrt();return 0===i.redSqr().cmp(n)},d(n,a.BasePoint),r.prototype.decodePoint=function(e,t){return this.point(f.toArray(e,t),1)},r.prototype.point=function(e,t){return new n(this,e,t)},r.prototype.pointFromJSON=function(e){return n.fromJSON(this,e)},n.prototype.precompute=function(){},n.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},n.fromJSON=function(e,t){return new n(e,t[0],t[1]||e.one)},n.prototype.inspect=function(){return this.isInfinity()?"":""},n.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},n.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),r=this.x.redSub(this.z),n=r.redSqr(),i=t.redSub(n),o=t.redMul(n),d=i.redMul(n.redAdd(this.curve.a24.redMul(i)));return this.curve.point(o,d)},n.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},n.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z),d=o.redMul(r),a=i.redMul(n),s=t.z.redMul(d.redAdd(a).redSqr()),f=t.x.redMul(d.redISub(a).redSqr());return this.curve.point(s,f)},n.prototype.mul=function(e){for(var r=e.clone(),t=this,n=this.curve.point(null,null),o=this,d=[];0!==r.cmpn(0);r.iushrn(1))d.push(r.andln(1));for(var a=d.length-1;0<=a;a--)0===d[a]?(t=t.diffAdd(n,o),n=n.dbl()):(n=t.diffAdd(n,o),t=t.dbl());return n},n.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},n.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},n.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},n.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},n.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":52,"../curve":55,"bn.js":51,inherits:146}],57:[function(e,t){"use strict";function r(e){c.call(this,"short",e),this.a=new a(e.a,16).toRed(this.red),this.b=new a(e.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(e),this._endoWnafT1=[,,,,],this._endoWnafT2=[,,,,]}function n(e,t,r,n){c.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new a(t,16),this.y=new a(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 i(e,t,r,n){c.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new a(0)):(this.x=new a(t,16),this.y=new a(r,16),this.z=new a(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}var o=e("../curve"),d=e("../../elliptic"),a=e("bn.js"),s=e("inherits"),c=o.base,p=d.utils.assert;s(r,c),t.exports=r,r.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new a(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=0>n[0].cmp(n[1])?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)r=new a(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],p(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}var o;return o=e.basis?e.basis.map(function(e){return{a:new a(e.a,16),b:new a(e.b,16)}}):this._getEndoBasis(r),{beta:t,lambda:r,basis:o}}},r.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:a.mont(e),r=new a(2).toRed(t).redInvm(),n=r.redNeg(),i=new a(3).toRed(t).redNeg().redSqrt().redMul(r),o=n.redAdd(i).fromRed(),d=n.redSub(i).fromRed();return[o,d]},r.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(f(this.n.bitLength()/2)),n=e,o=this.n.clone(),d=new a(1),s=new a(0),c=new a(0),p=new a(1),u=0,i,l,h,b,g,m,_,S,r,v;0!==n.cmpn(0);){v=o.div(n),S=o.sub(v.mul(n)),r=c.sub(v.mul(d));var k=p.sub(v.mul(s));if(!h&&0>S.cmp(t))i=_.neg(),l=d,h=S.neg(),b=r;else if(h&&2==++u)break;_=S,o=n,n=S,c=d,d=r,p=s,s=k}g=S.neg(),m=r;var y=h.sqr().add(b.sqr()),I=g.sqr().add(m.sqr());return 0<=I.cmp(y)&&(g=i,m=l),h.negative&&(h=h.neg(),b=b.neg()),g.negative&&(g=g.neg(),m=m.neg()),[{a:h,b:b},{a:g,b:m}]},r.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),d=i.mul(r.a),a=o.mul(n.a),s=i.mul(r.b),f=o.mul(n.b),c=e.sub(d).sub(a),p=s.add(f).neg();return{k1:c,k2:p}},r.prototype.pointFromX=function(e,t){e=new a(e,16),e.red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},r.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},r.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,o=this._endoWnafT2,d=0;d":""},n.prototype.isInfinity=function(){return this.inf},n.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},n.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),d=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,d)},n.prototype.getX=function(){return this.x.fromRed()},n.prototype.getY=function(){return this.y.fromRed()},n.prototype.mul=function(e){return e=new a(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},n.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},n.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},n.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},n.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.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 t},n.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e},s(i,c.BasePoint),r.prototype.jpoint=function(e,t,r){return new i(this,e,t,r)},i.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},i.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},i.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(t),o=e.x.redMul(n),d=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),s=i.redSub(o),f=d.redSub(a);if(0===s.cmpn(0))return 0===f.cmpn(0)?this.dbl():this.curve.jpoint(null,null,null);var r=s.redSqr(),c=r.redMul(s),p=i.redMul(r),u=f.redSqr().redIAdd(c).redISub(p).redISub(p),l=f.redMul(p.redISub(u)).redISub(d.redMul(c)),h=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(u,l,h)},i.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,i=e.x.redMul(t),o=this.y,d=e.y.redMul(t).redMul(this.z),a=n.redSub(i),s=o.redSub(d);if(0===a.cmpn(0))return 0===s.cmpn(0)?this.dbl():this.curve.jpoint(null,null,null);var r=a.redSqr(),f=r.redMul(a),c=n.redMul(r),p=s.redSqr().redIAdd(f).redISub(c).redISub(c),u=s.redMul(c.redISub(p)).redISub(o.redMul(f)),l=this.z.redMul(a);return this.curve.jpoint(p,u,l)},i.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r":""},i.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":52,"../curve":55,"bn.js":51,inherits:146}],58:[function(e,t,r){"use strict";function n(e){this.curve="short"===e.type?new a.curve.short(e):"edwards"===e.type?new a.curve.edwards(e):new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function i(e,t){Object.defineProperty(o,e,{configurable:!0,enumerable:!0,get:function(){var r=new n(t);return Object.defineProperty(o,e,{configurable:!0,enumerable:!0,value:r}),r}})}var o=r,d=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;o.PresetCurve=n,i("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:d.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),i("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:d.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),i("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:d.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),i("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:d.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"]}),i("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 a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:d.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),i("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:d.sha256,gRed:!1,g:["9"]}),i("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:d.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var f;try{f=e("./precomputed/secp256k1")}catch(t){f=void 0}i("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:d.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",f]})},{"../elliptic":52,"./precomputed/secp256k1":65,"hash.js":130}],59:[function(e,t){"use strict";function r(e){return this instanceof r?void("string"==typeof e&&(a(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash):new r(e)}var i=e("bn.js"),n=e("hmac-drbg"),o=e("../../elliptic"),d=o.utils,a=d.assert,s=e("./key"),f=e("./signature");t.exports=r,r.prototype.keyPair=function(e){return new s(this,e)},r.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},r.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},r.prototype.genKeyPair=function(e){e||(e={});var t=new n({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),d=this.n.sub(new i(2));do{var a=new i(t.generate(r));if(0=b.cmpn(1)||0<=b.cmp(l))){var g=this.g.mul(b);if(!g.isInfinity()){var y=g.getX(),m=y.umod(this.n);if(0!==m.cmpn(0)){var _=b.invm(this.n).mul(m.mul(t.getPrivate()).iadd(e));if(_=_.umod(this.n),0!==_.cmpn(0)){var S=(g.getY().isOdd()?1:0)|(0===y.cmp(m)?0:2);return d.canonical&&0<_.cmp(this.nh)&&(_=this.n.sub(_),S^=1),new f({r:m,s:_,recoveryParam:S})}}}}},r.prototype.verify=function(e,t,n,o){e=this._truncateToN(new i(e,16)),n=this.keyFromPublic(n,o),t=new f(t,"hex");var d=t.r,r=t.s;if(0>d.cmpn(1)||0<=d.cmp(this.n))return!1;if(0>r.cmpn(1)||0<=r.cmp(this.n))return!1;var a=r.invm(this.n),s=a.mul(e).umod(this.n),c=a.mul(d).umod(this.n);if(!this.curve._maxwellTrick){var u=this.g.mulAdd(s,n.getPublic(),c);return!u.isInfinity()&&0===u.getX().umod(this.n).cmp(d)}var u=this.g.jmulAdd(s,n.getPublic(),c);return!u.isInfinity()&&u.eqXToP(d)},r.prototype.recoverPubKey=function(t,o,d,c){a((3&d)===d,"The recovery param is more than two bits"),o=new f(o,c);var p=this.n,n=new i(t),e=o.r,r=o.s,s=1&d,u=d>>1;if(0<=e.cmp(this.curve.p.umod(this.curve.n))&&u)throw new Error("Unable to find sencond key candinate");e=u?this.curve.pointFromX(e.add(this.curve.n),s):this.curve.pointFromX(e,s);var l=o.r.invm(p),h=p.sub(n).mul(l).umod(p),b=r.mul(l).umod(p);return this.g.mulAdd(h,e,b)},r.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new f(e,n),null!==e.recoveryParam)return e.recoveryParam;for(var o=0;4>o;o++){var i;try{i=this.recoverPubKey(t,e,o)}catch(t){continue}if(i.eq(r))return o}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":52,"./key":60,"./signature":61,"bn.js":51,"hmac-drbg":143}],60:[function(e,t){"use strict";function r(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var n=e("bn.js"),i=e("../../elliptic"),o=i.utils,d=o.assert;t.exports=r,r.fromPublic=function(e,t,n){return t instanceof r?t:new r(e,{pub:t,pubEnc:n})},r.fromPrivate=function(e,t,n){return t instanceof r?t:new r(e,{priv:t,privEnc:n})},r.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},r.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},r.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},r.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},r.prototype._importPublic=function(e,t){return e.x||e.y?("mont"===this.ec.curve.type?d(e.x,"Need x coordinate"):("short"===this.ec.curve.type||"edwards"===this.ec.curve.type)&&d(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y))):void(this.pub=this.ec.curve.decodePoint(e,t))},r.prototype.derive=function(e){return e.mul(this.priv).getX()},r.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},r.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},r.prototype.inspect=function(){return""}},{"../../elliptic":52,"bn.js":51}],61:[function(e,n){"use strict";function i(e,t){return e instanceof i?e:void(this._importDER(e,t)||(p(e.r&&e.s,"Signature without r or s"),this.r=new c(e.r,16),this.s=new c(e.s,16),this.recoveryParam=void 0===e.recoveryParam?null:e.recoveryParam))}function o(){this.place=0}function d(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=0,o=0,i=t.place;o<(15&r);o++,i++)n<<=8,n|=e[i];return t.place=i,n}function a(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&tn)return void e.push(n);var i=1+(r(n)/t>>>3);for(e.push(128|i);--i;)e.push(255&n>>>(i<<3));e.push(n)}var c=e("bn.js"),s=e("../../elliptic"),u=s.utils,p=u.assert;n.exports=i,i.prototype._importDER=function(e,t){e=u.toArray(e,t);var n=new o;if(48!==e[n.place++])return!1;var i=d(e,n);if(i+n.place!==e.length)return!1;if(2!==e[n.place++])return!1;var a=d(e,n),f=e.slice(n.place,a+n.place);if(n.place+=a,2!==e[n.place++])return!1;var r=d(e,n);if(e.length!==r+n.place)return!1;var p=e.slice(n.place,r+n.place);return 0===f[0]&&128&f[1]&&(f=f.slice(1)),0===p[0]&&128&p[1]&&(p=p.slice(1)),this.r=new c(f),this.s=new c(p),this.recoveryParam=null,!0},i.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=a(t),r=a(r);!r[0]&&!(128&r[1]);)r=r.slice(1);var n=[2];f(n,t.length),n=n.concat(t),n.push(2),f(n,r.length);var i=n.concat(r),o=[48];return f(o,i.length),o=o.concat(i),u.encode(o,e)}},{"../../elliptic":52,"bn.js":51}],62:[function(e,t){"use strict";function r(e){if(d("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof r))return new r(e);var e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=h(e.n.bitLength()/8),this.hash=n.sha512}var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,d=o.assert,a=o.parseBytes,s=e("./key"),f=e("./signature");t.exports=r,r.prototype.sign=function(e,t){e=a(e);var n=this.keyFromSecret(t),i=this.hashInt(n.messagePrefix(),e),r=this.g.mul(i),o=this.encodePoint(r),d=this.hashInt(o,n.pubBytes(),e).mul(n.priv()),s=i.add(d).umod(this.curve.n);return this.makeSignature({R:r,S:s,Rencoded:o})},r.prototype.verify=function(e,t,r){e=a(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),d=t.R().add(n.pub().mul(i));return d.eq(o)},r.prototype.hashInt=function(){for(var e=this.hash(),t=0;t(n>>1)-1?(n>>1)-a:a,o.isubn(d)}else d=0;r.push(d);for(var s=0!==o.cmpn(0)&&0===o.andln(n-1)?t+1:1,f=1;f>8,t[o]&=255;for(;a;)t.push(255&a),a>>=8}for(r=0;"1"===e[r]&&rt[n]?1:0,0==r);++n);return 0==r&&(t.length>e.length?r=-1:e.length>t.length&&(r=1)),r}},{}],70:[function(e,t){(function(e){t.exports=function(t,r){for(var n=u(t.length,r.length),o=new e(n),d=0;dQ)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return c(e)}return i(e,t,r)}function i(e,t,r){if("number"==typeof e)throw new TypeError("\"value\" argument must not be a number");return W(e)?h(e,t,r):"string"==typeof e?p(e,t):b(e)}function a(e){if("number"!=typeof e)throw new TypeError("\"size\" argument must be a number");else if(0>e)throw new RangeError("\"size\" argument must not be negative")}function f(e,t,r){return a(e),0>=e?n(e):void 0===t?n(e):"string"==typeof r?n(e).fill(t,r):n(e).fill(t)}function c(e){return a(e),n(0>e?0:0|g(e))}function p(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!s.isEncoding(t))throw new TypeError("\"encoding\" must be a valid string encoding");var r=0|y(e,t),i=n(r),o=i.write(e,t);return o!==r&&(i=i.slice(0,o)),i}function l(e){for(var t=0>e.length?0:0|g(e.length),r=n(t),o=0;ot||e.byteLength=Q)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Q.toString(16)+" bytes");return 0|e}function y(e,t){if(s.isBuffer(e))return e.length;if(Y(e)||W(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(e).length;default:if(n)return K(e).length;t=(""+t).toLowerCase(),n=!0;}}function m(e,t,r){var n=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if(r>>>=0,t>>>=0,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,r);case"utf8":case"utf-8":return B(this,t,r);case"ascii":return R(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return P(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0;}}function _(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function S(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647r&&(r=-2147483648),r=+r,X(r)&&(r=i?0:e.length-1),0>r&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(0>r)if(i)r=0;else return-1;if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,o){function d(e,t){return 1==a?e[t]:e.readUInt16BE(t*a)}var a=1,s=e.length,f=t.length;if(void 0!==n&&(n=(n+"").toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(2>e.length||2>t.length)return-1;a=2,s/=2,f/=2,r/=2}var c;if(o){var i=-1;for(c=r;cs&&(r=s-f),c=r;0<=c;c--){for(var p=!0,u=0;uo&&(n=o)):n=o;var d=t.length;if(0!=d%2)throw new TypeError("Invalid hex string");n>d/2&&(n=d/2);for(var a=0,i;ai&&(d=i):2==a?(s=e[o+1],128==(192&s)&&(p=(31&i)<<6|63&s,127p||57343p&&(d=p))):void 0}null===d?(d=65533,a=1):65535>>10),d=56320|1023&d),n.push(d),o+=a}return O(n)}function O(e){var t=e.length;if(t<=$)return d.apply(String,e);for(var r="",n=0;nt)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var o="",d=t;de)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function M(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError("\"buffer\" argument must be a Buffer instance");if(t>i||te.length)throw new RangeError("Index out of range")}function U(e,t,r,n){if(r+n>e.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function L(e,t,r,n,i){return t=+t,r>>>=0,i||U(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,i){return t=+t,r>>>=0,i||U(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(e,t,r,n,52,8),r+8}function z(e){if(e=e.trim().replace(ee,""),2>e.length)return"";for(;0!=e.length%4;)e+="=";return e}function H(e){return 16>e?"0"+e.toString(16):e.toString(16)}function K(e,t){t=t||Infinity;for(var r=e.length,n=null,o=[],d=0,i;di){if(!n){if(56319i){-1<(t-=3)&&o.push(239,191,189),n=i;continue}i=(n-55296<<10|i-56320)+65536}else n&&-1<(t-=3)&&o.push(239,191,189);if(n=null,128>i){if(0>(t-=1))break;o.push(i)}else if(2048>i){if(0>(t-=2))break;o.push(192|i>>6,128|63&i)}else if(65536>i){if(0>(t-=3))break;o.push(224|i>>12,128|63&i>>6,128|63&i)}else if(1114112>i){if(0>(t-=4))break;o.push(240|i>>18,128|63&i>>12,128|63&i>>6,128|63&i)}else throw new Error("Invalid code point")}return o}function F(e){for(var t=[],r=0;r(t-=2));++n)i=e.charCodeAt(n),o=i>>8,d=i%256,r.push(d),r.push(o);return r}function V(e){return Z.toByteArray(z(e))}function G(e,t,r,n){for(var o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function W(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function Y(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function X(e){return e!==e}var Z=e("base64-js"),J=e("ieee754");r.Buffer=s,r.SlowBuffer=function(e){return+e!=e&&(e=0),s.alloc(+e)},r.INSPECT_MAX_BYTES=50;var Q=2147483647;r.kMaxLength=Q,s.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(t){return!1}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),s.poolSize=8192,s.from=function(e,t,r){return i(e,t,r)},s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,s.alloc=function(e,t,r){return f(e,t,r)},s.allocUnsafe=function(e){return c(e)},s.allocUnsafeSlow=function(e){return c(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer},s.compare=function(e,t){if(!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=u(r,n);ot&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,o){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),0>t||r>e.length||0>n||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,o>>>=0,this===e)return 0;for(var d=o-n,a=r-t,f=u(d,a),c=this.slice(n,o),p=e.slice(t,r),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-t;if((void 0===r||r>i)&&(r=i),0r||0>t)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return k(this,e,t,r);case"utf8":case"utf-8":return I(this,e,t,r);case"ascii":return x(this,e,t,r);case"latin1":case"binary":return A(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0;}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;s.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),t>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e],o=1,d=0;++d>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e+--t],i=1;0>>=0,t||j(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e],d=1,a=0;++a=d&&(n-=o(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);for(var n=t,i=1,d=this[e+--n];0=i&&(d-=o(2,8*t)),d},s.prototype.readInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||j(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||j(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||j(e,4,this.length),J.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||j(e,4,this.length),J.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||j(e,8,this.length),J.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||j(e,8,this.length),J.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){var d=o(2,8*r)-1;M(this,e,t,r,d,0)}var a=1,s=0;for(this[t]=255&e;++s>>=0,r>>>=0,!n){var d=o(2,8*r)-1;M(this,e,t,r,d,0)}var a=r-1,i=1;for(this[t+a]=255&e;0<=--a&&(i*=256);)this[t+a]=255&e/i;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var d=o(2,8*r-1);M(this,e,t,r,d-1,-d)}var a=0,i=1,s=0;for(this[t]=255&e;++ae&&0==s&&0!==this[t+a-1]&&(s=1),this[t+a]=255&(e/i>>0)-s;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var d=o(2,8*r-1);M(this,e,t,r,d-1,-d)}var a=r-1,i=1,s=0;for(this[t+a]=255&e;0<=--a&&(i*=256);)0>e&&0==s&&0!==this[t+a+1]&&(s=1),this[t+a]=255&(e/i>>0)-s;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,127,-128),0>e&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),0t)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-to)for(d=0;do&&(e=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(0>t||this.length>>=0,r=r===void 0?this.length:r>>>0,e||(e=0);var d;if("number"==typeof e)for(d=t;dn,`Invalid value: ${n}.`),t+="qpzry9x8gf2tvdw0s3jn54khce6mua7l"[n];return t},decode:function(e){r("string"==typeof e,`Invalid base32-encoded string: ${e}.`);let t=[];for(const i of e)r(i in n,`Invalid value: ${i}.`),t.push(n[i]);return t}}},{"./ensure":75}],73:[function(e,t){function r(e){let t=!1,r=!1;for(const n of e)if(t=t||n!==n.toUpperCase(),r=r||n!==n.toLowerCase(),t&&r)return!1;return!0}function n(e){switch(e){case"P2PKH":return 0;case"P2SH":return 8;default:throw new Error(`Invalid type: ${e}.`);}}function i(e){switch(120&e){case 0:return"P2PKH";case 8:return"P2SH";default:throw new Error(`Invalid address type in version byte: ${e}.`);}}function o(e){switch(8*e.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 Error(`Invalid hash size: ${e.length}.`);}}function d(e){switch(7&e){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;}}function a(e){const t=[];for(const r of e)t.push(31&r.charCodeAt(0));return t}function s(e){const t=[];for(let r=0;8>r;++r)t.push(e.and(31).toJSNumber()),e=e.shiftRight(5);return t.reverse()}function f(e,t){const r=a(e).concat([0]);return c(r.concat(t)).equals(0)}function c(e){const t=[656907472481,522768456162,1044723512260,748107326120,130178868336];let r=p(1);for(let n of e){let e=r.shiftRight(35);r=r.and(34359738367).shiftLeft(5).xor(n);for(let n=0;n{let i=0,o=0,d=[];const a=(1<s||0!=s>>t)throw new Error(`Invalid value: ${s}.`);for(i=i<=r;)o-=r,d.push(i>>o&a)}if(!n)0=t||i<{if(!e)throw new Error(t)}},{}],76:[function(e,t){function r(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder,d=e("inherits");d(r,i),r.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},r.prototype.setAutoPadding=function(){},r.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},r.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},r.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},r.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(t){n=t}finally{r(n)}},r.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)},r.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},r.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=r},{inherits:146,"safe-buffer":196,stream:205,string_decoder:206}],77:[function(e,t,r){(function(e){function t(e){return Object.prototype.toString.call(e)}r.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===t(e)},r.isBoolean=function(e){return"boolean"==typeof e},r.isNull=function(e){return null===e},r.isNullOrUndefined=function(e){return null==e},r.isNumber=function(e){return"number"==typeof e},r.isString=function(e){return"string"==typeof e},r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=function(e){return void 0===e},r.isRegExp=function(e){return"[object RegExp]"===t(e)},r.isObject=function(e){return"object"==typeof e&&null!==e},r.isDate=function(e){return"[object Date]"===t(e)},r.isError=function(r){return"[object Error]"===t(r)||r instanceof Error},r.isFunction=function(e){return"function"==typeof e},r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e},r.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":147}],78:[function(e,t){(function(r){function n(e){this.curveType=a[e],this.curveType||(this.curveType={name:e}),this.curve=new o.ec(this.curveType.name),this.keys=void 0}function i(e,t,n){Array.isArray(e)||(e=e.toArray());var i=new r(e);if(n&&i.length>>2),d=0,a=0;d>5]|=128<>>9<<4)+14]=t;for(var r=1732584193,n=-271733879,a=-1732584194,c=271733878,d=0;d>16)+(t>>16)+(r>>16)<<16|65535&r}function i(e,t){return e<>>32-t}var d=e("./make-hash");t.exports=function(e){return d(e,r)}},{"./make-hash":97}],99:[function(e,t){"use strict";function r(e,t){o.call(this,"digest"),"string"==typeof t&&(t=d.from(t));var r="sha512"===e||"sha384"===e?128:64;if(this._alg=e,this._key=t,t.length>r){var n="rmd160"===e?new s:f(e);t=n.update(t).digest()}else t.lengths?t=e(t):t.length>>1],r=a.r28shl(r,i),n=a.r28shl(n,i),a.pc2(r,n,e.keys,d)},n.prototype._update=function(e,t,n,i){var o=this._desState,d=a.readUInt32BE(e,t),s=a.readUInt32BE(e,t+4);a.ip(d,s,o.tmp,0),d=o.tmp[0],s=o.tmp[1],"encrypt"===this.type?this._encrypt(o,d,s,o.tmp,0):this._decrypt(o,d,s,o.tmp,0),d=o.tmp[0],s=o.tmp[1],a.writeUInt32BE(n,d,i),a.writeUInt32BE(n,s,i+4)},n.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,p=f}a.rip(u,p,d,c)},n.prototype._decrypt=function(e,n,o,d,c){for(var p=o,u=n,r=e.keys.length-2;0<=r;r-=2){var i=e.keys[r],l=e.keys[r+1];a.expand(p,e.tmp,0),i^=e.tmp[0],l^=e.tmp[1];var h=a.substitute(i,l),s=a.permute(h),f=p;p=(u^s)>>>0,u=f}a.rip(p,u,d,c)}},{"../des":102,inherits:146,"minimalistic-assert":154}],106:[function(e,t){"use strict";function r(e,t){i.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),n=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:n}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:n}),s.create({type:"decrypt",key:r})]}function n(e){a.call(this,e);var t=new r(this.type,this.options.key);this._edeState=t}var i=e("minimalistic-assert"),o=e("inherits"),d=e("../des"),a=d.Cipher,s=d.DES;o(n,a),t.exports=n,n.create=function(e){return new n(e)},n.prototype._update=function(e,t,r,n){var i=this._edeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},n.prototype._pad=s.prototype._pad,n.prototype._unpad=s.prototype._unpad},{"../des":102,inherits:146,"minimalistic-assert":154}],107:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){var r=e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t];return r>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=255&t>>>16,e[2+r]=255&t>>>8,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var o=0,d=0,a=6;0<=a;a-=2){for(var i=0;24>=i;i+=8)o<<=1,o|=1&t>>>i+a;for(var i=0;24>=i;i+=8)o<<=1,o|=1&e>>>i+a}for(var a=6;0<=a;a-=2){for(var i=1;25>=i;i+=8)d<<=1,d|=1&t>>>i+a;for(var i=1;25>=i;i+=8)d<<=1,d|=1&e>>>i+a}r[n+0]=o>>>0,r[n+1]=d>>>0},r.rip=function(e,t,r,n){for(var o=0,d=0,a=0;4>a;a++)for(var i=24;0<=i;i-=8)o<<=1,o|=1&t>>>i+a,o<<=1,o|=1&e>>>i+a;for(var a=4;8>a;a++)for(var i=24;0<=i;i-=8)d<<=1,d|=1&t>>>i+a,d<<=1,d|=1&e>>>i+a;r[n+0]=o>>>0,r[n+1]=d>>>0},r.pc1=function(e,t,r,n){for(var o=0,d=0,a=7;5<=a;a--){for(var i=0;24>=i;i+=8)o<<=1,o|=1&t>>i+a;for(var i=0;24>=i;i+=8)o<<=1,o|=1&e>>i+a}for(var i=0;24>=i;i+=8)o<<=1,o|=1&t>>i+a;for(var a=1;3>=a;a++){for(var i=0;24>=i;i+=8)d<<=1,d|=1&t>>i+a;for(var i=0;24>=i;i+=8)d<<=1,d|=1&e>>i+a}for(var i=0;24>=i;i+=8)d<<=1,d|=1&e>>i+a;r[n+0]=o>>>0,r[n+1]=d>>>0},r.r28shl=function(e,t){return 268435455&e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,o){for(var d=0,a=0,s=n.length>>>1,f=0;f>>n[f];for(var f=s;f>>n[f];r[o+0]=d>>>0,r[o+1]=a>>>0},r.expand=function(e,t,r){var n=0,o=0;n=(1&e)<<5|e>>>27;for(var d=23;15<=d;d-=4)n<<=6,n|=63&e>>>d;for(var d=11;3<=d;d-=4)o|=63&e>>>d,o<<=6;o|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=o>>>0};var o=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;4>n;n++){var i=63&e>>>18-6*n,d=o[64*n+i];r<<=4,r|=d}for(var n=0;4>n;n++){var i=63&t>>>18-6*n,d=o[256+64*n+i];r<<=4,r|=d}return r>>>0};var d=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>d[r];return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe)return 2===t||5===t?new a([140,123]):new a([140,39]);t=new a(t);for(var r,o;;){for(r=new a(d(h(e/8)));r.bitLength()>e;)r.ishrn(1);if(r.isEven()&&r.iadd(p),r.testn(1)||r.iadd(u),!t.cmp(u))for(;r.mod(s).cmp(S);)r.iadd(v);else if(!t.cmp(l))for(;r.mod(y).cmp(m);)r.iadd(v);if(o=r.shrn(1),n(o)&&n(r)&&i(o)&&i(r)&&c.test(o)&&c.test(r))return r}}var d=e("randombytes");t.exports=o,o.simpleSieve=n,o.fermatTest=i;var a=e("bn.js"),s=new a(24),f=e("miller-rabin"),c=new f,p=new a(1),u=new a(2),l=new a(5),b=new a(16),g=new a(8),y=new a(10),m=new a(3),_=new a(7),S=new a(11),v=new a(4),k=new a(12),I=null},{"bn.js":112,"miller-rabin":152,randombytes:179}],111:[function(e,t){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],112:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{buffer:22,dup:16}],113:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.hmacDRBG=e("./elliptic/hmac-drbg"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec")},{"../package.json":126,"./elliptic/curve":116,"./elliptic/curves":119,"./elliptic/ec":120,"./elliptic/hmac-drbg":123,"./elliptic/utils":125,brorand:21}],114:[function(e,t){"use strict";function r(e,t){this.type=e,this.p=new i(t.p,16),this.red=t.prime?i.red(t.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=t.n&&new i(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=[,,,,],this._wnafT2=[,,,,],this._wnafT3=[,,,,],this._wnafT4=[,,,,]}function n(e,t){this.curve=e,this.type=t,this.precomputed=null}var i=e("bn.js"),o=e("../../elliptic"),d=o.utils.getNAF,s=o.utils.getJSF,a=o.utils.assert;t.exports=r,r.prototype.point=function(){throw new Error("Not implemented")},r.prototype.validate=function(){throw new Error("Not implemented")},r.prototype._fixedNafMul=function(e,t){var r=e._getDoubles(),n=d(t,1),o=(1<=f;t--)c=(c<<1)+n[t];s.push(c)}for(var p=this.jpoint(null,null,null),a=this.jpoint(null,null,null),u=o;0c)break;var i=s[c];a(0!==i),f="affine"===e.type?0>1]):f.mixedAdd(o[-i-1>>1].neg()):0>1]):f.add(o[-i-1>>1].neg())}return"affine"===e.type?f.toP():f},r.prototype._wnafMulAdd=function(e,t,r,n){for(var o=this._wnafT1,f=this._wnafT2,c=this._wnafT3,u=0,l=0;ll)break;for(var _=0;_>1]:0>w&&(i=f[_][-w-1>>1].neg());I="affine"===i.type?I.mixedAdd(i):I.add(i)}}for(var l=0;l":""},n.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},n.prototype._extDbl=function(){var t=this.x.redSqr(),r=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var i=this.curve._mulA(t),o=this.x.redAdd(this.y).redSqr().redISub(t).redISub(r),e=i.redAdd(r),d=e.redSub(n),a=i.redSub(r),s=o.redMul(d),f=e.redMul(a),c=o.redMul(a),p=d.redMul(e);return this.curve.point(s,f,p,c)},n.prototype._projDbl=function(){var t=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),n=this.y.redSqr(),i,o,d;if(this.curve.twisted){var a=this.curve._mulA(r),e=a.redAdd(n);if(this.zOne)i=t.redSub(r).redSub(n).redMul(e.redSub(this.curve.two)),o=e.redMul(a.redSub(n)),d=e.redSqr().redSub(e).redSub(e);else{var s=this.z.redSqr(),f=e.redSub(s).redISub(s);i=t.redSub(r).redISub(n).redMul(f),o=e.redMul(a.redSub(n)),d=e.redMul(f)}}else{var a=r.redAdd(n),s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),f=a.redSub(s).redSub(s);i=this.curve._mulC(t.redISub(a)).redMul(f),o=this.curve._mulC(a).redMul(r.redISub(n)),d=a.redMul(f)}return this.curve.point(i,o,d)},n.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},n.prototype._extAdd=function(t){var r=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),n=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),o=this.z.redMul(t.z.redAdd(t.z)),d=n.redSub(r),e=o.redSub(i),a=o.redAdd(i),s=n.redAdd(r),f=d.redMul(e),c=a.redMul(s),p=d.redMul(s),u=e.redMul(a);return this.curve.point(f,c,u,p)},n.prototype._projAdd=function(t){var r=this.z.redMul(t.z),n=r.redSqr(),i=this.x.redMul(t.x),o=this.y.redMul(t.y),d=this.curve.d.redMul(i).redMul(o),e=n.redSub(d),a=n.redAdd(d),s=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(i).redISub(o),f=r.redMul(e).redMul(s),c,p;return this.curve.twisted?(c=r.redMul(a).redMul(o.redSub(this.curve._mulA(i))),p=e.redMul(a)):(c=r.redMul(a).redMul(o.redSub(i)),p=this.curve._mulC(e).redMul(a)),this.curve.point(f,c,p)},n.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},n.prototype.mul=function(e){return this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},n.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2)},n.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},n.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},n.prototype.getX=function(){return this.normalize(),this.x.fromRed()},n.prototype.getY=function(){return this.normalize(),this.y.fromRed()},n.prototype.toP=n.prototype.normalize,n.prototype.mixedAdd=n.prototype.add},{"../../elliptic":113,"../curve":116,"bn.js":20,inherits:146}],116:[function(e,t,r){arguments[4][55][0].apply(r,arguments)},{"./base":114,"./edwards":115,"./mont":117,"./short":118,dup:55}],117:[function(e,t){"use strict";function r(e){a.call(this,"mont",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.i4=new o(4).toRed(this.red).redInvm(),this.two=new o(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function n(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new o(t,16),this.z=new o(r,16),!this.x.red&&(this.x=this.x.toRed(this.curve.red)),!this.z.red&&(this.z=this.z.toRed(this.curve.red)))}var i=e("../curve"),o=e("bn.js"),d=e("inherits"),a=i.base;d(r,a),t.exports=r,r.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t),i=n.redSqrt();return 0===i.redSqr().cmp(n)},d(n,a.BasePoint),r.prototype.point=function(e,t){return new n(this,e,t)},r.prototype.pointFromJSON=function(e){return n.fromJSON(this,e)},n.prototype.precompute=function(){},n.fromJSON=function(e,t){return new n(e,t[0],t[1]||e.one)},n.prototype.inspect=function(){return this.isInfinity()?"":""},n.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},n.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),r=this.x.redSub(this.z),n=r.redSqr(),i=t.redSub(n),o=t.redMul(n),d=i.redMul(n.redAdd(this.curve.a24.redMul(i)));return this.curve.point(o,d)},n.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},n.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z),d=o.redMul(r),a=i.redMul(n),s=t.z.redMul(d.redAdd(a).redSqr()),f=t.x.redMul(d.redISub(a).redSqr());return this.curve.point(s,f)},n.prototype.mul=function(e){for(var r=e.clone(),t=this,n=this.curve.point(null,null),o=this,d=[];0!==r.cmpn(0);r.ishrn(1))d.push(r.andln(1));for(var a=d.length-1;0<=a;a--)0===d[a]?(t=t.diffAdd(n,o),n=n.dbl()):(n=t.diffAdd(n,o),t=t.dbl());return n},n.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},n.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},n.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../curve":116,"bn.js":20,inherits:146}],118:[function(e,t){"use strict";function r(e){c.call(this,"short",e),this.a=new a(e.a,16).toRed(this.red),this.b=new a(e.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(e),this._endoWnafT1=[,,,,],this._endoWnafT2=[,,,,]}function n(e,t,r,n){c.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new a(t,16),this.y=new a(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 i(e,t,r,n){c.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new a(0)):(this.x=new a(t,16),this.y=new a(r,16),this.z=new a(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}var o=e("../curve"),d=e("../../elliptic"),a=e("bn.js"),s=e("inherits"),c=o.base,p=d.utils.assert;s(r,c),t.exports=r,r.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new a(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=0>n[0].cmp(n[1])?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)r=new a(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],p(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}var o;return o=e.basis?e.basis.map(function(e){return{a:new a(e.a,16),b:new a(e.b,16)}}):this._getEndoBasis(r),{beta:t,lambda:r,basis:o}}},r.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:a.mont(e),r=new a(2).toRed(t).redInvm(),n=r.redNeg(),i=new a(3).toRed(t).redNeg().redSqrt().redMul(r),o=n.redAdd(i).fromRed(),d=n.redSub(i).fromRed();return[o,d]},r.prototype._getEndoBasis=function(e){for(var t=this.n.shrn(f(this.n.bitLength()/2)),n=e,o=this.n.clone(),d=new a(1),s=new a(0),c=new a(0),p=new a(1),u=0,i,l,h,b,g,m,_,S,r,v;0!==n.cmpn(0);){v=o.div(n),S=o.sub(v.mul(n)),r=c.sub(v.mul(d));var k=p.sub(v.mul(s));if(!h&&0>S.cmp(t))i=_.neg(),l=d,h=S.neg(),b=r;else if(h&&2==++u)break;_=S,o=n,n=S,c=d,d=r,p=s,s=k}g=S.neg(),m=r;var y=h.sqr().add(b.sqr()),I=g.sqr().add(m.sqr());return 0<=I.cmp(y)&&(g=i,m=l),h.sign&&(h=h.neg(),b=b.neg()),g.sign&&(g=g.neg(),m=m.neg()),[{a:h,b:b},{a:g,b:m}]},r.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),d=i.mul(r.a),a=o.mul(n.a),s=i.mul(r.b),f=o.mul(n.b),c=e.sub(d).sub(a),p=s.add(f).neg();return{k1:c,k2:p}},r.prototype.pointFromX=function(e,t){t=new a(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt(),i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},r.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},r.prototype._endoWnafMulAdd=function(e,t){for(var r=this._endoWnafT1,n=this._endoWnafT2,o=0;o":""},n.prototype.isInfinity=function(){return this.inf},n.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},n.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),d=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,d)},n.prototype.getX=function(){return this.x.fromRed()},n.prototype.getY=function(){return this.y.fromRed()},n.prototype.mul=function(e){return e=new a(e,16),this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},n.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},n.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},n.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.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 t},n.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e},s(i,c.BasePoint),r.prototype.jpoint=function(e,t,r){return new i(this,e,t,r)},i.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},i.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},i.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(t),o=e.x.redMul(n),d=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),s=i.redSub(o),f=d.redSub(a);if(0===s.cmpn(0))return 0===f.cmpn(0)?this.dbl():this.curve.jpoint(null,null,null);var r=s.redSqr(),c=r.redMul(s),p=i.redMul(r),u=f.redSqr().redIAdd(c).redISub(p).redISub(p),l=f.redMul(p.redISub(u)).redISub(d.redMul(c)),h=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(u,l,h)},i.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,i=e.x.redMul(t),o=this.y,d=e.y.redMul(t).redMul(this.z),a=n.redSub(i),s=o.redSub(d);if(0===a.cmpn(0))return 0===s.cmpn(0)?this.dbl():this.curve.jpoint(null,null,null);var r=a.redSqr(),f=r.redMul(a),c=n.redMul(r),p=s.redSqr().redIAdd(f).redISub(c).redISub(c),u=s.redMul(c.redISub(p)).redISub(o.redMul(f)),l=this.z.redMul(a);return this.curve.jpoint(p,u,l)},i.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r":""},i.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":113,"../curve":116,"bn.js":20,inherits:146}],119:[function(e,t,r){"use strict";function n(e){this.curve="short"===e.type?new a.curve.short(e):"edwards"===e.type?new a.curve.edwards(e):new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function i(e,t){Object.defineProperty(o,e,{configurable:!0,enumerable:!0,get:function(){var r=new n(t);return Object.defineProperty(o,e,{configurable:!0,enumerable:!0,value:r}),r}})}var o=r,d=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;o.PresetCurve=n,i("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:d.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),i("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:d.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),i("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:d.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),i("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:d.sha256,gRed:!1,g:["9"]}),i("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:d.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var f;try{f=e("./precomputed/secp256k1")}catch(t){f=void 0}i("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:d.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",f]})},{"../elliptic":113,"./precomputed/secp256k1":124,"hash.js":130}],120:[function(e,t){"use strict";function r(e){return this instanceof r?void("string"==typeof e&&(d(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.shrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash):new r(e)}var n=e("bn.js"),o=e("../../elliptic"),i=o.utils,d=i.assert,a=e("./key"),f=e("./signature");t.exports=r,r.prototype.keyPair=function(e){return new a(this,e)},r.prototype.keyFromPrivate=function(e,t){return a.fromPrivate(this,e,t)},r.prototype.keyFromPublic=function(e,t){return a.fromPublic(this,e,t)},r.prototype.genKeyPair=function(e){e||(e={});var t=new o.hmacDRBG({hash:this.hash,pers:e.pers,entropy:e.entropy||o.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new n(2));do{var d=new n(t.generate(r));if(0u;u++)p.unshift(0);for(var i=e.toArray(),u=i.length;u=b.cmpn(1)||0<=b.cmp(h))continue;var g=this.g.mul(b);if(g.isInfinity())continue;var y=g.getX().mod(this.n);if(0===y.cmpn(0))continue;var m=b.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e)).mod(this.n);if(0===m.cmpn(0))continue;return a.canonical&&0d.cmpn(1)||0<=d.cmp(this.n))return!1;if(0>r.cmpn(1)||0<=r.cmp(this.n))return!1;var a=r.invm(this.n),s=a.mul(e).mod(this.n),c=a.mul(d).mod(this.n),u=this.g.mulAdd(s,i.getPublic(),c);return!u.isInfinity()&&0===u.getX().mod(this.n).cmp(d)}},{"../../elliptic":113,"./key":121,"./signature":122,"bn.js":20}],121:[function(e,t){"use strict";function r(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var n=e("bn.js"),i=e("../../elliptic"),o=i.utils;t.exports=r,r.fromPublic=function(e,t,n){return t instanceof r?t:new r(e,{pub:t,pubEnc:n})},r.fromPrivate=function(e,t,n){return t instanceof r?t:new r(e,{priv:t,privEnc:n})},r.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},r.prototype.getPublic=function(e,t){if(this.pub||(this.pub=this.ec.g.mul(this.priv)),"string"==typeof e&&(t=e,e=null),!t)return this.pub;for(var r=this.ec.curve.p.byteLength(),n=this.pub.getX().toArray(),d=n.length;d"}},{"../../elliptic":113,"bn.js":20}],122:[function(e,t){"use strict";function r(e,t){return e instanceof r?e:void(this._importDER(e,t)||(d(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16)))}var n=e("bn.js"),i=e("../../elliptic"),o=i.utils,d=o.assert;t.exports=r,r.prototype._importDER=function(e,t){if(e=o.toArray(e,t),6>e.length||48!==e[0]||2!==e[2])return!1;var r=e[1];if(1+r>e.length)return!1;var i=e[3];if(128<=i)return!1;if(4+i+2>=e.length)return!1;if(2!==e[4+i])return!1;var d=e[5+i];return!(128<=d)&&!(4+i+2+d>e.length)&&(this.r=new n(e.slice(4,4+i)),this.s=new n(e.slice(4+i+2,4+i+2+d)),!0)},r.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r));var n=t.length+r.length+4,i=[48,n,2,t.length];return i=i.concat(t,[2,r.length],r),o.encode(i,e)}},{"../../elliptic":113,"bn.js":20}],123:[function(e,t){"use strict";function r(e){if(!(this instanceof r))return new r(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this.reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=o.toArray(e.entropy,e.entropyEnc),n=o.toArray(e.nonce,e.nonceEnc),i=o.toArray(e.pers,e.persEnc);d(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,i)}var n=e("hash.js"),i=e("../elliptic"),o=i.utils,d=o.assert;t.exports=r,r.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=Array(this.outLen/8),this.V=Array(this.outLen/8);for(var o=0;o=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this.reseed=1},r.prototype.generate=function(e,t,r,n){if(this.reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=o.toArray(r,n),this._update(r));for(var i=[];i.length>8,d=255&i;o?r.push(o,d):r.push(d)}else if("hex"===t){e=e.replace(/[^a-z0-9]+/ig,""),0!=e.length%2&&(e="0"+e);for(var n=0;n(n>>1)-1?(n>>1)-a:a,o.isubn(d)}else d=0;r.push(d);for(var s=0!==o.cmpn(0)&&0===o.andln(n-1)?t+1:1,f=1;fe||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,a,s,f,i;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length))if(t=arguments[1],t instanceof Error)throw t;else{var c=new Error("Uncaught, unspecified \"error\" event. ("+t+")");throw c.context=t,c}if(r=this._events[e],d(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),r.apply(this,s);}else if(o(r))for(s=Array.prototype.slice.call(arguments,1),i=r.slice(),a=i.length,f=0;fi&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function r(){this.removeListener(e,r),i||(i=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var i=!1;return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var r,d,a,s;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],a=r.length,d=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;0d)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(d,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[],t},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],128:[function(e,t){var r=e("safe-buffer").Buffer,n=e("md5.js");t.exports=function(e,t,i,o){if(r.isBuffer(e)||(e=r.from(e,"binary")),t&&(r.isBuffer(t)||(t=r.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var d=i/8,a=r.alloc(d),s=r.alloc(o||0),f=r.alloc(0),c;0=this._blockSize;){for(var d=this._blockOffset;d=this._delta8){e=this.pending;var n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),0===this.pending.length&&(this.pending=null),e=o.join32(e,0,e.length-n,this.endian);for(var r=0;r>>24,o[d++]=255&e>>>16,o[d++]=255&e>>>8,o[d++]=255&e}else for(o[d++]=255&e,o[d++]=255&e>>>8,o[d++]=255&e>>>16,o[d++]=255&e>>>24,o[d++]=0,o[d++]=0,o[d++]=0,o[d++]=0,i=8;ithis.blockSize&&(e=new this.Hash().update(e).digest()),o(e.length<=this.blockSize);for(var t=e.length;t=e?t^r^n:31>=e?t&r|~t&n:47>=e?(t|~r)^n:63>=e?t&n|r&~n:t^(r|~n)}function d(e){return 15>=e?0:31>=e?1518500249:47>=e?1859775393:63>=e?2400959708:2840853838}function a(e){return 15>=e?1352829926:31>=e?1548603684:47>=e?1836072691:63>=e?2053994217:0}var f=e("./utils"),c=e("./common"),p=f.rotl32,u=f.sum32,l=f.sum32_3,h=f.sum32_4,b=c.BlockHash;f.inherits(i,b),n.ripemd160=i,i.blockSize=512,i.outSize=160,i.hmacStrength=192,i.padLength=64,i.prototype._update=function(e,t){for(var n=this.h[0],i=this.h[1],f=this.h[2],c=this.h[3],b=this.h[4],m=n,_=i,S=f,v=c,k=b,I=0,x;80>I;I++)x=u(p(h(n,o(I,i,f,c),e[g[I]+t],d(I)),y[I]),b),n=b,b=c,c=p(f,10),f=i,i=x,x=u(p(h(m,o(79-I,_,S,v),e[r[I]+t],a(I)),s[I]),k),m=k,k=v,v=p(S,10),S=_,_=x;x=l(this.h[1],f,v),this.h[1]=l(this.h[2],c,k),this.h[2]=l(this.h[3],b,m),this.h[3]=l(this.h[4],n,_),this.h[4]=l(this.h[0],i,S),this.h[0]=x},i.prototype._digest=function(e){return"hex"===e?f.toHex32(this.h,"little"):f.split32(this.h,"little")};var g=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],r=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],y=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],s=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},{"./common":131,"./utils":141}],134:[function(e,t,r){"use strict";r.sha1=e("./sha/1"),r.sha224=e("./sha/224"),r.sha256=e("./sha/256"),r.sha384=e("./sha/384"),r.sha512=e("./sha/512")},{"./sha/1":135,"./sha/224":136,"./sha/256":137,"./sha/384":138,"./sha/512":139}],135:[function(e,t){"use strict";function r(){return this instanceof r?void(d.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=Array(80)):new r}var n=e("../utils"),i=e("../common"),o=e("./common"),f=n.rotl32,p=n.sum32,u=n.sum32_5,l=o.ft_1,d=i.BlockHash,h=[1518500249,1859775393,2400959708,3395469782];n.inherits(r,d),t.exports=r,r.blockSize=512,r.outSize=160,r.hmacStrength=80,r.padLength=64,r.prototype._update=function(r,n){for(var o=this.W,g=0;16>g;g++)o[g]=r[n+g];for(;go;o++)n[o]=t[r+o];for(;od&&(d+=4294967296),d}function o(e,t,n,i,o,d){var a=t&i^~t&d;return 0>a&&(a+=4294967296),a}function d(e,t,n,i,o){var d=e&n^e&o^n&o;return 0>d&&(d+=4294967296),d}function a(e,t,n,i,o,d){var a=t&i^t&d^i&d;return 0>a&&(a+=4294967296),a}function s(e,t){var n=m(e,t,28),i=m(t,e,2),o=m(t,e,7),d=n^i^o;return 0>d&&(d+=4294967296),d}function f(e,t){var n=_(e,t,28),i=_(t,e,2),o=_(t,e,7),d=n^i^o;return 0>d&&(d+=4294967296),d}function c(e,t){var n=m(e,t,14),i=m(e,t,18),o=m(t,e,9),d=n^i^o;return 0>d&&(d+=4294967296),d}function p(e,t){var n=_(e,t,14),i=_(e,t,18),o=_(t,e,9),d=n^i^o;return 0>d&&(d+=4294967296),d}function u(e,t){var n=m(e,t,1),i=m(e,t,8),o=S(e,t,7),d=n^i^o;return 0>d&&(d+=4294967296),d}function l(e,t){var n=_(e,t,1),i=_(e,t,8),o=v(e,t,7),d=n^i^o;return 0>d&&(d+=4294967296),d}function h(e,t){var n=m(e,t,19),i=m(t,e,29),o=S(e,t,6),d=n^i^o;return 0>d&&(d+=4294967296),d}function b(e,t){var n=_(e,t,19),i=_(t,e,29),o=v(e,t,6),d=n^i^o;return 0>d&&(d+=4294967296),d}var i=e("../utils"),g=e("../common"),y=e("minimalistic-assert"),m=i.rotr64_hi,_=i.rotr64_lo,S=i.shr64_hi,v=i.shr64_lo,k=i.sum64,I=i.sum64_hi,x=i.sum64_lo,A=i.sum64_4_hi,w=i.sum64_4_lo,E=i.sum64_5_hi,P=i.sum64_5_lo,B=g.BlockHash,O=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];i.inherits(r,B),t.exports=r,r.blockSize=1024,r.outSize=512,r.hmacStrength=192,r.padLength=128,r.prototype._prepareBlock=function(e,t){for(var r=this.W,n=0;32>n;n++)r[n]=e[t+n];for(;n>>3},r.g1_256=function(e){return a(e,17)^a(e,19)^e>>>10}},{"../utils":141}],141:[function(e,t,r){"use strict";function n(e){return(e>>>24|65280&e>>>8|16711680&e<<8|(255&e)<<24)>>>0}function o(e){return 1===e.length?"0"+e:e}function d(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var a=e("minimalistic-assert"),i=e("inherits");r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if(!("string"==typeof e))for(n=0;n>8,d=255&i;o?r.push(o,d):r.push(d)}else if("hex"===t)for(e=e.replace(/[^a-z0-9]+/ig,""),0!=e.length%2&&(e="0"+e),n=0;n>>0}return d},r.split32=function(e,t){for(var r=Array(4*e.length),n=0,i=0,o;n>>24,r[i+1]=255&o>>>16,r[i+2]=255&o>>>8,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=255&o>>>16,r[i+1]=255&o>>>8,r[i]=255&o);return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(t,r,n,i,o){return t+r+n+i+o>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=e[t+1],d=n+o>>>0,a=(d>>0,e[t+1]=d},r.sum64_hi=function(e,t,r,n){var i=(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,d,a){var s=0,f=t;f=f+n>>>0,s+=f>>0,s+=f>>0,s+=f>>0},r.sum64_4_lo=function(e,t,r,n,i,o,d,a){return t+n+o+a>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,d,a,s,f){var c=0,p=t;p=p+n>>>0,c+=p>>0,c+=p>>0,c+=p>>0,c+=p>>0},r.sum64_5_lo=function(e,t,r,n,i,o,d,a,s,f){return t+n+o+a+f>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:142,"minimalistic-assert":154}],142:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],143:[function(e,t){"use strict";function r(e){if(!(this instanceof r))return new r(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),n=i.toArray(e.nonce,e.nonceEnc||"hex"),d=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,d)}var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");t.exports=r,r.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=Array(this.outLen/8),this.V=Array(this.outLen/8);for(var o=0;o=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},r.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,l=-7,h=n?f-1:0,i=n?-1:1,d=t[r+h],s,e;for(h+=i,s=d&(1<<-l)-1,d>>=-l,l+=c;0>=-l,l+=a;0>1,_=23===l?5.960464477539063e-8-6.617444900424222e-24:0,S=u?0:h-1,i=u?1:-1,d=0>a||0===a&&0>1/a?1:0,v,k,m;for(a=s(a),isNaN(a)||a===Infinity?(k=isNaN(a)?1:0,v=g):(v=f(r(a)/t),1>a*(m=o(2,-v))&&(v--,m*=2),a+=1<=v+y?_/m:_*o(2,1-y),2<=a*m&&(v++,m/=2),v+y>=g?(k=0,v=g):1<=v+y?(k=(a*m-1)*o(2,l),v+=y):(k=a*o(2,y-1)*o(2,l),v=0));8<=l;n[p+S]=255&k,S+=i,k/=256,l-=8);for(v=v<"']/g,pt=RegExp(ft.source),ut=RegExp(ct.source),ht=/<%-([\s\S]+?)%>/g,bt=/<%([\s\S]+?)%>/g,yt=/<%=([\s\S]+?)%>/g,lt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,gt=/^\w*$/,mt=/^\./,_t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,St=/[\\^$.*+?()[\]{}|]/g,vt=RegExp(St.source),kt=/^\s+|\s+$/g,It=/^\s+/,xt=/\s+$/,At=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,wt=/\{\n\/\* \[wrapped with (.+)\] \*/,Et=/,? & /,Pt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Bt=/\\(\\)?/g,Ot=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Rt=/\w*$/,Tt=/^[-+]0x[0-9a-f]+$/i,Nt=/^0b[01]+$/i,Ct=/^\[object .+?Constructor\]$/,jt=/^0o[0-7]+$/i,Mt=/^(?:0|[1-9]\d*)$/,Ut=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Lt=/($^)/,Dt=/['\n\r\u2028\u2029\\]/g,zt="\\ud800-\\udfff",Ht="\\u2700-\\u27bf",Kt="a-z\\xdf-\\xf6\\xf8-\\xff",Ft="A-Z\\xc0-\\xd6\\xd8-\\xde",qt="\\xac\\xb1\\xd7\\xf7"+"\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf"+"\\u2000-\\u206f"+" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Vt="['\u2019]",Gt="["+qt+"]",Wt="["+("\\u0300-\\u036f"+"\\ufe20-\\ufe2f"+"\\u20d0-\\u20ff")+"]",Yt="\\d+",Xt="["+Kt+"]",Zt="[^"+zt+qt+Yt+Ht+Kt+Ft+"]",Jt="\\ud83c[\\udffb-\\udfff]",Qt="[^"+zt+"]",$t="(?:\\ud83c[\\udde6-\\uddff]){2}",er="[\\ud800-\\udbff][\\udc00-\\udfff]",tr="["+Ft+"]",rr="(?:"+Xt+"|"+Zt+")",nr="(?:"+Vt+"(?:d|ll|m|re|s|t|ve))?",ir="(?:"+Vt+"(?:D|LL|M|RE|S|T|VE))?",or="(?:"+Wt+"|"+Jt+")"+"?",dr="["+"\\ufe0e\\ufe0f"+"]?",ar="(?:"+"\\u200d"+"(?:"+[Qt,$t,er].join("|")+")"+dr+or+")*",sr=dr+or+ar,fr="(?:"+["["+Ht+"]",$t,er].join("|")+")"+sr,cr="(?:"+[Qt+Wt+"?",Wt,$t,er,"["+zt+"]"].join("|")+")",pr=/['’]/g,ur=/[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]/g,lr=RegExp(Jt+"(?="+Jt+")|"+cr+sr,"g"),hr=RegExp([tr+"?"+Xt+"+"+nr+"(?="+[Gt,tr,"$"].join("|")+")","(?:"+tr+"|"+Zt+")"+"+"+ir+"(?="+[Gt,tr+rr,"$"].join("|")+")",tr+"?"+rr+"+"+nr,tr+"+"+ir,"\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",Yt,fr].join("|"),"g"),br=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/,gr=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,yr=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],mr=-1,_r={};_r[Je]=_r[Qe]=_r[$e]=_r[et]=_r[tt]=_r[rt]=_r[nt]=_r[it]=_r[ot]=!0,_r[Ne]=_r[Ce]=_r[Xe]=_r[je]=_r[Ze]=_r[Me]=_r[Ue]=_r[Le]=_r[ze]=_r[He]=_r[Ke]=_r[qe]=_r[Ve]=_r[Ge]=_r[Ye]=!1;var Sr={};Sr[Ne]=Sr[Ce]=Sr[Xe]=Sr[Ze]=Sr[je]=Sr[Me]=Sr[Je]=Sr[Qe]=Sr[$e]=Sr[et]=Sr[tt]=Sr[ze]=Sr[He]=Sr[Ke]=Sr[qe]=Sr[Ve]=Sr[Ge]=Sr[We]=Sr[rt]=Sr[nt]=Sr[it]=Sr[ot]=!0,Sr[Ue]=Sr[Le]=Sr[Ye]=!1;var vr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kr=parseFloat,Ir=parseInt,xr="object"==typeof e&&e&&e.Object===Object&&e,Ar="object"==typeof self&&self&&self.Object===Object&&self,wr=xr||Ar||Function("return this")(),Er="object"==typeof r&&r&&!r.nodeType&&r,Pr=Er&&"object"==typeof t&&t&&!t.nodeType&&t,Br=Pr&&Pr.exports===Er,Or=Br&&xr.process,Rr=function(){try{return Or&&Or.binding&&Or.binding("util")}catch(t){}}(),Tr=Rr&&Rr.isArrayBuffer,Nr=Rr&&Rr.isDate,Cr=Rr&&Rr.isMap,jr=Rr&&Rr.isRegExp,Mr=Rr&&Rr.isSet,Ur=Rr&&Rr.isTypedArray,Lr=T("length"),Dr=N({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),zr=N({"&":"&","<":"<",">":">",'"':""","'":"'"}),Hr=N({"&":"&","<":"<",">":">",""":"\"","'":"'"}),Kr=function e(t){function r(e){if(Fo(e)&&!Ts(e)&&!(e instanceof x)){if(e instanceof _)return e;if(Nd.call(e,"__wrapped__"))return lo(e)}return new _(e)}function i(){}function _(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function x(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Re,this.__views__=[]}function N(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function $t(e,t,r,n,i,o){var d=t&ue,a=t&le,f;if(r&&(f=i?r(e,n,i,o):r(e)),void 0!==f)return f;if(!Ko(e))return e;var c=Ts(e);if(!c){var p=Ka(e),u=p==Le||p==De;if(Cs(e))return Mn(e,d);if(p!=Ke&&p!=Ne&&(!u||i)){if(!Sr[p])return i?e:{};f=Ki(e,p,$t,d)}else if(f=a||u?{}:Hi(e),!d)return a?Jn(e,Xt(f,e)):Zn(e,Yt(f,e))}else if(f=zi(e),!d)return Yn(e,f);o||(o=new Pt);var l=o.get(e);if(l)return l;o.set(e,f);var h=t&he?a?Bi:Pi:a?id:nd,b=c?void 0:h(e);return s(b||e,function(n,i){b&&(i=n,n=e[i]),Vt(f,i,$t(n,t,r,i,e,o))}),f}function er(e){var t=nd(e);return function(r){return tr(r,e,t)}}function tr(e,t,r){var n=r.length;if(null==e)return!n;for(e=xd(e);n--;){var i=r[n],o=t[i],d=e[i];if(void 0===d&&!(i in e)||!o(d))return!1}return!0}function rr(e,t,r){if("function"!=typeof e)throw new Ed(fe);return Va(function(){e.apply(void 0,r)},t)}function nr(e,t,r,n){var i=-1,o=g,d=!0,a=e.length,s=[],f=t.length;if(!a)return s;r&&(t=m(t,D(r))),n?(o=y,d=!1):t.length>=se&&(o=H,d=!1,t=new de(t));outer:for(;++ir&&(r=-r>i?0:i+r),n=void 0===n||n>i?i:Zo(n),0>n&&(n+=i),n=r>n?0:Jo(n);rt}function xr(e,t){return null!=e&&Nd.call(e,t)}function Ar(e,t){return null!=e&&t in xd(e)}function Er(e,t,r){return e>=fa(t,r)&&et?r:0,Vi(t,r)?e[t]:void 0}function nn(e,t,r){var n=-1;t=m(t.length?t:[ud],D(Ti()));var i=Jr(e,function(e){var r=m(t,function(t){return t(e)});return{criteria:r,index:++n,value:e}});return j(i,function(e,t){return Vn(e,t,r)})}function on(e,t){return dn(e,t,function(t,r){return rd(e,r)})}function dn(e,t,r){for(var n=-1,i=t.length,o={};++nt||t>Be)return r;do t%2&&(r+=e),t=ra(t/2),t&&(e+=e);while(t);return r}function ln(e,t){return Ga(no(e,t,ud),e+"")}function hn(e){return Ht(ad(e))}function bn(e,t){var r=ad(e);return fo(r,Qt(t,0,r.length))}function gn(e,t,r,n){if(!Ko(e))return e;t=Cn(t,e);for(var i=-1,o=t.length,d=e;null!=d&&++it&&(t=-t>i?0:i+t),r=r>i?i:r,0>r&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=_d(i);++n>>1){for(;n>>1,d=e[o];null!==d&&!Wo(d)&&(r?d<=t:d=se){var f=t?null:La(e);if(f)return $(f);d=!1,i=H,s=new de}else s=t?[]:a;outer:for(;++nn)return n?An(e[0]):[];for(var i=-1,o=_d(n);++i=n?e:mn(e,t,r)}function Mn(e,t){if(t)return e.slice();var r=e.length,n=Fd?Fd(r):new e.constructor(r);return e.copy(n),n}function Un(e){var t=new e.constructor(e.byteLength);return new Kd(t).set(new Kd(e)),t}function Ln(e,t){var r=t?Un(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}function Dn(e,t,r){var i=t?r(Z(e),ue):Z(e);return v(i,n,new e.constructor)}function zn(e){var t=new e.constructor(e.source,Rt.exec(e));return t.lastIndex=e.lastIndex,t}function Hn(e,t,r){var n=t?r($(e),ue):$(e);return v(n,o,new e.constructor)}function Kn(e){return Pa?xd(Pa.call(e)):{}}function Fn(e,t){var r=t?Un(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function qn(e,t){if(e!==t){var r=void 0!==e,n=null===e,i=e===e,o=Wo(e),d=void 0!==t,a=null===t,s=t===t,f=Wo(t);if(!a&&!f&&!o&&e>t||o&&d&&s&&!a&&!f||n&&d&&s||!r&&s||!i)return 1;if(!n&&!o&&!f&&e=a)return s;var f=r[n];return s*("desc"==f?-1:1)}return e.index-t.index}function Gn(e,t,r,n){for(var i=-1,o=e.length,d=r.length,a=-1,s=t.length,f=sa(o-d,0),c=_d(s+f),p=!n;++ai?void 0:o,i=1),t=xd(t);++no&&a[0]!==f&&a[o-1]!==f?[]:Q(a,f);if(o-=c.length,or)return r?un(t,e):t;var n=un(t,ta(e/ne(t)));return W(t)?jn(ie(n),0,e).join(""):n.slice(0,e)}function hi(e,t,r,n){function i(){for(var t=-1,s=arguments.length,f=-1,c=n.length,p=_d(c+s),u=this&&this!==wr&&this instanceof i?a:e;++fa))return!1;var f=o.get(e);if(f&&o.get(t))return f==t;var c=-1,p=!0,u=r&ge?new de:void 0;for(o.set(e,t),o.set(t,e);++ct.length?e:hr(e,mn(t,0,-1))}function oo(e,t){for(var r=e.length,n=fa(t.length,r),i=Yn(e),o;n--;)o=t[n],e[n]=Vi(o,r)?i[o]:void 0;return e}function ao(e,t,r){var n=t+"";return Ga(e,Fi(n,uo(Li(n),r)))}function so(e){var t=0,r=0;return function(){var n=ca(),i=16-(n-r);if(r=n,!(0=800)return arguments[0];return e.apply(void 0,arguments)}}function fo(e,t){var r=-1,n=e.length;for(t=void 0===t?n:t;++ri&&(i=sa(n+i,0)),E(e,Ti(t,3),i)}function bo(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=n-1;return void 0!==r&&(i=Zo(r),i=0>r?sa(n+i,0):fa(i,n-1)),E(e,Ti(t,3),i,!0)}function go(e){var t=null==e?0:e.length;return t?sr(e,1):[]}function yo(e){return e&&e.length?e[0]:void 0}function mo(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}function _o(e,t){return e&&e.length&&t&&t.length?sn(e,t):e}function So(e){return null==e?e:la.call(e)}function vo(e){if(!(e&&e.length))return[];var t=0;return e=b(e,function(e){if(Uo(e))return t=sa(e.length,t),!0}),U(t,function(t){return m(e,T(t))})}function ko(e,t){if(!(e&&e.length))return[];var r=vo(e);return null==t?r:m(r,function(e){return d(t,void 0,e)})}function Io(e){var t=r(e);return t.__chain__=!0,t}function xo(e,t){return t(e)}function Ao(e,t){var r=Ts(e)?s:Ra;return r(e,Ti(t,3))}function wo(e,t){var r=Ts(e)?c:Ta;return r(e,Ti(t,3))}function Eo(e,t){var r=Ts(e)?m:Jr;return r(e,Ti(t,3))}function Po(e,t,r){return t=r?void 0:t,t=e&&null==t?e.length:t,Si(e,xe,void 0,void 0,void 0,void 0,t)}function Bo(e,t){var r;if("function"!=typeof t)throw new Ed(fe);return e=Zo(e),function(){return 0<--e&&(r=t.apply(this,arguments)),1>=e&&(t=void 0),r}}function Oo(e,t,r){t=r?void 0:t;var n=Si(e,Se,void 0,void 0,void 0,void 0,void 0,t);return n.placeholder=Oo.placeholder,n}function Ro(e,t,r){t=r?void 0:t;var n=Si(e,ve,void 0,void 0,void 0,void 0,void 0,t);return n.placeholder=Ro.placeholder,n}function To(e,t,r){function n(t){var r=h,n=b;return h=b=void 0,c=t,y=e.apply(n,r),y}function i(e){return c=e,m=Va(a,t),p?n(e):y}function o(e){var r=e-_,n=e-c,i=t-r;return u?fa(i,g-n):i}function d(e){var r=e-_,n=e-c;return void 0==_||r>=t||0>r||u&&n>=g}function a(){var e=Ss();return d(e)?s(e):void(m=Va(a,o(e)))}function s(e){return(m=void 0,l&&h)?n(e):(h=b=void 0,y)}function f(){var e=Ss(),r=d(e);if(h=arguments,b=this,_=e,r){if(void 0===m)return i(_);if(u)return m=Va(a,t),n(_)}return void 0===m&&(m=Va(a,t)),y}var c=0,p=!1,u=!1,l=!0,h,b,g,y,m,_;if("function"!=typeof e)throw new Ed(fe);return t=Qo(t)||0,Ko(r)&&(p=!!r.leading,u="maxWait"in r,g=u?sa(Qo(r.maxWait)||0,t):g,l="trailing"in r?!!r.trailing:l),f.cancel=function(){void 0!==m&&Ua(m),c=0,h=_=b=m=void 0},f.flush=function(){return void 0===m?y:s(Ss())},f}function No(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ed(fe);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var d=e.apply(this,n);return r.cache=o.set(i,d)||o,d};return r.cache=new(No.Cache||oe),r}function Co(e){if("function"!=typeof e)throw new Ed(fe);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2]);}return!e.apply(this,t)}}function jo(e,t){return e===t||e!==e&&t!==t}function Mo(e){return null!=e&&Ho(e.length)&&!Do(e)}function Uo(e){return Fo(e)&&Mo(e)}function Lo(e){if(!Fo(e))return!1;var t=gr(e);return t==Ue||t=="[object DOMException]"||"string"==typeof e.message&&"string"==typeof e.name&&!Vo(e)}function Do(e){if(!Ko(e))return!1;var t=gr(e);return t==Le||t==De||t=="[object AsyncFunction]"||t=="[object Proxy]"}function zo(e){return"number"==typeof e&&e==Zo(e)}function Ho(e){return"number"==typeof e&&-1e?-1:1;return t*1.7976931348623157e308}return e===e?e:0}function Zo(e){var t=Xo(e),r=t%1;return t===t?r?t-r:t:0}function Jo(e){return e?Qt(Zo(e),0,Re):0}function Qo(e){if("number"==typeof e)return e;if(Wo(e))return Oe;if(Ko(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ko(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(kt,"");var r=Nt.test(e);return r||jt.test(e)?Ir(e.slice(2),r?2:8):Tt.test(e)?Oe:+e}function $o(e){return Xn(e,id(e))}function ed(e){return null==e?"":xn(e)}function td(e,t,r){var n=null==e?void 0:hr(e,t);return void 0===n?r:n}function rd(e,t){return null!=e&&Di(e,t,Ar)}function nd(e){return Mo(e)?zt(e):Yr(e)}function id(e){return Mo(e)?zt(e,!0):Xr(e)}function od(e,t){if(null==e)return{};var r=m(Bi(e),function(e){return[e]});return t=Ti(t),dn(e,r,function(e,r){return t(e,r[0])})}function dd(e,t,r){t=Cn(t,e);var n=-1,i=t.length;for(i||(i=1,e=void 0);++nr)return!1;var n=t.length-1;return r==n?t.pop():Wd.call(t,r,1),--this.size,!0},te.prototype.get=function(e){var t=this.__data__,r=Gt(t,e);return 0>r?void 0:t[r][1]},te.prototype.has=function(e){return-1n?(++this.size,r.push([e,t])):r[n][1]=t,this},oe.prototype.clear=function(){this.size=0,this.__data__={hash:new N,map:new(ba||te),string:new N}},oe.prototype["delete"]=function(e){var t=Ni(this,e)["delete"](e);return this.size-=t?1:0,t},oe.prototype.get=function(e){return Ni(this,e).get(e)},oe.prototype.has=function(e){return Ni(this,e).has(e)},oe.prototype.set=function(e,t){var r=Ni(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},de.prototype.add=de.prototype.push=function(e){return this.__data__.set(e,ce),this},de.prototype.has=function(e){return this.__data__.has(e)},Pt.prototype.clear=function(){this.__data__=new te,this.size=0},Pt.prototype["delete"]=function(e){var t=this.__data__,r=t["delete"](e);return this.size=t.size,r},Pt.prototype.get=function(e){return this.__data__.get(e)},Pt.prototype.has=function(e){return this.__data__.has(e)},Pt.prototype.set=function(e,t){var r=this.__data__;if(r instanceof te){var n=r.__data__;if(!ba||n.length=t}),Rs=Lr(function(){return arguments}())?Lr:function(e){return Fo(e)&&Nd.call(e,"callee")&&!Gd.call(e,"callee")},Ts=_d.isArray,Ns=Tr?D(Tr):function(e){return Fo(e)&&gr(e)==Xe},Cs=ia||md,js=Nr?D(Nr):function(e){return Fo(e)&&gr(e)==Me},Ms=Cr?D(Cr):function(e){return Fo(e)&&Ka(e)==ze},Us=jr?D(jr):function(e){return Fo(e)&&gr(e)==qe},Ls=Mr?D(Mr):function(e){return Fo(e)&&Ka(e)==Ve},Ds=Ur?D(Ur):function(e){return Fo(e)&&Ho(e.length)&&!!_r[gr(e)]},zs=gi(Zr),Hs=gi(function(e,t){return e<=t}),Ks=$n(function(e,t){if(Ji(t)||Mo(t))return void Xn(t,nd(t),e);for(var r in t)Nd.call(t,r)&&Vt(e,r,t[r])}),Fs=$n(function(e,t){Xn(t,id(t),e)}),qs=$n(function(e,t,r,n){Xn(t,id(t),e,n)}),Vs=$n(function(e,t,r,n){Xn(t,nd(t),e,n)}),Gs=Ei(Jt),Ws=ln(function(e){return e.push(void 0,vi),d(qs,void 0,e)}),Ys=ln(function(e){return e.push(void 0,ki),d($s,void 0,e)}),Xs=ci(function(e,t,r){e[t]=r},pd(ud)),Zs=ci(function(e,t,r){Nd.call(e,t)?e[t].push(r):e[t]=[r]},Ti),Js=ln(Rr),Qs=$n(function(e,t,r){en(e,t,r)}),$s=$n(function(e,t,r,n){en(e,t,r,n)}),ef=Ei(function(e,t){var r={};if(null==e)return r;var n=!1;t=m(t,function(t){return t=Cn(t,e),n||(n=1--e)return t.apply(this,arguments)}},r.ary=Po,r.assign=Ks,r.assignIn=Fs,r.assignInWith=qs,r.assignWith=Vs,r.at=Gs,r.before=Bo,r.bind=vs,r.bindAll=hf,r.bindKey=ks,r.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Ts(e)?e:[e]},r.chain=Io,r.chunk=function(e,t,r){t=(r?Gi(e,t,r):void 0===t)?1:sa(Zo(t),0);var n=null==e?0:e.length;if(!n||1>t)return[];for(var i=0,o=0,d=_d(ta(n/t));it?0:t,n)):[]},r.dropRight=function(e,t,r){var n=null==e?0:e.length;return n?(t=r||void 0===t?1:Zo(t),t=n-t,mn(e,0,0>t?0:t)):[]},r.dropRightWhile=function(e,t){return e&&e.length?Pn(e,Ti(t,3),!0,!0):[]},r.dropWhile=function(e,t){return e&&e.length?Pn(e,Ti(t,3),!0):[]},r.fill=function(e,t,r,n){var i=null==e?0:e.length;return i?(r&&"number"!=typeof r&&Gi(e,t,r)&&(r=0,n=i),dr(e,t,r,n)):[]},r.filter=function(e,t){var r=Ts(e)?b:ar;return r(e,Ti(t,3))},r.flatMap=function(e,t){return sr(Eo(e,t),1)},r.flatMapDeep=function(e,t){return sr(Eo(e,t),Pe)},r.flatMapDepth=function(e,t,r){return r=void 0===r?1:Zo(r),sr(Eo(e,t),r)},r.flatten=go,r.flattenDeep=function(e){var t=null==e?0:e.length;return t?sr(e,Pe):[]},r.flattenDepth=function(e,t){var r=null==e?0:e.length;return r?(t=void 0===t?1:Zo(t),sr(e,t)):[]},r.flip=function(e){return Si(e,we)},r.flow=bf,r.flowRight=gf,r.fromPairs=function(e){for(var t=-1,r=null==e?0:e.length,n={},i;++t>>0,!r)?[]:(e=ed(e),e&&("string"==typeof t||null!=t&&!Us(t))&&(t=xn(t),!t&&W(e))?jn(ie(e),0,r):e.split(t,r))},r.spread=function(e,t){if("function"!=typeof e)throw new Ed(fe);return t=null==t?0:sa(Zo(t),0),ln(function(r){var n=r[t],i=jn(r,0,t);return n&&S(i,n),d(e,this,i)})},r.tail=function(e){var t=null==e?0:e.length;return t?mn(e,1,t):[]},r.take=function(e,t,r){return e&&e.length?(t=r||void 0===t?1:Zo(t),mn(e,0,0>t?0:t)):[]},r.takeRight=function(e,t,r){var n=null==e?0:e.length;return n?(t=r||void 0===t?1:Zo(t),t=n-t,mn(e,0>t?0:t,n)):[]},r.takeRightWhile=function(e,t){return e&&e.length?Pn(e,Ti(t,3),!1,!0):[]},r.takeWhile=function(e,t){return e&&e.length?Pn(e,Ti(t,3)):[]},r.tap=function(e,t){return t(e),e},r.throttle=function(e,t,r){var n=!0,i=!0;if("function"!=typeof e)throw new Ed(fe);return Ko(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),To(e,t,{leading:n,maxWait:t,trailing:i})},r.thru=xo,r.toArray=Yo,r.toPairs=rf,r.toPairsIn=nf,r.toPath=function(e){return Ts(e)?m(e,co):Wo(e)?[e]:Yn(Wa(ed(e)))},r.toPlainObject=$o,r.transform=function(e,t,r){var n=Ts(e),i=n||Cs(e)||Ds(e);if(t=Ti(t,4),null==r){var o=e&&e.constructor;r=i?n?new o:[]:Ko(e)?Do(o)?Oa(qd(e)):{}:{}}return(i?s:fr)(e,function(e,n,i){return t(r,e,n,i)}),r},r.unary=function(e){return Po(e,1)},r.union=rs,r.unionBy=ns,r.unionWith=is,r.uniq=function(e){return e&&e.length?An(e):[]},r.uniqBy=function(e,t){return e&&e.length?An(e,Ti(t,2)):[]},r.uniqWith=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?An(e,void 0,t):[]},r.unset=function(e,t){return null==e||wn(e,t)},r.unzip=vo,r.unzipWith=ko,r.update=function(e,t,r){return null==e?e:En(e,t,Nn(r))},r.updateWith=function(e,t,r,n){return n="function"==typeof n?n:void 0,null==e?e:En(e,t,Nn(r),n)},r.values=ad,r.valuesIn=function(e){return null==e?[]:z(e,id(e))},r.without=os,r.words=cd,r.wrap=function(e,t){return ws(Nn(t),e)},r.xor=ds,r.xorBy=as,r.xorWith=ss,r.zip=fs,r.zipObject=function(e,t){return Rn(e||[],t||[],Vt)},r.zipObjectDeep=function(e,t){return Rn(e||[],t||[],gn)},r.zipWith=cs,r.entries=rf,r.entriesIn=nf,r.extend=Fs,r.extendWith=qs,hd(r,r),r.add=xf,r.attempt=lf,r.camelCase=of,r.capitalize=sd,r.ceil=Af,r.clamp=function(e,t,r){return void 0===r&&(r=t,t=void 0),void 0!==r&&(r=Qo(r),r=r===r?r:0),void 0!==t&&(t=Qo(t),t=t===t?t:0),Qt(Qo(e),t,r)},r.clone=function(e){return $t(e,he)},r.cloneDeep=function(e){return $t(e,ue|he)},r.cloneDeepWith=function(e,t){return t="function"==typeof t?t:void 0,$t(e,ue|he,t)},r.cloneWith=function(e,t){return t="function"==typeof t?t:void 0,$t(e,he,t)},r.conformsTo=function(e,t){return null==t||tr(e,t,nd(t))},r.deburr=fd,r.defaultTo=function(e,t){return null==e||e!==e?t:e},r.divide=wf,r.endsWith=function(e,t,r){e=ed(e),t=xn(t);var n=e.length;r=void 0===r?n:Qt(Zo(r),0,n);var i=r;return r-=t.length,0<=r&&e.slice(r,i)==t},r.eq=jo,r.escape=function(e){return e=ed(e),e&&ut.test(e)?e.replace(ct,zr):e},r.escapeRegExp=function(e){return e=ed(e),e&&vt.test(e)?e.replace(St,"\\$&"):e},r.every=function(e,t,r){var n=Ts(e)?l:ir;return r&&Gi(e,t,r)&&(t=void 0),n(e,Ti(t,3))},r.find=ls,r.findIndex=ho,r.findKey=function(e,t){return w(e,Ti(t,3),fr)},r.findLast=hs,r.findLastIndex=bo,r.findLastKey=function(e,t){return w(e,Ti(t,3),cr)},r.floor=Ef,r.forEach=Ao,r.forEachRight=wo,r.forIn=function(e,t){return null==e?e:Na(e,Ti(t,3),id)},r.forInRight=function(e,t){return null==e?e:Ca(e,Ti(t,3),id)},r.forOwn=function(e,t){return e&&fr(e,Ti(t,3))},r.forOwnRight=function(e,t){return e&&cr(e,Ti(t,3))},r.get=td,r.gt=Bs,r.gte=Os,r.has=function(e,t){return null!=e&&Di(e,t,xr)},r.hasIn=rd,r.head=yo,r.identity=ud,r.includes=function(e,t,r,n){e=Mo(e)?e:ad(e),r=r&&!n?Zo(r):0;var i=e.length;return 0>r&&(r=sa(i+r,0)),Go(e)?r<=i&&-1i&&(i=sa(n+i,0)),P(e,t,i)},r.inRange=function(e,t,r){return t=Xo(t),void 0===r?(r=t,t=0):r=Xo(r),e=Qo(e),Er(e,t,r)},r.invoke=Js,r.isArguments=Rs,r.isArray=Ts,r.isArrayBuffer=Ns,r.isArrayLike=Mo,r.isArrayLikeObject=Uo,r.isBoolean=function(e){return!0===e||!1===e||Fo(e)&&gr(e)==je},r.isBuffer=Cs,r.isDate=js,r.isElement=function(e){return Fo(e)&&1===e.nodeType&&!Vo(e)},r.isEmpty=function(e){if(null==e)return!0;if(Mo(e)&&(Ts(e)||"string"==typeof e||"function"==typeof e.splice||Cs(e)||Ds(e)||Rs(e)))return!e.length;var t=Ka(e);if(t==ze||t==Ve)return!e.size;if(Ji(e))return!Yr(e).length;for(var r in e)if(Nd.call(e,r))return!1;return!0},r.isEqual=function(e,t){return Fr(e,t)},r.isEqualWith=function(e,t,r){r="function"==typeof r?r:void 0;var n=r?r(e,t):void 0;return void 0===n?Fr(e,t,void 0,r):!!n},r.isError=Lo,r.isFinite=function(e){return"number"==typeof e&&oa(e)},r.isFunction=Do,r.isInteger=zo,r.isLength=Ho,r.isMap=Ms,r.isMatch=function(e,t){return e===t||Vr(e,t,Ci(t))},r.isMatchWith=function(e,t,r){return r="function"==typeof r?r:void 0,Vr(e,t,Ci(t),r)},r.isNaN=function(e){return qo(e)&&e!=+e},r.isNative=function(e){if(Fa(e))throw new vd("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Gr(e)},r.isNil=function(e){return null==e},r.isNull=function(e){return null===e},r.isNumber=qo,r.isObject=Ko,r.isObjectLike=Fo,r.isPlainObject=Vo,r.isRegExp=Us,r.isSafeInteger=function(e){return zo(e)&&e>=-Be&&e<=Be},r.isSet=Ls,r.isString=Go,r.isSymbol=Wo,r.isTypedArray=Ds,r.isUndefined=function(e){return void 0===e},r.isWeakMap=function(e){return Fo(e)&&Ka(e)==Ye},r.isWeakSet=function(e){return Fo(e)&&gr(e)=="[object WeakSet]"},r.join=function(e,t){return null==e?"":da.call(e,t)},r.kebabCase=df,r.last=mo,r.lastIndexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=n;return void 0!==r&&(i=Zo(r),i=0>i?sa(n+i,0):fa(i,n-1)),t===t?re(e,t,i):E(e,O,i,!0)},r.lowerCase=af,r.lowerFirst=sf,r.lt=zs,r.lte=Hs,r.max=function(e){return e&&e.length?or(e,ud,vr):void 0},r.maxBy=function(e,t){return e&&e.length?or(e,Ti(t,2),vr):void 0},r.mean=function(e){return R(e,ud)},r.meanBy=function(e,t){return R(e,Ti(t,2))},r.min=function(e){return e&&e.length?or(e,ud,Zr):void 0},r.minBy=function(e,t){return e&&e.length?or(e,Ti(t,2),Zr):void 0},r.stubArray=yd,r.stubFalse=md,r.stubObject=function(){return{}},r.stubString=function(){return""},r.stubTrue=function(){return!0},r.multiply=Pf,r.nth=function(e,t){return e&&e.length?rn(e,Zo(t)):void 0},r.noConflict=function(){return wr._===this&&(wr._=Ld),this},r.noop=bd,r.now=Ss,r.pad=function(e,t,r){e=ed(e),t=Zo(t);var n=t?ne(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return li(ra(i),r)+e+li(ta(i),r)},r.padEnd=function(e,t,r){e=ed(e),t=Zo(t);var n=t?ne(e):0;return t&&nt){var n=e;e=t,t=n}if(r||e%1||t%1){var i=ua();return fa(e+i*(t-e+kr("1e-"+((i+"").length-1))),t)}return cn(e,t)},r.reduce=function(e,t,r){var n=Ts(e)?v:C,i=3>arguments.length;return n(e,Ti(t,4),r,i,Ra)},r.reduceRight=function(e,t,r){var n=Ts(e)?k:C,i=3>arguments.length;return n(e,Ti(t,4),r,i,Ta)},r.repeat=function(e,t,r){return t=(r?Gi(e,t,r):void 0===t)?1:Zo(t),un(ed(e),t)},r.replace=function(){var e=arguments,t=ed(e[0]);return 3>e.length?t:t.replace(e[1],e[2])},r.result=dd,r.round=Bf,r.runInContext=e,r.sample=function(e){var t=Ts(e)?Ht:hn;return t(e)},r.size=function(e){if(null==e)return 0;if(Mo(e))return Go(e)?ne(e):e.length;var t=Ka(e);return t==ze||t==Ve?e.size:Yr(e).length},r.snakeCase=ff,r.some=function(e,t,r){var n=Ts(e)?I:_n;return r&&Gi(e,t,r)&&(t=void 0),n(e,Ti(t,3))},r.sortedIndex=function(e,t){return Sn(e,t)},r.sortedIndexBy=function(e,t,r){return vn(e,t,Ti(r,2))},r.sortedIndexOf=function(e,t){var r=null==e?0:e.length;if(r){var n=Sn(e,t);if(ne||e>Be)return[];var r=Re,n=fa(e,Re);t=Ti(t),e-=Re;for(var i=U(n,t);++r=o)return e;var a=r-ne(n);if(1>a)return n;var s=d?jn(d,0,a).join(""):e.slice(0,a);if(void 0===i)return s+n;if(d&&(a+=s.length-a),Us(i)){if(e.slice(a).search(i)){var f=s,c;for(i.global||(i=Ad(i.source,ed(Rt.exec(i))+"g")),i.lastIndex=0;c=i.exec(f);)var p=c.index;s=s.slice(0,void 0===p?a:p)}}else if(e.indexOf(xn(i),a)!=a){var u=s.lastIndexOf(i);-1n.__dir__?"Right":"")}),n},x.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),s(["filter","map","takeWhile"],function(e,t){var r=t+1;x.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Ti(e,3),type:r}),t.__filtered__=t.__filtered__||r==Ee||r==3,t}}),s(["head","last"],function(e,t){var r="take"+(t?"Right":"");x.prototype[e]=function(){return this[r](1).value()[0]}}),s(["initial","tail"],function(e,t){var r="drop"+(t?"":"Right");x.prototype[e]=function(){return this.__filtered__?new x(this):this[r](1)}}),x.prototype.compact=function(){return this.filter(ud)},x.prototype.find=function(e){return this.filter(e).head()},x.prototype.findLast=function(e){return this.reverse().find(e)},x.prototype.invokeMap=ln(function(e,t){return"function"==typeof e?new x(this):this.map(function(r){return Rr(r,e,t)})}),x.prototype.reject=function(e){return this.filter(Co(Ti(e)))},x.prototype.slice=function(e,t){e=Zo(e);var r=this;return r.__filtered__&&(0t)?new x(r):(0>e?r=r.takeRight(-e):e&&(r=r.drop(e)),void 0!==t&&(t=Zo(t),r=0>t?r.dropRight(-t):r.take(t-e)),r)},x.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},x.prototype.toArray=function(){return this.take(Re)},fr(x.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),o=r[i?"take"+("last"==t?"Right":""):t],d=i||/^find/.test(t);o&&(r.prototype[t]=function(){var t=this.__wrapped__,a=i?[1]:arguments,s=t instanceof x,f=a[0],c=s||Ts(t),p=function(e){var t=o.apply(r,S([e],a));return i&&u?t[0]:t};c&&n&&"function"==typeof f&&1!=f.length&&(s=c=!1);var u=this.__chain__,l=!!this.__actions__.length,h=d&&!u,b=s&&!l;if(!d&&c){t=b?t:new x(this);var g=e.apply(t,a);return g.__actions__.push({func:xo,args:[p],thisArg:void 0}),new _(g,u)}return h&&b?e.apply(this,a):(g=this.thru(p),h?i?g.value()[0]:g.value():g)})}),s(["pop","push","shift","sort","splice","unshift"],function(e){var t=Pd[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);r.prototype[e]=function(){var e=arguments;if(i&&!this.__chain__){var r=this.value();return t.apply(Ts(r)?r:[],e)}return this[n](function(r){return t.apply(Ts(r)?r:[],e)})}}),fr(x.prototype,function(e,t){var n=r[t];if(n){var i=n.name+"",o=va[i]||(va[i]=[]);o.push({name:t,func:n})}}),va[fi(void 0,me).name]=[{name:"wrapper",func:void 0}],x.prototype.clone=function(){var e=new x(this.__wrapped__);return e.__actions__=Yn(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Yn(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Yn(this.__views__),e},x.prototype.reverse=function(){if(this.__filtered__){var e=new x(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e},x.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Ts(e),n=0>t,i=r?e.length:0,o=Ui(0,i,this.__views__),d=o.start,a=o.end,s=a-d,f=n?a:d-1,c=this.__iteratees__,p=c.length,u=0,l=fa(s,this.__takeCount__);if(!r||!n&&i==s&&l==s)return Bn(e,this.__actions__);var h=[];outer:for(;s--&&u=this.__values__.length,t=e?void 0:this.__values__[this.__index__++];return{done:e,value:t}},r.prototype.plant=function(e){for(var t=this,r,n;t instanceof i;){n=lo(t),n.__index__=0,n.__values__=void 0,r?o.__wrapped__=n:r=n;var o=n;t=t.__wrapped__}return o.__wrapped__=e,r},r.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof x){var t=e;return this.__actions__.length&&(t=new x(this)),t=t.reverse(),t.__actions__.push({func:xo,args:[So],thisArg:void 0}),new _(t,this.__chain__)}return this.thru(So)},r.prototype.toJSON=r.prototype.valueOf=r.prototype.value=function(){return Bn(this.__wrapped__,this.__actions__)},r.prototype.first=r.prototype.head,Xd&&(r.prototype[Xd]=function(){return this}),r}();"function"==typeof i&&"object"==typeof i.amd&&i.amd?(wr._=Kr,i(function(){return Kr})):Pr?((Pr.exports=Kr)._=Kr,Er._=Kr):wr._=Kr}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],150:[function(e,t){(function(r){"use strict";function n(){a.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function i(e,t){return e<>>32-t}function o(e,t,r,n,o,d,a){return 0|i(0|e+(t&r|~t&n)+o+d,a)+t}function s(e,t,r,n,o,a,f){return 0|i(0|e+(t&n|r&~n)+o+a,f)+t}function f(e,t,r,n,o,d,a){return 0|i(0|e+(t^r^n)+o+d,a)+t}function p(e,t,r,n,o,a,f){return 0|i(0|e+(r^(t|~n))+o+a,f)+t}var d=e("inherits"),a=e("hash-base"),c=Array(16);d(n,a),n.prototype._update=function(){for(var e=c,t=0;16>t;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;r=o(r,n,i,a,e[0],3614090360,7),a=o(a,r,n,i,e[1],3905402710,12),i=o(i,a,r,n,e[2],606105819,17),n=o(n,i,a,r,e[3],3250441966,22),r=o(r,n,i,a,e[4],4118548399,7),a=o(a,r,n,i,e[5],1200080426,12),i=o(i,a,r,n,e[6],2821735955,17),n=o(n,i,a,r,e[7],4249261313,22),r=o(r,n,i,a,e[8],1770035416,7),a=o(a,r,n,i,e[9],2336552879,12),i=o(i,a,r,n,e[10],4294925233,17),n=o(n,i,a,r,e[11],2304563134,22),r=o(r,n,i,a,e[12],1804603682,7),a=o(a,r,n,i,e[13],4254626195,12),i=o(i,a,r,n,e[14],2792965006,17),n=o(n,i,a,r,e[15],1236535329,22),r=s(r,n,i,a,e[1],4129170786,5),a=s(a,r,n,i,e[6],3225465664,9),i=s(i,a,r,n,e[11],643717713,14),n=s(n,i,a,r,e[0],3921069994,20),r=s(r,n,i,a,e[5],3593408605,5),a=s(a,r,n,i,e[10],38016083,9),i=s(i,a,r,n,e[15],3634488961,14),n=s(n,i,a,r,e[4],3889429448,20),r=s(r,n,i,a,e[9],568446438,5),a=s(a,r,n,i,e[14],3275163606,9),i=s(i,a,r,n,e[3],4107603335,14),n=s(n,i,a,r,e[8],1163531501,20),r=s(r,n,i,a,e[13],2850285829,5),a=s(a,r,n,i,e[2],4243563512,9),i=s(i,a,r,n,e[7],1735328473,14),n=s(n,i,a,r,e[12],2368359562,20),r=f(r,n,i,a,e[5],4294588738,4),a=f(a,r,n,i,e[8],2272392833,11),i=f(i,a,r,n,e[11],1839030562,16),n=f(n,i,a,r,e[14],4259657740,23),r=f(r,n,i,a,e[1],2763975236,4),a=f(a,r,n,i,e[4],1272893353,11),i=f(i,a,r,n,e[7],4139469664,16),n=f(n,i,a,r,e[10],3200236656,23),r=f(r,n,i,a,e[13],681279174,4),a=f(a,r,n,i,e[0],3936430074,11),i=f(i,a,r,n,e[3],3572445317,16),n=f(n,i,a,r,e[6],76029189,23),r=f(r,n,i,a,e[9],3654602809,4),a=f(a,r,n,i,e[12],3873151461,11),i=f(i,a,r,n,e[15],530742520,16),n=f(n,i,a,r,e[2],3299628645,23),r=p(r,n,i,a,e[0],4096336452,6),a=p(a,r,n,i,e[7],1126891415,10),i=p(i,a,r,n,e[14],2878612391,15),n=p(n,i,a,r,e[5],4237533241,21),r=p(r,n,i,a,e[12],1700485571,6),a=p(a,r,n,i,e[3],2399980690,10),i=p(i,a,r,n,e[10],4293915773,15),n=p(n,i,a,r,e[1],2240044497,21),r=p(r,n,i,a,e[8],1873313359,6),a=p(a,r,n,i,e[15],4264355552,10),i=p(i,a,r,n,e[6],2734768916,15),n=p(n,i,a,r,e[13],1309151649,21),r=p(r,n,i,a,e[4],4149444226,6),a=p(a,r,n,i,e[11],3174756917,10),i=p(i,a,r,n,e[2],718787259,15),n=p(n,i,a,r,e[9],3951481745,21),this._a=0|this._a+r,this._b=0|this._b+n,this._c=0|this._c+i,this._d=0|this._d+a},n.prototype._digest=function(){this._block[this._blockOffset++]=128,56=this._blockSize;){for(var a=this._blockOffset;ar;++r)this._length[r]=0;return t},n.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=n},{inherits:146,"safe-buffer":196,stream:205}],152:[function(e,t){function r(e){this.rand=e||new n.Rand}var o=e("bn.js"),n=e("brorand");t.exports=r,r.create=function(e){return new r(e)},r.prototype._randbelow=function(e){var t=e.bitLength(),r=h(t/8);do var n=new o(this.rand.generate(r));while(0<=n.cmp(e));return n},r.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},r.prototype.test=function(e,t,r){var n=e.bitLength(),f=o.mont(e),c=new o(1).toRed(f);t||(t=p(1,0|n/48));for(var u=e.subn(1),l=0;!u.testn(l);l++);for(var s=e.shrn(l),d=u.toRed(f),h=!0;0>8,d=255&i;o?r.push(o,d):r.push(d)}return r},o.zero2=n,o.toHex=i,o.encode=function(e,t){return"hex"===t?i(e):e}},{}],156:[function(e,t){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],157:[function(e,t,r){"use strict";var n=e("asn1.js");r.certificate=e("./certificate");var i=n.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=i;var o=n.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var d=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())});r.PublicKey=d;var a=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),s=n.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(a),this.key("subjectPrivateKey").octstr())});r.PrivateKey=s;var f=n.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=f;var c=n.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=c,r.DSAparam=n.define("DSAparam",function(){this.int()});var p=n.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(u),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=p;var u=n.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=n.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":158,"asn1.js":2}],158:[function(e,t){"use strict";var r=e("asn1.js"),n=r.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),i=r.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),o=r.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),d=r.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(o),this.key("subjectPublicKey").bitstr())}),a=r.define("RelativeDistinguishedName",function(){this.setof(i)}),s=r.define("RDNSequence",function(){this.seqof(a)}),f=r.define("Name",function(){this.choice({rdnSequence:this.use(s)})}),c=r.define("Validity",function(){this.seq().obj(this.key("notBefore").use(n),this.key("notAfter").use(n))}),p=r.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),u=r.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(o),this.key("issuer").use(f),this.key("validity").use(c),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(d),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(p).optional())}),l=r.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(u),this.key("signatureAlgorithm").use(o),this.key("signatureValue").bitstr())});t.exports=l},{"asn1.js":2}],159:[function(e,t){(function(r){var n=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,i=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,o=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,d=e("evp_bytestokey"),a=e("browserify-aes");t.exports=function(e,t){var s=e.toString(),f=s.match(n),c;if(!f){var p=s.match(o);c=new r(p[2].replace(/\r?\n/g,""),"base64")}else{var u="aes"+f[1],l=new r(f[2],"hex"),h=new r(f[3].replace(/\r?\n/g,""),"base64"),b=d(t,l.slice(0,8),parseInt(f[1],10)).key,g=[],y=a.createDecipheriv(u,b,l);g.push(y.update(h)),g.push(y.final()),c=r.concat(g)}var m=s.match(i)[1];return{tag:m,data:c}}}).call(this,e("buffer").Buffer)},{"browserify-aes":25,buffer:71,evp_bytestokey:128}],160:[function(e,t){(function(r){function n(e){var t;"object"!=typeof e||r.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new r(e));var n=a(e,t),d=n.tag,s=n.data,f,c;switch(d){case"CERTIFICATE":c=o.certificate.decode(s,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=o.PublicKey.decode(s,"der")),f=c.algorithm.algorithm.join("."),f){case"1.2.840.113549.1.1.1":return o.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=o.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+f);}throw new Error("unknown key type "+d);case"ENCRYPTED PRIVATE KEY":s=o.EncryptedPrivateKey.decode(s,"der"),s=i(s,t);case"PRIVATE KEY":switch(c=o.PrivateKey.decode(s,"der"),f=c.algorithm.algorithm.join("."),f){case"1.2.840.113549.1.1.1":return o.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:o.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=o.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+f);}throw new Error("unknown key type "+d);case"RSA PUBLIC KEY":return o.RSAPublicKey.decode(s,"der");case"RSA PRIVATE KEY":return o.RSAPrivateKey.decode(s,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:o.DSAPrivateKey.decode(s,"der")};case"EC PRIVATE KEY":return s=o.ECPrivateKey.decode(s,"der"),{curve:s.parameters.value,privateKey:s.privateKey};default:throw new Error("unknown key type "+d);}}function i(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,i=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),o=d[e.algorithm.decrypt.cipher.algo.join(".")],a=e.algorithm.decrypt.cipher.iv,c=e.subjectPrivateKey,p=parseInt(o.split("-")[1],10)/8,u=f.pbkdf2Sync(t,n,i,p),l=s.createDecipheriv(o,u,a),h=[];return h.push(l.update(c)),h.push(l.final()),r.concat(h)}var o=e("./asn1"),d=e("./aesid.json"),a=e("./fixProc"),s=e("browserify-aes"),f=e("pbkdf2");t.exports=n,n.signature=o.signature}).call(this,e("buffer").Buffer)},{"./aesid.json":156,"./asn1":157,"./fixProc":159,"browserify-aes":25,buffer:71,pbkdf2:161}],161:[function(e,t,r){r.pbkdf2=e("./lib/async"),r.pbkdf2Sync=e("./lib/sync")},{"./lib/async":162,"./lib/sync":165}],162:[function(e,t){(function(r,n){function i(e){if(n.process&&!n.process.browser)return Promise.resolve(!1);if(!p||!p.importKey||!p.deriveBits)return Promise.resolve(!1);if(void 0!==l[e])return l[e];h=h||c.alloc(8);var t=o(h,h,10,128,e).then(function(){return!0}).catch(function(){return!1});return l[e]=t,t}function o(e,t,r,n,i){return p.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then(function(e){return p.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)}).then(function(e){return c.from(e)})}function d(e,t){e.then(function(e){r.nextTick(function(){t(null,e)})},function(n){r.nextTick(function(){t(n)})})}var a=e("./precondition"),s=e("./default-encoding"),f=e("./sync"),c=e("safe-buffer").Buffer,p=n.crypto&&n.crypto.subtle,u={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},l=[],h;t.exports=function(e,t,p,l,h,b){if(c.isBuffer(e)||(e=c.from(e,s)),c.isBuffer(t)||(t=c.from(t,s)),a(p,l),"function"==typeof h&&(b=h,h=void 0),"function"!=typeof b)throw new Error("No callback provided to pbkdf2");h=h||"sha1";var g=u[h.toLowerCase()];return g&&"function"==typeof n.Promise?void d(i(g).then(function(r){return r?o(e,t,p,l,g):f(e,t,p,l,h)}),b):r.nextTick(function(){var r;try{r=f(e,t,p,l,h)}catch(t){return b(t)}b(null,r)})}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./default-encoding":163,"./precondition":164,"./sync":165,_process:167,"safe-buffer":196}],163:[function(e,t){(function(e){var r;if(e.browser)r="utf-8";else{var n=parseInt(e.version.split(".")[0].slice(1),10);r=6<=n?"utf-8":"binary"}t.exports=r}).call(this,e("_process"))},{_process:167}],164:[function(e,t){t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(0>e)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(0>t||t>1073741823||t!==t)throw new TypeError("Bad key length")}},{}],165:[function(e,t){function r(e,t,r){var o=n(e),d="sha512"===e||"sha384"===e?128:64;t.length>d?t=o(t):t.length=t.length){i++;break}var d=t.slice(2,o-1),a=t.slice(o-1,o);if(("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&i++,8>d.length&&i++,i)throw new Error("decryption error");return t.slice(o)}function o(e,t){e=new r(e),t=new r(t);var n=0,o=e.length;e.length!==t.length&&(n++,o=u(e.length,t.length));for(var d=-1;++dp||0<=new f(t).cmp(s.modulus))throw new Error("decryption error");var u=o?l(new f(t),s):c(t,s);var h=new r(p-u.length);if(h.fill(0),u=r.concat([h,u],p),4===a)return n(s,u);if(1===a)return i(s,u,o);if(3===a)return u;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":169,"./withPublic":173,"./xor":174,"bn.js":170,"browserify-rsa":43,buffer:71,"create-hash":96,"parse-asn1":160}],172:[function(e,t){(function(r){function n(e,t){var n=e.modulus.byteLength(),i=t.length,o=s("sha1").update(new r("")).digest(),d=o.length,u=2*d;if(i>n-u-2)throw new Error("message too long");var l=new r(n-i-u-2);l.fill(0);var h=n-d-1,b=a(d),g=c(r.concat([o,l,new r([1]),t],h),f(b,h)),y=c(b,f(g,d));return new p(r.concat([new r([0]),y,g],n))}function i(e,t,n){var i=t.length,d=e.modulus.byteLength();if(i>d-11)throw new Error("message too long");var a;return n?(a=new r(d-i-3),a.fill(255)):a=o(d-i-3),new p(r.concat([new r([0,n?1:2]),a,new r([0]),t],d))}function o(e){for(var t=new r(e),n=0,i=a(2*e),o=0,d;n=i&&r>>10),e=56320|1023&e),t+=M(e),t}).join("")}function u(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:v}function l(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function h(e,t,r){var n=0;for(e=r?C(e/w):e>>1,e+=C(e/t);e>N*x>>1;n+=v)e=C(e/N);return C(n+(N+1)*e/(e+A))}function b(e){var r=[],d=e.length,a=0,i=P,n=E,s,f,c,l,b,g,y,m,_,t;for(f=e.lastIndexOf(B),0>f&&(f=0),c=0;c=d&&o("invalid-input"),m=u(e.charCodeAt(l++)),(m>=v||m>C((S-a)/g))&&o("overflow"),a+=m*g,_=y<=n?I:y>=n+x?x:y-n,m<_)break;t=v-_,g>C(S/t)&&o("overflow"),g*=t}s=r.length+1,n=h(a-b,s,0==b),C(a/s)>S-i&&o("overflow"),i+=C(a/s),a%=s,r.splice(a++,0,i)}return p(r)}function g(e){var r=[],i,n,d,a,s,f,p,u,b,g,t,y,m,_,k;for(e=c(e),y=e.length,i=P,n=0,s=E,f=0;ft&&r.push(M(t));for(d=a=r.length,a&&r.push(B);d=i&&tC((S-n)/m)&&o("overflow"),n+=(p-i)*m,i=p,f=0;fS&&o("overflow"),t==i){for(u=n,b=v;;b+=v){if(g=b<=s?I:b>=s+x?x:b-s,u= 0x80 (not a basic code point)","invalid-input":"Invalid input"},N=v-I,C=f,M=d,j,U;if(j={version:"1.4.1",ucs2:{decode:c,encode:p},decode:b,encode:g,toASCII:function(e){return s(e,function(e){return O.test(e)?"xn--"+g(e):e})},toUnicode:function(e){return s(e,function(e){return k.test(e)?b(e.slice(4).toLowerCase()):e})}},"function"==typeof i&&"object"==typeof i.amd&&i.amd)i("punycode",function(){return j});else if(!(y&&m))n.punycode=j;else if(t.exports==y)m.exports=j;else for(U in j)j.hasOwnProperty(U)&&(y[U]=j[U])})(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],176:[function(e,t){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,o,d){t=t||"&",o=o||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var f=1e3;d&&"number"==typeof d.maxKeys&&(f=d.maxKeys);var c=e.length;0f&&(c=f);for(var p=0;pl||0>e)throw new TypeError("offset must be a uint32");if(e>p||e>t)throw new RangeError("offset out of range")}function d(e,t,r){if("number"!=typeof e||e!==e)throw new TypeError("size must be a number");if(e>l||0>e)throw new TypeError("size must be a uint32");if(e+t>r||e>p)throw new RangeError("buffer too small")}function a(e,r,n,i){if(t.browser){var o=e.buffer,d=new Uint8Array(o,r,n);return u.getRandomValues(d),i?void t.nextTick(function(){i(null,e)}):e}if(i)return void f(n,function(t,n){return t?i(t):void(n.copy(e,r),i(null,e))});var a=f(n);return a.copy(e,r),e}var s=e("safe-buffer"),f=e("randombytes"),c=s.Buffer,p=s.kMaxLength,u=n.crypto||n.msCrypto,l=4294967295;u&&u.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!c.isBuffer(e)&&!(e instanceof n.Uint8Array))throw new TypeError("\"buf\" argument must be a Buffer or Uint8Array");if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError("\"cb\" argument must be a function");return o(t,e.length),d(r,t,e.length),a(e,t,r,i)},r.randomFillSync=function(e,t,r){if("undefined"==typeof t&&(t=0),!c.isBuffer(e)&&!(e instanceof n.Uint8Array))throw new TypeError("\"buf\" argument must be a Buffer or Uint8Array");return o(t,e.length),void 0===r&&(r=e.length-t),d(r,t,e.length),a(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{_process:167,randombytes:179,"safe-buffer":196}],181:[function(e,t){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":182}],182:[function(e,t){"use strict";function r(e){return this instanceof r?void(s.call(this,e),f.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",n)):new r(e)}function n(){this.allowHalfOpen||this._writableState.ended||o(i,this)}function i(e){e.end()}var o=e("process-nextick-args"),d=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=r;var a=e("core-util-is");a.inherits=e("inherits");var s=e("./_stream_readable"),f=e("./_stream_writable");a.inherits(r,s);for(var c=d(f.prototype),p=0,u;p=Y?e=Y:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function b(e,t){return 0>=e||0===t.length&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=h(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}function g(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,y(e)}}function y(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(F("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?N(m,e):m(e))}function m(e){F("emit readable"),e.emit("readable"),A(e)}function _(e,t){t.readingMore||(t.readingMore=!0,N(S,e,t))}function S(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=E(e,t.buffer,t.decoder),r}function E(e,t,r){var n;return eo.length?o.length:e;if(i+=d===o.length?o:o.slice(0,e),e-=d,0===e){d===o.length?(++n,t.head=r.next?r.next:t.tail=null):(t.head=r,r.data=o.slice(d));break}++n}return t.length-=n,i}function B(e,t){var r=D.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var o=n.data,d=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,d),e-=d,0===e){d===o.length?(++i,t.head=n.next?n.next:t.tail=null):(t.head=n,n.data=o.slice(d));break}++i}return t.length-=i,r}function O(e){var t=e._readableState;if(0=t.highWaterMark||t.ended))return F("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?O(this):y(this),null;if(e=b(e,t),0===e&&t.ended)return 0===t.length&&O(this),null;var n=t.needReadable;F("need readable",n),(0===t.length||t.length-e>>0),r=this.head,n=0;r;)o(r.data,t,n),n+=r.data.length,r=r.next;return t},e}()},{"safe-buffer":196}],188:[function(e,t){"use strict";function r(e,t){e.emit("error",t)}var n=e("process-nextick-args");t.exports={destroy:function(e,t){var i=this,o=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return o||d?void(t?t(e):e&&(!this._writableState||!this._writableState.errorEmitted)&&n(r,this,e)):void(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n(r,i,e),i._writableState&&(i._writableState.errorEmitted=!0)):t&&t(e)}))},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":166}],189:[function(e,t){t.exports=e("events").EventEmitter},{events:127}],190:[function(e,t,r){arguments[4][142][0].apply(r,arguments)},{dup:142}],191:[function(e,t){t.exports=e("./readable").PassThrough},{"./readable":192}],192:[function(e,t,r){r=t.exports=e("./lib/_stream_readable.js"),r.Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":182,"./lib/_stream_passthrough.js":183,"./lib/_stream_readable.js":184,"./lib/_stream_transform.js":185,"./lib/_stream_writable.js":186}],193:[function(e,t){t.exports=e("./readable").Transform},{"./readable":192}],194:[function(e,t){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":186}],195:[function(e,t){(function(r){"use strict";function n(){p.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function o(e,t){return e<>>32-t}function d(t,r,n,i,d,e,a,f){return 0|o(0|t+(r^n^i)+e+a,f)+d}function a(t,r,n,i,d,e,a,f){return 0|o(0|t+(r&n|~r&i)+e+a,f)+d}function s(t,r,n,i,d,e,a,f){return 0|o(0|t+((r|~n)^i)+e+a,f)+d}function f(t,r,n,i,a,e,f,c){return 0|o(0|t+(r&i|n&~i)+e+f,c)+a}function c(t,r,n,i,a,e,f,c){return 0|o(0|t+(r^(n|~i))+e+f,c)+a}var i=e("inherits"),p=e("hash-base");i(n,p),n.prototype._update=function(){for(var e=Array(16),r=0;16>r;++r)e[r]=this._block.readInt32LE(4*r);var n=this._a,i=this._b,p=this._c,u=this._d,l=this._e;n=d(n,i,p,u,l,e[0],0,11),p=o(p,10),l=d(l,n,i,p,u,e[1],0,14),i=o(i,10),u=d(u,l,n,i,p,e[2],0,15),n=o(n,10),p=d(p,u,l,n,i,e[3],0,12),l=o(l,10),i=d(i,p,u,l,n,e[4],0,5),u=o(u,10),n=d(n,i,p,u,l,e[5],0,8),p=o(p,10),l=d(l,n,i,p,u,e[6],0,7),i=o(i,10),u=d(u,l,n,i,p,e[7],0,9),n=o(n,10),p=d(p,u,l,n,i,e[8],0,11),l=o(l,10),i=d(i,p,u,l,n,e[9],0,13),u=o(u,10),n=d(n,i,p,u,l,e[10],0,14),p=o(p,10),l=d(l,n,i,p,u,e[11],0,15),i=o(i,10),u=d(u,l,n,i,p,e[12],0,6),n=o(n,10),p=d(p,u,l,n,i,e[13],0,7),l=o(l,10),i=d(i,p,u,l,n,e[14],0,9),u=o(u,10),n=d(n,i,p,u,l,e[15],0,8),p=o(p,10),l=a(l,n,i,p,u,e[7],1518500249,7),i=o(i,10),u=a(u,l,n,i,p,e[4],1518500249,6),n=o(n,10),p=a(p,u,l,n,i,e[13],1518500249,8),l=o(l,10),i=a(i,p,u,l,n,e[1],1518500249,13),u=o(u,10),n=a(n,i,p,u,l,e[10],1518500249,11),p=o(p,10),l=a(l,n,i,p,u,e[6],1518500249,9),i=o(i,10),u=a(u,l,n,i,p,e[15],1518500249,7),n=o(n,10),p=a(p,u,l,n,i,e[3],1518500249,15),l=o(l,10),i=a(i,p,u,l,n,e[12],1518500249,7),u=o(u,10),n=a(n,i,p,u,l,e[0],1518500249,12),p=o(p,10),l=a(l,n,i,p,u,e[9],1518500249,15),i=o(i,10),u=a(u,l,n,i,p,e[5],1518500249,9),n=o(n,10),p=a(p,u,l,n,i,e[2],1518500249,11),l=o(l,10),i=a(i,p,u,l,n,e[14],1518500249,7),u=o(u,10),n=a(n,i,p,u,l,e[11],1518500249,13),p=o(p,10),l=a(l,n,i,p,u,e[8],1518500249,12),i=o(i,10),u=s(u,l,n,i,p,e[3],1859775393,11),n=o(n,10),p=s(p,u,l,n,i,e[10],1859775393,13),l=o(l,10),i=s(i,p,u,l,n,e[14],1859775393,6),u=o(u,10),n=s(n,i,p,u,l,e[4],1859775393,7),p=o(p,10),l=s(l,n,i,p,u,e[9],1859775393,14),i=o(i,10),u=s(u,l,n,i,p,e[15],1859775393,9),n=o(n,10),p=s(p,u,l,n,i,e[8],1859775393,13),l=o(l,10),i=s(i,p,u,l,n,e[1],1859775393,15),u=o(u,10),n=s(n,i,p,u,l,e[2],1859775393,14),p=o(p,10),l=s(l,n,i,p,u,e[7],1859775393,8),i=o(i,10),u=s(u,l,n,i,p,e[0],1859775393,13),n=o(n,10),p=s(p,u,l,n,i,e[6],1859775393,6),l=o(l,10),i=s(i,p,u,l,n,e[13],1859775393,5),u=o(u,10),n=s(n,i,p,u,l,e[11],1859775393,12),p=o(p,10),l=s(l,n,i,p,u,e[5],1859775393,7),i=o(i,10),u=s(u,l,n,i,p,e[12],1859775393,5),n=o(n,10),p=f(p,u,l,n,i,e[1],2400959708,11),l=o(l,10),i=f(i,p,u,l,n,e[9],2400959708,12),u=o(u,10),n=f(n,i,p,u,l,e[11],2400959708,14),p=o(p,10),l=f(l,n,i,p,u,e[10],2400959708,15),i=o(i,10),u=f(u,l,n,i,p,e[0],2400959708,14),n=o(n,10),p=f(p,u,l,n,i,e[8],2400959708,15),l=o(l,10),i=f(i,p,u,l,n,e[12],2400959708,9),u=o(u,10),n=f(n,i,p,u,l,e[4],2400959708,8),p=o(p,10),l=f(l,n,i,p,u,e[13],2400959708,9),i=o(i,10),u=f(u,l,n,i,p,e[3],2400959708,14),n=o(n,10),p=f(p,u,l,n,i,e[7],2400959708,5),l=o(l,10),i=f(i,p,u,l,n,e[15],2400959708,6),u=o(u,10),n=f(n,i,p,u,l,e[14],2400959708,8),p=o(p,10),l=f(l,n,i,p,u,e[5],2400959708,6),i=o(i,10),u=f(u,l,n,i,p,e[6],2400959708,5),n=o(n,10),p=f(p,u,l,n,i,e[2],2400959708,12),l=o(l,10),i=c(i,p,u,l,n,e[4],2840853838,9),u=o(u,10),n=c(n,i,p,u,l,e[0],2840853838,15),p=o(p,10),l=c(l,n,i,p,u,e[5],2840853838,5),i=o(i,10),u=c(u,l,n,i,p,e[9],2840853838,11),n=o(n,10),p=c(p,u,l,n,i,e[7],2840853838,6),l=o(l,10),i=c(i,p,u,l,n,e[12],2840853838,8),u=o(u,10),n=c(n,i,p,u,l,e[2],2840853838,13),p=o(p,10),l=c(l,n,i,p,u,e[10],2840853838,12),i=o(i,10),u=c(u,l,n,i,p,e[14],2840853838,5),n=o(n,10),p=c(p,u,l,n,i,e[1],2840853838,12),l=o(l,10),i=c(i,p,u,l,n,e[3],2840853838,13),u=o(u,10),n=c(n,i,p,u,l,e[8],2840853838,14),p=o(p,10),l=c(l,n,i,p,u,e[11],2840853838,11),i=o(i,10),u=c(u,l,n,i,p,e[6],2840853838,8),n=o(n,10),p=c(p,u,l,n,i,e[15],2840853838,5),l=o(l,10),i=c(i,p,u,l,n,e[13],2840853838,6),u=o(u,10);var h=this._a,b=this._b,g=this._c,y=this._d,m=this._e;h=c(h,b,g,y,m,e[5],1352829926,8),g=o(g,10),m=c(m,h,b,g,y,e[14],1352829926,9),b=o(b,10),y=c(y,m,h,b,g,e[7],1352829926,9),h=o(h,10),g=c(g,y,m,h,b,e[0],1352829926,11),m=o(m,10),b=c(b,g,y,m,h,e[9],1352829926,13),y=o(y,10),h=c(h,b,g,y,m,e[2],1352829926,15),g=o(g,10),m=c(m,h,b,g,y,e[11],1352829926,15),b=o(b,10),y=c(y,m,h,b,g,e[4],1352829926,5),h=o(h,10),g=c(g,y,m,h,b,e[13],1352829926,7),m=o(m,10),b=c(b,g,y,m,h,e[6],1352829926,7),y=o(y,10),h=c(h,b,g,y,m,e[15],1352829926,8),g=o(g,10),m=c(m,h,b,g,y,e[8],1352829926,11),b=o(b,10),y=c(y,m,h,b,g,e[1],1352829926,14),h=o(h,10),g=c(g,y,m,h,b,e[10],1352829926,14),m=o(m,10),b=c(b,g,y,m,h,e[3],1352829926,12),y=o(y,10),h=c(h,b,g,y,m,e[12],1352829926,6),g=o(g,10),m=f(m,h,b,g,y,e[6],1548603684,9),b=o(b,10),y=f(y,m,h,b,g,e[11],1548603684,13),h=o(h,10),g=f(g,y,m,h,b,e[3],1548603684,15),m=o(m,10),b=f(b,g,y,m,h,e[7],1548603684,7),y=o(y,10),h=f(h,b,g,y,m,e[0],1548603684,12),g=o(g,10),m=f(m,h,b,g,y,e[13],1548603684,8),b=o(b,10),y=f(y,m,h,b,g,e[5],1548603684,9),h=o(h,10),g=f(g,y,m,h,b,e[10],1548603684,11),m=o(m,10),b=f(b,g,y,m,h,e[14],1548603684,7),y=o(y,10),h=f(h,b,g,y,m,e[15],1548603684,7),g=o(g,10),m=f(m,h,b,g,y,e[8],1548603684,12),b=o(b,10),y=f(y,m,h,b,g,e[12],1548603684,7),h=o(h,10),g=f(g,y,m,h,b,e[4],1548603684,6),m=o(m,10),b=f(b,g,y,m,h,e[9],1548603684,15),y=o(y,10),h=f(h,b,g,y,m,e[1],1548603684,13),g=o(g,10),m=f(m,h,b,g,y,e[2],1548603684,11),b=o(b,10),y=s(y,m,h,b,g,e[15],1836072691,9),h=o(h,10),g=s(g,y,m,h,b,e[5],1836072691,7),m=o(m,10),b=s(b,g,y,m,h,e[1],1836072691,15),y=o(y,10),h=s(h,b,g,y,m,e[3],1836072691,11),g=o(g,10),m=s(m,h,b,g,y,e[7],1836072691,8),b=o(b,10),y=s(y,m,h,b,g,e[14],1836072691,6),h=o(h,10),g=s(g,y,m,h,b,e[6],1836072691,6),m=o(m,10),b=s(b,g,y,m,h,e[9],1836072691,14),y=o(y,10),h=s(h,b,g,y,m,e[11],1836072691,12),g=o(g,10),m=s(m,h,b,g,y,e[8],1836072691,13),b=o(b,10),y=s(y,m,h,b,g,e[12],1836072691,5),h=o(h,10),g=s(g,y,m,h,b,e[2],1836072691,14),m=o(m,10),b=s(b,g,y,m,h,e[10],1836072691,13),y=o(y,10),h=s(h,b,g,y,m,e[0],1836072691,13),g=o(g,10),m=s(m,h,b,g,y,e[4],1836072691,7),b=o(b,10),y=s(y,m,h,b,g,e[13],1836072691,5),h=o(h,10),g=a(g,y,m,h,b,e[8],2053994217,15),m=o(m,10),b=a(b,g,y,m,h,e[6],2053994217,5),y=o(y,10),h=a(h,b,g,y,m,e[4],2053994217,8),g=o(g,10),m=a(m,h,b,g,y,e[1],2053994217,11),b=o(b,10),y=a(y,m,h,b,g,e[3],2053994217,14),h=o(h,10),g=a(g,y,m,h,b,e[11],2053994217,14),m=o(m,10),b=a(b,g,y,m,h,e[15],2053994217,6),y=o(y,10),h=a(h,b,g,y,m,e[0],2053994217,14),g=o(g,10),m=a(m,h,b,g,y,e[5],2053994217,6),b=o(b,10),y=a(y,m,h,b,g,e[12],2053994217,9),h=o(h,10),g=a(g,y,m,h,b,e[2],2053994217,12),m=o(m,10),b=a(b,g,y,m,h,e[13],2053994217,9),y=o(y,10),h=a(h,b,g,y,m,e[9],2053994217,12),g=o(g,10),m=a(m,h,b,g,y,e[7],2053994217,5),b=o(b,10),y=a(y,m,h,b,g,e[10],2053994217,15),h=o(h,10),g=a(g,y,m,h,b,e[14],2053994217,8),m=o(m,10),b=d(b,g,y,m,h,e[12],0,8),y=o(y,10),h=d(h,b,g,y,m,e[15],0,5),g=o(g,10),m=d(m,h,b,g,y,e[10],0,12),b=o(b,10),y=d(y,m,h,b,g,e[4],0,9),h=o(h,10),g=d(g,y,m,h,b,e[1],0,12),m=o(m,10),b=d(b,g,y,m,h,e[5],0,5),y=o(y,10),h=d(h,b,g,y,m,e[8],0,14),g=o(g,10),m=d(m,h,b,g,y,e[7],0,6),b=o(b,10),y=d(y,m,h,b,g,e[6],0,8),h=o(h,10),g=d(g,y,m,h,b,e[2],0,13),m=o(m,10),b=d(b,g,y,m,h,e[13],0,6),y=o(y,10),h=d(h,b,g,y,m,e[14],0,5),g=o(g,10),m=d(m,h,b,g,y,e[0],0,15),b=o(b,10),y=d(y,m,h,b,g,e[3],0,13),h=o(h,10),g=d(g,y,m,h,b,e[9],0,11),m=o(m,10),b=d(b,g,y,m,h,e[11],0,11),y=o(y,10);var _=0|this._b+p+y;this._b=0|this._c+u+m,this._c=0|this._d+l+h,this._d=0|this._e+n+b,this._e=0|this._a+i+g,this._a=_},n.prototype._digest=function(){this._block[this._blockOffset++]=128,56=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(4294967295>=r)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=4294967295&r;this._block.writeUInt32BE((r-n)/4294967296,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var i=this._hash();return e?i.toString(e):i},r.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=r},{"safe-buffer":196}],198:[function(e,t,r){var r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t};r.sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":199,"./sha1":200,"./sha224":201,"./sha256":202,"./sha384":203,"./sha512":204}],199:[function(e,t){function r(){this.init(),this._w=c,a.call(this,64,56)}function n(e){return e<<5|e>>>27}function i(e){return e<<30|e>>>2}function o(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}var d=e("inherits"),a=e("./hash"),s=e("safe-buffer").Buffer,f=[1518500249,1859775393,-1894007588,-899497514],c=Array(80);d(r,a),r.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},r.prototype._update=function(r){for(var p=this._w,u=0|this._a,a=0|this._b,l=0|this._c,c=0|this._d,d=0|this._e,e=0;16>e;++e)p[e]=r.readInt32BE(4*e);for(;80>e;++e)p[e]=p[e-3]^p[e-8]^p[e-14]^p[e-16];for(var h=0;80>h;++h){var b=~~(h/20),s=0|n(u)+o(b,a,l,c)+d+p[h]+f[b];d=c,c=l,l=i(a),a=u,u=s}this._a=0|u+this._a,this._b=0|a+this._b,this._c=0|l+this._c,this._d=0|c+this._d,this._e=0|d+this._e},r.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=r},{"./hash":197,inherits:146,"safe-buffer":196}],200:[function(e,t){function r(){this.init(),this._w=c,a.call(this,64,56)}function n(e){return e<<1|e>>>31}function i(e){return e<<5|e>>>27}function o(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}var d=e("inherits"),a=e("./hash"),s=e("safe-buffer").Buffer,p=[1518500249,1859775393,-1894007588,-899497514],c=Array(80);d(r,a),r.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},r.prototype._update=function(r){for(var u=this._w,l=0|this._a,a=0|this._b,h=0|this._c,c=0|this._d,d=0|this._e,e=0;16>e;++e)u[e]=r.readInt32BE(4*e);for(;80>e;++e)u[e]=n(u[e-3]^u[e-8]^u[e-14]^u[e-16]);for(var b=0;80>b;++b){var g=~~(b/20),s=0|i(l)+f(g,a,h,c)+d+u[b]+p[g];d=c,c=h,h=o(a),a=l,l=s}this._a=0|l+this._a,this._b=0|a+this._b,this._c=0|h+this._c,this._d=0|c+this._d,this._e=0|d+this._e},r.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=r},{"./hash":197,inherits:146,"safe-buffer":196}],201:[function(e,t){function r(){this.init(),this._w=a,o.call(this,64,56)}var n=e("inherits"),i=e("./sha256"),o=e("./hash"),d=e("safe-buffer").Buffer,a=Array(64);n(r,i),r.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},r.prototype._hash=function(){var e=d.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=r},{"./hash":197,"./sha256":202,inherits:146,"safe-buffer":196}],202:[function(e,t){function r(){this.init(),this._w=l,c.call(this,64,56)}function n(e,t,r){return r^e&(t^r)}function i(e,t,r){return e&t|r&(e|t)}function o(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function s(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function a(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}var f=e("inherits"),c=e("./hash"),p=e("safe-buffer").Buffer,u=[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],l=Array(64);f(r,c),r.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},r.prototype._update=function(t){for(var r=this._w,p=0|this._a,l=0|this._b,b=0|this._c,c=0|this._d,y=0|this._e,e=0|this._f,f=0|this._g,g=0|this._h,h=0;16>h;++h)r[h]=t.readInt32BE(4*h);for(;64>h;++h)r[h]=0|a(r[h-2])+r[h-7]+d(r[h-15])+r[h-16];for(var m=0;64>m;++m){var _=0|g+s(y)+n(y,e,f)+u[m]+r[m],S=0|o(p)+i(p,l,b);g=f,f=e,e=y,y=0|c+_,c=b,b=l,l=p,p=0|_+S}this._a=0|p+this._a,this._b=0|l+this._b,this._c=0|b+this._c,this._d=0|c+this._d,this._e=0|y+this._e,this._f=0|e+this._f,this._g=0|f+this._g,this._h=0|g+this._h},r.prototype._hash=function(){var e=p.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=r},{"./hash":197,inherits:146,"safe-buffer":196}],203:[function(e,t){function r(){this.init(),this._w=a,o.call(this,128,112)}var n=e("inherits"),i=e("./sha512"),o=e("./hash"),d=e("safe-buffer").Buffer,a=Array(160);n(r,i),r.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},r.prototype._hash=function(){function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}var t=d.allocUnsafe(48);return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=r},{"./hash":197,"./sha512":204,inherits:146,"safe-buffer":196}],204:[function(e,t){function r(){this.init(),this._w=g,l.call(this,128,112)}function n(e,t,r){return r^e&(t^r)}function i(e,t,r){return e&t|r&(e|t)}function o(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function d(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function a(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function s(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function f(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function c(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function p(e,t){return e>>>0>>0?1:0}var u=e("inherits"),l=e("./hash"),h=e("safe-buffer").Buffer,b=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],g=Array(160);u(r,l),r.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},r.prototype._update=function(e){for(var t=this._w,r=0|this._ah,u=0|this._bh,l=0|this._ch,h=0|this._dh,g=0|this._eh,y=0|this._fh,m=0|this._gh,_=0|this._hh,S=0|this._al,v=0|this._bl,k=0|this._cl,I=0|this._dl,x=0|this._el,A=0|this._fl,w=0|this._gl,E=0|this._hl,P=0;32>P;P+=2)t[P]=e.readInt32BE(4*P),t[P+1]=e.readInt32BE(4*P+4);for(;160>P;P+=2){var B=t[P-30],O=t[P-30+1],R=a(B,O),T=s(O,B);B=t[P-4],O=t[P-4+1];var N=f(B,O),C=c(O,B),M=t[P-14],U=t[P-14+1],L=t[P-32],D=t[P-32+1],z=0|T+U,H=0|R+M+p(z,T);z=0|z+C,H=0|H+N+p(z,C),z=0|z+D,H=0|H+L+p(z,D),t[P]=H,t[P+1]=z}for(var K=0;160>K;K+=2){H=t[K],z=t[K+1];var j=i(r,u,l),F=i(S,v,k),q=o(r,S),V=o(S,r),G=d(g,x),W=d(x,g),Y=b[K],X=b[K+1],Z=n(g,y,m),J=n(x,A,w),Q=0|E+W,$=0|_+G+p(Q,E);Q=0|Q+J,$=0|$+Z+p(Q,J),Q=0|Q+X,$=0|$+Y+p(Q,X),Q=0|Q+z,$=0|$+H+p(Q,z);var ee=0|V+F,te=0|q+j+p(ee,V);_=m,E=w,m=y,w=A,y=g,A=x,x=0|I+Q,g=0|h+$+p(x,I),h=l,I=k,l=u,k=v,u=r,v=S,S=0|Q+ee,r=0|$+te+p(S,Q)}this._al=0|this._al+S,this._bl=0|this._bl+v,this._cl=0|this._cl+k,this._dl=0|this._dl+I,this._el=0|this._el+x,this._fl=0|this._fl+A,this._gl=0|this._gl+w,this._hl=0|this._hl+E,this._ah=0|this._ah+r+p(this._al,S),this._bh=0|this._bh+u+p(this._bl,v),this._ch=0|this._ch+l+p(this._cl,k),this._dh=0|this._dh+h+p(this._dl,I),this._eh=0|this._eh+g+p(this._el,x),this._fh=0|this._fh+y+p(this._fl,A),this._gh=0|this._gh+m+p(this._gl,w),this._hh=0|this._hh+_+p(this._hl,E)},r.prototype._hash=function(){function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}var t=h.allocUnsafe(64);return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=r},{"./hash":197,inherits:146,"safe-buffer":196}],205:[function(e,t){function r(){n.call(this)}t.exports=r;var n=e("events").EventEmitter,i=e("inherits");i(r,n),r.Readable=e("readable-stream/readable.js"),r.Writable=e("readable-stream/writable.js"),r.Duplex=e("readable-stream/duplex.js"),r.Transform=e("readable-stream/transform.js"),r.PassThrough=e("readable-stream/passthrough.js"),r.Stream=r,r.prototype.pipe=function(e,t){function r(t){e.writable&&!1===e.write(t)&&f.pause&&f.pause()}function i(){f.readable&&f.resume&&f.resume()}function o(){c||(c=!0,e.end())}function d(){c||(c=!0,"function"==typeof e.destroy&&e.destroy())}function a(e){if(s(),0===n.listenerCount(this,"error"))throw e}function s(){f.removeListener("data",r),e.removeListener("drain",i),f.removeListener("end",o),f.removeListener("close",d),f.removeListener("error",a),e.removeListener("error",a),f.removeListener("end",s),f.removeListener("close",s),e.removeListener("close",s)}var f=this;f.on("data",r),e.on("drain",i),e._isStdio||t&&!1===t.end||(f.on("end",o),f.on("close",d));var c=!1;return f.on("error",a),e.on("error",a),f.on("end",s),f.on("close",s),e.on("close",s),e.emit("pipe",f),e}},{events:127,inherits:146,"readable-stream/duplex.js":181,"readable-stream/passthrough.js":191,"readable-stream/readable.js":192,"readable-stream/transform.js":193,"readable-stream/writable.js":194}],206:[function(e,t,r){"use strict";function n(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0;}}function i(e){var t=n(e);if("string"!=typeof t&&(g.isEncoding===y||!y(e)))throw new Error("Unknown encoding: "+e);return t||e}function o(e){this.encoding=i(e);var t;switch(this.encoding){case"utf16le":this.text=c,this.end=p,t=4;break;case"utf8":this.fillLast=f,t=4;break;case"base64":this.text=u,this.end=l,t=3;break;default:return this.write=h,void(this.end=b);}this.lastNeed=0,this.lastTotal=0,this.lastChar=g.allocUnsafe(t)}function d(e){if(127>=e)return 0;return 6==e>>5?2:14==e>>4?3:30==e>>3?4:-1}function a(e,t,r){var n=t.length-1;if(n=r)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function p(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0==r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1==r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function l(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function b(e){return e&&e.length?this.write(e):""}var g=e("safe-buffer").Buffer,y=g.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1;}};r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),void 0===t)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r","\"","`"," ","\r","\n","\t"]),p=["'"].concat(c),u=["%","/","?",";","#"].concat(p),l=["/","?","#"],h=/^[+a-z0-9A-Z_-]{0,63}$/,b=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},_=e("querystring");n.prototype.parse=function(e,t,r){if(!d.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var n=e.indexOf("?"),c=-1!==n&&n255?"":this.hostname.toLowerCase(),T||(this.hostname=o.toASCII(this.hostname));var H=this.port?":"+this.port:"",K=this.hostname||"";this.host=K+H,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==I[0]&&(I="/"+I))}if(!g[w])for(var B=0,C=p.length,F;B_.length&&_.unshift(""),r.pathname=_.join("/")}else r.pathname=e.pathname;if(r.search=e.search,r.query=e.query,r.host=e.host||"",r.auth=e.auth,r.hostname=e.hostname||e.host,r.port=e.port,r.pathname||r.search){var S=r.pathname||"",p=r.search||"";r.path=S+p}return r.slashes=r.slashes||e.slashes,r.href=r.format(),r}var s=r.pathname&&"/"===r.pathname.charAt(0),v=e.host||e.pathname&&"/"===e.pathname.charAt(0),k=v||s||r.host&&e.pathname,I=k,x=r.pathname&&r.pathname.split("/")||[],_=e.pathname&&e.pathname.split("/")||[],A=r.protocol&&!m[r.protocol];if(A&&(r.hostname="",r.port=null,r.host&&(""===x[0]?x[0]=r.host:x.unshift(r.host)),r.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===_[0]?_[0]=e.host:_.unshift(e.host)),e.host=null),k=k&&(""===_[0]||""===x[0])),v)r.host=e.host||""===e.host?e.host:r.host,r.hostname=e.hostname||""===e.hostname?e.hostname:r.hostname,r.search=e.search,r.query=e.query,x=_;else if(_.length)x||(x=[]),x.pop(),x=x.concat(_),r.search=e.search,r.query=e.query;else if(!d.isNullOrUndefined(e.search)){if(A){r.hostname=r.host=x.shift();var w=r.host&&0i)return S(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var n;return n=v?p(e,t,i,g,b):b.map(function(r){return u(e,t,i,g,r,v)}),e.seen.pop(),l(n,_,A)}function f(e,t){if(_(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,"\"")+"'";return e.stylize(r,"string")}return y(t)?e.stylize(""+t,"number"):b(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function c(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,r,n,o){for(var d=[],a=0,i=t.length;ae.seen.indexOf(f.value)?(a=g(r)?s(e,f.value,null):s(e,f.value,r-1),-1e?"0"+e.toString(10):e.toString(10)}function E(){var e=new Date,t=[w(e.getHours()),w(e.getMinutes()),w(e.getSeconds())].join(":");return[e.getDate(),T[e.getMonth()],t].join(" ")}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var B=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=i)return e;switch(e){case"%s":return n[r++]+"";case"%d":return+n[r++];case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e;}}),a=n[r];r",main:"index.js",scripts:{build:"npm install && npx gulp build",test:"npm install && npx gulp test",lint:"npm install && npx gulp lint",coveralls:"npm install && npx gulp coveralls"},keywords:["bitcoin","transaction","address","p2p","ecies","cryptocurrency","blockchain","payment","bip21","bip32","bip37","bip69","bip70","multisig"],repository:{type:"git",url:"https://github.com/bitcoincashjs/bitcoincashjs.git"},browser:{request:"browser-request"},dependencies:{"big-integer":"^1.6.26","bitcore-message":"^1.0.4","bn.js":"=2.0.4",bs58:"=2.0.0","buffer-compare":"=1.0.0",cashaddrjs:"^0.1.4",elliptic:"=3.0.3",inherits:"=2.0.1",lodash:"^4.17.4"},devDependencies:{"babel-core":"^6.26.0","babel-minify":"^0.2.0","babel-preset-env":"^1.6.1",babelify:"^8.0.0",brfs:"^1.4.3",browserify:"^14.5.0",chai:"^1.10.0",coveralls:"^3.0.0",gulp:"^3.8.10","gulp-shell":"^0.6.5",jsdoc:"^3.5.5",jshint:"^2.9.5",karma:"^2.0.0","karma-chrome-launcher":"^2.2.0","karma-detect-browsers":"^2.2.6","karma-firefox-launcher":"^1.1.0","karma-mocha":"^1.3.0",mocha:"^4.1.0",nyc:"^11.4.1","run-sequence":"^2.2.0",sinon:"^1.13.0","uglify-js":"^3.3.4"},license:"MIT"}},{}],214:[function(e,t){(function(r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t"},t.exports=i;var g=e("./script")}).call(this,e("buffer").Buffer)},{"./crypto/hash":221,"./encoding/base58check":226,"./errors":230,"./networks":234,"./publickey":237,"./script":238,"./util/js":256,"./util/preconditions":257,buffer:71,cashaddrjs:73,lodash:149}],215:[function(e,t){(function(r){"use strict";function n(e){return this instanceof n?(i.extend(this,n._from(e)),this):new n(e)}var i=e("lodash"),o=e("./blockheader"),d=e("../crypto/bn"),a=e("../util/buffer"),s=e("../encoding/bufferreader"),c=e("../encoding/bufferwriter"),p=e("../crypto/hash"),l=e("../transaction"),h=e("../util/preconditions");n.MAX_BLOCK_SIZE=1e6,n._from=function(e){var t={};if(a.isBuffer(e))t=n._fromBufferReader(s(e));else if(i.isObject(e))t=n._fromObject(e);else throw new TypeError("Unrecognized argument for Block");return t},n._fromObject=function(e){var t=[];e.transactions.forEach(function(e){e instanceof l?t.push(e):t.push(l().fromObject(e))});var r={header:o.fromObject(e.header),transactions:t};return r},n.fromObject=function(e){var t=n._fromObject(e);return new n(t)},n._fromBufferReader=function(e){var t={};h.checkState(!e.finished(),"No block data received"),t.header=o.fromBufferReader(e);var r=e.readVarintNum();t.transactions=[];for(var n=0;n"},n.Values={START_OF_BLOCK:8,NULL_HASH:new r("0000000000000000000000000000000000000000000000000000000000000000","hex")},t.exports=n}).call(this,e("buffer").Buffer)},{"../crypto/bn":219,"../crypto/hash":221,"../encoding/bufferreader":227,"../encoding/bufferwriter":228,"../transaction":241,"../util/buffer":255,"../util/preconditions":257,"./blockheader":216,buffer:71,lodash:149}],216:[function(t,r){(function(n){"use strict";var i=t("lodash"),o=t("../crypto/bn"),d=t("../util/buffer"),a=t("../encoding/bufferreader"),s=t("../encoding/bufferwriter"),f=t("../crypto/hash"),c=t("../util/js"),p=t("../util/preconditions"),u=function e(t){if(!(this instanceof e))return new e(t);var r=e._from(t);return this.version=r.version,this.prevHash=r.prevHash,this.merkleRoot=r.merkleRoot,this.time=r.time,this.timestamp=r.time,this.bits=r.bits,this.nonce=r.nonce,r.hash&&p.checkState(this.hash===r.hash,"Argument object hash property does not match block hash."),this};u._from=function(e){var t={};if(d.isBuffer(e))t=u._fromBufferReader(a(e));else if(i.isObject(e))t=u._fromObject(e);else throw new TypeError("Unrecognized argument for BlockHeader");return t},u._fromObject=function(e){p.checkArgument(e,"data is required");var t=e.prevHash,r=e.merkleRoot;i.isString(e.prevHash)&&(t=d.reverse(new n(e.prevHash,"hex"))),i.isString(e.merkleRoot)&&(r=d.reverse(new n(e.merkleRoot,"hex")));var o={hash:e.hash,version:e.version,prevHash:t,merkleRoot:r,time:e.time,timestamp:e.time,bits:e.bits,nonce:e.nonce};return o},u.fromObject=function(e){var t=u._fromObject(e);return new u(t)},u.fromRawBlock=function(e){d.isBuffer(e)||(e=new n(e,"binary"));var t=a(e);t.pos=u.Constants.START_OF_HEADER;var r=u._fromBufferReader(t);return new u(r)},u.fromBuffer=function(e){var t=u._fromBufferReader(a(e));return new u(t)},u.fromString=function(e){var t=new n(e,"hex");return u.fromBuffer(t)},u._fromBufferReader=function(e){var t={version:e.readInt32LE(),prevHash:e.read(32),merkleRoot:e.read(32),time:e.readUInt32LE(),bits:e.readUInt32LE(),nonce:e.readUInt32LE()};return t},u.fromBufferReader=function(e){var t=u._fromBufferReader(e);return new u(t)},u.prototype.toObject=u.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:d.reverse(this.prevHash).toString("hex"),merkleRoot:d.reverse(this.merkleRoot).toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}},u.prototype.toBuffer=function(){return this.toBufferWriter().concat()},u.prototype.toString=function(){return this.toBuffer().toString("hex")},u.prototype.toBufferWriter=function(e){return e||(e=new s),e.writeInt32LE(this.version),e.write(this.prevHash),e.write(this.merkleRoot),e.writeUInt32LE(this.time),e.writeUInt32LE(this.bits),e.writeUInt32LE(this.nonce),e},u.prototype.getTargetDifficulty=function(e){e=e||this.bits;for(var t=new o(16777215&e),r=8*((e>>>24)-3);0t+u.Constants.MAX_TIME_OFFSET)},u.prototype.validProofOfWork=function(){var e=new o(this.id,"hex"),t=this.getTargetDifficulty();return!(0"},u.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new o("10000000000000000000000000000000000000000000000000000000000000000","hex")},r.exports=u}).call(this,t("buffer").Buffer)},{"../crypto/bn":219,"../crypto/hash":221,"../encoding/bufferreader":227,"../encoding/bufferwriter":228,"../util/buffer":255,"../util/js":256,"../util/preconditions":257,buffer:71,lodash:149}],217:[function(e,t){"use strict";t.exports=e("./block"),t.exports.BlockHeader=e("./blockheader"),t.exports.MerkleBlock=e("./merkleblock")},{"./block":215,"./blockheader":216,"./merkleblock":218}],218:[function(e,t){(function(r){"use strict";function n(e){if(!(this instanceof n))return new n(e);var t={};if(d.isBuffer(e))t=n._fromBufferReader(a(e));else if(i.isObject(e)){var r;r=e.header instanceof o?e.header:o.fromObject(e.header),t={header:r,numTransactions:e.numTransactions,hashes:e.hashes,flags:e.flags}}else throw new TypeError("Unrecognized argument for MerkleBlock");return i.extend(this,t),this._flagBitsUsed=0,this._hashesUsed=0,this}var i=e("lodash"),o=e("./blockheader"),d=e("../util/buffer"),a=e("../encoding/bufferreader"),s=e("../encoding/bufferwriter"),f=e("../crypto/hash"),c=e("../util/js"),p=e("../transaction"),u=e("../util/preconditions");n.fromBuffer=function(e){return n.fromBufferReader(a(e))},n.fromBufferReader=function(e){return new n(n._fromBufferReader(e))},n.prototype.toBuffer=function(){return this.toBufferWriter().concat()},n.prototype.toBufferWriter=function(e){e||(e=new s),e.write(this.header.toBuffer()),e.writeUInt32LE(this.numTransactions),e.writeVarintNum(this.hashes.length);for(var t=0;tthis.numTransactions)return!1;if(8*this.flags.length8*this.flags.length)return null;var i=1&this.flags[n.flagBitsUsed>>3]>>>(7&n.flagBitsUsed++);if(0===e||!i){if(n.hashesUsed>=this.hashes.length)return null;var o=this.hashes[n.hashesUsed++];return 0===e&&i&&n.txs.push(o),new r(o,"hex")}var d=this._traverseMerkleTree(e-1,2*t,n),a=d;return 2*t+1>e},n.prototype._calcTreeHeight=function(){for(var e=0;1e.size?t=i.trim(t,d):d=e.length||0==(128&e[e.length-2])))throw new Error("non-minimally encoded script number");return i.fromSM(e,{endian:"little"})},i.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},i.prototype.gt=function(e){return 0this.cmp(e)},i.trim=function(e,t){return e.slice(t-e.length,e.length)},i.pad=function(e,t,n){for(var o=new r(n),d=0;de;e++){this.sig.i=e;var t;try{t=this.toPublicKey()}catch(t){console.error(t);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")},u.fromString=function(e){var t=JSON.parse(e);return new u(t)},u.prototype.randomK=function(){var e=a.getN(),t;do t=o.fromBuffer(i.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(o.Zero)));return this.k=t,this},u.prototype.deterministicK=function(e){c.isUndefined(e)&&(e=0);var t=new r(32);t.fill(1);var n=new r(32);n.fill(0);var d=this.privkey.bn.toBuffer({size:32}),p="little"===this.endian?f.reverse(this.hashbuf):this.hashbuf;n=s.sha256hmac(r.concat([t,new r([0]),d,p]),n),t=s.sha256hmac(t,n),n=s.sha256hmac(r.concat([t,new r([1]),d,p]),n),t=s.sha256hmac(t,n),t=s.sha256hmac(t,n);for(var u=o.fromBuffer(t),l=a.getN(),h=0;h>1?e.add(s):e,c=a.fromX(1&t,f),u=c.mul(s);if(!u.isInfinity())throw new Error("nR is not a valid curve point");var l=i.neg().mod(s),h=e.invm(s),b=c.mul(r).add(n.mul(l)).mul(h),g=d.fromPoint(b,this.sig.compressed);return g},u.prototype.sigError=function(){if(!f.isBuffer(this.hashbuf)||32!==this.hashbuf.length)return"hashbuf must be a 32 byte buffer";var t=this.sig.r,r=this.sig.s;if(!(t.gt(o.Zero)&&t.lt(a.getN()))||!(r.gt(o.Zero)&&r.lt(a.getN())))return"r and s not in range";var i=o.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),e=a.getN(),n=r.invm(e),d=n.mul(i).mod(e),s=n.mul(t).mod(e),c=a.getG().mulAdd(d,this.pubkey.point,s);return c.isInfinity()?"p is infinity":0!==c.getX().mod(e).cmp(t)&&"Invalid signature"},u.toLowS=function(e){return e.gt(o.fromBuffer(new r("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=a.getN().sub(e)),e},u.prototype._findSignature=function(t,n){var e=a.getN(),i=a.getG(),d=0,f,c,p,l;do(!this.k||0=p.cmp(o.Zero)||0>=l.cmp(o.Zero));return l=u.toLowS(l),{s:l,r:p}},u.prototype.sign=function(){var t=this.hashbuf,r=this.privkey,i=r.bn;p.checkState(t&&r&&i,new Error("invalid parameters")),p.checkState(f.isBuffer(t)&&32===t.length,new Error("hashbuf must be a 32 byte buffer"));var d=o.fromBuffer(t,this.endian?{endian:this.endian}:void 0),e=this._findSignature(i,d);return e.compressed=this.pubkey.compressed,this.sig=new n(e),this},u.prototype.signRandomK=function(){return this.randomK(),this.sign()},u.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)},u.prototype.verify=function(){return this.verified=!this.sigError(),this},u.sign=function(e,t,r){return u().set({hashbuf:e,endian:r,privkey:t}).sign().sig},u.verify=function(e,t,r,n){return u().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify().verified},t.exports=u}).call(this,e("buffer").Buffer)},{"../publickey":237,"../util/buffer":255,"../util/preconditions":257,"./bn":219,"./hash":221,"./point":222,"./random":223,"./signature":224,buffer:71,lodash:149}],221:[function(e,t){(function(r){"use strict";var n=e("crypto"),o=e("../util/buffer"),d=e("../util/preconditions"),i=t.exports;i.sha1=function(e){return d.checkArgument(o.isBuffer(e)),n.createHash("sha1").update(e).digest()},i.sha1.blocksize=512,i.sha256=function(e){return d.checkArgument(o.isBuffer(e)),n.createHash("sha256").update(e).digest()},i.sha256.blocksize=512,i.sha256sha256=function(e){return d.checkArgument(o.isBuffer(e)),i.sha256(i.sha256(e))},i.ripemd160=function(e){return d.checkArgument(o.isBuffer(e)),n.createHash("ripemd160").update(e).digest()},i.sha256ripemd160=function(e){return d.checkArgument(o.isBuffer(e)),i.ripemd160(i.sha256(e))},i.sha512=function(e){return d.checkArgument(o.isBuffer(e)),n.createHash("sha512").update(e).digest()},i.sha512.blocksize=1024,i.hmac=function(e,t,n){d.checkArgument(o.isBuffer(t)),d.checkArgument(o.isBuffer(n)),d.checkArgument(e.blocksize);var a=e.blocksize/8;if(n.length>a)n=e(n);else if(n>>=8)}return t},t.exports=i}).call(this,e("_process"),e("buffer").Buffer)},{_process:167,buffer:71,crypto:101}],224:[function(e,t){(function(r){"use strict";var n=e("./bn"),i=e("lodash"),o=e("../util/preconditions"),d=e("../util/buffer"),a=e("../util/js"),s=function e(t,i){if(!(this instanceof e))return new e(t,i);if(t instanceof n)this.set({r:t,s:i});else if(t){this.set(t)}};s.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i="undefined"==typeof e.i?this.i:e.i,this.compressed="undefined"==typeof e.compressed?this.compressed:e.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this},s.fromCompact=function(e){o.checkArgument(d.isBuffer(e),"Argument is expected to be a Buffer");var t=new s,r=!0,a=e.slice(0,1)[0]-27-4;0>a&&(r=!1,a+=4);var i=e.slice(1,33),f=e.slice(33,65);return o.checkArgument(0==a||1==a||2==a||3==a,new Error("i must be 0, 1, 2, or 3")),o.checkArgument(32===i.length,new Error("r must be 32 bytes")),o.checkArgument(32===f.length,new Error("s must be 32 bytes")),t.compressed=r,t.i=a,t.r=n.fromBuffer(i),t.s=n.fromBuffer(f),t},s.fromDER=s.fromBuffer=function(e,t){var r=s.parseDER(e,t),n=new s;return n.r=r.r,n.s=r.s,n},s.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=new s.fromDER(r,!1);return n.nhashtype=t,n},s.fromString=function(e){var t=new r(e,"hex");return s.fromDER(t)},s.parseDER=function(e,t){o.checkArgument(d.isBuffer(e),new Error("DER formatted signature should be a buffer")),i.isUndefined(t)&&(t=!0);var a=e[0];o.checkArgument(48===a,new Error("Header byte should be 0x30"));var f=e[1],c=e.slice(2).length;o.checkArgument(!t||f===c,new Error("Length byte should length of what follows")),f=fe.length)return!1;if(73=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(2!==e[2])return!1;if(0===t)return!1;if(128&n[0])return!1;if(1s.SIGHASH_SINGLE?!1:!0},s.prototype.toTxFormat=function(){var e=this.toDER(),t=new r(1);return t.writeUInt8(this.nhashtype,0),r.concat([e,t])},s.SIGHASH_ALL=1,s.SIGHASH_NONE=2,s.SIGHASH_SINGLE=3,s.SIGHASH_FORKID=64,s.SIGHASH_ANYONECANPAY=128,t.exports=s}).call(this,e("buffer").Buffer)},{"../util/buffer":255,"../util/js":256,"../util/preconditions":257,"./bn":219,buffer:71,lodash:149}],225:[function(e,t){(function(r){"use strict";var n=e("lodash"),i=e("bs58"),o=e("buffer"),d=["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],a=function e(t){if(!(this instanceof e))return new e(t);if(r.isBuffer(t)){this.fromBuffer(t)}else if("string"==typeof t){this.fromString(t)}else t&&this.set(t)};a.validCharacters=function(e){return o.Buffer.isBuffer(e)&&(e=e.toString()),n.every(n.map(e,function(e){return n.includes(d,e)}))},a.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this},a.encode=function(e){if(!o.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return i.encode(e)},a.decode=function(e){if("string"!=typeof e)throw new Error("Input should be a string");return new r(i.decode(e))},a.prototype.fromBuffer=function(e){return this.buf=e,this},a.prototype.fromString=function(e){var t=a.decode(e);return this.buf=t,this},a.prototype.toBuffer=function(){return this.buf},a.prototype.toString=function(){return a.encode(this.buf)},t.exports=a}).call(this,e("buffer").Buffer)},{bs58:68,buffer:71,lodash:149}],226:[function(e,t){(function(r){"use strict";var n=e("lodash"),i=e("./base58"),o=e("buffer"),d=e("../crypto/hash").sha256sha256,a=function e(t){if(!(this instanceof e))return new e(t);if(r.isBuffer(t)){this.fromBuffer(t)}else if("string"==typeof t){this.fromString(t)}else t&&this.set(t)};a.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this},a.validChecksum=function(e,t){return n.isString(e)&&(e=new o.Buffer(i.decode(e))),n.isString(t)&&(t=new o.Buffer(i.decode(t))),t||(t=e.slice(-4),e=e.slice(0,-4)),a.checksum(e).toString("hex")===t.toString("hex")},a.decode=function(e){if("string"!=typeof e)throw new Error("Input must be a string");var t=new r(i.decode(e));if(4>t.length)throw new Error("Input string too short");var n=t.slice(0,-4),o=t.slice(-4),a=d(n),f=a.slice(0,4);if(o.toString("hex")!==f.toString("hex"))throw new Error("Checksum mismatch");return n},a.checksum=function(e){return d(e).slice(0,4)},a.encode=function(e){if(!r.isBuffer(e))throw new Error("Input must be a buffer");var t=new r(e.length+4),n=a.checksum(e);return e.copy(t),n.copy(t,e.length),i.encode(t)},a.prototype.fromBuffer=function(e){return this.buf=e,this},a.prototype.fromString=function(e){var t=a.decode(e);return this.buf=t,this},a.prototype.toBuffer=function(){return this.buf},a.prototype.toString=function(){return a.encode(this.buf)},t.exports=a}).call(this,e("buffer").Buffer)},{"../crypto/hash":221,"./base58":225,buffer:71,lodash:149}],227:[function(e,t){(function(r){"use strict";var n=e("lodash"),i=e("../util/preconditions"),o=e("../util/buffer"),d=e("../crypto/bn"),a=function e(t){if(!(this instanceof e))return new e(t);if(!n.isUndefined(t))if(r.isBuffer(t))this.set({buf:t});else if(n.isString(t)){var i=new r(t,"hex");if(2*i.length!=t.length)throw new TypeError("Invalid hex string");this.set({buf:i})}else if(n.isObject(t)){this.set(t)}else throw new TypeError("Unrecognized argument for BufferReader")};a.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this},a.prototype.eof=function(){return this.pos>=this.buf.length},a.prototype.finished=a.prototype.eof,a.prototype.read=function(e){i.checkArgument(!n.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t},a.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e},a.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return++this.pos,e},a.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos+=2,e},a.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos+=2,e},a.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos+=4,e},a.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos+=4,e},a.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos+=4,e},a.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=d.fromBuffer(e);return this.pos+=8,t},a.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=4294967296*t+e,n;if(9007199254740991>=r)n=new d(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);n=new d(i,10,"le")}return this.pos+=8,n},a.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(9007199254740992>=r)return r;throw new Error("number too large to retain precision - use readVarintBN");break;default:return e;}},a.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return i.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t},a.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);return 253===e?this.read(3):254===e?this.read(5):255===e?this.read(9):this.read(1)},a.prototype.readVarintBN=function(){var e=this.readUInt8();return 253===e?new d(this.readUInt16LE()):254===e?new d(this.readUInt32LE()):255===e?this.readUInt64LEBN():new d(e)},a.prototype.reverse=function(){for(var e=new r(this.buf.length),t=0;te?(t=new r(1),t.writeUInt8(e,0)):65536>e?(t=new r(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):4294967296>e?(t=new r(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=new r(9),t.writeUInt8(255,0),t.writeInt32LE(-1&e,1),t.writeUInt32LE(f(e/4294967296),5)),t},o.varintBufBN=function(e){var t=e.toNumber(),n;if(253>t)n=new r(1),n.writeUInt8(t,0);else if(65536>t)n=new r(3),n.writeUInt8(253,0),n.writeUInt16LE(t,1);else if(4294967296>t)n=new r(5),n.writeUInt8(254,0),n.writeUInt32LE(t,1);else{var i=new o;i.writeUInt8(255),i.writeUInt64LEBN(e);var n=i.concat()}return n},t.exports=o}).call(this,e("buffer").Buffer)},{"../util/buffer":255,assert:17,buffer:71}],229:[function(e,t){(function(r){"use strict";var n=e("./bufferwriter"),i=e("./bufferreader"),o=e("../crypto/bn"),d=function e(t){if(!(this instanceof e))return new e(t);if(r.isBuffer(t))this.buf=t;else if("number"==typeof t){this.fromNumber(t)}else if(t instanceof o){this.fromBN(t)}else if(t){this.set(t)}};d.prototype.set=function(e){return this.buf=e.buf||this.buf,this},d.prototype.fromString=function(e){return this.set({buf:new r(e,"hex")}),this},d.prototype.toString=function(){return this.buf.toString("hex")},d.prototype.fromBuffer=function(e){return this.buf=e,this},d.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this},d.prototype.fromBN=function(e){return this.buf=n().writeVarintBN(e).concat(),this},d.prototype.fromNumber=function(e){return this.buf=n().writeVarintNum(e).concat(),this},d.prototype.toBuffer=function(){return this.buf},d.prototype.toBN=function(){return i(this.buf).readVarintBN()},d.prototype.toNumber=function(){return i(this.buf).readVarintNum()},t.exports=d}).call(this,e("buffer").Buffer)},{"../crypto/bn":219,"./bufferreader":227,"./bufferwriter":228,buffer:71}],230:[function(e,t){"use strict";function r(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var n=e("lodash"),i=function(e,t){var i=function(){if(n.isString(t.message))this.message=r(t.message,arguments);else if(n.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+"\n"+new Error().stack};return i.prototype=Object.create(e.prototype),i.prototype.name=e.prototype.name+t.name,e[t.name]=i,t.errors&&o(i,t.errors),i},o=function(e,t){n.each(t,function(t){i(e,t)})},d={};d.Error=function(){this.message="Internal error",this.stack=this.message+"\n"+new Error().stack},d.Error.prototype=Object.create(Error.prototype),d.Error.prototype.name="bitcore.Error";var a=e("./spec");(function(e,t){return o(e,t),e})(d.Error,a),t.exports=d.Error,t.exports.extend=function(e){return i(d.Error,e)}},{"./spec":231,lodash:149}],231:[function(e,t){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:"Invalid network: must be \"livenet\" or \"testnet\", got {0}"},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+"http://bitcore.io/"+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+r(arguments[0])}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:"Invalid entropy: more than 512 bits is non standard, got \"{0}\""},{name:"NotEnoughEntropy",message:"Invalid entropy: at least 128 bits needed, got \"{0}\""}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:"Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got \"{0}\""}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:"Invalid length for xpubkey: got \"{0}\""},{name:"InvalidPath",message:"Invalid derivation path, it should look like: \"m/1/100\", got \"{0}\""},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]},{}],232:[function(e,t){(function(r){"use strict";function n(e){if(e instanceof n)return e;if(!(this instanceof n))return new n(e);if(!e)return this._generateRandomly();if(u.get(e))return this._generateRandomly(e);if(d.isString(e)||m.isBuffer(e)){if(n.isValidSerialized(e))this._buildFromSerialized(e);else if(_.isValidJSON(e))this._buildFromJSON(e);else if(m.isBuffer(e)&&n.isValidSerialized(e.toString()))this._buildFromSerialized(e.toString());else throw n.getSerializedError(e);}else if(d.isObject(e))this._buildFromObject(e);else throw new y.UnrecognizedArgument(e)}var i=e("assert"),o=e("buffer"),d=e("lodash"),a=e("./util/preconditions"),s=e("./crypto/bn"),f=e("./encoding/base58"),c=e("./encoding/base58check"),p=e("./crypto/hash"),u=e("./networks"),l=e("./crypto/point"),h=e("./privatekey"),b=e("./crypto/random"),g=e("./errors"),y=g.HDPrivateKey,m=e("./util/buffer"),_=e("./util/js"),S=1/8;n.isValidPath=function(e,t){if(d.isString(e)){var r=n._getDerivationIndexes(e);return null!==r&&d.every(r,n.isValidPath)}return!!d.isNumber(e)&&(e=n.Hardened)||t,e512*S)throw new y.InvalidEntropyArgument.TooMuchEntropy(e);var i=p.sha512hmac(e,new o.Buffer("Bitcoin seed"));return new n({network:u.get(t)||u.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:i.slice(0,32),chainCode:i.slice(32,64)})},n.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var t=e("./hdpublickey");this._hdPublicKey=new t(this)}},n.prototype._buildFromBuffers=function(e){n._validateBufferArguments(e),_.defineImmutable(this,{_buffers:e});var t=[e.version,e.depth,e.parentFingerPrint,e.childIndex,e.chainCode,m.emptyBuffer(1),e.privateKey],i=o.Buffer.concat(t);if(!e.checksum||!e.checksum.length)e.checksum=c.checksum(i);else if(e.checksum.toString()!==c.checksum(i).toString())throw new g.InvalidB58Checksum(i);var d=u.get(m.integerFromBuffer(e.version)),a;a=c.encode(o.Buffer.concat(t)),e.xprivkey=new r(a);var f=new h(s.fromBuffer(e.privateKey),d),l=f.toPublicKey(),b=n.ParentFingerPrintSize,y=p.sha256ripemd160(l.toBuffer()).slice(0,b);return _.defineImmutable(this,{xprivkey:a,network:d,depth:m.integerFromSingleByteBuffer(e.depth),privateKey:f,publicKey:l,fingerPrint:y}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},n._validateBufferArguments=function(e){var t=function(t,r){var n=e[t];i(m.isBuffer(n),t+" argument is not a buffer"),i(n.length===r,t+" has not the expected size: found "+n.length+", expected "+r)};t("version",n.VersionSize),t("depth",n.DepthSize),t("parentFingerPrint",n.ParentFingerPrintSize),t("childIndex",n.ChildIndexSize),t("chainCode",n.ChainCodeSize),t("privateKey",n.PrivateKeySize),e.checksum&&e.checksum.length&&t("checksum",n.CheckSumSize)},n.prototype.toString=function(){return this.xprivkey},n.prototype.inspect=function(){return""},n.prototype.toObject=n.prototype.toJSON=function(){return{network:u.get(m.integerFromBuffer(this._buffers.version),"xprivkey").name,depth:m.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:m.integerFromBuffer(this.fingerPrint),parentFingerPrint:m.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:m.integerFromBuffer(this._buffers.childIndex),chainCode:m.bufferToHex(this._buffers.chainCode),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:m.integerFromBuffer(this._buffers.checksum),xprivkey:this.xprivkey}},n.fromBuffer=function(e){return new n(e.toString())},n.prototype.toBuffer=function(){return m.copy(this._buffers.xprivkey)},n.DefaultDepth=0,n.DefaultFingerprint=0,n.DefaultChildIndex=0,n.Hardened=2147483648,n.MaxIndex=2*n.Hardened,n.RootElementAlias=["m","M","m'","M'"],n.VersionSize=4,n.DepthSize=1,n.ParentFingerPrintSize=4,n.ChildIndexSize=4,n.ChainCodeSize=32,n.PrivateKeySize=32,n.CheckSumSize=4,n.DataLength=78,n.SerializedByteSize=82,n.VersionStart=0,n.VersionEnd=n.VersionStart+n.VersionSize,n.DepthStart=n.VersionEnd,n.DepthEnd=n.DepthStart+n.DepthSize,n.ParentFingerPrintStart=n.DepthEnd,n.ParentFingerPrintEnd=n.ParentFingerPrintStart+n.ParentFingerPrintSize,n.ChildIndexStart=n.ParentFingerPrintEnd,n.ChildIndexEnd=n.ChildIndexStart+n.ChildIndexSize,n.ChainCodeStart=n.ChildIndexEnd,n.ChainCodeEnd=n.ChainCodeStart+n.ChainCodeSize,n.PrivateKeyStart=n.ChainCodeEnd+1,n.PrivateKeyEnd=n.PrivateKeyStart+n.PrivateKeySize,n.ChecksumStart=n.PrivateKeyEnd,n.ChecksumEnd=n.ChecksumStart+n.CheckSumSize,i(n.ChecksumEnd===n.SerializedByteSize),t.exports=n}).call(this,e("buffer").Buffer)},{"./crypto/bn":219,"./crypto/hash":221,"./crypto/point":222,"./crypto/random":223,"./encoding/base58":225,"./encoding/base58check":226,"./errors":230,"./hdpublickey":233,"./networks":234,"./privatekey":236,"./util/buffer":255,"./util/js":256,"./util/preconditions":257,assert:17,buffer:71,lodash:149}],233:[function(e,t){(function(r){"use strict";function n(e){if(e instanceof n)return e;if(!(this instanceof n))return new n(e);if(!e)throw new y.MustSupplyArgument;else if(o.isString(e)||S.isBuffer(e)){var t=n.getSerializedError(e);if(!t)return this._buildFromSerialized(e);if(S.isBuffer(e)&&!n.getSerializedError(e.toString()))return this._buildFromSerialized(e.toString());if(t instanceof y.ArgumentIsPrivateExtended)return new p(e).hdPublicKey;throw t}else{if(o.isObject(e))return e instanceof p?this._buildFromPrivate(e):this._buildFromObject(e);throw new y.UnrecognizedArgument(e)}}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=e("lodash"),d=e("./util/preconditions"),a=e("./crypto/bn"),s=e("./encoding/base58"),f=e("./encoding/base58check"),c=e("./crypto/hash"),p=e("./hdprivatekey"),u=e("./networks"),l=e("./crypto/point"),h=e("./publickey"),b=e("./errors"),g=b,y=b.HDPublicKey,m=e("assert"),_=e("./util/js"),S=e("./util/buffer");n.isValidPath=function(e){if(o.isString(e)){var t=p._getDerivationIndexes(e);return null!==t&&o.every(t,n.isValidPath)}return!!o.isNumber(e)&&0<=e&&e=n.Hardened||t)throw new y.InvalidIndexCantDeriveHardened;if(0>e)throw new y.InvalidPath(e);var r=S.integerAsBuffer(e),i=S.concat([this.publicKey.toBuffer(),r]),o=c.sha512hmac(i,this._buffers.chainCode),d=a.fromBuffer(o.slice(0,32),{size:32}),s=o.slice(32,64),f;try{f=h.fromPoint(l.getG().mul(d).add(this.publicKey.point))}catch(t){return this._deriveWithNumber(e+1)}var p=new n({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:e,chainCode:s,publicKey:f});return p},n.prototype._deriveFromString=function(e){if(o.includes(e,"'"))throw new y.InvalidIndexCantDeriveHardened;else if(!n.isValidPath(e))throw new y.InvalidPath(e);var t=p._getDerivationIndexes(e),r=t.reduce(function(e,t){return e._deriveWithNumber(t)},this);return r},n.isValidSerialized=function(e,t){return o.isNull(n.getSerializedError(e,t))},n.getSerializedError=function(e,t){if(!(o.isString(e)||S.isBuffer(e)))return new y.UnrecognizedArgument("expected buffer or string");if(!s.validCharacters(e))return new g.InvalidB58Char("(unknown)",e);try{e=f.decode(e)}catch(t){return new g.InvalidB58Checksum(e)}if(e.length!==n.DataSize)return new y.InvalidLength(e);if(!o.isUndefined(t)){var r=n._validateNetwork(e,t);if(r)return r}var i=S.integerFromBuffer(e.slice(0,4));return i===u.livenet.xprivkey||i===u.testnet.xprivkey?new y.ArgumentIsPrivateExtended:null},n._validateNetwork=function(e,t){var r=u.get(t);if(!r)return new g.InvalidNetworkArgument(t);var i=e.slice(n.VersionStart,n.VersionEnd);return S.integerFromBuffer(i)===r.xpubkey?null:new g.InvalidNetwork(i)},n.prototype._buildFromPrivate=function(e){var t=o.clone(e._buffers),r=l.getG().mul(a.fromBuffer(t.privateKey));return t.publicKey=l.pointToCompressed(r),t.version=S.integerAsBuffer(u.get(S.integerFromBuffer(t.version)).xpubkey),t.privateKey=void 0,t.checksum=void 0,t.xprivkey=void 0,this._buildFromBuffers(t)},n.prototype._buildFromObject=function(e){var t={version:e.network?S.integerAsBuffer(u.get(e.network).xpubkey):e.version,depth:o.isNumber(e.depth)?S.integerAsSingleByteBuffer(e.depth):e.depth,parentFingerPrint:o.isNumber(e.parentFingerPrint)?S.integerAsBuffer(e.parentFingerPrint):e.parentFingerPrint,childIndex:o.isNumber(e.childIndex)?S.integerAsBuffer(e.childIndex):e.childIndex,chainCode:o.isString(e.chainCode)?S.hexToBuffer(e.chainCode):e.chainCode,publicKey:o.isString(e.publicKey)?S.hexToBuffer(e.publicKey):S.isBuffer(e.publicKey)?e.publicKey:e.publicKey.toBuffer(),checksum:o.isNumber(e.checksum)?S.integerAsBuffer(e.checksum):e.checksum};return this._buildFromBuffers(t)},n.prototype._buildFromSerialized=function(e){var t=f.decode(e),r={version:t.slice(n.VersionStart,n.VersionEnd),depth:t.slice(n.DepthStart,n.DepthEnd),parentFingerPrint:t.slice(n.ParentFingerPrintStart,n.ParentFingerPrintEnd),childIndex:t.slice(n.ChildIndexStart,n.ChildIndexEnd),chainCode:t.slice(n.ChainCodeStart,n.ChainCodeEnd),publicKey:t.slice(n.PublicKeyStart,n.PublicKeyEnd),checksum:t.slice(n.ChecksumStart,n.ChecksumEnd),xpubkey:e};return this._buildFromBuffers(r)},n.prototype._buildFromBuffers=function(e){n._validateBufferArguments(e),_.defineImmutable(this,{_buffers:e});var t=[e.version,e.depth,e.parentFingerPrint,e.childIndex,e.chainCode,e.publicKey],i=S.concat(t),o=f.checksum(i);if(!e.checksum||!e.checksum.length)e.checksum=o;else if(e.checksum.toString("hex")!==o.toString("hex"))throw new g.InvalidB58Checksum(i,o);var d=u.get(S.integerFromBuffer(e.version)),a;a=f.encode(S.concat(t)),e.xpubkey=new r(a);var s=new h(e.publicKey,{network:d}),p=n.ParentFingerPrintSize,l=c.sha256ripemd160(s.toBuffer()).slice(0,p);return _.defineImmutable(this,{xpubkey:a,network:d,depth:S.integerFromSingleByteBuffer(e.depth),publicKey:s,fingerPrint:l}),this},n._validateBufferArguments=function(e){var t=function(t,r){var n=e[t];m(S.isBuffer(n),t+" argument is not a buffer, it's "+("undefined"==typeof n?"undefined":i(n))),m(n.length===r,t+" has not the expected size: found "+n.length+", expected "+r)};t("version",n.VersionSize),t("depth",n.DepthSize),t("parentFingerPrint",n.ParentFingerPrintSize),t("childIndex",n.ChildIndexSize),t("chainCode",n.ChainCodeSize),t("publicKey",n.PublicKeySize),e.checksum&&e.checksum.length&&t("checksum",n.CheckSumSize)},n.fromString=function(e){return d.checkArgument(o.isString(e),"No valid string was provided"),new n(e)},n.fromObject=function(e){return d.checkArgument(o.isObject(e),"No valid argument was provided"),new n(e)},n.prototype.toString=function(){return this.xpubkey},n.prototype.inspect=function(){return""},n.prototype.toObject=n.prototype.toJSON=function(){return{network:u.get(S.integerFromBuffer(this._buffers.version)).name,depth:S.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:S.integerFromBuffer(this.fingerPrint),parentFingerPrint:S.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:S.integerFromBuffer(this._buffers.childIndex),chainCode:S.bufferToHex(this._buffers.chainCode),publicKey:this.publicKey.toString(),checksum:S.integerFromBuffer(this._buffers.checksum),xpubkey:this.xpubkey}},n.fromBuffer=function(e){return new n(e)},n.prototype.toBuffer=function(){return S.copy(this._buffers.xpubkey)},n.Hardened=2147483648,n.RootElementAlias=["m","M"],n.VersionSize=4,n.DepthSize=1,n.ParentFingerPrintSize=4,n.ChildIndexSize=4,n.ChainCodeSize=32,n.PublicKeySize=33,n.CheckSumSize=4,n.DataSize=78,n.SerializedByteSize=82,n.VersionStart=0,n.VersionEnd=n.VersionStart+n.VersionSize,n.DepthStart=n.VersionEnd,n.DepthEnd=n.DepthStart+n.DepthSize,n.ParentFingerPrintStart=n.DepthEnd,n.ParentFingerPrintEnd=n.ParentFingerPrintStart+n.ParentFingerPrintSize,n.ChildIndexStart=n.ParentFingerPrintEnd,n.ChildIndexEnd=n.ChildIndexStart+n.ChildIndexSize,n.ChainCodeStart=n.ChildIndexEnd,n.ChainCodeEnd=n.ChainCodeStart+n.ChainCodeSize,n.PublicKeyStart=n.ChainCodeEnd,n.PublicKeyEnd=n.PublicKeyStart+n.PublicKeySize,n.ChecksumStart=n.PublicKeyEnd,n.ChecksumEnd=n.ChecksumStart+n.CheckSumSize,m(n.PublicKeyEnd===n.DataSize),m(n.ChecksumEnd===n.SerializedByteSize),t.exports=n}).call(this,e("buffer").Buffer)},{"./crypto/bn":219,"./crypto/hash":221,"./crypto/point":222,"./encoding/base58":225,"./encoding/base58check":226,"./errors":230,"./hdprivatekey":232,"./networks":234,"./publickey":237,"./util/buffer":255,"./util/js":256,"./util/preconditions":257,assert:17,buffer:71,lodash:149}],234:[function(e,t){"use strict";function r(){}function n(e,t){if(~s.indexOf(e))return e;if(t){o.isArray(t)||(t=[t]);var r=function(t){return s[n][t]===e};for(var n in s)if(o.some(t,r))return s[n];return}return f[e]}function i(e){var t=new r;return a.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey}),e.networkMagic&&a.defineImmutable(t,{networkMagic:d.integerAsBuffer(e.networkMagic)}),e.port&&a.defineImmutable(t,{port:e.port}),e.dnsSeeds&&a.defineImmutable(t,{dnsSeeds:e.dnsSeeds}),o.each(t,function(e){o.isUndefined(e)||o.isObject(e)||(f[e]=t)}),s.push(t),t}var o=e("lodash"),d=e("./util/buffer"),a=e("./util/js"),s=[],f={};r.prototype.toString=function(){return this.name},i({name:"livenet",alias:"mainnet",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:4190024921,port:8333,dnsSeeds:["seed.bitcoin.sipa.be","dnsseed.bluematt.me","dnsseed.bitcoin.dashjr.org","seed.bitcoinstats.com","seed.bitnodes.io","bitseed.xf2.org"]});var c=n("livenet");i({name:"testnet",alias:"regtest",pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956});var p=n("testnet"),u={PORT:18333,NETWORK_MAGIC:d.integerAsBuffer(185665799),DNS_SEEDS:["testnet-seed.bitcoin.petertodd.org","testnet-seed.bluematt.me","testnet-seed.alexykot.me","testnet-seed.bitcoin.schildbach.de"]};for(var l in u)o.isObject(u[l])||(f[u[l]]=p);var h={PORT:18444,NETWORK_MAGIC:d.integerAsBuffer(4206867930),DNS_SEEDS:[]};for(var l in h)o.isObject(h[l])||(f[h[l]]=p);Object.defineProperty(p,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?h.PORT:u.PORT}}),Object.defineProperty(p,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?h.NETWORK_MAGIC:u.NETWORK_MAGIC}}),Object.defineProperty(p,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?h.DNS_SEEDS:u.DNS_SEEDS}}),t.exports={add:i,remove:function(e){for(var t=0;t=e,"Invalid Argument: n must be between 0 and 16"),0===e?i("OP_0"):new i(i.map.OP_1+e-1)},i.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},i.reverseMap=[],i.map)i.reverseMap[i.map[f]]=f;o.extend(i,i.map),i.isSmallIntOp=function(e){return e instanceof i&&(e=e.toNumber()),e===i.map.OP_0||e>=i.map.OP_1&&e<=i.map.OP_16},i.prototype.inspect=function(){return""},t.exports=i}).call(this,e("buffer").Buffer)},{"./util/buffer":255,"./util/js":256,"./util/preconditions":257,buffer:71,lodash:149}],236:[function(e,t){(function(r){"use strict";function n(e,t){if(!(this instanceof n))return new n(e,t);if(e instanceof n)return e;var r=this._classifyArguments(e,t);if(!r.bn||0===r.bn.cmp(new a(0)))throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(c.getN()))throw new TypeError("Number must be less than N");if("undefined"==typeof r.network)throw new TypeError("Must specify the network (\"livenet\" or \"testnet\")");return s.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}var i=e("lodash"),o=e("./address"),d=e("./encoding/base58check"),a=e("./crypto/bn"),s=e("./util/js"),f=e("./networks"),c=e("./crypto/point"),p=e("./publickey"),u=e("./crypto/random"),l=e("./util/preconditions");n.prototype._classifyArguments=function(e,t){var o={compressed:!0,network:t?f.get(t):f.defaultNetwork};if(i.isUndefined(e)||i.isNull(e))o.bn=n._getRandomBN();else if(e instanceof a)o.bn=e;else if(e instanceof r||e instanceof Uint8Array)o=n._transformBuffer(e,t);else if(e.bn&&e.network)o=n._transformObject(e);else if(!t&&f.get(e))o.bn=n._getRandomBN(),o.network=f.get(e);else if("string"==typeof e)s.isHexa(e)?o.bn=new a(new r(e,"hex")):o=n._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return o},n._getRandomBN=function(){var e,t;do{var r=u.getRandomBuffer(32);t=a.fromBuffer(r),e=t.lt(c.getN())}while(!e);return t},n._transformBuffer=function(e,t){var r={};if(32===e.length)return n._transformBNBuffer(e,t);if(r.network=f.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==f.get(t))throw new TypeError("Private key network mismatch");if(34===e.length&&1===e[33])r.compressed=!0;else if(33===e.length)r.compressed=!1;else throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");return r.bn=a.fromBuffer(e.slice(1,33)),r},n._transformBNBuffer=function(e,t){var r={network:f.get(t)||f.defaultNetwork,bn:a.fromBuffer(e),compressed:!1};return r},n._transformWIF=function(e,t){return n._transformBuffer(d.decode(e),t)},n.fromBuffer=function(e,t){return new n(e,t)},n._transformObject=function(e){var t=new a(e.bn,"hex"),r=f.get(e.network);return{bn:t,network:r,compressed:e.compressed}},n.fromString=n.fromWIF=function(e){return l.checkArgument(i.isString(e),"First argument is expected to be a string."),new n(e)},n.fromObject=function(e){return l.checkArgument(i.isObject(e),"First argument is expected to be an object."),new n(e)},n.fromRandom=function(e){var t=n._getRandomBN();return new n(t,e)},n.getValidationError=function(e,t){var r;try{new n(e,t)}catch(t){r=t}return r},n.isValid=function(e,t){return!!e&&!n.getValidationError(e,t)},n.prototype.toString=function(){return this.toBuffer().toString("hex")},n.prototype.toWIF=function(){var e=this.network,t=this.compressed,n;return n=t?r.concat([new r([e.privatekey]),this.bn.toBuffer({size:32}),new r([1])]):r.concat([new r([e.privatekey]),this.bn.toBuffer({size:32})]),d.encode(n)},n.prototype.toBigNumber=function(){return this.bn},n.prototype.toBuffer=function(){return this.bn.toBuffer()},n.prototype.toBufferNoPadding=function(){return this.bn.toBuffer()},n.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=p.fromPrivateKey(this)),this._pubkey},n.prototype.toAddress=function(e){var t=this.toPublicKey();return o.fromPublicKey(t,e||this.network)},n.prototype.toObject=n.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},n.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return""},t.exports=n}).call(this,e("buffer").Buffer)},{"./address":214,"./crypto/bn":219,"./crypto/point":222,"./crypto/random":223,"./encoding/base58check":226,"./networks":234,"./publickey":237,"./util/js":256,"./util/preconditions":257,buffer:71,lodash:149}],237:[function(e,t){(function(r){"use strict";function n(e,t){if(!(this instanceof n))return new n(e,t);if(c.checkArgument(e,"First argument is required, please include public key data."),e instanceof n)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),a.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||s.defaultNetwork}),this}var i=e("./crypto/bn"),o=e("./crypto/point"),d=e("./crypto/hash"),a=e("./util/js"),s=e("./networks"),f=e("lodash"),c=e("./util/preconditions");n.prototype._classifyArgs=function(e,t){var i={compressed:f.isUndefined(t.compressed)||t.compressed};if(e instanceof o)i.point=e;else if(e.x&&e.y)i=n._transformObject(e);else if("string"==typeof e)i=n._transformDER(new r(e,"hex"));else if(n._isBuffer(e))i=n._transformDER(e);else if(n._isPrivateKey(e))i=n._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return i.network||(i.network=f.isUndefined(t.network)?void 0:s.get(t.network)),i},n._isPrivateKey=function(t){var r=e("./privatekey");return t instanceof r},n._isBuffer=function(e){return e instanceof r||e instanceof Uint8Array},n._transformPrivateKey=function(e){c.checkArgument(n._isPrivateKey(e),"Must be an instance of PrivateKey");var t={point:o.getG().mul(e.bn),compressed:e.compressed,network:e.network};return t},n._transformDER=function(e,t){c.checkArgument(n._isBuffer(e),"Must be a hex buffer of DER encoded public key");var r={};t=!!f.isUndefined(t)||t;var d,a,s,p;if(4===e[0]||!t&&(6===e[0]||7===e[0])){if(s=e.slice(1,33),p=e.slice(33,65),32!==s.length||32!==p.length||65!==e.length)throw new TypeError("Length of x and y must be 32 bytes");d=new i(s),a=new i(p),r.point=new o(d,a),r.compressed=!1}else if(3===e[0])s=e.slice(1),d=new i(s),r=n._transformX(!0,d),r.compressed=!0;else if(2===e[0])s=e.slice(1),d=new i(s),r=n._transformX(!1,d),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r},n._transformX=function(e,t){c.checkArgument("boolean"==typeof e,"Must specify whether y is odd or not (true or false)");var r={point:o.fromX(e,t)};return r},n._transformObject=function(e){var t=new i(e.x,"hex"),r=new i(e.y,"hex"),d=new o(t,r);return new n(d,{compressed:e.compressed})},n.fromPrivateKey=function(e){c.checkArgument(n._isPrivateKey(e),"Must be an instance of PrivateKey");var t=n._transformPrivateKey(e);return new n(t.point,{compressed:t.compressed,network:t.network})},n.fromDER=n.fromBuffer=function(e,t){c.checkArgument(n._isBuffer(e),"Must be a hex buffer of DER encoded public key");var r=n._transformDER(e,t);return new n(r.point,{compressed:r.compressed})},n.fromPoint=function(e,t){return c.checkArgument(e instanceof o,"First argument must be an instance of Point."),new n(e,{compressed:t})},n.fromString=function(e,t){var i=new r(e,t||"hex"),o=n._transformDER(i);return new n(o.point,{compressed:o.compressed})},n.fromX=function(e,t){var r=n._transformX(e,t);return new n(r.point,{compressed:r.compressed})},n.getValidationError=function(e){var t;try{new n(e)}catch(r){t=r}return t},n.isValid=function(e){return!n.getValidationError(e)},n.prototype.toObject=n.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},n.prototype.toBuffer=n.prototype.toDER=function(){var e=this.point.getX(),t=this.point.getY(),n=e.toBuffer({size:32}),i=t.toBuffer({size:32}),o;if(!this.compressed)return o=new r([4]),r.concat([o,n,i]);var d=i[i.length-1]%2;return o=d?new r([3]):new r([2]),r.concat([o,n])},n.prototype._getID=function(){return d.sha256ripemd160(this.toBuffer())},n.prototype.toAddress=function(t){var r=e("./address");return r.fromPublicKey(this,t||this.network)},n.prototype.toString=function(){return this.toDER().toString("hex")},n.prototype.inspect=function(){return""},t.exports=n}).call(this,e("buffer").Buffer)},{"./address":214,"./crypto/bn":219,"./crypto/hash":221,"./crypto/point":222,"./networks":234,"./privatekey":236,"./util/js":256,"./util/preconditions":257,buffer:71,lodash:149}],238:[function(e,t){"use strict";t.exports=e("./script"),t.exports.Interpreter=e("./interpreter")},{"./interpreter":239,"./script":240}],239:[function(e,t){(function(r){"use strict";var o=e("lodash"),n=e("./script"),d=e("../opcode"),a=e("../crypto/bn"),i=e("../crypto/hash"),s=e("../crypto/signature"),f=e("../publickey"),c=function e(t){return this instanceof e?void(t?(this.initialize(),this.set(t)):this.initialize()):new e(t)};c.prototype.verify=function(t,r,i,d,a){var s=e("../transaction");o.isUndefined(i)&&(i=new s),o.isUndefined(d)&&(d=0),o.isUndefined(a)&&(a=0),this.set({script:t,tx:i,nin:d,flags:a});var f;if(0!=(a&c.SCRIPT_VERIFY_SIGPUSHONLY)&&!t.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;a&c.SCRIPT_VERIFY_P2SH&&(f=this.stack.slice());var p=this.stack;if(this.initialize(),this.set({script:r,stack:p,tx:i,nin:d,flags:a}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var u=this.stack[this.stack.length-1];if(!c.castToBool(u))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(a&c.SCRIPT_VERIFY_P2SH&&r.isScriptHashOut()){if(!t.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===f.length)throw new Error("internal error - stack copy empty");var l=f[f.length-1],h=n.fromBuffer(l);return f.pop(),this.initialize(),this.set({script:h,stack:f,tx:i,nin:d,flags:a}),!!this.evaluate()&&(0===f.length?(this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1):!!c.castToBool(f[f.length-1])||(this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1))}return!0},t.exports=c,c.prototype.initialize=function(){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},c.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin="undefined"==typeof e.nin?this.nin:e.nin,this.stack=e.stack||this.stack,this.altstack=e.altack||this.altstack,this.pc="undefined"==typeof e.pc?this.pc:e.pc,this.pbegincodehash="undefined"==typeof e.pbegincodehash?this.pbegincodehash:e.pbegincodehash,this.nOpCount="undefined"==typeof e.nOpCount?this.nOpCount:e.nOpCount,this.vfExec=e.vfExec||this.vfExec,this.errstr=e.errstr||this.errstr,this.flags="undefined"==typeof e.flags?this.flags:e.flags},c.true=new r([1]),c.false=new r([]),c.MAX_SCRIPT_ELEMENT_SIZE=520,c.LOCKTIME_THRESHOLD=5e8,c.LOCKTIME_THRESHOLD_BN=new a(c.LOCKTIME_THRESHOLD),c.SCRIPT_VERIFY_NONE=0,c.SCRIPT_VERIFY_P2SH=1,c.SCRIPT_VERIFY_STRICTENC=2,c.SCRIPT_VERIFY_DERSIG=4,c.SCRIPT_VERIFY_LOW_S=8,c.SCRIPT_VERIFY_NULLDUMMY=16,c.SCRIPT_VERIFY_SIGPUSHONLY=32,c.SCRIPT_VERIFY_MINIMALDATA=64,c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,c.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,c.castToBool=function(e){for(var t=0;t=c.LOCKTIME_THRESHOLD&&e.gte(c.LOCKTIME_THRESHOLD_BN))&&!e.gt(new a(this.tx.nLockTime))&&!!this.tx.inputs[this.nin].isFinal()},c.prototype.step=function(){var e=0!=(this.flags&c.SCRIPT_VERIFY_MINIMALDATA),t=-1===this.vfExec.indexOf(!1),r=this.script.chunks[this.pc],p,u,l,h,b,g,y,m,_,S,v,I,x,A,w,E,P;this.pc++;var B=r.opcodenum;if(o.isUndefined(B))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(r.buf&&r.buf.length>c.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(B>d.OP_16&&201<++this.nOpCount)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(B===d.OP_CAT||B===d.OP_SUBSTR||B===d.OP_LEFT||B===d.OP_RIGHT||B===d.OP_INVERT||B===d.OP_AND||B===d.OP_OR||B===d.OP_XOR||B===d.OP_2MUL||B===d.OP_2DIV||B===d.OP_MUL||B===d.OP_DIV||B===d.OP_MOD||B===d.OP_LSHIFT||B===d.OP_RSHIFT)return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(t&&0<=B&&B<=d.OP_PUSHDATA4){if(e&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!r.buf)this.stack.push(c.false);else if(r.len!==r.buf.length)throw new Error("Length of push value not equal to length of data");else this.stack.push(r.buf)}else if(t||d.OP_IF<=B&&B<=d.OP_ENDIF)switch(B){case d.OP_1NEGATE:case d.OP_1:case d.OP_2:case d.OP_3:case d.OP_4:case d.OP_5:case d.OP_6:case d.OP_7:case d.OP_8:case d.OP_9:case d.OP_10:case d.OP_11:case d.OP_12:case d.OP_13:case d.OP_14:case d.OP_15:case d.OP_16:b=B-(d.OP_1-1),p=new a(b).toScriptNumBuffer(),this.stack.push(p);break;case d.OP_NOP:break;case d.OP_NOP2:case d.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&c.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(1>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var O=a.fromScriptNumBuffer(this.stack[this.stack.length-1],e,5);if(O.lt(new a(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(O))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case d.OP_NOP1:case d.OP_NOP3:case d.OP_NOP4:case d.OP_NOP5:case d.OP_NOP6:case d.OP_NOP7:case d.OP_NOP8:case d.OP_NOP9:case d.OP_NOP10:if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case d.OP_IF:case d.OP_NOTIF:{if(E=!1,t){if(1>this.stack.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;p=this.stack.pop(),E=c.castToBool(p),B===d.OP_NOTIF&&(E=!E)}this.vfExec.push(E)}break;case d.OP_ELSE:{if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1]}break;case d.OP_ENDIF:{if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop()}break;case d.OP_VERIFY:{if(1>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(p=this.stack[this.stack.length-1],E=c.castToBool(p),E)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1}break;case d.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;break;case d.OP_TOALTSTACK:{if(1>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop())}break;case d.OP_FROMALTSTACK:{if(1>this.altstack.length)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop())}break;case d.OP_2DROP:{if(2>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop()}break;case d.OP_2DUP:{if(2>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;u=this.stack[this.stack.length-2],l=this.stack[this.stack.length-1],this.stack.push(u),this.stack.push(l)}break;case d.OP_3DUP:{if(3>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;u=this.stack[this.stack.length-3],l=this.stack[this.stack.length-2];var R=this.stack[this.stack.length-1];this.stack.push(u),this.stack.push(l),this.stack.push(R)}break;case d.OP_2OVER:{if(4>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;u=this.stack[this.stack.length-4],l=this.stack[this.stack.length-3],this.stack.push(u),this.stack.push(l)}break;case d.OP_2ROT:{if(6>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;h=this.stack.splice(this.stack.length-6,2),this.stack.push(h[0]),this.stack.push(h[1])}break;case d.OP_2SWAP:{if(4>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;h=this.stack.splice(this.stack.length-4,2),this.stack.push(h[0]),this.stack.push(h[1])}break;case d.OP_IFDUP:{if(1>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack[this.stack.length-1],E=c.castToBool(p),E&&this.stack.push(p)}break;case d.OP_DEPTH:p=new a(this.stack.length).toScriptNumBuffer(),this.stack.push(p);break;case d.OP_DROP:{if(1>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop()}break;case d.OP_DUP:{if(1>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-1])}break;case d.OP_NIP:{if(2>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1)}break;case d.OP_OVER:{if(2>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-2])}break;case d.OP_PICK:case d.OP_ROLL:{if(2>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(p=this.stack[this.stack.length-1],m=a.fromScriptNumBuffer(p,e),b=m.toNumber(),this.stack.pop(),0>b||b>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack[this.stack.length-b-1],B===d.OP_ROLL&&this.stack.splice(this.stack.length-b-1,1),this.stack.push(p)}break;case d.OP_ROT:{if(3>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=this.stack[this.stack.length-3],y=this.stack[this.stack.length-2];var T=this.stack[this.stack.length-1];this.stack[this.stack.length-3]=y,this.stack[this.stack.length-2]=T,this.stack[this.stack.length-1]=g}break;case d.OP_SWAP:{if(2>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=this.stack[this.stack.length-2],y=this.stack[this.stack.length-1],this.stack[this.stack.length-2]=y,this.stack[this.stack.length-1]=g}break;case d.OP_TUCK:{if(2>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,this.stack[this.stack.length-1])}break;case d.OP_SIZE:{if(1>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=new a(this.stack[this.stack.length-1].length),this.stack.push(m.toScriptNumBuffer())}break;case d.OP_EQUAL:case d.OP_EQUALVERIFY:{if(2>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;u=this.stack[this.stack.length-2],l=this.stack[this.stack.length-1];var N=u.toString("hex")===l.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(N?c.true:c.false),B===d.OP_EQUALVERIFY)if(N)this.stack.pop();else return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1}break;case d.OP_1ADD:case d.OP_1SUB:case d.OP_NEGATE:case d.OP_ABS:case d.OP_NOT:case d.OP_0NOTEQUAL:{if(1>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack[this.stack.length-1],m=a.fromScriptNumBuffer(p,e),B===d.OP_1ADD?m=m.add(a.One):B===d.OP_1SUB?m=m.sub(a.One):B===d.OP_NEGATE?m=m.neg():B===d.OP_ABS?0>m.cmp(a.Zero)&&(m=m.neg()):B===d.OP_NOT?m=new a((0===m.cmp(a.Zero))+0):B===d.OP_0NOTEQUAL?m=new a((0!==m.cmp(a.Zero))+0):void 0,this.stack.pop(),this.stack.push(m.toScriptNumBuffer())}break;case d.OP_ADD:case d.OP_SUB:case d.OP_BOOLAND:case d.OP_BOOLOR:case d.OP_NUMEQUAL:case d.OP_NUMEQUALVERIFY:case d.OP_NUMNOTEQUAL:case d.OP_LESSTHAN:case d.OP_GREATERTHAN:case d.OP_LESSTHANOREQUAL:case d.OP_GREATERTHANOREQUAL:case d.OP_MIN:case d.OP_MAX:{if(2>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(_=a.fromScriptNumBuffer(this.stack[this.stack.length-2],e),S=a.fromScriptNumBuffer(this.stack[this.stack.length-1],e),m=new a(0),B===d.OP_ADD?m=_.add(S):B===d.OP_SUB?m=_.sub(S):B===d.OP_BOOLAND?m=new a((0!==_.cmp(a.Zero)&&0!==S.cmp(a.Zero))+0):B===d.OP_BOOLOR?m=new a((0!==_.cmp(a.Zero)||0!==S.cmp(a.Zero))+0):B===d.OP_NUMEQUAL?m=new a((0===_.cmp(S))+0):B===d.OP_NUMEQUALVERIFY?m=new a((0===_.cmp(S))+0):B===d.OP_NUMNOTEQUAL?m=new a((0!==_.cmp(S))+0):B===d.OP_LESSTHAN?m=new a((0>_.cmp(S))+0):B===d.OP_GREATERTHAN?m=new a((0<_.cmp(S))+0):B===d.OP_LESSTHANOREQUAL?m=new a((0>=_.cmp(S))+0):B===d.OP_GREATERTHANOREQUAL?m=new a((0<=_.cmp(S))+0):B===d.OP_MIN?m=0>_.cmp(S)?_:S:B===d.OP_MAX?m=0<_.cmp(S)?_:S:void 0,(this.stack.pop(),this.stack.pop(),this.stack.push(m.toScriptNumBuffer()),B===d.OP_NUMEQUALVERIFY))if(c.castToBool(this.stack[this.stack.length-1]))this.stack.pop();else return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1}break;case d.OP_WITHIN:{if(3>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;_=a.fromScriptNumBuffer(this.stack[this.stack.length-3],e),S=a.fromScriptNumBuffer(this.stack[this.stack.length-2],e);var C=a.fromScriptNumBuffer(this.stack[this.stack.length-1],e);E=0>=S.cmp(_)&&0>_.cmp(C),this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(E?c.true:c.false)}break;case d.OP_RIPEMD160:case d.OP_SHA1:case d.OP_SHA256:case d.OP_HASH160:case d.OP_HASH256:{if(1>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack[this.stack.length-1];var j;B===d.OP_RIPEMD160?j=i.ripemd160(p):B===d.OP_SHA1?j=i.sha1(p):B===d.OP_SHA256?j=i.sha256(p):B===d.OP_HASH160?j=i.sha256ripemd160(p):B===d.OP_HASH256&&(j=i.sha256sha256(p)),this.stack.pop(),this.stack.push(j)}break;case d.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case d.OP_CHECKSIG:case d.OP_CHECKSIGVERIFY:{if(2>this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;v=this.stack[this.stack.length-2],I=this.stack[this.stack.length-1],x=new n().set({chunks:this.script.chunks.slice(this.pbegincodehash)});var M=new n().add(v);if(x.findAndDelete(M),!this.checkSignatureEncoding(v)||!this.checkPubkeyEncoding(I))return!1;try{A=s.fromTxFormat(v),w=f.fromBuffer(I,!1),P=this.tx.verifySignature(A,w,this.nin,x)}catch(t){P=!1}if(this.stack.pop(),this.stack.pop(),this.stack.push(P?c.true:c.false),B===d.OP_CHECKSIGVERIFY)if(P)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1}break;case d.OP_CHECKMULTISIG:case d.OP_CHECKMULTISIGVERIFY:{var U=1;if(this.stack.lengthL||20z||z>L)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var H=++U;if(U+=z,this.stack.lengthL&&(P=!1)}for(;1this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&c.SCRIPT_VERIFY_NULLDUMMY&&this.stack[this.stack.length-1].length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(P?c.true:c.false),B===d.OP_CHECKMULTISIGVERIFY)if(P)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1}break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;}return!0}}).call(this,e("buffer").Buffer)},{"../crypto/bn":219,"../crypto/hash":221,"../crypto/signature":224,"../opcode":235,"../publickey":237,"../transaction":241,"./script":240,buffer:71,lodash:149}],240:[function(e,t){(function(r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("../address"),o=e("../encoding/bufferreader"),d=e("../encoding/bufferwriter"),a=e("../crypto/hash"),f=e("../opcode"),c=e("../publickey"),s=e("../crypto/signature"),p=e("../networks"),u=e("../util/preconditions"),l=e("lodash"),h=e("../errors"),b=e("buffer"),g=e("../util/buffer"),y=e("../util/js"),m=function e(t){return this instanceof e?(this.chunks=[],g.isBuffer(t))?e.fromBuffer(t):t instanceof i?e.fromAddress(t):t instanceof e?e.fromBuffer(t.toBuffer()):"string"==typeof t?e.fromString(t):void("undefined"!=typeof t&&this.set(t)):new e(t)};m.prototype.set=function(e){return this.chunks=e.chunks||this.chunks,this},m.fromBuffer=function(t){var e=new m;e.chunks=[];for(var r=new o(t);!r.finished();)try{var n=r.readUInt8(),i,d;0"},m.prototype.isPublicKeyHashOut=function(){return!!(5===this.chunks.length&&this.chunks[0].opcodenum===f.OP_DUP&&this.chunks[1].opcodenum===f.OP_HASH160&&this.chunks[2].buf&&20===this.chunks[2].buf.length&&this.chunks[3].opcodenum===f.OP_EQUALVERIFY&&this.chunks[4].opcodenum===f.OP_CHECKSIG)},m.prototype.isPublicKeyHashIn=function(){if(2===this.chunks.length){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&48===e[0]&&t&&t.length){var r=t[0];if((4===r||6===r||7===r)&&65===t.length)return!0;if((3===r||2===r)&&33===t.length)return!0}}return!1},m.prototype.getPublicKey=function(){return u.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf},m.prototype.getPublicKeyHash=function(){return u.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf},m.prototype.isPublicKeyOut=function(){if(2===this.chunks.length&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===f.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if((4===t||6===t||7===t)&&65===e.length?r=!0:(3===t||2===t)&&33===e.length&&(r=!0),r)return c.isValid(e)}return!1},m.prototype.isPublicKeyIn=function(){if(1===this.chunks.length){var e=this.chunks[0].buf;if(e&&e.length&&48===e[0])return!0}return!1},m.prototype.isScriptHashOut=function(){var e=this.toBuffer();return 23===e.length&&e[0]===f.OP_HASH160&&20===e[1]&&e[e.length-1]===f.OP_EQUAL},m.prototype.isScriptHashIn=function(){if(1>=this.chunks.length)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=m.fromBuffer(t)}catch(t){if(t instanceof h.Script.InvalidBuffer)return!1;throw t}var n=r.classify();return n!==m.types.UNKNOWN},m.prototype.isMultisigOut=function(){return 3r)n=f.OP_PUSHDATA1;else if(65536>r)n=f.OP_PUSHDATA2;else if(4294967296>r)n=f.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:r,opcodenum:n},t),this},m.prototype.removeCodeseparators=function(){for(var e=[],t=0;t=r[0]?n===f.OP_1+(r[0]-1):1===r.length&&129===r[0]?n===f.OP_1NEGATE:75>=r.length?n===r.length:255>=r.length?n===f.OP_PUSHDATA1:!(65535>=r.length)||n===f.OP_PUSHDATA2},m.prototype._decodeOP_N=function(e){if(e===f.OP_0)return 0;if(e>=f.OP_1&&e<=f.OP_16)return e-(f.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))},m.prototype.getSignatureOperationsCount=function(e){e=!!l.isUndefined(e)||e;var t=this,r=0,n=f.OP_INVALIDOPCODE;return l.each(t.chunks,function(i){var o=i.opcodenum;o==f.OP_CHECKSIG||o==f.OP_CHECKSIGVERIFY?r++:(o==f.OP_CHECKMULTISIG||o==f.OP_CHECKMULTISIGVERIFY)&&(e&&n>=f.OP_1&&n<=f.OP_16?r+=t._decodeOP_N(n):r+=20),n=o}),r},t.exports=m}).call(this,e("buffer").Buffer)},{"../address":214,"../crypto/hash":221,"../crypto/signature":224,"../encoding/bufferreader":227,"../encoding/bufferwriter":228,"../errors":230,"../networks":234,"../opcode":235,"../publickey":237,"../util/buffer":255,"../util/js":256,"../util/preconditions":257,buffer:71,lodash:149}],241:[function(e,t){"use strict";t.exports=e("./transaction"),t.exports.Input=e("./input"),t.exports.Output=e("./output"),t.exports.UnspentOutput=e("./unspentoutput"),t.exports.Signature=e("./signature"),t.exports.Sighash=e("./sighash")},{"./input":242,"./output":248,"./sighash":249,"./signature":250,"./transaction":251,"./unspentoutput":252}],242:[function(e,t){"use strict";t.exports=e("./input"),t.exports.PublicKey=e("./publickey"),t.exports.PublicKeyHash=e("./publickeyhash"),t.exports.MultiSig=e("./multisig.js"),t.exports.MultiSigScriptHash=e("./multisigscripthash.js")},{"./input":243,"./multisig.js":244,"./multisigscripthash.js":245,"./publickey":246,"./publickeyhash":247}],243:[function(e,t){"use strict";function r(e){return this instanceof r?e?this._fromObject(e):void 0:new r(e)}var n=e("lodash"),i=e("../../util/preconditions"),o=e("../../errors"),d=e("../../encoding/bufferwriter"),a=e("buffer"),s=e("../../util/buffer"),f=e("../../util/js"),c=e("../../script"),p=e("../sighash"),u=e("../output"),l=4294967295,h=l;r.MAXINT=l,r.DEFAULT_SEQNUMBER=h,r.DEFAULT_LOCKTIME_SEQNUMBER=l-1,r.DEFAULT_RBF_SEQNUMBER=l-2,Object.defineProperty(r.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new c(this._scriptBuffer),this._script._isInput=!0),this._script)}}),r.fromObject=function(e){i.checkArgument(n.isObject(e));var t=new r;return t._fromObject(e)},r.prototype._fromObject=function(e){var t;if(t=n.isString(e.prevTxId)&&f.isHexa(e.prevTxId)?new a.Buffer(e.prevTxId,"hex"):e.prevTxId,this.output=e.output?e.output instanceof u?e.output:new u(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=n.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=n.isUndefined(e.sequenceNumber)?n.isUndefined(e.seqnum)?h:e.seqnum:e.sequenceNumber,n.isUndefined(e.script)&&n.isUndefined(e.scriptBuffer))throw new o.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this},r.prototype.toObject=r.prototype.toJSON=function(){var e={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(e.scriptString=this.script.toString()),this.output&&(e.output=this.output.toObject()),e},r.fromBufferReader=function(e){var t=new r;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t},r.prototype.toBufferWriter=function(e){e||(e=new d),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e},r.prototype.setScript=function(e){if(this._script=null,e instanceof c)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(f.isHexa(e))this._scriptBuffer=new a.Buffer(e,"hex");else if(n.isString(e))this._script=new c(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(s.isBuffer(e))this._scriptBuffer=new a.Buffer(e);else throw new TypeError("Invalid argument type: script");return this},r.prototype.getSignatures=function(){throw new o.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))},r.prototype.isFullySigned=function(){throw new o.AbstractMethodInvoked("Input#isFullySigned")},r.prototype.isFinal=function(){return 4294967295!==this.sequenceNumber},r.prototype.addSignature=function(){throw new o.AbstractMethodInvoked("Input#addSignature")},r.prototype.clearSignatures=function(){throw new o.AbstractMethodInvoked("Input#clearSignatures")},r.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,p.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)},r.prototype.isNull=function(){return"0000000000000000000000000000000000000000000000000000000000000000"===this.prevTxId.toString("hex")&&4294967295===this.outputIndex},r.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length},t.exports=r},{"../../encoding/bufferwriter":228,"../../errors":230,"../../script":238,"../../util/buffer":255,"../../util/js":256,"../../util/preconditions":257,"../output":248,"../sighash":249,buffer:71,lodash:149}],244:[function(e,t){"use strict";function r(e,t,r,i){d.apply(this,arguments);var o=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=n.sortBy(t,function(e){return e.toString("hex")}),s.checkState(f.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},n.each(this.publicKeys,function(e,t){o.publicKeyIndex[e.toString()]=t}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):Array(this.publicKeys.length)}var n=e("lodash"),i=e("inherits"),o=e("../transaction"),d=e("./input"),a=e("../output"),s=e("../../util/preconditions"),f=e("../../script"),c=e("../../crypto/signature"),p=e("../sighash"),u=e("../../publickey"),l=e("../../util/buffer"),h=e("../signature");i(r,d),r.prototype.toObject=function(){var e=d.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=n.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},r.prototype._deserializeSignatures=function(e){return n.map(e,function(e){return e?new h(e):void 0})},r.prototype._serializeSignatures=function(){return n.map(this.signatures,function(e){return e?e.toObject():void 0})},r.prototype.getSignatures=function(e,t,r,i){s.checkState(this.output instanceof a),i=i||c.SIGHASH_ALL|c.SIGHASH_FORKID;var o=this,d=[];return n.each(this.publicKeys,function(n){n.toString()===t.publicKey.toString()&&d.push(new h({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:p.sign(e,t,i,r,o.output.script,o.output.satoshisBN),sigtype:i}))}),d},r.prototype.addSignature=function(e,t){return s.checkState(!this.isFullySigned(),"All needed signatures have already been added"),s.checkArgument(!n.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),s.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},r.prototype._updateScript=function(){return this.setScript(f.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},r.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,function(e){return!n.isUndefined(e)}),function(e){return l.concat([e.signature.toDER(),l.integerAsSingleByteBuffer(e.sigtype)])})},r.prototype.clearSignatures=function(){this.signatures=Array(this.publicKeys.length),this._updateScript()},r.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},r.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},r.prototype.countSignatures=function(){return n.reduce(this.signatures,function(e,t){return e+!!t},0)},r.prototype.publicKeysWithoutSignature=function(){var e=this;return n.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},r.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,p.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)},r.normalizeSignatures=function(e,t,r,n,i){return i.map(function(i){var o=null;return n=n.filter(function(n){if(o)return!0;var d=new h({signature:c.fromTxFormat(n),publicKey:i,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:c.SIGHASH_ALL});d.signature.nhashtype=d.sigtype;var a=p.verify(e,d.signature,d.publicKey,d.inputIndex,t.output.script);return!a||(o=d,!1)}),o?o:null})},r.OPCODES_SIZE=1,r.SIGNATURE_SIZE=73,r.prototype._estimateSize=function(){return r.OPCODES_SIZE+this.threshold*r.SIGNATURE_SIZE},t.exports=r},{"../../crypto/signature":224,"../../publickey":237,"../../script":238,"../../util/buffer":255,"../../util/preconditions":257,"../output":248,"../sighash":249,"../signature":250,"../transaction":251,"./input":243,inherits:146,lodash:149}],245:[function(e,t){"use strict";function r(e,t,r,i){o.apply(this,arguments);var d=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=n.sortBy(t,function(e){return e.toString("hex")}),this.redeemScript=s.buildMultisigOut(this.publicKeys,r),a.checkState(s.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},n.each(this.publicKeys,function(e,t){d.publicKeyIndex[e.toString()]=t}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):Array(this.publicKeys.length)}var n=e("lodash"),i=e("inherits"),o=e("./input"),d=e("../output"),a=e("../../util/preconditions"),s=e("../../script"),f=e("../../crypto/signature"),c=e("../sighash"),p=e("../../publickey"),u=e("../../util/buffer"),l=e("../signature");i(r,o),r.prototype.toObject=function(){var e=o.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=n.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},r.prototype._deserializeSignatures=function(e){return n.map(e,function(e){return e?new l(e):void 0})},r.prototype._serializeSignatures=function(){return n.map(this.signatures,function(e){return e?e.toObject():void 0})},r.prototype.getSignatures=function(e,t,r,i){a.checkState(this.output instanceof d),i=i||f.SIGHASH_ALL|f.SIGHASH_FORKID;var o=this,s=[];return n.each(this.publicKeys,function(n){n.toString()===t.publicKey.toString()&&s.push(new l({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:c.sign(e,t,i,r,o.redeemScript,o.output.satoshisBN),sigtype:i}))}),s},r.prototype.addSignature=function(e,t){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!n.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},r.prototype._updateScript=function(){return this.setScript(s.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},r.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,function(e){return!n.isUndefined(e)}),function(e){return u.concat([e.signature.toDER(),u.integerAsSingleByteBuffer(e.sigtype)])})},r.prototype.clearSignatures=function(){this.signatures=Array(this.publicKeys.length),this._updateScript()},r.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},r.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},r.prototype.countSignatures=function(){return n.reduce(this.signatures,function(e,t){return e+!!t},0)},r.prototype.publicKeysWithoutSignature=function(){var e=this;return n.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},r.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,c.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)},r.OPCODES_SIZE=7,r.SIGNATURE_SIZE=74,r.PUBKEY_SIZE=34,r.prototype._estimateSize=function(){return r.OPCODES_SIZE+this.threshold*r.SIGNATURE_SIZE+this.publicKeys.length*r.PUBKEY_SIZE},t.exports=r},{"../../crypto/signature":224,"../../publickey":237,"../../script":238,"../../util/buffer":255,"../../util/preconditions":257,"../output":248,"../sighash":249,"../signature":250,"./input":243,inherits:146,lodash:149}],246:[function(e,t){"use strict";function r(){d.apply(this,arguments)}var n=e("inherits"),i=e("../../util/preconditions"),o=e("../../util/buffer"),d=e("./input"),a=e("../output"),s=e("../sighash"),f=e("../../script"),c=e("../../crypto/signature"),p=e("../signature");n(r,d),r.prototype.getSignatures=function(e,t,r,n){i.checkState(this.output instanceof a),n=n||c.SIGHASH_ALL|c.SIGHASH_FORKID;var o=t.toPublicKey();return o.toString()===this.output.script.getPublicKey().toString("hex")?[new p({publicKey:o,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:s.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]},r.prototype.addSignature=function(e,t){return i.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(f.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this},r.prototype.clearSignatures=function(){return this.setScript(f.empty()),this},r.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},r.SCRIPT_MAX_SIZE=73,r.prototype._estimateSize=function(){return r.SCRIPT_MAX_SIZE},t.exports=r},{"../../crypto/signature":224,"../../script":238,"../../util/buffer":255,"../../util/preconditions":257,"../output":248,"../sighash":249,"../signature":250,"./input":243,inherits:146}],247:[function(e,t){"use strict";function r(){a.apply(this,arguments)}var n=e("inherits"),i=e("../../util/preconditions"),o=e("../../util/buffer"),d=e("../../crypto/hash"),a=e("./input"),s=e("../output"),f=e("../sighash"),c=e("../../script"),p=e("../../crypto/signature"),u=e("../signature");n(r,a),r.prototype.getSignatures=function(e,t,r,n,a){return i.checkState(this.output instanceof s),a=a||d.sha256ripemd160(t.publicKey.toBuffer()),n=n||p.SIGHASH_ALL|p.SIGHASH_FORKID,o.equals(a,this.output.script.getPublicKeyHash())?[new u({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:f.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]},r.prototype.addSignature=function(e,t){return i.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(c.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this},r.prototype.clearSignatures=function(){return this.setScript(c.empty()),this},r.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},r.SCRIPT_MAX_SIZE=107,r.prototype._estimateSize=function(){return r.SCRIPT_MAX_SIZE},t.exports=r},{"../../crypto/hash":221,"../../crypto/signature":224,"../../script":238,"../../util/buffer":255,"../../util/preconditions":257,"../output":248,"../sighash":249,"../signature":250,"./input":243,inherits:146}],248:[function(e,t){"use strict";function r(e){if(!(this instanceof r))return new r(e);if(!n.isObject(e))throw new TypeError("Unrecognized argument for Output");else if(this.satoshis=e.satoshis,d.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;t=n.isString(e.script)&&a.isHexa(e.script)?new o.Buffer(e.script,"hex"):e.script,this.setScript(t)}}var n=e("lodash"),i=e("../crypto/bn"),o=e("buffer"),d=e("../util/buffer"),a=e("../util/js"),s=e("../encoding/bufferwriter"),f=e("../script"),c=e("../util/preconditions"),p=e("../errors");Object.defineProperty(r.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}}),Object.defineProperty(r.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof i?(this._satoshisBN=e,this._satoshis=e.toNumber()):n.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=i.fromNumber(this._satoshis)):(c.checkArgument(a.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=i.fromNumber(e),this._satoshis=e),c.checkState(a.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),r.prototype.invalidSatoshis=function(){return this._satoshis>9007199254740991?"transaction txout satoshis greater than max safe integer":this._satoshis===this._satoshisBN.toNumber()?!!(0>this._satoshis)&&"transaction txout negative":"transaction txout satoshis has corrupted value"},Object.defineProperty(r.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),c.checkState(a.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),r.prototype.toObject=r.prototype.toJSON=function(){var e={satoshis:this.satoshis,script:this._scriptBuffer.toString("hex")};return e},r.fromObject=function(e){return new r(e)},r.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=f.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof p.Script.InvalidBuffer)this._script=null;else throw t}},r.prototype.setScript=function(e){if(e instanceof f)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(n.isString(e))this._script=f.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(d.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this},r.prototype.inspect=function(){var e;return e=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),""},r.fromBufferReader=function(e){var t={satoshis:e.readUInt64LEBN()},n=e.readVarintNum();return t.script=0===n?new o.Buffer([]):e.read(n),new r(t)},r.prototype.toBufferWriter=function(e){e||(e=new s),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e},t.exports=r},{"../crypto/bn":219,"../encoding/bufferwriter":228,"../errors":230,"../script":238,"../util/buffer":255,"../util/js":256,"../util/preconditions":257,buffer:71,lodash:149}],249:[function(e,t){(function(r){"use strict";var n=e("buffer"),o=e("../crypto/signature"),d=e("../script"),a=e("./output"),s=e("../encoding/bufferreader"),f=e("../encoding/bufferwriter"),c=e("../crypto/bn"),p=e("../crypto/hash"),i=e("../crypto/ecdsa"),u=e("../util/preconditions"),l=e("../util/buffer"),h=e("lodash"),b=function(e,t,r,n,i){function d(e,t){var r=new f;h.isUndefined(t)?h.each(e.outputs,function(e){e.toBufferWriter(r)}):e.outputs[t].toBufferWriter(r);var n=r.toBuffer(),i=p.sha256sha256(n);return i}var a=e.inputs[r];u.checkArgument(i instanceof c,"For ForkId=0 signatures, satoshis or complete input must be provided");var b=l.emptyBuffer(32),g=l.emptyBuffer(32),y=l.emptyBuffer(32);t&o.SIGHASH_ANYONECANPAY||(b=function(e){var t=new f;h.each(e.inputs,function(e){t.writeReverse(e.prevTxId),t.writeUInt32LE(e.outputIndex)});var r=t.toBuffer(),n=p.sha256sha256(r);return n}(e)),t&o.SIGHASH_ANYONECANPAY||(31&t)==o.SIGHASH_SINGLE||(31&t)==o.SIGHASH_NONE||(g=function(e){var t=new f;h.each(e.inputs,function(e){t.writeUInt32LE(e.sequenceNumber)});var r=t.toBuffer(),n=p.sha256sha256(r);return n}(e)),(31&t)!=o.SIGHASH_SINGLE&&(31&t)!=o.SIGHASH_NONE?y=d(e):(31&t)==o.SIGHASH_SINGLE&&r>>0);var S=m.toBuffer(),v=p.sha256sha256(S);return v=new s(v).readReverse(),v},g=function(t,u,l,h,g){var y=e("./transaction"),m=e("./input"),_=y.shallowCopy(t);if(h=new d(h),u&o.SIGHASH_FORKID&&!0)return b(_,u,l,h,g);h.removeCodeseparators();var S;for(S=0;S<_.inputs.length;S++)_.inputs[S]=new m(_.inputs[S]).setScript(d.empty());if(_.inputs[l]=new m(_.inputs[l]).setScript(h),(31&u)===o.SIGHASH_NONE||(31&u)===o.SIGHASH_SINGLE)for(S=0;S<_.inputs.length;S++)S!==l&&(_.inputs[S].sequenceNumber=0);if((31&u)===o.SIGHASH_NONE)_.outputs=[];else if((31&u)===o.SIGHASH_SINGLE){if(l>=_.outputs.length)return new r("0000000000000000000000000000000000000000000000000000000000000001","hex");for(_.outputs.length=l+1,S=0;St?!e.disableMoreOutputThanInput&&(r=new s.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)},n.prototype._hasFeeError=function(e,t){if(!o.isUndefined(this._fee)&&this._fee!==t)return new s.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=f(n.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new s.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new s.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}if(!e.disableSmallFees){var i=h(this._estimateFee()/n.FEE_SECURITY_MARGIN);if(t"},n.prototype.toBuffer=function(){var e=new l;return this.toBufferWriter(e).toBuffer()},n.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),o.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),o.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e},n.prototype.fromBuffer=function(e){var t=new u(e);return this.fromBufferReader(t)},n.prototype.fromBufferReader=function(e){d.checkArgument(!e.finished(),"No transaction data received");var t,r,n;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t=n.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.BlockHeightTooHigh;if(0>e)throw new s.Transaction.NLockTimeOutOfRange;for(var t=0;ti&&(e+=n.CHANGE_OUTPUT_MAX_SIZE),h(e/1e3)*(r||n.FEE_PER_KB)},n.prototype._estimateSize=function(){var e=n.MAXIMUM_EXTRA_SIZE;return o.each(this.inputs,function(t){e+=t._estimateSize()}),o.each(this.outputs,function(t){e+=t.script.toBuffer().length+9}),e},n.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=o.without(this.outputs,t),this._outputAmount=void 0},n.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()},n.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(e,t){return a(e.prevTxId,t.prevTxId)||e.outputIndex-t.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(e,t){return e.satoshis-t.satoshis||a(e.script.toBuffer(),t.script.toBuffer())}),t}),this},n.prototype.shuffleOutputs=function(){return this.sortOutputs(o.shuffle)},n.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)},n.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this},n.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||0!==o.difference(this.outputs,e).length;if(t)throw new s.Transaction.InvalidSorting;if(!o.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=o.findIndex(e,r)}return this.outputs=e,this},n.prototype.removeInput=function(e,t){var r;if(r=!t&&o.isNumber(e)?e:o.findIndex(this.inputs,function(r){return r.prevTxId.toString("hex")===e&&r.outputIndex===t}),0>r||r>=this.inputs.length)throw new s.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=o.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()},n.prototype.sign=function(e,t){d.checkState(this.hasAllUtxoInfo());var r=this;return o.isArray(e)?(o.each(e,function(e){r.sign(e,t)}),this):(o.each(this.getSignatures(e,t),function(e){r.applySignature(e)}),this)},n.prototype.getSignatures=function(e,t){e=new E(e),t=t||g.SIGHASH_ALL|g.SIGHASH_FORKID;var r=this,n=[],i=b.sha256ripemd160(e.publicKey.toBuffer());return o.each(this.inputs,function(d,a){o.each(d.getSignatures(r,e,a,t,i),function(e){n.push(e)})}),n},n.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this},n.prototype.isFullySigned=function(){return o.each(this.inputs,function(e){if(e.isFullySigned===S.prototype.isFullySigned)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),o.every(o.map(this.inputs,function(e){return e.isFullySigned()}))},n.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===S.prototype.isValidSignature)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)},n.prototype.verifySignature=function(e,t,r,n){return y.verify(this,e,t,r,n)},n.prototype.verify=function(){if(0===this.inputs.length)return"transaction txins empty";if(0===this.outputs.length)return"transaction txouts empty";for(var e=new P(0),t=0,r;t1e6)return"transaction over the maximum block size";var i={};for(t=0;tf.length||100=S.MAXINT-1&&(t.sequenceNumber=S.DEFAULT_RBF_SEQNUMBER);return this},t.exports=n}).call(this,e("buffer").Buffer)},{"../address":214,"../crypto/bn":219,"../crypto/hash":221,"../crypto/signature":224,"../encoding/bufferreader":227,"../encoding/bufferwriter":228,"../errors":230,"../privatekey":236,"../script":238,"../util/buffer":255,"../util/js":256,"../util/preconditions":257,"./input":242,"./output":248,"./sighash":249,"./unspentoutput":252,buffer:71,"buffer-compare":69,lodash:149}],252:[function(e,t){"use strict";function r(e){if(!(this instanceof r))return new r(e);i.checkArgument(n.isObject(e),"Must provide an object from where to extract data");var t=e.address?new a(e.address):void 0,f=e.txid?e.txid:e.txId;if(!f||!o.isHexaString(f)||64"},r.prototype.toString=function(){return this.txId+":"+this.outputIndex},r.fromObject=function(e){return new r(e)},r.prototype.toObject=r.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:s.fromSatoshis(this.satoshis).toBTC()}},t.exports=r},{"../address":214,"../script":238,"../unit":253,"../util/js":256,"../util/preconditions":257,lodash:149}],253:[function(e,t){"use strict";function r(e,t){if(!(this instanceof r))return new r(e,t);if(n.isNumber(t)){if(0>=t)throw new i.Unit.InvalidRate(t);e/=t,t=r.BTC}this._value=this._from(e,t);var o=this;Object.keys(d).forEach(function(e){Object.defineProperty(o,e,{get:function(){return o.to(e)},enumerable:!0})})}var n=e("lodash"),i=e("./errors"),o=e("./util/preconditions"),d={BTC:[100000000,8],mBTC:[100000,5],uBTC:[100,2],bits:[100,2],satoshis:[1,0]};Object.keys(d).forEach(function(e){r[e]=e}),r.fromObject=function(e){return o.checkArgument(n.isObject(e),"Argument is expected to be an object"),new r(e.amount,e.code)},r.fromBTC=function(e){return new r(e,r.BTC)},r.fromMillis=r.fromMilis=function(e){return new r(e,r.mBTC)},r.fromMicros=r.fromBits=function(e){return new r(e,r.bits)},r.fromSatoshis=function(e){return new r(e,r.satoshis)},r.fromFiat=function(e,t){return new r(e,t)},r.prototype._from=function(e,t){if(!d[t])throw new i.Unit.UnknownCode(t);return parseInt((e*d[t][0]).toFixed())},r.prototype.to=function(e){if(n.isNumber(e)){if(0>=e)throw new i.Unit.InvalidRate(e);return parseFloat((this.BTC*e).toFixed(2))}if(!d[e])throw new i.Unit.UnknownCode(e);var t=this._value/d[e][0];return parseFloat(t.toFixed(d[e][1]))},r.prototype.toBTC=function(){return this.to(r.BTC)},r.prototype.toMillis=r.prototype.toMilis=function(){return this.to(r.mBTC)},r.prototype.toMicros=r.prototype.toBits=function(){return this.to(r.bits)},r.prototype.toSatoshis=function(){return this.to(r.satoshis)},r.prototype.atRate=function(e){return this.to(e)},r.prototype.toString=function(){return this.satoshis+" satoshis"},r.prototype.toObject=r.prototype.toJSON=function(){return{amount:this.BTC,code:r.BTC}},r.prototype.inspect=function(){return""},t.exports=r},{"./errors":230,"./util/preconditions":257,lodash:149}],254:[function(e,t){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=e("lodash"),i=e("url"),o=e("./address"),d=e("./unit"),a=function e(t,n){if(!(this instanceof e))return new e(t,n);if(this.extras={},this.knownParams=n||[],this.address=this.network=this.amount=this.message=null,"string"==typeof t){var i=e.parse(t);i.amount&&(i.amount=this._parseAmount(i.amount)),this._fromObject(i)}else if("object"===("undefined"==typeof t?"undefined":r(t)))this._fromObject(t);else throw new TypeError("Unrecognized data format.")};a.fromString=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return new a(e)},a.fromObject=function(e){return new a(e)},a.isValid=function(e,t){try{new a(e,t)}catch(e){return!1}return!0},a.parse=function(e){var t=i.parse(e,!0);if("bitcoincash:"!==t.protocol)throw new TypeError("Invalid bitcoin cash URI");var r=/[^:]*:\/?\/?([^?]*)/.exec(e);return t.query.address=r&&r[1]||void 0,t.query},a.Members=["address","amount","message","label","r"],a.prototype._fromObject=function(e){if(!o.isValid(e.address))throw new TypeError("Invalid bitcoin address");for(var t in this.address=new o(e.address),this.network=this.address.network,this.amount=e.amount,e)if("address"!=t&&"amount"!=t){if(/^req-/.exec(t)&&-1===this.knownParams.indexOf(t))throw Error("Unknown required argument "+t);var r=-1"},t.exports=a},{"./address":214,"./unit":253,lodash:149,url:207}],255:[function(e,t){(function(r){"use strict";function n(e,t){if(e.length!==t.length)return!1;for(var r=e.length,n=0;n>24,255&e>>16,255&e>>8,255&e])},integerFromBuffer:function(e){return a.checkArgumentType(e,"Buffer","buffer"),e[0]<<24|e[1]<<16|e[2]<<8|e[3]},integerFromSingleByteBuffer:function(e){return a.checkArgumentType(e,"Buffer","buffer"),e[0]},bufferToHex:function(e){return a.checkArgumentType(e,"Buffer","buffer"),e.toString("hex")},reverse:function(e){for(var t=new o.Buffer(e.length),r=0;r", "main": "index.js", "scripts": { - "start": "npm install && npx gulp build", + "build": "npm install && npx gulp build", "test": "npm install && npx gulp test", "lint": "npm install && npx gulp lint", "coveralls": "npm install && npx gulp coveralls" @@ -46,6 +46,7 @@ }, "devDependencies": { "babel-core": "^6.26.0", + "babel-minify": "^0.2.0", "babel-preset-env": "^1.6.1", "babelify": "^8.0.0", "brfs": "^1.4.3",