diff options
author | iancoleman <1281387+iancoleman@users.noreply.github.com> | 2019-11-11 09:47:35 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-11 09:47:35 +1100 |
commit | c7a092db32f161fe3f205493dafc54bd02627f84 (patch) | |
tree | 960d9264e1cadfe42cc0a82040962c200f9a8180 /src | |
parent | de5fe245ccc5b333efcf772d19d8965ffeb47272 (diff) | |
parent | 36523e0d9714a8ff9996ec3e062a8e16e28c3415 (diff) | |
download | BIP39-c7a092db32f161fe3f205493dafc54bd02627f84.tar.gz BIP39-c7a092db32f161fe3f205493dafc54bd02627f84.tar.zst BIP39-c7a092db32f161fe3f205493dafc54bd02627f84.zip |
Merge pull request #368 from johnnynanjiang/elastos-pr
Add Elastos
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 5 | ||||
-rw-r--r-- | src/js/bitcoinjs-extensions.js | 11 | ||||
-rw-r--r-- | src/js/elastos-1.0.9.min.js | 69 | ||||
-rw-r--r-- | src/js/index.js | 93 |
4 files changed, 171 insertions, 7 deletions
diff --git a/src/index.html b/src/index.html index bfb2bc1..2684c9f 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -930,6 +930,9 @@ | |||
930 | <script src="js/bitcoinjs-3.3.2.js"></script> | 930 | <script src="js/bitcoinjs-3.3.2.js"></script> |
931 | <script src="js/bitcoinjs-extensions.js"></script> | 931 | <script src="js/bitcoinjs-extensions.js"></script> |
932 | <script src="js/bitcoinjs-bip38-2.0.2.js"></script> | 932 | <script src="js/bitcoinjs-bip38-2.0.2.js"></script> |
933 | <script src="js/groestlcoinjs-3.3.2.js"></script> | ||
934 | <script src="js/groestlcoinjs-bip38-2.0.2.js"></script> | ||
935 | <script src="js/elastos-1.0.9.min.js"></script> | ||
933 | <script src="js/segwit-parameters.js"></script> | 936 | <script src="js/segwit-parameters.js"></script> |
934 | <script src="js/ethereumjs-util.js"></script> | 937 | <script src="js/ethereumjs-util.js"></script> |
935 | <script src="js/ripple-util.js"></script> | 938 | <script src="js/ripple-util.js"></script> |
@@ -952,7 +955,5 @@ | |||
952 | <script src="js/entropy.js"></script> | 955 | <script src="js/entropy.js"></script> |
953 | <script src="js/stellar-util.js"></script> | 956 | <script src="js/stellar-util.js"></script> |
954 | <script src="js/index.js"></script> | 957 | <script src="js/index.js"></script> |
955 | <script src="js/groestlcoinjs-3.3.2.js"></script> | ||
956 | <script src="js/groestlcoinjs-bip38-2.0.2.js"></script> | ||
957 | </body> | 958 | </body> |
958 | </html> | 959 | </html> |
diff --git a/src/js/bitcoinjs-extensions.js b/src/js/bitcoinjs-extensions.js index a9db485..b6d2de6 100644 --- a/src/js/bitcoinjs-extensions.js +++ b/src/js/bitcoinjs-extensions.js | |||
@@ -1716,3 +1716,14 @@ bitcoinjs.bitcoin.networks.aryacoin = { | |||
1716 | scriptHash: 0x6f, | 1716 | scriptHash: 0x6f, |
1717 | wif: 0x97 | 1717 | wif: 0x97 |
1718 | }; | 1718 | }; |
1719 | |||
1720 | bitcoinjs.bitcoin.networks.elastos = { | ||
1721 | messagePrefix: 'unused', | ||
1722 | bip32: { | ||
1723 | public: 0x0488B21E, | ||
1724 | private: 0x0488ADE4, | ||
1725 | }, | ||
1726 | pubKeyHash: 0x21, | ||
1727 | scriptHash: 0xc4, // TODO set this correctly, same as BTC for now | ||
1728 | wif: 0xef // TODO set this correctly, same as BTC for now | ||
1729 | }; | ||
diff --git a/src/js/elastos-1.0.9.min.js b/src/js/elastos-1.0.9.min.js new file mode 100644 index 0000000..6b74e0d --- /dev/null +++ b/src/js/elastos-1.0.9.min.js | |||
@@ -0,0 +1,69 @@ | |||
1 | !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).elastosjs=f()}}((function(){var define,module,exports;return function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,(function(r){return o(e[i][1][r]||r)}),p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({1:[function(require,module,exports){var asn1=exports;asn1.bignum=require("bn.js"),asn1.define=require("./asn1/api").define,asn1.base=require("./asn1/base"),asn1.constants=require("./asn1/constants"),asn1.decoders=require("./asn1/decoders"),asn1.encoders=require("./asn1/encoders")},{"./asn1/api":2,"./asn1/base":4,"./asn1/constants":8,"./asn1/decoders":10,"./asn1/encoders":13,"bn.js":20}],2:[function(require,module,exports){var asn1=require("../asn1"),inherits=require("inherits");function Entity(name,body){this.name=name,this.body=body,this.decoders={},this.encoders={}}exports.define=function(name,body){return new Entity(name,body)},Entity.prototype._createNamed=function(base){var named;try{named=require("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){named=function(entity){this._initNamed(entity)}}return inherits(named,base),named.prototype._initNamed=function(entity){base.call(this,entity)},new named(this)},Entity.prototype._getDecoder=function(enc){return enc=enc||"der",this.decoders.hasOwnProperty(enc)||(this.decoders[enc]=this._createNamed(asn1.decoders[enc])),this.decoders[enc]},Entity.prototype.decode=function(data,enc,options){return this._getDecoder(enc).decode(data,options)},Entity.prototype._getEncoder=function(enc){return enc=enc||"der",this.encoders.hasOwnProperty(enc)||(this.encoders[enc]=this._createNamed(asn1.encoders[enc])),this.encoders[enc]},Entity.prototype.encode=function(data,enc,reporter){return this._getEncoder(enc).encode(data,reporter)}},{"../asn1":1,inherits:103,vm:166}],3:[function(require,module,exports){var inherits=require("inherits"),Reporter=require("../base").Reporter,Buffer=require("buffer").Buffer;function DecoderBuffer(base,options){Reporter.call(this,options),Buffer.isBuffer(base)?(this.base=base,this.offset=0,this.length=base.length):this.error("Input not Buffer")}function EncoderBuffer(value,reporter){if(Array.isArray(value))this.length=0,this.value=value.map((function(item){return item instanceof EncoderBuffer||(item=new EncoderBuffer(item,reporter)),this.length+=item.length,item}),this);else if("number"==typeof value){if(!(0<=value&&value<=255))return reporter.error("non-byte EncoderBuffer value");this.value=value,this.length=1}else if("string"==typeof value)this.value=value,this.length=Buffer.byteLength(value);else{if(!Buffer.isBuffer(value))return reporter.error("Unsupported type: "+typeof value);this.value=value,this.length=value.length}}inherits(DecoderBuffer,Reporter),exports.DecoderBuffer=DecoderBuffer,DecoderBuffer.prototype.save=function(){return{offset:this.offset,reporter:Reporter.prototype.save.call(this)}},DecoderBuffer.prototype.restore=function(save){var res=new DecoderBuffer(this.base);return res.offset=save.offset,res.length=this.offset,this.offset=save.offset,Reporter.prototype.restore.call(this,save.reporter),res},DecoderBuffer.prototype.isEmpty=function(){return this.offset===this.length},DecoderBuffer.prototype.readUInt8=function(fail){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(fail||"DecoderBuffer overrun")},DecoderBuffer.prototype.skip=function(bytes,fail){if(!(this.offset+bytes<=this.length))return this.error(fail||"DecoderBuffer overrun");var res=new DecoderBuffer(this.base);return res._reporterState=this._reporterState,res.offset=this.offset,res.length=this.offset+bytes,this.offset+=bytes,res},DecoderBuffer.prototype.raw=function(save){return this.base.slice(save?save.offset:this.offset,this.length)},exports.EncoderBuffer=EncoderBuffer,EncoderBuffer.prototype.join=function(out,offset){return out||(out=new Buffer(this.length)),offset||(offset=0),0===this.length?out:(Array.isArray(this.value)?this.value.forEach((function(item){item.join(out,offset),offset+=item.length})):("number"==typeof this.value?out[offset]=this.value:"string"==typeof this.value?out.write(this.value,offset):Buffer.isBuffer(this.value)&&this.value.copy(out,offset),offset+=this.length),out)}},{"../base":4,buffer:51,inherits:103}],4:[function(require,module,exports){var base=exports;base.Reporter=require("./reporter").Reporter,base.DecoderBuffer=require("./buffer").DecoderBuffer,base.EncoderBuffer=require("./buffer").EncoderBuffer,base.Node=require("./node")},{"./buffer":3,"./node":5,"./reporter":6}],5:[function(require,module,exports){var Reporter=require("../base").Reporter,EncoderBuffer=require("../base").EncoderBuffer,DecoderBuffer=require("../base").DecoderBuffer,assert=require("minimalistic-assert"),tags=["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"],methods=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(tags);function Node(enc,parent){var state={};this._baseState=state,state.enc=enc,state.parent=parent||null,state.children=null,state.tag=null,state.args=null,state.reverseArgs=null,state.choice=null,state.optional=!1,state.any=!1,state.obj=!1,state.use=null,state.useDecoder=null,state.key=null,state.default=null,state.explicit=null,state.implicit=null,state.contains=null,state.parent||(state.children=[],this._wrap())}module.exports=Node;var stateProps=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];Node.prototype.clone=function(){var state=this._baseState,cstate={};stateProps.forEach((function(prop){cstate[prop]=state[prop]}));var res=new this.constructor(cstate.parent);return res._baseState=cstate,res},Node.prototype._wrap=function(){var state=this._baseState;methods.forEach((function(method){this[method]=function(){var clone=new this.constructor(this);return state.children.push(clone),clone[method].apply(clone,arguments)}}),this)},Node.prototype._init=function(body){var state=this._baseState;assert(null===state.parent),body.call(this),state.children=state.children.filter((function(child){return child._baseState.parent===this}),this),assert.equal(state.children.length,1,"Root node can have only one child")},Node.prototype._useArgs=function(args){var state=this._baseState,children=args.filter((function(arg){return arg instanceof this.constructor}),this);args=args.filter((function(arg){return!(arg instanceof this.constructor)}),this),0!==children.length&&(assert(null===state.children),state.children=children,children.forEach((function(child){child._baseState.parent=this}),this)),0!==args.length&&(assert(null===state.args),state.args=args,state.reverseArgs=args.map((function(arg){if("object"!=typeof arg||arg.constructor!==Object)return arg;var res={};return Object.keys(arg).forEach((function(key){key==(0|key)&&(key|=0);var value=arg[key];res[value]=key})),res})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(method){Node.prototype[method]=function(){var state=this._baseState;throw new Error(method+" not implemented for encoding: "+state.enc)}})),tags.forEach((function(tag){Node.prototype[tag]=function(){var state=this._baseState,args=Array.prototype.slice.call(arguments);return assert(null===state.tag),state.tag=tag,this._useArgs(args),this}})),Node.prototype.use=function(item){assert(item);var state=this._baseState;return assert(null===state.use),state.use=item,this},Node.prototype.optional=function(){return this._baseState.optional=!0,this},Node.prototype.def=function(val){var state=this._baseState;return assert(null===state.default),state.default=val,state.optional=!0,this},Node.prototype.explicit=function(num){var state=this._baseState;return assert(null===state.explicit&&null===state.implicit),state.explicit=num,this},Node.prototype.implicit=function(num){var state=this._baseState;return assert(null===state.explicit&&null===state.implicit),state.implicit=num,this},Node.prototype.obj=function(){var state=this._baseState,args=Array.prototype.slice.call(arguments);return state.obj=!0,0!==args.length&&this._useArgs(args),this},Node.prototype.key=function(newKey){var state=this._baseState;return assert(null===state.key),state.key=newKey,this},Node.prototype.any=function(){return this._baseState.any=!0,this},Node.prototype.choice=function(obj){var state=this._baseState;return assert(null===state.choice),state.choice=obj,this._useArgs(Object.keys(obj).map((function(key){return obj[key]}))),this},Node.prototype.contains=function(item){var state=this._baseState;return assert(null===state.use),state.contains=item,this},Node.prototype._decode=function(input,options){var state=this._baseState;if(null===state.parent)return input.wrapResult(state.children[0]._decode(input,options));var prevObj,result=state.default,present=!0,prevKey=null;if(null!==state.key&&(prevKey=input.enterKey(state.key)),state.optional){var tag=null;if(null!==state.explicit?tag=state.explicit:null!==state.implicit?tag=state.implicit:null!==state.tag&&(tag=state.tag),null!==tag||state.any){if(present=this._peekTag(input,tag,state.any),input.isError(present))return present}else{var save=input.save();try{null===state.choice?this._decodeGeneric(state.tag,input,options):this._decodeChoice(input,options),present=!0}catch(e){present=!1}input.restore(save)}}if(state.obj&&present&&(prevObj=input.enterObject()),present){if(null!==state.explicit){var explicit=this._decodeTag(input,state.explicit);if(input.isError(explicit))return explicit;input=explicit}var start=input.offset;if(null===state.use&&null===state.choice){if(state.any)save=input.save();var body=this._decodeTag(input,null!==state.implicit?state.implicit:state.tag,state.any);if(input.isError(body))return body;state.any?result=input.raw(save):input=body}if(options&&options.track&&null!==state.tag&&options.track(input.path(),start,input.length,"tagged"),options&&options.track&&null!==state.tag&&options.track(input.path(),input.offset,input.length,"content"),result=state.any?result:null===state.choice?this._decodeGeneric(state.tag,input,options):this._decodeChoice(input,options),input.isError(result))return result;if(state.any||null!==state.choice||null===state.children||state.children.forEach((function(child){child._decode(input,options)})),state.contains&&("octstr"===state.tag||"bitstr"===state.tag)){var data=new DecoderBuffer(result);result=this._getUse(state.contains,input._reporterState.obj)._decode(data,options)}}return state.obj&&present&&(result=input.leaveObject(prevObj)),null===state.key||null===result&&!0!==present?null!==prevKey&&input.exitKey(prevKey):input.leaveKey(prevKey,state.key,result),result},Node.prototype._decodeGeneric=function(tag,input,options){var state=this._baseState;return"seq"===tag||"set"===tag?null:"seqof"===tag||"setof"===tag?this._decodeList(input,tag,state.args[0],options):/str$/.test(tag)?this._decodeStr(input,tag,options):"objid"===tag&&state.args?this._decodeObjid(input,state.args[0],state.args[1],options):"objid"===tag?this._decodeObjid(input,null,null,options):"gentime"===tag||"utctime"===tag?this._decodeTime(input,tag,options):"null_"===tag?this._decodeNull(input,options):"bool"===tag?this._decodeBool(input,options):"objDesc"===tag?this._decodeStr(input,tag,options):"int"===tag||"enum"===tag?this._decodeInt(input,state.args&&state.args[0],options):null!==state.use?this._getUse(state.use,input._reporterState.obj)._decode(input,options):input.error("unknown tag: "+tag)},Node.prototype._getUse=function(entity,obj){var state=this._baseState;return state.useDecoder=this._use(entity,obj),assert(null===state.useDecoder._baseState.parent),state.useDecoder=state.useDecoder._baseState.children[0],state.implicit!==state.useDecoder._baseState.implicit&&(state.useDecoder=state.useDecoder.clone(),state.useDecoder._baseState.implicit=state.implicit),state.useDecoder},Node.prototype._decodeChoice=function(input,options){var state=this._baseState,result=null,match=!1;return Object.keys(state.choice).some((function(key){var save=input.save(),node=state.choice[key];try{var value=node._decode(input,options);if(input.isError(value))return!1;result={type:key,value:value},match=!0}catch(e){return input.restore(save),!1}return!0}),this),match?result:input.error("Choice not matched")},Node.prototype._createEncoderBuffer=function(data){return new EncoderBuffer(data,this.reporter)},Node.prototype._encode=function(data,reporter,parent){var state=this._baseState;if(null===state.default||state.default!==data){var result=this._encodeValue(data,reporter,parent);if(void 0!==result&&!this._skipDefault(result,reporter,parent))return result}},Node.prototype._encodeValue=function(data,reporter,parent){var state=this._baseState;if(null===state.parent)return state.children[0]._encode(data,reporter||new Reporter);var result=null;if(this.reporter=reporter,state.optional&&void 0===data){if(null===state.default)return;data=state.default}var content=null,primitive=!1;if(state.any)result=this._createEncoderBuffer(data);else if(state.choice)result=this._encodeChoice(data,reporter);else if(state.contains)content=this._getUse(state.contains,parent)._encode(data,reporter),primitive=!0;else if(state.children)content=state.children.map((function(child){if("null_"===child._baseState.tag)return child._encode(null,reporter,data);if(null===child._baseState.key)return reporter.error("Child should have a key");var prevKey=reporter.enterKey(child._baseState.key);if("object"!=typeof data)return reporter.error("Child expected, but input is not object");var res=child._encode(data[child._baseState.key],reporter,data);return reporter.leaveKey(prevKey),res}),this).filter((function(child){return child})),content=this._createEncoderBuffer(content);else if("seqof"===state.tag||"setof"===state.tag){if(!state.args||1!==state.args.length)return reporter.error("Too many args for : "+state.tag);if(!Array.isArray(data))return reporter.error("seqof/setof, but data is not Array");var child=this.clone();child._baseState.implicit=null,content=this._createEncoderBuffer(data.map((function(item){var state=this._baseState;return this._getUse(state.args[0],data)._encode(item,reporter)}),child))}else null!==state.use?result=this._getUse(state.use,parent)._encode(data,reporter):(content=this._encodePrimitive(state.tag,data),primitive=!0);if(!state.any&&null===state.choice){var tag=null!==state.implicit?state.implicit:state.tag,cls=null===state.implicit?"universal":"context";null===tag?null===state.use&&reporter.error("Tag could be omitted only for .use()"):null===state.use&&(result=this._encodeComposite(tag,primitive,cls,content))}return null!==state.explicit&&(result=this._encodeComposite(state.explicit,!1,"context",result)),result},Node.prototype._encodeChoice=function(data,reporter){var state=this._baseState,node=state.choice[data.type];return node||assert(!1,data.type+" not found in "+JSON.stringify(Object.keys(state.choice))),node._encode(data.value,reporter)},Node.prototype._encodePrimitive=function(tag,data){var state=this._baseState;if(/str$/.test(tag))return this._encodeStr(data,tag);if("objid"===tag&&state.args)return this._encodeObjid(data,state.reverseArgs[0],state.args[1]);if("objid"===tag)return this._encodeObjid(data,null,null);if("gentime"===tag||"utctime"===tag)return this._encodeTime(data,tag);if("null_"===tag)return this._encodeNull();if("int"===tag||"enum"===tag)return this._encodeInt(data,state.args&&state.reverseArgs[0]);if("bool"===tag)return this._encodeBool(data);if("objDesc"===tag)return this._encodeStr(data,tag);throw new Error("Unsupported tag: "+tag)},Node.prototype._isNumstr=function(str){return/^[0-9 ]*$/.test(str)},Node.prototype._isPrintstr=function(str){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str)}},{"../base":4,"minimalistic-assert":108}],6:[function(require,module,exports){var inherits=require("inherits");function Reporter(options){this._reporterState={obj:null,path:[],options:options||{},errors:[]}}function ReporterError(path,msg){this.path=path,this.rethrow(msg)}exports.Reporter=Reporter,Reporter.prototype.isError=function(obj){return obj instanceof ReporterError},Reporter.prototype.save=function(){var state=this._reporterState;return{obj:state.obj,pathLen:state.path.length}},Reporter.prototype.restore=function(data){var state=this._reporterState;state.obj=data.obj,state.path=state.path.slice(0,data.pathLen)},Reporter.prototype.enterKey=function(key){return this._reporterState.path.push(key)},Reporter.prototype.exitKey=function(index){var state=this._reporterState;state.path=state.path.slice(0,index-1)},Reporter.prototype.leaveKey=function(index,key,value){var state=this._reporterState;this.exitKey(index),null!==state.obj&&(state.obj[key]=value)},Reporter.prototype.path=function(){return this._reporterState.path.join("/")},Reporter.prototype.enterObject=function(){var state=this._reporterState,prev=state.obj;return state.obj={},prev},Reporter.prototype.leaveObject=function(prev){var state=this._reporterState,now=state.obj;return state.obj=prev,now},Reporter.prototype.error=function(msg){var err,state=this._reporterState,inherited=msg instanceof ReporterError;if(err=inherited?msg:new ReporterError(state.path.map((function(elem){return"["+JSON.stringify(elem)+"]"})).join(""),msg.message||msg,msg.stack),!state.options.partial)throw err;return inherited||state.errors.push(err),err},Reporter.prototype.wrapResult=function(result){var state=this._reporterState;return state.options.partial?{result:this.isError(result)?null:result,errors:state.errors}:result},inherits(ReporterError,Error),ReporterError.prototype.rethrow=function(msg){if(this.message=msg+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,ReporterError),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:103}],7:[function(require,module,exports){var constants=require("../constants");exports.tagClass={0:"universal",1:"application",2:"context",3:"private"},exports.tagClassByName=constants._reverse(exports.tagClass),exports.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"},exports.tagByName=constants._reverse(exports.tag)},{"../constants":8}],8:[function(require,module,exports){var constants=exports;constants._reverse=function(map){var res={};return Object.keys(map).forEach((function(key){(0|key)==key&&(key|=0);var value=map[key];res[value]=key})),res},constants.der=require("./der")},{"./der":7}],9:[function(require,module,exports){var inherits=require("inherits"),asn1=require("../../asn1"),base=asn1.base,bignum=asn1.bignum,der=asn1.constants.der;function DERDecoder(entity){this.enc="der",this.name=entity.name,this.entity=entity,this.tree=new DERNode,this.tree._init(entity.body)}function DERNode(parent){base.Node.call(this,"der",parent)}function derDecodeTag(buf,fail){var tag=buf.readUInt8(fail);if(buf.isError(tag))return tag;var cls=der.tagClass[tag>>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<num;i++){len<<=8;var j=buf.readUInt8(fail);if(buf.isError(j))return j;len|=j}return len}module.exports=DERDecoder,DERDecoder.prototype.decode=function(data,options){return data instanceof base.DecoderBuffer||(data=new base.DecoderBuffer(data,options)),this.tree._decode(data,options)},inherits(DERNode,base.Node),DERNode.prototype._peekTag=function(buffer,tag,any){if(buffer.isEmpty())return!1;var state=buffer.save(),decodedTag=derDecodeTag(buffer,'Failed to peek tag: "'+tag+'"');return buffer.isError(decodedTag)?decodedTag:(buffer.restore(state),decodedTag.tag===tag||decodedTag.tagStr===tag||decodedTag.tagStr+"of"===tag||any)},DERNode.prototype._decodeTag=function(buffer,tag,any){var decodedTag=derDecodeTag(buffer,'Failed to decode tag of "'+tag+'"');if(buffer.isError(decodedTag))return decodedTag;var len=derDecodeLen(buffer,decodedTag.primitive,'Failed to get length of "'+tag+'"');if(buffer.isError(len))return len;if(!any&&decodedTag.tag!==tag&&decodedTag.tagStr!==tag&&decodedTag.tagStr+"of"!==tag)return buffer.error('Failed to match tag: "'+tag+'"');if(decodedTag.primitive||null!==len)return buffer.skip(len,'Failed to match body of: "'+tag+'"');var state=buffer.save(),res=this._skipUntilEnd(buffer,'Failed to skip indefinite length body: "'+this.tag+'"');return buffer.isError(res)?res:(len=buffer.offset-state.offset,buffer.restore(state),buffer.skip(len,'Failed to match body of: "'+tag+'"'))},DERNode.prototype._skipUntilEnd=function(buffer,fail){for(;;){var tag=derDecodeTag(buffer,fail);if(buffer.isError(tag))return tag;var res,len=derDecodeLen(buffer,tag.primitive,fail);if(buffer.isError(len))return len;if(res=tag.primitive||null!==len?buffer.skip(len):this._skipUntilEnd(buffer,fail),buffer.isError(res))return res;if("end"===tag.tagStr)break}},DERNode.prototype._decodeList=function(buffer,tag,decoder,options){for(var result=[];!buffer.isEmpty();){var possibleEnd=this._peekTag(buffer,"end");if(buffer.isError(possibleEnd))return possibleEnd;var res=decoder.decode(buffer,"der",options);if(buffer.isError(res)&&possibleEnd)break;result.push(res)}return result},DERNode.prototype._decodeStr=function(buffer,tag){if("bitstr"===tag){var unused=buffer.readUInt8();return buffer.isError(unused)?unused:{unused:unused,data:buffer.raw()}}if("bmpstr"===tag){var raw=buffer.raw();if(raw.length%2==1)return buffer.error("Decoding of string type: bmpstr length mismatch");for(var str="",i=0;i<raw.length/2;i++)str+=String.fromCharCode(raw.readUInt16BE(2*i));return str}if("numstr"===tag){var numstr=buffer.raw().toString("ascii");return this._isNumstr(numstr)?numstr:buffer.error("Decoding of string type: numstr unsupported characters")}if("octstr"===tag)return buffer.raw();if("objDesc"===tag)return buffer.raw();if("printstr"===tag){var printstr=buffer.raw().toString("ascii");return this._isPrintstr(printstr)?printstr:buffer.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(tag)?buffer.raw().toString():buffer.error("Decoding of string type: "+tag+" unsupported")},DERNode.prototype._decodeObjid=function(buffer,values,relative){for(var result,identifiers=[],ident=0;!buffer.isEmpty();){var subident=buffer.readUInt8();ident<<=7,ident|=127&subident,0==(128&subident)&&(identifiers.push(ident),ident=0)}128&subident&&identifiers.push(ident);var first=identifiers[0]/40|0,second=identifiers[0]%40;if(result=relative?identifiers:[first,second].concat(identifiers.slice(1)),values){var tmp=values[result.join(" ")];void 0===tmp&&(tmp=values[result.join(".")]),void 0!==tmp&&(result=tmp)}return result},DERNode.prototype._decodeTime=function(buffer,tag){var str=buffer.raw().toString();if("gentime"===tag)var year=0|str.slice(0,4),mon=0|str.slice(4,6),day=0|str.slice(6,8),hour=0|str.slice(8,10),min=0|str.slice(10,12),sec=0|str.slice(12,14);else{if("utctime"!==tag)return buffer.error("Decoding "+tag+" time is not supported yet");year=0|str.slice(0,2),mon=0|str.slice(2,4),day=0|str.slice(4,6),hour=0|str.slice(6,8),min=0|str.slice(8,10),sec=0|str.slice(10,12);year=year<70?2e3+year:1900+year}return Date.UTC(year,mon-1,day,hour,min,sec,0)},DERNode.prototype._decodeNull=function(buffer){return null},DERNode.prototype._decodeBool=function(buffer){var res=buffer.readUInt8();return buffer.isError(res)?res:0!==res},DERNode.prototype._decodeInt=function(buffer,values){var raw=buffer.raw(),res=new bignum(raw);return values&&(res=values[res.toString(10)]||res),res},DERNode.prototype._use=function(entity,obj){return"function"==typeof entity&&(entity=entity(obj)),entity._getDecoder("der").tree}},{"../../asn1":1,inherits:103}],10:[function(require,module,exports){var decoders=exports;decoders.der=require("./der"),decoders.pem=require("./pem")},{"./der":9,"./pem":11}],11:[function(require,module,exports){var inherits=require("inherits"),Buffer=require("buffer").Buffer,DERDecoder=require("./der");function PEMDecoder(entity){DERDecoder.call(this,entity),this.enc="pem"}inherits(PEMDecoder,DERDecoder),module.exports=PEMDecoder,PEMDecoder.prototype.decode=function(data,options){for(var lines=data.toString().split(/[\r\n]+/g),label=options.label.toUpperCase(),re=/^-----(BEGIN|END) ([^-]+)-----$/,start=-1,end=-1,i=0;i<lines.length;i++){var match=lines[i].match(re);if(null!==match&&match[2]===label){if(-1!==start){if("END"!==match[1])break;end=i;break}if("BEGIN"!==match[1])break;start=i}}if(-1===start||-1===end)throw new Error("PEM section not found for: "+label);var base64=lines.slice(start+1,end).join("");base64.replace(/[^a-z0-9\+\/=]+/gi,"");var input=new Buffer(base64,"base64");return DERDecoder.prototype.decode.call(this,input,options)}},{"./der":9,buffer:51,inherits:103}],12:[function(require,module,exports){var inherits=require("inherits"),Buffer=require("buffer").Buffer,asn1=require("../../asn1"),base=asn1.base,der=asn1.constants.der;function DEREncoder(entity){this.enc="der",this.name=entity.name,this.entity=entity,this.tree=new DERNode,this.tree._init(entity.body)}function DERNode(parent){base.Node.call(this,"der",parent)}function two(num){return num<10?"0"+num:num}module.exports=DEREncoder,DEREncoder.prototype.encode=function(data,reporter){return this.tree._encode(data,reporter).join()},inherits(DERNode,base.Node),DERNode.prototype._encodeComposite=function(tag,primitive,cls,content){var header,encodedTag=function(tag,primitive,cls,reporter){var res;"seqof"===tag?tag="seq":"setof"===tag&&(tag="set");if(der.tagByName.hasOwnProperty(tag))res=der.tagByName[tag];else{if("number"!=typeof tag||(0|tag)!==tag)return reporter.error("Unknown tag: "+tag);res=tag}if(res>=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++;(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<str.length;i++)buf.writeUInt16BE(str.charCodeAt(i),2*i);return this._createEncoderBuffer(buf)}return"numstr"===tag?this._isNumstr(str)?this._createEncoderBuffer(str):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===tag?this._isPrintstr(str)?this._createEncoderBuffer(str):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(tag)?this._createEncoderBuffer(str):"objDesc"===tag?this._createEncoderBuffer(str):this.reporter.error("Encoding of string type: "+tag+" unsupported")},DERNode.prototype._encodeObjid=function(id,values,relative){if("string"==typeof id){if(!values)return this.reporter.error("string objid given, but no values map found");if(!values.hasOwnProperty(id))return this.reporter.error("objid not found in values map");id=values[id].split(/[\s\.]+/g);for(var i=0;i<id.length;i++)id[i]|=0}else if(Array.isArray(id)){id=id.slice();for(i=0;i<id.length;i++)id[i]|=0}if(!Array.isArray(id))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(id));if(!relative){if(id[1]>=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<id.length;i++){var ident=id[i];for(size++;ident>=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)},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;i<data.length;i++)if(data[i]!==state.defaultBuffer[i])return!1;return!0}},{"../../asn1":1,buffer:51,inherits:103}],13:[function(require,module,exports){var encoders=exports;encoders.der=require("./der"),encoders.pem=require("./pem")},{"./der":12,"./pem":14}],14:[function(require,module,exports){var inherits=require("inherits"),DEREncoder=require("./der");function PEMEncoder(entity){DEREncoder.call(this,entity),this.enc="pem"}inherits(PEMEncoder,DEREncoder),module.exports=PEMEncoder,PEMEncoder.prototype.encode=function(data,options){for(var p=DEREncoder.prototype.encode.call(this,data).toString("base64"),out=["-----BEGIN "+options.label+"-----"],i=0;i<p.length;i+=64)out.push(p.slice(i,i+64));return out.push("-----END "+options.label+"-----"),out.join("\n")}},{"./der":12,inherits:103}],15:[function(require,module,exports){(function(global){"use strict";var objectAssign=require("object-assign"); | ||
2 | /*! | ||
3 | * The buffer module from node.js, for the browser. | ||
4 | * | ||
5 | * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> | ||
6 | * @license MIT | ||
7 | */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<len;++i)if(a[i]!==b[i]){x=a[i],y=b[i];break}return x<y?-1:y<x?1:0}function isBuffer(b){return global.Buffer&&"function"==typeof global.Buffer.isBuffer?global.Buffer.isBuffer(b):!(null==b||!b._isBuffer)}var util=require("util/"),hasOwn=Object.prototype.hasOwnProperty,pSlice=Array.prototype.slice,functionsHaveNames="foo"===function(){}.name;function pToString(obj){return Object.prototype.toString.call(obj)}function isView(arrbuf){return!isBuffer(arrbuf)&&("function"==typeof global.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(arrbuf):!!arrbuf&&(arrbuf instanceof DataView||!!(arrbuf.buffer&&arrbuf.buffer instanceof ArrayBuffer))))}var assert=module.exports=ok,regex=/\s*function\s+([^\(\s]*)\s*/;function getName(func){if(util.isFunction(func)){if(functionsHaveNames)return func.name;var match=func.toString().match(regex);return match&&match[1]}}function truncate(s,n){return"string"==typeof s?s.length<n?s:s.slice(0,n):s}function inspect(something){if(functionsHaveNames||!util.isFunction(something))return util.inspect(something);var rawname=getName(something);return"[Function"+(rawname?": "+rawname:"")+"]"}function fail(actual,expected,message,operator,stackStartFunction){throw new assert.AssertionError({message:message,actual:actual,expected:expected,operator:operator,stackStartFunction:stackStartFunction})}function ok(value,message){value||fail(value,!0,message,"==",assert.ok)}function _deepEqual(actual,expected,strict,memos){if(actual===expected)return!0;if(isBuffer(actual)&&isBuffer(expected))return 0===compare(actual,expected);if(util.isDate(actual)&&util.isDate(expected))return actual.getTime()===expected.getTime();if(util.isRegExp(actual)&&util.isRegExp(expected))return actual.source===expected.source&&actual.global===expected.global&&actual.multiline===expected.multiline&&actual.lastIndex===expected.lastIndex&&actual.ignoreCase===expected.ignoreCase;if(null!==actual&&"object"==typeof actual||null!==expected&&"object"==typeof expected){if(isView(actual)&&isView(expected)&&pToString(actual)===pToString(expected)&&!(actual instanceof Float32Array||actual instanceof Float64Array))return 0===compare(new Uint8Array(actual.buffer),new Uint8Array(expected.buffer));if(isBuffer(actual)!==isBuffer(expected))return!1;var actualIndex=(memos=memos||{actual:[],expected:[]}).actual.indexOf(actual);return-1!==actualIndex&&actualIndex===memos.expected.indexOf(expected)||(memos.actual.push(actual),memos.expected.push(expected),function(a,b,strict,actualVisitedObjects){if(null==a||null==b)return!1;if(util.isPrimitive(a)||util.isPrimitive(b))return a===b;if(strict&&Object.getPrototypeOf(a)!==Object.getPrototypeOf(b))return!1;var aIsArgs=isArguments(a),bIsArgs=isArguments(b);if(aIsArgs&&!bIsArgs||!aIsArgs&&bIsArgs)return!1;if(aIsArgs)return a=pSlice.call(a),b=pSlice.call(b),_deepEqual(a,b,strict);var key,i,ka=objectKeys(a),kb=objectKeys(b);if(ka.length!==kb.length)return!1;for(ka.sort(),kb.sort(),i=ka.length-1;i>=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)}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,isUnexpectedException=!shouldThrow&&actual&&!expected;if((!shouldThrow&&util.isError(actual)&&userProvidedMessage&&expectedException(actual,expected)||isUnexpectedException)&&fail(actual,expected,"Got unwanted exception"+message),shouldThrow&&actual&&expected&&!expectedException(actual,expected)||!shouldThrow&&actual)throw actual}assert.AssertionError=function(options){this.name="AssertionError",this.actual=options.actual,this.expected=options.expected,this.operator=options.operator,options.message?(this.message=options.message,this.generatedMessage=!1):(this.message=function(self){return truncate(inspect(self.actual),128)+" "+self.operator+" "+truncate(inspect(self.expected),128)}(this),this.generatedMessage=!0);var stackStartFunction=options.stackStartFunction||fail;if(Error.captureStackTrace)Error.captureStackTrace(this,stackStartFunction);else{var err=new Error;if(err.stack){var out=err.stack,fn_name=getName(stackStartFunction),idx=out.indexOf("\n"+fn_name);if(idx>=0){var next_line=out.indexOf("\n",idx+1);out=out.substring(next_line+1)}this.stack=out}}},util.inherits(assert.AssertionError,Error),assert.fail=fail,assert.ok=ok,assert.equal=function(actual,expected,message){actual!=expected&&fail(actual,expected,message,"==",assert.equal)},assert.notEqual=function(actual,expected,message){actual==expected&&fail(actual,expected,message,"!=",assert.notEqual)},assert.deepEqual=function(actual,expected,message){_deepEqual(actual,expected,!1)||fail(actual,expected,message,"deepEqual",assert.deepEqual)},assert.deepStrictEqual=function(actual,expected,message){_deepEqual(actual,expected,!0)||fail(actual,expected,message,"deepStrictEqual",assert.deepStrictEqual)},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)},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},assert.strict=objectAssign((function strict(value,message){value||fail(value,!0,message,"==",strict)}),assert,{equal:assert.strictEqual,deepEqual:assert.deepStrictEqual,notEqual:assert.notStrictEqual,notDeepEqual:assert.notDeepStrictEqual}),assert.strict.strict=assert.strict;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:{})},{"object-assign":110,"util/":18}],16:[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}},{}],17:[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}},{}],18:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){for(var objects=[],i=0;i<arguments.length;i++)objects.push(inspect(arguments[i]));return objects.join(" ")}i=1;for(var args=arguments,len=args.length,str=String(f).replace(formatRegExp,(function(x){if("%%"===x)return"%";if(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<len;x=args[++i])isNull(x)||!isObject(x)?str+=" "+x:str+=" "+inspect(x);return str},exports.deprecate=function(fn,msg){if(isUndefined(global.process))return function(){return exports.deprecate(fn,msg).apply(this,arguments)};if(!0===process.noDeprecation)return fn;var warned=!1;return function(){if(!warned){if(process.throwDeprecation)throw new Error(msg);process.traceDeprecation?console.trace(msg):console.error(msg),warned=!0}return fn.apply(this,arguments)}};var debugEnviron,debugs={};function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};return arguments.length>=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)}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 output,base="",array=!1,braces=["{","}"];(isArray(value)&&(array=!0,braces=["[","]"]),isFunction(value))&&(base=" [Function"+(value.name?": "+value.name:"")+"]");return 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?recurseTimes<0?isRegExp(value)?ctx.stylize(RegExp.prototype.toString.call(value),"regexp"):ctx.stylize("[Object]","special"):(ctx.seen.push(value),output=array?function(ctx,value,recurseTimes,visibleKeys,keys){for(var output=[],i=0,l=value.length;i<l;++i)hasOwnProperty(value,String(i))?output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),!0)):output.push("");return keys.forEach((function(key){key.match(/^\d+$/)||output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,!0))})),output}(ctx,value,recurseTimes,visibleKeys,keys):keys.map((function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})),ctx.seen.pop(),function(output,base,braces){if(output.reduce((function(prev,cur){return cur.indexOf("\n")>=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)):braces[0]+base+braces[1]}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)}function isBoolean(arg){return"boolean"==typeof arg}function isNull(arg){return null===arg}function isNumber(arg){return"number"==typeof arg}function isString(arg){return"string"==typeof arg}function isUndefined(arg){return void 0===arg}function isRegExp(re){return isObject(re)&&"[object RegExp]"===objectToString(re)}function isObject(arg){return"object"==typeof arg&&null!==arg}function isDate(d){return isObject(d)&&"[object Date]"===objectToString(d)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(arg){return"function"==typeof arg}function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}exports.debuglog=function(set){if(isUndefined(debugEnviron)&&(debugEnviron=process.env.NODE_DEBUG||""),set=set.toUpperCase(),!debugs[set])if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else debugs[set]=function(){};return debugs[set]},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"},exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=function(arg){return null==arg},exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=function(arg){return"symbol"==typeof arg},exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,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");var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var d=new Date,time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}exports.log=function(){console.log("%s - %s",timestamp(),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}}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":17,_process:122,inherits:16}],19:[function(require,module,exports){"use strict";exports.byteLength=function(b64){var lens=getLens(b64),validLen=lens[0],placeHoldersLen=lens[1];return 3*(validLen+placeHoldersLen)/4-placeHoldersLen},exports.toByteArray=function(b64){var tmp,i,lens=getLens(b64),validLen=lens[0],placeHoldersLen=lens[1],arr=new Arr(function(b64,validLen,placeHoldersLen){return 3*(validLen+placeHoldersLen)/4-placeHoldersLen}(0,validLen,placeHoldersLen)),curByte=0,len=placeHoldersLen>0?validLen-4:validLen;for(i=0;i<len;i+=4)tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)],arr[curByte++]=tmp>>16&255,arr[curByte++]=tmp>>8&255,arr[curByte++]=255&tmp;2===placeHoldersLen&&(tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4,arr[curByte++]=255&tmp);1===placeHoldersLen&&(tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2,arr[curByte++]=tmp>>8&255,arr[curByte++]=255&tmp);return arr},exports.fromByteArray=function(uint8){for(var tmp,len=uint8.length,extraBytes=len%3,parts=[],i=0,len2=len-extraBytes;i<len2;i+=16383)parts.push(encodeChunk(uint8,i,i+16383>len2?len2:i+16383));1===extraBytes?(tmp=uint8[len-1],parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")):2===extraBytes&&(tmp=(uint8[len-2]<<8)+uint8[len-1],parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"="));return parts.join("")};for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function getLens(b64){var len=b64.length;if(len%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var validLen=b64.indexOf("=");return-1===validLen&&(validLen=len),[validLen,validLen===len?0:4-validLen%4]}function encodeChunk(uint8,start,end){for(var tmp,num,output=[],i=start;i<end;i+=3)tmp=(uint8[i]<<16&16711680)+(uint8[i+1]<<8&65280)+(255&uint8[i+2]),output.push(lookup[(num=tmp)>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[63&num]);return output.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63},{}],20:[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(BN.isBN(number))return number;this.negative=0,this.words=null,this.length=0,this.red=null,null!==number&&("le"!==base&&"be"!==base||(endian=base,base=10),this._init(number||0,base||10,endian||"be"))}var Buffer;"object"==typeof module?module.exports=BN:exports.BN=BN,BN.BN=BN,BN.wordSize=26;try{Buffer=require("buffer").Buffer}catch(e){}function parseHex(str,start,end){for(var r=0,len=Math.min(str.length,end),i=start;i<len;i++){var c=str.charCodeAt(i)-48;r<<=4,r|=c>=49&&c<=54?c-49+10:c>=17&&c<=22?c-17+10:15&c}return r}function parseBase(str,start,end,mul){for(var r=0,len=Math.min(str.length,end),i=start;i<len;i++){var c=str.charCodeAt(i)-48;r*=mul,r+=c>=49?c-49+10:c>=17?c-17+10:c}return r}BN.isBN=function(num){return num instanceof BN||null!==num&&"object"==typeof num&&num.constructor.wordSize===BN.wordSize&&Array.isArray(num.words)},BN.max=function(left,right){return left.cmp(right)>0?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<this.length;i++)this.words[i]=0;var j,w,off=0;if("be"===endian)for(i=number.length-1,j=0;i>=0;i-=3)w=number[i]|number[i-1]<<8|number[i-2]<<16,this.words[j]|=w<<off&67108863,this.words[j+1]=w>>>26-off&67108863,(off+=24)>=26&&(off-=26,j++);else if("le"===endian)for(i=0,j=0;i<number.length;i+=3)w=number[i]|number[i+1]<<8|number[i+2]<<16,this.words[j]|=w<<off&67108863,this.words[j+1]=w>>>26-off&67108863,(off+=24)>=26&&(off-=26,j++);return this.strip()},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<this.length;i++)this.words[i]=0;var j,w,off=0;for(i=number.length-6,j=0;i>=start;i-=6)w=parseHex(number,i,i+6),this.words[j]|=w<<off&67108863,this.words[j+1]|=w>>>26-off&4194303,(off+=24)>=26&&(off-=26,j++);i+6!==start&&(w=parseHex(number,start,i+6),this.words[j]|=w<<off&67108863,this.words[j+1]|=w>>>26-off&4194303),this.strip()},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;i<end;i+=limbLen)word=parseBase(number,i,i+limbLen,base),this.imuln(limbPow),this.words[0]+word<67108864?this.words[0]+=word:this._iaddn(word);if(0!==mod){var pow=1;for(word=parseBase(number,i,number.length,base),i=0;i<mod;i++)pow*=base;this.imuln(pow),this.words[0]+word<67108864?this.words[0]+=word:this._iaddn(word)}},BN.prototype.copy=function(dest){dest.words=new Array(this.length);for(var i=0;i<this.length;i++)dest.words[i]=this.words[i];dest.length=this.length,dest.negative=this.negative,dest.red=this.red},BN.prototype.clone=function(){var r=new BN(null);return this.copy(r),r},BN.prototype._expand=function(size){for(;this.length<size;)this.words[this.length++]=0;return this},BN.prototype.strip=function(){for(;this.length>1&&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?"<BN-R: ":"<BN: ")+this.toString(16)+">"};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];function smallMulTo(self,num,out){out.negative=num.negative^self.negative;var len=self.length+num.length|0;out.length=len,len=len-1|0;var a=0|self.words[0],b=0|num.words[0],r=a*b,lo=67108863&r,carry=r/67108864|0;out.words[0]=lo;for(var k=1;k<len;k++){for(var ncarry=carry>>>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()}BN.prototype.toString=function(base,padding){var out;if(padding=0|padding||1,16===(base=base||10)||"hex"===base){out="";for(var off=0,carry=0,i=0;i<this.length;i++){var w=this.words[i],word=(16777215&(w<<off|carry)).toString(16);out=0!==(carry=w>>>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<reqLength;i++)res[i]=0}else{for(i=0;i<reqLength-byteLength;i++)res[i]=0;for(i=0;!q.isZero();i++)b=q.andln(255),q.iushrn(8),res[reqLength-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 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;i<this.length;i++){var b=this._zeroBits(this.words[i]);if(r+=b,26!==b)break}return r},BN.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},BN.prototype.toTwos=function(width){return 0!==this.negative?this.abs().inotn(width).iaddn(1):this.clone()},BN.prototype.fromTwos=function(width){return this.testn(width-1)?this.notn(width).iaddn(1).ineg():this.clone()},BN.prototype.isNeg=function(){return 0!==this.negative},BN.prototype.neg=function(){return this.clone().ineg()},BN.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},BN.prototype.iuor=function(num){for(;this.length<num.length;)this.words[this.length++]=0;for(var i=0;i<num.length;i++)this.words[i]=this.words[i]|num.words[i];return this.strip()},BN.prototype.ior=function(num){return assert(0==(this.negative|num.negative)),this.iuor(num)},BN.prototype.or=function(num){return this.length>num.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;i<b.length;i++)this.words[i]=this.words[i]&num.words[i];return this.length=b.length,this.strip()},BN.prototype.iand=function(num){return assert(0==(this.negative|num.negative)),this.iuand(num)},BN.prototype.and=function(num){return this.length>num.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;i<b.length;i++)this.words[i]=a.words[i]^b.words[i];if(this!==a)for(;i<a.length;i++)this.words[i]=a.words[i];return this.length=a.length,this.strip()},BN.prototype.ixor=function(num){return assert(0==(this.negative|num.negative)),this.iuxor(num)},BN.prototype.xor=function(num){return this.length>num.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;i<bytesNeeded;i++)this.words[i]=67108863&~this.words[i];return bitsLeft>0&&(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<<wbit:this.words[off]&~(1<<wbit),this.strip()},BN.prototype.iadd=function(num){var r,a,b;if(0!==this.negative&&0===num.negative)return this.negative=0,r=this.isub(num),this.negative^=1,this._normSign();if(0===this.negative&&0!==num.negative)return num.negative=0,r=this.isub(num),num.negative=1,r._normSign();this.length>num.length?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i<b.length;i++)r=(0|a.words[i])+(0|b.words[i])+carry,this.words[i]=67108863&r,carry=r>>>26;for(;0!==carry&&i<a.length;i++)r=(0|a.words[i])+carry,this.words[i]=67108863&r,carry=r>>>26;if(this.length=a.length,0!==carry)this.words[this.length]=carry,this.length++;else if(a!==this)for(;i<a.length;i++)this.words[i]=a.words[i];return this},BN.prototype.add=function(num){var res;return 0!==num.negative&&0===this.negative?(num.negative=0,res=this.sub(num),num.negative^=1,res):0===num.negative&&0!==this.negative?(this.negative=0,res=num.sub(this),this.negative=1,res):this.length>num.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 a,b,cmp=this.cmp(num);if(0===cmp)return this.negative=0,this.length=1,this.words[0]=0,this;cmp>0?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i<b.length;i++)carry=(r=(0|a.words[i])-(0|b.words[i])+carry)>>26,this.words[i]=67108863&r;for(;0!==carry&&i<a.length;i++)carry=(r=(0|a.words[i])+carry)>>26,this.words[i]=67108863&r;if(0===carry&&i<a.length&&a!==this)for(;i<a.length;i++)this.words[i]=a.words[i];return this.length=Math.max(this.length,i),a!==this&&(this.negative=1),this.strip()},BN.prototype.sub=function(num){return this.clone().isub(num)};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};function jumboMulTo(self,num,out){return(new FFTM).mulp(self,num,out)}function FFTM(x,y){this.x=x,this.y=y}Math.imul||(comb10MulTo=smallMulTo),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<out.length-1;k++){var ncarry=hncarry;hncarry=0;for(var 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,r=(0|self.words[i])*(0|num.words[j]),lo=67108863&r;rword=67108863&(lo=lo+rword|0),hncarry+=(ncarry=(ncarry=ncarry+(r/67108864|0)|0)+(lo>>>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)},FFTM.prototype.makeRBT=function(N){for(var t=new Array(N),l=BN.prototype._countBits(N)-1,i=0;i<N;i++)t[i]=this.revBin(i,l,N);return t},FFTM.prototype.revBin=function(x,l,N){if(0===x||x===N-1)return x;for(var rb=0,i=0;i<l;i++)rb|=(1&x)<<l-i-1,x>>=1;return rb},FFTM.prototype.permute=function(rbt,rws,iws,rtws,itws,N){for(var i=0;i<N;i++)rtws[i]=rws[rbt[i]],itws[i]=iws[rbt[i]]},FFTM.prototype.transform=function(rws,iws,rtws,itws,N,rbt){this.permute(rbt,rws,iws,rtws,itws,N);for(var s=1;s<N;s<<=1)for(var l=s<<1,rtwdf=Math.cos(2*Math.PI/l),itwdf=Math.sin(2*Math.PI/l),p=0;p<N;p+=l)for(var rtwdf_=rtwdf,itwdf_=itwdf,j=0;j<s;j++){var re=rtws[p+j],ie=itws[p+j],ro=rtws[p+j+s],io=itws[p+j+s],rx=rtwdf_*ro-itwdf_*io;io=rtwdf_*io+itwdf_*ro,ro=rx,rtws[p+j]=re+ro,itws[p+j]=ie+io,rtws[p+j+s]=re-ro,itws[p+j+s]=ie-io,j!==l&&(rx=rtwdf*rtwdf_-itwdf*itwdf_,itwdf_=rtwdf*itwdf_+itwdf*rtwdf_,rtwdf_=rx)}},FFTM.prototype.guessLen13b=function(n,m){var N=1|Math.max(m,n),odd=1&N,i=0;for(N=N/2|0;N;N>>>=1)i++;return 1<<i+1+odd},FFTM.prototype.conjugate=function(rws,iws,N){if(!(N<=1))for(var i=0;i<N/2;i++){var t=rws[i];rws[i]=rws[N-i-1],rws[N-i-1]=t,t=iws[i],iws[i]=-iws[N-i-1],iws[N-i-1]=-t}},FFTM.prototype.normalize13b=function(ws,N){for(var carry=0,i=0;i<N/2;i++){var w=8192*Math.round(ws[2*i+1]/N)+Math.round(ws[2*i]/N)+carry;ws[i]=67108863&w,carry=w<67108864?0:w/67108864|0}return ws},FFTM.prototype.convert13b=function(ws,len,rws,N){for(var carry=0,i=0;i<len;i++)carry+=0|ws[i],rws[2*i]=8191&carry,carry>>>=13,rws[2*i+1]=8191&carry,carry>>>=13;for(i=2*len;i<N;++i)rws[i]=0;assert(0===carry),assert(0==(-8192&carry))},FFTM.prototype.stub=function(N){for(var ph=new Array(N),i=0;i<N;i++)ph[i]=0;return ph},FFTM.prototype.mulp=function(x,y,out){var N=2*this.guessLen13b(x.length,y.length),rbt=this.makeRBT(N),_=this.stub(N),rws=new Array(N),rwst=new Array(N),iwst=new Array(N),nrws=new Array(N),nrwst=new Array(N),niwst=new Array(N),rmws=out.words;rmws.length=N,this.convert13b(x.words,x.length,rws,N),this.convert13b(y.words,y.length,nrws,N),this.transform(rws,_,rwst,iwst,N,rbt),this.transform(nrws,_,nrwst,niwst,N,rbt);for(var i=0;i<N;i++){var rx=rwst[i]*nrwst[i]-iwst[i]*niwst[i];iwst[i]=rwst[i]*niwst[i]+iwst[i]*nrwst[i],rwst[i]=rx}return this.conjugate(rwst,iwst,N),this.transform(rwst,iwst,rmws,_,N,rbt),this.conjugate(rmws,_,N),this.normalize13b(rmws,N),out.negative=x.negative^y.negative,out.length=x.length+y.length,out.strip()},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.mulf=function(num){var out=new BN(null);return out.words=new Array(this.length+num.length),jumboMulTo(this,num,out)},BN.prototype.imul=function(num){return this.clone().mulTo(num,this)},BN.prototype.imuln=function(num){assert("number"==typeof num),assert(num<67108864);for(var carry=0,i=0;i<this.length;i++){var w=(0|this.words[i])*num,lo=(67108863&w)+(67108863&carry);carry>>=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<w.length;bit++){var off=bit/26|0,wbit=bit%26;w[bit]=(num.words[off]&1<<wbit)>>>wbit}return w}(num);if(0===w.length)return new BN(1);for(var res=this,i=0;i<w.length&&0===w[i];i++,res=res.sqr());if(++i<w.length)for(var q=res.sqr();i<w.length;i++,q=q.sqr())0!==w[i]&&(res=res.mul(q));return res},BN.prototype.iushln=function(bits){assert("number"==typeof bits&&bits>=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<this.length;i++){var newCarry=this.words[i]&carryMask,c=(0|this.words[i])-newCarry<<r;this.words[i]=c|carry,carry=newCarry>>>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<s;i++)this.words[i]=0;this.length+=s}return this.strip()},BN.prototype.ishln=function(bits){return assert(0===this.negative),this.iushln(bits)},BN.prototype.iushrn=function(bits,hint,extended){var h;assert("number"==typeof bits&&bits>=0),h=hint?(hint-hint%26)/26:0;var r=bits%26,s=Math.min((bits-r)/26,this.length),mask=67108863^67108863>>>r<<r,maskedWords=extended;if(h-=s,h=Math.max(0,h),maskedWords){for(var i=0;i<s;i++)maskedWords.words[i]=this.words[i];maskedWords.length=s}if(0===s);else if(this.length>s)for(this.length-=s,i=0;i<this.length;i++)this.words[i]=this.words[i+s];else this.words[0]=0,this.length=1;var carry=0;for(i=this.length-1;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<<r;return!(this.length<=s)&&!!(this.words[s]&q)},BN.prototype.imaskn=function(bits){assert("number"==typeof bits&&bits>=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<<r;this.words[this.length-1]&=mask}return this.strip()},BN.prototype.maskn=function(bits){return this.clone().imaskn(bits)},BN.prototype.iaddn=function(num){return assert("number"==typeof num),assert(num<67108864),num<0?this.isubn(-num):0!==this.negative?1===this.length&&(0|this.words[0])<num?(this.words[0]=num-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(num),this.negative=1,this):this._iaddn(num)},BN.prototype._iaddn=function(num){this.words[0]+=num;for(var i=0;i<this.length&&this.words[i]>=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<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this.strip()},BN.prototype.addn=function(num){return this.clone().iaddn(num)},BN.prototype.subn=function(num){return this.clone().isubn(num)},BN.prototype.iabs=function(){return this.negative=0,this},BN.prototype.abs=function(){return this.clone().iabs()},BN.prototype._ishlnsubmul=function(num,mul,shift){var i,w,len=num.length+shift;this._expand(len);var carry=0;for(i=0;i<num.length;i++){w=(0|this.words[i+shift])+carry;var right=(0|num.words[i])*mul;carry=((w-=67108863&right)>>26)-(right/67108864|0),this.words[i+shift]=67108863&w}for(;i<this.length-shift;i++)carry=(w=(0|this.words[i+shift])+carry)>>26,this.words[i+shift]=67108863&w;if(0===carry)return this.strip();for(assert(-1===carry),carry=0,i=0;i<this.length;i++)carry=(w=-(0|this.words[i])+carry)>>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<q.length;i++)q.words[i]=0}var diff=a.clone()._ishlnsubmul(b,1,m);0===diff.negative&&(a=diff,q&&(q.words[m]=1));for(var j=m-1;j>=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){return assert(!num.isZero()),this.isZero()?{div:new BN(0),mod:new BN(0)}: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);var div,mod,res},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 res,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))}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<<r;if(this.length<=s)return this._expand(s+1),this.words[s]|=q,this;for(var carry=q,i=s;0!==carry&&i<this.length;i++){var w=0|this.words[i];carry=(w+=carry)>>>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 res,negative=num<0;if(0!==this.negative&&!negative)return-1;if(0===this.negative&&negative)return 1;if(this.strip(),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:w<num?-1:1}return 0!==this.negative?0|-res:res},BN.prototype.cmp=function(num){if(0!==this.negative&&0===num.negative)return-1;if(0===this.negative&&0!==num.negative)return 1;var res=this.ucmp(num);return 0!==this.negative?0|-res:res},BN.prototype.ucmp=function(num){if(this.length>num.length)return 1;if(this.length<num.length)return-1;for(var res=0,i=this.length-1;i>=0;i--){var a=0|this.words[i],b=0|num.words[i];if(a!==b){a<b?res=-1:a>b&&(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()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}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}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)}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=rlen<this.n?-1:r.ucmp(this.p);return 0===cmp?(r.words[0]=0,r.length=1):cmp>0?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)},inherits(K256,MPrime),K256.prototype.split=function(input,output){for(var outLen=Math.min(input.length,9),i=0;i<outLen;i++)output.words[i]=input.words[i];if(output.length=outLen,input.length<=9)return input.words[0]=0,void(input.length=1);var prev=input.words[9];for(output.words[output.length++]=4194303&prev,i=10;i<input.length;i++){var next=0|input.words[i];input.words[i-10]=(4194303&next)<<4|prev>>>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<num.length;i++){var w=0|num.words[i];lo+=977*w,num.words[i]=67108863&lo,lo=64*w+(lo/67108864|0)}return 0===num.words[num.length-1]&&(num.length--,0===num.words[num.length-1]&&num.length--),num},inherits(P224,MPrime),inherits(P192,MPrime),inherits(P25519,MPrime),P25519.prototype.imulK=function(num){for(var carry=0,i=0;i<num.length;i++){var hi=19*(0|num.words[i])+carry,lo=67108863&hi;hi>>>=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},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<m);var b=this.pow(c,new BN(1).iushln(m-i-1));r=r.redMul(b),c=b.redSqr(),t=t.redMul(c),m=i}return r},Red.prototype.invm=function(a){var inv=a._invmp(this.m);return 0!==inv.negative?(inv.negative=0,this.imod(inv).redNeg()):this.imod(inv)},Red.prototype.pow=function(a,num){if(num.isZero())return new BN(1).toRed(this);if(0===num.cmpn(1))return a.clone();var wnd=new Array(16);wnd[0]=new BN(1).toRed(this),wnd[1]=a;for(var i=2;i<wnd.length;i++)wnd[i]=this.mul(wnd[i-1],a);var res=wnd[0],current=0,currentLen=0,start=num.bitLength()%26;for(0===start&&(start=26),i=num.length-1;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)},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:22}],21:[function(require,module,exports){var r;function Rand(rand){this.rand=rand}if(module.exports=function(len){return r||(r=new Rand(null)),r.generate(len)},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<res.length;i++)res[i]=this.rand.getByte();return res},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?Rand.prototype._rand=function(n){var arr=new Uint8Array(n);return self.crypto.getRandomValues(arr),arr}:self.msCrypto&&self.msCrypto.getRandomValues?Rand.prototype._rand=function(n){var arr=new Uint8Array(n);return self.msCrypto.getRandomValues(arr),arr}:"object"==typeof window&&(Rand.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var crypto=require("crypto");if("function"!=typeof crypto.randomBytes)throw new Error("Not supported");Rand.prototype._rand=function(n){return crypto.randomBytes(n)}}catch(e){}},{crypto:22}],22:[function(require,module,exports){},{}],23:[function(require,module,exports){var Buffer=require("safe-buffer").Buffer;function asUInt32Array(buf){Buffer.isBuffer(buf)||(buf=Buffer.from(buf));for(var len=buf.length/4|0,out=new Array(len),i=0;i<len;i++)out[i]=buf.readUInt32BE(4*i);return out}function scrubVec(v){for(;0<v.length;v++)v[0]=0}function cryptBlock(M,keySchedule,SUB_MIX,SBOX,nRounds){for(var t0,t1,t2,t3,SUB_MIX0=SUB_MIX[0],SUB_MIX1=SUB_MIX[1],SUB_MIX2=SUB_MIX[2],SUB_MIX3=SUB_MIX[3],s0=M[0]^keySchedule[0],s1=M[1]^keySchedule[1],s2=M[2]^keySchedule[2],s3=M[3]^keySchedule[3],ksRow=4,round=1;round<nRounds;round++)t0=SUB_MIX0[s0>>>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<keySize;k++)keySchedule[k]=keyWords[k];for(k=keySize;k<ksRows;k++){var t=keySchedule[k-1];k%keySize==0?(t=t<<8|t>>>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<ksRows;ik++){var ksR=ksRows-ik,tt=keySchedule[ksR-(ik%4?0:4)];invKeySchedule[ik]=ik<4||ksR<=4?tt:G.INV_SUB_MIX[0][G.SBOX[tt>>>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":151}],24:[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;i<len;++i)out+=a[i]^b[i];return out}(tag,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=tag,this._cipher.scrub()},StreamCipher.prototype.getAuthTag=function(){if(this._decrypt||!Buffer.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},StreamCipher.prototype.setAuthTag=function(tag){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=tag},StreamCipher.prototype.setAAD=function(buf){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(buf),this._alen+=buf.length},module.exports=StreamCipher},{"./aes":23,"./ghash":28,"./incr32":29,"buffer-xor":50,"cipher-base":52,inherits:103,"safe-buffer":151}],25:[function(require,module,exports){var ciphers=require("./encrypter"),deciphers=require("./decrypter"),modes=require("./modes/list.json");exports.createCipher=exports.Cipher=ciphers.createCipher,exports.createCipheriv=exports.Cipheriv=ciphers.createCipheriv,exports.createDecipher=exports.Decipher=deciphers.createDecipher,exports.createDecipheriv=exports.Decipheriv=deciphers.createDecipheriv,exports.listCiphers=exports.getCiphers=function(){return Object.keys(modes)}},{"./decrypter":26,"./encrypter":27,"./modes/list.json":37}],26:[function(require,module,exports){var AuthCipher=require("./authCipher"),Buffer=require("safe-buffer").Buffer,MODES=require("./modes"),StreamCipher=require("./streamCipher"),Transform=require("cipher-base"),aes=require("./aes"),ebtk=require("evp_bytestokey");function Decipher(mode,key,iv){Transform.call(this),this._cache=new Splitter,this._last=void 0,this._cipher=new aes.AES(key),this._prev=Buffer.from(iv),this._mode=mode,this._autopadding=!0}function Splitter(){this.cache=Buffer.allocUnsafe(0)}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)}require("inherits")(Decipher,Transform),Decipher.prototype._update=function(data){var chunk,thing;this._cache.add(data);for(var out=[];chunk=this._cache.get(this._autopadding);)thing=this._mode.decrypt(this,chunk),out.push(thing);return Buffer.concat(out)},Decipher.prototype._final=function(){var chunk=this._cache.flush();if(this._autopadding)return function(last){var padded=last[15];if(padded<1||padded>16)throw new Error("unable to decrypt data");var i=-1;for(;++i<padded;)if(last[i+(16-padded)]!==padded)throw new Error("unable to decrypt data");if(16===padded)return;return last.slice(0,16-padded)}(this._mode.decrypt(this,chunk));if(chunk)throw new Error("data not multiple of block length")},Decipher.prototype.setAutoPadding=function(setTo){return this._autopadding=!!setTo,this},Splitter.prototype.add=function(data){this.cache=Buffer.concat([this.cache,data])},Splitter.prototype.get=function(autoPadding){var out;if(autoPadding){if(this.cache.length>16)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},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":23,"./authCipher":24,"./modes":36,"./streamCipher":39,"cipher-base":52,evp_bytestokey:87,inherits:103,"safe-buffer":151}],27:[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){var chunk,thing;this._cache.add(data);for(var out=[];chunk=this._cache.get();)thing=this._mode.encrypt(this,chunk),out.push(thing);return Buffer.concat(out)};var PADDING=Buffer.alloc(16,16);function Splitter(){this.cache=Buffer.allocUnsafe(0)}function createCipheriv(suite,password,iv){var config=MODES[suite.toLowerCase()];if(!config)throw new TypeError("invalid suite type");if("string"==typeof password&&(password=Buffer.from(password)),password.length!==config.key/8)throw new TypeError("invalid key length "+password.length);if("string"==typeof iv&&(iv=Buffer.from(iv)),"GCM"!==config.mode&&iv.length!==config.iv)throw new TypeError("invalid iv length "+iv.length);return"stream"===config.type?new StreamCipher(config.module,password,iv):"auth"===config.type?new AuthCipher(config.module,password,iv):new Cipher(config.module,password,iv)}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},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<len;)padBuff.writeUInt8(len,i);return Buffer.concat([this.cache,padBuff])},exports.createCipheriv=createCipheriv,exports.createCipher=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 createCipheriv(suite,keys.key,keys.iv)}},{"./aes":23,"./authCipher":24,"./modes":36,"./streamCipher":39,"cipher-base":52,evp_bytestokey:87,inherits:103,"safe-buffer":151}],28:[function(require,module,exports){var Buffer=require("safe-buffer").Buffer,ZEROES=Buffer.alloc(16,0);function fromArray(out){var buf=Buffer.allocUnsafe(16);return buf.writeUInt32BE(out[0]>>>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;++i<block.length;)this.state[i]^=block[i];this._multiply()},GHASH.prototype._multiply=function(){for(var buf,j,lsbVi,Vi=[(buf=this.h).readUInt32BE(0),buf.readUInt32BE(4),buf.readUInt32BE(8),buf.readUInt32BE(12)],Zi=[0,0,0,0],i=-1;++i<128;){for(0!=(this.state[~~(i/8)]&1<<7-i%8)&&(Zi[0]^=Vi[0],Zi[1]^=Vi[1],Zi[2]^=Vi[2],Zi[3]^=Vi[3]),lsbVi=0!=(1&Vi[3]),j=3;j>0;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){var chunk;for(this.cache=Buffer.concat([this.cache,buf]);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":151}],29:[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)}}},{}],30:[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":50}],31:[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":50,"safe-buffer":151}],32:[function(require,module,exports){var Buffer=require("safe-buffer").Buffer;function encryptByte(self,byteParam,decrypt){for(var bit,value,i=-1,out=0;++i<8;)bit=byteParam&1<<7-i?128:0,out+=(128&(value=self._cipher.encryptBlock(self._prev)[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<len;)out[i]=buffer[i]<<1|buffer[i+1]>>7;return out}exports.encrypt=function(self,chunk,decrypt){for(var len=chunk.length,out=Buffer.allocUnsafe(len),i=-1;++i<len;)out[i]=encryptByte(self,chunk[i],decrypt);return out}},{"safe-buffer":151}],33:[function(require,module,exports){var Buffer=require("safe-buffer").Buffer;function encryptByte(self,byteParam,decrypt){var out=self._cipher.encryptBlock(self._prev)[0]^byteParam;return self._prev=Buffer.concat([self._prev.slice(1),Buffer.from([decrypt?byteParam:out])]),out}exports.encrypt=function(self,chunk,decrypt){for(var len=chunk.length,out=Buffer.allocUnsafe(len),i=-1;++i<len;)out[i]=encryptByte(self,chunk[i],decrypt);return out}},{"safe-buffer":151}],34:[function(require,module,exports){var xor=require("buffer-xor"),Buffer=require("safe-buffer").Buffer,incr32=require("../incr32");function getBlock(self){var out=self._cipher.encryptBlockRaw(self._prev);return incr32(self._prev),out}exports.encrypt=function(self,chunk){var chunkNum=Math.ceil(chunk.length/16),start=self._cache.length;self._cache=Buffer.concat([self._cache,Buffer.allocUnsafe(16*chunkNum)]);for(var i=0;i<chunkNum;i++){var out=getBlock(self),offset=start+16*i;self._cache.writeUInt32BE(out[0],offset+0),self._cache.writeUInt32BE(out[1],offset+4),self._cache.writeUInt32BE(out[2],offset+8),self._cache.writeUInt32BE(out[3],offset+12)}var pad=self._cache.slice(0,chunk.length);return self._cache=self._cache.slice(chunk.length),xor(chunk,pad)}},{"../incr32":29,"buffer-xor":50,"safe-buffer":151}],35:[function(require,module,exports){exports.encrypt=function(self,block){return self._cipher.encryptBlock(block)},exports.decrypt=function(self,block){return self._cipher.decryptBlock(block)}},{}],36:[function(require,module,exports){var modeModules={ECB:require("./ecb"),CBC:require("./cbc"),CFB:require("./cfb"),CFB8:require("./cfb8"),CFB1:require("./cfb1"),OFB:require("./ofb"),CTR:require("./ctr"),GCM:require("./ctr")},modes=require("./list.json");for(var key in modes)modes[key].module=modeModules[modes[key].mode];module.exports=modes},{"./cbc":30,"./cfb":31,"./cfb1":32,"./cfb8":33,"./ctr":34,"./ecb":35,"./list.json":37,"./ofb":38}],37:[function(require,module,exports){module.exports={"aes-128-ecb":{cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},"aes-192-ecb":{cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},"aes-256-ecb":{cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},"aes-128-cbc":{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},"aes-192-cbc":{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},"aes-256-cbc":{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},aes128:{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},aes192:{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},aes256:{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},"aes-128-cfb":{cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},"aes-192-cfb":{cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},"aes-256-cfb":{cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},"aes-128-cfb8":{cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},"aes-192-cfb8":{cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},"aes-256-cfb8":{cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},"aes-128-cfb1":{cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},"aes-192-cfb1":{cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},"aes-256-cfb1":{cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},"aes-128-ofb":{cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},"aes-192-ofb":{cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},"aes-256-ofb":{cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},"aes-128-ctr":{cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},"aes-192-ctr":{cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},"aes-256-ctr":{cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},"aes-128-gcm":{cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},"aes-192-gcm":{cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},"aes-256-gcm":{cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}}},{}],38:[function(require,module,exports){(function(Buffer){var xor=require("buffer-xor");function getBlock(self){return self._prev=self._cipher.encryptBlock(self._prev),self._prev}exports.encrypt=function(self,chunk){for(;self._cache.length<chunk.length;)self._cache=Buffer.concat([self._cache,getBlock(self)]);var pad=self._cache.slice(0,chunk.length);return self._cache=self._cache.slice(chunk.length),xor(chunk,pad)}}).call(this,require("buffer").Buffer)},{buffer:51,"buffer-xor":50}],39:[function(require,module,exports){var aes=require("./aes"),Buffer=require("safe-buffer").Buffer,Transform=require("cipher-base");function StreamCipher(mode,key,iv,decrypt){Transform.call(this),this._cipher=new aes.AES(key),this._prev=Buffer.from(iv),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=decrypt,this._mode=mode}require("inherits")(StreamCipher,Transform),StreamCipher.prototype._update=function(chunk){return this._mode.encrypt(this,chunk,this._decrypt)},StreamCipher.prototype._final=function(){this._cipher.scrub()},module.exports=StreamCipher},{"./aes":23,"cipher-base":52,inherits:103,"safe-buffer":151}],40:[function(require,module,exports){var DES=require("browserify-des"),aes=require("browserify-aes/browser"),aesModes=require("browserify-aes/modes"),desModes=require("browserify-des/modes"),ebtk=require("evp_bytestokey");function createCipheriv(suite,key,iv){if(suite=suite.toLowerCase(),aesModes[suite])return aes.createCipheriv(suite,key,iv);if(desModes[suite])return new DES({key:key,iv:iv,mode:suite});throw new TypeError("invalid suite type")}function createDecipheriv(suite,key,iv){if(suite=suite.toLowerCase(),aesModes[suite])return aes.createDecipheriv(suite,key,iv);if(desModes[suite])return new DES({key:key,iv:iv,mode:suite,decrypt:!0});throw new TypeError("invalid suite type")}exports.createCipher=exports.Cipher=function(suite,password){var keyLen,ivLen;if(suite=suite.toLowerCase(),aesModes[suite])keyLen=aesModes[suite].key,ivLen=aesModes[suite].iv;else{if(!desModes[suite])throw new TypeError("invalid suite type");keyLen=8*desModes[suite].key,ivLen=desModes[suite].iv}var keys=ebtk(password,!1,keyLen,ivLen);return createCipheriv(suite,keys.key,keys.iv)},exports.createCipheriv=exports.Cipheriv=createCipheriv,exports.createDecipher=exports.Decipher=function(suite,password){var keyLen,ivLen;if(suite=suite.toLowerCase(),aesModes[suite])keyLen=aesModes[suite].key,ivLen=aesModes[suite].iv;else{if(!desModes[suite])throw new TypeError("invalid suite type");keyLen=8*desModes[suite].key,ivLen=desModes[suite].iv}var keys=ebtk(password,!1,keyLen,ivLen);return createDecipheriv(suite,keys.key,keys.iv)},exports.createDecipheriv=exports.Decipheriv=createDecipheriv,exports.listCiphers=exports.getCiphers=function(){return Object.keys(desModes).concat(aes.getCiphers())}},{"browserify-aes/browser":25,"browserify-aes/modes":36,"browserify-des":41,"browserify-des/modes":42,evp_bytestokey:87}],41:[function(require,module,exports){var CipherBase=require("cipher-base"),des=require("des.js"),inherits=require("inherits"),Buffer=require("safe-buffer").Buffer,modes={"des-ede3-cbc":des.CBC.instantiate(des.EDE),"des-ede3":des.EDE,"des-ede-cbc":des.CBC.instantiate(des.EDE),"des-ede":des.EDE,"des-cbc":des.CBC.instantiate(des.DES),"des-ecb":des.DES};function DES(opts){CipherBase.call(this);var type,modeName=opts.mode.toLowerCase(),mode=modes[modeName];type=opts.decrypt?"decrypt":"encrypt";var key=opts.key;Buffer.isBuffer(key)||(key=Buffer.from(key)),"des-ede"!==modeName&&"des-ede-cbc"!==modeName||(key=Buffer.concat([key,key.slice(0,8)]));var iv=opts.iv;Buffer.isBuffer(iv)||(iv=Buffer.from(iv)),this._des=mode.create({key:key,iv:iv,type:type})}modes.des=modes["des-cbc"],modes.des3=modes["des-ede3-cbc"],module.exports=DES,inherits(DES,CipherBase),DES.prototype._update=function(data){return Buffer.from(this._des.update(data))},DES.prototype._final=function(){return Buffer.from(this._des.final())}},{"cipher-base":52,"des.js":60,inherits:103,"safe-buffer":151}],42:[function(require,module,exports){exports["des-ecb"]={key:8,iv:0},exports["des-cbc"]=exports.des={key:8,iv:8},exports["des-ede3-cbc"]=exports.des3={key:24,iv:8},exports["des-ede3"]={key:24,iv:0},exports["des-ede-cbc"]={key:16,iv:8},exports["des-ede"]={key:16,iv:0}},{}],43:[function(require,module,exports){(function(Buffer){var bn=require("bn.js"),randomBytes=require("randombytes");function crt(msg,priv){var blinds=function(priv){var r=getr(priv);return{blinder:r.toRed(bn.mont(priv.modulus)).redPow(new bn(priv.publicExponent)).fromRed(),unblinder:r.invm(priv.modulus)}}(priv),len=priv.modulus.byteLength(),blinded=(bn.mont(priv.modulus),new bn(msg).mul(blinds.blinder).umod(priv.modulus)),c1=blinded.toRed(bn.mont(priv.prime1)),c2=blinded.toRed(bn.mont(priv.prime2)),qinv=priv.coefficient,p=priv.prime1,q=priv.prime2,m1=c1.redPow(priv.exponent1),m2=c2.redPow(priv.exponent2);m1=m1.fromRed(),m2=m2.fromRed();var h=m1.isub(m2).imul(qinv).umod(p);return h.imul(q),m2.iadd(h),new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(!1,len))}function getr(priv){for(var len=priv.modulus.byteLength(),r=new bn(randomBytes(len));r.cmp(priv.modulus)>=0||!r.umod(priv.prime1)||!r.umod(priv.prime2);)r=new bn(randomBytes(len));return r}module.exports=crt,crt.getr=getr}).call(this,require("buffer").Buffer)},{"bn.js":20,buffer:51,randombytes:133}],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");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}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}function createSign(algorithm){return new Sign(algorithm)}function createVerify(algorithm){return new Verify(algorithm)}Object.keys(algorithms).forEach((function(key){algorithms[key].id=new Buffer(algorithms[key].id,"hex"),algorithms[key.toLowerCase()]=algorithms[key]})),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},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)},module.exports={Sign:createSign,Verify:createVerify,createSign:createSign,createVerify:createVerify}}).call(this,require("buffer").Buffer)},{"./algorithms.json":45,"./sign":48,"./verify":49,buffer:51,"create-hash":55,inherits:103,stream:160}],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())).length<q.byteLength()){var zeros=new Buffer(q.byteLength()-x.length);zeros.fill(0),x=Buffer.concat([zeros,x])}var hlen=hash.length,hbits=function(bits,q){bits=(bits=bits2int(bits,q)).mod(q);var out=new Buffer(bits.toArray());if(out.length<q.byteLength()){var zeros=new Buffer(q.byteLength()-out.length);zeros.fill(0),out=Buffer.concat([zeros,out])}return out}(hash,q),v=new Buffer(hlen);v.fill(1);var k=new Buffer(hlen);return k.fill(0),k=createHmac(algo,k).update(v).update(new Buffer([0])).update(x).update(hbits).digest(),v=createHmac(algo,k).update(v).digest(),{k:k=createHmac(algo,k).update(v).update(new Buffer([1])).update(x).update(hbits).digest(),v:v=createHmac(algo,k).update(v).digest()}}function bits2int(obits,q){var bits=new BN(obits),shift=(obits.length<<3)-q.bitLength();return shift>0&&bits.ishrn(shift),bits}function makeKey(q,kv,algo){var t,k;do{for(t=new Buffer(0);8*t.length<q.bitLength();)kv.v=createHmac(algo,kv.k).update(kv.v).digest(),t=Buffer.concat([t,kv.v]);k=bits2int(t,q),kv.k=createHmac(algo,kv.k).update(kv.v).update(new Buffer([0])).digest(),kv.v=createHmac(algo,kv.k).update(kv.v).digest()}while(-1!==k.cmp(q));return k}function makeR(g,k,p,q){return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)}module.exports=function(hash,key,hashType,signType,tag){var priv=parseKeys(key);if(priv.curve){if("ecdsa"!==signType&&"ecdsa/rsa"!==signType)throw new Error("wrong private key type");return function(hash,priv){var curveId=curves[priv.curve.join(".")];if(!curveId)throw new Error("unknown curve "+priv.curve.join("."));var out=new EC(curveId).keyFromPrivate(priv.privateKey).sign(hash);return new Buffer(out.toDER())}(hash,priv)}if("dsa"===priv.type){if("dsa"!==signType)throw new Error("wrong private key type");return function(hash,priv,algo){var k,x=priv.params.priv_key,p=priv.params.p,q=priv.params.q,g=priv.params.g,r=new BN(0),H=bits2int(hash,q).mod(q),s=!1,kv=getKey(x,q,hash,algo);for(;!1===s;)k=makeKey(q,kv,algo),r=makeR(g,k,p,q),0===(s=k.invm(q).imul(H.add(x.mul(r))).mod(q)).cmpn(0)&&(s=!1,r=new BN(0));return function(r,s){r=r.toArray(),s=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),new Buffer(res)}(r,s)}(hash,priv,hashType)}if("rsa"!==signType&&"ecdsa/rsa"!==signType)throw new Error("wrong private key type");hash=Buffer.concat([tag,hash]);for(var len=priv.modulus.byteLength(),pad=[0,1];hash.length+pad.length+1<len;)pad.push(255);pad.push(0);for(var i=-1;++i<hash.length;)pad.push(hash[i]);return crt(pad,priv)},module.exports.getKey=getKey,module.exports.makeKey=makeKey}).call(this,require("buffer").Buffer)},{"./curves.json":46,"bn.js":20,"browserify-rsa":43,buffer:51,"create-hmac":57,elliptic:70,"parse-asn1":115}],49:[function(require,module,exports){(function(Buffer){var BN=require("bn.js"),EC=require("elliptic").ec,parseKeys=require("parse-asn1"),curves=require("./curves.json");function checkValue(b,q){if(b.cmpn(0)<=0)throw new Error("invalid sig");if(b.cmp(q)>=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+2<len;)pad.push(255),padNum++;pad.push(0);for(var i=-1;++i<hash.length;)pad.push(hash[i]);pad=new Buffer(pad);var red=BN.mont(pub.modulus);sig=(sig=new BN(sig).toRed(red)).redPow(new BN(pub.publicExponent)),sig=new Buffer(sig.fromRed().toArray());var out=padNum<8?1:0;for(len=Math.min(sig.length,pad.length),sig.length!==pad.length&&(out=1),i=-1;++i<len;)out|=sig[i]^pad[i];return 0===out}}).call(this,require("buffer").Buffer)},{"./curves.json":46,"bn.js":20,buffer:51,elliptic:70,"parse-asn1":115}],50:[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<length;++i)buffer[i]=a[i]^b[i];return buffer}}).call(this,require("buffer").Buffer)},{buffer:51}],51:[function(require,module,exports){(function(Buffer){ | ||
8 | /*! | ||
9 | * The buffer module from node.js, for the browser. | ||
10 | * | ||
11 | * @author Feross Aboukhadijeh <https://feross.org> | ||
12 | * @license MIT | ||
13 | */ | ||
14 | "use strict";var base64=require("base64-js"),ieee754=require("ieee754"),customInspectSymbol="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;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;function createBuffer(length){if(length>K_MAX_LENGTH)throw new RangeError('The value "'+length+'" is invalid for option "size"');var buf=new Uint8Array(length);return Object.setPrototypeOf(buf,Buffer.prototype),buf}function Buffer(arg,encodingOrOffset,length){if("number"==typeof arg){if("string"==typeof encodingOrOffset)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}function from(value,encodingOrOffset,length){if("string"==typeof value)return function(string,encoding){"string"==typeof encoding&&""!==encoding||(encoding="utf8");if(!Buffer.isEncoding(encoding))throw new TypeError("Unknown encoding: "+encoding);var length=0|byteLength(string,encoding),buf=createBuffer(length),actual=buf.write(string,encoding);actual!==length&&(buf=buf.slice(0,actual));return buf}(value,encodingOrOffset);if(ArrayBuffer.isView(value))return fromArrayLike(value);if(null==value)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof value);if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer))return function(array,byteOffset,length){if(byteOffset<0||array.byteLength<byteOffset)throw new RangeError('"offset" is outside of buffer bounds');if(array.byteLength<byteOffset+(length||0))throw new RangeError('"length" is outside of buffer bounds');var buf;buf=void 0===byteOffset&&void 0===length?new Uint8Array(array):void 0===length?new Uint8Array(array,byteOffset):new Uint8Array(array,byteOffset,length);return Object.setPrototypeOf(buf,Buffer.prototype),buf}(value,encodingOrOffset,length);if("number"==typeof value)throw new TypeError('The "value" argument must not be of type number. Received type number');var valueOf=value.valueOf&&value.valueOf();if(null!=valueOf&&valueOf!==value)return Buffer.from(valueOf,encodingOrOffset,length);var b=function(obj){if(Buffer.isBuffer(obj)){var len=0|checked(obj.length),buf=createBuffer(len);return 0===buf.length?buf:(obj.copy(buf,0,0,len),buf)}if(void 0!==obj.length)return"number"!=typeof obj.length||numberIsNaN(obj.length)?createBuffer(0):fromArrayLike(obj);if("Buffer"===obj.type&&Array.isArray(obj.data))return fromArrayLike(obj.data)}(value);if(b)return b;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof value[Symbol.toPrimitive])return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof value)}function assertSize(size){if("number"!=typeof size)throw new TypeError('"size" argument must be of type number');if(size<0)throw new RangeError('The value "'+size+'" is invalid for option "size"')}function allocUnsafe(size){return assertSize(size),createBuffer(size<0?0:0|checked(size))}function fromArrayLike(array){for(var length=array.length<0?0:0|checked(array.length),buf=createBuffer(length),i=0;i<length;i+=1)buf[i]=255&array[i];return buf}function checked(length){if(length>=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return 0|length}function byteLength(string,encoding){if(Buffer.isBuffer(string))return string.length;if(ArrayBuffer.isView(string)||isInstance(string,ArrayBuffer))return string.byteLength;if("string"!=typeof string)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof string);var len=string.length,mustMatch=arguments.length>2&&!0===arguments[2];if(!mustMatch&&0===len)return 0;for(var loweredCase=!1;;)switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*len;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return mustMatch?-1:utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase(),loweredCase=!0}}function slowToString(encoding,start,end){var loweredCase=!1;if((void 0===start||start<0)&&(start=0),start>this.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}}function swap(b,n,m){var i=b[n];b[n]=b[m],b[m]=i}function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){if(0===buffer.length)return-1;if("string"==typeof byteOffset?(encoding=byteOffset,byteOffset=0):byteOffset>2147483647?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 i,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)}if(dir){var foundIndex=-1;for(i=byteOffset;i<arrLength;i++)if(read(arr,i)===read(val,-1===foundIndex?0:i-foundIndex)){if(-1===foundIndex&&(foundIndex=i),i-foundIndex+1===valLength)return foundIndex*indexSize}else-1!==foundIndex&&(i-=i-foundIndex),foundIndex=-1}else for(byteOffset+valLength>arrLength&&(byteOffset=arrLength-valLength),i=byteOffset;i>=0;i--){for(var found=!0,j=0;j<valLength;j++)if(read(arr,i+j)!==read(val,j)){found=!1;break}if(found)return i}return-1}function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;length?(length=Number(length))>remaining&&(length=remaining):length=remaining;var strLen=string.length;length>strLen/2&&(length=strLen/2);for(var i=0;i<length;++i){var parsed=parseInt(string.substr(2*i,2),16);if(numberIsNaN(parsed))return i;buf[offset+i]=parsed}return i}function utf8Write(buf,string,offset,length){return blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length)}function asciiWrite(buf,string,offset,length){return blitBuffer(function(str){for(var byteArray=[],i=0;i<str.length;++i)byteArray.push(255&str.charCodeAt(i));return byteArray}(string),buf,offset,length)}function latin1Write(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){return blitBuffer(base64ToBytes(string),buf,offset,length)}function ucs2Write(buf,string,offset,length){return blitBuffer(function(str,units){for(var c,hi,lo,byteArray=[],i=0;i<str.length&&!((units-=2)<0);++i)c=str.charCodeAt(i),hi=c>>8,lo=c%256,byteArray.push(lo),byteArray.push(hi);return byteArray}(string,buf.length-offset),buf,offset,length)}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;i<end;){var secondByte,thirdByte,fourthByte,tempCodePoint,firstByte=buf[i],codePoint=null,bytesPerSequence=firstByte>239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end)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(;i<len;)res+=String.fromCharCode.apply(String,codePoints.slice(i,i+=MAX_ARGUMENTS_LENGTH));return res}(res)}exports.kMaxLength=K_MAX_LENGTH,Buffer.TYPED_ARRAY_SUPPORT=function(){try{var arr=new Uint8Array(1),proto={foo:function(){return 42}};return Object.setPrototypeOf(proto,Uint8Array.prototype),Object.setPrototypeOf(arr,proto),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."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),Buffer.poolSize=8192,Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)},Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype),Object.setPrototypeOf(Buffer,Uint8Array),Buffer.alloc=function(size,fill,encoding){return function(size,fill,encoding){return assertSize(size),size<=0?createBuffer(size):void 0!==fill?"string"==typeof encoding?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill):createBuffer(size)}(size,fill,encoding)},Buffer.allocUnsafe=function(size){return allocUnsafe(size)},Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)},Buffer.isBuffer=function(b){return null!=b&&!0===b._isBuffer&&b!==Buffer.prototype},Buffer.compare=function(a,b){if(isInstance(a,Uint8Array)&&(a=Buffer.from(a,a.offset,a.byteLength)),isInstance(b,Uint8Array)&&(b=Buffer.from(b,b.offset,b.byteLength)),!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(a===b)return 0;for(var x=a.length,y=b.length,i=0,len=Math.min(x,y);i<len;++i)if(a[i]!==b[i]){x=a[i],y=b[i];break}return x<y?-1:y<x?1:0},Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(list,length){if(!Array.isArray(list))throw new TypeError('"list" argument must be an Array of Buffers');if(0===list.length)return Buffer.alloc(0);var i;if(void 0===length)for(length=0,i=0;i<list.length;++i)length+=list[i].length;var buffer=Buffer.allocUnsafe(length),pos=0;for(i=0;i<list.length;++i){var buf=list[i];if(isInstance(buf,Uint8Array)&&(buf=Buffer.from(buf)),!Buffer.isBuffer(buf))throw new TypeError('"list" argument must be an Array of Buffers');buf.copy(buffer,pos),pos+=buf.length}return buffer},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,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;i<len;i+=2)swap(this,i,i+1);return this},Buffer.prototype.swap32=function(){var len=this.length;if(len%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var i=0;i<len;i+=4)swap(this,i,i+3),swap(this,i+1,i+2);return this},Buffer.prototype.swap64=function(){var len=this.length;if(len%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var i=0;i<len;i+=8)swap(this,i,i+7),swap(this,i+1,i+6),swap(this,i+2,i+5),swap(this,i+3,i+4);return this},Buffer.prototype.toString=function(){var length=this.length;return 0===length?"":0===arguments.length?utf8Slice(this,0,length):slowToString.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,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 str=this.toString("hex",0,max).replace(/(.{2})/g,"$1 ").trim(),this.length>max&&(str+=" ... "),"<Buffer "+str+">"},customInspectSymbol&&(Buffer.prototype[customInspectSymbol]=Buffer.prototype.inspect),Buffer.prototype.compare=function(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)&&(target=Buffer.from(target,target.offset,target.byteLength)),!Buffer.isBuffer(target))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof target);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(this===target)return 0;for(var x=(thisEnd>>>=0)-(thisStart>>>=0),y=(end>>>=0)-(start>>>=0),len=Math.min(x,y),thisCopy=this.slice(thisStart,thisEnd),targetCopy=target.slice(start,end),i=0;i<len;++i)if(thisCopy[i]!==targetCopy[i]){x=thisCopy[i],y=targetCopy[i];break}return x<y?-1:y<x?1:0},Buffer.prototype.includes=function(val,byteOffset,encoding){return-1!==this.indexOf(val,byteOffset,encoding)},Buffer.prototype.indexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!0)},Buffer.prototype.lastIndexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!1)},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)}};var MAX_ARGUMENTS_LENGTH=4096;function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i)ret+=String.fromCharCode(127&buf[i]);return ret}function latin1Slice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i)ret+=String.fromCharCode(buf[i]);return ret}function hexSlice(buf,start,end){var len=buf.length;(!start||start<0)&&(start=0),(!end||end<0||end>len)&&(end=len);for(var out="",i=start;i<end;++i)out+=hexSliceLookupTable[buf[i]];return out}function utf16leSlice(buf,start,end){for(var bytes=buf.slice(start,end),res="",i=0;i<bytes.length;i+=2)res+=String.fromCharCode(bytes[i]+256*bytes[i+1]);return res}function checkOffset(offset,ext,length){if(offset%1!=0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}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||value<min)throw new RangeError('"value" argument is out of bounds');if(offset+ext>buf.length)throw new RangeError("Index out of range")}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}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.slice=function(start,end){var len=this.length;(start=~~start)<0?(start+=len)<0&&(start=0):start>len&&(start=len),(end=void 0===end?len:~~end)<0?(end+=len)<0&&(end=0):end>len&&(end=len),end<start&&(end=start);var newBuf=this.subarray(start,end);return Object.setPrototypeOf(newBuf,Buffer.prototype),newBuf},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<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return val},Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset>>>=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<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return val>=(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)},Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){(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<byteLength&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){(value=+value,offset>>>=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<byteLength&&(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.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},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)},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(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(start||(start=0),end||0===end||(end=this.length),targetStart>=target.length&&(targetStart=target.length),targetStart||(targetStart=0),end>0&&end<start&&(end=start),end===start)return 0;if(0===target.length||0===this.length)return 0;if(targetStart<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");end>this.length&&(end=this.length),target.length-targetStart<end-start&&(end=target.length-targetStart+start);var len=end-start;if(this===target&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(targetStart,start,end);else if(this===target&&start<targetStart&&targetStart<end)for(var i=len-1;i>=0;--i)target[i+targetStart]=this[i+start];else Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart);return len},Buffer.prototype.fill=function(val,start,end,encoding){if("string"==typeof val){if("string"==typeof start?(encoding=start,start=0,end=this.length):"string"==typeof end&&(encoding=end,end=this.length),void 0!==encoding&&"string"!=typeof encoding)throw new TypeError("encoding must be a string");if("string"==typeof encoding&&!Buffer.isEncoding(encoding))throw new TypeError("Unknown encoding: "+encoding);if(1===val.length){var code=val.charCodeAt(0);("utf8"===encoding&&code<128||"latin1"===encoding)&&(val=code)}}else"number"==typeof val?val&=255:"boolean"==typeof val&&(val=Number(val));if(start<0||this.length<start||this.length<end)throw new RangeError("Out of range index");if(end<=start)return this;var i;if(start>>>=0,end=void 0===end?this.length:end>>>0,val||(val=0),"number"==typeof val)for(i=start;i<end;++i)this[i]=val;else{var bytes=Buffer.isBuffer(val)?val:Buffer.from(val,encoding),len=bytes.length;if(0===len)throw new TypeError('The value "'+val+'" is invalid for argument "value"');for(i=0;i<end-start;++i)this[i+start]=bytes[i%len]}return this};var INVALID_BASE64_RE=/[^+/0-9A-Za-z-_]/g;function utf8ToBytes(string,units){var codePoint;units=units||1/0;for(var length=string.length,leadSurrogate=null,bytes=[],i=0;i<length;++i){if((codePoint=string.charCodeAt(i))>55295&&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=str.split("=")[0]).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<length&&!(i+offset>=dst.length||i>=src.length);++i)dst[i+offset]=src[i];return i}function isInstance(obj,type){return obj instanceof type||null!=obj&&null!=obj.constructor&&null!=obj.constructor.name&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!=obj}var hexSliceLookupTable=function(){for(var table=new Array(256),i=0;i<16;++i)for(var i16=16*i,j=0;j<16;++j)table[i16+j]="0123456789abcdef"[i]+"0123456789abcdef"[j];return table}()}).call(this,require("buffer").Buffer)},{"base64-js":19,buffer:51,ieee754:102}],52:[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:103,"safe-buffer":151,stream:160,string_decoder:161}],53:[function(require,module,exports){(function(Buffer){function objectToString(o){return Object.prototype.toString.call(o)}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}).call(this,{isBuffer:require("../../is-buffer/index.js")})},{"../../is-buffer/index.js":104}],54:[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}};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}function formatReturnValue(bn,enc,len){Array.isArray(bn)||(bn=bn.toArray());var buf=new Buffer(bn);if(len&&buf.length<len){var zeros=new Buffer(len-buf.length);zeros.fill(0),buf=Buffer.concat([zeros,buf])}return enc?buf.toString(enc):buf}aliases.p224=aliases.secp224r1,aliases.p256=aliases.secp256r1=aliases.prime256v1,aliases.p192=aliases.secp192r1=aliases.prime192v1,aliases.p384=aliases.secp384r1,aliases.p521=aliases.secp521r1,ECDH.prototype.generateKeys=function(enc,format){return this.keys=this.curve.genKeyPair(),this.getPublicKey(enc,format)},ECDH.prototype.computeSecret=function(other,inenc,enc){return inenc=inenc||"utf8",Buffer.isBuffer(other)||(other=new Buffer(other,inenc)),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=this.curve.genKeyPair(),this.keys._importPrivate(_priv),this}}).call(this,require("buffer").Buffer)},{"bn.js":20,buffer:51,elliptic:70}],55:[function(require,module,exports){"use strict";var inherits=require("inherits"),MD5=require("md5.js"),RIPEMD160=require("ripemd160"),sha=require("sha.js"),Base=require("cipher-base");function Hash(hash){Base.call(this,"digest"),this._hash=hash}inherits(Hash,Base),Hash.prototype._update=function(data){this._hash.update(data)},Hash.prototype._final=function(){return this._hash.digest()},module.exports=function(alg){return"md5"===(alg=alg.toLowerCase())?new MD5:"rmd160"===alg||"ripemd160"===alg?new RIPEMD160:new Hash(sha(alg))}},{"cipher-base":52,inherits:103,"md5.js":106,ripemd160:150,"sha.js":153}],56:[function(require,module,exports){var MD5=require("md5.js");module.exports=function(buffer){return(new MD5).update(buffer).digest()}},{"md5.js":106}],57:[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;(this._alg=alg,this._key=key,key.length>blocksize)?key=("rmd160"===alg?new RIPEMD160:sha(alg)).update(key).digest():key.length<blocksize&&(key=Buffer.concat([key,ZEROS],blocksize));for(var ipad=this._ipad=Buffer.allocUnsafe(blocksize),opad=this._opad=Buffer.allocUnsafe(blocksize),i=0;i<blocksize;i++)ipad[i]=54^key[i],opad[i]=92^key[i];this._hash="rmd160"===alg?new RIPEMD160:sha(alg),this._hash.update(ipad)}inherits(Hmac,Base),Hmac.prototype._update=function(data){this._hash.update(data)},Hmac.prototype._final=function(){var h=this._hash.digest();return("rmd160"===this._alg?new RIPEMD160:sha(this._alg)).update(this._opad).update(h).digest()},module.exports=function(alg,key){return"rmd160"===(alg=alg.toLowerCase())||"ripemd160"===alg?new Hmac("rmd160",key):"md5"===alg?new Legacy(md5,key):new Hmac(alg,key)}},{"./legacy":58,"cipher-base":52,"create-hash/md5":56,inherits:103,ripemd160:150,"safe-buffer":151,"sha.js":153}],58:[function(require,module,exports){"use strict";var inherits=require("inherits"),Buffer=require("safe-buffer").Buffer,Base=require("cipher-base"),ZEROS=Buffer.alloc(128),blocksize=64;function Hmac(alg,key){Base.call(this,"digest"),"string"==typeof key&&(key=Buffer.from(key)),this._alg=alg,this._key=key,key.length>blocksize?key=alg(key):key.length<blocksize&&(key=Buffer.concat([key,ZEROS],blocksize));for(var ipad=this._ipad=Buffer.allocUnsafe(blocksize),opad=this._opad=Buffer.allocUnsafe(blocksize),i=0;i<blocksize;i++)ipad[i]=54^key[i],opad[i]=92^key[i];this._hash=[ipad]}inherits(Hmac,Base),Hmac.prototype._update=function(data){this._hash.push(data)},Hmac.prototype._final=function(){var h=this._alg(Buffer.concat(this._hash));return this._alg(Buffer.concat([this._opad,h]))},module.exports=Hmac},{"cipher-base":52,inherits:103,"safe-buffer":151}],59:[function(require,module,exports){"use strict";exports.randomBytes=exports.rng=exports.pseudoRandomBytes=exports.prng=require("randombytes"),exports.createHash=exports.Hash=require("create-hash"),exports.createHmac=exports.Hmac=require("create-hmac");var algos=require("browserify-sign/algos"),algoKeys=Object.keys(algos),hashes=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(algoKeys);exports.getHashes=function(){return hashes};var p=require("pbkdf2");exports.pbkdf2=p.pbkdf2,exports.pbkdf2Sync=p.pbkdf2Sync;var aes=require("browserify-cipher");exports.Cipher=aes.Cipher,exports.createCipher=aes.createCipher,exports.Cipheriv=aes.Cipheriv,exports.createCipheriv=aes.createCipheriv,exports.Decipher=aes.Decipher,exports.createDecipher=aes.createDecipher,exports.Decipheriv=aes.Decipheriv,exports.createDecipheriv=aes.createDecipheriv,exports.getCiphers=aes.getCiphers,exports.listCiphers=aes.listCiphers;var dh=require("diffie-hellman");exports.DiffieHellmanGroup=dh.DiffieHellmanGroup,exports.createDiffieHellmanGroup=dh.createDiffieHellmanGroup,exports.getDiffieHellman=dh.getDiffieHellman,exports.createDiffieHellman=dh.createDiffieHellman,exports.DiffieHellman=dh.DiffieHellman;var sign=require("browserify-sign");exports.createSign=sign.createSign,exports.Sign=sign.Sign,exports.createVerify=sign.createVerify,exports.Verify=sign.Verify,exports.createECDH=require("create-ecdh");var publicEncrypt=require("public-encrypt");exports.publicEncrypt=publicEncrypt.publicEncrypt,exports.privateEncrypt=publicEncrypt.privateEncrypt,exports.publicDecrypt=publicEncrypt.publicDecrypt,exports.privateDecrypt=publicEncrypt.privateDecrypt;var rf=require("randomfill");exports.randomFill=rf.randomFill,exports.randomFillSync=rf.randomFillSync,exports.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},exports.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{"browserify-cipher":40,"browserify-sign":47,"browserify-sign/algos":44,"create-ecdh":54,"create-hash":55,"create-hmac":57,"diffie-hellman":66,pbkdf2:116,"public-encrypt":123,randombytes:133,randomfill:134}],60:[function(require,module,exports){"use strict";exports.utils=require("./des/utils"),exports.Cipher=require("./des/cipher"),exports.DES=require("./des/des"),exports.CBC=require("./des/cbc"),exports.EDE=require("./des/ede")},{"./des/cbc":61,"./des/cipher":62,"./des/des":63,"./des/ede":64,"./des/utils":65}],61:[function(require,module,exports){"use strict";var assert=require("minimalistic-assert"),inherits=require("inherits"),proto={};function CBCState(iv){assert.equal(iv.length,8,"Invalid IV length"),this.iv=new Array(8);for(var i=0;i<this.iv.length;i++)this.iv[i]=iv[i]}exports.instantiate=function(Base){function CBC(options){Base.call(this,options),this._cbcInit()}inherits(CBC,Base);for(var keys=Object.keys(proto),i=0;i<keys.length;i++){var key=keys[i];CBC.prototype[key]=proto[key]}return CBC.create=function(options){return new CBC(options)},CBC},proto._cbcInit=function(){var state=new CBCState(this.options.iv);this._cbcState=state},proto._update=function(inp,inOff,out,outOff){var state=this._cbcState,superProto=this.constructor.super_.prototype,iv=state.iv;if("encrypt"===this.type){for(var i=0;i<this.blockSize;i++)iv[i]^=inp[inOff+i];superProto._update.call(this,iv,0,out,outOff);for(i=0;i<this.blockSize;i++)iv[i]=out[outOff+i]}else{superProto._update.call(this,inp,inOff,out,outOff);for(i=0;i<this.blockSize;i++)out[outOff+i]^=iv[i];for(i=0;i<this.blockSize;i++)iv[i]=inp[inOff+i]}}},{inherits:103,"minimalistic-assert":108}],62:[function(require,module,exports){"use strict";var assert=require("minimalistic-assert");function Cipher(options){this.options=options,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}module.exports=Cipher,Cipher.prototype._init=function(){},Cipher.prototype.update=function(data){return 0===data.length?[]:"decrypt"===this.type?this._updateDecrypt(data):this._updateEncrypt(data)},Cipher.prototype._buffer=function(data,off){for(var min=Math.min(this.buffer.length-this.bufferOff,data.length-off),i=0;i<min;i++)this.buffer[this.bufferOff+i]=data[off+i];return this.bufferOff+=min,min},Cipher.prototype._flushBuffer=function(out,off){return this._update(this.buffer,0,out,off),this.bufferOff=0,this.blockSize},Cipher.prototype._updateEncrypt=function(data){var inputOff=0,outputOff=0,count=(this.bufferOff+data.length)/this.blockSize|0,out=new Array(count*this.blockSize);0!==this.bufferOff&&(inputOff+=this._buffer(data,inputOff),this.bufferOff===this.buffer.length&&(outputOff+=this._flushBuffer(out,outputOff)));for(var max=data.length-(data.length-inputOff)%this.blockSize;inputOff<max;inputOff+=this.blockSize)this._update(data,inputOff,out,outputOff),outputOff+=this.blockSize;for(;inputOff<data.length;inputOff++,this.bufferOff++)this.buffer[this.bufferOff]=data[inputOff];return out},Cipher.prototype._updateDecrypt=function(data){for(var inputOff=0,outputOff=0,count=Math.ceil((this.bufferOff+data.length)/this.blockSize)-1,out=new Array(count*this.blockSize);count>0;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,last;return buffer&&(first=this.update(buffer)),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<buffer.length;)buffer[off++]=0;return!0},Cipher.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var out=new Array(this.blockSize);return this._update(this.buffer,0,out,0),out},Cipher.prototype._unpad=function(buffer){return buffer},Cipher.prototype._finalDecrypt=function(){assert.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var out=new Array(this.blockSize);return this._flushBuffer(out,0),this._unpad(out)}},{"minimalistic-assert":108}],63:[function(require,module,exports){"use strict";var assert=require("minimalistic-assert"),inherits=require("inherits"),des=require("../des"),utils=des.utils,Cipher=des.Cipher;function DESState(){this.tmp=new Array(2),this.keys=null}function DES(options){Cipher.call(this,options);var state=new DESState;this._desState=state,this.deriveKeys(state,options.key)}inherits(DES,Cipher),module.exports=DES,DES.create=function(options){return new DES(options)};var shiftTable=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];DES.prototype.deriveKeys=function(state,key){state.keys=new Array(32),assert.equal(key.length,this.blockSize,"Invalid key length");var kL=utils.readUInt32BE(key,0),kR=utils.readUInt32BE(key,4);utils.pc1(kL,kR,state.tmp,0),kL=state.tmp[0],kR=state.tmp[1];for(var i=0;i<state.keys.length;i+=2){var shift=shiftTable[i>>>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<buffer.length;i++)buffer[i]=value;return!0},DES.prototype._unpad=function(buffer){for(var pad=buffer[buffer.length-1],i=buffer.length-pad;i<buffer.length;i++)assert.equal(buffer[i],pad);return buffer.slice(0,buffer.length-pad)},DES.prototype._encrypt=function(state,lStart,rStart,out,off){for(var l=lStart,r=rStart,i=0;i<state.keys.length;i+=2){var keyL=state.keys[i],keyR=state.keys[i+1];utils.expand(r,state.tmp,0),keyL^=state.tmp[0],keyR^=state.tmp[1];var s=utils.substitute(keyL,keyR),t=r;r=(l^utils.permute(s))>>>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":60,inherits:103,"minimalistic-assert":108}],64:[function(require,module,exports){"use strict";var assert=require("minimalistic-assert"),inherits=require("inherits"),des=require("../des"),Cipher=des.Cipher,DES=des.DES;function EDEState(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})]}function EDE(options){Cipher.call(this,options);var state=new EDEState(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":60,inherits:103,"minimalistic-assert":108}],65:[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<<shift&268435455|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<len;i++)outL<<=1,outL|=inL>>>pc2table[i]&1;for(i=len;i<pc2table.length;i++)outR<<=1,outR|=inR>>>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.length;i++)out<<=1,out|=num>>>permuteTable[i]&1;return out>>>0},exports.padSplit=function(num,size,group){for(var str=num.toString(2);str.length<size;)str="0"+str;for(var out=[],i=0;i<size;i+=group)out.push(str.slice(i,i+group));return out.join(" ")}},{}],66:[function(require,module,exports){(function(Buffer){var generatePrime=require("./lib/generatePrime"),primes=require("./lib/primes.json"),DH=require("./lib/dh");var ENCODINGS={binary:!0,hex:!0,base64:!0};exports.DiffieHellmanGroup=exports.createDiffieHellmanGroup=exports.getDiffieHellman=function(mod){var prime=new Buffer(primes[mod].prime,"hex"),gen=new Buffer(primes[mod].gen,"hex");return new DH(prime,gen)},exports.createDiffieHellman=exports.DiffieHellman=function createDiffieHellman(prime,enc,generator,genc){return Buffer.isBuffer(enc)||void 0===ENCODINGS[enc]?createDiffieHellman(prime,"binary",enc,generator):(enc=enc||"binary",genc=genc||"binary",generator=generator||new Buffer([2]),Buffer.isBuffer(generator)||(generator=new Buffer(generator,genc)),"number"==typeof prime?new DH(generatePrime(prime,generator),generator,!0):(Buffer.isBuffer(prime)||(prime=new Buffer(prime,enc)),new DH(prime,generator,!0)))}}).call(this,require("buffer").Buffer)},{"./lib/dh":67,"./lib/generatePrime":68,"./lib/primes.json":69,buffer:51}],67:[function(require,module,exports){(function(Buffer){var BN=require("bn.js"),millerRabin=new(require("miller-rabin")),TWENTYFOUR=new BN(24),ELEVEN=new BN(11),TEN=new BN(10),THREE=new BN(3),SEVEN=new BN(7),primes=require("./generatePrime"),randomBytes=require("randombytes");function setPublicKey(pub,enc){return enc=enc||"utf8",Buffer.isBuffer(pub)||(pub=new Buffer(pub,enc)),this._pub=new BN(pub),this}function setPrivateKey(priv,enc){return enc=enc||"utf8",Buffer.isBuffer(priv)||(priv=new Buffer(priv,enc)),this._priv=new BN(priv),this}module.exports=DH;var primeCache={};function DH(prime,generator,malleable){this.setGenerator(generator),this.__prime=new BN(prime),this._prime=BN.mont(this.__prime),this._primeLen=prime.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,malleable?(this.setPublicKey=setPublicKey,this.setPrivateKey=setPrivateKey):this._primeCode=8}function formatReturnValue(bn,enc){var buf=new Buffer(bn.toArray());return enc?buf.toString(enc):buf}Object.defineProperty(DH.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(prime,generator){var gen=generator.toString("hex"),hex=[gen,prime.toString(16)].join("_");if(hex in primeCache)return primeCache[hex];var rem,error=0;if(prime.isEven()||!primes.simpleSieve||!primes.fermatTest(prime)||!millerRabin.test(prime))return error+=1,error+="02"===gen||"05"===gen?8:4,primeCache[hex]=error,error;switch(millerRabin.test(prime.shrn(1))||(error+=2),gen){case"02":prime.mod(TWENTYFOUR).cmp(ELEVEN)&&(error+=8);break;case"05":(rem=prime.mod(TEN)).cmp(THREE)&&rem.cmp(SEVEN)&&(error+=8);break;default:error+=4}return primeCache[hex]=error,error}(this.__prime,this.__gen)),this._primeCode}}),DH.prototype.generateKeys=function(){return this._priv||(this._priv=new BN(randomBytes(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},DH.prototype.computeSecret=function(other){var secret=(other=(other=new BN(other)).toRed(this._prime)).redPow(this._priv).fromRed(),out=new Buffer(secret.toArray()),prime=this.getPrime();if(out.length<prime.length){var front=new Buffer(prime.length-out.length);front.fill(0),out=Buffer.concat([front,out])}return out},DH.prototype.getPublicKey=function(enc){return formatReturnValue(this._pub,enc)},DH.prototype.getPrivateKey=function(enc){return formatReturnValue(this._priv,enc)},DH.prototype.getPrime=function(enc){return formatReturnValue(this.__prime,enc)},DH.prototype.getGenerator=function(enc){return formatReturnValue(this._gen,enc)},DH.prototype.setGenerator=function(gen,enc){return enc=enc||"utf8",Buffer.isBuffer(gen)||(gen=new Buffer(gen,enc)),this.__gen=gen,this._gen=new BN(gen),this}}).call(this,require("buffer").Buffer)},{"./generatePrime":68,"bn.js":20,buffer:51,"miller-rabin":107,randombytes:133}],68:[function(require,module,exports){var randomBytes=require("randombytes");module.exports=findPrime,findPrime.simpleSieve=simpleSieve,findPrime.fermatTest=fermatTest;var BN=require("bn.js"),TWENTYFOUR=new BN(24),millerRabin=new(require("miller-rabin")),ONE=new BN(1),TWO=new BN(2),FIVE=new BN(5),TEN=(new BN(16),new BN(8),new BN(10)),THREE=new BN(3),ELEVEN=(new BN(7),new BN(11)),FOUR=new BN(4),primes=(new BN(12),null);function _getPrimes(){if(null!==primes)return primes;var res=[];res[0]=2;for(var i=1,k=3;k<1048576;k+=2){for(var sqrt=Math.ceil(Math.sqrt(k)),j=0;j<i&&res[j]<=sqrt&&k%res[j]!=0;j++);i!==j&&res[j]<=sqrt||(res[i++]=k)}return primes=res,res}function simpleSieve(p){for(var primes=_getPrimes(),i=0;i<primes.length;i++)if(0===p.modn(primes[i]))return 0===p.cmpn(primes[i]);return!0}function fermatTest(p){var red=BN.mont(p);return 0===TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1)}function findPrime(bits,gen){if(bits<16)return new BN(2===gen||5===gen?[140,123]:[140,39]);var num,n2;for(gen=new BN(gen);;){for(num=new BN(randomBytes(Math.ceil(bits/8)));num.bitLength()>bits;)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":20,"miller-rabin":107,randombytes:133}],69:[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"}}},{}],70:[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.curve=require("./elliptic/curve"),elliptic.curves=require("./elliptic/curves"),elliptic.ec=require("./elliptic/ec"),elliptic.eddsa=require("./elliptic/eddsa")},{"../package.json":85,"./elliptic/curve":73,"./elliptic/curves":76,"./elliptic/ec":77,"./elliptic/eddsa":80,"./elliptic/utils":84,brorand:21}],71:[function(require,module,exports){"use strict";var BN=require("bn.js"),utils=require("../utils"),getNAF=utils.getNAF,getJSF=utils.getJSF,assert=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);var adjustCount=this.n&&this.p.div(this.n);!adjustCount||adjustCount.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(curve,type){this.curve=curve,this.type=type,this.precomputed=null}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<<doubles.step+1)-(doubles.step%2==0?2:1);I/=3;for(var repr=[],j=0;j<naf.length;j+=doubles.step){var nafW=0;for(k=j+doubles.step-1;k>=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<repr.length;j++){(nafW=repr[j])===i?b=b.mixedAdd(doubles.points[j]):nafW===-i&&(b=b.mixedAdd(doubles.points[j].neg()))}a=a.add(b)}return a.toP()},BaseCurve.prototype._wnafMul=function(p,k){var w=4,nafPoints=p._getNAFPoints(w);w=nafPoints.wnd;for(var wnd=nafPoints.points,naf=getNAF(k,w),acc=this.jpoint(null,null,null),i=naf.length-1;i>=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<len;i++){var nafPoints=(p=points[i])._getNAFPoints(defW);wndWidth[i]=nafPoints.wnd,wnd[i]=nafPoints.points}for(i=len-1;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<max;j++){var ja=0|jsf[0][j],jb=0|jsf[1][j];naf[a][j]=index[3*(ja+1)+(jb+1)],naf[b][j]=0,wnd[a]=comb}}else naf[a]=getNAF(coeffs[a],wndWidth[a]),naf[b]=getNAF(coeffs[b],wndWidth[b]),max=Math.max(naf[a].length,max),max=Math.max(naf[b].length,max)}var acc=this.jpoint(null,null,null),tmp=this._wnafT4;for(i=max;i>=0;i--){for(var k=0;i>=0;){var zero=!0;for(j=0;j<len;j++)tmp[j]=0|naf[j][i],0!==tmp[j]&&(zero=!1);if(!zero)break;k++,i--}if(i>=0&&k++,acc=acc.dblp(k),i<0)break;for(j=0;j<len;j++){var p,z=tmp[j];0!==z&&(z>0?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<len;i++)wnd[i]=null;return jacobianResult?acc:acc.toP()},BaseCurve.BasePoint=BasePoint,BasePoint.prototype.eq=function(){throw new Error("Not implemented")},BasePoint.prototype.validate=function(){return this.curve.validate(this)},BaseCurve.prototype.decodePoint=function(bytes,enc){bytes=utils.toArray(bytes,enc);var len=this.p.byteLength();if((4===bytes[0]||6===bytes[0]||7===bytes[0])&&bytes.length-1==2*len)return 6===bytes[0]?assert(bytes[bytes.length-1]%2==0):7===bytes[0]&&assert(bytes[bytes.length-1]%2==1),this.point(bytes.slice(1,1+len),bytes.slice(1+len,1+2*len));if((2===bytes[0]||3===bytes[0])&&bytes.length-1===len)return this.pointFromX(bytes.slice(1,1+len),3===bytes[0]);throw new Error("Unknown point format")},BasePoint.prototype.encodeCompressed=function(enc){return this.encode(enc,!0)},BasePoint.prototype._encode=function(compact){var len=this.curve.p.byteLength(),x=this.getX().toArray("be",len);return compact?[this.getY().isEven()?2:3].concat(x):[4].concat(x,this.getY().toArray("be",len))},BasePoint.prototype.encode=function(enc,compact){return utils.encode(this._encode(compact),enc)},BasePoint.prototype.precompute=function(power){if(this.precomputed)return this;var precomputed={doubles:null,naf:null,beta:null};return precomputed.naf=this._getNAFPoints(8),precomputed.doubles=this._getDoubles(4,power),precomputed.beta=this._getBeta(),this.precomputed=precomputed,this},BasePoint.prototype._hasDoubles=function(k){if(!this.precomputed)return!1;var doubles=this.precomputed.doubles;return!!doubles&&doubles.points.length>=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<power;i+=step){for(var j=0;j<step;j++)acc=acc.dbl();doubles.push(acc)}return{step:step,points:doubles}},BasePoint.prototype._getNAFPoints=function(wnd){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var res=[this],max=(1<<wnd)-1,dbl=1===max?null:this.dbl(),i=1;i<max;i++)res[i]=res[i-1].add(dbl);return{wnd:wnd,points:res}},BasePoint.prototype._getBeta=function(){return null},BasePoint.prototype.dblp=function(k){for(var r=this,i=0;i<k;i++)r=r.dbl();return r}},{"../utils":84,"bn.js":20}],72:[function(require,module,exports){"use strict";var utils=require("../utils"),BN=require("bn.js"),inherits=require("inherits"),Base=require("./base"),assert=utils.assert;function EdwardsCurve(conf){this.twisted=1!=(0|conf.a),this.mOneA=this.twisted&&-1==(0|conf.a),this.extended=this.mOneA,Base.call(this,"edwards",conf),this.a=new BN(conf.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new BN(conf.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new BN(conf.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),assert(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|conf.c)}function Point(curve,x,y,z,t){Base.BasePoint.call(this,curve,"projective"),null===x&&null===y&&null===z?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=z?new BN(z,16):this.curve.one,this.t=t&&new BN(t,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.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}inherits(EdwardsCurve,Base),module.exports=EdwardsCurve,EdwardsCurve.prototype._mulA=function(num){return this.mOneA?num.redNeg():this.a.redMul(num)},EdwardsCurve.prototype._mulC=function(num){return this.oneC?num:this.c.redMul(num)},EdwardsCurve.prototype.jpoint=function(x,y,z,t){return this.point(x,y,z,t)},EdwardsCurve.prototype.pointFromX=function(x,odd){(x=new BN(x,16)).red||(x=x.toRed(this.red));var x2=x.redSqr(),rhs=this.c2.redSub(this.a.redMul(x2)),lhs=this.one.redSub(this.c2.redMul(this.d).redMul(x2)),y2=rhs.redMul(lhs.redInvm()),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)},EdwardsCurve.prototype.pointFromY=function(y,odd){(y=new BN(y,16)).red||(y=y.toRed(this.red));var y2=y.redSqr(),lhs=y2.redSub(this.c2),rhs=y2.redMul(this.d).redMul(this.c2).redSub(this.a),x2=lhs.redMul(rhs.redInvm());if(0===x2.cmp(this.zero)){if(odd)throw new Error("invalid point");return this.point(this.zero,y)}var x=x2.redSqrt();if(0!==x.redSqr().redSub(x2).cmp(this.zero))throw new Error("invalid point");return x.fromRed().isOdd()!==odd&&(x=x.redNeg()),this.point(x,y)},EdwardsCurve.prototype.validate=function(point){if(point.isInfinity())return!0;point.normalize();var x2=point.x.redSqr(),y2=point.y.redSqr(),lhs=x2.redMul(this.a).redAdd(y2),rhs=this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));return 0===lhs.cmp(rhs)},inherits(Point,Base.BasePoint),EdwardsCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},EdwardsCurve.prototype.point=function(x,y,z,t){return new Point(this,x,y,z,t)},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1],obj[2])},Point.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},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.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}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../utils":84,"./base":71,"bn.js":20,inherits:103}],73:[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":71,"./edwards":72,"./mont":74,"./short":75}],74:[function(require,module,exports){"use strict";var BN=require("bn.js"),inherits=require("inherits"),Base=require("./base"),utils=require("../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))}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(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)},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()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},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()}},{"../utils":84,"./base":71,"bn.js":20,inherits:103}],75:[function(require,module,exports){"use strict";var utils=require("../utils"),BN=require("bn.js"),inherits=require("inherits"),Base=require("./base"),assert=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)}function Point(curve,x,y,isRed){Base.BasePoint.call(this,curve,"affine"),null===x&&null===y?(this.x=null,this.y=null,this.inf=!0):(this.x=new BN(x,16),this.y=new BN(y,16),isRed&&(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 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(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<points.length;i++){var split=this._endoSplit(coeffs[i]),p=points[i],beta=p._getBeta();split.k1.negative&&(split.k1.ineg(),p=p.neg(!0)),split.k2.negative&&(split.k2.ineg(),beta=beta.neg(!0)),npoints[2*i]=p,npoints[2*i+1]=beta,ncoeffs[2*i]=split.k1,ncoeffs[2*i+1]=split.k2}for(var res=this._wnafMulAdd(1,npoints,ncoeffs,2*i,jacobianResult),j=0;j<2*i;j++)npoints[j]=null,ncoeffs[j]=null;return res},inherits(Point,Base.BasePoint),ShortCurve.prototype.point=function(x,y,isRed){return new Point(this,x,y,isRed)},ShortCurve.prototype.pointFromJSON=function(obj,red){return Point.fromJSON(this,obj,red)},Point.prototype._getBeta=function(){if(this.curve.endo){var pre=this.precomputed;if(pre&&pre.beta)return pre.beta;var beta=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(pre){var curve=this.curve,endoMul=function(p){return curve.point(p.x.redMul(curve.endo.beta),p.y)};pre.beta=beta,beta.precomputed={beta:null,naf:pre.naf&&{wnd:pre.naf.wnd,points:pre.naf.points.map(endoMul)},doubles:pre.doubles&&{step:pre.doubles.step,points:pre.doubles.points.map(endoMul)}}}return beta}},Point.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Point.fromJSON=function(curve,obj,red){"string"==typeof obj&&(obj=JSON.parse(obj));var res=curve.point(obj[0],obj[1],red);if(!obj[2])return res;function obj2point(obj){return curve.point(obj[0],obj[1],red)}var pre=obj[2];return res.precomputed={beta:null,doubles:pre.doubles&&{step:pre.doubles.step,points:[res].concat(pre.doubles.points.map(obj2point))},naf:pre.naf&&{wnd:pre.naf.wnd,points:[res].concat(pre.naf.points.map(obj2point))}},res},Point.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},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.isInfinity()?this: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(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,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<pow;i++)r=r.dbl();return r}var a=this.curve.a,tinv=this.curve.tinv,jx=this.x,jy=this.y,jz=this.z,jz4=jz.redSqr().redSqr(),jyd=jy.redAdd(jy);for(i=0;i<pow;i++){var jx2=jx.redSqr(),jyd2=jyd.redSqr(),jyd4=jyd2.redSqr(),c=jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)),t1=jx.redMul(jyd2),nx=c.redSqr().redISub(t1.redAdd(t1)),t2=t1.redISub(nx),dny=c.redMul(t2);dny=dny.redIAdd(dny).redISub(jyd4);var nz=jyd.redMul(jz);i+1<pow&&(jz4=jz4.redMul(jyd4)),jx=nx,jz=nz,jyd=dny}return this.curve.jpoint(jx,jyd.redMul(tinv),jz)},JPoint.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},JPoint.prototype._zeroDbl=function(){var nx,ny,nz;if(this.zOne){var xx=this.x.redSqr(),yy=this.y.redSqr(),yyyy=yy.redSqr(),s=this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);s=s.redIAdd(s);var m=xx.redAdd(xx).redIAdd(xx),t=m.redSqr().redISub(s).redISub(s),yyyy8=yyyy.redIAdd(yyyy);yyyy8=(yyyy8=yyyy8.redIAdd(yyyy8)).redIAdd(yyyy8),nx=t,ny=m.redMul(s.redISub(t)).redISub(yyyy8),nz=this.y.redAdd(this.y)}else{var a=this.x.redSqr(),b=this.y.redSqr(),c=b.redSqr(),d=this.x.redAdd(b).redSqr().redISub(a).redISub(c);d=d.redIAdd(d);var e=a.redAdd(a).redIAdd(a),f=e.redSqr(),c8=c.redIAdd(c);c8=(c8=c8.redIAdd(c8)).redIAdd(c8),nx=f.redISub(d).redISub(d),ny=e.redMul(d.redISub(nx)).redISub(c8),nz=(nz=this.y.redMul(this.z)).redIAdd(nz)}return this.curve.jpoint(nx,ny,nz)},JPoint.prototype._threeDbl=function(){var nx,ny,nz;if(this.zOne){var xx=this.x.redSqr(),yy=this.y.redSqr(),yyyy=yy.redSqr(),s=this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);s=s.redIAdd(s);var m=xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a),t=m.redSqr().redISub(s).redISub(s);nx=t;var yyyy8=yyyy.redIAdd(yyyy);yyyy8=(yyyy8=yyyy8.redIAdd(yyyy8)).redIAdd(yyyy8),ny=m.redMul(s.redISub(t)).redISub(yyyy8),nz=this.y.redAdd(this.y)}else{var delta=this.z.redSqr(),gamma=this.y.redSqr(),beta=this.x.redMul(gamma),alpha=this.x.redSub(delta).redMul(this.x.redAdd(delta));alpha=alpha.redAdd(alpha).redIAdd(alpha);var beta4=beta.redIAdd(beta),beta8=(beta4=beta4.redIAdd(beta4)).redAdd(beta4);nx=alpha.redSqr().redISub(beta8),nz=this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);var ggamma8=gamma.redSqr();ggamma8=(ggamma8=(ggamma8=ggamma8.redIAdd(ggamma8)).redIAdd(ggamma8)).redIAdd(ggamma8),ny=alpha.redMul(beta4.redISub(nx)).redISub(ggamma8)}return this.curve.jpoint(nx,ny,nz)},JPoint.prototype._dbl=function(){var a=this.curve.a,jx=this.x,jy=this.y,jz=this.z,jz4=jz.redSqr().redSqr(),jx2=jx.redSqr(),jy2=jy.redSqr(),c=jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)),jxd4=jx.redAdd(jx),t1=(jxd4=jxd4.redIAdd(jxd4)).redMul(jy2),nx=c.redSqr().redISub(t1.redAdd(t1)),t2=t1.redISub(nx),jyd8=jy2.redSqr();jyd8=(jyd8=(jyd8=jyd8.redIAdd(jyd8)).redIAdd(jyd8)).redIAdd(jyd8);var ny=c.redMul(t2).redISub(jyd8),nz=jy.redAdd(jy).redMul(jz);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var xx=this.x.redSqr(),yy=this.y.redSqr(),zz=this.z.redSqr(),yyyy=yy.redSqr(),m=xx.redAdd(xx).redIAdd(xx),mm=m.redSqr(),e=this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy),ee=(e=(e=(e=e.redIAdd(e)).redAdd(e).redIAdd(e)).redISub(mm)).redSqr(),t=yyyy.redIAdd(yyyy);t=(t=(t=t.redIAdd(t)).redIAdd(t)).redIAdd(t);var u=m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t),yyu4=yy.redMul(u);yyu4=(yyu4=yyu4.redIAdd(yyu4)).redIAdd(yyu4);var nx=this.x.redMul(ee).redISub(yyu4);nx=(nx=nx.redIAdd(nx)).redIAdd(nx);var ny=this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));ny=(ny=(ny=ny.redIAdd(ny)).redIAdd(ny)).redIAdd(ny);var nz=this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.mul=function(k,kbase){return k=new BN(k,kbase),this.curve._wnafMul(this,k)},JPoint.prototype.eq=function(p){if("affine"===p.type)return this.eq(p.toJ());if(this===p)return!0;var z2=this.z.redSqr(),pz2=p.z.redSqr();if(0!==this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0))return!1;var z3=z2.redMul(this.z),pz3=pz2.redMul(p.z);return 0===this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0)},JPoint.prototype.eqXToP=function(x){var zs=this.z.redSqr(),rx=x.toRed(this.curve.red).redMul(zs);if(0===this.x.cmp(rx))return!0;for(var xc=x.clone(),t=this.curve.redN.redMul(zs);;){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}},JPoint.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},JPoint.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":84,"./base":71,"bn.js":20,inherits:103}],76:[function(require,module,exports){"use strict";var pre,curves=exports,hash=require("hash.js"),curve=require("./curve"),assert=require("./utils").assert;function PresetCurve(options){"short"===options.type?this.curve=new curve.short(options):"edwards"===options.type?this.curve=new curve.edwards(options):this.curve=new 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")}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}})}curves.PresetCurve=PresetCurve,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"]});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]})},{"./curve":73,"./precomputed/secp256k1":83,"./utils":84,"hash.js":89}],77:[function(require,module,exports){"use strict";var BN=require("bn.js"),HmacDRBG=require("hmac-drbg"),utils=require("../utils"),curves=require("../curves"),rand=require("brorand"),assert=utils.assert,KeyPair=require("./key"),Signature=require("./signature");function EC(options){if(!(this instanceof EC))return new EC(options);"string"==typeof options&&(assert(curves.hasOwnProperty(options),"Unknown curve "+options),options=curves[options]),options instanceof 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||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 p,sinv=s.invm(this.n),u1=sinv.mul(msg).umod(this.n),u2=sinv.mul(r).umod(this.n);return this.curve._maxwellTrick?!(p=this.g.jmulAdd(u1,key.getPublic(),u2)).isInfinity()&&p.eqXToP(r):!(p=this.g.mulAdd(u1,key.getPublic(),u2)).isInfinity()&&0===p.getX().umod(this.n).cmp(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")}},{"../curves":76,"../utils":84,"./key":78,"./signature":79,"bn.js":20,brorand:21,"hmac-drbg":101}],78:[function(require,module,exports){"use strict";var BN=require("bn.js"),assert=require("../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"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},{"../utils":84,"bn.js":20}],79:[function(require,module,exports){"use strict";var BN=require("bn.js"),utils=require("../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)}function Position(){this.place=0}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<octetLen;i++,off++)val<<=8,val|=buf[off];return p.place=off,val}function rmPadding(buf){for(var i=0,len=buf.length-1;!buf[i]&&!(128&buf[i+1])&&i<len;)i++;return 0===i?buf:buf.slice(i)}function constructLength(arr,len){if(len<128)arr.push(len);else{var octets=1+(Math.log(len)/Math.LN2>>>3);for(arr.push(128|octets);--octets;)arr.push(len>>>(octets<<3)&255);arr.push(len)}}module.exports=Signature,Signature.prototype._importDER=function(data,enc){data=utils.toArray(data,enc);var p=new Position;if(48!==data[p.place++])return!1;if(getLength(data,p)+p.place!==data.length)return!1;if(2!==data[p.place++])return!1;var rlen=getLength(data,p),r=data.slice(p.place,rlen+p.place);if(p.place+=rlen,2!==data[p.place++])return!1;var slen=getLength(data,p);if(data.length!==slen+p.place)return!1;var s=data.slice(p.place,slen+p.place);return 0===r[0]&&128&r[1]&&(r=r.slice(1)),0===s[0]&&128&s[1]&&(s=s.slice(1)),this.r=new BN(r),this.s=new BN(s),this.recoveryParam=null,!0},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)}},{"../utils":84,"bn.js":20}],80:[function(require,module,exports){"use strict";var hash=require("hash.js"),curves=require("../curves"),utils=require("../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=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<arguments.length;i++)hash.update(arguments[i]);return utils.intFromLE(hash.digest()).umod(this.curve.n)},EDDSA.prototype.keyFromPublic=function(pub){return KeyPair.fromPublic(this,pub)},EDDSA.prototype.keyFromSecret=function(secret){return KeyPair.fromSecret(this,secret)},EDDSA.prototype.makeSignature=function(sig){return sig instanceof Signature?sig:new Signature(this,sig)},EDDSA.prototype.encodePoint=function(point){var enc=point.getY().toArray("le",this.encodingLength);return enc[this.encodingLength-1]|=point.getX().isOdd()?128:0,enc},EDDSA.prototype.decodePoint=function(bytes){var lastIx=(bytes=utils.parseBytes(bytes)).length-1,normed=bytes.slice(0,lastIx).concat(-129&bytes[lastIx]),xIsOdd=0!=(128&bytes[lastIx]),y=utils.intFromLE(normed);return this.curve.pointFromY(y,xIsOdd)},EDDSA.prototype.encodeInt=function(num){return num.toArray("le",this.encodingLength)},EDDSA.prototype.decodeInt=function(bytes){return utils.intFromLE(bytes)},EDDSA.prototype.isPoint=function(val){return val instanceof this.pointClass}},{"../curves":76,"../utils":84,"./key":81,"./signature":82,"hash.js":89}],81:[function(require,module,exports){"use strict";var utils=require("../utils"),assert=utils.assert,parseBytes=utils.parseBytes,cachedProperty=utils.cachedProperty;function KeyPair(eddsa,params){this.eddsa=eddsa,this._secret=parseBytes(params.secret),eddsa.isPoint(params.pub)?this._pub=params.pub:this._pubBytes=parseBytes(params.pub)}KeyPair.fromPublic=function(eddsa,pub){return pub instanceof KeyPair?pub:new KeyPair(eddsa,{pub:pub})},KeyPair.fromSecret=function(eddsa,secret){return secret instanceof KeyPair?secret:new KeyPair(eddsa,{secret:secret})},KeyPair.prototype.secret=function(){return this._secret},cachedProperty(KeyPair,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),cachedProperty(KeyPair,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),cachedProperty(KeyPair,"privBytes",(function(){var eddsa=this.eddsa,hash=this.hash(),lastIx=eddsa.encodingLength-1,a=hash.slice(0,eddsa.encodingLength);return a[0]&=248,a[lastIx]&=127,a[lastIx]|=64,a})),cachedProperty(KeyPair,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),cachedProperty(KeyPair,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),cachedProperty(KeyPair,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),KeyPair.prototype.sign=function(message){return assert(this._secret,"KeyPair can only verify"),this.eddsa.sign(message,this)},KeyPair.prototype.verify=function(message,sig){return this.eddsa.verify(message,sig,this)},KeyPair.prototype.getSecret=function(enc){return assert(this._secret,"KeyPair is public only"),utils.encode(this.secret(),enc)},KeyPair.prototype.getPublic=function(enc){return utils.encode(this.pubBytes(),enc)},module.exports=KeyPair},{"../utils":84}],82:[function(require,module,exports){"use strict";var BN=require("bn.js"),utils=require("../utils"),assert=utils.assert,cachedProperty=utils.cachedProperty,parseBytes=utils.parseBytes;function Signature(eddsa,sig){this.eddsa=eddsa,"object"!=typeof sig&&(sig=parseBytes(sig)),Array.isArray(sig)&&(sig={R:sig.slice(0,eddsa.encodingLength),S:sig.slice(eddsa.encodingLength)}),assert(sig.R&&sig.S,"Signature without R or S"),eddsa.isPoint(sig.R)&&(this._R=sig.R),sig.S instanceof BN&&(this._S=sig.S),this._Rencoded=Array.isArray(sig.R)?sig.R:sig.Rencoded,this._Sencoded=Array.isArray(sig.S)?sig.S:sig.Sencoded}cachedProperty(Signature,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),cachedProperty(Signature,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),cachedProperty(Signature,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),cachedProperty(Signature,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),Signature.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Signature.prototype.toHex=function(){return utils.encode(this.toBytes(),"hex").toUpperCase()},module.exports=Signature},{"../utils":84,"bn.js":20}],83:[function(require,module,exports){module.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},{}],84:[function(require,module,exports){"use strict";var utils=exports,BN=require("bn.js"),minAssert=require("minimalistic-assert"),minUtils=require("minimalistic-crypto-utils");utils.assert=minAssert,utils.toArray=minUtils.toArray,utils.zero2=minUtils.zero2,utils.toHex=minUtils.toHex,utils.encode=minUtils.encode,utils.getNAF=function(num,w){for(var naf=[],ws=1<<w+1,k=num.clone();k.cmpn(1)>=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;i<shift;i++)naf.push(0);k.iushrn(shift)}return naf},utils.getJSF=function(k1,k2){var jsf=[[],[]];k1=k1.clone(),k2=k2.clone();for(var d1=0,d2=0;k1.cmpn(-d1)>0||k2.cmpn(-d2)>0;){var u1,u2,m8,m14=k1.andln(3)+d1&3,m24=k2.andln(3)+d2&3;if(3===m14&&(m14=-1),3===m24&&(m24=-1),0==(1&m14))u1=0;else u1=3!==(m8=k1.andln(7)+d1&7)&&5!==m8||2!==m24?m14:-m14;if(jsf[0].push(u1),0==(1&m24))u2=0;else 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":20,"minimalistic-assert":108,"minimalistic-crypto-utils":109}],85:[function(require,module,exports){module.exports={_from:"elliptic@^6.0.0",_id:"elliptic@6.5.1",_inBundle:!1,_integrity:"sha512-xvJINNLbTeWQjrl6X+7eQCrIy/YPv5XCpKW6kB5mKvtnGILoLDcySuwomfdzt0BMdLNVnuRNTuzKNHj0bva1Cg==",_location:"/browserify/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/browserify-sign","/browserify/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.1.tgz",_shasum:"c380f5f909bf1b9b4428d028cd18d3b0efd6b52b",_spec:"elliptic@^6.0.0",_where:"/Users/nanjiang/.nvm/versions/node/v9.9.0/lib/node_modules/browserify/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:"^3.0.4",grunt:"^1.0.4","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":"^9.0.1",istanbul:"^0.4.2",jscs:"^3.0.7",jshint:"^2.6.0",mocha:"^6.1.4"},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.5.1"}},{}],86:[function(require,module,exports){var objectCreate=Object.create||function(proto){var F=function(){};return F.prototype=proto,new F},objectKeys=Object.keys||function(obj){var keys=[];for(var k in obj)Object.prototype.hasOwnProperty.call(obj,k)&&keys.push(k);return k},bind=Function.prototype.bind||function(context){var fn=this;return function(){return fn.apply(context,arguments)}};function EventEmitter(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=objectCreate(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0;var hasDefineProperty,defaultMaxListeners=10;try{var o={};Object.defineProperty&&Object.defineProperty(o,"x",{value:0}),hasDefineProperty=0===o.x}catch(err){hasDefineProperty=!1}function $getMaxListeners(that){return void 0===that._maxListeners?EventEmitter.defaultMaxListeners:that._maxListeners}function emitNone(handler,isFn,self){if(isFn)handler.call(self);else for(var len=handler.length,listeners=arrayClone(handler,len),i=0;i<len;++i)listeners[i].call(self)}function emitOne(handler,isFn,self,arg1){if(isFn)handler.call(self,arg1);else for(var len=handler.length,listeners=arrayClone(handler,len),i=0;i<len;++i)listeners[i].call(self,arg1)}function emitTwo(handler,isFn,self,arg1,arg2){if(isFn)handler.call(self,arg1,arg2);else for(var len=handler.length,listeners=arrayClone(handler,len),i=0;i<len;++i)listeners[i].call(self,arg1,arg2)}function emitThree(handler,isFn,self,arg1,arg2,arg3){if(isFn)handler.call(self,arg1,arg2,arg3);else for(var len=handler.length,listeners=arrayClone(handler,len),i=0;i<len;++i)listeners[i].call(self,arg1,arg2,arg3)}function emitMany(handler,isFn,self,args){if(isFn)handler.apply(self,args);else for(var len=handler.length,listeners=arrayClone(handler,len),i=0;i<len;++i)listeners[i].apply(self,args)}function _addListener(target,type,listener,prepend){var m,events,existing;if("function"!=typeof listener)throw new TypeError('"listener" argument must be a function');if((events=target._events)?(events.newListener&&(target.emit("newListener",type,listener.listener?listener.listener:listener),events=target._events),existing=events[type]):(events=target._events=objectCreate(null),target._eventsCount=0),existing){if("function"==typeof existing?existing=events[type]=prepend?[listener,existing]:[existing,listener]:prepend?existing.unshift(listener):existing.push(listener),!existing.warned&&(m=$getMaxListeners(target))&&m>0&&existing.length>m){existing.warned=!0;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+' "'+String(type)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');w.name="MaxListenersExceededWarning",w.emitter=target,w.type=type,w.count=existing.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",w.name,w.message)}}else existing=events[type]=listener,++target._eventsCount;return target}function onceWrapper(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var args=new Array(arguments.length),i=0;i<args.length;++i)args[i]=arguments[i];this.listener.apply(this.target,args)}}function _onceWrap(target,type,listener){var state={fired:!1,wrapFn:void 0,target:target,type:type,listener:listener},wrapped=bind.call(onceWrapper,state);return wrapped.listener=listener,state.wrapFn=wrapped,wrapped}function _listeners(target,type,unwrap){var events=target._events;if(!events)return[];var evlistener=events[type];return evlistener?"function"==typeof evlistener?unwrap?[evlistener.listener||evlistener]:[evlistener]:unwrap?function(arr){for(var ret=new Array(arr.length),i=0;i<ret.length;++i)ret[i]=arr[i].listener||arr[i];return ret}(evlistener):arrayClone(evlistener,evlistener.length):[]}function listenerCount(type){var events=this._events;if(events){var evlistener=events[type];if("function"==typeof evlistener)return 1;if(evlistener)return evlistener.length}return 0}function arrayClone(arr,n){for(var copy=new Array(n),i=0;i<n;++i)copy[i]=arr[i];return copy}hasDefineProperty?Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(arg){if("number"!=typeof arg||arg<0||arg!=arg)throw new TypeError('"defaultMaxListeners" must be a positive number');defaultMaxListeners=arg}}):EventEmitter.defaultMaxListeners=defaultMaxListeners,EventEmitter.prototype.setMaxListeners=function(n){if("number"!=typeof n||n<0||isNaN(n))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=n,this},EventEmitter.prototype.getMaxListeners=function(){return $getMaxListeners(this)},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,events,doError="error"===type;if(events=this._events)doError=doError&&null==events.error;else if(!doError)return!1;if(doError){if(arguments.length>1&&(er=arguments[1]),er instanceof Error)throw er;var err=new Error('Unhandled "error" event. ('+er+")");throw err.context=er,err}if(!(handler=events[type]))return!1;var isFn="function"==typeof handler;switch(len=arguments.length){case 1:emitNone(handler,isFn,this);break;case 2:emitOne(handler,isFn,this,arguments[1]);break;case 3:emitTwo(handler,isFn,this,arguments[1],arguments[2]);break;case 4:emitThree(handler,isFn,this,arguments[1],arguments[2],arguments[3]);break;default:for(args=new Array(len-1),i=1;i<len;i++)args[i-1]=arguments[i];emitMany(handler,isFn,this,args)}return!0},EventEmitter.prototype.addListener=function(type,listener){return _addListener(this,type,listener,!1)},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.prependListener=function(type,listener){return _addListener(this,type,listener,!0)},EventEmitter.prototype.once=function(type,listener){if("function"!=typeof listener)throw new TypeError('"listener" argument must be a function');return this.on(type,_onceWrap(this,type,listener)),this},EventEmitter.prototype.prependOnceListener=function(type,listener){if("function"!=typeof listener)throw new TypeError('"listener" argument must be a function');return this.prependListener(type,_onceWrap(this,type,listener)),this},EventEmitter.prototype.removeListener=function(type,listener){var list,events,position,i,originalListener;if("function"!=typeof listener)throw new TypeError('"listener" argument must be a function');if(!(events=this._events))return this;if(!(list=events[type]))return this;if(list===listener||list.listener===listener)0==--this._eventsCount?this._events=objectCreate(null):(delete events[type],events.removeListener&&this.emit("removeListener",type,list.listener||listener));else if("function"!=typeof list){for(position=-1,i=list.length-1;i>=0;i--)if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener,position=i;break}if(position<0)return this;0===position?list.shift():function(list,index){for(var i=index,k=i+1,n=list.length;k<n;i+=1,k+=1)list[i]=list[k];list.pop()}(list,position),1===list.length&&(events[type]=list[0]),events.removeListener&&this.emit("removeListener",type,originalListener||listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var listeners,events,i;if(!(events=this._events))return this;if(!events.removeListener)return 0===arguments.length?(this._events=objectCreate(null),this._eventsCount=0):events[type]&&(0==--this._eventsCount?this._events=objectCreate(null):delete events[type]),this;if(0===arguments.length){var key,keys=objectKeys(events);for(i=0;i<keys.length;++i)"removeListener"!==(key=keys[i])&&this.removeAllListeners(key);return this.removeAllListeners("removeListener"),this._events=objectCreate(null),this._eventsCount=0,this}if("function"==typeof(listeners=events[type]))this.removeListener(type,listeners);else if(listeners)for(i=listeners.length-1;i>=0;i--)this.removeListener(type,listeners[i]);return this},EventEmitter.prototype.listeners=function(type){return _listeners(this,type,!0)},EventEmitter.prototype.rawListeners=function(type){return _listeners(this,type,!1)},EventEmitter.listenerCount=function(emitter,type){return"function"==typeof emitter.listenerCount?emitter.listenerCount(type):listenerCount.call(emitter,type)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],87:[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(used<tmp.length&&ivLen>0){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":106,"safe-buffer":151}],88:[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;i<this._blockSize;)block[i++]=data[offset++];this._update(),this._blockOffset=0}for(;offset<data.length;)block[this._blockOffset++]=data[offset++];for(var j=0,carry=8*data.length;carry>0;++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:103,"safe-buffer":151,stream:160}],89:[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":90,"./hash/hmac":91,"./hash/ripemd":92,"./hash/sha":93,"./hash/utils":100}],90:[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<msg.length;i+=this._delta32)this._update(msg,i,i+this._delta32)}return this},BlockHash.prototype.digest=function(enc){return this.update(this._pad()),assert(null===this.pending),this._digest(enc)},BlockHash.prototype._pad=function(){var len=this.pendingTotal,bytes=this._delta8,k=bytes-(len+this.padLength)%bytes,res=new Array(k+this.padLength);res[0]=128;for(var i=1;i<k;i++)res[i]=0;if(len<<=3,"big"===this.endian){for(var t=8;t<this.padLength;t++)res[i++]=0;res[i++]=0,res[i++]=0,res[i++]=0,res[i++]=0,res[i++]=len>>>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;t<this.padLength;t++)res[i++]=0;return res}},{"./utils":100,"minimalistic-assert":108}],91:[function(require,module,exports){"use strict";var utils=require("./utils"),assert=require("minimalistic-assert");function Hmac(hash,key,enc){if(!(this instanceof Hmac))return new Hmac(hash,key,enc);this.Hash=hash,this.blockSize=hash.blockSize/8,this.outSize=hash.outSize/8,this.inner=null,this.outer=null,this._init(utils.toArray(key,enc))}module.exports=Hmac,Hmac.prototype._init=function(key){key.length>this.blockSize&&(key=(new this.Hash).update(key).digest()),assert(key.length<=this.blockSize);for(var i=key.length;i<this.blockSize;i++)key.push(0);for(i=0;i<key.length;i++)key[i]^=54;for(this.inner=(new this.Hash).update(key),i=0;i<key.length;i++)key[i]^=106;this.outer=(new this.Hash).update(key)},Hmac.prototype.update=function(msg,enc){return this.inner.update(msg,enc),this},Hmac.prototype.digest=function(enc){return this.outer.update(this.inner.digest()),this.outer.digest(enc)}},{"./utils":100,"minimalistic-assert":108}],92:[function(require,module,exports){"use strict";var utils=require("./utils"),common=require("./common"),rotl32=utils.rotl32,sum32=utils.sum32,sum32_3=utils.sum32_3,sum32_4=utils.sum32_4,BlockHash=common.BlockHash;function RIPEMD160(){if(!(this instanceof RIPEMD160))return new RIPEMD160;BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function f(j,x,y,z){return j<=15?x^y^z:j<=31?x&y|~x&z:j<=47?(x|~y)^z:j<=63?x&z|y&~z:x^(y|~z)}function K(j){return j<=15?0:j<=31?1518500249:j<=47?1859775393:j<=63?2400959708:2840853838}function Kh(j){return j<=15?1352829926:j<=31?1548603684:j<=47?1836072691:j<=63?2053994217:0}utils.inherits(RIPEMD160,BlockHash),exports.ripemd160=RIPEMD160,RIPEMD160.blockSize=512,RIPEMD160.outSize=160,RIPEMD160.hmacStrength=192,RIPEMD160.padLength=64,RIPEMD160.prototype._update=function(msg,start){for(var A=this.h[0],B=this.h[1],C=this.h[2],D=this.h[3],E=this.h[4],Ah=A,Bh=B,Ch=C,Dh=D,Eh=E,j=0;j<80;j++){var T=sum32(rotl32(sum32_4(A,f(j,B,C,D),msg[r[j]+start],K(j)),s[j]),E);A=E,E=D,D=rotl32(C,10),C=B,B=T,T=sum32(rotl32(sum32_4(Ah,f(79-j,Bh,Ch,Dh),msg[rh[j]+start],Kh(j)),sh[j]),Eh),Ah=Eh,Eh=Dh,Dh=rotl32(Ch,10),Ch=Bh,Bh=T}T=sum32_3(this.h[1],C,Dh),this.h[1]=sum32_3(this.h[2],D,Eh),this.h[2]=sum32_3(this.h[3],E,Ah),this.h[3]=sum32_3(this.h[4],A,Bh),this.h[4]=sum32_3(this.h[0],B,Ch),this.h[0]=T},RIPEMD160.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h,"little"):utils.split32(this.h,"little")};var r=[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],rh=[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],s=[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],sh=[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":90,"./utils":100}],93:[function(require,module,exports){"use strict";exports.sha1=require("./sha/1"),exports.sha224=require("./sha/224"),exports.sha256=require("./sha/256"),exports.sha384=require("./sha/384"),exports.sha512=require("./sha/512")},{"./sha/1":94,"./sha/224":95,"./sha/256":96,"./sha/384":97,"./sha/512":98}],94:[function(require,module,exports){"use strict";var utils=require("../utils"),common=require("../common"),shaCommon=require("./common"),rotl32=utils.rotl32,sum32=utils.sum32,sum32_5=utils.sum32_5,ft_1=shaCommon.ft_1,BlockHash=common.BlockHash,sha1_K=[1518500249,1859775393,2400959708,3395469782];function SHA1(){if(!(this instanceof SHA1))return new SHA1;BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}utils.inherits(SHA1,BlockHash),module.exports=SHA1,SHA1.blockSize=512,SHA1.outSize=160,SHA1.hmacStrength=80,SHA1.padLength=64,SHA1.prototype._update=function(msg,start){for(var W=this.W,i=0;i<16;i++)W[i]=msg[start+i];for(;i<W.length;i++)W[i]=rotl32(W[i-3]^W[i-8]^W[i-14]^W[i-16],1);var a=this.h[0],b=this.h[1],c=this.h[2],d=this.h[3],e=this.h[4];for(i=0;i<W.length;i++){var s=~~(i/20),t=sum32_5(rotl32(a,5),ft_1(s,b,c,d),e,W[i],sha1_K[s]);e=d,d=c,c=rotl32(b,30),b=a,a=t}this.h[0]=sum32(this.h[0],a),this.h[1]=sum32(this.h[1],b),this.h[2]=sum32(this.h[2],c),this.h[3]=sum32(this.h[3],d),this.h[4]=sum32(this.h[4],e)},SHA1.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h,"big"):utils.split32(this.h,"big")}},{"../common":90,"../utils":100,"./common":99}],95:[function(require,module,exports){"use strict";var utils=require("../utils"),SHA256=require("./256");function SHA224(){if(!(this instanceof SHA224))return new SHA224;SHA256.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}utils.inherits(SHA224,SHA256),module.exports=SHA224,SHA224.blockSize=512,SHA224.outSize=224,SHA224.hmacStrength=192,SHA224.padLength=64,SHA224.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h.slice(0,7),"big"):utils.split32(this.h.slice(0,7),"big")}},{"../utils":100,"./256":96}],96:[function(require,module,exports){"use strict";var utils=require("../utils"),common=require("../common"),shaCommon=require("./common"),assert=require("minimalistic-assert"),sum32=utils.sum32,sum32_4=utils.sum32_4,sum32_5=utils.sum32_5,ch32=shaCommon.ch32,maj32=shaCommon.maj32,s0_256=shaCommon.s0_256,s1_256=shaCommon.s1_256,g0_256=shaCommon.g0_256,g1_256=shaCommon.g1_256,BlockHash=common.BlockHash,sha256_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];function SHA256(){if(!(this instanceof SHA256))return new SHA256;BlockHash.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=sha256_K,this.W=new Array(64)}utils.inherits(SHA256,BlockHash),module.exports=SHA256,SHA256.blockSize=512,SHA256.outSize=256,SHA256.hmacStrength=192,SHA256.padLength=64,SHA256.prototype._update=function(msg,start){for(var W=this.W,i=0;i<16;i++)W[i]=msg[start+i];for(;i<W.length;i++)W[i]=sum32_4(g1_256(W[i-2]),W[i-7],g0_256(W[i-15]),W[i-16]);var a=this.h[0],b=this.h[1],c=this.h[2],d=this.h[3],e=this.h[4],f=this.h[5],g=this.h[6],h=this.h[7];for(assert(this.k.length===W.length),i=0;i<W.length;i++){var T1=sum32_5(h,s1_256(e),ch32(e,f,g),this.k[i],W[i]),T2=sum32(s0_256(a),maj32(a,b,c));h=g,g=f,f=e,e=sum32(d,T1),d=c,c=b,b=a,a=sum32(T1,T2)}this.h[0]=sum32(this.h[0],a),this.h[1]=sum32(this.h[1],b),this.h[2]=sum32(this.h[2],c),this.h[3]=sum32(this.h[3],d),this.h[4]=sum32(this.h[4],e),this.h[5]=sum32(this.h[5],f),this.h[6]=sum32(this.h[6],g),this.h[7]=sum32(this.h[7],h)},SHA256.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h,"big"):utils.split32(this.h,"big")}},{"../common":90,"../utils":100,"./common":99,"minimalistic-assert":108}],97:[function(require,module,exports){"use strict";var utils=require("../utils"),SHA512=require("./512");function SHA384(){if(!(this instanceof SHA384))return new SHA384;SHA512.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}utils.inherits(SHA384,SHA512),module.exports=SHA384,SHA384.blockSize=1024,SHA384.outSize=384,SHA384.hmacStrength=192,SHA384.padLength=128,SHA384.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h.slice(0,12),"big"):utils.split32(this.h.slice(0,12),"big")}},{"../utils":100,"./512":98}],98:[function(require,module,exports){"use strict";var utils=require("../utils"),common=require("../common"),assert=require("minimalistic-assert"),rotr64_hi=utils.rotr64_hi,rotr64_lo=utils.rotr64_lo,shr64_hi=utils.shr64_hi,shr64_lo=utils.shr64_lo,sum64=utils.sum64,sum64_hi=utils.sum64_hi,sum64_lo=utils.sum64_lo,sum64_4_hi=utils.sum64_4_hi,sum64_4_lo=utils.sum64_4_lo,sum64_5_hi=utils.sum64_5_hi,sum64_5_lo=utils.sum64_5_lo,BlockHash=common.BlockHash,sha512_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];function SHA512(){if(!(this instanceof SHA512))return new SHA512;BlockHash.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=sha512_K,this.W=new Array(160)}function ch64_hi(xh,xl,yh,yl,zh){var r=xh&yh^~xh&zh;return r<0&&(r+=4294967296),r}function ch64_lo(xh,xl,yh,yl,zh,zl){var r=xl&yl^~xl&zl;return r<0&&(r+=4294967296),r}function maj64_hi(xh,xl,yh,yl,zh){var r=xh&yh^xh&zh^yh&zh;return r<0&&(r+=4294967296),r}function maj64_lo(xh,xl,yh,yl,zh,zl){var r=xl&yl^xl&zl^yl&zl;return r<0&&(r+=4294967296),r}function s0_512_hi(xh,xl){var r=rotr64_hi(xh,xl,28)^rotr64_hi(xl,xh,2)^rotr64_hi(xl,xh,7);return r<0&&(r+=4294967296),r}function s0_512_lo(xh,xl){var r=rotr64_lo(xh,xl,28)^rotr64_lo(xl,xh,2)^rotr64_lo(xl,xh,7);return r<0&&(r+=4294967296),r}function s1_512_hi(xh,xl){var r=rotr64_hi(xh,xl,14)^rotr64_hi(xh,xl,18)^rotr64_hi(xl,xh,9);return r<0&&(r+=4294967296),r}function s1_512_lo(xh,xl){var r=rotr64_lo(xh,xl,14)^rotr64_lo(xh,xl,18)^rotr64_lo(xl,xh,9);return r<0&&(r+=4294967296),r}function g0_512_hi(xh,xl){var r=rotr64_hi(xh,xl,1)^rotr64_hi(xh,xl,8)^shr64_hi(xh,xl,7);return r<0&&(r+=4294967296),r}function g0_512_lo(xh,xl){var r=rotr64_lo(xh,xl,1)^rotr64_lo(xh,xl,8)^shr64_lo(xh,xl,7);return r<0&&(r+=4294967296),r}function g1_512_hi(xh,xl){var r=rotr64_hi(xh,xl,19)^rotr64_hi(xl,xh,29)^shr64_hi(xh,xl,6);return r<0&&(r+=4294967296),r}function g1_512_lo(xh,xl){var r=rotr64_lo(xh,xl,19)^rotr64_lo(xl,xh,29)^shr64_lo(xh,xl,6);return r<0&&(r+=4294967296),r}utils.inherits(SHA512,BlockHash),module.exports=SHA512,SHA512.blockSize=1024,SHA512.outSize=512,SHA512.hmacStrength=192,SHA512.padLength=128,SHA512.prototype._prepareBlock=function(msg,start){for(var W=this.W,i=0;i<32;i++)W[i]=msg[start+i];for(;i<W.length;i+=2){var c0_hi=g1_512_hi(W[i-4],W[i-3]),c0_lo=g1_512_lo(W[i-4],W[i-3]),c1_hi=W[i-14],c1_lo=W[i-13],c2_hi=g0_512_hi(W[i-30],W[i-29]),c2_lo=g0_512_lo(W[i-30],W[i-29]),c3_hi=W[i-32],c3_lo=W[i-31];W[i]=sum64_4_hi(c0_hi,c0_lo,c1_hi,c1_lo,c2_hi,c2_lo,c3_hi,c3_lo),W[i+1]=sum64_4_lo(c0_hi,c0_lo,c1_hi,c1_lo,c2_hi,c2_lo,c3_hi,c3_lo)}},SHA512.prototype._update=function(msg,start){this._prepareBlock(msg,start);var W=this.W,ah=this.h[0],al=this.h[1],bh=this.h[2],bl=this.h[3],ch=this.h[4],cl=this.h[5],dh=this.h[6],dl=this.h[7],eh=this.h[8],el=this.h[9],fh=this.h[10],fl=this.h[11],gh=this.h[12],gl=this.h[13],hh=this.h[14],hl=this.h[15];assert(this.k.length===W.length);for(var i=0;i<W.length;i+=2){var c0_hi=hh,c0_lo=hl,c1_hi=s1_512_hi(eh,el),c1_lo=s1_512_lo(eh,el),c2_hi=ch64_hi(eh,el,fh,fl,gh),c2_lo=ch64_lo(eh,el,fh,fl,gh,gl),c3_hi=this.k[i],c3_lo=this.k[i+1],c4_hi=W[i],c4_lo=W[i+1],T1_hi=sum64_5_hi(c0_hi,c0_lo,c1_hi,c1_lo,c2_hi,c2_lo,c3_hi,c3_lo,c4_hi,c4_lo),T1_lo=sum64_5_lo(c0_hi,c0_lo,c1_hi,c1_lo,c2_hi,c2_lo,c3_hi,c3_lo,c4_hi,c4_lo);c0_hi=s0_512_hi(ah,al),c0_lo=s0_512_lo(ah,al),c1_hi=maj64_hi(ah,al,bh,bl,ch),c1_lo=maj64_lo(ah,al,bh,bl,ch,cl);var T2_hi=sum64_hi(c0_hi,c0_lo,c1_hi,c1_lo),T2_lo=sum64_lo(c0_hi,c0_lo,c1_hi,c1_lo);hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,eh=sum64_hi(dh,dl,T1_hi,T1_lo),el=sum64_lo(dl,dl,T1_hi,T1_lo),dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,ah=sum64_hi(T1_hi,T1_lo,T2_hi,T2_lo),al=sum64_lo(T1_hi,T1_lo,T2_hi,T2_lo)}sum64(this.h,0,ah,al),sum64(this.h,2,bh,bl),sum64(this.h,4,ch,cl),sum64(this.h,6,dh,dl),sum64(this.h,8,eh,el),sum64(this.h,10,fh,fl),sum64(this.h,12,gh,gl),sum64(this.h,14,hh,hl)},SHA512.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h,"big"):utils.split32(this.h,"big")}},{"../common":90,"../utils":100,"minimalistic-assert":108}],99:[function(require,module,exports){"use strict";var rotr32=require("../utils").rotr32;function ch32(x,y,z){return x&y^~x&z}function maj32(x,y,z){return x&y^x&z^y&z}function p32(x,y,z){return x^y^z}exports.ft_1=function(s,x,y,z){return 0===s?ch32(x,y,z):1===s||3===s?p32(x,y,z):2===s?maj32(x,y,z):void 0},exports.ch32=ch32,exports.maj32=maj32,exports.p32=p32,exports.s0_256=function(x){return rotr32(x,2)^rotr32(x,13)^rotr32(x,22)},exports.s1_256=function(x){return rotr32(x,6)^rotr32(x,11)^rotr32(x,25)},exports.g0_256=function(x){return rotr32(x,7)^rotr32(x,18)^x>>>3},exports.g1_256=function(x){return rotr32(x,17)^rotr32(x,19)^x>>>10}},{"../utils":100}],100:[function(require,module,exports){"use strict";var assert=require("minimalistic-assert"),inherits=require("inherits");function isSurrogatePair(msg,i){return 55296==(64512&msg.charCodeAt(i))&&(!(i<0||i+1>=msg.length)&&56320==(64512&msg.charCodeAt(i+1)))}function htonl(w){return(w>>>24|w>>>8&65280|w<<8&16711680|(255&w)<<24)>>>0}function zero2(word){return 1===word.length?"0"+word:word}function zero8(word){return 7===word.length?"0"+word:6===word.length?"00"+word:5===word.length?"000"+word:4===word.length?"0000"+word:3===word.length?"00000"+word:2===word.length?"000000"+word:1===word.length?"0000000"+word:word}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<msg.length;i+=2)res.push(parseInt(msg[i]+msg[i+1],16))}else for(var p=0,i=0;i<msg.length;i++){var c=msg.charCodeAt(i);c<128?res[p++]=c:c<2048?(res[p++]=c>>6|192,res[p++]=63&c|128):isSurrogatePair(msg,i)?(c=65536+((1023&c)<<10)+(1023&msg.charCodeAt(++i)),res[p++]=c>>18|240,res[p++]=c>>12&63|128,res[p++]=c>>6&63|128,res[p++]=63&c|128):(res[p++]=c>>12|224,res[p++]=c>>6&63|128,res[p++]=63&c|128)}else for(i=0;i<msg.length;i++)res[i]=0|msg[i];return res},exports.toHex=function(msg){for(var res="",i=0;i<msg.length;i++)res+=zero2(msg[i].toString(16));return res},exports.htonl=htonl,exports.toHex32=function(msg,endian){for(var res="",i=0;i<msg.length;i++){var w=msg[i];"little"===endian&&(w=htonl(w)),res+=zero8(w.toString(16))}return res},exports.zero2=zero2,exports.zero8=zero8,exports.join32=function(msg,start,end,endian){var len=end-start;assert(len%4==0);for(var res=new Array(len/4),i=0,k=start;i<res.length;i++,k+=4){var w;w="big"===endian?msg[k]<<24|msg[k+1]<<16|msg[k+2]<<8|msg[k+3]:msg[k+3]<<24|msg[k+2]<<16|msg[k+1]<<8|msg[k],res[i]=w>>>0}return res},exports.split32=function(msg,endian){for(var res=new Array(4*msg.length),i=0,k=0;i<msg.length;i++,k+=4){var m=msg[i];"big"===endian?(res[k]=m>>>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<<b|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<al?1:0)+ah+bh;buf[pos]=hi>>>0,buf[pos+1]=lo},exports.sum64_hi=function(ah,al,bh,bl){return(al+bl>>>0<al?1:0)+ah+bh>>>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)<al?1:0,carry+=(lo=lo+cl>>>0)<cl?1:0,ah+bh+ch+dh+(carry+=(lo=lo+dl>>>0)<dl?1: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)<al?1:0,carry+=(lo=lo+cl>>>0)<cl?1:0,carry+=(lo=lo+dl>>>0)<dl?1:0,ah+bh+ch+dh+eh+(carry+=(lo=lo+el>>>0)<el?1: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:103,"minimalistic-assert":108}],101:[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.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(seed),this._reseed=1,this.reseedInterval=281474976710656},HmacDRBG.prototype._hmac=function(){return new hash.hmac(this.hash,this.K)},HmacDRBG.prototype._update=function(seed){var kmac=this._hmac().update(this.V).update([0]);seed&&(kmac=kmac.update(seed)),this.K=kmac.digest(),this.V=this._hmac().update(this.V).digest(),seed&&(this.K=this._hmac().update(this.V).update([1]).update(seed).digest(),this.V=this._hmac().update(this.V).digest())},HmacDRBG.prototype.reseed=function(entropy,entropyEnc,add,addEnc){"string"!=typeof entropyEnc&&(addEnc=add,add=entropyEnc,entropyEnc=null),entropy=utils.toArray(entropy,entropyEnc),add=utils.toArray(add,addEnc),assert(entropy.length>=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<len;)this.V=this._hmac().update(this.V).digest(),temp=temp.concat(this.V);var res=temp.slice(0,len);return this._update(add),this._reseed++,utils.encode(res,enc)}},{"hash.js":89,"minimalistic-assert":108,"minimalistic-crypto-utils":109}],102:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>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<<eLen)-1,eBias=eMax>>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<<mLen|m,eLen+=mLen;eLen>0;buffer[offset+i]=255&e,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=128*s}},{}],103:[function(require,module,exports){"function"==typeof Object.create?module.exports=function(ctor,superCtor){superCtor&&(ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}}))}:module.exports=function(ctor,superCtor){if(superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}}},{}],104:[function(require,module,exports){function isBuffer(obj){return!!obj.constructor&&"function"==typeof obj.constructor.isBuffer&&obj.constructor.isBuffer(obj)} | ||
15 | /*! | ||
16 | * Determine if an object is a Buffer | ||
17 | * | ||
18 | * @author Feross Aboukhadijeh <https://feross.org> | ||
19 | * @license MIT | ||
20 | */ | ||
21 | 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)}},{}],105:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return"[object Array]"==toString.call(arr)}},{}],106:[function(require,module,exports){"use strict";var inherits=require("inherits"),HashBase=require("hash-base"),Buffer=require("safe-buffer").Buffer,ARRAY16=new Array(16);function MD5(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function rotl(x,n){return x<<n|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}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;a=fnF(a,b,c,d,M[0],3614090360,7),d=fnF(d,a,b,c,M[1],3905402710,12),c=fnF(c,d,a,b,M[2],606105819,17),b=fnF(b,c,d,a,M[3],3250441966,22),a=fnF(a,b,c,d,M[4],4118548399,7),d=fnF(d,a,b,c,M[5],1200080426,12),c=fnF(c,d,a,b,M[6],2821735955,17),b=fnF(b,c,d,a,M[7],4249261313,22),a=fnF(a,b,c,d,M[8],1770035416,7),d=fnF(d,a,b,c,M[9],2336552879,12),c=fnF(c,d,a,b,M[10],4294925233,17),b=fnF(b,c,d,a,M[11],2304563134,22),a=fnF(a,b,c,d,M[12],1804603682,7),d=fnF(d,a,b,c,M[13],4254626195,12),c=fnF(c,d,a,b,M[14],2792965006,17),a=fnG(a,b=fnF(b,c,d,a,M[15],1236535329,22),c,d,M[1],4129170786,5),d=fnG(d,a,b,c,M[6],3225465664,9),c=fnG(c,d,a,b,M[11],643717713,14),b=fnG(b,c,d,a,M[0],3921069994,20),a=fnG(a,b,c,d,M[5],3593408605,5),d=fnG(d,a,b,c,M[10],38016083,9),c=fnG(c,d,a,b,M[15],3634488961,14),b=fnG(b,c,d,a,M[4],3889429448,20),a=fnG(a,b,c,d,M[9],568446438,5),d=fnG(d,a,b,c,M[14],3275163606,9),c=fnG(c,d,a,b,M[3],4107603335,14),b=fnG(b,c,d,a,M[8],1163531501,20),a=fnG(a,b,c,d,M[13],2850285829,5),d=fnG(d,a,b,c,M[2],4243563512,9),c=fnG(c,d,a,b,M[7],1735328473,14),a=fnH(a,b=fnG(b,c,d,a,M[12],2368359562,20),c,d,M[5],4294588738,4),d=fnH(d,a,b,c,M[8],2272392833,11),c=fnH(c,d,a,b,M[11],1839030562,16),b=fnH(b,c,d,a,M[14],4259657740,23),a=fnH(a,b,c,d,M[1],2763975236,4),d=fnH(d,a,b,c,M[4],1272893353,11),c=fnH(c,d,a,b,M[7],4139469664,16),b=fnH(b,c,d,a,M[10],3200236656,23),a=fnH(a,b,c,d,M[13],681279174,4),d=fnH(d,a,b,c,M[0],3936430074,11),c=fnH(c,d,a,b,M[3],3572445317,16),b=fnH(b,c,d,a,M[6],76029189,23),a=fnH(a,b,c,d,M[9],3654602809,4),d=fnH(d,a,b,c,M[12],3873151461,11),c=fnH(c,d,a,b,M[15],530742520,16),a=fnI(a,b=fnH(b,c,d,a,M[2],3299628645,23),c,d,M[0],4096336452,6),d=fnI(d,a,b,c,M[7],1126891415,10),c=fnI(c,d,a,b,M[14],2878612391,15),b=fnI(b,c,d,a,M[5],4237533241,21),a=fnI(a,b,c,d,M[12],1700485571,6),d=fnI(d,a,b,c,M[3],2399980690,10),c=fnI(c,d,a,b,M[10],4293915773,15),b=fnI(b,c,d,a,M[1],2240044497,21),a=fnI(a,b,c,d,M[8],1873313359,6),d=fnI(d,a,b,c,M[15],4264355552,10),c=fnI(c,d,a,b,M[6],2734768916,15),b=fnI(b,c,d,a,M[13],1309151649,21),a=fnI(a,b,c,d,M[4],4149444226,6),d=fnI(d,a,b,c,M[11],3174756917,10),c=fnI(c,d,a,b,M[2],718787259,15),b=fnI(b,c,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=Buffer.allocUnsafe(16);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer},module.exports=MD5},{"hash-base":88,inherits:103,"safe-buffer":151}],107:[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;i<s;i++){if(0===(x=x.redSqr()).cmp(rone))return!1;if(0===x.cmp(rn1))break}if(i===s)return!1}}return!0},MillerRabin.prototype.getDivisor=function(n,k){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),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<s;i++){if(0===(x=x.redSqr()).cmp(rone))return x.fromRed().subn(1).gcd(n);if(0===x.cmp(rn1))break}if(i===s)return(x=x.redSqr()).fromRed().subn(1).gcd(n)}}return!1}},{"bn.js":20,brorand:21}],108:[function(require,module,exports){function assert(val,msg){if(!val)throw new Error(msg||"Assertion failed")}module.exports=assert,assert.equal=function(l,r,msg){if(l!=r)throw new Error(msg||"Assertion failed: "+l+" != "+r)}},{}],109:[function(require,module,exports){"use strict";var utils=exports;function zero2(word){return 1===word.length?"0"+word:word}function toHex(msg){for(var res="",i=0;i<msg.length;i++)res+=zero2(msg[i].toString(16));return res}utils.toArray=function(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if("string"!=typeof msg){for(var i=0;i<msg.length;i++)res[i]=0|msg[i];return res}if("hex"===enc){(msg=msg.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(msg="0"+msg);for(i=0;i<msg.length;i+=2)res.push(parseInt(msg[i]+msg[i+1],16))}else for(i=0;i<msg.length;i++){var c=msg.charCodeAt(i),hi=c>>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}return res},utils.zero2=zero2,utils.toHex=toHex,utils.encode=function(arr,enc){return"hex"===enc?toHex(arr):arr}},{}],110:[function(require,module,exports){ | ||
22 | /* | ||
23 | object-assign | ||
24 | (c) Sindre Sorhus | ||
25 | @license MIT | ||
26 | */ | ||
27 | "use strict";var getOwnPropertySymbols=Object.getOwnPropertySymbols,hasOwnProperty=Object.prototype.hasOwnProperty,propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(val){if(null==val)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(val)}module.exports=function(){try{if(!Object.assign)return!1;var test1=new String("abc");if(test1[5]="de","5"===Object.getOwnPropertyNames(test1)[0])return!1;for(var test2={},i=0;i<10;i++)test2["_"+String.fromCharCode(i)]=i;if("0123456789"!==Object.getOwnPropertyNames(test2).map((function(n){return test2[n]})).join(""))return!1;var test3={};return"abcdefghijklmnopqrst".split("").forEach((function(letter){test3[letter]=letter})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},test3)).join("")}catch(err){return!1}}()?Object.assign:function(target,source){for(var from,symbols,to=toObject(target),s=1;s<arguments.length;s++){for(var key in from=Object(arguments[s]))hasOwnProperty.call(from,key)&&(to[key]=from[key]);if(getOwnPropertySymbols){symbols=getOwnPropertySymbols(from);for(var i=0;i<symbols.length;i++)propIsEnumerable.call(from,symbols[i])&&(to[symbols[i]]=from[symbols[i]])}}return to}},{}],111:[function(require,module,exports){module.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"}},{}],112:[function(require,module,exports){"use strict";var asn1=require("asn1.js");exports.certificate=require("./certificate");var RSAPrivateKey=asn1.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())}));exports.RSAPrivateKey=RSAPrivateKey;var RSAPublicKey=asn1.define("RSAPublicKey",(function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())}));exports.RSAPublicKey=RSAPublicKey;var PublicKey=asn1.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPublicKey").bitstr())}));exports.PublicKey=PublicKey;var AlgorithmIdentifier=asn1.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())})),PrivateKeyInfo=asn1.define("PrivateKeyInfo",(function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPrivateKey").octstr())}));exports.PrivateKey=PrivateKeyInfo;var EncryptedPrivateKeyInfo=asn1.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())}));exports.EncryptedPrivateKey=EncryptedPrivateKeyInfo;var DSAPrivateKey=asn1.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())}));exports.DSAPrivateKey=DSAPrivateKey,exports.DSAparam=asn1.define("DSAparam",(function(){this.int()}));var ECPrivateKey=asn1.define("ECPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(ECParameters),this.key("publicKey").optional().explicit(1).bitstr())}));exports.ECPrivateKey=ECPrivateKey;var ECParameters=asn1.define("ECParameters",(function(){this.choice({namedCurve:this.objid()})}));exports.signature=asn1.define("signature",(function(){this.seq().obj(this.key("r").int(),this.key("s").int())}))},{"./certificate":113,"asn1.js":1}],113:[function(require,module,exports){"use strict";var asn=require("asn1.js"),Time=asn.define("Time",(function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})})),AttributeTypeValue=asn.define("AttributeTypeValue",(function(){this.seq().obj(this.key("type").objid(),this.key("value").any())})),AlgorithmIdentifier=asn.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())})),SubjectPublicKeyInfo=asn.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPublicKey").bitstr())})),RelativeDistinguishedName=asn.define("RelativeDistinguishedName",(function(){this.setof(AttributeTypeValue)})),RDNSequence=asn.define("RDNSequence",(function(){this.seqof(RelativeDistinguishedName)})),Name=asn.define("Name",(function(){this.choice({rdnSequence:this.use(RDNSequence)})})),Validity=asn.define("Validity",(function(){this.seq().obj(this.key("notBefore").use(Time),this.key("notAfter").use(Time))})),Extension=asn.define("Extension",(function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())})),TBSCertificate=asn.define("TBSCertificate",(function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(AlgorithmIdentifier),this.key("issuer").use(Name),this.key("validity").use(Validity),this.key("subject").use(Name),this.key("subjectPublicKeyInfo").use(SubjectPublicKeyInfo),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(Extension).optional())})),X509Certificate=asn.define("X509Certificate",(function(){this.seq().obj(this.key("tbsCertificate").use(TBSCertificate),this.key("signatureAlgorithm").use(AlgorithmIdentifier),this.key("signatureValue").bitstr())}));module.exports=X509Certificate},{"asn1.js":1}],114:[function(require,module,exports){var findProc=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r\+\/\=]+)[\n\r]+/m,startRegex=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,fullRegex=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m,evp=require("evp_bytestokey"),ciphers=require("browserify-aes"),Buffer=require("safe-buffer").Buffer;module.exports=function(okey,password){var decrypted,key=okey.toString(),match=key.match(findProc);if(match){var suite="aes"+match[1],iv=Buffer.from(match[2],"hex"),cipherText=Buffer.from(match[3].replace(/[\r\n]/g,""),"base64"),cipherKey=evp(password,iv.slice(0,8),parseInt(match[1],10)).key,out=[],cipher=ciphers.createDecipheriv(suite,cipherKey,iv);out.push(cipher.update(cipherText)),out.push(cipher.final()),decrypted=Buffer.concat(out)}else{var match2=key.match(fullRegex);decrypted=new Buffer(match2[2].replace(/[\r\n]/g,""),"base64")}return{tag:key.match(startRegex)[1],data:decrypted}}},{"browserify-aes":25,evp_bytestokey:87,"safe-buffer":151}],115:[function(require,module,exports){var asn1=require("./asn1"),aesid=require("./aesid.json"),fixProc=require("./fixProc"),ciphers=require("browserify-aes"),compat=require("pbkdf2"),Buffer=require("safe-buffer").Buffer;function parseKeys(buffer){var password;"object"!=typeof buffer||Buffer.isBuffer(buffer)||(password=buffer.passphrase,buffer=buffer.key),"string"==typeof buffer&&(buffer=Buffer.from(buffer));var subtype,ndata,stripped=fixProc(buffer,password),type=stripped.tag,data=stripped.data;switch(type){case"CERTIFICATE":ndata=asn1.certificate.decode(data,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(ndata||(ndata=asn1.PublicKey.decode(data,"der")),subtype=ndata.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return ndata.subjectPrivateKey=ndata.subjectPublicKey,{type:"ec",data:ndata};case"1.2.840.10040.4.1":return ndata.algorithm.params.pub_key=asn1.DSAparam.decode(ndata.subjectPublicKey.data,"der"),{type:"dsa",data:ndata.algorithm.params};default:throw new Error("unknown key id "+subtype)}throw new Error("unknown key type "+type);case"ENCRYPTED PRIVATE KEY":data=function(data,password){var salt=data.algorithm.decrypt.kde.kdeparams.salt,iters=parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(),10),algo=aesid[data.algorithm.decrypt.cipher.algo.join(".")],iv=data.algorithm.decrypt.cipher.iv,cipherText=data.subjectPrivateKey,keylen=parseInt(algo.split("-")[1],10)/8,key=compat.pbkdf2Sync(password,salt,iters,keylen,"sha1"),cipher=ciphers.createDecipheriv(algo,key,iv),out=[];return out.push(cipher.update(cipherText)),out.push(cipher.final()),Buffer.concat(out)}(data=asn1.EncryptedPrivateKey.decode(data,"der"),password);case"PRIVATE KEY":switch(subtype=(ndata=asn1.PrivateKey.decode(data,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:ndata.algorithm.curve,privateKey:asn1.ECPrivateKey.decode(ndata.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return ndata.algorithm.params.priv_key=asn1.DSAparam.decode(ndata.subjectPrivateKey,"der"),{type:"dsa",params:ndata.algorithm.params};default:throw new Error("unknown key id "+subtype)}throw new Error("unknown key type "+type);case"RSA PUBLIC KEY":return asn1.RSAPublicKey.decode(data,"der");case"RSA PRIVATE KEY":return asn1.RSAPrivateKey.decode(data,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:asn1.DSAPrivateKey.decode(data,"der")};case"EC PRIVATE KEY":return{curve:(data=asn1.ECPrivateKey.decode(data,"der")).parameters.value,privateKey:data.privateKey};default:throw new Error("unknown key type "+type)}}module.exports=parseKeys,parseKeys.signature=asn1.signature},{"./aesid.json":111,"./asn1":112,"./fixProc":114,"browserify-aes":25,pbkdf2:116,"safe-buffer":151}],116:[function(require,module,exports){exports.pbkdf2=require("./lib/async"),exports.pbkdf2Sync=require("./lib/sync")},{"./lib/async":117,"./lib/sync":120}],117:[function(require,module,exports){(function(process,global){var ZERO_BUF,checkParameters=require("./precondition"),defaultEncoding=require("./default-encoding"),sync=require("./sync"),Buffer=require("safe-buffer").Buffer,subtle=global.crypto&&global.crypto.subtle,toBrowser={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"},checks=[];function browserPbkdf2(password,salt,iterations,length,algo){return subtle.importKey("raw",password,{name:"PBKDF2"},!1,["deriveBits"]).then((function(key){return subtle.deriveBits({name:"PBKDF2",salt:salt,iterations:iterations,hash:{name:algo}},key,length<<3)})).then((function(res){return Buffer.from(res)}))}module.exports=function(password,salt,iterations,keylen,digest,callback){"function"==typeof digest&&(callback=digest,digest=void 0);var algo=toBrowser[(digest=digest||"sha1").toLowerCase()];if(!algo||"function"!=typeof global.Promise)return process.nextTick((function(){var out;try{out=sync(password,salt,iterations,keylen,digest)}catch(e){return callback(e)}callback(null,out)}));if(checkParameters(password,salt,iterations,keylen),"function"!=typeof callback)throw new Error("No callback provided to pbkdf2");Buffer.isBuffer(password)||(password=Buffer.from(password,defaultEncoding)),Buffer.isBuffer(salt)||(salt=Buffer.from(salt,defaultEncoding)),function(promise,callback){promise.then((function(out){process.nextTick((function(){callback(null,out)}))}),(function(e){process.nextTick((function(){callback(e)}))}))}(function(algo){if(global.process&&!global.process.browser)return Promise.resolve(!1);if(!subtle||!subtle.importKey||!subtle.deriveBits)return Promise.resolve(!1);if(void 0!==checks[algo])return checks[algo];var prom=browserPbkdf2(ZERO_BUF=ZERO_BUF||Buffer.alloc(8),ZERO_BUF,10,128,algo).then((function(){return!0})).catch((function(){return!1}));return checks[algo]=prom,prom}(algo).then((function(resp){return resp?browserPbkdf2(password,salt,iterations,keylen,algo):sync(password,salt,iterations,keylen,digest)})),callback)}}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":118,"./precondition":119,"./sync":120,_process:122,"safe-buffer":151}],118:[function(require,module,exports){(function(process){var defaultEncoding;process.browser?defaultEncoding="utf-8":defaultEncoding=parseInt(process.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";module.exports=defaultEncoding}).call(this,require("_process"))},{_process:122}],119:[function(require,module,exports){(function(Buffer){var MAX_ALLOC=Math.pow(2,30)-1;function checkBuffer(buf,name){if("string"!=typeof buf&&!Buffer.isBuffer(buf))throw new TypeError(name+" must be a buffer or string")}module.exports=function(password,salt,iterations,keylen){if(checkBuffer(password,"Password"),checkBuffer(salt,"Salt"),"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")}}).call(this,{isBuffer:require("../../is-buffer/index.js")})},{"../../is-buffer/index.js":104}],120:[function(require,module,exports){var md5=require("create-hash/md5"),RIPEMD160=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?function(data){return(new RIPEMD160).update(data).digest()}:"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.length<blocksize&&(key=Buffer.concat([key,ZEROS],blocksize));for(var ipad=Buffer.allocUnsafe(blocksize+sizes[alg]),opad=Buffer.allocUnsafe(blocksize+sizes[alg]),i=0;i<blocksize;i++)ipad[i]=54^key[i],opad[i]=92^key[i];var ipad1=Buffer.allocUnsafe(blocksize+saltLen+4);ipad.copy(ipad1,0,0,blocksize),this.ipad1=ipad1,this.ipad2=ipad,this.opad=opad,this.alg=alg,this.blocksize=blocksize,this.hash=hash,this.size=sizes[alg]}Hmac.prototype.run=function(data,ipad){return data.copy(ipad,this.blocksize),this.hash(ipad).copy(this.opad,this.blocksize),this.hash(this.opad)},module.exports=function(password,salt,iterations,keylen,digest){checkParameters(password,salt,iterations,keylen),Buffer.isBuffer(password)||(password=Buffer.from(password,defaultEncoding)),Buffer.isBuffer(salt)||(salt=Buffer.from(salt,defaultEncoding));var hmac=new Hmac(digest=digest||"sha1",password,salt.length),DK=Buffer.allocUnsafe(keylen),block1=Buffer.allocUnsafe(salt.length+4);salt.copy(block1,0,0,salt.length);for(var destPos=0,hLen=sizes[digest],l=Math.ceil(keylen/hLen),i=1;i<=l;i++){block1.writeUInt32BE(i,salt.length);for(var T=hmac.run(block1,hmac.ipad1),U=T,j=1;j<iterations;j++){U=hmac.run(U,hmac.ipad2);for(var k=0;k<hLen;k++)T[k]^=U[k]}T.copy(DK,destPos),destPos+=hLen}return DK}},{"./default-encoding":118,"./precondition":119,"create-hash/md5":56,ripemd160:150,"safe-buffer":151,"sha.js":153}],121:[function(require,module,exports){(function(process){"use strict";void 0===process||!process.version||0===process.version.indexOf("v0.")||0===process.version.indexOf("v1.")&&0!==process.version.indexOf("v1.8.")?module.exports={nextTick:function(fn,arg1,arg2,arg3){if("function"!=typeof fn)throw new TypeError('"callback" argument must be a function');var args,i,len=arguments.length;switch(len){case 0:case 1:return process.nextTick(fn);case 2:return process.nextTick((function(){fn.call(null,arg1)}));case 3:return process.nextTick((function(){fn.call(null,arg1,arg2)}));case 4:return process.nextTick((function(){fn.call(null,arg1,arg2,arg3)}));default:for(args=new Array(len-1),i=0;i<args.length;)args[i++]=arguments[i];return process.nextTick((function(){fn.apply(null,args)}))}}}:module.exports=process}).call(this,require("_process"))},{_process:122}],122:[function(require,module,exports){var cachedSetTimeout,cachedClearTimeout,process=module.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(fun){if(cachedSetTimeout===setTimeout)return setTimeout(fun,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(fun,0);try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=runTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex<len;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,len=queue.length}currentQueue=null,draining=!1,function(marker){if(cachedClearTimeout===clearTimeout)return clearTimeout(marker);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(marker);try{cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}(timeout)}}function Item(fun,array){this.fun=fun,this.array=array}function noop(){}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)args[i-1]=arguments[i];queue.push(new Item(fun,args)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(name){return[]},process.binding=function(name){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(dir){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],123:[function(require,module,exports){exports.publicEncrypt=require("./publicEncrypt"),exports.privateDecrypt=require("./privateDecrypt"),exports.privateEncrypt=function(key,buf){return exports.publicEncrypt(key,buf,!0)},exports.publicDecrypt=function(key,buf){return exports.privateDecrypt(key,buf,!0)}},{"./privateDecrypt":125,"./publicEncrypt":126}],124:[function(require,module,exports){var createHash=require("create-hash"),Buffer=require("safe-buffer").Buffer;function i2ops(c){var out=Buffer.allocUnsafe(4);return out.writeUInt32BE(c,0),out}module.exports=function(seed,len){for(var c,t=Buffer.alloc(0),i=0;t.length<len;)c=i2ops(i++),t=Buffer.concat([t,createHash("sha1").update(seed).update(c).digest()]);return t.slice(0,len)}},{"create-hash":55,"safe-buffer":151}],125:[function(require,module,exports){var parseKeys=require("parse-asn1"),mgf=require("./mgf"),xor=require("./xor"),BN=require("bn.js"),crt=require("browserify-rsa"),createHash=require("create-hash"),withPublic=require("./withPublic"),Buffer=require("safe-buffer").Buffer;module.exports=function(privateKey,enc,reverse){var padding;padding=privateKey.padding?privateKey.padding:reverse?1:4;var msg,key=parseKeys(privateKey),k=key.modulus.byteLength();if(enc.length>k||new BN(enc).cmp(key.modulus)>=0)throw new Error("decryption error");msg=reverse?withPublic(new BN(enc),key):crt(enc,key);var zBuffer=Buffer.alloc(k-msg.length);if(msg=Buffer.concat([zBuffer,msg],k),4===padding)return function(key,msg){var k=key.modulus.byteLength(),iHash=createHash("sha1").update(Buffer.alloc(0)).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=Buffer.from(a),b=Buffer.from(b);var dif=0,len=a.length;a.length!==b.length&&(dif++,len=Math.min(a.length,b.length));var i=-1;for(;++i<len;)dif+=a[i]^b[i];return dif}(iHash,db.slice(0,hLen)))throw new Error("decryption error");var i=hLen;for(;0===db[i];)i++;if(1!==db[i++])throw new Error("decryption error");return db.slice(i)}(key,msg);if(1===padding)return function(key,msg,reverse){var p1=msg.slice(0,2),i=2,status=0;for(;0!==msg[i++];)if(i>=msg.length){status++;break}var ps=msg.slice(2,i-1);("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")}},{"./mgf":124,"./withPublic":127,"./xor":128,"bn.js":20,"browserify-rsa":43,"create-hash":55,"parse-asn1":115,"safe-buffer":151}],126:[function(require,module,exports){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"),Buffer=require("safe-buffer").Buffer;module.exports=function(publicKey,msg,reverse){var padding;padding=publicKey.padding?publicKey.padding:reverse?1:4;var paddedMsg,key=parseKeys(publicKey);if(4===padding)paddedMsg=function(key,msg){var k=key.modulus.byteLength(),mLen=msg.length,iHash=createHash("sha1").update(Buffer.alloc(0)).digest(),hLen=iHash.length,hLen2=2*hLen;if(mLen>k-hLen2-2)throw new Error("message too long");var ps=Buffer.alloc(k-mLen-hLen2-2),dblen=k-hLen-1,seed=randomBytes(hLen),maskedDb=xor(Buffer.concat([iHash,ps,Buffer.alloc(1,1),msg],dblen),mgf(seed,dblen)),maskedSeed=xor(seed,mgf(maskedDb,hLen));return new BN(Buffer.concat([Buffer.alloc(1),maskedSeed,maskedDb],k))}(key,msg);else if(1===padding)paddedMsg=function(key,msg,reverse){var ps,mLen=msg.length,k=key.modulus.byteLength();if(mLen>k-11)throw new Error("message too long");ps=reverse?Buffer.alloc(k-mLen-3,255):function(len){var num,out=Buffer.allocUnsafe(len),i=0,cache=randomBytes(2*len),cur=0;for(;i<len;)cur===cache.length&&(cache=randomBytes(2*len),cur=0),(num=cache[cur++])&&(out[i++]=num);return out}(k-mLen-3);return new BN(Buffer.concat([Buffer.from([0,reverse?1:2]),ps,Buffer.alloc(1),msg],k))}(key,msg,reverse);else{if(3!==padding)throw new Error("unknown padding");if((paddedMsg=new BN(msg)).cmp(key.modulus)>=0)throw new Error("data too long for modulus")}return reverse?crt(paddedMsg,key):withPublic(paddedMsg,key)}},{"./mgf":124,"./withPublic":127,"./xor":128,"bn.js":20,"browserify-rsa":43,"create-hash":55,"parse-asn1":115,randombytes:133,"safe-buffer":151}],127:[function(require,module,exports){var BN=require("bn.js"),Buffer=require("safe-buffer").Buffer;module.exports=function(paddedMsg,key){return Buffer.from(paddedMsg.toRed(BN.mont(key.modulus)).redPow(new BN(key.publicExponent)).fromRed().toArray())}},{"bn.js":20,"safe-buffer":151}],128:[function(require,module,exports){module.exports=function(a,b){for(var len=a.length,i=-1;++i<len;)a[i]^=b[i];return a}},{}],129:[function(require,module,exports){(function(global){!function(root){var freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule="object"==typeof module&&module&&!module.nodeType&&module,freeGlobal="object"==typeof global&&global;freeGlobal.global!==freeGlobal&&freeGlobal.window!==freeGlobal&&freeGlobal.self!==freeGlobal||(root=freeGlobal);var punycode,key,maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\x20-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 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="";return parts.length>1&&(result=parts[0]+"@",string=parts[1]),result+map((string=string.replace(regexSeparators,".")).split("."),fn).join(".")}function ucs2decode(string){for(var value,extra,output=[],counter=0,length=string.length;counter<length;)(value=string.charCodeAt(counter++))>=55296&&value<=56319&&counter<length?56320==(64512&(extra=string.charCodeAt(counter++)))?output.push(((1023&value)<<10)+(1023&extra)+65536):(output.push(value),counter--):output.push(value);return output}function ucs2encode(array){return map(array,(function(value){var output="";return value>65535&&(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,codePoint,output=[],inputLength=input.length,i=0,n=initialN,bias=initialBias;for((basic=input.lastIndexOf(delimiter))<0&&(basic=0),j=0;j<basic;++j)input.charCodeAt(j)>=128&&error("not-basic"),output.push(input.charCodeAt(j));for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;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)}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<inputLength;++j)(currentValue=input[j])<128&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push(delimiter);handledCPCount<inputLength;){for(m=maxInt,j=0;j<inputLength;++j)(currentValue=input[j])>=n&¤tValue<m&&(m=currentValue);for(m-n>floor((maxInt-delta)/(handledCPCountPlusOne=handledCPCount+1))&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;j<inputLength;++j)if((currentValue=input[j])<n&&++delta>maxInt&&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:{})},{}],130:[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<len;++i){var kstr,vstr,k,v,x=qs[i].replace(regexp,"%20"),idx=x.indexOf(eq);idx>=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)}},{}],131:[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;i<xs.length;i++)res.push(f(xs[i],i));return res}var objectKeys=Object.keys||function(obj){var res=[];for(var key in obj)Object.prototype.hasOwnProperty.call(obj,key)&&res.push(key);return res}},{}],132:[function(require,module,exports){"use strict";exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode")},{"./decode":130,"./encode":131}],133:[function(require,module,exports){(function(process,global){"use strict";var MAX_BYTES=65536,MAX_UINT32=4294967295;var Buffer=require("safe-buffer").Buffer,crypto=global.crypto||global.msCrypto;crypto&&crypto.getRandomValues?module.exports=function(size,cb){if(size>MAX_UINT32)throw new RangeError("requested too many random bytes");var bytes=Buffer.allocUnsafe(size);if(size>0)if(size>MAX_BYTES)for(var generated=0;generated<size;generated+=MAX_BYTES)crypto.getRandomValues(bytes.slice(generated,generated+MAX_BYTES));else crypto.getRandomValues(bytes);if("function"==typeof cb)return process.nextTick((function(){cb(null,bytes)}));return bytes}:module.exports=function(){throw new Error("Secure random number generation is 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:122,"safe-buffer":151}],134:[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")}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)}))}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)}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:122,randombytes:133,"safe-buffer":151}],135:[function(require,module,exports){module.exports=require("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":136}],136:[function(require,module,exports){"use strict";var pna=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;v<keys.length;v++){var method=keys[v];Duplex.prototype[method]||(Duplex.prototype[method]=Writable.prototype[method])}function Duplex(options){if(!(this instanceof Duplex))return new Duplex(options);Readable.call(this,options),Writable.call(this,options),options&&!1===options.readable&&(this.readable=!1),options&&!1===options.writable&&(this.writable=!1),this.allowHalfOpen=!0,options&&!1===options.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",onend)}function onend(){this.allowHalfOpen||this._writableState.ended||pna.nextTick(onEndNT,this)}function onEndNT(self){self.end()}Object.defineProperty(Duplex.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(Duplex.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(value){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=value,this._writableState.destroyed=value)}}),Duplex.prototype._destroy=function(err,cb){this.push(null),this.end(),pna.nextTick(cb,err)}},{"./_stream_readable":138,"./_stream_writable":140,"core-util-is":53,inherits:103,"process-nextick-args":121}],137:[function(require,module,exports){"use strict";module.exports=PassThrough;var Transform=require("./_stream_transform"),util=require("core-util-is");function PassThrough(options){if(!(this instanceof PassThrough))return new PassThrough(options);Transform.call(this,options)}util.inherits=require("inherits"),util.inherits(PassThrough,Transform),PassThrough.prototype._transform=function(chunk,encoding,cb){cb(null,chunk)}},{"./_stream_transform":139,"core-util-is":53,inherits:103}],138:[function(require,module,exports){(function(process,global){"use strict";var pna=require("process-nextick-args");module.exports=Readable;var Duplex,isArray=require("isarray");Readable.ReadableState=ReadableState;require("events").EventEmitter;var EElistenerCount=function(emitter,type){return emitter.listeners(type).length},Stream=require("./internal/streams/stream"),Buffer=require("safe-buffer").Buffer,OurUint8Array=global.Uint8Array||function(){};var util=require("core-util-is");util.inherits=require("inherits");var debugUtil=require("util"),debug=void 0;debug=debugUtil&&debugUtil.debuglog?debugUtil.debuglog("stream"):function(){};var StringDecoder,BufferList=require("./internal/streams/BufferList"),destroyImpl=require("./internal/streams/destroy");util.inherits(Readable,Stream);var kProxyEvents=["error","close","destroy","pause","resume"];function ReadableState(options,stream){options=options||{};var isDuplex=stream instanceof(Duplex=Duplex||require("./_stream_duplex"));this.objectMode=!!options.objectMode,isDuplex&&(this.objectMode=this.objectMode||!!options.readableObjectMode);var hwm=options.highWaterMark,readableHwm=options.readableHighWaterMark,defaultHwm=this.objectMode?16:16384;this.highWaterMark=hwm||0===hwm?hwm:isDuplex&&(readableHwm||0===readableHwm)?readableHwm:defaultHwm,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new BufferList,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=options.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,options.encoding&&(StringDecoder||(StringDecoder=require("string_decoder/").StringDecoder),this.decoder=new StringDecoder(options.encoding),this.encoding=options.encoding)}function Readable(options){if(Duplex=Duplex||require("./_stream_duplex"),!(this instanceof Readable))return new Readable(options);this._readableState=new ReadableState(options,this),this.readable=!0,options&&("function"==typeof options.read&&(this._read=options.read),"function"==typeof options.destroy&&(this._destroy=options.destroy)),Stream.call(this)}function readableAddChunk(stream,chunk,encoding,addToFront,skipChunkCheck){var er,state=stream._readableState;null===chunk?(state.reading=!1,function(stream,state){if(state.ended)return;if(state.decoder){var chunk=state.decoder.end();chunk&&chunk.length&&(state.buffer.push(chunk),state.length+=state.objectMode?1:chunk.length)}state.ended=!0,emitReadable(stream)}(stream,state)):(skipChunkCheck||(er=function(state,chunk){var er;obj=chunk,Buffer.isBuffer(obj)||obj instanceof OurUint8Array||"string"==typeof chunk||void 0===chunk||state.objectMode||(er=new TypeError("Invalid non-string/buffer chunk"));var obj;return er}(state,chunk)),er?stream.emit("error",er):state.objectMode||chunk&&chunk.length>0?("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.length<state.highWaterMark||0===state.length)}(state)}function addChunk(stream,state,chunk,addToFront){state.flowing&&0===state.length&&!state.sync?(stream.emit("data",chunk),stream.read(0)):(state.length+=state.objectMode?1:chunk.length,addToFront?state.buffer.unshift(chunk):state.buffer.push(chunk),state.needReadable&&emitReadable(stream)),maybeReadMore(stream,state)}Object.defineProperty(Readable.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(value){this._readableState&&(this._readableState.destroyed=value)}}),Readable.prototype.destroy=destroyImpl.destroy,Readable.prototype._undestroy=destroyImpl.undestroy,Readable.prototype._destroy=function(err,cb){this.push(null),cb(err)},Readable.prototype.push=function(chunk,encoding){var skipChunkCheck,state=this._readableState;return state.objectMode?skipChunkCheck=!0:"string"==typeof chunk&&((encoding=encoding||state.defaultEncoding)!==state.encoding&&(chunk=Buffer.from(chunk,encoding),encoding=""),skipChunkCheck=!0),readableAddChunk(this,chunk,encoding,!1,skipChunkCheck)},Readable.prototype.unshift=function(chunk){return readableAddChunk(this,chunk,null,!0,!1)},Readable.prototype.isPaused=function(){return!1===this._readableState.flowing},Readable.prototype.setEncoding=function(enc){return StringDecoder||(StringDecoder=require("string_decoder/").StringDecoder),this._readableState.decoder=new StringDecoder(enc),this._readableState.encoding=enc,this};var MAX_HWM=8388608;function howMuchToRead(n,state){return n<=0||0===state.length&&state.ended?0:state.objectMode?1:n!=n?state.flowing&&state.length?state.buffer.head.data.length:state.length:(n>state.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))}function emitReadable(stream){var state=stream._readableState;state.needReadable=!1,state.emittedReadable||(debug("emitReadable",state.flowing),state.emittedReadable=!0,state.sync?pna.nextTick(emitReadable_,stream):emitReadable_(stream))}function emitReadable_(stream){debug("emit readable"),stream.emit("readable"),flow(stream)}function maybeReadMore(stream,state){state.readingMore||(state.readingMore=!0,pna.nextTick(maybeReadMore_,stream,state))}function maybeReadMore_(stream,state){for(var len=state.length;!state.reading&&!state.flowing&&!state.ended&&state.length<state.highWaterMark&&(debug("maybeReadMore read 0"),stream.read(0),len!==state.length);)len=state.length;state.readingMore=!1}function nReadingNextTick(self){debug("readable nexttick read 0"),self.read(0)}function resume_(stream,state){state.reading||(debug("resume read 0"),stream.read(0)),state.resumeScheduled=!1,state.awaitDrain=0,stream.emit("resume"),flow(stream),state.flowing&&!state.reading&&stream.read(0)}function flow(stream){var state=stream._readableState;for(debug("flow",state.flowing);state.flowing&&null!==stream.read(););}function fromList(n,state){return 0===state.length?null:(state.objectMode?ret=state.buffer.shift():!n||n>=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;n<list.head.data.length?(ret=list.head.data.slice(0,n),list.head.data=list.head.data.slice(n)):ret=n===list.head.data.length?list.shift():hasStrings?function(n,list){var p=list.head,c=1,ret=p.data;n-=ret.length;for(;p=p.next;){var str=p.data,nb=n>str.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);var 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,pna.nextTick(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<l;i++)if(xs[i]===x)return i;return-1}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 ret,doRead=state.needReadable;return debug("need readable",doRead),(0===state.length||state.length-n<state.highWaterMark)&&debug("length less than watermark",doRead=!0),state.ended||state.reading?debug("reading or ended",doRead=!1):doRead&&(debug("do read"),state.reading=!0,state.sync=!0,0===state.length&&(state.needReadable=!0),this._read(state.highWaterMark),state.sync=!1,state.reading||(n=howMuchToRead(nOrig,state))),null===(ret=n>0?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},Readable.prototype._read=function(n){this.emit("error",new Error("_read() is not implemented"))},Readable.prototype.pipe=function(dest,pipeOpts){var src=this,state=this._readableState;switch(state.pipesCount){case 0:state.pipes=dest;break;case 1:state.pipes=[state.pipes,dest];break;default:state.pipes.push(dest)}state.pipesCount+=1,debug("pipe count=%d opts=%j",state.pipesCount,pipeOpts);var endFn=(!pipeOpts||!1!==pipeOpts.end)&&dest!==process.stdout&&dest!==process.stderr?onend:unpipe;function onunpipe(readable,unpipeInfo){debug("onunpipe"),readable===src&&unpipeInfo&&!1===unpipeInfo.hasUnpiped&&(unpipeInfo.hasUnpiped=!0,debug("cleanup"),dest.removeListener("close",onclose),dest.removeListener("finish",onfinish),dest.removeListener("drain",ondrain),dest.removeListener("error",onerror),dest.removeListener("unpipe",onunpipe),src.removeListener("end",onend),src.removeListener("end",unpipe),src.removeListener("data",ondata),cleanedUp=!0,!state.awaitDrain||dest._writableState&&!dest._writableState.needDrain||ondrain())}function onend(){debug("onend"),dest.end()}state.endEmitted?pna.nextTick(endFn):src.once("end",endFn),dest.on("unpipe",onunpipe);var ondrain=function(src){return function(){var state=src._readableState;debug("pipeOnDrain",state.awaitDrain),state.awaitDrain&&state.awaitDrain--,0===state.awaitDrain&&EElistenerCount(src,"data")&&(state.flowing=!0,flow(src))}}(src);dest.on("drain",ondrain);var cleanedUp=!1;var increasedAwaitDrain=!1;function ondata(chunk){debug("ondata"),increasedAwaitDrain=!1,!1!==dest.write(chunk)||increasedAwaitDrain||((1===state.pipesCount&&state.pipes===dest||state.pipesCount>1&&-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 onclose(){dest.removeListener("finish",onfinish),unpipe()}function onfinish(){debug("onfinish"),dest.removeListener("close",onclose),unpipe()}function unpipe(){debug("unpipe"),src.unpipe(dest)}return src.on("data",ondata),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),dest.once("close",onclose),dest.once("finish",onfinish),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<len;i++)dests[i].emit("unpipe",this,unpipeInfo);return this}var index=indexOf(state.pipes,dest);return-1===index?this:(state.pipes.splice(index,1),state.pipesCount-=1,1===state.pipesCount&&(state.pipes=state.pipes[0]),dest.emit("unpipe",this,unpipeInfo),this)},Readable.prototype.on=function(ev,fn){var res=Stream.prototype.on.call(this,ev,fn);if("data"===ev)!1!==this._readableState.flowing&&this.resume();else if("readable"===ev){var state=this._readableState;state.endEmitted||state.readableListening||(state.readableListening=state.needReadable=!0,state.emittedReadable=!1,state.reading?state.length&&emitReadable(this):pna.nextTick(nReadingNextTick,this))}return res},Readable.prototype.addListener=Readable.prototype.on,Readable.prototype.resume=function(){var state=this._readableState;return state.flowing||(debug("resume"),state.flowing=!0,function(stream,state){state.resumeScheduled||(state.resumeScheduled=!0,pna.nextTick(resume_,stream,state))}(this,state)),this},Readable.prototype.pause=function(){return debug("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(debug("pause"),this._readableState.flowing=!1,this.emit("pause")),this},Readable.prototype.wrap=function(stream){var _this=this,state=this._readableState,paused=!1;for(var i in stream.on("end",(function(){if(debug("wrapped end"),state.decoder&&!state.ended){var chunk=state.decoder.end();chunk&&chunk.length&&_this.push(chunk)}_this.push(null)})),stream.on("data",(function(chunk){(debug("wrapped data"),state.decoder&&(chunk=state.decoder.write(chunk)),state.objectMode&&null==chunk)||(state.objectMode||chunk&&chunk.length)&&(_this.push(chunk)||(paused=!0,stream.pause()))})),stream)void 0===this[i]&&"function"==typeof stream[i]&&(this[i]=function(method){return function(){return stream[method].apply(stream,arguments)}}(i));for(var n=0;n<kProxyEvents.length;n++)stream.on(kProxyEvents[n],this.emit.bind(this,kProxyEvents[n]));return this._read=function(n){debug("wrapped _read",n),paused&&(paused=!1,stream.resume())},this},Object.defineProperty(Readable.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Readable._fromList=fromList}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":136,"./internal/streams/BufferList":141,"./internal/streams/destroy":142,"./internal/streams/stream":143,_process:122,"core-util-is":53,events:86,inherits:103,isarray:105,"process-nextick-args":121,"safe-buffer":144,"string_decoder/":145,util:22}],139:[function(require,module,exports){"use strict";module.exports=Transform;var Duplex=require("./_stream_duplex"),util=require("core-util-is");function afterTransform(er,data){var ts=this._transformState;ts.transforming=!1;var cb=ts.writecb;if(!cb)return this.emit("error",new Error("write callback called multiple times"));ts.writechunk=null,ts.writecb=null,null!=data&&this.push(data),cb(er);var rs=this._readableState;rs.reading=!1,(rs.needReadable||rs.length<rs.highWaterMark)&&this._read(rs.highWaterMark)}function Transform(options){if(!(this instanceof Transform))return new Transform(options);Duplex.call(this,options),this._transformState={afterTransform:afterTransform.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,options&&("function"==typeof options.transform&&(this._transform=options.transform),"function"==typeof options.flush&&(this._flush=options.flush)),this.on("prefinish",prefinish)}function prefinish(){var _this=this;"function"==typeof this._flush?this._flush((function(er,data){done(_this,er,data)})):done(this,null,null)}function done(stream,er,data){if(er)return stream.emit("error",er);if(null!=data&&stream.push(data),stream._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(stream._transformState.transforming)throw new Error("Calling transform done when still transforming");return stream.push(null)}util.inherits=require("inherits"),util.inherits(Transform,Duplex),Transform.prototype.push=function(chunk,encoding){return this._transformState.needTransform=!1,Duplex.prototype.push.call(this,chunk,encoding)},Transform.prototype._transform=function(chunk,encoding,cb){throw new Error("_transform() is not implemented")},Transform.prototype._write=function(chunk,encoding,cb){var ts=this._transformState;if(ts.writecb=cb,ts.writechunk=chunk,ts.writeencoding=encoding,!ts.transforming){var rs=this._readableState;(ts.needTransform||rs.needReadable||rs.length<rs.highWaterMark)&&this._read(rs.highWaterMark)}},Transform.prototype._read=function(n){var ts=this._transformState;null!==ts.writechunk&&ts.writecb&&!ts.transforming?(ts.transforming=!0,this._transform(ts.writechunk,ts.writeencoding,ts.afterTransform)):ts.needTransform=!0},Transform.prototype._destroy=function(err,cb){var _this2=this;Duplex.prototype._destroy.call(this,err,(function(err2){cb(err2),_this2.emit("close")}))}},{"./_stream_duplex":136,"core-util-is":53,inherits:103}],140:[function(require,module,exports){(function(process,global,setImmediate){"use strict";var pna=require("process-nextick-args");function CorkedRequest(state){var _this=this;this.next=null,this.entry=null,this.finish=function(){!function(corkReq,state,err){var entry=corkReq.entry;corkReq.entry=null;for(;entry;){var cb=entry.callback;state.pendingcb--,cb(err),entry=entry.next}state.corkedRequestsFree?state.corkedRequestsFree.next=corkReq:state.corkedRequestsFree=corkReq}(_this,state)}}module.exports=Writable;var Duplex,asyncWrite=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:pna.nextTick;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 realHasInstance,destroyImpl=require("./internal/streams/destroy");function nop(){}function WritableState(options,stream){Duplex=Duplex||require("./_stream_duplex"),options=options||{};var isDuplex=stream instanceof Duplex;this.objectMode=!!options.objectMode,isDuplex&&(this.objectMode=this.objectMode||!!options.writableObjectMode);var hwm=options.highWaterMark,writableHwm=options.writableHighWaterMark,defaultHwm=this.objectMode?16:16384;this.highWaterMark=hwm||0===hwm?hwm:isDuplex&&(writableHwm||0===writableHwm)?writableHwm: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?(pna.nextTick(cb,er),pna.nextTick(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)}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)}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),state.bufferedRequestCount=0}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.bufferedRequestCount--,state.writing)break}null===entry&&(state.lastBufferedRequest=null)}state.bufferedRequest=entry,state.bufferProcessing=!1}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,pna.nextTick(callFinal,stream,state)):(state.prefinished=!0,stream.emit("prefinish")))}(stream,state),0===state.pendingcb&&(state.finished=!0,stream.emit("finish"))),need}util.inherits(Writable,Stream),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(_){}}(),"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)||this===Writable&&(object&&object._writableState instanceof WritableState)}})):realHasInstance=function(object){return object instanceof 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=!state.objectMode&&(obj=chunk,Buffer.isBuffer(obj)||obj instanceof OurUint8Array);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),pna.nextTick(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),pna.nextTick(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<state.highWaterMark;ret||(state.needDrain=!0);if(state.writing||state.corked){var last=state.lastBufferedRequest;state.lastBufferedRequest={chunk:chunk,encoding:encoding,isBuf:isBuf,callback:cb,next:null},last?last.next=state.lastBufferedRequest:state.bufferedRequest=state.lastBufferedRequest,state.bufferedRequestCount+=1}else doWrite(stream,state,!1,len,chunk,encoding,cb);return ret}(this,state,isBuf,chunk,encoding,cb)),ret},Writable.prototype.cork=function(){this._writableState.corked++},Writable.prototype.uncork=function(){var state=this._writableState;state.corked&&(state.corked--,state.writing||state.corked||state.finished||state.bufferProcessing||!state.bufferedRequest||clearBuffer(this,state))},Writable.prototype.setDefaultEncoding=function(encoding){if("string"==typeof encoding&&(encoding=encoding.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((encoding+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+encoding);return this._writableState.defaultEncoding=encoding,this},Object.defineProperty(Writable.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),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&&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?pna.nextTick(cb):stream.once("finish",cb));state.ended=!0,stream.writable=!1}(this,state,cb)},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:{},require("timers").setImmediate)},{"./_stream_duplex":136,"./internal/streams/destroy":142,"./internal/streams/stream":143,_process:122,"core-util-is":53,inherits:103,"process-nextick-args":121,"safe-buffer":144,timers:162,"util-deprecate":165}],141:[function(require,module,exports){"use strict";var Buffer=require("safe-buffer").Buffer,util=require("util");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 src,target,offset,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;return ret},BufferList}(),util&&util.inspect&&util.inspect.custom&&(module.exports.prototype[util.inspect.custom]=function(){var obj=util.inspect({length:this.length});return this.constructor.name+" "+obj})},{"safe-buffer":144,util:22}],142:[function(require,module,exports){"use strict";var pna=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;return readableDestroyed||writableDestroyed?(cb?cb(err):!err||this._writableState&&this._writableState.errorEmitted||pna.nextTick(emitErrorNT,this,err),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(err||null,(function(err){!cb&&err?(pna.nextTick(emitErrorNT,_this,err),_this._writableState&&(_this._writableState.errorEmitted=!0)):cb&&cb(err)})),this)},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":121}],143:[function(require,module,exports){module.exports=require("events").EventEmitter},{events:86}],144:[function(require,module,exports){var buffer=require("buffer"),Buffer=buffer.Buffer;function copyProps(src,dst){for(var key in src)dst[key]=src[key]}function SafeBuffer(arg,encodingOrOffset,length){return Buffer(arg,encodingOrOffset,length)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer),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:51}],145:[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}};function StringDecoder(encoding){var nb;switch(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),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)}function utf8CheckByte(byte){return byte<=127?0:byte>>5==6?2:byte>>4==14?3:byte>>3==30?4:byte>>6==2?-1:-2}function utf8FillLast(buf){var p=this.lastTotal-this.lastNeed,r=function(self,buf,p){if(128!=(192&buf[0]))return self.lastNeed=0,"�";if(self.lastNeed>1&&buf.length>1){if(128!=(192&buf[1]))return self.lastNeed=1,"�";if(self.lastNeed>2&&buf.length>2&&128!=(192&buf[2]))return self.lastNeed=2,"�"}}(this,buf);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):""}exports.StringDecoder=StringDecoder,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<buf.length?r?r+this.text(buf,i):this.text(buf,i):r||""},StringDecoder.prototype.end=function(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+"�":r},StringDecoder.prototype.text=function(buf,i){var total=function(self,buf,i){var j=buf.length-1;if(j<i)return 0;var nb=utf8CheckByte(buf[j]);if(nb>=0)return nb>0&&(self.lastNeed=nb-1),nb;if(--j<i||-2===nb)return 0;if((nb=utf8CheckByte(buf[j]))>=0)return nb>0&&(self.lastNeed=nb-2),nb;if(--j<i||-2===nb)return 0;if((nb=utf8CheckByte(buf[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}},{"safe-buffer":144}],146:[function(require,module,exports){module.exports=require("./readable").PassThrough},{"./readable":147}],147:[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":136,"./lib/_stream_passthrough.js":137,"./lib/_stream_readable.js":138,"./lib/_stream_transform.js":139,"./lib/_stream_writable.js":140}],148:[function(require,module,exports){module.exports=require("./readable").Transform},{"./readable":147}],149:[function(require,module,exports){module.exports=require("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":140}],150:[function(require,module,exports){"use strict";var Buffer=require("buffer").Buffer,inherits=require("inherits"),HashBase=require("hash-base"),ARRAY16=new Array(16),zl=[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],zr=[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],sl=[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],sr=[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],hl=[0,1518500249,1859775393,2400959708,2840853838],hr=[1352829926,1548603684,1836072691,2053994217,0];function RIPEMD160(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function rotl(x,n){return x<<n|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}inherits(RIPEMD160,HashBase),RIPEMD160.prototype._update=function(){for(var words=ARRAY16,j=0;j<16;++j)words[j]=this._block.readInt32LE(4*j);for(var al=0|this._a,bl=0|this._b,cl=0|this._c,dl=0|this._d,el=0|this._e,ar=0|this._a,br=0|this._b,cr=0|this._c,dr=0|this._d,er=0|this._e,i=0;i<80;i+=1){var tl,tr;i<16?(tl=fn1(al,bl,cl,dl,el,words[zl[i]],hl[0],sl[i]),tr=fn5(ar,br,cr,dr,er,words[zr[i]],hr[0],sr[i])):i<32?(tl=fn2(al,bl,cl,dl,el,words[zl[i]],hl[1],sl[i]),tr=fn4(ar,br,cr,dr,er,words[zr[i]],hr[1],sr[i])):i<48?(tl=fn3(al,bl,cl,dl,el,words[zl[i]],hl[2],sl[i]),tr=fn3(ar,br,cr,dr,er,words[zr[i]],hr[2],sr[i])):i<64?(tl=fn4(al,bl,cl,dl,el,words[zl[i]],hl[3],sl[i]),tr=fn2(ar,br,cr,dr,er,words[zr[i]],hr[3],sr[i])):(tl=fn5(al,bl,cl,dl,el,words[zl[i]],hl[4],sl[i]),tr=fn1(ar,br,cr,dr,er,words[zr[i]],hr[4],sr[i])),al=el,el=dl,dl=rotl(cl,10),cl=bl,bl=tl,ar=er,er=dr,dr=rotl(cr,10),cr=br,br=tr}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=Buffer.alloc?Buffer.alloc(20):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},module.exports=RIPEMD160},{buffer:51,"hash-base":88,inherits:103}],151:[function(require,module,exports){var buffer=require("buffer"),Buffer=buffer.Buffer;function copyProps(src,dst){for(var key in src)dst[key]=src[key]}function SafeBuffer(arg,encodingOrOffset,length){return Buffer(arg,encodingOrOffset,length)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(Buffer.prototype),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:51}],152:[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<length;){for(var assigned=accum%blockSize,remainder=Math.min(length-offset,blockSize-assigned),i=0;i<remainder;i++)block[assigned+i]=data[offset+i];offset+=remainder,(accum+=remainder)%blockSize==0&&this._update(block)}return this._len+=length,this},Hash.prototype.digest=function(enc){var rem=this._len%this._blockSize;this._block[rem]=128,this._block.fill(0,rem+1),rem>=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)>>>0,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":151}],153:[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":154,"./sha1":155,"./sha224":156,"./sha256":157,"./sha384":158,"./sha512":159}],154:[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)}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}inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha.prototype._update=function(M){for(var num,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)<<5|num>>>27)+ft(s,b,c,d)+e+W[j]+K[s];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},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":152,inherits:103,"safe-buffer":151}],155:[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)}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}inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha1.prototype._update=function(M){for(var num,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])<<1|num>>>31;for(var 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":152,inherits:103,"safe-buffer":151}],156:[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":152,"./sha256":157,inherits:103,"safe-buffer":151}],157:[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)}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}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},Sha256.prototype._update=function(M){for(var x,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])>>>17|x<<15)^(x>>>19|x<<13)^x>>>10)+W[i-7]+gamma0(W[i-15])+W[i-16];for(var 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":152,inherits:103,"safe-buffer":151}],158:[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":152,"./sha512":159,inherits:103,"safe-buffer":151}],159:[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)}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<b>>>0?1:0}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},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":152,inherits:103,"safe-buffer":151}],160:[function(require,module,exports){module.exports=Stream;var EE=require("events").EventEmitter;function Stream(){EE.call(this)}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,Stream.prototype.pipe=function(dest,options){var source=this;function ondata(chunk){dest.writable&&!1===dest.write(chunk)&&source.pause&&source.pause()}function ondrain(){source.readable&&source.resume&&source.resume()}source.on("data",ondata),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}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("error",onerror),dest.on("error",onerror),source.on("end",cleanup),source.on("close",cleanup),dest.on("close",cleanup),dest.emit("pipe",source),dest}},{events:86,inherits:103,"readable-stream/duplex.js":135,"readable-stream/passthrough.js":146,"readable-stream/readable.js":147,"readable-stream/transform.js":148,"readable-stream/writable.js":149}],161:[function(require,module,exports){arguments[4][145][0].apply(exports,arguments)},{dup:145,"safe-buffer":151}],162:[function(require,module,exports){(function(setImmediate,clearImmediate){var nextTick=require("process/browser.js").nextTick,apply=Function.prototype.apply,slice=Array.prototype.slice,immediateIds={},nextImmediateId=0;function Timeout(id,clearFn){this._id=id,this._clearFn=clearFn}exports.setTimeout=function(){return new Timeout(apply.call(setTimeout,window,arguments),clearTimeout)},exports.setInterval=function(){return new Timeout(apply.call(setInterval,window,arguments),clearInterval)},exports.clearTimeout=exports.clearInterval=function(timeout){timeout.close()},Timeout.prototype.unref=Timeout.prototype.ref=function(){},Timeout.prototype.close=function(){this._clearFn.call(window,this._id)},exports.enroll=function(item,msecs){clearTimeout(item._idleTimeoutId),item._idleTimeout=msecs},exports.unenroll=function(item){clearTimeout(item._idleTimeoutId),item._idleTimeout=-1},exports._unrefActive=exports.active=function(item){clearTimeout(item._idleTimeoutId);var msecs=item._idleTimeout;msecs>=0&&(item._idleTimeoutId=setTimeout((function(){item._onTimeout&&item._onTimeout()}),msecs))},exports.setImmediate="function"==typeof setImmediate?setImmediate:function(fn){var id=nextImmediateId++,args=!(arguments.length<2)&&slice.call(arguments,1);return immediateIds[id]=!0,nextTick((function(){immediateIds[id]&&(args?fn.apply(null,args):fn.call(null),exports.clearImmediate(id))})),id},exports.clearImmediate="function"==typeof clearImmediate?clearImmediate:function(id){delete immediateIds[id]}}).call(this,require("timers").setImmediate,require("timers").clearImmediate)},{"process/browser.js":122,timers:162}],163:[function(require,module,exports){"use strict";var punycode=require("punycode"),util=require("./util");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}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;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&&queryIndex<url.indexOf("#")?"?":"#",uSplit=url.split(splitter);uSplit[0]=uSplit[0].replace(/\\/g,"/");var rest=url=uSplit.join(splitter);if(rest=rest.trim(),!slashesDenoteHost&&1===url.split("#").length){var simplePath=simplePathPattern.exec(rest);if(simplePath)return this.path=rest,this.href=rest,this.pathname=simplePath[1],simplePath[2]?(this.search=simplePath[2],this.query=parseQueryString?querystring.parse(this.search.substr(1)):this.search.substr(1)):parseQueryString&&(this.search="",this.query={}),this}var proto=protocolPattern.exec(rest);if(proto){var lowerProto=(proto=proto[0]).toLowerCase();this.protocol=lowerProto,rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\/\/[^@\/]+@[^@\/]+/)){var slashes="//"===rest.substr(0,2);!slashes||proto&&hostlessProtocol[proto]||(rest=rest.substr(2),this.slashes=!0)}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){for(var auth,atSign,hostEnd=-1,i=0;i<hostEndingChars.length;i++){-1!==(hec=rest.indexOf(hostEndingChars[i]))&&(-1===hostEnd||hec<hostEnd)&&(hostEnd=hec)}-1!==(atSign=-1===hostEnd?rest.lastIndexOf("@"):rest.lastIndexOf("@",hostEnd))&&(auth=rest.slice(0,atSign),rest=rest.slice(atSign+1),this.auth=decodeURIComponent(auth)),hostEnd=-1;for(i=0;i<nonHostChars.length;i++){var hec;-1!==(hec=rest.indexOf(nonHostChars[i]))&&(-1===hostEnd||hec<hostEnd)&&(hostEnd=hec)}-1===hostEnd&&(hostEnd=rest.length),this.host=rest.slice(0,hostEnd),rest=rest.slice(hostEnd),this.parseHost(),this.hostname=this.hostname||"";var ipv6Hostname="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!ipv6Hostname)for(var hostparts=this.hostname.split(/\./),l=(i=0,hostparts.length);i<l;i++){var part=hostparts[i];if(part&&!part.match(hostnamePartPattern)){for(var newpart="",j=0,k=part.length;j<k;j++)part.charCodeAt(j)>127?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;i<l;i++){var ae=autoEscape[i];if(-1!==rest.indexOf(ae)){var esc=encodeURIComponent(ae);esc===ae&&(esc=escape(ae)),rest=rest.split(ae).join(esc)}}var hash=rest.indexOf("#");-1!==hash&&(this.hash=rest.substr(hash),rest=rest.slice(0,hash));var qm=rest.indexOf("?");if(-1!==qm?(this.search=rest.substr(qm),this.query=rest.substr(qm+1),parseQueryString&&(this.query=querystring.parse(this.query)),rest=rest.slice(0,qm)):parseQueryString&&(this.search="",this.query={}),rest&&(this.pathname=rest),slashedProtocol[lowerProto]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){p=this.pathname||"";var s=this.search||"";this.path=p+s}return this.href=this.format(),this},Url.prototype.format=function(){var auth=this.auth||"";auth&&(auth=(auth=encodeURIComponent(auth)).replace(/%3A/i,":"),auth+="@");var protocol=this.protocol||"",pathname=this.pathname||"",hash=this.hash||"",host=!1,query="";this.host?host=auth+this.host:this.hostname&&(host=auth+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(host+=":"+this.port)),this.query&&util.isObject(this.query)&&Object.keys(this.query).length&&(query=querystring.stringify(this.query));var search=this.search||query&&"?"+query||"";return protocol&&":"!==protocol.substr(-1)&&(protocol+=":"),this.slashes||(!protocol||slashedProtocol[protocol])&&!1!==host?(host="//"+(host||""),pathname&&"/"!==pathname.charAt(0)&&(pathname="/"+pathname)):host||(host=""),hash&&"#"!==hash.charAt(0)&&(hash="#"+hash),search&&"?"!==search.charAt(0)&&(search="?"+search),protocol+host+(pathname=pathname.replace(/[?#]/g,(function(match){return encodeURIComponent(match)})))+(search=search.replace("#","%23"))+hash},Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,!1,!0)).format()},Url.prototype.resolveObject=function(relative){if(util.isString(relative)){var rel=new Url;rel.parse(relative,!1,!0),relative=rel}for(var result=new Url,tkeys=Object.keys(this),tk=0;tk<tkeys.length;tk++){var tkey=tkeys[tk];result[tkey]=this[tkey]}if(result.hash=relative.hash,""===relative.href)return result.href=result.format(),result;if(relative.slashes&&!relative.protocol){for(var rkeys=Object.keys(relative),rk=0;rk<rkeys.length;rk++){var rkey=rkeys[rk];"protocol"!==rkey&&(result[rkey]=relative[rkey])}return slashedProtocol[result.protocol]&&result.hostname&&!result.pathname&&(result.path=result.pathname="/"),result.href=result.format(),result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){for(var keys=Object.keys(relative),v=0;v<keys.length;v++){var k=keys[v];result[k]=relative[k]}return result.href=result.format(),result}if(result.protocol=relative.protocol,relative.host||hostlessProtocol[relative.protocol])result.pathname=relative.pathname;else{for(var relPath=(relative.pathname||"").split("/");relPath.length&&!(relative.host=relPath.shift()););relative.host||(relative.host=""),relative.hostname||(relative.hostname=""),""!==relPath[0]&&relPath.unshift(""),relPath.length<2&&relPath.unshift(""),result.pathname=relPath.join("/")}if(result.search=relative.search,result.query=relative.query,result.host=relative.host||"",result.auth=relative.auth,result.hostname=relative.hostname||relative.host,result.port=relative.port,result.pathname||result.search){var p=result.pathname||"",s=result.search||"";result.path=p+s}return result.slashes=result.slashes||relative.slashes,result.href=result.format(),result}var isSourceAbs=result.pathname&&"/"===result.pathname.charAt(0),isRelAbs=relative.host||relative.pathname&&"/"===relative.pathname.charAt(0),mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split("/")||[],psychotic=(relPath=relative.pathname&&relative.pathname.split("/")||[],result.protocol&&!slashedProtocol[result.protocol]);if(psychotic&&(result.hostname="",result.port=null,result.host&&(""===srcPath[0]?srcPath[0]=result.host:srcPath.unshift(result.host)),result.host="",relative.protocol&&(relative.hostname=null,relative.port=null,relative.host&&(""===relPath[0]?relPath[0]=relative.host:relPath.unshift(relative.host)),relative.host=null),mustEndAbs=mustEndAbs&&(""===relPath[0]||""===srcPath[0])),isRelAbs)result.host=relative.host||""===relative.host?relative.host:result.host,result.hostname=relative.hostname||""===relative.hostname?relative.hostname:result.hostname,result.search=relative.search,result.query=relative.query,srcPath=relPath;else if(relPath.length)srcPath||(srcPath=[]),srcPath.pop(),srcPath=srcPath.concat(relPath),result.search=relative.search,result.query=relative.query;else if(!util.isNullOrUndefined(relative.search)){if(psychotic)result.hostname=result.host=srcPath.shift(),(authInHost=!!(result.host&&result.host.indexOf("@")>0)&&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 authInHost,isAbsolute=""===srcPath[0]||srcPath[0]&&"/"===srcPath[0].charAt(0);psychotic&&(result.hostname=result.host=isAbsolute?"":srcPath.length?srcPath.shift():"",(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":164,punycode:129,querystring:132}],164:[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}}},{}],165:[function(require,module,exports){(function(global){function config(name){try{if(!global.localStorage)return!1}catch(_){return!1}var val=global.localStorage[name];return null!=val&&"true"===String(val).toLowerCase()}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)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],166:[function(require,module,exports){var indexOf=function(xs,item){if(xs.indexOf)return xs.indexOf(item);for(var i=0;i<xs.length;i++)if(xs[i]===item)return i;return-1},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<xs.length;i++)fn(xs[i],i,xs)},defineProp=function(){try{return Object.defineProperty({},"_",{}),function(obj,name,value){Object.defineProperty(obj,name,{writable:!0,enumerable:!1,configurable:!0,value:value})}}catch(e){return function(obj,name,value){obj[name]=value}}}(),globals=["Array","Boolean","Date","Error","EvalError","Function","Infinity","JSON","Math","NaN","Number","Object","RangeError","ReferenceError","RegExp","String","SyntaxError","TypeError","URIError","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","eval","isFinite","isNaN","parseFloat","parseInt","undefined","unescape"];function Context(){}Context.prototype={};var Script=exports.Script=function(code){if(!(this instanceof Script))return new Script(code);this.code=code};Script.prototype.runInContext=function(context){if(!(context instanceof Context))throw new TypeError("needs a 'context' argument.");var iframe=document.createElement("iframe");iframe.style||(iframe.style={}),iframe.style.display="none",document.body.appendChild(iframe);var win=iframe.contentWindow,wEval=win.eval,wExecScript=win.execScript;!wEval&&wExecScript&&(wExecScript.call(win,"null"),wEval=win.eval),forEach(Object_keys(context),(function(key){win[key]=context[key]})),forEach(globals,(function(key){context[key]&&(win[key]=context[key])}));var winKeys=Object_keys(win),res=wEval.call(win,this.code);return forEach(Object_keys(win),(function(key){(key in context||-1===indexOf(winKeys,key))&&(context[key]=win[key])})),forEach(globals,(function(key){key in context||defineProp(context,key,win[key])})),document.body.removeChild(iframe),res},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInNewContext=function(context){var ctx=Script.createContext(context),res=this.runInContext(ctx);return context&&forEach(Object_keys(ctx),(function(key){context[key]=ctx[key]})),res},forEach(Object_keys(Script.prototype),(function(name){exports[name]=Script[name]=function(code){var s=Script(code);return s[name].apply(s,[].slice.call(arguments,1))}})),exports.isContext=function(context){return context instanceof Context},exports.createScript=function(code){return exports.Script(code)},exports.createContext=Script.createContext=function(context){var copy=new Context;return"object"==typeof context&&forEach(Object_keys(context),(function(key){copy[key]=context[key]})),copy}},{}],167:[function(require,module,exports){const{getMultiSignAddress:getMultiSignAddress,getAddress:getAddress,getDid:getDid}=require("./src/Address"),{getMasterPrivateKey:getMasterPrivateKey,getMasterPublicKey:getMasterPublicKey,getBip32ExtendedPrivateKey:getBip32ExtendedPrivateKey,getBip32ExtendedPublicKey:getBip32ExtendedPublicKey,getAccountExtendedPrivateKey:getAccountExtendedPrivateKey,getAccountExtendedPublicKey:getAccountExtendedPublicKey,getDerivedPrivateKey:getDerivedPrivateKey,getDerivedPublicKey:getDerivedPublicKey,getSinglePrivateKey:getSinglePrivateKey,getSinglePublicKey:getSinglePublicKey,getPublicKeyFromPrivateKey:getPublicKeyFromPrivateKey,generateSubPrivateKey:generateSubPrivateKey,generateSubPublicKey:generateSubPublicKey,getIdChainMasterPublicKey:getIdChainMasterPublicKey,generateIdChainSubPrivateKey:generateIdChainSubPrivateKey,generateIdChainSubPublicKey:generateIdChainSubPublicKey,sign:sign,verify:verify}=require("./src/Api");module.exports={getMultiSignAddress:getMultiSignAddress,getAddress:getAddress,getDid:getDid,getMasterPrivateKey:getMasterPrivateKey,getMasterPublicKey:getMasterPublicKey,getBip32ExtendedPrivateKey:getBip32ExtendedPrivateKey,getBip32ExtendedPublicKey:getBip32ExtendedPublicKey,getAccountExtendedPrivateKey:getAccountExtendedPrivateKey,getAccountExtendedPublicKey:getAccountExtendedPublicKey,getDerivedPrivateKey:getDerivedPrivateKey,getDerivedPublicKey:getDerivedPublicKey,getSinglePrivateKey:getSinglePrivateKey,getSinglePublicKey:getSinglePublicKey,getPublicKeyFromPrivateKey:getPublicKeyFromPrivateKey,generateSubPrivateKey:generateSubPrivateKey,generateSubPublicKey:generateSubPublicKey,getIdChainMasterPublicKey:getIdChainMasterPublicKey,generateIdChainSubPrivateKey:generateIdChainSubPrivateKey,generateIdChainSubPublicKey:generateIdChainSubPublicKey,sign:sign,verify:verify}},{"./src/Address":256,"./src/Api":257}],168:[function(require,module,exports){const Buffer=require("safe-buffer").Buffer;module.exports=function(ALPHABET){if(ALPHABET.length>=255)throw new TypeError("Alphabet too long");const BASE_MAP=new Uint8Array(256);BASE_MAP.fill(255);for(let i=0;i<ALPHABET.length;i++){const x=ALPHABET.charAt(i),xc=x.charCodeAt(0);if(255!==BASE_MAP[xc])throw new TypeError(x+" is ambiguous");BASE_MAP[xc]=i}const BASE=ALPHABET.length,LEADER=ALPHABET.charAt(0),FACTOR=Math.log(BASE)/Math.log(256),iFACTOR=Math.log(256)/Math.log(BASE);function decodeUnsafe(source){if("string"!=typeof source)throw new TypeError("Expected String");if(0===source.length)return Buffer.alloc(0);let psz=0;if(" "===source[psz])return;let zeroes=0,length=0;for(;source[psz]===LEADER;)zeroes++,psz++;const size=(source.length-psz)*FACTOR+1>>>0,b256=new Uint8Array(size);for(;source[psz];){let carry=BASE_MAP[source.charCodeAt(psz)];if(255===carry)return;let i=0;for(let it=size-1;(0!==carry||i<length)&&-1!==it;it--,i++)carry+=BASE*b256[it]>>>0,b256[it]=carry%256>>>0,carry=carry/256>>>0;if(0!==carry)throw new Error("Non-zero carry");length=i,psz++}if(" "===source[psz])return;let it=size-length;for(;it!==size&&0===b256[it];)it++;const vch=Buffer.allocUnsafe(zeroes+(size-it));vch.fill(0,0,zeroes);let j=zeroes;for(;it!==size;)vch[j++]=b256[it++];return vch}return{encode:function(source){if(!Buffer.isBuffer(source))throw new TypeError("Expected Buffer");if(0===source.length)return"";let zeroes=0,length=0,pbegin=0;const pend=source.length;for(;pbegin!==pend&&0===source[pbegin];)pbegin++,zeroes++;const size=(pend-pbegin)*iFACTOR+1>>>0,b58=new Uint8Array(size);for(;pbegin!==pend;){let carry=source[pbegin],i=0;for(let it=size-1;(0!==carry||i<length)&&-1!==it;it--,i++)carry+=256*b58[it]>>>0,b58[it]=carry%BASE>>>0,carry=carry/BASE>>>0;if(0!==carry)throw new Error("Non-zero carry");length=i,pbegin++}let it=size-length;for(;it!==size&&0===b58[it];)it++;let str=LEADER.repeat(zeroes);for(;it<size;++it)str+=ALPHABET.charAt(b58[it]);return str},decodeUnsafe:decodeUnsafe,decode:function(string){const buffer=decodeUnsafe(string);if(buffer)return buffer;throw new Error("Non-base"+BASE+" character")}}}},{"safe-buffer":255}],169:[function(require,module,exports){(function(global,Buffer){"use strict";var bitcore=module.exports;bitcore.version="v"+require("./package.json").version,bitcore.versionGuard=function(version){if(void 0!==version){throw new Error("More than one instance of bitcore-lib found. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency.")}},bitcore.versionGuard(global._bitcore),global._bitcore=bitcore.version,bitcore.crypto={},bitcore.crypto.BN=require("./lib/crypto/bn"),bitcore.crypto.ECDSA=require("./lib/crypto/ecdsa"),bitcore.crypto.Hash=require("./lib/crypto/hash"),bitcore.crypto.Random=require("./lib/crypto/random"),bitcore.crypto.Point=require("./lib/crypto/point"),bitcore.crypto.Signature=require("./lib/crypto/signature"),bitcore.encoding={},bitcore.encoding.Base58=require("./lib/encoding/base58"),bitcore.encoding.Base58Check=require("./lib/encoding/base58check"),bitcore.encoding.BufferReader=require("./lib/encoding/bufferreader"),bitcore.encoding.BufferWriter=require("./lib/encoding/bufferwriter"),bitcore.encoding.Varint=require("./lib/encoding/varint"),bitcore.util={},bitcore.util.buffer=require("./lib/util/buffer"),bitcore.util.js=require("./lib/util/js"),bitcore.util.preconditions=require("./lib/util/preconditions"),bitcore.errors=require("./lib/errors"),bitcore.Address=require("./lib/address"),bitcore.Block=require("./lib/block"),bitcore.MerkleBlock=require("./lib/block/merkleblock"),bitcore.BlockHeader=require("./lib/block/blockheader"),bitcore.HDPrivateKey=require("./lib/hdprivatekey.js"),bitcore.HDPublicKey=require("./lib/hdpublickey.js"),bitcore.Networks=require("./lib/networks"),bitcore.Opcode=require("./lib/opcode"),bitcore.PrivateKey=require("./lib/privatekey"),bitcore.PublicKey=require("./lib/publickey"),bitcore.Script=require("./lib/script"),bitcore.Transaction=require("./lib/transaction"),bitcore.URI=require("./lib/uri"),bitcore.Unit=require("./lib/unit"),bitcore.deps={},bitcore.deps.bnjs=require("bn.js"),bitcore.deps.bs58=require("bs58"),bitcore.deps.Buffer=Buffer,bitcore.deps.elliptic=require("elliptic"),bitcore.deps._=require("lodash"),bitcore.Transaction.sighash=require("./lib/transaction/sighash")}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},require("buffer").Buffer)},{"./lib/address":170,"./lib/block":173,"./lib/block/blockheader":172,"./lib/block/merkleblock":174,"./lib/crypto/bn":175,"./lib/crypto/ecdsa":176,"./lib/crypto/hash":177,"./lib/crypto/point":178,"./lib/crypto/random":179,"./lib/crypto/signature":180,"./lib/encoding/base58":181,"./lib/encoding/base58check":182,"./lib/encoding/bufferreader":183,"./lib/encoding/bufferwriter":184,"./lib/encoding/varint":185,"./lib/errors":186,"./lib/hdprivatekey.js":188,"./lib/hdpublickey.js":189,"./lib/networks":190,"./lib/opcode":191,"./lib/privatekey":192,"./lib/publickey":193,"./lib/script":194,"./lib/transaction":197,"./lib/transaction/sighash":205,"./lib/unit":210,"./lib/uri":211,"./lib/util/buffer":212,"./lib/util/js":213,"./lib/util/preconditions":214,"./package.json":216,"bn.js":217,bs58:219,buffer:51,elliptic:221,lodash:252}],170:[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?Buffer.from(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.");var networkObj=Networks.get(network),bufferVersion=Address._classifyFromVersion(buffer);if(network&&!networkObj)throw new TypeError("Unknown network");if(!bufferVersion.network||networkObj&&networkObj!==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,nestedWitness){network=network||publicKeys[0].network||Networks.defaultNetwork;var redeemScript=Script.buildMultisigOut(publicKeys,threshold);return nestedWitness?Address.payingTo(Script.buildWitnessMultisigOutFromScript(redeemScript),network):Address.payingTo(redeemScript,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){var info=Address._transformHash(hash);return new Address(info.hashBuffer,network,Address.PayToPublicKeyHash)},Address.fromScriptHash=function(hash,network){$.checkArgument(hash,"hash parameter is required");var info=Address._transformHash(hash);return new Address(info.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){return $.checkState(JSUtil.isHexa(obj.hash),'Unexpected hash property, "'+obj.hash+'", expected to be hex.'),new Address(Buffer.from(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=Buffer.from([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"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"},module.exports=Address;var Script=require("./script")}).call(this,require("buffer").Buffer)},{"./crypto/hash":177,"./encoding/base58check":182,"./errors":186,"./networks":190,"./publickey":193,"./script":194,"./util/js":213,"./util/preconditions":214,buffer:51,lodash:252}],171:[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=[];return data.transactions.forEach((function(tx){tx instanceof Transaction?transactions.push(tx):transactions.push(Transaction().fromObject(tx))})),{header:BlockHeader.fromObject(data.header),transactions:transactions}},Block.fromObject=function(obj){var info=Block._fromObject(obj);return new Block(info)},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;i<transactions;i++)info.transactions.push(Transaction().fromBufferReader(br));return info},Block.fromBufferReader=function(br){$.checkArgument(br,"br is required");var info=Block._fromBufferReader(br);return new Block(info)},Block.fromBuffer=function(buf){return Block.fromBufferReader(new BufferReader(buf))},Block.fromString=function(str){var buf=Buffer.from(str,"hex");return Block.fromBuffer(buf)},Block.fromRawBlock=function(data){BufferUtil.isBuffer(data)||(data=Buffer.from(data,"binary"));var br=BufferReader(data);br.pos=Block.Values.START_OF_BLOCK;var info=Block._fromBufferReader(br);return new Block(info)},Block.prototype.toObject=Block.prototype.toJSON=function(){var transactions=[];return this.transactions.forEach((function(tx){transactions.push(tx.toObject())})),{header:this.header.toObject(),transactions:transactions}},Block.prototype.toBuffer=function(){return this.toBufferWriter().concat()},Block.prototype.toString=function(){return this.toBuffer().toString("hex")},Block.prototype.toBufferWriter=function(bw){bw||(bw=new BufferWriter),bw.write(this.header.toBuffer()),bw.writeVarintNum(this.transactions.length);for(var i=0;i<this.transactions.length;i++)this.transactions[i].toBufferWriter(bw);return bw},Block.prototype.getTransactionHashes=function(){var hashes=[];if(0===this.transactions.length)return[Block.Values.NULL_HASH];for(var t=0;t<this.transactions.length;t++)hashes.push(this.transactions[t]._getHash());return hashes},Block.prototype.getMerkleTree=function(){for(var tree=this.getTransactionHashes(),j=0,size=this.transactions.length;size>1;size=Math.floor((size+1)/2)){for(var i=0;i<size;i+=2){var i2=Math.min(i+1,size-1),buf=Buffer.concat([tree[j+i],tree[j+i2]]);tree.push(Hash.sha256sha256(buf))}j+=size}return tree},Block.prototype.getMerkleRoot=function(){var tree=this.getMerkleTree();return tree[tree.length-1]},Block.prototype.validMerkleRoot=function(){var h=new BN(this.header.merkleRoot.toString("hex"),"hex"),c=new BN(this.getMerkleRoot().toString("hex"),"hex");return 0===h.cmp(c)},Block.prototype._getHash=function(){return this.header._getHash()};var idProperty={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=this.header.id),this._id},set:_.noop};Object.defineProperty(Block.prototype,"id",idProperty),Object.defineProperty(Block.prototype,"hash",idProperty),Block.prototype.inspect=function(){return"<Block "+this.id+">"},Block.Values={START_OF_BLOCK:8,NULL_HASH:Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex")},module.exports=Block}).call(this,require("buffer").Buffer)},{"../crypto/bn":175,"../crypto/hash":177,"../encoding/bufferreader":183,"../encoding/bufferwriter":184,"../transaction":197,"../util/buffer":212,"../util/preconditions":214,"./blockheader":172,buffer:51,lodash:252}],172:[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;return _.isString(data.prevHash)&&(prevHash=BufferUtil.reverse(Buffer.from(data.prevHash,"hex"))),_.isString(data.merkleRoot)&&(merkleRoot=BufferUtil.reverse(Buffer.from(data.merkleRoot,"hex"))),{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=Buffer.from(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=Buffer.from(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 "+this.id+">"},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":175,"../crypto/hash":177,"../encoding/bufferreader":183,"../encoding/bufferwriter":184,"../util/buffer":212,"../util/js":213,"../util/preconditions":214,buffer:51,lodash:252}],173:[function(require,module,exports){module.exports=require("./block"),module.exports.BlockHeader=require("./blockheader"),module.exports.MerkleBlock=require("./merkleblock")},{"./block":171,"./blockheader":172,"./merkleblock":174}],174:[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")),errors=require("../errors"),$=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;i<this.hashes.length;i++)bw.write(Buffer.from(this.hashes[i],"hex"));for(bw.writeVarintNum(this.flags.length),i=0;i<this.flags.length;i++)bw.writeUInt8(this.flags[i]);return bw},MerkleBlock.prototype.toObject=MerkleBlock.prototype.toJSON=function(){return{header:this.header.toObject(),numTransactions:this.numTransactions,hashes:this.hashes,flags:this.flags}},MerkleBlock.prototype.validMerkleTree=function(){if($.checkState(_.isArray(this.flags),"MerkleBlock flags is not an array"),$.checkState(_.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)return!1;if(8*this.flags.length<this.hashes.length)return!1;var height=this._calcTreeHeight(),opts={hashesUsed:0,flagBitsUsed:0},root=this._traverseMerkleTree(height,0,opts);return opts.hashesUsed===this.hashes.length&&BufferUtil.equals(root,this.header.merkleRoot)},MerkleBlock.prototype.filterdTxsHash=function(){if($.checkState(_.isArray(this.flags),"MerkleBlock flags is not an array"),$.checkState(_.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)throw new errors.MerkleBlock.InvalidMerkleTree;if(8*this.flags.length<this.hashes.length)throw new errors.MerkleBlock.InvalidMerkleTree;if(1===this.hashes.length)return[];var height=this._calcTreeHeight(),opts={hashesUsed:0,flagBitsUsed:0},txs=this._traverseMerkleTree(height,0,opts,!0);if(opts.hashesUsed!==this.hashes.length)throw new errors.MerkleBlock.InvalidMerkleTree;return txs},MerkleBlock.prototype._traverseMerkleTree=function(depth,pos,opts,checkForTxs){(opts=opts||{}).txs=opts.txs||[],opts.flagBitsUsed=opts.flagBitsUsed||0,opts.hashesUsed=opts.hashesUsed||0;checkForTxs=checkForTxs||!1;if(opts.flagBitsUsed>8*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._calcTreeWidth(depth-1)&&(right=this._traverseMerkleTree(depth-1,2*pos+1,opts)),checkForTxs?opts.txs:Hash.sha256sha256(new Buffer.concat([left,right]))}if(opts.hashesUsed>=this.hashes.length)return null;var hash=this.hashes[opts.hashesUsed++];return 0===depth&&isParentOfMatch&&opts.txs.push(hash),Buffer.from(hash,"hex")},MerkleBlock.prototype._calcTreeWidth=function(height){return this.numTransactions+(1<<height)-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(Buffer.from(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;i<numHashes;i++)info.hashes.push(br.read(32).toString("hex"));var numFlags=br.readVarintNum();for(info.flags=[],i=0;i<numFlags;i++)info.flags.push(br.readUInt8());return info},MerkleBlock.fromObject=function(obj){return new MerkleBlock(obj)},module.exports=MerkleBlock}).call(this,require("buffer").Buffer)},{"../crypto/hash":177,"../encoding/bufferreader":183,"../encoding/bufferwriter":184,"../errors":186,"../transaction":197,"../util/buffer":212,"../util/js":213,"../util/preconditions":214,"./blockheader":172,buffer:51,lodash:252}],175:[function(require,module,exports){(function(Buffer){"use strict";var BN=require("bn.js"),$=require("../util/preconditions"),_=require("lodash"),reversebuf=function(buf){for(var buf2=Buffer.alloc(buf.length),i=0;i<buf.length;i++)buf2[i]=buf[buf.length-1-i];return buf2};BN.Zero=new BN(0),BN.One=new BN(1),BN.Minus1=new BN(-1),BN.fromNumber=function(n){return $.checkArgument(_.isNumber(n)),new BN(n)},BN.fromString=function(str,base){return $.checkArgument(_.isString(str)),new BN(str,base)},BN.fromBuffer=function(buf,opts){void 0!==opts&&"little"===opts.endian&&(buf=reversebuf(buf));var hex=buf.toString("hex");return new BN(hex,16)},BN.fromSM=function(buf,opts){var ret;if(0===buf.length)return BN.fromBuffer(Buffer.from([0]));var endian="big";return opts&&(endian=opts.endian),"little"===endian&&(buf=reversebuf(buf)),128&buf[0]?(buf[0]=127&buf[0],(ret=BN.fromBuffer(buf)).neg().copy(ret)):ret=BN.fromBuffer(buf),ret},BN.prototype.toNumber=function(){return parseInt(this.toString(10),10)},BN.prototype.toBuffer=function(opts){var buf,hex;if(opts&&opts.size){var natlen=(hex=this.toString(16,2)).length/2;buf=Buffer.from(hex,"hex"),natlen===opts.size?buf=buf:natlen>opts.size?buf=BN.trim(buf,natlen):natlen<opts.size&&(buf=BN.pad(buf,natlen,opts.size))}else hex=this.toString(16,2),buf=Buffer.from(hex,"hex");return void 0!==opts&&"little"===opts.endian&&(buf=reversebuf(buf)),buf},BN.prototype.toSMBigEndian=function(){var buf;return-1===this.cmp(BN.Zero)?128&(buf=this.neg().toBuffer())[0]?buf=Buffer.concat([Buffer.from([128]),buf]):buf[0]=128|buf[0]:128&(buf=this.toBuffer())[0]&&(buf=Buffer.concat([Buffer.from([0]),buf])),1===buf.length&0===buf[0]&&(buf=Buffer.from([])),buf},BN.prototype.toSM=function(opts){var endian=opts?opts.endian:"big",buf=this.toSMBigEndian();return"little"===endian&&(buf=reversebuf(buf)),buf},BN.fromScriptNumBuffer=function(buf,fRequireMinimal,size){var nMaxNumSize=size||4;if($.checkArgument(buf.length<=nMaxNumSize,new Error("script number overflow")),fRequireMinimal&&buf.length>0&&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.trim=function(buf,natlen){return buf.slice(natlen-buf.length,buf.length)},BN.pad=function(buf,natlen,size){for(var rbuf=Buffer.alloc(size),i=0;i<buf.length;i++)rbuf[rbuf.length-1-i]=buf[buf.length-1-i];for(i=0;i<size-natlen;i++)rbuf[i]=0;return rbuf},module.exports=BN}).call(this,require("buffer").Buffer)},{"../util/preconditions":214,"bn.js":217,buffer:51,lodash:252}],176:[function(require,module,exports){(function(Buffer){"use strict";var BN=require("./bn"),Point=require("./point"),Signature=require("./signature"),PublicKey=require("../publickey"),Random=require("./random"),Hash=require("./hash"),BufferUtil=require("../util/buffer"),_=require("lodash"),$=require("../util/preconditions"),ECDSA=function ECDSA(obj){if(!(this instanceof ECDSA))return new ECDSA(obj);obj&&this.set(obj)};ECDSA.prototype.set=function(obj){return this.hashbuf=obj.hashbuf||this.hashbuf,this.endian=obj.endian||this.endian,this.privkey=obj.privkey||this.privkey,this.pubkey=obj.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),this.sig=obj.sig||this.sig,this.k=obj.k||this.k,this.verified=obj.verified||this.verified,this},ECDSA.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()},ECDSA.prototype.calci=function(){for(var i=0;i<4;i++){var Qprime;this.sig.i=i;try{Qprime=this.toPublicKey()}catch(e){console.error(e);continue}if(Qprime.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")},ECDSA.fromString=function(str){var obj=JSON.parse(str);return new ECDSA(obj)},ECDSA.prototype.randomK=function(){var k,N=Point.getN();do{k=BN.fromBuffer(Random.getRandomBuffer(32))}while(!k.lt(N)||!k.gt(BN.Zero));return this.k=k,this},ECDSA.prototype.deterministicK=function(badrs){_.isUndefined(badrs)&&(badrs=0);var v=Buffer.alloc(32);v.fill(1);var k=Buffer.alloc(32);k.fill(0);var x=this.privkey.bn.toBuffer({size:32}),hashbuf="little"===this.endian?BufferUtil.reverse(this.hashbuf):this.hashbuf;k=Hash.sha256hmac(Buffer.concat([v,Buffer.from([0]),x,hashbuf]),k),v=Hash.sha256hmac(v,k),k=Hash.sha256hmac(Buffer.concat([v,Buffer.from([1]),x,hashbuf]),k),v=Hash.sha256hmac(v,k),v=Hash.sha256hmac(v,k);for(var T=BN.fromBuffer(v),N=Point.getN(),i=0;i<badrs||!T.lt(N)||!T.gt(BN.Zero);i++)k=Hash.sha256hmac(Buffer.concat([v,Buffer.from([0])]),k),v=Hash.sha256hmac(v,k),v=Hash.sha256hmac(v,k),T=BN.fromBuffer(v);return this.k=T,this},ECDSA.prototype.toPublicKey=function(){var i=this.sig.i;$.checkArgument(0===i||1===i||2===i||3===i,new Error("i must be equal to 0, 1, 2, or 3"));var e=BN.fromBuffer(this.hashbuf),r=this.sig.r,s=this.sig.s,isYOdd=1&i,isSecondKey=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().umod(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).umod(n),u2=sinv.mul(r).umod(n),p=Point.getG().mulAdd(u1,this.pubkey.point,u2);return p.isInfinity()?"p is infinity":0!==p.getX().umod(n).cmp(r)&&"Invalid signature"},ECDSA.toLowS=function(s){return s.gt(BN.fromBuffer(Buffer.from("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.umod(N),s=k.invm(N).mul(e.add(d.mul(r))).umod(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":193,"../util/buffer":212,"../util/preconditions":214,"./bn":175,"./hash":177,"./point":178,"./random":179,"./signature":180,buffer:51,lodash:252}],177:[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<blocksize){var fill=Buffer.alloc(blocksize);fill.fill(0),key.copy(fill),key=fill}var o_key=Buffer.alloc(blocksize);o_key.fill(92);var i_key=Buffer.alloc(blocksize);i_key.fill(54);for(var o_key_pad=Buffer.alloc(blocksize),i_key_pad=Buffer.alloc(blocksize),i=0;i<blocksize;i++)o_key_pad[i]=o_key[i]^key[i],i_key_pad[i]=i_key[i]^key[i];return hashf(Buffer.concat([o_key_pad,hashf(Buffer.concat([i_key_pad,data]))]))},Hash.sha256hmac=function(data,key){return Hash.hmac(Hash.sha256,data,key)},Hash.sha512hmac=function(data,key){return Hash.hmac(Hash.sha512,data,key)}}).call(this,require("buffer").Buffer)},{"../util/buffer":212,"../util/preconditions":214,buffer:51,crypto:59}],178:[function(require,module,exports){(function(Buffer){"use strict";var BN=require("./bn"),BufferUtil=require("../util/buffer"),ec=new(0,require("elliptic").ec)("p256"),ecPoint=ec.curve.point.bind(ec.curve),ecPointFromX=ec.curve.pointFromX.bind(ec.curve),Point=function(x,y,isRed){try{var point=ecPoint(x,y,isRed)}catch(e){throw new Error("Invalid Point")}return point.validate(),point};Point.prototype=Object.getPrototypeOf(ec.curve.point()),Point.fromX=function(odd,x){try{var point=ecPointFromX(x,odd)}catch(e){throw new Error("Invalid X")}return point.validate(),point},Point.getG=function(){return ec.curve.g},Point.getN=function(){return new BN(ec.curve.n.toArray())},Point.prototype._getX=Point.prototype.getX,Point.prototype.getX=function(){return new BN(this._getX().toArray())},Point.prototype._getY=Point.prototype.getY,Point.prototype.getY=function(){return new BN(this._getY().toArray())},Point.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var p2;try{p2=ecPointFromX(this.getX(),this.getY().isOdd())}catch(e){throw new Error("Point does not lie on the curve")}if(0!==p2.y.cmp(this.y))throw new Error("Invalid y value for curve.");if(!this.mul(Point.getN()).isInfinity())throw new Error("Point times N must be infinity");return this},Point.pointToCompressed=function(point){var prefix,xbuf=point.getX().toBuffer({size:32}),ybuf=point.getY().toBuffer({size:32});return prefix=ybuf[ybuf.length-1]%2?Buffer.from([3]):Buffer.from([2]),BufferUtil.concat([prefix,xbuf])},module.exports=Point}).call(this,require("buffer").Buffer)},{"../util/buffer":212,"./bn":175,buffer:51,elliptic:221}],179:[function(require,module,exports){(function(process,Buffer){"use strict";function Random(){}Random.getRandomBuffer=function(size){return process.browser?Random.getRandomBufferBrowser(size):Random.getRandomBufferNode(size)},Random.getRandomBufferNode=function(size){return require("crypto").randomBytes(size)},Random.getRandomBufferBrowser=function(size){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");if(window.crypto&&window.crypto.getRandomValues)var crypto=window.crypto;else{if(!window.msCrypto||!window.msCrypto.getRandomValues)throw new Error("window.crypto.getRandomValues not available");crypto=window.msCrypto}var bbuf=new Uint8Array(size);return crypto.getRandomValues(bbuf),Buffer.from(bbuf)},Random.getPseudoRandomBuffer=function(size){for(var r,b=Buffer.alloc(size),i=0;i<=size;i++){0===i-4*Math.floor(i/4)?(r=4294967296*Math.random(),b[i]=255&r):b[i]=255&(r>>>=8)}return b},module.exports=Random}).call(this,require("_process"),require("buffer").Buffer)},{_process:122,buffer:51,crypto:59}],180:[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=Buffer.from(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=length<buflength?length:buflength;var rheader=buf[2];$.checkArgument(2===rheader,new Error("Integer byte for r should be 0x02"));var rlength=buf[3],rbuf=buf.slice(4,4+rlength),r=BN.fromBuffer(rbuf),rneg=0===buf[4];$.checkArgument(rlength===rbuf.length,new Error("Length of r incorrect"));var sheader=buf[4+rlength+0];$.checkArgument(2===sheader,new Error("Integer byte for s should be 0x02"));var slength=buf[4+rlength+1],sbuf=buf.slice(4+rlength+2,4+rlength+2+slength),s=BN.fromBuffer(sbuf),sneg=0===buf[4+rlength+2+2];$.checkArgument(slength===sbuf.length,new Error("Length of s incorrect"));var sumlength=4+rlength+2+slength;return $.checkArgument(length===sumlength-2,new Error("Length of signature incorrect")),{header:header,length:length,rheader:rheader,rlength:rlength,rneg:rneg,rbuf:rbuf,r:r,sheader:sheader,slength:slength,sneg:sneg,sbuf:sbuf,s:s}},Signature.prototype.toCompact=function(i,compressed){if(i="number"==typeof i?i:this.i,compressed="boolean"==typeof compressed?compressed:this.compressed,0!==i&&1!==i&&2!==i&&3!==i)throw new Error("i must be equal to 0, 1, 2, or 3");var val=i+27+4;!1===compressed&&(val-=4);var b1=Buffer.from([val]),b2=this.r.toBuffer({size:32}),b3=this.s.toBuffer({size:32});return Buffer.concat([b1,b2,b3])},Signature.prototype.toBuffer=Signature.prototype.toDER=function(){var rnbuf=this.r.toBuffer(),snbuf=this.s.toBuffer(),rneg=!!(128&rnbuf[0]),sneg=!!(128&snbuf[0]),rbuf=rneg?Buffer.concat([Buffer.from([0]),rnbuf]):rnbuf,sbuf=sneg?Buffer.concat([Buffer.from([0]),snbuf]):snbuf,rlength=rbuf.length,slength=sbuf.length,length=2+rlength+2+slength;return Buffer.concat([Buffer.from([48,length,2,rlength]),rbuf,Buffer.from([2,slength]),sbuf])},Signature.prototype.toString=function(){return this.toDER().toString("hex")},Signature.isTxDER=function(buf){if(buf.length<9)return!1;if(buf.length>73)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!(temp<Signature.SIGHASH_ALL||temp>Signature.SIGHASH_SINGLE)},Signature.prototype.toTxFormat=function(){var derbuf=this.toDER(),buf=Buffer.alloc(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_ANYONECANPAY=128,module.exports=Signature}).call(this,require("buffer").Buffer)},{"../util/buffer":212,"../util/js":213,"../util/preconditions":214,"./bn":175,buffer:51,lodash:252}],181:[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 Buffer.from(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:219,buffer:51,lodash:252}],182:[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=Buffer.from(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=Buffer.alloc(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":177,"./base58":181,buffer:51,lodash:252}],183:[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))this.set({buf:Buffer.from(buf,"hex")});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=Buffer.alloc(this.buf.length),i=0;i<buf.length;i++)buf[i]=this.buf[this.buf.length-1-i];return this.buf=buf,this},BufferReader.prototype.readReverse=function(len){_.isUndefined(len)&&(len=this.buf.length);var buf=this.buf.slice(this.pos,this.pos+len);return this.pos=this.pos+len,BufferUtil.reverse(buf)},module.exports=BufferReader}).call(this,require("buffer").Buffer)},{"../crypto/bn":175,"../util/buffer":212,"../util/preconditions":214,buffer:51,lodash:252}],184:[function(require,module,exports){(function(Buffer){"use strict";var bufferUtil=require("../util/buffer"),assert=require("assert"),BufferWriter=function BufferWriter(obj){if(!(this instanceof BufferWriter))return new BufferWriter(obj);this.bufLen=0,obj?this.set(obj):this.bufs=[]};BufferWriter.prototype.set=function(obj){return this.bufs=obj.bufs||this.bufs||[],this.bufLen=this.bufs.reduce((function(prev,buf){return prev+buf.length}),0),this},BufferWriter.prototype.toBuffer=function(){return this.concat()},BufferWriter.prototype.concat=function(){return Buffer.concat(this.bufs,this.bufLen)},BufferWriter.prototype.write=function(buf){return assert(bufferUtil.isBuffer(buf)),this.bufs.push(buf),this.bufLen+=buf.length,this},BufferWriter.prototype.writeReverse=function(buf){return assert(bufferUtil.isBuffer(buf)),this.bufs.push(bufferUtil.reverse(buf)),this.bufLen+=buf.length,this},BufferWriter.prototype.writeUInt8=function(n){var buf=Buffer.alloc(1);return buf.writeUInt8(n,0),this.write(buf),this},BufferWriter.prototype.writeUInt16BE=function(n){var buf=Buffer.alloc(2);return buf.writeUInt16BE(n,0),this.write(buf),this},BufferWriter.prototype.writeUInt16LE=function(n){var buf=Buffer.alloc(2);return buf.writeUInt16LE(n,0),this.write(buf),this},BufferWriter.prototype.writeUInt32BE=function(n){var buf=Buffer.alloc(4);return buf.writeUInt32BE(n,0),this.write(buf),this},BufferWriter.prototype.writeInt32LE=function(n){var buf=Buffer.alloc(4);return buf.writeInt32LE(n,0),this.write(buf),this},BufferWriter.prototype.writeUInt32LE=function(n){var buf=Buffer.alloc(4);return buf.writeUInt32LE(n,0),this.write(buf),this},BufferWriter.prototype.writeUInt64BEBN=function(bn){var buf=bn.toBuffer({size:8});return this.write(buf),this},BufferWriter.prototype.writeUInt64LEBN=function(bn){var buf=bn.toBuffer({size:8});return this.writeReverse(buf),this},BufferWriter.prototype.writeVarintNum=function(n){var buf=BufferWriter.varintBufNum(n);return this.write(buf),this},BufferWriter.prototype.writeVarintBN=function(bn){var buf=BufferWriter.varintBufBN(bn);return this.write(buf),this},BufferWriter.varintBufNum=function(n){var buf=void 0;return n<253?(buf=Buffer.alloc(1)).writeUInt8(n,0):n<65536?((buf=Buffer.alloc(3)).writeUInt8(253,0),buf.writeUInt16LE(n,1)):n<4294967296?((buf=Buffer.alloc(5)).writeUInt8(254,0),buf.writeUInt32LE(n,1)):((buf=Buffer.alloc(9)).writeUInt8(255,0),buf.writeInt32LE(-1&n,1),buf.writeUInt32LE(Math.floor(n/4294967296),5)),buf},BufferWriter.varintBufBN=function(bn){var buf=void 0,n=bn.toNumber();if(n<253)(buf=Buffer.alloc(1)).writeUInt8(n,0);else if(n<65536)(buf=Buffer.alloc(3)).writeUInt8(253,0),buf.writeUInt16LE(n,1);else if(n<4294967296)(buf=Buffer.alloc(5)).writeUInt8(254,0),buf.writeUInt32LE(n,1);else{var bw=new BufferWriter;bw.writeUInt8(255),bw.writeUInt64LEBN(bn);buf=bw.concat()}return buf},module.exports=BufferWriter}).call(this,require("buffer").Buffer)},{"../util/buffer":212,assert:15,buffer:51}],185:[function(require,module,exports){(function(Buffer){"use strict";var BufferWriter=require("./bufferwriter"),BufferReader=require("./bufferreader"),BN=require("../crypto/bn"),Varint=function Varint(buf){if(!(this instanceof Varint))return new Varint(buf);if(Buffer.isBuffer(buf))this.buf=buf;else if("number"==typeof buf){var num=buf;this.fromNumber(num)}else if(buf instanceof BN){var bn=buf;this.fromBN(bn)}else if(buf){var obj=buf;this.set(obj)}};Varint.prototype.set=function(obj){return this.buf=obj.buf||this.buf,this},Varint.prototype.fromString=function(str){return this.set({buf:Buffer.from(str,"hex")}),this},Varint.prototype.toString=function(){return this.buf.toString("hex")},Varint.prototype.fromBuffer=function(buf){return this.buf=buf,this},Varint.prototype.fromBufferReader=function(br){return this.buf=br.readVarintBuf(),this},Varint.prototype.fromBN=function(bn){return this.buf=BufferWriter().writeVarintBN(bn).concat(),this},Varint.prototype.fromNumber=function(num){return this.buf=BufferWriter().writeVarintNum(num).concat(),this},Varint.prototype.toBuffer=function(){return this.buf},Varint.prototype.toBN=function(){return BufferReader(this.buf).readVarintBN()},Varint.prototype.toNumber=function(){return BufferReader(this.buf).readVarintNum()},module.exports=Varint}).call(this,require("buffer").Buffer)},{"../crypto/bn":175,"./bufferreader":183,"./bufferwriter":184,buffer:51}],186:[function(require,module,exports){"use strict";var _=require("lodash");function format(message,args){return message.replace("{0}",args[0]).replace("{1}",args[1]).replace("{2}",args[2])}var traverseNode=function(parent,errorDefinition){var NodeError=function(){if(_.isString(errorDefinition.message))this.message=format(errorDefinition.message,arguments);else{if(!_.isFunction(errorDefinition.message))throw new Error("Invalid error definition for "+errorDefinition.name);this.message=errorDefinition.message.apply(null,arguments)}this.stack=this.message+"\n"+(new Error).stack};return(NodeError.prototype=Object.create(parent.prototype)).name=parent.prototype.name+errorDefinition.name,parent[errorDefinition.name]=NodeError,errorDefinition.errors&&childDefinitions(NodeError,errorDefinition.errors),NodeError},childDefinitions=function(parent,childDefinitions){_.each(childDefinitions,(function(childDefinition){traverseNode(parent,childDefinition)}))},bitcore={Error:function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack}};bitcore.Error.prototype=Object.create(Error.prototype),bitcore.Error.prototype.name="bitcore.Error";var parent,data=require("./spec");parent=bitcore.Error,childDefinitions(parent,data),module.exports=bitcore.Error,module.exports.extend=function(spec){return traverseNode(bitcore.Error,spec)}},{"./spec":187,lodash:252}],187:[function(require,module,exports){"use strict";module.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 "+typeof 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:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{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"}]}]},{}],188:[function(require,module,exports){(function(Buffer){"use strict";var assert=require("assert"),buffer=require("buffer"),_=require("lodash"),$=require("./util/preconditions"),BN=require("./crypto/bn"),Base58=require("./encoding/base58"),Base58Check=require("./encoding/base58check"),Hash=require("./crypto/hash"),Network=require("./networks"),Point=require("./crypto/point"),PrivateKey=require("./privatekey"),Random=require("./crypto/random"),errors=require("./errors"),hdErrors=errors.HDPrivateKey,BufferUtil=require("./util/buffer"),JSUtil=require("./util/js");function HDPrivateKey(arg){if(arg instanceof HDPrivateKey)return arg;if(!(this instanceof HDPrivateKey))return new HDPrivateKey(arg);if(!arg)return this._generateRandomly();if(Network.get(arg))return this._generateRandomly(arg);if(_.isString(arg)||BufferUtil.isBuffer(arg))if(HDPrivateKey.isValidSerialized(arg))this._buildFromSerialized(arg);else if(JSUtil.isValidJSON(arg))this._buildFromJSON(arg);else{if(!BufferUtil.isBuffer(arg)||!HDPrivateKey.isValidSerialized(arg.toString()))throw HDPrivateKey.getSerializedError(arg);this._buildFromSerialized(arg.toString())}else{if(!_.isObject(arg))throw new hdErrors.UnrecognizedArgument(arg);this._buildFromObject(arg)}}HDPrivateKey.isValidPath=function(arg,hardened){if(_.isString(arg)){var indexes=HDPrivateKey._getDerivationIndexes(arg);return null!==indexes&&_.every(indexes,HDPrivateKey.isValidPath)}return!!_.isNumber(arg)&&(arg<HDPrivateKey.Hardened&&!0===hardened&&(arg+=HDPrivateKey.Hardened),arg>=0&&arg<HDPrivateKey.MaxIndex)},HDPrivateKey._getDerivationIndexes=function(path){var steps=path.split("/");if(_.includes(HDPrivateKey.RootElementAlias,path))return[];if(!_.includes(HDPrivateKey.RootElementAlias,steps[0]))return null;var indexes=steps.slice(1).map((function(step){var isHardened="'"===step.slice(-1);if(isHardened&&(step=step.slice(0,-1)),!step||"-"===step[0])return NaN;var index=+step;return isHardened&&(index+=HDPrivateKey.Hardened),index}));return _.some(indexes,isNaN)?null:indexes},HDPrivateKey.prototype.derive=function(arg,hardened){return this.deriveNonCompliantChild(arg,hardened)},HDPrivateKey.prototype.deriveChild=function(arg,hardened){if(_.isNumber(arg))return this._deriveWithNumber(arg,hardened);if(_.isString(arg))return this._deriveFromString(arg);throw new hdErrors.InvalidDerivationArgument(arg)},HDPrivateKey.prototype.deriveNonCompliantChild=function(arg,hardened){if(_.isNumber(arg))return this._deriveWithNumber(arg,hardened,!0);if(_.isString(arg))return this._deriveFromString(arg,!0);throw new hdErrors.InvalidDerivationArgument(arg)},HDPrivateKey.prototype._deriveWithNumber=function(index,hardened,nonCompliant){if(!HDPrivateKey.isValidPath(index,hardened))throw new hdErrors.InvalidPath(index);hardened=index>=HDPrivateKey.Hardened||hardened,index<HDPrivateKey.Hardened&&!0===hardened&&(index+=HDPrivateKey.Hardened);var data,indexBuffer=BufferUtil.integerAsBuffer(index);if(hardened&&nonCompliant){var nonZeroPadded=this.privateKey.bn.toBuffer();data=BufferUtil.concat([new buffer.Buffer([0]),nonZeroPadded,indexBuffer])}else if(hardened){var privateKeyBuffer=this.privateKey.bn.toBuffer({size:32});assert(32===privateKeyBuffer.length,"length of private key buffer is expected to be 32 bytes"),data=BufferUtil.concat([new buffer.Buffer([0]),privateKeyBuffer,indexBuffer])}else data=BufferUtil.concat([this.publicKey.toBuffer(),indexBuffer]);var hash=Hash.sha512hmac(data,this._buffers.chainCode),leftPart=BN.fromBuffer(hash.slice(0,32),{size:32}),chainCode=hash.slice(32,64),privateKey=leftPart.add(this.privateKey.toBigNumber()).umod(Point.getN()).toBuffer({size:32});return PrivateKey.isValid(privateKey)?new HDPrivateKey({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:index,chainCode:chainCode,privateKey:privateKey}):this._deriveWithNumber(index+1,null,nonCompliant)},HDPrivateKey.prototype._deriveFromString=function(path,nonCompliant){if(!HDPrivateKey.isValidPath(path))throw new hdErrors.InvalidPath(path);return HDPrivateKey._getDerivationIndexes(path).reduce((function(prev,index){return prev._deriveWithNumber(index,null,nonCompliant)}),this)},HDPrivateKey.isValidSerialized=function(data,network){return!HDPrivateKey.getSerializedError(data,network)},HDPrivateKey.getSerializedError=function(data,network){if(!_.isString(data)&&!BufferUtil.isBuffer(data))return new hdErrors.UnrecognizedArgument("Expected string or buffer");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!==HDPrivateKey.DataLength)return new hdErrors.InvalidLength(data);if(!_.isUndefined(network)){var error=HDPrivateKey._validateNetwork(data,network);if(error)return error}return null},HDPrivateKey._validateNetwork=function(data,networkArg){var network=Network.get(networkArg);if(!network)return new errors.InvalidNetworkArgument(networkArg);var version=data.slice(0,4);return BufferUtil.integerFromBuffer(version)!==network.xprivkey?new errors.InvalidNetwork(version):null},HDPrivateKey.fromString=function(arg){return $.checkArgument(_.isString(arg),"No valid string was provided"),new HDPrivateKey(arg)},HDPrivateKey.fromObject=function(arg){return $.checkArgument(_.isObject(arg),"No valid argument was provided"),new HDPrivateKey(arg)},HDPrivateKey.prototype._buildFromJSON=function(arg){return this._buildFromObject(JSON.parse(arg))},HDPrivateKey.prototype._buildFromObject=function(arg){var buffers={version:arg.network?BufferUtil.integerAsBuffer(Network.get(arg.network).xprivkey):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,privateKey:_.isString(arg.privateKey)&&JSUtil.isHexa(arg.privateKey)?BufferUtil.hexToBuffer(arg.privateKey):arg.privateKey,checksum:arg.checksum?arg.checksum.length?arg.checksum:BufferUtil.integerAsBuffer(arg.checksum):void 0};return this._buildFromBuffers(buffers)},HDPrivateKey.prototype._buildFromSerialized=function(arg){var decoded=Base58Check.decode(arg),buffers={version:decoded.slice(HDPrivateKey.VersionStart,HDPrivateKey.VersionEnd),depth:decoded.slice(HDPrivateKey.DepthStart,HDPrivateKey.DepthEnd),parentFingerPrint:decoded.slice(HDPrivateKey.ParentFingerPrintStart,HDPrivateKey.ParentFingerPrintEnd),childIndex:decoded.slice(HDPrivateKey.ChildIndexStart,HDPrivateKey.ChildIndexEnd),chainCode:decoded.slice(HDPrivateKey.ChainCodeStart,HDPrivateKey.ChainCodeEnd),privateKey:decoded.slice(HDPrivateKey.PrivateKeyStart,HDPrivateKey.PrivateKeyEnd),checksum:decoded.slice(HDPrivateKey.ChecksumStart,HDPrivateKey.ChecksumEnd),xprivkey:arg};return this._buildFromBuffers(buffers)},HDPrivateKey.prototype._generateRandomly=function(network){return HDPrivateKey.fromSeed(Random.getRandomBuffer(64),network)},HDPrivateKey.fromSeed=function(hexa,network){if(JSUtil.isHexaString(hexa)&&(hexa=BufferUtil.hexToBuffer(hexa)),!Buffer.isBuffer(hexa))throw new hdErrors.InvalidEntropyArgument(hexa);if(hexa.length<16)throw new hdErrors.InvalidEntropyArgument.NotEnoughEntropy(hexa);if(hexa.length>64)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=Buffer.from(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: "+this.xprivkey+">"},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":175,"./crypto/hash":177,"./crypto/point":178,"./crypto/random":179,"./encoding/base58":181,"./encoding/base58check":182,"./errors":186,"./hdpublickey":189,"./networks":190,"./privatekey":192,"./util/buffer":212,"./util/js":213,"./util/preconditions":214,assert:15,buffer:51,lodash:252}],189:[function(require,module,exports){(function(Buffer){"use strict";var _=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)},HDPublicKey.prototype.derive=function(arg,hardened){return this.deriveChild(arg,hardened)},HDPublicKey.prototype.deriveChild=function(arg,hardened){if(_.isNumber(arg))return this._deriveWithNumber(arg,hardened);if(_.isString(arg))return this._deriveFromString(arg);throw new hdErrors.InvalidDerivationArgument(arg)},HDPublicKey.prototype._deriveWithNumber=function(index,hardened){if(index>=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=Buffer.from(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 "+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: "+this.xpubkey+">"},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":175,"./crypto/hash":177,"./crypto/point":178,"./encoding/base58":181,"./encoding/base58check":182,"./errors":186,"./hdprivatekey":188,"./networks":190,"./publickey":193,"./util/buffer":212,"./util/js":213,"./util/preconditions":214,assert:15,buffer:51,lodash:252}],190:[function(require,module,exports){"use strict";var _=require("lodash"),BufferUtil=require("./util/buffer"),JSUtil=require("./util/js"),networks=[],networkMaps={};function Network(){}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}Network.prototype.toString=function(){return this.name},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<networks.length;i++)networks[i]===network&&networks.splice(i,1);for(var key in networkMaps)networkMaps[key]===network&&delete networkMaps[key]},defaultNetwork:livenet,livenet:livenet,mainnet:livenet,testnet:testnet,get:get,enableRegtest:function(){testnet.regtestEnabled=!0},disableRegtest:function(){testnet.regtestEnabled=!1}}},{"./util/buffer":212,"./util/js":213,lodash:252}],191:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),$=require("./util/preconditions"),BufferUtil=require("./util/buffer"),JSUtil=require("./util/js");function Opcode(num){if(!(this instanceof Opcode))return new Opcode(num);var value;if(_.isNumber(num))value=num;else{if(!_.isString(num))throw new TypeError('Unrecognized num type: "'+typeof num+'" for Opcode');value=Opcode.map[num]}return JSUtil.defineImmutable(this,{num:value}),this}for(var k in Opcode.fromBuffer=function(buf){return $.checkArgument(BufferUtil.isBuffer(buf)),new Opcode(Number("0x"+buf.toString("hex")))},Opcode.fromNumber=function(num){return $.checkArgument(_.isNumber(num)),new Opcode(num)},Opcode.fromString=function(str){$.checkArgument(_.isString(str));var value=Opcode.map[str];if(void 0===value)throw new TypeError("Invalid opcodestr");return new Opcode(value)},Opcode.prototype.toHex=function(){return this.num.toString(16)},Opcode.prototype.toBuffer=function(){return Buffer.from(this.toHex(),"hex")},Opcode.prototype.toNumber=function(){return this.num},Opcode.prototype.toString=function(){var str=Opcode.reverseMap[this.num];if(void 0===str)throw new Error("Opcode does not have a string representation");return str},Opcode.smallInt=function(n){return $.checkArgument(_.isNumber(n),"Invalid Argument: n should be number"),$.checkArgument(n>=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_CHECKSEQUENCEVERIFY:178,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=[],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"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"},module.exports=Opcode}).call(this,require("buffer").Buffer)},{"./util/buffer":212,"./util/js":213,"./util/preconditions":214,buffer:51,lodash:252}],192:[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(Buffer.from(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){var bn=PrivateKey._getRandomBN();return new PrivateKey(bn,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([Buffer.from([network.privatekey]),this.bn.toBuffer({size:32}),Buffer.from([1])]):Buffer.concat([Buffer.from([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"<PrivateKey: "+this.toString()+", network: "+this.network+uncompressed+">"},module.exports=PrivateKey}).call(this,require("buffer").Buffer)},{"./address":170,"./crypto/bn":175,"./crypto/point":178,"./crypto/random":179,"./encoding/base58check":182,"./networks":190,"./publickey":193,"./util/js":213,"./util/preconditions":214,buffer:51,lodash:252}],193:[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(Buffer.from(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 x,y,xbuf,ybuf,info={};if(strict=!!_.isUndefined(strict)||strict,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=Buffer.from(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});return this.compressed?(prefix=ybuf[ybuf.length-1]%2?Buffer.from([3]):Buffer.from([2]),Buffer.concat([prefix,xbuf])):(prefix=Buffer.from([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"<PublicKey: "+this.toString()+(this.compressed?"":", uncompressed")+">"},module.exports=PublicKey}).call(this,require("buffer").Buffer)},{"./address":170,"./crypto/bn":175,"./crypto/hash":177,"./crypto/point":178,"./networks":190,"./privatekey":192,"./util/js":213,"./util/preconditions":214,buffer:51,lodash:252}],194:[function(require,module,exports){module.exports=require("./script"),module.exports.Interpreter=require("./interpreter")},{"./interpreter":195,"./script":196}],195:[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.verifyWitnessProgram=function(version,program,witness,satoshis,flags){var scriptPubKey=new Script,stack=[];if(0!==version)return!(flags&Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM)||(this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM",!1);if(32===program.length){if(0===witness.length)return this.errstr="SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY",!1;var scriptPubKeyBuffer=witness[witness.length-1];if(scriptPubKey=new Script(scriptPubKeyBuffer),Hash.sha256(scriptPubKeyBuffer).toString("hex")!==program.toString("hex"))return this.errstr="SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH",!1;stack=witness.slice(0,-1)}else{if(20!==program.length)return this.errstr="SCRIPT_ERR_WITNESS_PROGRAM_WRONG_LENGTH",!1;if(2!==witness.length)return this.errstr="SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH",!1;scriptPubKey.add(Opcode.OP_DUP),scriptPubKey.add(Opcode.OP_HASH160),scriptPubKey.add(program),scriptPubKey.add(Opcode.OP_EQUALVERIFY),scriptPubKey.add(Opcode.OP_CHECKSIG),stack=witness}if(this.initialize(),this.set({script:scriptPubKey,stack:stack,sigversion:1,satoshis:satoshis,flags:flags}),!this.evaluate())return!1;if(1!==this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE",!1;var buf=this.stack[this.stack.length-1];return!!Interpreter.castToBool(buf)||(this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1)},Interpreter.prototype.verify=function(scriptSig,scriptPubkey,tx,nin,flags,witness,satoshis){var stackCopy,Transaction=require("../transaction");if(_.isUndefined(tx)&&(tx=new Transaction),_.isUndefined(nin)&&(nin=0),_.isUndefined(flags)&&(flags=0),_.isUndefined(witness)&&(witness=null),_.isUndefined(satoshis)&&(satoshis=0),this.set({script:scriptSig,tx:tx,nin:nin,sigversion:0,satoshis:0,flags:flags}),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;var hadWitness=!1;if(flags&Interpreter.SCRIPT_VERIFY_WITNESS){var witnessValues={};if(scriptPubkey.isWitnessProgram(witnessValues)){if(hadWitness=!0,0!==scriptSig.toBuffer().length)return!1;if(!this.verifyWitnessProgram(witnessValues.version,witnessValues.program,witness,satoshis,this.flags))return!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);if(stackCopy.pop(),this.initialize(),this.set({script:redeemScript,stack:stackCopy,tx:tx,nin:nin,flags:flags}),!this.evaluate())return!1;if(0===stackCopy.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!Interpreter.castToBool(stackCopy[stackCopy.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1;if(flags&Interpreter.SCRIPT_VERIFY_WITNESS){var p2shWitnessValues={};if(redeemScript.isWitnessProgram(p2shWitnessValues)){hadWitness=!0;var redeemScriptPush=new Script;if(redeemScriptPush.add(redeemScript.toBuffer()),scriptSig.toHex()!==redeemScriptPush.toHex())return this.errstr="SCRIPT_ERR_WITNESS_MALLEATED_P2SH",!1;if(!this.verifyWitnessProgram(p2shWitnessValues.version,p2shWitnessValues.program,witness,satoshis,this.flags))return!1;stack=[stack[0]]}}}if(0!=(this.flags&Interpreter.SCRIPT_VERIFY_CLEANSTACK)){if(0==(this.flags&Interpreter.SCRIPT_VERIFY_P2SH))throw"flags & SCRIPT_VERIFY_P2SH";if(1!=stackCopy.length)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!(this.flags&Interpreter.SCRIPT_VERIFY_WITNESS&&!hadWitness&&witness.length>0)||(this.errstr="SCRIPT_ERR_WITNESS_UNEXPECTED",!1)},module.exports=Interpreter,Interpreter.prototype.initialize=function(obj){this.stack=[],this.altstack=[],this.pc=0,this.satoshis=0,this.sigversion=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.sigversion=void 0!==obj.sigversion?obj.sigversion:this.sigversion,this.satoshis=void 0!==obj.satoshis?obj.satoshis:this.satoshis,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=Buffer.from([1]),Interpreter.false=Buffer.from([]),Interpreter.MAX_SCRIPT_ELEMENT_SIZE=520,Interpreter.LOCKTIME_THRESHOLD_BN=new BN(Interpreter.LOCKTIME_THRESHOLD=5e8),Interpreter.SCRIPT_VERIFY_NONE=0,Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM=4096,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_CLEANSTACK=256,Interpreter.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,Interpreter.SCRIPT_VERIFY_WITNESS=1024,Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=2048,Interpreter.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024,Interpreter.SCRIPT_VERIFY_MINIMALIF=8192,Interpreter.SCRIPT_VERIFY_NULLFAIL=16384,Interpreter.SCRIPT_VERIFY_WITNESS_PUBKEYTYPE=32768,Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID=65536,Interpreter.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17,Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES=1<<18,Interpreter.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31,Interpreter.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22,Interpreter.SEQUENCE_LOCKTIME_MASK=65535,Interpreter.castToBool=function(buf){for(var i=0;i<buf.length;i++)if(0!==buf[i])return i!==buf.length-1||128!==buf[i];return!1},Interpreter.prototype.checkSignatureEncoding=function(buf){if(0==buf.length)return!0;if(0!=(this.flags&(Interpreter.SCRIPT_VERIFY_DERSIG|Interpreter.SCRIPT_VERIFY_LOW_S|Interpreter.SCRIPT_VERIFY_STRICTENC))&&!Signature.isTxDER(buf))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if(0!=(this.flags&Interpreter.SCRIPT_VERIFY_LOW_S)){if(!Signature.fromTxFormat(buf).hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if(0!=(this.flags&Interpreter.SCRIPT_VERIFY_STRICTENC)&&!Signature.fromTxFormat(buf).hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;return!0},Interpreter.prototype.checkPubkeyEncoding=function(buf){return 0==(this.flags&Interpreter.SCRIPT_VERIFY_STRICTENC)||PublicKey.isValid(buf)?!(0!=(this.flags&Interpreter.SCRIPT_VERIFY_WITNESS_PUBKEYTYPE)&&1==this.sigversion&&!PublicKey.fromBuffer(buf).compressed)||(this.errstr="SCRIPT_ERR_WITNESS_PUBKEYTYPE",!1):(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1)},Interpreter.prototype.evaluate=function(){if(this.script.toBuffer().length>1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){if(!this.step())return!1}if(this.stack.length+this.altstack.length>1e3)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.lt(Interpreter.LOCKTIME_THRESHOLD_BN)||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.checkSequence=function(nSequence){var txToSequence=this.tx.inputs[this.nin].sequenceNumber;if(this.tx.version<2)return!1;if(txToSequence&SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var nLockTimeMask=Interpreter.SEQUENCE_LOCKTIME_TYPE_FLAG|Interpreter.SEQUENCE_LOCKTIME_MASK,txToSequenceMasked=new BN(txToSequence&nLockTimeMask),nSequenceMasked=nSequence.and(nLockTimeMask),SEQUENCE_LOCKTIME_TYPE_FLAG_BN=new BN(Interpreter.SEQUENCE_LOCKTIME_TYPE_FLAG);return!!(txToSequenceMasked.lt(SEQUENCE_LOCKTIME_TYPE_FLAG_BN)&&nSequenceMasked.lt(SEQUENCE_LOCKTIME_TYPE_FLAG_BN)||txToSequenceMasked.gte(SEQUENCE_LOCKTIME_TYPE_FLAG_BN)&&nSequenceMasked.gte(SEQUENCE_LOCKTIME_TYPE_FLAG_BN))&&!nSequenceMasked.gt(txToSequenceMasked)},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_NOP3:case Opcode.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&Interpreter.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){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 nSequence=BN.fromScriptNumBuffer(this.stack[this.stack.length-1],fRequireMinimal,5);if(nSequence.lt(new BN(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(0!=(nSequence&Interpreter.SEQUENCE_LOCKTIME_DISABLE_FLAG))break;if(!this.checkSequence(nSequence))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case Opcode.OP_NOP1: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;if(buf=this.stack[this.stack.length-1],this.flags&Interpreter.SCRIPT_VERIFY_MINIMALIF){if((buf=this.stack[this.stack.length-1]).length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(1==buf.length&&1!=buf[0])return this.errstr="SCRIPT_ERR_MINIMALIF",!1}fValue=Interpreter.castToBool(buf),opcodenum===Opcode.OP_NOTIF&&(fValue=!fValue),this.stack.pop()}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;var bufHash;buf=this.stack[this.stack.length-1],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;if(bufSig=this.stack[this.stack.length-2],bufPubkey=this.stack[this.stack.length-1],!this.checkSignatureEncoding(bufSig)||!this.checkPubkeyEncoding(bufPubkey))return!1;subscript=(new Script).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var tmpScript=(new Script).add(bufSig);subscript.findAndDelete(tmpScript);try{sig=Signature.fromTxFormat(bufSig),pubkey=PublicKey.fromBuffer(bufPubkey,!1),fSuccess=this.tx.verifySignature(sig,pubkey,this.nin,subscript,this.sigversion,this.satoshis)}catch(e){fSuccess=!1}if(!fSuccess&&this.flags&Interpreter.SCRIPT_VERIFY_NULLFAIL&&bufSig.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!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.length<i)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var nKeysCount=BN.fromScriptNumBuffer(this.stack[this.stack.length-i],fRequireMinimal).toNumber();if(nKeysCount<0||nKeysCount>20)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;i+=nKeysCount;var ikey2=nKeysCount+2;if(this.stack.length<i)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var nSigsCount=BN.fromScriptNumBuffer(this.stack[this.stack.length-i],fRequireMinimal).toNumber();if(nSigsCount<0||nSigsCount>nKeysCount)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var isig=++i;if(i+=nSigsCount,this.stack.length<i)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;subscript=(new Script).set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var k=0;k<nSigsCount;k++)bufSig=this.stack[this.stack.length-isig-k],subscript.findAndDelete((new Script).add(bufSig));for(fSuccess=!0;fSuccess&&nSigsCount>0;){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,this.sigversion,this.satoshis)}catch(e){fOk=!1}fOk&&(isig++,nSigsCount--),ikey++,nSigsCount>--nKeysCount&&(fSuccess=!1)}for(;i-- >1;){if(!fSuccess&&this.flags&Interpreter.SCRIPT_VERIFY_NULLFAIL&&!ikey2&&this.stack[this.stack.length-1].length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;ikey2>0&&ikey2--,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":175,"../crypto/hash":177,"../crypto/signature":180,"../opcode":191,"../publickey":193,"../transaction":197,"./script":196,buffer:51,lodash:252}],196:[function(require,module,exports){(function(Buffer){"use strict";var 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()):_.isString(from)?Script.fromString(from):void(_.isObject(from)&&_.isArray(from.chunks)&&this.set(from))):new Script(from)};Script.prototype.set=function(obj){return $.checkArgument(_.isObject(obj)),$.checkArgument(_.isArray(obj.chunks)),this.chunks=obj.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&&opcodenum<Opcode.OP_PUSHDATA1?(len=opcodenum,script.chunks.push({buf:br.read(len),len:len,opcodenum:opcodenum})):opcodenum===Opcode.OP_PUSHDATA1?(len=br.readUInt8(),buf=br.read(len),script.chunks.push({buf:buf,len:len,opcodenum:opcodenum})):opcodenum===Opcode.OP_PUSHDATA2?(len=br.readUInt16LE(),buf=br.read(len),script.chunks.push({buf:buf,len:len,opcodenum:opcodenum})):opcodenum===Opcode.OP_PUSHDATA4?(len=br.readUInt32LE(),buf=br.read(len),script.chunks.push({buf:buf,len:len,opcodenum:opcodenum})):script.chunks.push({opcodenum:opcodenum})}catch(e){if(e instanceof RangeError)throw new errors.Script.InvalidBuffer(buffer.toString("hex"));throw e}return script},Script.prototype.toBuffer=function(){for(var bw=new BufferWriter,i=0;i<this.chunks.length;i++){var chunk=this.chunks[i],opcodenum=chunk.opcodenum;bw.writeUInt8(chunk.opcodenum),chunk.buf&&(opcodenum<Opcode.OP_PUSHDATA1?bw.write(chunk.buf):opcodenum===Opcode.OP_PUSHDATA1?(bw.writeUInt8(chunk.len),bw.write(chunk.buf)):opcodenum===Opcode.OP_PUSHDATA2?(bw.writeUInt16LE(chunk.len),bw.write(chunk.buf)):opcodenum===Opcode.OP_PUSHDATA4&&(bw.writeUInt32LE(chunk.len),bw.write(chunk.buf)))}return bw.concat()},Script.fromASM=function(str){var script=new Script;script.chunks=[];for(var tokens=str.split(" "),i=0;i<tokens.length;){var token=tokens[i],opcodenum=Opcode(token).toNumber();if(_.isUndefined(opcodenum)){var buf=Buffer.from(tokens[i],"hex");script.chunks.push({buf:buf,len:buf.length,opcodenum:buf.length}),i+=1}else opcodenum===Opcode.OP_PUSHDATA1||opcodenum===Opcode.OP_PUSHDATA2||opcodenum===Opcode.OP_PUSHDATA4?(script.chunks.push({buf:Buffer.from(tokens[i+2],"hex"),len:parseInt(tokens[i+1]),opcodenum:opcodenum}),i+=3):(script.chunks.push({opcodenum:opcodenum}),i+=1)}return script},Script.fromHex=function(str){return new Script(new buffer.Buffer(str,"hex"))},Script.fromString=function(str){if(JSUtil.isHexa(str)||0===str.length)return new Script(new buffer.Buffer(str,"hex"));var script=new Script;script.chunks=[];for(var tokens=str.split(" "),i=0;i<tokens.length;){var token=tokens[i],opcodenum=Opcode(token).toNumber();if(_.isUndefined(opcodenum)){if(!((opcodenum=parseInt(token))>0&&opcodenum<Opcode.OP_PUSHDATA1))throw new Error("Invalid script: "+JSON.stringify(str));script.chunks.push({buf:Buffer.from(tokens[i+1].slice(2),"hex"),len:opcodenum,opcodenum:opcodenum}),i+=2}else if(opcodenum===Opcode.OP_PUSHDATA1||opcodenum===Opcode.OP_PUSHDATA2||opcodenum===Opcode.OP_PUSHDATA4){if("0x"!==tokens[i+2].slice(0,2))throw new Error("Pushdata data must start with 0x");script.chunks.push({buf:Buffer.from(tokens[i+2].slice(2),"hex"),len:parseInt(tokens[i+1]),opcodenum:opcodenum}),i+=3}else script.chunks.push({opcodenum:opcodenum}),i+=1}return script},Script.prototype._chunkToString=function(chunk,type){var opcodenum=chunk.opcodenum,asm="asm"===type,str="";if(chunk.buf)(!asm&&opcodenum===Opcode.OP_PUSHDATA1||opcodenum===Opcode.OP_PUSHDATA2||opcodenum===Opcode.OP_PUSHDATA4)&&(str=str+" "+Opcode(opcodenum).toString()),chunk.len>0&&(str=asm?str+" "+chunk.buf.toString("hex"):str+" "+chunk.len+" 0x"+chunk.buf.toString("hex"));else if(void 0!==Opcode.reverseMap[opcodenum])asm?0===opcodenum?str+=" 0":79===opcodenum?str+=" -1":str=str+" "+Opcode(opcodenum).toString():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<this.chunks.length;i++){var chunk=this.chunks[i];str+=this._chunkToString(chunk,"asm")}return str.substr(1)},Script.prototype.toString=function(){for(var str="",i=0;i<this.chunks.length;i++){var chunk=this.chunks[i];str+=this._chunkToString(chunk)}return str.substr(1)},Script.prototype.toHex=function(){return this.toBuffer().toString("hex")},Script.prototype.inspect=function(){return"<Script: "+this.toString()+">"},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)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.isWitnessScriptHashOut=function(){var buf=this.toBuffer();return 34===buf.length&&0===buf[0]&&32===buf[1]},Script.prototype.isWitnessPublicKeyHashOut=function(){var buf=this.toBuffer();return 22===buf.length&&0===buf[0]&&20===buf[1]},Script.prototype.isWitnessProgram=function(values){values||(values={});var buf=this.toBuffer();return!(buf.length<4||buf.length>42)&&((buf[0]===Opcode.OP_0||buf[0]>=Opcode.OP_1&&buf[0]<=Opcode.OP_16)&&(buf.length===buf[1]+2&&(values.version=buf[0],values.program=buf.slice(2,buf.length),!0)))},Script.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var redeemScript,redeemBuf=this.chunks[this.chunks.length-1].buf;if(!redeemBuf)return!1;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])?Buffer.alloc(0):Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return Buffer.from(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<this.chunks.length;i++){if(BufferUtil.isBuffer(this.chunks[i].buf)&&!BufferUtil.isBuffer(script.chunks[i].buf))return!1;if(BufferUtil.isBuffer(this.chunks[i].buf)&&!BufferUtil.equals(this.chunks[i].buf,script.chunks[i].buf))return!1;if(this.chunks[i].opcodenum!==script.chunks[i].opcodenum)return!1}return!0},Script.prototype.add=function(obj){return this._addByType(obj,!1),this},Script.prototype._addByType=function(obj,prepend){if("string"==typeof obj)this._addOpcode(obj,prepend);else if("number"==typeof obj)this._addOpcode(obj,prepend);else if(obj instanceof Opcode)this._addOpcode(obj,prepend);else if(BufferUtil.isBuffer(obj))this._addBuffer(obj,prepend);else if(obj instanceof Script)this.chunks=this.chunks.concat(obj.chunks);else{if("object"!=typeof obj)throw new Error("Invalid script chunk");this._insertAtPosition(obj,prepend)}},Script.prototype._insertAtPosition=function(op,prepend){prepend?this.chunks.unshift(op):this.chunks.push(op)},Script.prototype._addOpcode=function(opcode,prepend){var op;return op="number"==typeof opcode?opcode:opcode instanceof Opcode?opcode.toNumber():Opcode(opcode).toNumber(),this._insertAtPosition({opcodenum:op},prepend),this},Script.prototype._addBuffer=function(buf,prepend){var opcodenum,len=buf.length;if(len>=0&&len<Opcode.OP_PUSHDATA1)opcodenum=len;else if(len<Math.pow(2,8))opcodenum=Opcode.OP_PUSHDATA1;else if(len<Math.pow(2,16))opcodenum=Opcode.OP_PUSHDATA2;else{if(!(len<Math.pow(2,32)))throw new Error("You can't push that much data");opcodenum=Opcode.OP_PUSHDATA4}return this._insertAtPosition({buf:buf,len:len,opcodenum:opcodenum},prepend),this},Script.prototype.hasCodeseparators=function(){for(var i=0;i<this.chunks.length;i++)if(this.chunks[i].opcodenum===Opcode.OP_CODESEPARATOR)return!0;return!1},Script.prototype.removeCodeseparators=function(){for(var chunks=[],i=0;i<this.chunks.length;i++)this.chunks[i].opcodenum!==Opcode.OP_CODESEPARATOR&&chunks.push(this.chunks[i]);return this.chunks=chunks,this},Script.buildMultisigOut=function(publicKeys,threshold,opts){$.checkArgument(threshold<=publicKeys.length,"Number of required signatures must be less than or equal to the number of public keys"),opts=opts||{};var script=new Script;script.add(Opcode.smallInt(threshold));var sorted=publicKeys=_.map(publicKeys,PublicKey);opts.noSorting||(sorted=_.sortBy(publicKeys,(function(publicKey){return publicKey.toString("hex")})));for(var i=0;i<sorted.length;i++){var publicKey=sorted[i];script.add(publicKey.toBuffer())}return script.add(Opcode.smallInt(publicKeys.length)),script.add(Opcode.OP_CHECKMULTISIG),script},Script.buildWitnessMultisigOutFromScript=function(script){if(script instanceof Script){var s=new Script;return s.add(Opcode.OP_0),s.add(Hash.sha256(script.toBuffer())),s}throw new TypeError("First argument is expected to be a p2sh script")},Script.buildMultisigIn=function(pubkeys,threshold,signatures,opts){$.checkArgument(_.isArray(pubkeys)),$.checkArgument(_.isNumber(threshold)),$.checkArgument(_.isArray(signatures)),opts=opts||{};var s=new Script;return s.add(Opcode.OP_0),_.each(signatures,(function(signature){$.checkArgument(BufferUtil.isBuffer(signature),"Signatures must be an array of Buffers"),s.add(signature)})),s},Script.buildP2SHMultisigIn=function(pubkeys,threshold,signatures,opts){$.checkArgument(_.isArray(pubkeys)),$.checkArgument(_.isNumber(threshold)),$.checkArgument(_.isArray(signatures)),opts=opts||{};var s=new Script;return s.add(Opcode.OP_0),_.each(signatures,(function(signature){$.checkArgument(BufferUtil.isBuffer(signature),"Signatures must be an array of Buffers"),s.add(signature)})),s.add((opts.cachedMultisig||Script.buildMultisigOut(pubkeys,threshold,opts)).toBuffer()),s},Script.buildPublicKeyHashOut=function(to){$.checkArgument(!_.isUndefined(to)),$.checkArgument(to instanceof PublicKey||to instanceof Address||_.isString(to)),to instanceof PublicKey?to=to.toAddress():_.isString(to)&&(to=new Address(to));var s=new Script;return s.add(Opcode.OP_DUP).add(Opcode.OP_HASH160).add(to.hashBuffer).add(Opcode.OP_EQUALVERIFY).add(Opcode.OP_CHECKSIG),s._network=to.network,s},Script.buildPublicKeyOut=function(pubkey){$.checkArgument(pubkey instanceof PublicKey);var s=new Script;return s.add(pubkey.toBuffer()).add(Opcode.OP_CHECKSIG),s},Script.buildDataOut=function(data,encoding){$.checkArgument(_.isUndefined(data)||_.isString(data)||BufferUtil.isBuffer(data)),_.isString(data)&&(data=Buffer.from(data,encoding));var s=new Script;return s.add(Opcode.OP_RETURN),_.isUndefined(data)||s.add(data),s},Script.buildScriptHashOut=function(script){$.checkArgument(script instanceof Script||script instanceof Address&&script.isPayToScriptHash());var s=new Script;return s.add(Opcode.OP_HASH160).add(script instanceof Address?script.hashBuffer:Hash.sha256ripemd160(script.toBuffer())).add(Opcode.OP_EQUAL),s._network=script._network||script.network,s},Script.buildPublicKeyIn=function(signature,sigtype){$.checkArgument(signature instanceof Signature||BufferUtil.isBuffer(signature)),$.checkArgument(_.isUndefined(sigtype)||_.isNumber(sigtype)),signature instanceof Signature&&(signature=signature.toBuffer());var script=new Script;return script.add(BufferUtil.concat([signature,BufferUtil.integerAsSingleByteBuffer(sigtype||Signature.SIGHASH_ALL)])),script},Script.buildPublicKeyHashIn=function(publicKey,signature,sigtype){return $.checkArgument(signature instanceof Signature||BufferUtil.isBuffer(signature)),$.checkArgument(_.isUndefined(sigtype)||_.isNumber(sigtype)),signature instanceof Signature&&(signature=signature.toBuffer()),(new Script).add(BufferUtil.concat([signature,BufferUtil.integerAsSingleByteBuffer(sigtype||Signature.SIGHASH_ALL)])).add(new PublicKey(publicKey).toBuffer())},Script.empty=function(){return new Script},Script.prototype.toScriptHashOut=function(){return Script.buildScriptHashOut(this)},Script.fromAddress=function(address){if((address=Address(address)).isPayToScriptHash())return Script.buildScriptHashOut(address);if(address.isPayToPublicKeyHash())return Script.buildPublicKeyHashOut(address);throw new errors.Script.UnrecognizedAddress(address)},Script.prototype.getAddressInfo=function(opts){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var info=this._getOutputAddressInfo();return info||this._getInputAddressInfo()},Script.prototype._getOutputAddressInfo=function(){var info={};if(this.isScriptHashOut())info.hashBuffer=this.getData(),info.type=Address.PayToScriptHash;else{if(!this.isPublicKeyHashOut())return!1;info.hashBuffer=this.getData(),info.type=Address.PayToPublicKeyHash}return info},Script.prototype._getInputAddressInfo=function(){var info={};if(this.isPublicKeyHashIn())info.hashBuffer=Hash.sha256ripemd160(this.chunks[1].buf),info.type=Address.PayToPublicKeyHash;else{if(!this.isScriptHashIn())return!1;info.hashBuffer=Hash.sha256ripemd160(this.chunks[this.chunks.length-1].buf),info.type=Address.PayToScriptHash}return info},Script.prototype.toAddress=function(network){var info=this.getAddressInfo();return!!info&&(info.network=Networks.get(network)||this._network||Networks.defaultNetwork,new Address(info))},Script.prototype.findAndDelete=function(script){for(var hex=script.toBuffer().toString("hex"),i=0;i<this.chunks.length;i++){hex===Script({chunks:[this.chunks[i]]}).toBuffer().toString("hex")&&this.chunks.splice(i,1)}return this},Script.prototype.checkMinimalPush=function(i){var chunk=this.chunks[i],buf=chunk.buf,opcodenum=chunk.opcodenum;return!buf||(0===buf.length?opcodenum===Opcode.OP_0:1===buf.length&&buf[0]>=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":170,"../crypto/hash":177,"../crypto/signature":180,"../encoding/bufferreader":183,"../encoding/bufferwriter":184,"../errors":186,"../networks":190,"../opcode":191,"../publickey":193,"../util/buffer":212,"../util/js":213,"../util/preconditions":214,buffer:51,lodash:252}],197:[function(require,module,exports){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"),module.exports.SighashWitness=require("./sighashwitness")},{"./input":198,"./output":204,"./sighash":205,"./sighashwitness":206,"./signature":207,"./transaction":208,"./unspentoutput":209}],198:[function(require,module,exports){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":199,"./multisig.js":200,"./multisigscripthash.js":201,"./publickey":202,"./publickeyhash":203}],199:[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){return $.checkArgument(_.isObject(obj)),(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.witnesses=[],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.getSatoshisBuffer=function(){return $.checkState(this.output instanceof Output),$.checkState(this.output._satoshisBN),(new BufferWriter).writeUInt64LEBN(this.output._satoshisBN).toBuffer()},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.hasWitnesses=function(){return!!(this.witnesses&&this.witnesses.length>0)},Input.prototype.getWitnesses=function(){return this.witnesses},Input.prototype.setWitnesses=function(witnesses){this.witnesses=witnesses},Input.prototype.isValidSignature=function(transaction,signature){return signature.signature.nhashtype=signature.sigtype,Sighash.verify(transaction,signature.signature,signature.publicKey,signature.inputIndex,this.output.script)},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":184,"../../errors":186,"../../script":194,"../../util/buffer":212,"../../util/js":213,"../../util/preconditions":214,"../output":204,"../sighash":205,buffer:51,lodash:252}],200:[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,opts){opts=opts||{},Input.apply(this,arguments);var self=this;pubkeys=pubkeys||input.publicKeys,threshold=threshold||input.threshold,signatures=signatures||input.signatures,opts.noSorting?this.publicKeys=pubkeys: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;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),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)},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});return signature.signature.nhashtype=signature.sigtype,!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":180,"../../publickey":193,"../../script":194,"../../util/buffer":212,"../../util/preconditions":214,"../output":204,"../sighash":205,"../signature":207,"../transaction":208,"./input":199,inherits:215,lodash:252}],201:[function(require,module,exports){(function(Buffer){"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"),SighashWitness=require("../sighashwitness"),BufferWriter=require("../../encoding/bufferwriter"),BufferUtil=require("../../util/buffer"),TransactionSignature=require("../signature");function MultiSigScriptHashInput(input,pubkeys,threshold,signatures,nestedWitness,opts){opts=opts||{},Input.apply(this,arguments);var self=this;if(pubkeys=pubkeys||input.publicKeys,threshold=threshold||input.threshold,signatures=signatures||input.signatures,this.nestedWitness=!!nestedWitness,opts.noSorting?this.publicKeys=pubkeys:this.publicKeys=_.sortBy(pubkeys,(function(publicKey){return publicKey.toString("hex")})),this.redeemScript=Script.buildMultisigOut(this.publicKeys,threshold),this.nestedWitness){var nested=Script.buildWitnessMultisigOutFromScript(this.redeemScript);$.checkState(Script.buildScriptHashOut(nested).equals(this.output.script),"Provided public keys don't hash to the provided output (nested witness)");var scriptSig=new Script;scriptSig.add(nested.toBuffer()),this.setScript(scriptSig)}else $.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.getScriptCode=function(){var writer=new BufferWriter;if(this.redeemScript.hasCodeseparators())throw new Error("@TODO");var redeemScriptBuffer=this.redeemScript.toBuffer();return writer.writeVarintNum(redeemScriptBuffer.length),writer.write(redeemScriptBuffer),writer.toBuffer()},MultiSigScriptHashInput.prototype.getSighash=function(transaction,privateKey,index,sigtype){var hash;if(this.nestedWitness){var scriptCode=this.getScriptCode(),satoshisBuffer=this.getSatoshisBuffer();hash=SighashWitness.sighash(transaction,sigtype,index,scriptCode,satoshisBuffer)}else hash=Sighash.sighash(transaction,sigtype,index,this.redeemScript);return hash},MultiSigScriptHashInput.prototype.getSignatures=function(transaction,privateKey,index,sigtype){$.checkState(this.output instanceof Output),sigtype=sigtype||Signature.SIGHASH_ALL;var self=this,results=[];return _.each(this.publicKeys,(function(publicKey){if(publicKey.toString()===privateKey.publicKey.toString()){var signature;if(self.nestedWitness){var scriptCode=self.getScriptCode(),satoshisBuffer=self.getSatoshisBuffer();signature=SighashWitness.sign(transaction,privateKey,sigtype,index,scriptCode,satoshisBuffer)}else signature=Sighash.sign(transaction,privateKey,sigtype,index,self.redeemScript);results.push(new TransactionSignature({publicKey:privateKey.publicKey,prevTxId:self.prevTxId,outputIndex:self.outputIndex,inputIndex:index,signature:signature,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(){if(this.nestedWitness){for(var stack=[new Buffer(0)],signatures=this._createSignatures(),i=0;i<signatures.length;i++)stack.push(signatures[i]);stack.push(this.redeemScript.toBuffer()),this.setWitnesses(stack)}else{var scriptSig=Script.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript});this.setScript(scriptSig)}return 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){if(this.nestedWitness){signature.signature.nhashtype=signature.sigtype;var scriptCode=this.getScriptCode(),satoshisBuffer=this.getSatoshisBuffer();return SighashWitness.verify(transaction,signature.signature,signature.publicKey,signature.inputIndex,scriptCode,satoshisBuffer)}return signature.signature.nhashtype=signature.sigtype,Sighash.verify(transaction,signature.signature,signature.publicKey,signature.inputIndex,this.redeemScript)},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}).call(this,require("buffer").Buffer)},{"../../crypto/signature":180,"../../encoding/bufferwriter":184,"../../script":194,"../../util/buffer":212,"../../util/preconditions":214,"../output":204,"../sighash":205,"../sighashwitness":206,"../signature":207,"./input":199,buffer:51,inherits:215,lodash:252}],202:[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;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),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":180,"../../script":194,"../../util/buffer":212,"../../util/preconditions":214,"../output":204,"../sighash":205,"../signature":207,"./input":199,inherits:215}],203:[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,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),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":177,"../../crypto/signature":180,"../../script":194,"../../util/buffer":212,"../../util/preconditions":214,"../output":204,"../sighash":205,"../signature":207,"./input":199,inherits:215}],204:[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");var script;this.satoshis=args.satoshis,bufferUtil.isBuffer(args.script)?this._scriptBuffer=args.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"},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 ("+this.satoshis+" sats) "+scriptStr+">"},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":175,"../encoding/bufferwriter":184,"../errors":186,"../script":194,"../util/buffer":212,"../util/js":213,"../util/preconditions":214,buffer:51,lodash:252}],205:[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"),_=require("lodash"),sighash=function(transaction,sighashType,inputNumber,subscript){var i,Transaction=require("./transaction"),Input=require("./input"),txcopy=Transaction.shallowCopy(transaction);for((subscript=new Script(subscript)).removeCodeseparators(),i=0;i<txcopy.inputs.length;i++)txcopy.inputs[i]=new Input(txcopy.inputs[i]).setScript(Script.empty());if(txcopy.inputs[inputNumber]=new Input(txcopy.inputs[inputNumber]).setScript(subscript),(31&sighashType)===Signature.SIGHASH_NONE||(31&sighashType)===Signature.SIGHASH_SINGLE)for(i=0;i<txcopy.inputs.length;i++)i!==inputNumber&&(txcopy.inputs[i].sequenceNumber=0);if((31&sighashType)===Signature.SIGHASH_NONE)txcopy.outputs=[];else if((31&sighashType)===Signature.SIGHASH_SINGLE){if(inputNumber>=txcopy.outputs.length)return Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex");for(txcopy.outputs.length=inputNumber+1,i=0;i<inputNumber;i++)txcopy.outputs[i]=new Output({satoshis:BN.fromBuffer(new buffer.Buffer("ffffffffffffffff","hex")),script:Script.empty()})}sighashType&Signature.SIGHASH_ANYONECANPAY&&(txcopy.inputs=[txcopy.inputs[inputNumber]]);var buf=(new BufferWriter).write(txcopy.toBuffer()).writeInt32LE(sighashType).toBuffer(),ret=Hash.sha256sha256(buf);return ret=new BufferReader(ret).readReverse()};module.exports={sighash:sighash,sign:function(transaction,privateKey,sighashType,inputIndex,subscript){var hashbuf=sighash(transaction,sighashType,inputIndex,subscript);return ECDSA.sign(hashbuf,privateKey,"little").set({nhashtype:sighashType})},verify:function(transaction,signature,publicKey,inputIndex,subscript){$.checkArgument(!_.isUndefined(transaction)),$.checkArgument(!_.isUndefined(signature)&&!_.isUndefined(signature.nhashtype));var hashbuf=sighash(transaction,signature.nhashtype,inputIndex,subscript);return ECDSA.verify(hashbuf,signature,publicKey,"little")}}}).call(this,require("buffer").Buffer)},{"../crypto/bn":175,"../crypto/ecdsa":176,"../crypto/hash":177,"../crypto/signature":180,"../encoding/bufferreader":183,"../encoding/bufferwriter":184,"../script":194,"../util/preconditions":214,"./input":198,"./output":204,"./transaction":208,buffer:51,lodash:252}],206:[function(require,module,exports){(function(Buffer){"use strict";var Signature=require("../crypto/signature"),BufferReader=(require("../script"),require("./output"),require("../encoding/bufferreader")),BufferWriter=require("../encoding/bufferwriter"),Hash=(require("../crypto/bn"),require("../crypto/hash")),ECDSA=require("../crypto/ecdsa"),$=require("../util/preconditions"),_=require("lodash"),sighash=function(transaction,sighashType,inputNumber,scriptCode,satoshisBuffer){var hashPrevouts,hashSequence,hashOutputs;if(!(sighashType&Signature.SIGHASH_ANYONECANPAY)){for(var buffers=[],n=0;n<transaction.inputs.length;n++){var input=transaction.inputs[n],prevTxIdBuffer=new BufferReader(input.prevTxId).readReverse();buffers.push(prevTxIdBuffer);var outputIndexBuffer=new Buffer(new Array(4));outputIndexBuffer.writeUInt32LE(input.outputIndex,0),buffers.push(outputIndexBuffer)}hashPrevouts=Hash.sha256sha256(Buffer.concat(buffers))}if(!(sighashType&Signature.SIGHASH_ANYONECANPAY)&&(31&sighashType)!==Signature.SIGHASH_SINGLE&&(31&sighashType)!==Signature.SIGHASH_NONE){for(var sequenceBuffers=[],m=0;m<transaction.inputs.length;m++){var sequenceBuffer=new Buffer(new Array(4));sequenceBuffer.writeUInt32LE(transaction.inputs[m].sequenceNumber,0),sequenceBuffers.push(sequenceBuffer)}hashSequence=Hash.sha256sha256(Buffer.concat(sequenceBuffers))}var outputWriter=new BufferWriter;if((31&sighashType)!==Signature.SIGHASH_SINGLE&&(31&sighashType)!==Signature.SIGHASH_NONE){for(var p=0;p<transaction.outputs.length;p++)transaction.outputs[p].toBufferWriter(outputWriter);hashOutputs=Hash.sha256sha256(outputWriter.toBuffer())}else(31&sighashType)===Signature.SIGHASH_SINGLE&&inputNumber<transaction.outputs.length&&(transaction.outputs[inputNumber].toBufferWriter(outputWriter),hashOutputs=Hash.sha256sha256(outputWriter.toBuffer()));var writer=new BufferWriter;writer.writeUInt32LE(transaction.version),writer.write(hashPrevouts),writer.write(hashSequence);var outpointId=new BufferReader(transaction.inputs[inputNumber].prevTxId).readReverse();return writer.write(outpointId),writer.writeUInt32LE(transaction.inputs[inputNumber].outputIndex),writer.write(scriptCode),writer.write(satoshisBuffer),writer.writeUInt32LE(transaction.inputs[inputNumber].sequenceNumber),writer.write(hashOutputs),writer.writeUInt32LE(transaction.nLockTime),writer.writeInt32LE(sighashType),Hash.sha256sha256(writer.toBuffer())};module.exports={sighash:sighash,sign:function(transaction,privateKey,sighashType,inputIndex,scriptCode,satoshisBuffer){var hashbuf=sighash(transaction,sighashType,inputIndex,scriptCode,satoshisBuffer);return ECDSA.sign(hashbuf,privateKey).set({nhashtype:sighashType})},verify:function(transaction,signature,publicKey,inputIndex,scriptCode,satoshisBuffer){$.checkArgument(!_.isUndefined(transaction)),$.checkArgument(!_.isUndefined(signature)&&!_.isUndefined(signature.nhashtype));var hashbuf=sighash(transaction,signature.nhashtype,inputIndex,scriptCode,satoshisBuffer);return ECDSA.verify(hashbuf,signature,publicKey)}}}).call(this,require("buffer").Buffer)},{"../crypto/bn":175,"../crypto/ecdsa":176,"../crypto/hash":177,"../crypto/signature":180,"../encoding/bufferreader":183,"../encoding/bufferwriter":184,"../script":194,"../util/preconditions":214,"./output":204,buffer:51,lodash:252}],207:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),$=require("../util/preconditions"),inherits=require("inherits"),BufferUtil=require("../util/buffer"),JSUtil=require("../util/js"),PublicKey=require("../publickey"),errors=require("../errors"),Signature=require("../crypto/signature");function TransactionSignature(arg){if(!(this instanceof TransactionSignature))return new TransactionSignature(arg);if(arg instanceof TransactionSignature)return arg;if(_.isObject(arg))return this._fromObject(arg);throw new errors.InvalidArgument("TransactionSignatures must be instantiated from an object")}inherits(TransactionSignature,Signature),TransactionSignature.prototype._fromObject=function(arg){return this._checkObjectArgs(arg),this.publicKey=new PublicKey(arg.publicKey),this.prevTxId=BufferUtil.isBuffer(arg.prevTxId)?arg.prevTxId:Buffer.from(arg.prevTxId,"hex"),this.outputIndex=arg.outputIndex,this.inputIndex=arg.inputIndex,this.signature=arg.signature instanceof Signature?arg.signature:BufferUtil.isBuffer(arg.signature)?Signature.fromBuffer(arg.signature):Signature.fromString(arg.signature),this.sigtype=arg.sigtype,this},TransactionSignature.prototype._checkObjectArgs=function(arg){$.checkArgument(PublicKey(arg.publicKey),"publicKey"),$.checkArgument(!_.isUndefined(arg.inputIndex),"inputIndex"),$.checkArgument(!_.isUndefined(arg.outputIndex),"outputIndex"),$.checkState(_.isNumber(arg.inputIndex),"inputIndex must be a number"),$.checkState(_.isNumber(arg.outputIndex),"outputIndex must be a number"),$.checkArgument(arg.signature,"signature"),$.checkArgument(arg.prevTxId,"prevTxId"),$.checkState(arg.signature instanceof Signature||BufferUtil.isBuffer(arg.signature)||JSUtil.isHexa(arg.signature),"signature must be a buffer or hexa value"),$.checkState(BufferUtil.isBuffer(arg.prevTxId)||JSUtil.isHexa(arg.prevTxId),"prevTxId must be a buffer or hexa value"),$.checkArgument(arg.sigtype,"sigtype"),$.checkState(_.isNumber(arg.sigtype),"sigtype must be a number")},TransactionSignature.prototype.toObject=TransactionSignature.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}},TransactionSignature.fromObject=function(object){return $.checkArgument(object),new TransactionSignature(object)},module.exports=TransactionSignature}).call(this,require("buffer").Buffer)},{"../crypto/signature":180,"../errors":186,"../publickey":193,"../util/buffer":212,"../util/js":213,"../util/preconditions":214,buffer:51,inherits:215,lodash:252}],208:[function(require,module,exports){(function(Buffer){"use strict";var _=require("lodash"),$=require("../util/preconditions"),buffer=require("buffer"),compare=Buffer.compare||require("buffer-compare"),errors=require("../errors"),BufferUtil=require("../util/buffer"),JSUtil=require("../util/js"),BufferReader=require("../encoding/bufferreader"),BufferWriter=require("../encoding/bufferwriter"),Hash=require("../crypto/hash"),Signature=require("../crypto/signature"),Sighash=require("./sighash"),SighashWitness=require("./sighashwitness"),Address=require("../address"),UnspentOutput=require("./unspentoutput"),Input=require("./input"),PublicKeyHashInput=Input.PublicKeyHash,PublicKeyInput=Input.PublicKey,MultiSigScriptHashInput=Input.MultiSigScriptHash,MultiSigInput=Input.MultiSig,Output=require("./output"),Script=require("../script"),PrivateKey=require("../privatekey"),BN=require("../crypto/bn");function Transaction(serialized){if(!(this instanceof Transaction))return new Transaction(serialized);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,serialized){if(serialized instanceof Transaction)return Transaction.shallowCopy(serialized);if(JSUtil.isHexa(serialized))this.fromString(serialized);else if(BufferUtil.isBuffer(serialized))this.fromBuffer(serialized);else{if(!_.isObject(serialized))throw new errors.InvalidArgument("Must provide an object or string to deserialize a transaction");this.fromObject(serialized)}}else this._newTransaction()}Transaction.DUST_AMOUNT=546,Transaction.FEE_SECURITY_MARGIN=150,Transaction.MAX_MONEY=21e14,Transaction.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8,Transaction.NLOCKTIME_MAX_VALUE=4294967295,Transaction.FEE_PER_KB=1e5,Transaction.CHANGE_OUTPUT_MAX_SIZE=62,Transaction.MAXIMUM_EXTRA_SIZE=26,Transaction.shallowCopy=function(transaction){return new Transaction(transaction.toBuffer())};var hashProperty={configurable:!1,enumerable:!0,get:function(){return this._hash=new BufferReader(this._getHash()).readReverse().toString("hex"),this._hash}},witnessHashProperty={configurable:!1,enumerable:!0,get:function(){return new BufferReader(this._getWitnessHash()).readReverse().toString("hex")}};Object.defineProperty(Transaction.prototype,"witnessHash",witnessHashProperty),Object.defineProperty(Transaction.prototype,"hash",hashProperty),Object.defineProperty(Transaction.prototype,"id",hashProperty);var ioProperty={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(Transaction.prototype,"inputAmount",ioProperty),ioProperty.get=function(){return this._getOutputAmount()},Object.defineProperty(Transaction.prototype,"outputAmount",ioProperty),Transaction.prototype._getHash=function(){return Hash.sha256sha256(this.toBuffer(!0))},Transaction.prototype._getWitnessHash=function(){return Hash.sha256sha256(this.toBuffer(!1))},Transaction.prototype.serialize=function(unsafe){return!0===unsafe||unsafe&&unsafe.disableAll?this.uncheckedSerialize():this.checkedSerialize(unsafe)},Transaction.prototype.uncheckedSerialize=Transaction.prototype.toString=function(){return this.toBuffer().toString("hex")},Transaction.prototype.checkedSerialize=function(opts){var serializationError=this.getSerializationError(opts);if(serializationError)throw serializationError.message+=" - For more information please see: https://bitcore.io/api/lib/transaction#serialization-checks",serializationError;return this.uncheckedSerialize()},Transaction.prototype.invalidSatoshis=function(){for(var invalid=!1,i=0;i<this.outputs.length;i++)this.outputs[i].invalidSatoshis()&&(invalid=!0);return invalid},Transaction.prototype.getSerializationError=function(opts){if(opts=opts||{},this.invalidSatoshis())return new errors.Transaction.InvalidSatoshis;var unspentError,unspent=this._getUnspentValue();return unspent<0?opts.disableMoreOutputThanInput||(unspentError=new errors.Transaction.InvalidOutputAmountSum):unspentError=this._hasFeeError(opts,unspent),unspentError||this._hasDustOutputs(opts)||this._isMissingSignatures(opts)},Transaction.prototype._hasFeeError=function(opts,unspent){if(!_.isUndefined(this._fee)&&this._fee!==unspent)return new errors.Transaction.FeeError.Different("Unspent value is "+unspent+" but specified fee is "+this._fee);if(!opts.disableLargeFees){var maximumFee=Math.floor(Transaction.FEE_SECURITY_MARGIN*this._estimateFee());if(unspent>maximumFee)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<minimumFee)return new errors.Transaction.FeeError.TooSmall("expected more than "+minimumFee+" but got "+unspent)}},Transaction.prototype._missingChange=function(){return!this._changeScript},Transaction.prototype._hasDustOutputs=function(opts){var index,output;if(!opts.disableDustOutputs)for(index in this.outputs)if((output=this.outputs[index]).satoshis<Transaction.DUST_AMOUNT&&!output.script.isDataOut())return new errors.Transaction.DustOutputs},Transaction.prototype._isMissingSignatures=function(opts){if(!opts.disableIsFullySigned)return this.isFullySigned()?void 0:new errors.Transaction.MissingSignatures},Transaction.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"},Transaction.prototype.toBuffer=function(noWitness){var writer=new BufferWriter;return this.toBufferWriter(writer,noWitness).toBuffer()},Transaction.prototype.hasWitnesses=function(){for(var i=0;i<this.inputs.length;i++)if(this.inputs[i].hasWitnesses())return!0;return!1},Transaction.prototype.toBufferWriter=function(writer,noWitness){writer.writeInt32LE(this.version);var hasWitnesses=this.hasWitnesses();return hasWitnesses&&!noWitness&&writer.write(new Buffer("0001","hex")),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)})),hasWitnesses&&!noWitness&&_.each(this.inputs,(function(input){var witnesses=input.getWitnesses();writer.writeVarintNum(witnesses.length);for(var j=0;j<witnesses.length;j++)writer.writeVarintNum(witnesses[j].length),writer.write(witnesses[j])})),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"),this.version=reader.readInt32LE();var sizeTxIns=reader.readVarintNum(),hasWitnesses=!1;0===sizeTxIns&&0!==reader.buf[reader.pos]&&(reader.pos+=1,hasWitnesses=!0,sizeTxIns=reader.readVarintNum());for(var i=0;i<sizeTxIns;i++){var input=Input.fromBufferReader(reader);this.inputs.push(input)}for(var sizeTxOuts=reader.readVarintNum(),j=0;j<sizeTxOuts;j++)this.outputs.push(Output.fromBufferReader(reader));if(hasWitnesses)for(var k=0;k<sizeTxIns;k++){for(var itemCount=reader.readVarintNum(),witnesses=[],l=0;l<itemCount;l++){var size=reader.readVarintNum(),item=reader.read(size);witnesses.push(item)}this.inputs[k].setWitnesses(witnesses)}return this.nLockTime=reader.readUInt32LE(),this},Transaction.prototype.toObject=Transaction.prototype.toJSON=function(){var inputs=[];this.inputs.forEach((function(input){inputs.push(input.toObject())}));var outputs=[];this.outputs.forEach((function(output){outputs.push(output.toObject())}));var obj={hash:this.hash,version:this.version,inputs:inputs,outputs:outputs,nLockTime:this.nLockTime};return this._changeScript&&(obj.changeScript=this._changeScript.toString()),_.isUndefined(this._changeIndex)||(obj.changeIndex=this._changeIndex),_.isUndefined(this._fee)||(obj.fee=this._fee),obj},Transaction.prototype.fromObject=function(arg){$.checkArgument(_.isObject(arg)||arg instanceof Transaction);var transaction,self=this;return transaction=arg instanceof Transaction?transaction.toObject():arg,_.each(transaction.inputs,(function(input){if(input.output&&input.output.script){var txin,script=new Script(input.output.script);if(script.isPublicKeyHashOut())txin=new Input.PublicKeyHash(input);else if(script.isScriptHashOut()&&input.publicKeys&&input.threshold)txin=new Input.MultiSigScriptHash(input,input.publicKeys,input.threshold,input.signatures);else{if(!script.isPublicKeyOut())throw new errors.Transaction.Input.UnsupportedScript(input.output.script);txin=new Input.PublicKey(input)}self.addInput(txin)}else self.uncheckedAddInput(new Input(input))})),_.each(transaction.outputs,(function(output){self.addOutput(new Output(output))})),transaction.changeIndex&&(this._changeIndex=transaction.changeIndex),transaction.changeScript&&(this._changeScript=new Script(transaction.changeScript)),transaction.fee&&(this._fee=transaction.fee),this.nLockTime=transaction.nLockTime,this.version=transaction.version,this._checkConsistency(arg),this},Transaction.prototype._checkConsistency=function(arg){_.isUndefined(this._changeIndex)||($.checkState(this._changeScript,"Change script is expected."),$.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),$.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),arg&&arg.hash&&$.checkState(arg.hash===this.hash,"Hash in object does not match transaction hash.")},Transaction.prototype.lockUntilDate=function(time){if($.checkArgument(time),_.isNumber(time)&&time<Transaction.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new errors.Transaction.LockTimeTooEarly;_.isDate(time)&&(time=time.getTime()/1e3);for(var i=0;i<this.inputs.length;i++)this.inputs[i].sequenceNumber===Input.DEFAULT_SEQNUMBER&&(this.inputs[i].sequenceNumber=Input.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=time,this},Transaction.prototype.lockUntilBlockHeight=function(height){if($.checkArgument(_.isNumber(height)),height>=Transaction.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new errors.Transaction.BlockHeightTooHigh;if(height<0)throw new errors.Transaction.NLockTimeOutOfRange;for(var i=0;i<this.inputs.length;i++)this.inputs[i].sequenceNumber===Input.DEFAULT_SEQNUMBER&&(this.inputs[i].sequenceNumber=Input.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=height,this},Transaction.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<Transaction.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null},Transaction.prototype.fromString=function(string){this.fromBuffer(buffer.Buffer.from(string,"hex"))},Transaction.prototype._newTransaction=function(){this.version=1,this.nLockTime=0},Transaction.prototype.from=function(utxo,pubkeys,threshold,nestedWitness,opts){if(_.isArray(utxo)){var self=this;return _.each(utxo,(function(utxo){self.from(utxo,pubkeys,threshold)})),this}return _.some(this.inputs,(function(input){return input.prevTxId.toString("hex")===utxo.txId&&input.outputIndex===utxo.outputIndex}))?this:(pubkeys&&threshold?this._fromMultisigUtxo(utxo,pubkeys,threshold,nestedWitness,opts):this._fromNonP2SH(utxo),this)},Transaction.prototype._fromNonP2SH=function(utxo){var clazz;clazz=(utxo=new UnspentOutput(utxo)).script.isPublicKeyHashOut()?PublicKeyHashInput:utxo.script.isPublicKeyOut()?PublicKeyInput:Input,this.addInput(new clazz({output:new Output({script:utxo.script,satoshis:utxo.satoshis}),prevTxId:utxo.txId,outputIndex:utxo.outputIndex,script:Script.empty()}))},Transaction.prototype._fromMultisigUtxo=function(utxo,pubkeys,threshold,nestedWitness,opts){var clazz;if($.checkArgument(threshold<=pubkeys.length,"Number of required signatures must be greater than the number of public keys"),(utxo=new UnspentOutput(utxo)).script.isMultisigOut())clazz=MultiSigInput;else{if(!utxo.script.isScriptHashOut())throw new Error("@TODO");clazz=MultiSigScriptHashInput}this.addInput(new clazz({output:new Output({script:utxo.script,satoshis:utxo.satoshis}),prevTxId:utxo.txId,outputIndex:utxo.outputIndex,script:Script.empty()},pubkeys,threshold,!1,nestedWitness,opts))},Transaction.prototype.addInput=function(input,outputScript,satoshis){if($.checkArgumentType(input,Input,"input"),!input.output&&(_.isUndefined(outputScript)||_.isUndefined(satoshis)))throw new errors.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return input.output||!outputScript||_.isUndefined(satoshis)||(outputScript=outputScript instanceof Script?outputScript:new Script(outputScript),$.checkArgumentType(satoshis,"number","satoshis"),input.output=new Output({script:outputScript,satoshis:satoshis})),this.uncheckedAddInput(input)},Transaction.prototype.uncheckedAddInput=function(input){return $.checkArgumentType(input,Input,"input"),this.inputs.push(input),this._inputAmount=void 0,this._updateChangeOutput(),this},Transaction.prototype.hasAllUtxoInfo=function(){return _.every(this.inputs.map((function(input){return!!input.output})))},Transaction.prototype.fee=function(amount){return $.checkArgument(_.isNumber(amount),"amount must be a number"),this._fee=amount,this._updateChangeOutput(),this},Transaction.prototype.feePerKb=function(amount){return $.checkArgument(_.isNumber(amount),"amount must be a number"),this._feePerKb=amount,this._updateChangeOutput(),this},Transaction.prototype.change=function(address){return $.checkArgument(address,"address is required"),this._changeScript=Script.fromAddress(address),this._updateChangeOutput(),this},Transaction.prototype.getChangeOutput=function(){return _.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]},Transaction.prototype.to=function(address,amount){if(_.isArray(address)){var self=this;return _.each(address,(function(to){self.to(to.address,to.satoshis)})),this}return $.checkArgument(JSUtil.isNaturalNumber(amount),"Amount is expected to be a positive integer"),this.addOutput(new Output({script:Script(new Address(address)),satoshis:amount})),this},Transaction.prototype.addData=function(value){return this.addOutput(new Output({script:Script.buildDataOut(value),satoshis:0})),this},Transaction.prototype.addOutput=function(output){return $.checkArgumentType(output,Output,"output"),this._addOutput(output),this._updateChangeOutput(),this},Transaction.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this},Transaction.prototype._addOutput=function(output){this.outputs.push(output),this._outputAmount=void 0},Transaction.prototype._getOutputAmount=function(){if(_.isUndefined(this._outputAmount)){var self=this;this._outputAmount=0,_.each(this.outputs,(function(output){self._outputAmount+=output.satoshis}))}return this._outputAmount},Transaction.prototype._getInputAmount=function(){return _.isUndefined(this._inputAmount)&&(this._inputAmount=_.sumBy(this.inputs,(function(input){if(_.isUndefined(input.output))throw new errors.Transaction.Input.MissingPreviousOutput;return input.output.satoshis}))),this._inputAmount},Transaction.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),_.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex);var changeAmount=this._getUnspentValue()-this.getFee();changeAmount>0?(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(),"Not all utxo information is available to sign the transaction.");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;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,sigversion,satoshis){if(_.isUndefined(sigversion)&&(sigversion=0),1===sigversion){var satoshisBuffer,subscriptBuffer=subscript.toBuffer(),scriptCodeWriter=new BufferWriter;return scriptCodeWriter.writeVarintNum(subscriptBuffer.length),scriptCodeWriter.write(subscriptBuffer),satoshis?($.checkState(JSUtil.isNaturalNumber(satoshis)),satoshisBuffer=(new BufferWriter).writeUInt64LEBN(new BN(satoshis)).toBuffer()):satoshisBuffer=this.inputs[nin].getSatoshisBuffer(),SighashWitness.verify(this,sig,pubkey,nin,scriptCodeWriter.toBuffer(),satoshisBuffer)}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;i<this.outputs.length;i++){var txout=this.outputs[i];if(txout.invalidSatoshis())return"transaction txout "+i+" satoshis is invalid";if(txout._satoshisBN.gt(new BN(Transaction.MAX_MONEY,10)))return"transaction txout "+i+" greater than MAX_MONEY";if((valueoutbn=valueoutbn.add(txout._satoshisBN)).gt(new BN(Transaction.MAX_MONEY)))return"transaction txout "+i+" total output greater than MAX_MONEY"}if(this.toBuffer().length>1e6)return"transaction over the maximum block size";var txinmap={};for(i=0;i<this.inputs.length;i++){var txin=this.inputs[i],inputid=txin.prevTxId+":"+txin.outputIndex;if(!_.isUndefined(txinmap[inputid]))return"transaction input "+i+" duplicate input";txinmap[inputid]=!0}if(this.isCoinbase()){var buf=this.inputs[0]._scriptBuffer;if(buf.length<2||buf.length>100)return"coinbase transaction script size invalid"}else for(i=0;i<this.inputs.length;i++)if(this.inputs[i].isNull())return"transaction input "+i+" has null input";return!0},Transaction.prototype.isCoinbase=function(){return 1===this.inputs.length&&this.inputs[0].isNull()},Transaction.prototype.isRBF=function(){for(var i=0;i<this.inputs.length;i++){if(this.inputs[i].sequenceNumber<Input.MAXINT-1)return!0}return!1},Transaction.prototype.enableRBF=function(){for(var i=0;i<this.inputs.length;i++){var input=this.inputs[i];input.sequenceNumber>=Input.MAXINT-1&&(input.sequenceNumber=Input.DEFAULT_RBF_SEQNUMBER)}return this},module.exports=Transaction}).call(this,require("buffer").Buffer)},{"../address":170,"../crypto/bn":175,"../crypto/hash":177,"../crypto/signature":180,"../encoding/bufferreader":183,"../encoding/bufferwriter":184,"../errors":186,"../privatekey":192,"../script":194,"../util/buffer":212,"../util/js":213,"../util/preconditions":214,"./input":198,"./output":204,"./sighash":205,"./sighashwitness":206,"./unspentoutput":209,buffer:51,"buffer-compare":220,lodash:252}],209:[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: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"},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":170,"../script":194,"../unit":210,"../util/js":213,"../util/preconditions":214,lodash:252}],210:[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"<Unit: "+this.toString()+">"},module.exports=Unit},{"./errors":186,"./util/preconditions":214,lodash:252}],211:[function(require,module,exports){"use strict";var _=require("lodash"),URL=require("url"),Address=require("./address"),Unit=require("./unit"),URI=function(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"!=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("bitcoin:"!==info.protocol)throw new TypeError("Invalid bitcoin 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");for(var key in this.address=new Address(obj.address),this.network=this.address.network,this.amount=obj.amount,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<URI.Members.length;i++){var m=URI.Members[i];this.hasOwnProperty(m)&&void 0!==this[m]&&(json[m]=this[m].toString())}return _.extend(json,this.extras),json},URI.prototype.toString=function(){var query={};return this.amount&&(query.amount=Unit.fromSatoshis(this.amount).toBTC()),this.message&&(query.message=this.message),this.label&&(query.label=this.label),this.r&&(query.r=this.r),_.extend(query,this.extras),URL.format({protocol:"bitcoin:",host:this.address,query:query})},URI.prototype.inspect=function(){return"<URI: "+this.toString()+">"},module.exports=URI},{"./address":170,"./unit":210,lodash:252,url:163}],212:[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<length;i++)if(a[i]!==b[i])return!1;return!0}module.exports={fill:function(buffer,value){$.checkArgumentType(buffer,"Buffer","buffer"),$.checkArgumentType(value,"number","value");for(var length=buffer.length,i=0;i<length;i++)buffer[i]=value;return buffer},copy:function(original){var buffer=Buffer.alloc(original.length);return original.copy(buffer),buffer},isBuffer:function(arg){return buffer.Buffer.isBuffer(arg)||arg instanceof Uint8Array},emptyBuffer:function(bytes){$.checkArgumentType(bytes,"number","bytes");for(var result=new buffer.Buffer(bytes),i=0;i<bytes;i++)result.write("\0",i);return result},concat:buffer.Buffer.concat,equals:equals,equal:equals,integerAsSingleByteBuffer:function(integer){return $.checkArgumentType(integer,"number","integer"),new buffer.Buffer([255&integer])},integerAsBuffer:function(integer){$.checkArgumentType(integer,"number","integer");var bytes=[];return bytes.push(integer>>24&255),bytes.push(integer>>16&255),bytes.push(integer>>8&255),bytes.push(255&integer),Buffer.from(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<param.length;i++)ret[i]=param[param.length-i-1];return ret},hexToBuffer:function(string){return assert(js.isHexa(string)),new buffer.Buffer(string,"hex")}},module.exports.NULL_HASH=module.exports.fill(Buffer.alloc(32),0),module.exports.EMPTY_BUFFER=Buffer.alloc(0)}).call(this,require("buffer").Buffer)},{"./js":213,"./preconditions":214,assert:15,buffer:51}],213:[function(require,module,exports){"use strict";var _=require("lodash"),isHexa=function(value){return!!_.isString(value)&&/^[0-9a-fA-F]+$/.test(value)};module.exports={isValidJSON:function(arg){var parsed;if(!_.isString(arg))return!1;try{parsed=JSON.parse(arg)}catch(e){return!1}return"object"==typeof parsed},isHexa:isHexa,isHexaString:isHexa,cloneArray:function(array){return[].concat(array)},defineImmutable:function(target,values){return Object.keys(values).forEach((function(key){Object.defineProperty(target,key,{configurable:!1,enumerable:!0,value:values[key]})})),target},isNaturalNumber:function(value){return"number"==typeof value&&isFinite(value)&&Math.floor(value)===value&&value>=0}}},{lodash:252}],214:[function(require,module,exports){"use strict";var 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(typeof argument!==type)throw new errors.InvalidArgumentType(argument,type,argumentName)}else if(!(argument instanceof type))throw new errors.InvalidArgumentType(argument,type.name,argumentName)}}},{"../errors":186,buffer:51,lodash:252}],215:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{dup:16}],216:[function(require,module,exports){module.exports={name:"bitcore-lib-p256",version:"0.16.0",description:"A pure and powerful JavaScript Bitcoin library.",author:"BitPay <dev@bitpay.com>",main:"index.js",scripts:{lint:"gulp lint",test:"gulp test",coverage:"gulp coverage",build:"gulp"},keywords:["bitcoin","transaction","address","p2p","ecies","cryptocurrency","blockchain","payment","bip21","bip32","bip37","bip69","bip70","multisig"],repository:{type:"git",url:"https://github.com/bitpay/bitcore-lib.git"},browser:{request:"browser-request"},dependencies:{"bn.js":"=4.11.8",bs58:"=4.0.1","buffer-compare":"=1.1.1",elliptic:"=6.4.0",inherits:"=2.0.1",lodash:"=4.17.11"},devDependencies:{"bitcore-build":"https://github.com/bitpay/bitcore-build.git#1023e8a99cd42b9241ccafe8e34c52f308c10284",brfs:"^2.0.1",chai:"^4.2.0",gulp:"^4.0.0",sinon:"^7.1.1"},license:"MIT"}},{}],217:[function(require,module,exports){arguments[4][20][0].apply(exports,arguments)},{buffer:22,dup:20}],218:[function(require,module,exports){arguments[4][21][0].apply(exports,arguments)},{crypto:22,dup:21}],219:[function(require,module,exports){var basex=require("base-x");module.exports=basex("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":168}],220:[function(require,module,exports){module.exports=function(a,b){if("function"==typeof a.compare)return a.compare(b);if(a===b)return 0;for(var x=a.length,y=b.length,i=0,len=Math.min(x,y);i<len&&a[i]===b[i];)++i;return i!==len&&(x=a[i],y=b[i]),x<y?-1:y<x?1:0}},{}],221:[function(require,module,exports){arguments[4][70][0].apply(exports,arguments)},{"../package.json":236,"./elliptic/curve":224,"./elliptic/curves":227,"./elliptic/ec":228,"./elliptic/eddsa":231,"./elliptic/utils":235,brorand:218,dup:70}],222:[function(require,module,exports){"use strict";var BN=require("bn.js"),utils=require("../../elliptic").utils,getNAF=utils.getNAF,getJSF=utils.getJSF,assert=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);var adjustCount=this.n&&this.p.div(this.n);!adjustCount||adjustCount.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(curve,type){this.curve=curve,this.type=type,this.precomputed=null}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<<doubles.step+1)-(doubles.step%2==0?2:1);I/=3;for(var repr=[],j=0;j<naf.length;j+=doubles.step){var nafW=0;for(k=j+doubles.step-1;k>=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<repr.length;j++){(nafW=repr[j])===i?b=b.mixedAdd(doubles.points[j]):nafW===-i&&(b=b.mixedAdd(doubles.points[j].neg()))}a=a.add(b)}return a.toP()},BaseCurve.prototype._wnafMul=function(p,k){var w=4,nafPoints=p._getNAFPoints(w);w=nafPoints.wnd;for(var wnd=nafPoints.points,naf=getNAF(k,w),acc=this.jpoint(null,null,null),i=naf.length-1;i>=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<len;i++){var nafPoints=(p=points[i])._getNAFPoints(defW);wndWidth[i]=nafPoints.wnd,wnd[i]=nafPoints.points}for(i=len-1;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<max;j++){var ja=0|jsf[0][j],jb=0|jsf[1][j];naf[a][j]=index[3*(ja+1)+(jb+1)],naf[b][j]=0,wnd[a]=comb}}else naf[a]=getNAF(coeffs[a],wndWidth[a]),naf[b]=getNAF(coeffs[b],wndWidth[b]),max=Math.max(naf[a].length,max),max=Math.max(naf[b].length,max)}var acc=this.jpoint(null,null,null),tmp=this._wnafT4;for(i=max;i>=0;i--){for(var k=0;i>=0;){var zero=!0;for(j=0;j<len;j++)tmp[j]=0|naf[j][i],0!==tmp[j]&&(zero=!1);if(!zero)break;k++,i--}if(i>=0&&k++,acc=acc.dblp(k),i<0)break;for(j=0;j<len;j++){var p,z=tmp[j];0!==z&&(z>0?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<len;i++)wnd[i]=null;return jacobianResult?acc:acc.toP()},BaseCurve.BasePoint=BasePoint,BasePoint.prototype.eq=function(){throw new Error("Not implemented")},BasePoint.prototype.validate=function(){return this.curve.validate(this)},BaseCurve.prototype.decodePoint=function(bytes,enc){bytes=utils.toArray(bytes,enc);var len=this.p.byteLength();if((4===bytes[0]||6===bytes[0]||7===bytes[0])&&bytes.length-1==2*len)return 6===bytes[0]?assert(bytes[bytes.length-1]%2==0):7===bytes[0]&&assert(bytes[bytes.length-1]%2==1),this.point(bytes.slice(1,1+len),bytes.slice(1+len,1+2*len));if((2===bytes[0]||3===bytes[0])&&bytes.length-1===len)return this.pointFromX(bytes.slice(1,1+len),3===bytes[0]);throw new Error("Unknown point format")},BasePoint.prototype.encodeCompressed=function(enc){return this.encode(enc,!0)},BasePoint.prototype._encode=function(compact){var len=this.curve.p.byteLength(),x=this.getX().toArray("be",len);return compact?[this.getY().isEven()?2:3].concat(x):[4].concat(x,this.getY().toArray("be",len))},BasePoint.prototype.encode=function(enc,compact){return utils.encode(this._encode(compact),enc)},BasePoint.prototype.precompute=function(power){if(this.precomputed)return this;var precomputed={doubles:null,naf:null,beta:null};return precomputed.naf=this._getNAFPoints(8),precomputed.doubles=this._getDoubles(4,power),precomputed.beta=this._getBeta(),this.precomputed=precomputed,this},BasePoint.prototype._hasDoubles=function(k){if(!this.precomputed)return!1;var doubles=this.precomputed.doubles;return!!doubles&&doubles.points.length>=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<power;i+=step){for(var j=0;j<step;j++)acc=acc.dbl();doubles.push(acc)}return{step:step,points:doubles}},BasePoint.prototype._getNAFPoints=function(wnd){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var res=[this],max=(1<<wnd)-1,dbl=1===max?null:this.dbl(),i=1;i<max;i++)res[i]=res[i-1].add(dbl);return{wnd:wnd,points:res}},BasePoint.prototype._getBeta=function(){return null},BasePoint.prototype.dblp=function(k){for(var r=this,i=0;i<k;i++)r=r.dbl();return r}},{"../../elliptic":221,"bn.js":217}],223:[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 EdwardsCurve(conf){this.twisted=1!=(0|conf.a),this.mOneA=this.twisted&&-1==(0|conf.a),this.extended=this.mOneA,Base.call(this,"edwards",conf),this.a=new BN(conf.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new BN(conf.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new BN(conf.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),assert(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|conf.c)}function Point(curve,x,y,z,t){Base.BasePoint.call(this,curve,"projective"),null===x&&null===y&&null===z?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=z?new BN(z,16):this.curve.one,this.t=t&&new BN(t,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.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}inherits(EdwardsCurve,Base),module.exports=EdwardsCurve,EdwardsCurve.prototype._mulA=function(num){return this.mOneA?num.redNeg():this.a.redMul(num)},EdwardsCurve.prototype._mulC=function(num){return this.oneC?num:this.c.redMul(num)},EdwardsCurve.prototype.jpoint=function(x,y,z,t){return this.point(x,y,z,t)},EdwardsCurve.prototype.pointFromX=function(x,odd){(x=new BN(x,16)).red||(x=x.toRed(this.red));var x2=x.redSqr(),rhs=this.c2.redSub(this.a.redMul(x2)),lhs=this.one.redSub(this.c2.redMul(this.d).redMul(x2)),y2=rhs.redMul(lhs.redInvm()),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)},EdwardsCurve.prototype.pointFromY=function(y,odd){(y=new BN(y,16)).red||(y=y.toRed(this.red));var y2=y.redSqr(),lhs=y2.redSub(this.one),rhs=y2.redMul(this.d).redAdd(this.one),x2=lhs.redMul(rhs.redInvm());if(0===x2.cmp(this.zero)){if(odd)throw new Error("invalid point");return this.point(this.zero,y)}var x=x2.redSqrt();if(0!==x.redSqr().redSub(x2).cmp(this.zero))throw new Error("invalid point");return x.isOdd()!==odd&&(x=x.redNeg()),this.point(x,y)},EdwardsCurve.prototype.validate=function(point){if(point.isInfinity())return!0;point.normalize();var x2=point.x.redSqr(),y2=point.y.redSqr(),lhs=x2.redMul(this.a).redAdd(y2),rhs=this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));return 0===lhs.cmp(rhs)},inherits(Point,Base.BasePoint),EdwardsCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},EdwardsCurve.prototype.point=function(x,y,z,t){return new Point(this,x,y,z,t)},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1],obj[2])},Point.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},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":221,"../curve":224,"bn.js":217,inherits:250}],224:[function(require,module,exports){arguments[4][73][0].apply(exports,arguments)},{"./base":222,"./edwards":223,"./mont":225,"./short":226,dup:73}],225:[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))}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(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)},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()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},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":221,"../curve":224,"bn.js":217,inherits:250}],226:[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)}function Point(curve,x,y,isRed){Base.BasePoint.call(this,curve,"affine"),null===x&&null===y?(this.x=null,this.y=null,this.inf=!0):(this.x=new BN(x,16),this.y=new BN(y,16),isRed&&(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 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(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<points.length;i++){var split=this._endoSplit(coeffs[i]),p=points[i],beta=p._getBeta();split.k1.negative&&(split.k1.ineg(),p=p.neg(!0)),split.k2.negative&&(split.k2.ineg(),beta=beta.neg(!0)),npoints[2*i]=p,npoints[2*i+1]=beta,ncoeffs[2*i]=split.k1,ncoeffs[2*i+1]=split.k2}for(var res=this._wnafMulAdd(1,npoints,ncoeffs,2*i,jacobianResult),j=0;j<2*i;j++)npoints[j]=null,ncoeffs[j]=null;return res},inherits(Point,Base.BasePoint),ShortCurve.prototype.point=function(x,y,isRed){return new Point(this,x,y,isRed)},ShortCurve.prototype.pointFromJSON=function(obj,red){return Point.fromJSON(this,obj,red)},Point.prototype._getBeta=function(){if(this.curve.endo){var pre=this.precomputed;if(pre&&pre.beta)return pre.beta;var beta=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(pre){var curve=this.curve,endoMul=function(p){return curve.point(p.x.redMul(curve.endo.beta),p.y)};pre.beta=beta,beta.precomputed={beta:null,naf:pre.naf&&{wnd:pre.naf.wnd,points:pre.naf.points.map(endoMul)},doubles:pre.doubles&&{step:pre.doubles.step,points:pre.doubles.points.map(endoMul)}}}return beta}},Point.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Point.fromJSON=function(curve,obj,red){"string"==typeof obj&&(obj=JSON.parse(obj));var res=curve.point(obj[0],obj[1],red);if(!obj[2])return res;function obj2point(obj){return curve.point(obj[0],obj[1],red)}var pre=obj[2];return res.precomputed={beta:null,doubles:pre.doubles&&{step:pre.doubles.step,points:[res].concat(pre.doubles.points.map(obj2point))},naf:pre.naf&&{wnd:pre.naf.wnd,points:[res].concat(pre.naf.points.map(obj2point))}},res},Point.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},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(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,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<pow;i++)r=r.dbl();return r}var a=this.curve.a,tinv=this.curve.tinv,jx=this.x,jy=this.y,jz=this.z,jz4=jz.redSqr().redSqr(),jyd=jy.redAdd(jy);for(i=0;i<pow;i++){var jx2=jx.redSqr(),jyd2=jyd.redSqr(),jyd4=jyd2.redSqr(),c=jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)),t1=jx.redMul(jyd2),nx=c.redSqr().redISub(t1.redAdd(t1)),t2=t1.redISub(nx),dny=c.redMul(t2);dny=dny.redIAdd(dny).redISub(jyd4);var nz=jyd.redMul(jz);i+1<pow&&(jz4=jz4.redMul(jyd4)),jx=nx,jz=nz,jyd=dny}return this.curve.jpoint(jx,jyd.redMul(tinv),jz)},JPoint.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},JPoint.prototype._zeroDbl=function(){var nx,ny,nz;if(this.zOne){var xx=this.x.redSqr(),yy=this.y.redSqr(),yyyy=yy.redSqr(),s=this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);s=s.redIAdd(s);var m=xx.redAdd(xx).redIAdd(xx),t=m.redSqr().redISub(s).redISub(s),yyyy8=yyyy.redIAdd(yyyy);yyyy8=(yyyy8=yyyy8.redIAdd(yyyy8)).redIAdd(yyyy8),nx=t,ny=m.redMul(s.redISub(t)).redISub(yyyy8),nz=this.y.redAdd(this.y)}else{var a=this.x.redSqr(),b=this.y.redSqr(),c=b.redSqr(),d=this.x.redAdd(b).redSqr().redISub(a).redISub(c);d=d.redIAdd(d);var e=a.redAdd(a).redIAdd(a),f=e.redSqr(),c8=c.redIAdd(c);c8=(c8=c8.redIAdd(c8)).redIAdd(c8),nx=f.redISub(d).redISub(d),ny=e.redMul(d.redISub(nx)).redISub(c8),nz=(nz=this.y.redMul(this.z)).redIAdd(nz)}return this.curve.jpoint(nx,ny,nz)},JPoint.prototype._threeDbl=function(){var nx,ny,nz;if(this.zOne){var xx=this.x.redSqr(),yy=this.y.redSqr(),yyyy=yy.redSqr(),s=this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);s=s.redIAdd(s);var m=xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a),t=m.redSqr().redISub(s).redISub(s);nx=t;var yyyy8=yyyy.redIAdd(yyyy);yyyy8=(yyyy8=yyyy8.redIAdd(yyyy8)).redIAdd(yyyy8),ny=m.redMul(s.redISub(t)).redISub(yyyy8),nz=this.y.redAdd(this.y)}else{var delta=this.z.redSqr(),gamma=this.y.redSqr(),beta=this.x.redMul(gamma),alpha=this.x.redSub(delta).redMul(this.x.redAdd(delta));alpha=alpha.redAdd(alpha).redIAdd(alpha);var beta4=beta.redIAdd(beta),beta8=(beta4=beta4.redIAdd(beta4)).redAdd(beta4);nx=alpha.redSqr().redISub(beta8),nz=this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);var ggamma8=gamma.redSqr();ggamma8=(ggamma8=(ggamma8=ggamma8.redIAdd(ggamma8)).redIAdd(ggamma8)).redIAdd(ggamma8),ny=alpha.redMul(beta4.redISub(nx)).redISub(ggamma8)}return this.curve.jpoint(nx,ny,nz)},JPoint.prototype._dbl=function(){var a=this.curve.a,jx=this.x,jy=this.y,jz=this.z,jz4=jz.redSqr().redSqr(),jx2=jx.redSqr(),jy2=jy.redSqr(),c=jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)),jxd4=jx.redAdd(jx),t1=(jxd4=jxd4.redIAdd(jxd4)).redMul(jy2),nx=c.redSqr().redISub(t1.redAdd(t1)),t2=t1.redISub(nx),jyd8=jy2.redSqr();jyd8=(jyd8=(jyd8=jyd8.redIAdd(jyd8)).redIAdd(jyd8)).redIAdd(jyd8);var ny=c.redMul(t2).redISub(jyd8),nz=jy.redAdd(jy).redMul(jz);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var xx=this.x.redSqr(),yy=this.y.redSqr(),zz=this.z.redSqr(),yyyy=yy.redSqr(),m=xx.redAdd(xx).redIAdd(xx),mm=m.redSqr(),e=this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy),ee=(e=(e=(e=e.redIAdd(e)).redAdd(e).redIAdd(e)).redISub(mm)).redSqr(),t=yyyy.redIAdd(yyyy);t=(t=(t=t.redIAdd(t)).redIAdd(t)).redIAdd(t);var u=m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t),yyu4=yy.redMul(u);yyu4=(yyu4=yyu4.redIAdd(yyu4)).redIAdd(yyu4);var nx=this.x.redMul(ee).redISub(yyu4);nx=(nx=nx.redIAdd(nx)).redIAdd(nx);var ny=this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));ny=(ny=(ny=ny.redIAdd(ny)).redIAdd(ny)).redIAdd(ny);var nz=this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.mul=function(k,kbase){return k=new BN(k,kbase),this.curve._wnafMul(this,k)},JPoint.prototype.eq=function(p){if("affine"===p.type)return this.eq(p.toJ());if(this===p)return!0;var z2=this.z.redSqr(),pz2=p.z.redSqr();if(0!==this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0))return!1;var z3=z2.redMul(this.z),pz3=pz2.redMul(p.z);return 0===this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0)},JPoint.prototype.eqXToP=function(x){var zs=this.z.redSqr(),rx=x.toRed(this.curve.red).redMul(zs);if(0===this.x.cmp(rx))return!0;for(var xc=x.clone(),t=this.curve.redN.redMul(zs);;){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},JPoint.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},JPoint.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":221,"../curve":224,"bn.js":217,inherits:250}],227:[function(require,module,exports){"use strict";var pre,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")}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}})}curves.PresetCurve=PresetCurve,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"]});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":221,"./precomputed/secp256k1":234,"hash.js":237}],228:[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 p,sinv=s.invm(this.n),u1=sinv.mul(msg).umod(this.n),u2=sinv.mul(r).umod(this.n);return this.curve._maxwellTrick?!(p=this.g.jmulAdd(u1,key.getPublic(),u2)).isInfinity()&&p.eqXToP(r):!(p=this.g.mulAdd(u1,key.getPublic(),u2)).isInfinity()&&0===p.getX().umod(this.n).cmp(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":221,"./key":229,"./signature":230,"bn.js":217,"hmac-drbg":249}],229:[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"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},{"../../elliptic":221,"bn.js":217}],230:[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)}function Position(){this.place=0}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<octetLen;i++,off++)val<<=8,val|=buf[off];return p.place=off,val}function rmPadding(buf){for(var i=0,len=buf.length-1;!buf[i]&&!(128&buf[i+1])&&i<len;)i++;return 0===i?buf:buf.slice(i)}function constructLength(arr,len){if(len<128)arr.push(len);else{var octets=1+(Math.log(len)/Math.LN2>>>3);for(arr.push(128|octets);--octets;)arr.push(len>>>(octets<<3)&255);arr.push(len)}}module.exports=Signature,Signature.prototype._importDER=function(data,enc){data=utils.toArray(data,enc);var p=new Position;if(48!==data[p.place++])return!1;if(getLength(data,p)+p.place!==data.length)return!1;if(2!==data[p.place++])return!1;var rlen=getLength(data,p),r=data.slice(p.place,rlen+p.place);if(p.place+=rlen,2!==data[p.place++])return!1;var slen=getLength(data,p);if(data.length!==slen+p.place)return!1;var s=data.slice(p.place,slen+p.place);return 0===r[0]&&128&r[1]&&(r=r.slice(1)),0===s[0]&&128&s[1]&&(s=s.slice(1)),this.r=new BN(r),this.s=new BN(s),this.recoveryParam=null,!0},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":221,"bn.js":217}],231:[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<arguments.length;i++)hash.update(arguments[i]);return utils.intFromLE(hash.digest()).umod(this.curve.n)},EDDSA.prototype.keyFromPublic=function(pub){return KeyPair.fromPublic(this,pub)},EDDSA.prototype.keyFromSecret=function(secret){return KeyPair.fromSecret(this,secret)},EDDSA.prototype.makeSignature=function(sig){return sig instanceof Signature?sig:new Signature(this,sig)},EDDSA.prototype.encodePoint=function(point){var enc=point.getY().toArray("le",this.encodingLength);return enc[this.encodingLength-1]|=point.getX().isOdd()?128:0,enc},EDDSA.prototype.decodePoint=function(bytes){var lastIx=(bytes=utils.parseBytes(bytes)).length-1,normed=bytes.slice(0,lastIx).concat(-129&bytes[lastIx]),xIsOdd=0!=(128&bytes[lastIx]),y=utils.intFromLE(normed);return this.curve.pointFromY(y,xIsOdd)},EDDSA.prototype.encodeInt=function(num){return num.toArray("le",this.encodingLength)},EDDSA.prototype.decodeInt=function(bytes){return utils.intFromLE(bytes)},EDDSA.prototype.isPoint=function(val){return val instanceof this.pointClass}},{"../../elliptic":221,"./key":232,"./signature":233,"hash.js":237}],232:[function(require,module,exports){"use strict";var utils=require("../../elliptic").utils,assert=utils.assert,parseBytes=utils.parseBytes,cachedProperty=utils.cachedProperty;function KeyPair(eddsa,params){this.eddsa=eddsa,this._secret=parseBytes(params.secret),eddsa.isPoint(params.pub)?this._pub=params.pub:this._pubBytes=parseBytes(params.pub)}KeyPair.fromPublic=function(eddsa,pub){return pub instanceof KeyPair?pub:new KeyPair(eddsa,{pub:pub})},KeyPair.fromSecret=function(eddsa,secret){return secret instanceof KeyPair?secret:new KeyPair(eddsa,{secret:secret})},KeyPair.prototype.secret=function(){return this._secret},cachedProperty(KeyPair,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),cachedProperty(KeyPair,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),cachedProperty(KeyPair,"privBytes",(function(){var eddsa=this.eddsa,hash=this.hash(),lastIx=eddsa.encodingLength-1,a=hash.slice(0,eddsa.encodingLength);return a[0]&=248,a[lastIx]&=127,a[lastIx]|=64,a})),cachedProperty(KeyPair,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),cachedProperty(KeyPair,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),cachedProperty(KeyPair,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),KeyPair.prototype.sign=function(message){return assert(this._secret,"KeyPair can only verify"),this.eddsa.sign(message,this)},KeyPair.prototype.verify=function(message,sig){return this.eddsa.verify(message,sig,this)},KeyPair.prototype.getSecret=function(enc){return assert(this._secret,"KeyPair is public only"),utils.encode(this.secret(),enc)},KeyPair.prototype.getPublic=function(enc){return utils.encode(this.pubBytes(),enc)},module.exports=KeyPair},{"../../elliptic":221}],233:[function(require,module,exports){"use strict";var BN=require("bn.js"),utils=require("../../elliptic").utils,assert=utils.assert,cachedProperty=utils.cachedProperty,parseBytes=utils.parseBytes;function Signature(eddsa,sig){this.eddsa=eddsa,"object"!=typeof sig&&(sig=parseBytes(sig)),Array.isArray(sig)&&(sig={R:sig.slice(0,eddsa.encodingLength),S:sig.slice(eddsa.encodingLength)}),assert(sig.R&&sig.S,"Signature without R or S"),eddsa.isPoint(sig.R)&&(this._R=sig.R),sig.S instanceof BN&&(this._S=sig.S),this._Rencoded=Array.isArray(sig.R)?sig.R:sig.Rencoded,this._Sencoded=Array.isArray(sig.S)?sig.S:sig.Sencoded}cachedProperty(Signature,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),cachedProperty(Signature,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),cachedProperty(Signature,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),cachedProperty(Signature,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),Signature.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Signature.prototype.toHex=function(){return utils.encode(this.toBytes(),"hex").toUpperCase()},module.exports=Signature},{"../../elliptic":221,"bn.js":217}],234:[function(require,module,exports){arguments[4][83][0].apply(exports,arguments)},{dup:83}],235:[function(require,module,exports){arguments[4][84][0].apply(exports,arguments)},{"bn.js":217,dup:84,"minimalistic-assert":253,"minimalistic-crypto-utils":254}],236:[function(require,module,exports){module.exports={name:"elliptic",version:"6.4.0",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],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",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny <fedor@indutny.com>",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",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"},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"}}},{}],237:[function(require,module,exports){arguments[4][89][0].apply(exports,arguments)},{"./hash/common":238,"./hash/hmac":239,"./hash/ripemd":240,"./hash/sha":241,"./hash/utils":248,dup:89}],238:[function(require,module,exports){arguments[4][90][0].apply(exports,arguments)},{"./utils":248,dup:90,"minimalistic-assert":253}],239:[function(require,module,exports){arguments[4][91][0].apply(exports,arguments)},{"./utils":248,dup:91,"minimalistic-assert":253}],240:[function(require,module,exports){arguments[4][92][0].apply(exports,arguments)},{"./common":238,"./utils":248,dup:92}],241:[function(require,module,exports){arguments[4][93][0].apply(exports,arguments)},{"./sha/1":242,"./sha/224":243,"./sha/256":244,"./sha/384":245,"./sha/512":246,dup:93}],242:[function(require,module,exports){arguments[4][94][0].apply(exports,arguments)},{"../common":238,"../utils":248,"./common":247,dup:94}],243:[function(require,module,exports){arguments[4][95][0].apply(exports,arguments)},{"../utils":248,"./256":244,dup:95}],244:[function(require,module,exports){arguments[4][96][0].apply(exports,arguments)},{"../common":238,"../utils":248,"./common":247,dup:96,"minimalistic-assert":253}],245:[function(require,module,exports){arguments[4][97][0].apply(exports,arguments)},{"../utils":248,"./512":246,dup:97}],246:[function(require,module,exports){arguments[4][98][0].apply(exports,arguments)},{"../common":238,"../utils":248,dup:98,"minimalistic-assert":253}],247:[function(require,module,exports){arguments[4][99][0].apply(exports,arguments)},{"../utils":248,dup:99}],248:[function(require,module,exports){"use strict";var assert=require("minimalistic-assert"),inherits=require("inherits");function htonl(w){return(w>>>24|w>>>8&65280|w<<8&16711680|(255&w)<<24)>>>0}function zero2(word){return 1===word.length?"0"+word:word}function zero8(word){return 7===word.length?"0"+word:6===word.length?"00"+word:5===word.length?"000"+word:4===word.length?"0000"+word:3===word.length?"00000"+word:2===word.length?"000000"+word:1===word.length?"0000000"+word:word}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<msg.length;i+=2)res.push(parseInt(msg[i]+msg[i+1],16))}else for(var i=0;i<msg.length;i++){var c=msg.charCodeAt(i),hi=c>>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}else for(i=0;i<msg.length;i++)res[i]=0|msg[i];return res},exports.toHex=function(msg){for(var res="",i=0;i<msg.length;i++)res+=zero2(msg[i].toString(16));return res},exports.htonl=htonl,exports.toHex32=function(msg,endian){for(var res="",i=0;i<msg.length;i++){var w=msg[i];"little"===endian&&(w=htonl(w)),res+=zero8(w.toString(16))}return res},exports.zero2=zero2,exports.zero8=zero8,exports.join32=function(msg,start,end,endian){var len=end-start;assert(len%4==0);for(var res=new Array(len/4),i=0,k=start;i<res.length;i++,k+=4){var w;w="big"===endian?msg[k]<<24|msg[k+1]<<16|msg[k+2]<<8|msg[k+3]:msg[k+3]<<24|msg[k+2]<<16|msg[k+1]<<8|msg[k],res[i]=w>>>0}return res},exports.split32=function(msg,endian){for(var res=new Array(4*msg.length),i=0,k=0;i<msg.length;i++,k+=4){var m=msg[i];"big"===endian?(res[k]=m>>>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<<b|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<al?1:0)+ah+bh;buf[pos]=hi>>>0,buf[pos+1]=lo},exports.sum64_hi=function(ah,al,bh,bl){return(al+bl>>>0<al?1:0)+ah+bh>>>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)<al?1:0,carry+=(lo=lo+cl>>>0)<cl?1:0,ah+bh+ch+dh+(carry+=(lo=lo+dl>>>0)<dl?1: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)<al?1:0,carry+=(lo=lo+cl>>>0)<cl?1:0,carry+=(lo=lo+dl>>>0)<dl?1:0,ah+bh+ch+dh+eh+(carry+=(lo=lo+el>>>0)<el?1: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:250,"minimalistic-assert":253}],249:[function(require,module,exports){arguments[4][101][0].apply(exports,arguments)},{dup:101,"hash.js":237,"minimalistic-assert":253,"minimalistic-crypto-utils":254}],250:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{dup:16}],251:[function(require,module,exports){(function(Buffer){var navigator={userAgent:!1},window={}; | ||
28 | /*! | ||
29 | Copyright (c) 2011, Yahoo! Inc. All rights reserved. | ||
30 | Code licensed under the BSD License: | ||
31 | http://developer.yahoo.com/yui/license.html | ||
32 | version: 2.9.0 | ||
33 | */ | ||
34 | if(void 0===YAHOO)var YAHOO={};YAHOO.lang={extend:function(g,h,f){if(!h||!g)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var d=function(){};if(d.prototype=h.prototype,g.prototype=new d,g.prototype.constructor=g,g.superclass=h.prototype,h.prototype.constructor==Object.prototype.constructor&&(h.prototype.constructor=h),f){var b;for(b in f)g.prototype[b]=f[b];var e=function(){},c=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(e=function(j,i){for(b=0;b<c.length;b+=1){var l=c[b],k=i[l];"function"==typeof k&&k!=Object.prototype[l]&&(j[l]=k)}})}catch(a){}e(g.prototype,f)}}}; | ||
35 | /*! CryptoJS v3.1.2 core-fix.js | ||
36 | * code.google.com/p/crypto-js | ||
37 | * (c) 2009-2013 by Jeff Mott. All rights reserved. | ||
38 | * code.google.com/p/crypto-js/wiki/License | ||
39 | * THIS IS FIX of 'core.js' to fix Hmac issue. | ||
40 | * https://code.google.com/p/crypto-js/issues/detail?id=84 | ||
41 | * https://crypto-js.googlecode.com/svn-history/r667/branches/3.x/src/core.js | ||
42 | */ | ||
43 | var e,a,b,j,l,m,h,d,c,i,k,CryptoJS=CryptoJS||(e=Math,b=(a={}).lib={},j=b.Base=function(){function n(){}return{extend:function(p){n.prototype=this;var o=new n;return p&&o.mixIn(p),o.hasOwnProperty("init")||(o.init=function(){o.$super.init.apply(this,arguments)}),o.init.prototype=o,o.$super=this,o},create:function(){var o=this.extend();return o.init.apply(o,arguments),o},init:function(){},mixIn:function(p){for(var o in p)p.hasOwnProperty(o)&&(this[o]=p[o]);p.hasOwnProperty("toString")&&(this.toString=p.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),l=b.WordArray=j.extend({init:function(o,n){o=this.words=o||[],this.sigBytes=null!=n?n:4*o.length},toString:function(n){return(n||h).stringify(this)},concat:function(t){var q=this.words,p=t.words,n=this.sigBytes,s=t.sigBytes;if(this.clamp(),n%4)for(var r=0;r<s;r++){var o=p[r>>>2]>>>24-r%4*8&255;q[n+r>>>2]|=o<<24-(n+r)%4*8}else for(r=0;r<s;r+=4)q[n+r>>>2]=p[r>>>2];return this.sigBytes+=s,this},clamp:function(){var o=this.words,n=this.sigBytes;o[n>>>2]&=4294967295<<32-n%4*8,o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);return n.words=this.words.slice(0),n},random:function(p){for(var o=[],n=0;n<p;n+=4)o.push(4294967296*e.random()|0);return new l.init(o,p)}}),m=a.enc={},h=m.Hex={stringify:function(p){for(var r=p.words,o=p.sigBytes,q=[],n=0;n<o;n++){var s=r[n>>>2]>>>24-n%4*8&255;q.push((s>>>4).toString(16)),q.push((15&s).toString(16))}return q.join("")},parse:function(p){for(var n=p.length,q=[],o=0;o<n;o+=2)q[o>>>3]|=parseInt(p.substr(o,2),16)<<24-o%8*4;return new l.init(q,n/2)}},d=m.Latin1={stringify:function(q){for(var r=q.words,p=q.sigBytes,n=[],o=0;o<p;o++){var s=r[o>>>2]>>>24-o%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(p){for(var n=p.length,q=[],o=0;o<n;o++)q[o>>>2]|=(255&p.charCodeAt(o))<<24-o%4*8;return new l.init(q,n)}},c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error("Malformed UTF-8 data")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}},i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init,this._nDataBytes=0},_append:function(n){"string"==typeof n&&(n=c.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data,x=q.words,n=q.sigBytes,t=this.blockSize,u=n/(4*t),s=(u=w?e.ceil(u):e.max((0|u)-this._minBufferSize,0))*t,r=e.min(4*s,n);if(s){for(var p=0;p<s;p+=t)this._doProcessBlock(x,p);var o=x.splice(0,s);q.sigBytes-=r}return new l.init(o,r)},clone:function(){var n=j.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0}),b.Hasher=i.extend({cfg:j.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset()},reset:function(){i.reset.call(this),this._doReset()},update:function(n){return this._append(n),this._process(),this},finalize:function(n){return n&&this._append(n),this._doFinalize()},blockSize:16,_createHelper:function(n){return function(p,o){return new n.init(o).finalize(p)}},_createHmacHelper:function(n){return function(p,o){return new k.HMAC.init(n,o).finalize(p)}}}),k=a.algo={},a);!function(g){var a,f=(a=CryptoJS).lib,e=f.Base,h=f.WordArray;(a=a.x64={}).Word=e.extend({init:function(b,c){this.high=b,this.low=c}}),a.WordArray=e.extend({init:function(b,c){b=this.words=b||[],this.sigBytes=null!=c?c:8*b.length},toX32:function(){for(var b=this.words,c=b.length,a=[],d=0;d<c;d++){var e=b[d];a.push(e.high),a.push(e.low)}return h.create(a,this.sigBytes)},clone:function(){for(var b=e.clone.call(this),c=b.words=this.words.slice(0),a=c.length,d=0;d<a;d++)c[d]=c[d].clone();return b}})}(),CryptoJS.lib.Cipher||function(u){var f=(g=CryptoJS).lib,k=f.Base,l=f.WordArray,q=f.BufferedBlockAlgorithm,r=g.enc.Base64,v=g.algo.EvpKDF,n=f.Cipher=q.extend({cfg:k.extend(),createEncryptor:function(a,b){return this.create(this._ENC_XFORM_MODE,a,b)},createDecryptor:function(a,b){return this.create(this._DEC_XFORM_MODE,a,b)},init:function(a,b,c){this.cfg=this.cfg.extend(c),this._xformMode=a,this._key=b,this.reset()},reset:function(){q.reset.call(this),this._doReset()},process:function(a){return this._append(a),this._process()},finalize:function(a){return a&&this._append(a),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(a){return{encrypt:function(b,c,d){return("string"==typeof c?s:j).encrypt(a,b,c,d)},decrypt:function(b,c,d){return("string"==typeof c?s:j).decrypt(a,b,c,d)}}}});f.StreamCipher=n.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var m=g.mode={},t=function(a,b,c){var d=this._iv;d?this._iv=void 0:d=this._prevBlock;for(var e=0;e<c;e++)a[b+e]^=d[e]},h=(f.BlockCipherMode=k.extend({createEncryptor:function(a,b){return this.Encryptor.create(a,b)},createDecryptor:function(a,b){return this.Decryptor.create(a,b)},init:function(a,b){this._cipher=a,this._iv=b}})).extend();h.Encryptor=h.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize;t.call(this,a,b,d),c.encryptBlock(a,b),this._prevBlock=a.slice(b,b+d)}}),h.Decryptor=h.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize,e=a.slice(b,b+d);c.decryptBlock(a,b),t.call(this,a,b,d),this._prevBlock=e}}),m=m.CBC=h,h=(g.pad={}).Pkcs7={pad:function(a,b){for(var c,d=(c=(c=4*b)-a.sigBytes%c)<<24|c<<16|c<<8|c,e=[],f=0;f<c;f+=4)e.push(d);c=l.create(e,c),a.concat(c)},unpad:function(a){a.sigBytes-=255&a.words[a.sigBytes-1>>>2]}},f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var b=(a=this.cfg).iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;this._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),j=(m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;return((a=a.salt)?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){var b=(a=r.parse(a)).words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4),a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);return b=e.finalize(b),e=e.cfg,p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,blockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){return d=this.cfg.extend(d),b=this._parse(b,d.format),a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}})),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){return d||(d=l.random(8)),a=v.create({keySize:b+c}).compute(a,d),c=l.create(a.words.slice(b),4*c),a.sigBytes=4*b,p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,b,c,d){return c=(d=this.cfg.extend(d)).kdf.execute(c,a.keySize,a.ivSize),d.iv=c.iv,(a=j.encrypt.call(this,a,b,c.key,d)).mixIn(c),a},decrypt:function(a,b,c,d){return d=this.cfg.extend(d),b=this._parse(b,d.format),c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt),d.iv=c.iv,j.decrypt.call(this,a,b,c.key,d)}})}(),function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;var n=0,l=0;for(k=0;256>k;k++){var f=(f=l^l<<1^l<<2^l<<3^l<<4)>>>8^255&f^99;j[n]=f,y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8,A[n]=b<<16|b>>>16,B[n]=b<<8|b>>>24,C[n]=b,b=16843009*E^65537*D^257*t^16843008*n,s[f]=b<<24|b>>>8,u[f]=b<<16|b>>>16,v[f]=b<<8|b>>>24,w[f]=b,n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,16,32,64,128,27,54];r=r.AES=x.extend({_doReset:function(){for(var e=(c=this._key).words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h<c;h++)if(h<a)b[h]=e[h];else{var d=b[h-1];h%a?6<a&&4==h%a&&(d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[255&d]):(d=j[(d=d<<8|d>>>24)>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[255&d],d^=F[h/a|0]<<24),b[h]=b[h-a]^d}for(e=this._invKeySchedule=[],a=0;a<c;a++)h=c-a,d=a%4?b[h]:b[h-4],e[a]=4>a||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>8&255]]^w[j[255&d]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3],c[e+3]=a,this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y),a=c[e+1],c[e+1]=c[e+3],c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t<n;t++){var q=b[f>>>24]^h[g>>>16&255]^d[k>>>8&255]^j[255&p]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[255&f]^a[l++],s=b[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[255&g]^a[l++];p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[255&k]^a[l++],f=q,g=r,k=s}q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[255&p])^a[l++],r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[255&f])^a[l++],s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[255&g])^a[l++],p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[255&k])^a[l++],c[e]=q,c[e+1]=r,c[e+2]=s,c[e+3]=p},keySize:8});q.AES=x._createHelper(r)}(),function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a,this._lBlock^=a<<b}function l(b,c){var a=(this._rBlock>>>b^this._lBlock)&c;this._lBlock^=a,this._rBlock^=a<<b}var h=CryptoJS,n=(e=h.lib).WordArray,e=e.BlockCipher,g=h.algo,q=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],p=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],r=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],s=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],t=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],m=g.DES=e.extend({_doReset:function(){for(var b=this._key.words,c=[],a=0;56>a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}for(b=this._subKeys=[],f=0;16>f;f++){var d=b[f]=[],e=r[f];for(a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;for(d[0]=d[0]<<1|d[0]>>>31,a=1;7>a;a++)d[a]>>>=4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}for(c=this._invSubKeys=[],a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c],this._rBlock=b[c+1],j.call(this,4,252645135),j.call(this,16,65535),l.call(this,2,858993459),l.call(this,8,16711935),j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^d[k])&t[k])>>>0];this._lBlock=h,this._rBlock=e^g}a=this._lBlock,this._lBlock=this._rBlock,this._rBlock=a,j.call(this,1,1431655765),l.call(this,8,16711935),l.call(this,2,858993459),j.call(this,16,65535),j.call(this,4,252645135),b[c]=this._lBlock,b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m),g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2))),this._des2=m.createEncryptor(n.create(b.slice(2,4))),this._des3=m.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c),this._des2.decryptBlock(b,c),this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c),this._des2.encryptBlock(b,c),this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2}),h.TripleDES=e._createHelper(g)}(),function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp(),b=[];for(var a=0;a<f;a+=3)for(var d=(e[a>>>2]>>>24-a%4*8&255)<<16|(e[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|e[a+2>>>2]>>>24-(a+2)%4*8&255,g=0;4>g&&a+.75*g<f;g++)b.push(c.charAt(d>>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join("")},parse:function(b){var e=b.length,f=this._map;(c=f.charAt(64))&&(-1!=(c=b.indexOf(c))&&(e=c));for(var c=[],a=0,d=0;d<e;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<d%4*2,h=f.indexOf(b.charAt(d))>>>6-d%4*2;c[a>>>2]|=(g|h)<<24-a%4*8,a++}return j.create(c,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(E){function h(a,f,g,j,p,h,k){return((a=a+(f&g|~f&j)+p+k)<<h|a>>>32-h)+f}function k(a,f,g,j,p,h,k){return((a=a+(f&j|g&~j)+p+k)<<h|a>>>32-h)+f}function l(a,f,g,j,h,k,l){return((a=a+(f^g^j)+h+l)<<k|a>>>32-k)+f}function n(a,f,g,j,h,k,l){return((a=a+(g^(f|~j))+h+l)<<k|a>>>32-k)+f}for(var r=CryptoJS,F=(q=r.lib).WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var p=m[j=f+g];m[j]=16711935&(p<<8|p>>>24)|4278255360&(p<<24|p>>>8)}g=this._hash.words;var j=m[f+0],q=(p=m[f+1],m[f+2]),r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=h(b=g[0],c=g[1],d=g[2],e=g[3],j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]);b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),b=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),b=k(b,c=h(c,d,e,b,D,22,a[15]),d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,c,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),b=l(b,c=k(c,d,e,b,A,20,a[31]),d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),b=n(b,c=l(c,d,e,b,q,23,a[47]),d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,C,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0,g[1]=g[1]+c|0,g[2]=g[2]+d|0,g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/4294967296);for(f[15+(j+64>>>9<<4)]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),f[14+(j+64>>>9<<4)]=16711935&(g<<8|g>>>24)|4278255360&(g<<24|g>>>8),a.sigBytes=4*(f.length+1),this._process(),f=(a=this._hash).words,g=0;4>g;g++)j=f[g],f[g]=16711935&(j<<8|j>>>24)|4278255360&(j<<24|j>>>8);return a},clone:function(){var a=s.clone.call(this);return a._hash=this._hash.clone(),a}}),r.MD5=s._createHelper(q),r.HmacMD5=s._createHmacHelper(q)}(Math),function(){var k=CryptoJS,m=(b=k.lib).WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=0|n[p+c];else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c],g=20>c?g+(1518500249+(f&h|~f&j)):40>c?g+(1859775393+(f^h^j)):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^j)-899497514),b=j,j=h,h=f<<30|f>>>2,f=e,e=g}a[0]=a[0]+e|0,a[1]=a[1]+f|0,a[2]=a[2]+h|0,a[3]=a[3]+j|0,a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;return d[e>>>5]|=128<<24-e%32,d[14+(e+64>>>9<<4)]=Math.floor(a/4294967296),d[15+(e+64>>>9<<4)]=a,b.sigBytes=4*d.length,this._process(),this._hash},clone:function(){var b=l.clone.call(this);return b._hash=this._hash.clone(),b}});k.SHA1=l._createHelper(b),k.HmacSHA1=l._createHmacHelper(b)}(),function(k){for(var g=CryptoJS,v=(h=g.lib).WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(0|q))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,.5))),t[b]=u(k.pow(l,1/3)),b++),l++}var n=[];h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=0|q[h+e];else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e],p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b),l=j,j=g,g=f,f=k+m|0,k=b,b=d,d=c,c=m+p|0}a[0]=a[0]+c|0,a[1]=a[1]+d|0,a[2]=a[2]+b|0,a[3]=a[3]+k|0,a[4]=a[4]+f|0,a[5]=a[5]+g|0,a[6]=a[6]+j|0,a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;return b[c>>>5]|=128<<24-c%32,b[14+(c+64>>>9<<4)]=k.floor(a/4294967296),b[15+(c+64>>>9<<4)]=a,d.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var b=j.clone.call(this);return b._hash=this._hash.clone(),b}});g.SHA256=j._createHelper(h),g.HmacSHA256=j._createHmacHelper(h)}(Math),function(){var b=CryptoJS,d=b.lib.WordArray,c=(a=b.algo).SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);return a.sigBytes-=4,a}});b.SHA224=c._createHelper(a),b.HmacSHA224=c._createHmacHelper(a)}(),function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,d=(e=n.x64).Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var F=(f=this._hash.words)[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=0|a[d+2*m],b=s.low=0|a[d+2*m+1];else{j=((b=(j=v[m-15]).high)>>>1|(p=j.low)<<31)^(b>>>8|p<<24)^b>>>7;var p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=((b=(u=v[m-2]).high)>>>19|(c=u.low)<<13)^(b<<3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),W=(b=v[m-7]).high,q=(t=v[m-16]).high,t=t.low;j=(j=(j=j+W+((b=p+b.low)>>>0<p>>>0?1:0))+u+((b=b+c)>>>0<c>>>0?1:0))+q+((b=b+t)>>>0<t>>>0?1:0);s.high=j,s.low=b}W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A;var T=g&x^g&y^x&y,fa=(p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),(c=ea[m]).high),da=c.low;q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+((c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)))>>>0<E>>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,l=U+(q=(q=(q=q+W+((c=c+t)>>>0<t>>>0?1:0))+fa+((c=c+da)>>>0<da>>>0?1:0))+j+((c=c+b)>>>0<b>>>0?1:0))+((h=B+c|0)>>>0<B>>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,k=q+(s=p+s+((b=u+T)>>>0<u>>>0?1:0))+((g=c+b|0)>>>0<c>>>0?1:0)|0}J=F.low=J+g,F.high=w+k+(J>>>0<g>>>0?1:0),K=e.low=K+x,e.high=X+z+(K>>>0<x>>>0?1:0),L=n.low=L+y,n.high=Y+A+(L>>>0<y>>>0?1:0),M=r.low=M+B,r.high=Z+U+(M>>>0<B>>>0?1:0),N=G.low=N+h,G.high=$+l+(N>>>0<h>>>0?1:0),O=H.low=O+C,H.high=aa+R+(O>>>0<C>>>0?1:0),P=I.low=P+D,I.high=ba+S+(P>>>0<D>>>0?1:0),Q=f.low=Q+E,f.high=ca+V+(Q>>>0<E>>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;return d[e>>>5]|=128<<24-e%32,d[30+(e+128>>>10<<5)]=Math.floor(f/4294967296),d[31+(e+128>>>10<<5)]=f,a.sigBytes=4*d.length,this._process(),this._hash.toX32()},clone:function(){var a=r.clone.call(this);return a._hash=this._hash.clone(),a},blockSize:32}),n.SHA512=r._createHelper(e),n.HmacSHA512=r._createHmacHelper(e)}(),function(){var c=CryptoJS,b=(a=c.x64).Word,e=a.WordArray,d=(a=c.algo).SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);return a.sigBytes-=16,a}});c.SHA384=d._createHelper(a),c.HmacSHA384=d._createHmacHelper(a)}(),function(){var q=CryptoJS,n=(d=q.lib).WordArray,p=d.Hasher,d=q.algo,x=n.create([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]),y=n.create([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]),z=n.create([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]),A=n.create([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]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,2053994217,0]);d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var f=e[c=v+b];e[c]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}var t,g,h,j,r,u,k,l,m,s,c=this._hash.words,d=(f=B.words,C.words),n=x.words,q=y.words,p=z.words,w=A.words;u=t=c[0],k=g=c[1],l=h=c[2],m=j=c[3],s=r=c[4];var a;for(b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?a+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a=(a=(a|=0)<<p[b]|a>>>32-p[b])+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a=(a=(a|=0)<<w[b]|a>>>32-w[b])+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0,c[1]=c[2]+j+s|0,c[2]=c[3]+r+u|0,c[3]=c[4]+t+k|0,c[4]=c[0]+g+l|0,c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;for(d[c>>>5]|=128<<24-c%32,d[14+(c+64>>>9<<4)]=16711935&(b<<8|b>>>24)|4278255360&(b<<24|b>>>8),e.sigBytes=4*(d.length+1),this._process(),d=(e=this._hash).words,b=0;5>b;b++)c=d[b],d[b]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8);return e},clone:function(){var d=p.clone.call(this);return d._hash=this._hash.clone(),d}});q.RIPEMD160=p._createHelper(d),q.HmacRIPEMD160=p._createHmacHelper(d)}(Math),function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init,"string"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b)),b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d<c;d++)h[d]^=1549556828,j[d]^=909522486;f.sigBytes=g.sigBytes=e,this.reset()},reset:function(){var a=this._hasher;a.reset(),a.update(this._iKey)},update:function(a){return this._hasher.update(a),this},finalize:function(a){var b=this._hasher;return a=b.finalize(a),b.reset(),b.finalize(this._oKey.clone().concat(a))}})}(),function(){var a,b=CryptoJS,d=(a=b.lib).Base,m=a.WordArray,q=(a=b.algo).HMAC,l=a.PBKDF2=d.extend({cfg:d.extend({keySize:4,hasher:a.SHA1,iterations:1}),init:function(a){this.cfg=this.cfg.extend(a)},compute:function(a,b){var c=this.cfg,f=q.create(c.hasher,a),g=m.create(),d=m.create([1]),l=g.words,r=d.words,n=c.keySize;for(c=c.iterations;l.length<n;){var h=f.update(b).finalize(d);f.reset();for(var j=h.words,s=j.length,k=h,p=1;p<c;p++){k=f.finalize(k),f.reset();for(var t=k.words,e=0;e<s;e++)j[e]^=t[e]}g.concat(h),r[0]++}return g.sigBytes=4*n,g}});b.PBKDF2=function(a,b,c){return l.create(c).compute(a,b)}}(); | ||
44 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ | ||
45 | */ | ||
46 | var dbits,b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64pad="=";function hex2b64(d){var b,e,a="";for(b=0;b+3<=d.length;b+=3)e=parseInt(d.substring(b,b+3),16),a+=b64map.charAt(e>>6)+b64map.charAt(63&e);if(b+1==d.length?(e=parseInt(d.substring(b,b+1),16),a+=b64map.charAt(e<<2)):b+2==d.length&&(e=parseInt(d.substring(b,b+2),16),a+=b64map.charAt(e>>2)+b64map.charAt((3&e)<<4)),b64pad)for(;(3&a.length)>0;)a+=b64pad;return a}function b64tohex(f){var e,c,a,d="",b=0;for(e=0;e<f.length&&f.charAt(e)!=b64pad;++e)(a=b64map.indexOf(f.charAt(e)))<0||(0==b?(d+=int2char(a>>2),c=3&a,b=1):1==b?(d+=int2char(c<<2|a>>4),c=15&a,b=2):2==b?(d+=int2char(c),d+=int2char(a>>2),c=3&a,b=3):(d+=int2char(c<<2|a>>4),d+=int2char(15&a),b=0));return 1==b&&(d+=int2char(c<<2)),d}function b64toBA(e){var c,d=b64tohex(e),b=new Array;for(c=0;2*c<d.length;++c)b[c]=parseInt(d.substring(2*c,2*c+2),16);return b}function BigInteger(e,d,f){null!=e&&("number"==typeof e?this.fromNumber(e,d,f):null==d&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,d))}function nbi(){return new BigInteger(null)}"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=function(f,q,r,e,o,a){for(var k=32767&q,p=q>>15;--a>=0;){var d=32767&this[f],g=this[f++]>>15,b=p*d+g*k;o=((d=k*d+((32767&b)<<15)+r[e]+(1073741823&o))>>>30)+(b>>>15)+p*g+(o>>>30),r[e++]=1073741823&d}return o},dbits=30):"Netscape"!=navigator.appName?(BigInteger.prototype.am=function(f,a,b,e,h,g){for(;--g>=0;){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864),b[e++]=67108863&d}return h},dbits=26):(BigInteger.prototype.am=function(f,q,r,e,o,a){for(var k=16383&q,p=q>>14;--a>=0;){var d=16383&this[f],g=this[f++]>>14,b=p*d+g*k;o=((d=k*d+((16383&b)<<14)+r[e]+o)>>28)+(b>>14)+p*g,r[e++]=268435455&d}return o},dbits=28),BigInteger.prototype.DB=dbits,BigInteger.prototype.DM=(1<<dbits)-1,BigInteger.prototype.DV=1<<dbits;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=52-dbits,BigInteger.prototype.F2=2*dbits-52;var rr,vv,BI_RM="0123456789abcdefghijklmnopqrstuvwxyz",BI_RC=new Array;for(rr="0".charCodeAt(0),vv=0;vv<=9;++vv)BI_RC[rr++]=vv;for(rr="a".charCodeAt(0),vv=10;vv<36;++vv)BI_RC[rr++]=vv;for(rr="A".charCodeAt(0),vv=10;vv<36;++vv)BI_RC[rr++]=vv;function int2char(a){return BI_RM.charAt(a)}function intAt(b,a){var d=BI_RC[b.charCodeAt(a)];return null==d?-1:d}function nbv(a){var b=nbi();return b.fromInt(a),b}function nbits(a){var b,c=1;return 0!=(b=a>>>16)&&(a=b,c+=16),0!=(b=a>>8)&&(a=b,c+=8),0!=(b=a>>4)&&(a=b,c+=4),0!=(b=a>>2)&&(a=b,c+=2),0!=(b=a>>1)&&(a=b,c+=1),c}function Classic(a){this.m=a}function Montgomery(a){this.m=a,this.mp=a.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<a.DB-15)-1,this.mt2=2*a.t}function op_and(a,b){return a&b}function op_or(a,b){return a|b}function op_xor(a,b){return a^b}function op_andnot(a,b){return a&~b}function lbit(a){if(0==a)return-1;var b=0;return 0==(65535&a)&&(a>>=16,b+=16),0==(255&a)&&(a>>=8,b+=8),0==(15&a)&&(a>>=4,b+=4),0==(3&a)&&(a>>=2,b+=2),0==(1&a)&&++b,b}function cbit(a){for(var b=0;0!=a;)a&=a-1,++b;return b}function NullExp(){}function nNop(a){return a}function Barrett(a){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*a.t,this.r2),this.mu=this.r2.divide(a),this.m=a}Classic.prototype.convert=function(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a},Classic.prototype.revert=function(a){return a},Classic.prototype.reduce=function(a){a.divRemTo(this.m,null,a)},Classic.prototype.mulTo=function(a,c,b){a.multiplyTo(c,b),this.reduce(b)},Classic.prototype.sqrTo=function(a,b){a.squareTo(b),this.reduce(b)},Montgomery.prototype.convert=function(a){var b=nbi();return a.abs().dlShiftTo(this.m.t,b),b.divRemTo(this.m,null,b),a.s<0&&b.compareTo(BigInteger.ZERO)>0&&this.m.subTo(b,b),b},Montgomery.prototype.revert=function(a){var b=nbi();return a.copyTo(b),this.reduce(b),b},Montgomery.prototype.reduce=function(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var c=0;c<this.m.t;++c){var b=32767&a[c],d=b*this.mpl+((b*this.mph+(a[c]>>15)*this.mpl&this.um)<<15)&a.DM;for(a[b=c+this.m.t]+=this.m.am(0,d,a,c,0,this.m.t);a[b]>=a.DV;)a[b]-=a.DV,a[++b]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)},Montgomery.prototype.mulTo=function(a,c,b){a.multiplyTo(c,b),this.reduce(b)},Montgomery.prototype.sqrTo=function(a,b){a.squareTo(b),this.reduce(b)},BigInteger.prototype.copyTo=function(b){for(var a=this.t-1;a>=0;--a)b[a]=this[a];b.t=this.t,b.s=this.s},BigInteger.prototype.fromInt=function(a){this.t=1,this.s=a<0?-1:0,a>0?this[0]=a:a<-1?this[0]=a+this.DV:this.t=0},BigInteger.prototype.fromString=function(h,c){var e;if(16==c)e=4;else if(8==c)e=3;else if(256==c)e=8;else if(2==c)e=1;else if(32==c)e=5;else{if(4!=c)return void this.fromRadix(h,c);e=2}this.t=0,this.s=0;for(var g=h.length,d=!1,f=0;--g>=0;){var a=8==e?255&h[g]:intAt(h,g);a<0?"-"==h.charAt(g)&&(d=!0):(d=!1,0==f?this[this.t++]=a:f+e>this.DB?(this[this.t-1]|=(a&(1<<this.DB-f)-1)<<f,this[this.t++]=a>>this.DB-f):this[this.t-1]|=a<<f,(f+=e)>=this.DB&&(f-=this.DB))}8==e&&0!=(128&h[0])&&(this.s=-1,f>0&&(this[this.t-1]|=(1<<this.DB-f)-1<<f)),this.clamp(),d&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.clamp=function(){for(var a=this.s&this.DM;this.t>0&&this[this.t-1]==a;)--this.t},BigInteger.prototype.dlShiftTo=function(c,b){var a;for(a=this.t-1;a>=0;--a)b[a+c]=this[a];for(a=c-1;a>=0;--a)b[a]=0;b.t=this.t+c,b.s=this.s},BigInteger.prototype.drShiftTo=function(c,b){for(var a=c;a<this.t;++a)b[a-c]=this[a];b.t=Math.max(this.t-c,0),b.s=this.s},BigInteger.prototype.lShiftTo=function(j,e){var d,b=j%this.DB,a=this.DB-b,g=(1<<a)-1,f=Math.floor(j/this.DB),h=this.s<<b&this.DM;for(d=this.t-1;d>=0;--d)e[d+f+1]=this[d]>>a|h,h=(this[d]&g)<<b;for(d=f-1;d>=0;--d)e[d]=0;e[f]=h,e.t=this.t+f+1,e.s=this.s,e.clamp()},BigInteger.prototype.rShiftTo=function(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t)d.t=0;else{var b=g%this.DB,a=this.DB-b,f=(1<<b)-1;d[0]=this[e]>>b;for(var c=e+1;c<this.t;++c)d[c-e-1]|=(this[c]&f)<<a,d[c-e]=this[c]>>b;b>0&&(d[this.t-e-1]|=(this.s&f)<<a),d.t=this.t-e,d.clamp()}},BigInteger.prototype.subTo=function(d,f){for(var e=0,g=0,b=Math.min(d.t,this.t);e<b;)g+=this[e]-d[e],f[e++]=g&this.DM,g>>=this.DB;if(d.t<this.t){for(g-=d.s;e<this.t;)g+=this[e],f[e++]=g&this.DM,g>>=this.DB;g+=this.s}else{for(g+=this.s;e<d.t;)g-=d[e],f[e++]=g&this.DM,g>>=this.DB;g-=d.s}f.s=g<0?-1:0,g<-1?f[e++]=this.DV+g:g>0&&(f[e++]=g),f.t=e,f.clamp()},BigInteger.prototype.multiplyTo=function(c,e){var b=this.abs(),f=c.abs(),d=b.t;for(e.t=d+f.t;--d>=0;)e[d]=0;for(d=0;d<f.t;++d)e[d+b.t]=b.am(0,f[d],e,d,0,b.t);e.s=0,e.clamp(),this.s!=c.s&&BigInteger.ZERO.subTo(e,e)},BigInteger.prototype.squareTo=function(d){for(var a=this.abs(),b=d.t=2*a.t;--b>=0;)d[b]=0;for(b=0;b<a.t-1;++b){var e=a.am(b,a[b],d,2*b,0,1);(d[b+a.t]+=a.am(b+1,2*a[b],d,2*b+1,e,a.t-b-1))>=a.DV&&(d[b+a.t]-=a.DV,d[b+a.t+1]=1)}d.t>0&&(d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)),d.s=0,d.clamp()},BigInteger.prototype.divRemTo=function(n,h,g){var w=n.abs();if(!(w.t<=0)){var k=this.abs();if(k.t<w.t)return null!=h&&h.fromInt(0),void(null!=g&&this.copyTo(g));null==g&&(g=nbi());var d=nbi(),a=this.s,l=n.s,v=this.DB-nbits(w[w.t-1]);v>0?(w.lShiftTo(v,d),k.lShiftTo(v,g)):(w.copyTo(d),k.copyTo(g));var p=d.t,b=d[p-1];if(0!=b){var o=b*(1<<this.F1)+(p>1?d[p-2]>>this.F2:0),A=this.FV/o,z=(1<<this.F1)/o,x=1<<this.F2,u=g.t,s=u-p,f=null==h?nbi():h;for(d.dlShiftTo(s,f),g.compareTo(f)>=0&&(g[g.t++]=1,g.subTo(f,g)),BigInteger.ONE.dlShiftTo(p,f),f.subTo(d,d);d.t<p;)d[d.t++]=0;for(;--s>=0;){var c=g[--u]==b?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))<c)for(d.dlShiftTo(s,f),g.subTo(f,g);g[u]<--c;)g.subTo(f,g)}null!=h&&(g.drShiftTo(p,h),a!=l&&BigInteger.ZERO.subTo(h,h)),g.t=p,g.clamp(),v>0&&g.rShiftTo(v,g),a<0&&BigInteger.ZERO.subTo(g,g)}}},BigInteger.prototype.invDigit=function(){if(this.t<1)return 0;var a=this[0];if(0==(1&a))return 0;var b=3&a;return(b=(b=(b=(b=b*(2-(15&a)*b)&15)*(2-(255&a)*b)&255)*(2-((65535&a)*b&65535))&65535)*(2-a*b%this.DV)%this.DV)>0?this.DV-b:-b},BigInteger.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},BigInteger.prototype.exp=function(h,j){if(h>4294967295||h<1)return BigInteger.ONE;var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;for(d.copyTo(f);--c>=0;)if(j.sqrTo(f,a),(h&1<<c)>0)j.mulTo(a,d,f);else{var b=f;f=a,a=b}return j.revert(f)},BigInteger.prototype.toString=function(c){if(this.s<0)return"-"+this.negate().toString(c);var e;if(16==c)e=4;else if(8==c)e=3;else if(2==c)e=1;else if(32==c)e=5;else{if(4!=c)return this.toRadix(c);e=2}var l,g=(1<<e)-1,a=!1,h="",f=this.t,j=this.DB-f*this.DB%e;if(f-- >0)for(j<this.DB&&(l=this[f]>>j)>0&&(a=!0,h=int2char(l));f>=0;)j<e?(l=(this[f]&(1<<j)-1)<<e-j,l|=this[--f]>>(j+=this.DB-e)):(l=this[f]>>(j-=e)&g,j<=0&&(j+=this.DB,--f)),l>0&&(a=!0),a&&(h+=int2char(l));return a?h:"0"},BigInteger.prototype.negate=function(){var a=nbi();return BigInteger.ZERO.subTo(this,a),a},BigInteger.prototype.abs=function(){return this.s<0?this.negate():this},BigInteger.prototype.compareTo=function(b){var d=this.s-b.s;if(0!=d)return d;var c=this.t;if(0!=(d=c-b.t))return this.s<0?-d:d;for(;--c>=0;)if(0!=(d=this[c]-b[c]))return d;return 0},BigInteger.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)},BigInteger.prototype.mod=function(b){var c=nbi();return this.abs().divRemTo(b,null,c),this.s<0&&c.compareTo(BigInteger.ZERO)>0&&b.subTo(c,c),c},BigInteger.prototype.modPowInt=function(b,a){var c;return c=b<256||a.isEven()?new Classic(a):new Montgomery(a),this.exp(b,c)},BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=function(a,c,b){a.multiplyTo(c,b)},NullExp.prototype.sqrTo=function(a,b){a.squareTo(b)},Barrett.prototype.convert=function(a){if(a.s<0||a.t>2*this.m.t)return a.mod(this.m);if(a.compareTo(this.m)<0)return a;var b=nbi();return a.copyTo(b),this.reduce(b),b},Barrett.prototype.revert=function(a){return a},Barrett.prototype.reduce=function(a){for(a.drShiftTo(this.m.t-1,this.r2),a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);a.compareTo(this.r2)<0;)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);a.compareTo(this.m)>=0;)a.subTo(this.m,a)},Barrett.prototype.mulTo=function(a,c,b){a.multiplyTo(c,b),this.reduce(b)},Barrett.prototype.sqrTo=function(a,b){a.squareTo(b),this.reduce(b)};var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],lplim=(1<<26)/lowprimes[lowprimes.length-1]; | ||
47 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ | ||
48 | */ | ||
49 | function Arcfour(){this.i=0,this.j=0,this.S=new Array}BigInteger.prototype.chunkSize=function(a){return Math.floor(Math.LN2*this.DB/Math.log(a))},BigInteger.prototype.toRadix=function(c){if(null==c&&(c=10),0==this.signum()||c<2||c>36)return"0";var f=this.chunkSize(c),e=Math.pow(c,f),i=nbv(e),j=nbi(),h=nbi(),g="";for(this.divRemTo(i,j,h);j.signum()>0;)g=(e+h.intValue()).toString(c).substr(1)+g,j.divRemTo(i,j,h);return h.intValue().toString(c)+g},BigInteger.prototype.fromRadix=function(m,h){this.fromInt(0),null==h&&(h=10);for(var f=this.chunkSize(h),g=Math.pow(h,f),e=!1,a=0,l=0,c=0;c<m.length;++c){var k=intAt(m,c);k<0?"-"==m.charAt(c)&&0==this.signum()&&(e=!0):(l=h*l+k,++a>=f&&(this.dMultiply(g),this.dAddOffset(l,0),a=0,l=0))}a>0&&(this.dMultiply(Math.pow(h,a)),this.dAddOffset(l,0)),e&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.fromNumber=function(f,e,h){if("number"==typeof e)if(f<2)this.fromInt(1);else for(this.fromNumber(f,h),this.testBit(f-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>f&&this.subTo(BigInteger.ONE.shiftLeft(f-1),this);else{var d=new Array,g=7&f;d.length=1+(f>>3),e.nextBytes(d),g>0?d[0]&=(1<<g)-1:d[0]=0,this.fromString(d,256)}},BigInteger.prototype.bitwiseTo=function(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d<b;++d)e[d]=h(this[d],c[d]);if(c.t<this.t){for(g=c.s&this.DM,d=b;d<this.t;++d)e[d]=h(this[d],g);e.t=this.t}else{for(g=this.s&this.DM,d=b;d<c.t;++d)e[d]=h(g,c[d]);e.t=c.t}e.s=h(this.s,c.s),e.clamp()},BigInteger.prototype.changeBit=function(c,b){var a=BigInteger.ONE.shiftLeft(c);return this.bitwiseTo(a,b,a),a},BigInteger.prototype.addTo=function(d,f){for(var e=0,g=0,b=Math.min(d.t,this.t);e<b;)g+=this[e]+d[e],f[e++]=g&this.DM,g>>=this.DB;if(d.t<this.t){for(g+=d.s;e<this.t;)g+=this[e],f[e++]=g&this.DM,g>>=this.DB;g+=this.s}else{for(g+=this.s;e<d.t;)g+=d[e],f[e++]=g&this.DM,g>>=this.DB;g+=d.s}f.s=g<0?-1:0,g>0?f[e++]=g:g<-1&&(f[e++]=this.DV+g),f.t=e,f.clamp()},BigInteger.prototype.dMultiply=function(a){this[this.t]=this.am(0,a-1,this,0,0,this.t),++this.t,this.clamp()},BigInteger.prototype.dAddOffset=function(b,a){if(0!=b){for(;this.t<=a;)this[this.t++]=0;for(this[a]+=b;this[a]>=this.DV;)this[a]-=this.DV,++a>=this.t&&(this[this.t++]=0),++this[a]}},BigInteger.prototype.multiplyLowerTo=function(b,f,e){var c,d=Math.min(this.t+b.t,f);for(e.s=0,e.t=d;d>0;)e[--d]=0;for(c=e.t-this.t;d<c;++d)e[d+this.t]=this.am(0,b[d],e,d,0,this.t);for(c=Math.min(b.t,f);d<c;++d)this.am(0,b[d],e,d,0,f-d);e.clamp()},BigInteger.prototype.multiplyUpperTo=function(b,e,d){--e;var c=d.t=this.t+b.t-e;for(d.s=0;--c>=0;)d[c]=0;for(c=Math.max(e-this.t,0);c<b.t;++c)d[this.t+c-e]=this.am(e-c,b[c],d,0,0,this.t+c-e);d.clamp(),d.drShiftTo(1,d)},BigInteger.prototype.modInt=function(e){if(e<=0)return 0;var c=this.DV%e,b=this.s<0?e-1:0;if(this.t>0)if(0==c)b=this[0]%e;else for(var a=this.t-1;a>=0;--a)b=(c*b+this[a])%e;return b},BigInteger.prototype.millerRabin=function(f){var g=this.subtract(BigInteger.ONE),c=g.getLowestSetBit();if(c<=0)return!1;var h=g.shiftRight(c);(f=f+1>>1)>lowprimes.length&&(f=lowprimes.length);for(var b=nbi(),e=0;e<f;++e){b.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);var l=b.modPow(h,this);if(0!=l.compareTo(BigInteger.ONE)&&0!=l.compareTo(g)){for(var d=1;d++<c&&0!=l.compareTo(g);)if(0==(l=l.modPowInt(2,this)).compareTo(BigInteger.ONE))return!1;if(0!=l.compareTo(g))return!1}}return!0},BigInteger.prototype.clone= | ||
50 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ | ||
51 | */ | ||
52 | function(){var a=nbi();return this.copyTo(a),a},BigInteger.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},BigInteger.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},BigInteger.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},BigInteger.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},BigInteger.prototype.toByteArray=function(){var b=this.t,c=new Array;c[0]=this.s;var f,e=this.DB-b*this.DB%8,a=0;if(b-- >0)for(e<this.DB&&(f=this[b]>>e)!=(this.s&this.DM)>>e&&(c[a++]=f|this.s<<this.DB-e);b>=0;)e<8?(f=(this[b]&(1<<e)-1)<<8-e,f|=this[--b]>>(e+=this.DB-8)):(f=this[b]>>(e-=8)&255,e<=0&&(e+=this.DB,--b)),0!=(128&f)&&(f|=-256),0==a&&(128&this.s)!=(128&f)&&++a,(a>0||f!=this.s)&&(c[a++]=f);return c},BigInteger.prototype.equals=function(b){return 0==this.compareTo(b)},BigInteger.prototype.min=function(b){return this.compareTo(b)<0?this:b},BigInteger.prototype.max=function(b){return this.compareTo(b)>0?this:b},BigInteger.prototype.and=function(b){var c=nbi();return this.bitwiseTo(b,op_and,c),c},BigInteger.prototype.or=function(b){var c=nbi();return this.bitwiseTo(b,op_or,c),c},BigInteger.prototype.xor=function(b){var c=nbi();return this.bitwiseTo(b,op_xor,c),c},BigInteger.prototype.andNot=function(b){var c=nbi();return this.bitwiseTo(b,op_andnot,c),c},BigInteger.prototype.not=function(){for(var b=nbi(),a=0;a<this.t;++a)b[a]=this.DM&~this[a];return b.t=this.t,b.s=~this.s,b},BigInteger.prototype.shiftLeft=function(b){var a=nbi();return b<0?this.rShiftTo(-b,a):this.lShiftTo(b,a),a},BigInteger.prototype.shiftRight=function(b){var a=nbi();return b<0?this.lShiftTo(-b,a):this.rShiftTo(b,a),a},BigInteger.prototype.getLowestSetBit=function(){for(var a=0;a<this.t;++a)if(0!=this[a])return a*this.DB+lbit(this[a]);return this.s<0?this.t*this.DB:-1},BigInteger.prototype.bitCount=function(){for(var c=0,a=this.s&this.DM,b=0;b<this.t;++b)c+=cbit(this[b]^a);return c},BigInteger.prototype.testBit=function(b){var a=Math.floor(b/this.DB);return a>=this.t?0!=this.s:0!=(this[a]&1<<b%this.DB)},BigInteger.prototype.setBit=function(a){return this.changeBit(a,op_or)},BigInteger.prototype.clearBit=function(a){return this.changeBit(a,op_andnot)},BigInteger.prototype.flipBit=function(a){return this.changeBit(a,op_xor)},BigInteger.prototype.add=function(b){var c=nbi();return this.addTo(b,c),c},BigInteger.prototype.subtract=function(b){var c=nbi();return this.subTo(b,c),c},BigInteger.prototype.multiply=function(b){var c=nbi();return this.multiplyTo(b,c),c},BigInteger.prototype.divide=function(b){var c=nbi();return this.divRemTo(b,c,null),c},BigInteger.prototype.remainder=function(b){var c=nbi();return this.divRemTo(b,null,c),c},BigInteger.prototype.divideAndRemainder=function(b){var d=nbi(),c=nbi();return this.divRemTo(b,d,c),new Array(d,c)},BigInteger.prototype.modPow=function(q,f){var h,v,o=q.bitLength(),b=nbv(1);if(o<=0)return b;h=o<18?1:o<48?3:o<144?4:o<768?5:6,v=o<8?new Classic(f):f.isEven()?new Barrett(f):new Montgomery(f);var p=new Array,d=3,s=h-1,a=(1<<h)-1;if(p[1]=v.convert(this),h>1){var A=nbi();for(v.sqrTo(p[1],A);d<=a;)p[d]=nbi(),v.mulTo(A,p[d-2],p[d]),d+=2}var x,y,l=q.t-1,u=!0,c=nbi();for(o=nbits(q[l])-1;l>=0;){for(o>=s?x=q[l]>>o-s&a:(x=(q[l]&(1<<o+1)-1)<<s-o,l>0&&(x|=q[l-1]>>this.DB+o-s)),d=h;0==(1&x);)x>>=1,--d;if((o-=d)<0&&(o+=this.DB,--l),u)p[x].copyTo(b),u=!1;else{for(;d>1;)v.sqrTo(b,c),v.sqrTo(c,b),d-=2;d>0?v.sqrTo(b,c):(y=b,b=c,c=y),v.mulTo(c,p[x],b)}for(;l>=0&&0==(q[l]&1<<o);)v.sqrTo(b,c),y=b,b=c,c=y,--o<0&&(o=this.DB-1,--l)}return v.revert(b)},BigInteger.prototype.modInverse=function(f){var j=f.isEven();if(this.isEven()&&j||0==f.signum())return BigInteger.ZERO;for(var i=f.clone(),h=this.clone(),g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),j?(g.isEven()&&e.isEven()||(g.addTo(this,g),e.subTo(f,e)),g.rShiftTo(1,g)):e.isEven()||e.subTo(f,e),e.rShiftTo(1,e);for(;h.isEven();)h.rShiftTo(1,h),j?(l.isEven()&&k.isEven()||(l.addTo(this,l),k.subTo(f,k)),l.rShiftTo(1,l)):k.isEven()||k.subTo(f,k),k.rShiftTo(1,k);i.compareTo(h)>=0?(i.subTo(h,i),j&&g.subTo(l,g),e.subTo(k,e)):(h.subTo(i,h),j&&l.subTo(g,l),k.subTo(e,k))}return 0!=h.compareTo(BigInteger.ONE)?BigInteger.ZERO:k.compareTo(f)>=0?k.subtract(f):k.signum()<0?(k.addTo(f,k),k.signum()<0?k.add(f):k):k},BigInteger.prototype.pow=function(a){return this.exp(a,new NullExp)},BigInteger.prototype.gcd=function(c){var b=this.s<0?this.negate():this.clone(),h=c.s<0?c.negate():c.clone();if(b.compareTo(h)<0){var e=b;b=h,h=e}var d=b.getLowestSetBit(),f=h.getLowestSetBit();if(f<0)return b;for(d<f&&(f=d),f>0&&(b.rShiftTo(f,b),h.rShiftTo(f,h));b.signum()>0;)(d=b.getLowestSetBit())>0&&b.rShiftTo(d,b),(d=h.getLowestSetBit())>0&&h.rShiftTo(d,h),b.compareTo(h)>=0?(b.subTo(h,b),b.rShiftTo(1,b)):(h.subTo(b,h),h.rShiftTo(1,h));return f>0&&h.lShiftTo(f,h),h},BigInteger.prototype.isProbablePrime=function(e){var d,b=this.abs();if(1==b.t&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d<lowprimes.length;++d)if(b[0]==lowprimes[d])return!0;return!1}if(b.isEven())return!1;for(d=1;d<lowprimes.length;){for(var a=lowprimes[d],c=d+1;c<lowprimes.length&&a<lplim;)a*=lowprimes[c++];for(a=b.modInt(a);d<c;)if(a%lowprimes[d++]==0)return!1}return b.millerRabin(e)},BigInteger.prototype.square=function(){var a=nbi();return this.squareTo(a),a},Arcfour.prototype.init=function(d){var c,a,b;for(c=0;c<256;++c)this.S[c]=c;for(a=0,c=0;c<256;++c)a=a+this.S[c]+d[c%d.length]&255,b=this.S[c],this.S[c]=this.S[a],this.S[a]=b;this.i=0,this.j=0},Arcfour.prototype.next=function(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]};var rng_state,rng_pool,rng_pptr,rng_psize=256; | ||
53 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ | ||
54 | */function rng_seed_time(){!function(a){rng_pool[rng_pptr++]^=255&a,rng_pool[rng_pptr++]^=a>>8&255,rng_pool[rng_pptr++]^=a>>16&255,rng_pool[rng_pptr++]^=a>>24&255,rng_pptr>=rng_psize&&(rng_pptr-=rng_psize)}((new Date).getTime())}if(null==rng_pool){var t;if(rng_pool=new Array,rng_pptr=0,void 0!==window&&(void 0!==window.crypto||void 0!==window.msCrypto)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);for(crypto.getRandomValues(ua),t=0;t<32;++t)rng_pool[rng_pptr++]=ua[t]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var z=window.crypto.random(32);for(t=0;t<z.length;++t)rng_pool[rng_pptr++]=255&z.charCodeAt(t)}}for(;rng_pptr<rng_psize;)t=Math.floor(65536*Math.random()),rng_pool[rng_pptr++]=t>>>8,rng_pool[rng_pptr++]=255&t;rng_pptr=0,rng_seed_time()}function rng_get_byte(){if(null==rng_state){for(rng_seed_time(),(rng_state=new Arcfour).init(rng_pool),rng_pptr=0;rng_pptr<rng_pool.length;++rng_pptr)rng_pool[rng_pptr]=0;rng_pptr=0}return rng_state.next()}function SecureRandom(){} | ||
55 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ | ||
56 | */ | ||
57 | function parseBigInt(b,a){return new BigInteger(b,a)}function oaep_mgf1_arr(c,a,e){for(var b="",d=0;b.length<a;)b+=e(String.fromCharCode.apply(String,c.concat([(4278190080&d)>>24,(16711680&d)>>16,(65280&d)>>8,255&d]))),d+=1;return b}function RSAKey(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function oaep_mgf1_str(c,a,e){for(var b="",d=0;b.length<a;)b+=e(c+String.fromCharCode.apply(String,[(4278190080&d)>>24,(16711680&d)>>16,(65280&d)>>8,255&d])),d+=1;return b} | ||
58 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ | ||
59 | */ | ||
60 | function ECFieldElementFp(b,a){this.x=a,this.q=b}function ECPointFp(c,a,d,b){this.curve=c,this.x=a,this.y=d,this.z=null==b?BigInteger.ONE:b,this.zinv=null}function ECCurveFp(e,d,c){this.q=e,this.a=this.fromBigInteger(d),this.b=this.fromBigInteger(c),this.infinity=new ECPointFp(this,null,null)}SecureRandom.prototype.nextBytes=function(b){var a;for(a=0;a<b.length;++a)b[a]=rng_get_byte()},RSAKey.prototype.doPublic=function(a){return a.modPowInt(this.e,this.n)},RSAKey.prototype.setPublic=function(b,a){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof b)this.n=b,this.e=a;else{if(!(null!=b&&null!=a&&b.length>0&&a.length>0))throw"Invalid RSA public key";this.n=parseBigInt(b,16),this.e=parseInt(a,16)}},RSAKey.prototype.encrypt=function(d){var a=function(e,h){if(h<e.length+11)throw"Message too long for RSA";for(var g=new Array,d=e.length-1;d>=0&&h>0;){var f=e.charCodeAt(d--);f<128?g[--h]=f:f>127&&f<2048?(g[--h]=63&f|128,g[--h]=f>>6|192):(g[--h]=63&f|128,g[--h]=f>>6&63|128,g[--h]=f>>12|224)}g[--h]=0;for(var b=new SecureRandom,a=new Array;h>2;){for(a[0]=0;0==a[0];)b.nextBytes(a);g[--h]=a[0]}return g[--h]=2,g[--h]=0,new BigInteger(g)}(d,this.n.bitLength()+7>>3);if(null==a)return null;var e=this.doPublic(a);if(null==e)return null;var b=e.toString(16);return 0==(1&b.length)?b:"0"+b},RSAKey.prototype.encryptOAEP=function(f,e,b){var a=function(q,a,f,l){var c=KJUR.crypto.MessageDigest,o=KJUR.crypto.Util,b=null;if(f||(f="sha1"),"string"==typeof f&&(b=c.getCanonicalAlgName(f),l=c.getHashLength(b),f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}),q.length+2*l+2>a)throw"Message too long for RSA";var e,k="";for(e=0;e<a-q.length-2*l-2;e+=1)k+="\0";var h=f("")+k+""+q,g=new Array(l);(new SecureRandom).nextBytes(g);var j=oaep_mgf1_arr(g,h.length,f),p=[];for(e=0;e<h.length;e+=1)p[e]=h.charCodeAt(e)^j.charCodeAt(e);var m=oaep_mgf1_arr(p,g.length,f),d=[0];for(e=0;e<g.length;e+=1)d[e+1]=g[e]^m.charCodeAt(e);return new BigInteger(d.concat(p))}(f,this.n.bitLength()+7>>3,e,b);if(null==a)return null;var g=this.doPublic(a);if(null==g)return null;var d=g.toString(16);return 0==(1&d.length)?d:"0"+d},RSAKey.prototype.type="RSA",RSAKey.prototype.doPrivate=function(a){if(null==this.p||null==this.q)return a.modPow(this.d,this.n);for(var c=a.mod(this.p).modPow(this.dmp1,this.p),b=a.mod(this.q).modPow(this.dmq1,this.q);c.compareTo(b)<0;)c=c.add(this.p);return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)},RSAKey.prototype.setPrivate=function(c,a,b){if(this.isPrivate=!0,"string"!=typeof c)this.n=c,this.e=a,this.d=b;else{if(!(null!=c&&null!=a&&c.length>0&&a.length>0))throw"Invalid RSA private key";this.n=parseBigInt(c,16),this.e=parseInt(a,16),this.d=parseBigInt(b,16)}},RSAKey.prototype.setPrivateEx=function(g,d,e,c,b,a,h,f){if(this.isPrivate=!0,this.isPublic=!1,null==g)throw"RSASetPrivateEx N == null";if(null==d)throw"RSASetPrivateEx E == null";if(0==g.length)throw"RSASetPrivateEx N.length == 0";if(0==d.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=g&&null!=d&&g.length>0&&d.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=parseBigInt(g,16),this.e=parseInt(d,16),this.d=parseBigInt(e,16),this.p=parseBigInt(c,16),this.q=parseBigInt(b,16),this.dmp1=parseBigInt(a,16),this.dmq1=parseBigInt(h,16),this.coeff=parseBigInt(f,16)},RSAKey.prototype.generate=function(b,i){var a=new SecureRandom,f=b>>1;this.e=parseInt(i,16);for(var c=new BigInteger(i,16);;){for(;this.p=new BigInteger(b-f,1,a),0!=this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)||!this.p.isProbablePrime(10););for(;this.q=new BigInteger(f,1,a),0!=this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q,this.q=h}var g=this.p.subtract(BigInteger.ONE),d=this.q.subtract(BigInteger.ONE),e=g.multiply(d);if(0==e.gcd(c).compareTo(BigInteger.ONE)){this.n=this.p.multiply(this.q),this.d=c.modInverse(e),this.dmp1=this.d.mod(g),this.dmq1=this.d.mod(d),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},RSAKey.prototype.decrypt=function(b){var d=parseBigInt(b,16),a=this.doPrivate(d);return null==a?null: | ||
61 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ | ||
62 | */ | ||
63 | function(g,j){for(var a=g.toByteArray(),f=0;f<a.length&&0==a[f];)++f;if(a.length-f!=j-1||2!=a[f])return null;for(++f;0!=a[f];)if(++f>=a.length)return null;for(var e="";++f<a.length;){var h=255&a[f];h<128?e+=String.fromCharCode(h):h>191&&h<224?(e+=String.fromCharCode((31&h)<<6|63&a[f+1]),++f):(e+=String.fromCharCode((15&h)<<12|(63&a[f+1])<<6|63&a[f+2]),f+=2)}return e}(a,this.n.bitLength()+7>>3)},RSAKey.prototype.decryptOAEP=function(e,d,b){var f=parseBigInt(e,16),a=this.doPrivate(f);return null==a?null:function(o,b,g,p){var e=KJUR.crypto.MessageDigest,r=KJUR.crypto.Util,c=null;for(g||(g="sha1"),"string"==typeof g&&(c=e.getCanonicalAlgName(g),p=e.getHashLength(c),g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}),o=o.toByteArray(),h=0;h<o.length;h+=1)o[h]&=255;for(;o.length<b;)o.unshift(0);if((o=String.fromCharCode.apply(String,o)).length<2*p+2)throw"Cipher too short";var h,f=o.substr(1,p),s=o.substr(p+1),q=oaep_mgf1_str(s,p,g),k=[];for(h=0;h<f.length;h+=1)k[h]=f.charCodeAt(h)^q.charCodeAt(h);var l=oaep_mgf1_str(String.fromCharCode.apply(String,k),o.length-p,g),j=[];for(h=0;h<s.length;h+=1)j[h]=s.charCodeAt(h)^l.charCodeAt(h);if((j=String.fromCharCode.apply(String,j)).substr(0,p)!==g(""))throw"Hash mismatch";var a=(j=j.substr(p)).indexOf("");if((-1!=a?j.substr(0,a).lastIndexOf("\0"):-1)+1!=a)throw"Malformed data";return j.substr(a+1)}(a,this.n.bitLength()+7>>3,d,b)},ECFieldElementFp.prototype.equals=function(a){return a==this||this.q.equals(a.q)&&this.x.equals(a.x)},ECFieldElementFp.prototype.toBigInteger=function(){return this.x},ECFieldElementFp.prototype.negate=function(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))},ECFieldElementFp.prototype.add=function(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.subtract=function(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.multiply=function(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.square=function(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))},ECFieldElementFp.prototype.divide=function(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))},ECPointFp.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ECPointFp.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ECPointFp.prototype.equals=function(a){return a==this||(this.isInfinity()?a.isInfinity():a.isInfinity()?this.isInfinity():!!a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q).equals(BigInteger.ZERO)&&a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q).equals(BigInteger.ZERO))},ECPointFp.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)},ECPointFp.prototype.negate=function(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)},ECPointFp.prototype.add=function(l){if(this.isInfinity())return l;if(l.isInfinity())return this;var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q),o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o))return BigInteger.ZERO.equals(p)?this.twice():this.curve.getInfinity();var j=new BigInteger("3"),e=this.x.toBigInteger(),n=this.y.toBigInteger(),m=(l.x.toBigInteger(),l.y.toBigInteger(),o.square()),i=m.multiply(o),d=e.multiply(m),g=p.square().multiply(this.z),a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q),h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q),f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)},ECPointFp.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var g=new BigInteger("3"),c=this.x.toBigInteger(),h=this.y.toBigInteger(),e=h.multiply(this.z),j=e.multiply(h).mod(this.curve.q),i=this.curve.a.toBigInteger(),k=c.square().multiply(g);BigInteger.ZERO.equals(i)||(k=k.add(this.z.square().multiply(i)));var b=(k=k.mod(this.curve.q)).square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q),f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q),d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)},ECPointFp.prototype.multiply=function(b){if(this.isInfinity())return this;if(0==b.signum())return this.curve.getInfinity();var c,g=b,f=g.multiply(new BigInteger("3")),l=this.negate(),d=this;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);a!=g.testBit(c)&&(d=d.add(a?this:l))}return d},ECPointFp.prototype.multiplyTwo=function(c,a,b){var d;d=c.bitLength()>b.bitLength()?c.bitLength()-1:b.bitLength()-1;for(var f=this.curve.getInfinity(),e=this.add(a);d>=0;)f=f.twice(),c.testBit(d)?f=b.testBit(d)?f.add(e):f.add(this):b.testBit(d)&&(f=f.add(a)),--d;return f},ECCurveFp.prototype.getQ=function(){return this.q},ECCurveFp.prototype.getA=function(){return this.a},ECCurveFp.prototype.getB=function(){return this.b},ECCurveFp.prototype.equals=function(a){return a==this||this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b)},ECCurveFp.prototype.getInfinity=function(){return this.infinity},ECCurveFp.prototype.fromBigInteger=function(a){return new ECFieldElementFp(this.q,a)},ECCurveFp.prototype.decodePointHex=function(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2,c=d.substr(2,a),b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}, | ||
64 | /*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib | ||
65 | */ | ||
66 | ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(f<g.length)g=g.slice(g.length-f);else for(;f>g.length;)g.unshift(0);return g},a=this.getX().toBigInteger(),e=this.getY().toBigInteger(),b=d(a,32);return c?e.isEven()?b.unshift(2):b.unshift(3):(b.unshift(4),b=b.concat(d(e,32))),b},ECPointFp.decodeFrom=function(g,c){c[0];var e=c.length-1,d=c.slice(1,1+e/2),b=c.slice(1+e/2,1+e);d.unshift(0),b.unshift(0);var a=new BigInteger(d),h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))},ECPointFp.decodeFromHex=function(g,c){c.substr(0,2);var e=c.length-2,d=c.substr(2,e/2),b=c.substr(2+e/2,e/2),a=new BigInteger(d,16),h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))},ECPointFp.prototype.add2D=function(c){if(this.isInfinity())return c;if(c.isInfinity())return this;if(this.x.equals(c.x))return this.y.equals(c.y)?this.twice():this.curve.getInfinity();var g=c.x.subtract(this.x),a=c.y.subtract(this.y).divide(g),d=a.square().subtract(this.x).subtract(c.x),f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)},ECPointFp.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var b=this.curve.fromBigInteger(BigInteger.valueOf(2)),e=this.curve.fromBigInteger(BigInteger.valueOf(3)),a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b)),c=a.square().subtract(this.x.multiply(b)),d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)},ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity())return this;if(0==b.signum())return this.curve.getInfinity();var c,g=b,f=g.multiply(new BigInteger("3")),l=this.negate(),d=this;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);a!=g.testBit(c)&&(d=d.add2D(a?this:l))}return d},ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger(),i=this.getY().toBigInteger(),f=this.curve.getA().toBigInteger(),c=this.curve.getB().toBigInteger(),h=this.curve.getQ(),e=i.multiply(i).mod(h),g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)},ECPointFp.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var a=this.getX().toBigInteger(),b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0)throw new Error("x coordinate out of bounds");if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(c).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; | ||
67 | /*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval | ||
68 | */ | ||
69 | var jsonParse=function(){var d=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),k=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),g={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(""),b=(Object,Array,Object.hasOwnProperty);return function(u,q){var x,t,p=u.match(d),v=p[0],l=!1;"{"===v?x={}:"["===v?x=[]:(x=[],l=!0);for(var r=[x],o=1-l,m=p.length;o<m;++o){var w;switch((v=p[o]).charCodeAt(0)){default:(w=r[0])[t||w.length]=+v,t=void 0;break;case 34:if(-1!==(v=v.substring(1,v.length-1)).indexOf("\\")&&(v=v.replace(k,h)),w=r[0],!t){if(!(w instanceof Array)){t=v||c;break}t=w.length}w[t]=v,t=void 0;break;case 91:w=r[0],r.unshift(w[t||w.length]=[]),t=void 0;break;case 93:r.shift();break;case 102:(w=r[0])[t||w.length]=!1,t=void 0;break;case 110:(w=r[0])[t||w.length]=null,t=void 0;break;case 116:(w=r[0])[t||w.length]=!0,t=void 0;break;case 123:w=r[0],r.unshift(w[t||w.length]={}),t=void 0;break;case 125:r.shift()}}if(l){if(1!==r.length)throw new Error;x=x[0]}else if(r.length)throw new Error;if(q){var s=function(C,B){var D=C[B];if(D&&"object"==typeof D){var n=null;for(var z in D)if(b.call(D,z)&&D!==C){var y=s(D,z);void 0!==y?D[z]=y:(n||(n=[]),n.push(z))}if(n)for(var A=n.length;--A>=0;)delete D[n[A]]}return q.call(C,B,D)};x=s({"":x},"")}return x}}();void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);return b.length%2==1&&(b="0"+b),b},this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if("-"!=f.substr(0,1))f.length%2==1?f="0"+f:f.match(/^[0-7]/)||(f="00"+f);else{var e=f.substr(1).length;e%2==1?e+=1:f.match(/^[0-7]/)||(e+=2);for(var g="",d=0;d<e;d++)g+="f";f=new BigInteger(g,16).xor(j).add(BigInteger.ONE).toString(16).replace(/^-/,"")}return f},this.getPEMStringFromHex=function(a,b){return hextopem(a,b)},this.newObject=function(k){var n=KJUR.asn1,z=n.DERBoolean,e=n.DERInteger,s=n.DERBitString,h=n.DEROctetString,v=n.DERNull,w=n.DERObjectIdentifier,l=n.DEREnumerated,g=n.DERUTF8String,f=n.DERNumericString,y=n.DERPrintableString,u=n.DERTeletexString,p=n.DERIA5String,C=n.DERUTCTime,j=n.DERGeneralizedTime,m=n.DERSequence,c=n.DERSet,r=n.DERTaggedObject,o=n.ASN1Util.newObject,t=Object.keys(k);if(1!=t.length)throw"key of param shall be only one.";var F=t[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+F+":"))throw"undefined key: "+F;if("bool"==F)return new z(k[F]);if("int"==F)return new e(k[F]);if("bitstr"==F)return new s(k[F]);if("octstr"==F)return new h(k[F]);if("null"==F)return new v(k[F]);if("oid"==F)return new w(k[F]);if("enum"==F)return new l(k[F]);if("utf8str"==F)return new g(k[F]);if("numstr"==F)return new f(k[F]);if("prnstr"==F)return new y(k[F]);if("telstr"==F)return new u(k[F]);if("ia5str"==F)return new p(k[F]);if("utctime"==F)return new C(k[F]);if("gentime"==F)return new j(k[F]);if("seq"==F){for(var d=k[F],E=[],x=0;x<d.length;x++){var B=o(d[x]);E.push(B)}return new m({array:E})}if("set"==F){for(d=k[F],E=[],x=0;x<d.length;x++){B=o(d[x]);E.push(B)}return new c({array:E})}if("tag"==F){var A=k[F];if("[object Array]"===Object.prototype.toString.call(A)&&3==A.length){var q=o(A[2]);return new r({tag:A[0],explicit:A[1],obj:q})}var b={};if(void 0!==A.explicit&&(b.explicit=A.explicit),void 0!==A.tag&&(b.tag=A.tag),void 0===A.obj)throw"obj shall be specified for 'tag'.";return b.obj=o(A.obj),new r(b)}},this.jsonToASN1HEX=function(b){return this.newObject(b).getEncodedHex()}},KJUR.asn1.ASN1Util.oidHexToInt=function(a){for(var j="",k=parseInt(a.substr(0,2),16),e=(j=Math.floor(k/40)+"."+k%40,""),f=2;f<a.length;f+=2){var h=("00000000"+parseInt(a.substr(f,2),16).toString(2)).slice(-8);if(e+=h.substr(1,7),"0"==h.substr(0,1))j=j+"."+new BigInteger(e,2).toString(10),e=""}return j},KJUR.asn1.ASN1Util.oidIntToHex=function(f){var e=function(a){var k=a.toString(16);return 1==k.length&&(k="0"+k),k},d=function(o){var n="",a=new BigInteger(o,10).toString(2),l=7-a.length%7;7==l&&(l=0);for(var q="",m=0;m<l;m++)q+="0";a=q+a;for(m=0;m<a.length-1;m+=7){var p=a.substr(m,7);m!=a.length-7&&(p="1"+p),n+=e(parseInt(p,2))}return n};if(!f.match(/^[0-9.]+$/))throw"malformed oid string: "+f;var g="",b=f.split("."),j=40*parseInt(b[0])+parseInt(b[1]);g+=e(j),b.splice(0,2);for(var c=0;c<b.length;c++)g+=d(b[c]);return g},KJUR.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+"".length+",v="+this.hV;var i=this.hV.length/2,h=i.toString(16);if(h.length%2==1&&(h="0"+h),i<128)return h;var g=h.length/2;if(g>15)throw"ASN.1 length too long to represent by 8x: n = "+i.toString(16);return(128+g).toString(16)+h},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(d){this.hTLV=null,this.isModified=!0,this.s=d,this.hV=utf8tohex(this.s).toLowerCase()},this.setStringHex=function(d){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=d},this.getFreshValueHex=function(){return this.hV},void 0!==c&&("string"==typeof c?this.setString(c):void 0!==c.str?this.setString(c.str):void 0!==c.hex&&this.setStringHex(c.hex))},YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(f){return utc=f.getTime()+6e4*f.getTimezoneOffset(),new Date(utc)},this.formatDate=function(m,o,e){var g=this.zeroPadding,n=this.localDateToUTC(m),p=String(n.getFullYear());"utc"==o&&(p=p.substr(2,2));var r=p+g(String(n.getMonth()+1),2)+g(String(n.getDate()),2)+g(String(n.getHours()),2)+g(String(n.getMinutes()),2)+g(String(n.getSeconds()),2);if(!0===e){var f=n.getMilliseconds();if(0!=f){var k=g(String(f),3);r=r+"."+(k=k.replace(/[0]+$/,""))}}return r+"Z"},this.zeroPadding=function(e,d){return e.length>=d?e:new Array(d-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(d){this.hTLV=null,this.isModified=!0,this.s=d,this.hV=stohex(d)},this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)},this.getFreshValueHex=function(){return this.hV}},YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(c){this.hTLV=null,this.isModified=!0,this.asn1Array=c},this.appendASN1Object=function(c){this.hTLV=null,this.isModified=!0,this.asn1Array.push(c)},this.asn1Array=new Array,void 0!==b&&void 0!==b.array&&(this.asn1Array=b.array)},YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object),KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object),KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(b){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)},this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)},this.setValueHex=function(b){this.hV=b},this.getFreshValueHex=function(){return this.hV},void 0!==a&&(void 0!==a.bigint?this.setByBigInteger(a.bigint):void 0!==a.int?this.setByInteger(a.int):"number"==typeof a?this.setByInteger(a):void 0!==a.hex&&this.setValueHex(a.hex))},YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object),KJUR.asn1.DERBitString=function(b){if(void 0!==b&&void 0!==b.obj){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null,this.isModified=!0,this.hV=c},this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7<c)throw"unused bits shall be from 0 to 7: u = "+c;var d="0"+c;this.hTLV=null,this.isModified=!0,this.hV=d+e},this.setByBinaryString=function(e){var f=8-(e=e.replace(/0+$/,"")).length%8;8==f&&(f=0);for(var g=0;g<=f;g++)e+="0";var j="";for(g=0;g<e.length-1;g+=8){var d=e.substr(g,8),c=parseInt(d,2).toString(16);1==c.length&&(c="0"+c),j+=c}this.hTLV=null,this.isModified=!0,this.hV="0"+f+j},this.setByBooleanArray=function(e){for(var d="",c=0;c<e.length;c++)1==e[c]?d+="1":d+="0";this.setByBinaryString(d)},this.newFalseArray=function(e){for(var c=new Array(e),d=0;d<e;d++)c[d]=!1;return c},this.getFreshValueHex=function(){return this.hV},void 0!==b&&("string"==typeof b&&b.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(b):void 0!==b.hex?this.setHexValueIncludingUnusedBits(b.hex):void 0!==b.bin?this.setByBinaryString(b.bin):void 0!==b.array&&this.setByBooleanArray(b.array))},YAHOO.lang.extend(KJUR.asn1.DERBitString,KJUR.asn1.ASN1Object),KJUR.asn1.DEROctetString=function(b){if(void 0!==b&&void 0!==b.obj){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=a.getEncodedHex()}KJUR.asn1.DEROctetString.superclass.constructor.call(this,b),this.hT="04"},YAHOO.lang.extend(KJUR.asn1.DEROctetString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNull=function(){KJUR.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},YAHOO.lang.extend(KJUR.asn1.DERNull,KJUR.asn1.ASN1Object),KJUR.asn1.DERObjectIdentifier=function(c){var b=function(d){var e=d.toString(16);return 1==e.length&&(e="0"+e),e},a=function(k){var j="",d=new BigInteger(k,10).toString(2),f=7-d.length%7;7==f&&(f=0);for(var m="",g=0;g<f;g++)m+="0";d=m+d;for(g=0;g<d.length-1;g+=7){var l=d.substr(g,7);g!=d.length-7&&(l="1"+l),j+=b(parseInt(l,2))}return j};KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(d){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=d},this.setValueOidString=function(f){if(!f.match(/^[0-9.]+$/))throw"malformed oid string: "+f;var g="",d=f.split("."),j=40*parseInt(d[0])+parseInt(d[1]);g+=b(j),d.splice(0,2);for(var e=0;e<d.length;e++)g+=a(d[e]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=g},this.setValueName=function(e){var d=KJUR.asn1.x509.OID.name2oid(e);if(""===d)throw"DERObjectIdentifier oidName undefined: "+e;this.setValueOidString(d)},this.getFreshValueHex=function(){return this.hV},void 0!==c&&("string"==typeof c?c.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(c):this.setValueName(c):void 0!==c.oid?this.setValueOidString(c.oid):void 0!==c.hex?this.setValueHex(c.hex):void 0!==c.name&&this.setValueName(c.name))},YAHOO.lang.extend(KJUR.asn1.DERObjectIdentifier,KJUR.asn1.ASN1Object),KJUR.asn1.DEREnumerated=function(a){KJUR.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(b){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)},this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)},this.setValueHex=function(b){this.hV=b},this.getFreshValueHex=function(){return this.hV},void 0!==a&&(void 0!==a.int?this.setByInteger(a.int):"number"==typeof a?this.setByInteger(a):void 0!==a.hex&&this.setValueHex(a.hex))},YAHOO.lang.extend(KJUR.asn1.DEREnumerated,KJUR.asn1.ASN1Object),KJUR.asn1.DERUTF8String=function(a){KJUR.asn1.DERUTF8String.superclass.constructor.call(this,a),this.hT="0c"},YAHOO.lang.extend(KJUR.asn1.DERUTF8String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNumericString=function(a){KJUR.asn1.DERNumericString.superclass.constructor.call(this,a),this.hT="12"},YAHOO.lang.extend(KJUR.asn1.DERNumericString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERPrintableString=function(a){KJUR.asn1.DERPrintableString.superclass.constructor.call(this,a),this.hT="13"},YAHOO.lang.extend(KJUR.asn1.DERPrintableString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERTeletexString=function(a){KJUR.asn1.DERTeletexString.superclass.constructor.call(this,a),this.hT="14"},YAHOO.lang.extend(KJUR.asn1.DERTeletexString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERIA5String=function(a){KJUR.asn1.DERIA5String.superclass.constructor.call(this,a),this.hT="16"},YAHOO.lang.extend(KJUR.asn1.DERIA5String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERUTCTime=function(a){KJUR.asn1.DERUTCTime.superclass.constructor.call(this,a),this.hT="17",this.setByDate=function(b){this.hTLV=null,this.isModified=!0,this.date=b,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==a&&(void 0!==a.str?this.setString(a.str):"string"==typeof a&&a.match(/^[0-9]{12}Z$/)?this.setString(a):void 0!==a.hex?this.setStringHex(a.hex):void 0!==a.date&&this.setByDate(a.date))},YAHOO.lang.extend(KJUR.asn1.DERUTCTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERGeneralizedTime=function(a){KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this,a),this.hT="18",this.withMillis=!1,this.setByDate=function(b){this.hTLV=null,this.isModified=!0,this.date=b,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==a&&(void 0!==a.str?this.setString(a.str):"string"==typeof a&&a.match(/^[0-9]{14}Z$/)?this.setString(a):void 0!==a.hex?this.setStringHex(a.hex):void 0!==a.date&&this.setByDate(a.date),!0===a.millis&&(this.withMillis=!0))},YAHOO.lang.extend(KJUR.asn1.DERGeneralizedTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERSequence=function(a){KJUR.asn1.DERSequence.superclass.constructor.call(this,a),this.hT="30",this.getFreshValueHex=function(){for(var c="",b=0;b<this.asn1Array.length;b++){c+=this.asn1Array[b].getEncodedHex()}return this.hV=c,this.hV}},YAHOO.lang.extend(KJUR.asn1.DERSequence,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERSet=function(a){KJUR.asn1.DERSet.superclass.constructor.call(this,a),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var b=new Array,c=0;c<this.asn1Array.length;c++){var d=this.asn1Array[c];b.push(d.getEncodedHex())}return 1==this.sortFlag&&b.sort(),this.hV=b.join(""),this.hV},void 0!==a&&void 0!==a.sortflag&&0==a.sortflag&&(this.sortFlag=!1)},YAHOO.lang.extend(KJUR.asn1.DERSet,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERTaggedObject=function(a){KJUR.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(b,c,d){this.hT=c,this.isExplicit=b,this.asn1Object=d,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=d.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,c),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==a&&(void 0!==a.tag&&(this.hT=a.tag),void 0!==a.explicit&&(this.isExplicit=a.explicit),void 0!==a.obj&&(this.asn1Object=a.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},YAHOO.lang.extend(KJUR.asn1.DERTaggedObject,KJUR.asn1.ASN1Object);var KJUR,utf8tob64u,b64utoutf8,ASN1HEX=new function(){};function stoBA(d){for(var b=new Array,c=0;c<d.length;c++)b[c]=d.charCodeAt(c);return b}function BAtos(b){for(var d="",c=0;c<b.length;c++)d+=String.fromCharCode(b[c]);return d}function BAtohex(b){for(var e="",d=0;d<b.length;d++){var c=b[d].toString(16);1==c.length&&(c="0"+c),e+=c}return e}function stohex(a){return BAtohex(stoBA(a))}function b64tob64u(a){return a=(a=(a=a.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function b64utob64(a){return a.length%4==2?a+="==":a.length%4==3&&(a+="="),a=(a=a.replace(/-/g,"+")).replace(/_/g,"/")}function hextob64u(a){return a.length%2==1&&(a="0"+a),b64tob64u(hex2b64(a))}function b64utohex(a){return b64tohex(b64utob64(a))}function utf8tohex(a){return uricmptohex(encodeURIComponentAll(a))}function hextoutf8(a){return decodeURIComponent(hextouricmp(a))}function hextorstr(c){for(var b="",a=0;a<c.length-1;a+=2)b+=String.fromCharCode(parseInt(c.substr(a,2),16));return b}function rstrtohex(c){for(var a="",b=0;b<c.length;b++)a+=("0"+c.charCodeAt(b).toString(16)).slice(-2);return a}function hextob64(a){return hex2b64(a)}function hextob64nl(b){var c=hextob64(b).replace(/(.{64})/g,"$1\r\n");return c=c.replace(/\r\n$/,"")}function b64nltohex(b){return b64tohex(b.replace(/[^0-9A-Za-z\/+=]*/g,""))}function hextopem(a,b){return"-----BEGIN "+b+"-----\r\n"+hextob64nl(a)+"\r\n-----END "+b+"-----\r\n"}function pemtohex(a,b){if(-1==a.indexOf("-----BEGIN "))throw"can't find PEM header: "+b;return b64nltohex(a=void 0!==b?(a=a.replace("-----BEGIN "+b+"-----","")).replace("-----END "+b+"-----",""):(a=a.replace(/-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----/,""))}function zulutomsec(n){var l,j,m,e,f,i,b,a,h,g,c;if(c=n.match(/^(\d{2}|\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return a=c[1],l=parseInt(a),2===a.length&&(50<=l&&l<100?l=1900+l:0<=l&&l<50&&(l=2e3+l)),j=parseInt(c[2])-1,m=parseInt(c[3]),e=parseInt(c[4]),f=parseInt(c[5]),i=parseInt(c[6]),b=0,""!==(h=c[7])&&(g=(h.substr(1)+"00").substr(0,3),b=parseInt(g)),Date.UTC(l,j,m,e,f,i,b);throw"unsupported zulu format: "+n}function zulutosec(a){return~~(zulutomsec(a)/1e3)}function uricmptohex(a){return a.replace(/%/g,"")}function hextouricmp(a){return a.replace(/(..)/g,"%$1")}function ipv6tohex(g){var b="malformed IPv6 address";if(!g.match(/^[0-9A-Fa-f:]+$/))throw b;var d=(g=g.toLowerCase()).split(":").length-1;if(d<2)throw b;var e=":".repeat(7-d+2),c=(g=g.replace("::",e)).split(":");if(8!=c.length)throw b;for(var f=0;f<8;f++)c[f]=("0000"+c[f]).slice(-4);return c.join("")}function hextoipv6(e){if(!e.match(/^[0-9A-Fa-f]{32}$/))throw"malformed IPv6 address octet";for(var b=(e=e.toLowerCase()).match(/.{1,4}/g),d=0;d<8;d++)b[d]=b[d].replace(/^0+/,""),""==b[d]&&(b[d]="0");var c=(e=":"+b.join(":")+":").match(/:(0:){2,}/g);if(null===c)return e.slice(1,-1);var f="";for(d=0;d<c.length;d++)c[d].length>f.length&&(f=c[d]);return(e=e.replace(f,"::")).slice(1,-1)}function hextoip(b){var d="malformed hex value";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw d;if(8!=b.length)return 32==b.length?hextoipv6(b):b;try{return parseInt(b.substr(0,2),16)+"."+parseInt(b.substr(2,2),16)+"."+parseInt(b.substr(4,2),16)+"."+parseInt(b.substr(6,2),16)}catch(a){throw d}}function encodeURIComponentAll(a){for(var d=encodeURIComponent(a),b="",c=0;c<d.length;c++)"%"==d[c]?(b+=d.substr(c,3),c+=2):b=b+"%"+stohex(d[c]);return b}function hextoposhex(a){return a.length%2==1?"0"+a:a.substr(0,1)>"7"?"00"+a:a}function intarystrtohex(b){b=(b=(b=b.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return b.split(/,/).map((function(g,e,h){var f=parseInt(g);if(f<0||255<f)throw"integer not in range 0-255";return("00"+f.toString(16)).slice(-2)})).join("")}catch(a){throw"malformed integer array string: "+a}}ASN1HEX.getLblen=function(c,a){if("8"!=c.substr(a+2,1))return 1;var b=parseInt(c.substr(a+3,1));return 0==b?-1:0<b&&b<10?b+1:-2},ASN1HEX.getL=function(c,b){var a=ASN1HEX.getLblen(c,b);return a<1?"":c.substr(b+2,2*a)},ASN1HEX.getVblen=function(d,a){var c;return""==(c=ASN1HEX.getL(d,a))?-1:("8"===c.substr(0,1)?new BigInteger(c.substr(2),16):new BigInteger(c,16)).intValue()},ASN1HEX.getVidx=function(c,b){var a=ASN1HEX.getLblen(c,b);return a<0?a:b+2*(a+1)},ASN1HEX.getV=function(d,a){var c=ASN1HEX.getVidx(d,a),b=ASN1HEX.getVblen(d,a);return d.substr(c,2*b)},ASN1HEX.getTLV=function(b,a){return b.substr(a,2)+ASN1HEX.getL(b,a)+ASN1HEX.getV(b,a)},ASN1HEX.getNextSiblingIdx=function(d,a){return ASN1HEX.getVidx(d,a)+2*ASN1HEX.getVblen(d,a)},ASN1HEX.getChildIdx=function(e,f){var j=ASN1HEX,g=new Array,i=j.getVidx(e,f);"03"==e.substr(f,2)?g.push(i+2):g.push(i);for(var l=j.getVblen(e,f),c=i,d=0;;){var b=j.getNextSiblingIdx(e,c);if(null==b||b-i>=2*l)break;if(d>=200)break;g.push(b),c=b,d++}return g},ASN1HEX.getNthChildIdx=function(d,b,e){return ASN1HEX.getChildIdx(d,b)[e]},ASN1HEX.getIdxbyList=function(e,d,c,i){var f,b,g=ASN1HEX;if(0==c.length){if(void 0!==i&&e.substr(d,2)!==i)throw"checking tag doesn't match: "+e.substr(d,2)+"!="+i;return d}return f=c.shift(),b=g.getChildIdx(e,d),g.getIdxbyList(e,b[f],c,i)},ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX,a=e.getIdxbyList(d,c,b);if(void 0===a)throw"can't find nthList object";if(void 0!==f&&d.substr(a,2)!=f)throw"checking tag doesn't match: "+d.substr(a,2)+"!="+f;return e.getTLV(d,a)},ASN1HEX.getVbyList=function(e,c,b,g,i){var a,d,f=ASN1HEX;if(void 0===(a=f.getIdxbyList(e,c,b,g)))throw"can't find nthList object";return d=f.getV(e,a),!0===i&&(d=d.substr(2)),d},ASN1HEX.hextooidstr=function(e){var h=function(b,a){return b.length>=a?b:new Array(a-b.length+1).join("0")+b},l=[],o=e.substr(0,2),f=parseInt(o,16);l[0]=new String(Math.floor(f/40)),l[1]=new String(f%40);for(var m=e.substr(2),k=[],g=0;g<m.length/2;g++)k.push(parseInt(m.substr(2*g,2),16));var j=[],d="";for(g=0;g<k.length;g++)128&k[g]?d+=h((127&k[g]).toString(2),7):(d+=h((127&k[g]).toString(2),7),j.push(new String(parseInt(d,2))),d="");var n=l.join(".");return j.length>0&&(n=n+"."+j.join(".")),n},ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX,j=p.getV,y=p.dump,w=p.getChildIdx,e=t;t instanceof KJUR.asn1.ASN1Object&&(e=t.getEncodedHex());var q=function(A,i){return A.length<=2*i?A:A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i)};void 0===c&&(c={ommit_long_octet:32}),void 0===l&&(l=0),void 0===g&&(g="");var x=c.ommit_long_octet;if("01"==e.substr(l,2))return"00"==(h=j(e,l))?g+"BOOLEAN FALSE\n":g+"BOOLEAN TRUE\n";if("02"==e.substr(l,2))return g+"INTEGER "+q(h=j(e,l),x)+"\n";if("03"==e.substr(l,2))return g+"BITSTRING "+q(h=j(e,l),x)+"\n";if("04"==e.substr(l,2)){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";return k+=y(h,c,0,g+" ")}return g+"OCTETSTRING "+q(h,x)+"\n"}if("05"==e.substr(l,2))return g+"NULL\n";if("06"==e.substr(l,2)){var m=j(e,l),a=KJUR.asn1.ASN1Util.oidHexToInt(m),o=KJUR.asn1.x509.OID.oid2name(a),b=a.replace(/\./g," ");return""!=o?g+"ObjectIdentifier "+o+" ("+b+")\n":g+"ObjectIdentifier ("+b+")\n"}if("0c"==e.substr(l,2))return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n";if("13"==e.substr(l,2))return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n";if("14"==e.substr(l,2))return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n";if("16"==e.substr(l,2))return g+"IA5String '"+hextoutf8(j(e,l))+"'\n";if("17"==e.substr(l,2))return g+"UTCTime "+hextoutf8(j(e,l))+"\n";if("18"==e.substr(l,2))return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n";if("30"==e.substr(l,2)){if("3000"==e.substr(l,4))return g+"SEQUENCE {}\n";k=g+"SEQUENCE\n";var f=c;if((2==(d=w(e,l)).length||3==d.length)&&"06"==e.substr(d[0],2)&&"04"==e.substr(d[d.length-1],2)){o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o,f=r}for(var u=0;u<d.length;u++)k+=y(e,f,d[u],g+" ");return k}if("31"==e.substr(l,2)){k=g+"SET\n";var d=w(e,l);for(u=0;u<d.length;u++)k+=y(e,c,d[u],g+" ");return k}var z=parseInt(e.substr(l,2),16);if(0!=(128&z)){var n=31&z;if(0!=(32&z)){var k=g+"["+n+"]\n";for(d=w(e,l),u=0;u<d.length;u++)k+=y(e,c,d[u],g+" ");return k}return"68747470"==(h=j(e,l)).substr(0,8)&&(h=hextoutf8(h)),"subjectAltName"===c.x509ExtName&&2==n&&(h=hextoutf8(h)),k=g+"["+n+"] "+h+"\n"}return g+"UNKNOWN("+e.substr(l,2)+") "+j(e,l)+"\n"},ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1)return!1;var c=d.getVblen(e,0),b=e.substr(0,2),f=d.getL(e,0);return e.length-b.length-f.length==2*c},ASN1HEX.oidname=function(a){var c=KJUR.asn1;KJUR.lang.String.isHex(a)&&(a=c.ASN1Util.oidHexToInt(a));var b=c.x509.OID.oid2name(a);return""===b&&(b=a),b},void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),void 0!==KJUR.asn1.x509&&KJUR.asn1.x509||(KJUR.asn1.x509={}),KJUR.asn1.x509.Certificate=function(e){KJUR.asn1.x509.Certificate.superclass.constructor.call(this);var b=KJUR,g=(b.crypto,b.asn1),d=g.DERSequence,c=g.DERBitString;this.sign=function(){this.asn1SignatureAlg=this.asn1TBSCert.asn1SignatureAlg;var m=new KJUR.crypto.Signature({alg:this.asn1SignatureAlg.nameAlg});m.init(this.prvKey),m.updateHex(this.asn1TBSCert.getEncodedHex()),this.hexSig=m.sign(),this.asn1Sig=new c({hex:"00"+this.hexSig});var l=new d({array:[this.asn1TBSCert,this.asn1SignatureAlg,this.asn1Sig]});this.hTLV=l.getEncodedHex(),this.isModified=!1},this.setSignatureHex=function(l){this.asn1SignatureAlg=this.asn1TBSCert.asn1SignatureAlg,this.hexSig=l,this.asn1Sig=new c({hex:"00"+this.hexSig});var m=new d({array:[this.asn1TBSCert,this.asn1SignatureAlg,this.asn1Sig]});this.hTLV=m.getEncodedHex(),this.isModified=!1},this.getEncodedHex=function(){if(0==this.isModified&&null!=this.hTLV)return this.hTLV;throw"not signed yet"},this.getPEMString=function(){return"-----BEGIN CERTIFICATE-----\r\n"+hextob64nl(this.getEncodedHex())+"\r\n-----END CERTIFICATE-----\r\n"},void 0!==e&&(void 0!==e.tbscertobj&&(this.asn1TBSCert=e.tbscertobj),void 0!==e.prvkeyobj&&(this.prvKey=e.prvkeyobj))},YAHOO.lang.extend(KJUR.asn1.x509.Certificate,KJUR.asn1.ASN1Object),KJUR.asn1.x509.TBSCertificate=function(e){KJUR.asn1.x509.TBSCertificate.superclass.constructor.call(this);var i=KJUR.asn1,f=i.DERSequence,h=i.DERInteger,c=i.DERTaggedObject,d=i.x509,g=d.Time,a=d.X500Name,j=d.SubjectPublicKeyInfo;this._initialize=function(){this.asn1Array=new Array,this.asn1Version=new c({obj:new h({int:2})}),this.asn1SerialNumber=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1NotBefore=null,this.asn1NotAfter=null,this.asn1Subject=null,this.asn1SubjPKey=null,this.extensionsArray=new Array},this.setSerialNumberByParam=function(k){this.asn1SerialNumber=new h(k)},this.setSignatureAlgByParam=function(k){this.asn1SignatureAlg=new d.AlgorithmIdentifier(k)},this.setIssuerByParam=function(k){this.asn1Issuer=new a(k)},this.setNotBeforeByParam=function(k){this.asn1NotBefore=new g(k)},this.setNotAfterByParam=function(k){this.asn1NotAfter=new g(k)},this.setSubjectByParam=function(k){this.asn1Subject=new a(k)},this.setSubjectPublicKey=function(k){this.asn1SubjPKey=new j(k)},this.setSubjectPublicKeyByGetKey=function(l){var k=KEYUTIL.getKey(l);this.asn1SubjPKey=new j(k)},this.appendExtension=function(k){this.extensionsArray.push(k)},this.appendExtensionByName=function(l,k){KJUR.asn1.x509.Extension.appendByNameToArray(l,k,this.extensionsArray)},this.getEncodedHex=function(){if(null==this.asn1NotBefore||null==this.asn1NotAfter)throw"notBefore and/or notAfter not set";var l=new f({array:[this.asn1NotBefore,this.asn1NotAfter]});if(this.asn1Array=new Array,this.asn1Array.push(this.asn1Version),this.asn1Array.push(this.asn1SerialNumber),this.asn1Array.push(this.asn1SignatureAlg),this.asn1Array.push(this.asn1Issuer),this.asn1Array.push(l),this.asn1Array.push(this.asn1Subject),this.asn1Array.push(this.asn1SubjPKey),this.extensionsArray.length>0){var m=new f({array:this.extensionsArray}),k=new c({explicit:!0,tag:"a3",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});return this.hTLV=n.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object),KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var e=KJUR.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,g=(e.DERBitString,e.DERBoolean),c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid}),l=new i({hex:this.getExtnValueHex()}),k=new Array;return k.push(m),this.critical&&k.push(new g),k.push(l),new c({array:k}).getEncodedHex()},this.critical=!1,void 0!==d&&void 0!==d.critical&&(this.critical=d.critical)},YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object),KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if("basicconstraints"==g){var d=new f.BasicConstraints(c);b.push(d)}else if("keyusage"==g){d=new f.KeyUsage(c);b.push(d)}else if("crldistributionpoints"==g){d=new f.CRLDistributionPoints(c);b.push(d)}else if("extkeyusage"==g){d=new f.ExtKeyUsage(c);b.push(d)}else if("authoritykeyidentifier"==g){d=new f.AuthorityKeyIdentifier(c);b.push(d)}else if("authorityinfoaccess"==g){d=new f.AuthorityInfoAccess(c);b.push(d)}else if("subjectaltname"==g){d=new f.SubjectAltName(c);b.push(d)}else{if("issueraltname"!=g)throw"unsupported extension name: "+e;d=new f.IssuerAltName(c);b.push(d)}},KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==f&&(void 0!==f.bin&&(this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)),void 0!==f.names&&void 0!==f.names.length)){for(var e=f.names,d="000000000",c=0;c<e.length;c++)for(var b=0;b<a.length;b++)e[c]===a[b]&&(d=d.substring(0,b)+"1"+d.substring(b+1,d.length));this.asn1ExtnValue=new KJUR.asn1.DERBitString({bin:d})}},YAHOO.lang.extend(KJUR.asn1.x509.KeyUsage,KJUR.asn1.x509.Extension),KJUR.asn1.x509.BasicConstraints=function(c){KJUR.asn1.x509.BasicConstraints.superclass.constructor.call(this,c);this.getExtnValueHex=function(){var e=new Array;this.cA&&e.push(new KJUR.asn1.DERBoolean),this.pathLen>-1&&e.push(new KJUR.asn1.DERInteger({int:this.pathLen}));var d=new KJUR.asn1.DERSequence({array:e});return this.asn1ExtnValue=d,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==c&&(void 0!==c.cA&&(this.cA=c.cA),void 0!==c.pathLen&&(this.pathLen=c.pathLen))},YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension),KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var a=KJUR.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})},this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]),g=new c.DistributionPointName(e),f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])},this.oid="2.5.29.31",void 0!==d&&(void 0!==d.array?this.setByDPArray(d.array):void 0!==d.uri&&this.setByOneURI(d.uri))},YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension),KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var a=KJUR.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence;for(var e=0;e<d.length;e++){var f=new a.DERObjectIdentifier(d[e]);this.asn1ExtnValue.appendASN1Object(f)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.37",void 0!==c&&void 0!==c.array&&this.setPurposeArray(c.array)},YAHOO.lang.extend(KJUR.asn1.x509.ExtKeyUsage,KJUR.asn1.x509.Extension),KJUR.asn1.x509.AuthorityKeyIdentifier=function(d){KJUR.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,d);var a=KJUR.asn1,c=a.DERTaggedObject;this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var f=new Array;this.asn1KID&&f.push(new c({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&f.push(new c({explicit:!1,tag:"a1",obj:this.asn1CertIssuer})),this.asn1CertSN&&f.push(new c({explicit:!1,tag:"82",obj:this.asn1CertSN}));var e=new a.DERSequence({array:f});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(e){this.asn1KID=new KJUR.asn1.DEROctetString(e)},this.setCertIssuerByParam=function(e){this.asn1CertIssuer=new KJUR.asn1.x509.X500Name(e)},this.setCertSNByParam=function(e){this.asn1CertSN=new KJUR.asn1.DERInteger(e)},this.oid="2.5.29.35",void 0!==d&&(void 0!==d.kid&&this.setKIDByParam(d.kid),void 0!==d.issuer&&this.setCertIssuerByParam(d.issuer),void 0!==d.sn&&this.setCertSNByParam(d.sn))},YAHOO.lang.extend(KJUR.asn1.x509.AuthorityKeyIdentifier,KJUR.asn1.x509.Extension),KJUR.asn1.x509.AuthorityInfoAccess=function(a){KJUR.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,a),this.setAccessDescriptionArray=function(k){for(var j=new Array,g=KJUR.asn1,d=g.DERSequence,f=0;f<k.length;f++){var h=new d({array:[new g.DERObjectIdentifier(k[f].accessMethod),new g.x509.GeneralName(k[f].accessLocation)]});j.push(h)}this.asn1ExtnValue=new d({array:j})},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==a&&void 0!==a.array&&this.setAccessDescriptionArray(a.array)},YAHOO.lang.extend(KJUR.asn1.x509.AuthorityInfoAccess,KJUR.asn1.x509.Extension),KJUR.asn1.x509.SubjectAltName=function(a){KJUR.asn1.x509.SubjectAltName.superclass.constructor.call(this,a),this.setNameArray=function(b){this.asn1ExtnValue=new KJUR.asn1.x509.GeneralNames(b)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.17",void 0!==a&&void 0!==a.array&&this.setNameArray(a.array)},YAHOO.lang.extend(KJUR.asn1.x509.SubjectAltName,KJUR.asn1.x509.Extension),KJUR.asn1.x509.IssuerAltName=function(a){KJUR.asn1.x509.IssuerAltName.superclass.constructor.call(this,a),this.setNameArray=function(b){this.asn1ExtnValue=new KJUR.asn1.x509.GeneralNames(b)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.18",void 0!==a&&void 0!==a.array&&this.setNameArray(a.array)},YAHOO.lang.extend(KJUR.asn1.x509.IssuerAltName,KJUR.asn1.x509.Extension),KJUR.asn1.x509.CRL=function(f){KJUR.asn1.x509.CRL.superclass.constructor.call(this);this.sign=function(){this.asn1SignatureAlg=this.asn1TBSCertList.asn1SignatureAlg,sig=new KJUR.crypto.Signature({alg:"SHA1withRSA",prov:"cryptojs/jsrsa"}),sig.init(this.prvKey),sig.updateHex(this.asn1TBSCertList.getEncodedHex()),this.hexSig=sig.sign(),this.asn1Sig=new KJUR.asn1.DERBitString({hex:"00"+this.hexSig});var g=new KJUR.asn1.DERSequence({array:[this.asn1TBSCertList,this.asn1SignatureAlg,this.asn1Sig]});this.hTLV=g.getEncodedHex(),this.isModified=!1},this.getEncodedHex=function(){if(0==this.isModified&&null!=this.hTLV)return this.hTLV;throw"not signed yet"},this.getPEMString=function(){return"-----BEGIN X509 CRL-----\r\n"+hextob64nl(this.getEncodedHex())+"\r\n-----END X509 CRL-----\r\n"},void 0!==f&&(void 0!==f.tbsobj&&(this.asn1TBSCertList=f.tbsobj),void 0!==f.prvkeyobj&&(this.prvKey=f.prvkeyobj))},YAHOO.lang.extend(KJUR.asn1.x509.CRL,KJUR.asn1.ASN1Object),KJUR.asn1.x509.TBSCertList=function(g){KJUR.asn1.x509.TBSCertList.superclass.constructor.call(this);var c=KJUR.asn1,b=c.DERSequence,f=c.x509,a=f.Time;this.setSignatureAlgByParam=function(h){this.asn1SignatureAlg=new f.AlgorithmIdentifier(h)},this.setIssuerByParam=function(h){this.asn1Issuer=new f.X500Name(h)},this.setThisUpdateByParam=function(h){this.asn1ThisUpdate=new a(h)},this.setNextUpdateByParam=function(h){this.asn1NextUpdate=new a(h)},this.addRevokedCert=function(h,i){var k={};null!=h&&null!=h&&(k.sn=h),null!=i&&null!=i&&(k.time=i);var j=new f.CRLEntry(k);this.aRevokedCert.push(j)},this.getEncodedHex=function(){if(this.asn1Array=new Array,null!=this.asn1Version&&this.asn1Array.push(this.asn1Version),this.asn1Array.push(this.asn1SignatureAlg),this.asn1Array.push(this.asn1Issuer),this.asn1Array.push(this.asn1ThisUpdate),null!=this.asn1NextUpdate&&this.asn1Array.push(this.asn1NextUpdate),this.aRevokedCert.length>0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});return this.hTLV=i.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object),KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var a=KJUR.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)},this.setRevocationDate=function(f){this.time=new a.x509.Time(f)},this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});return this.TLV=f.getEncodedHex(),this.TLV},void 0!==e&&(void 0!==e.time&&this.setRevocationDate(e.time),void 0!==e.sn&&this.setCertSerial(e.sn))},YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object),KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var c=KJUR.asn1,e=c.x509,b=pemtohex;if(this.setByString=function(g){var k=g.split("/");k.shift();for(var j=[],l=0;l<k.length;l++)if(k[l].match(/^[^=]+=.+$/))j.push(k[l]);else{var h=j.length-1;j[h]=j[h]+"/"+k[l]}for(l=0;l<j.length;l++)this.asn1Array.push(new e.RDN({str:j[l]}))},this.setByLdapString=function(g){var h=e.X500Name.ldapToOneline(g);this.setByString(h)},this.setByObject=function(i){for(var g in i)if(i.hasOwnProperty(g)){var h=new KJUR.asn1.x509.RDN({str:g+"="+i[g]});this.asn1Array?this.asn1Array.push(h):this.asn1Array=[h]}},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;var g=new c.DERSequence({array:this.asn1Array});return this.hTLV=g.getEncodedHex(),this.hTLV},void 0!==f){var a;if(void 0!==f.str?this.setByString(f.str):void 0!==f.ldapstr?this.setByLdapString(f.ldapstr):"object"==typeof f&&this.setByObject(f),void 0!==f.certissuer)(a=new X509).hex=b(f.certissuer),this.hTLV=a.getIssuerHex();if(void 0!==f.certsubject)(a=new X509).hex=b(f.certsubject),this.hTLV=a.getSubjectHex()}},YAHOO.lang.extend(KJUR.asn1.x509.X500Name,KJUR.asn1.ASN1Object),KJUR.asn1.x509.X500Name.onelineToLDAP=function(d){if("/"!==d.substr(0,1))throw"malformed input";var c=(d=d.substr(1)).split("/");return c.reverse(),(c=c.map((function(a){return a.replace(/,/,"\\,")}))).join(",")},KJUR.asn1.x509.X500Name.ldapToOneline=function(g){for(var c=g.split(","),e=!1,b=[],f=0;c.length>0;f++){var h=c.shift();if(!0===e){var j=(b.pop()+","+h).replace(/\\,/g,",");b.push(j),e=!1}else b.push(h);"\\"===h.substr(-1,1)&&(e=!0)}return(b=b.map((function(a){return a.replace("/","\\/")}))).reverse(),"/"+b.join("/")},KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))},this.addByMultiValuedString=function(d){for(var b=KJUR.asn1.x509.RDN.parseString(d),c=0;c<b.length;c++)this.addByString(b[c])},this.getEncodedHex=function(){var b=new KJUR.asn1.DERSet({array:this.asn1Array});return this.TLV=b.getEncodedHex(),this.TLV},void 0!==a&&void 0!==a.str&&this.addByMultiValuedString(a.str)},YAHOO.lang.extend(KJUR.asn1.x509.RDN,KJUR.asn1.ASN1Object),KJUR.asn1.x509.RDN.parseString=function(m){for(var j=m.split(/\+/),h=!1,c=[],g=0;j.length>0;g++){var k=j.shift();if(!0===h){var d=(c.pop()+"+"+k).replace(/\\\+/g,"+");c.push(d),h=!1}else c.push(k);"\\"===k.substr(-1,1)&&(h=!0)}var l=!1,b=[];for(g=0;c.length>0;g++){k=c.shift();if(!0===l){var e=b.pop();if(k.match(/"$/)){d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d),l=!1}else b.push(e+"+"+k)}else b.push(k);k.match(/^[^=]+="/)&&(l=!0)}return b},KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var b=KJUR.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(!g)throw"malformed attrTypeAndValueStr: "+h;this.setByAttrTypeAndValueStr(g[1],g[2])},this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g="utf8";"C"==i&&(g="prn"),this.valueObj=this.getValueObj(g,h)},this.getValueObj=function(h,g){if("utf8"==h)return new b.DERUTF8String({str:g});if("prn"==h)return new b.DERPrintableString({str:g});if("tel"==h)return new b.DERTeletexString({str:g});if("ia5"==h)return new b.DERIA5String({str:g});throw"unsupported directory string type: type="+h+" value="+g},this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=g.getEncodedHex(),this.TLV},void 0!==d&&void 0!==d.str&&this.setByString(d.str)},YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object),KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,o=j.x509.AlgorithmIdentifier,g=a.crypto;g.ECDSA,g.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new e({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var p=this.getASN1Object();return this.hTLV=p.getEncodedHex(),this.hTLV},this.setPubKey=function(q){try{if(q instanceof RSAKey){var s=h({seq:[{int:{bigint:q.n}},{int:{int:q.e}}]}).getEncodedHex();this.asn1AlgId=new o({name:"rsaEncryption"}),this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){r=new h({seq:[{int:{bigint:q.p}},{int:{bigint:q.q}},{int:{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.getEncodedHex()})}}catch(p){}},void 0!==f&&this.setPubKey(f)},YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object),KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var c=KJUR.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h},this.getEncodedHex=function(){var h=null;return h=null!=this.timeParams?"utc"==this.type?new b(this.timeParams):new g(this.timeParams):"utc"==this.type?new b:new g,this.TLV=h.getEncodedHex(),this.TLV},this.type="utc",void 0!==f&&(void 0!==f.type?this.type=f.type:void 0!==f.str&&(f.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),f.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=f)},YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object),KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var a=KJUR.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=a.x509.OID.name2obj(this.nameAlg));var e=[this.asn1Alg];null!==this.asn1Params&&e.push(this.asn1Params);var f=new a.DERSequence({array:e});return this.hTLV=f.getEncodedHex(),this.hTLV},void 0!==d&&(void 0!==d.name&&(this.nameAlg=d.name),void 0!==d.asn1params&&(this.asn1Params=d.asn1params),void 0!==d.paramempty&&(this.paramEmpty=d.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var c=this.nameAlg.toLowerCase();"withdsa"!==c.substr(-7,7)&&"withecdsa"!==c.substr(-9,9)&&(this.asn1Params=new a.DERNull)}},YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object),KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var k={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},g=KJUR.asn1,j=(g.DERSequence,g.DEROctetString),d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=!1,this.setByParam=function(p){var u=null;if(void 0!==p){if(void 0!==p.rfc822&&(this.type="rfc822",u=new d({str:p[this.type]})),void 0!==p.dns&&(this.type="dns",u=new d({str:p[this.type]})),void 0!==p.uri&&(this.type="uri",u=new d({str:p[this.type]})),void 0!==p.dn&&(this.type="dn",this.explicit=!0,u=new a({str:p.dn})),void 0!==p.ldapdn&&(this.type="dn",this.explicit=!0,u=new a({ldapstr:p.ldapdn})),void 0!==p.certissuer){this.type="dn",this.explicit=!0;var w=null;if((o=p.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=o.indexOf("-----BEGIN ")&&(w=h(o)),null==w)throw"certissuer param not cert";(t=new X509).hex=w;var y=t.getIssuerHex();(u=new l).hTLV=y}if(void 0!==p.certsubj){this.type="dn",this.explicit=!0;var o,t;w=null;if((o=p.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=o.indexOf("-----BEGIN ")&&(w=h(o)),null==w)throw"certsubj param not cert";(t=new X509).hex=w;y=t.getSubjectHex();(u=new l).hTLV=y}if(void 0!==p.ip){this.type="ip",this.explicit=!1;var s,q=p.ip,n="malformed IP address";if(q.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(s=intarystrtohex("["+q.split(".").join(",")+"]")).length)throw n}else if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))s=ipv6tohex(q);else{if(!q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw n;s=q}u=new j({hex:s})}if(null==this.type)throw"unsupported type in params="+p;this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==e&&this.setByParam(e)},YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object),KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var b=KJUR.asn1;this.setByParamArray=function(g){for(var e=0;e<g.length;e++){var f=new b.x509.GeneralName(g[e]);this.asn1Array.push(f)}},this.getEncodedHex=function(){return new b.DERSequence({array:this.asn1Array}).getEncodedHex()},this.asn1Array=new Array,void 0!==d&&this.setByParamArray(d)},YAHOO.lang.extend(KJUR.asn1.x509.GeneralNames,KJUR.asn1.ASN1Object),KJUR.asn1.x509.DistributionPointName=function(b){KJUR.asn1.x509.DistributionPointName.superclass.constructor.call(this);var c=KJUR.asn1,f=c.DERTaggedObject;if(this.getEncodedHex=function(){if("full"!=this.type)throw"currently type shall be 'full': "+this.type;return this.asn1Obj=new f({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.getEncodedHex(),this.hTLV},void 0!==b){if(!c.x509.GeneralNames.prototype.isPrototypeOf(b))throw"This class supports GeneralNames only as argument";this.type="full",this.tag="a0",this.asn1V=b}},YAHOO.lang.extend(KJUR.asn1.x509.DistributionPointName,KJUR.asn1.ASN1Object),KJUR.asn1.x509.DistributionPoint=function(d){KJUR.asn1.x509.DistributionPoint.superclass.constructor.call(this);var b=KJUR.asn1;this.getEncodedHex=function(){var e=new b.DERSequence;if(null!=this.asn1DP){var f=new b.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});e.appendASN1Object(f)}return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==d&&void 0!==d.dpobj&&(this.asn1DP=d.dpobj)},YAHOO.lang.extend(KJUR.asn1.x509.DistributionPoint,KJUR.asn1.ASN1Object),KJUR.asn1.x509.OID=new function(a){this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.name2oidList={sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",title:"2.5.4.12",distinguishedName:"2.5.4.49",emailAddress:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3",subjectKeyIdentifier:"2.5.29.14",keyUsage:"2.5.29.15",subjectAltName:"2.5.29.17",issuerAltName:"2.5.29.18",basicConstraints:"2.5.29.19",nameConstraints:"2.5.29.30",cRLDistributionPoints:"2.5.29.31",certificatePolicies:"2.5.29.32",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",authorityInfoAccess:"1.3.6.1.5.5.7.1.1",ocsp:"1.3.6.1.5.5.7.48.1",caIssuers:"1.3.6.1.5.5.7.48.2",anyExtendedKeyUsage:"2.5.29.37.0",serverAuth:"1.3.6.1.5.5.7.3.1",clientAuth:"1.3.6.1.5.5.7.3.2",codeSigning:"1.3.6.1.5.5.7.3.3",emailProtection:"1.3.6.1.5.5.7.3.4",timeStamping:"1.3.6.1.5.5.7.3.8",ocspSigning:"1.3.6.1.5.5.7.3.9",ecPublicKey:"1.2.840.10045.2.1",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",extensionRequest:"1.2.840.113549.1.9.14"},this.objCache={},this.name2obj=function(b){if(void 0!==this.objCache[b])return this.objCache[b];if(void 0===this.name2oidList[b])throw"Name of ObjectIdentifier not defined: "+b;var c=this.name2oidList[b],d=new KJUR.asn1.DERObjectIdentifier({oid:c});return this.objCache[b]=d,d},this.atype2obj=function(b){if(void 0!==this.objCache[b])return this.objCache[b];if(void 0===this.atype2oidList[b])throw"AttributeType name undefined: "+b;var c=this.atype2oidList[b],d=new KJUR.asn1.DERObjectIdentifier({oid:c});return this.objCache[b]=d,d}},KJUR.asn1.x509.OID.oid2name=function(b){var c=KJUR.asn1.x509.OID.name2oidList;for(var a in c)if(c[a]==b)return a;return""},KJUR.asn1.x509.OID.oid2atype=function(b){var c=KJUR.asn1.x509.OID.atype2oidList;for(var a in c)if(c[a]==b)return a;return b},KJUR.asn1.x509.OID.name2oid=function(a){var b=KJUR.asn1.x509.OID.name2oidList;return void 0===b[a]?"":b[a]},KJUR.asn1.x509.X509Util={},KJUR.asn1.x509.X509Util.newCertPEM=function(h){var g=KJUR.asn1.x509,b=g.TBSCertificate,a=g.Certificate,f=new b;if(void 0===h.serial)throw"serial number undefined.";if(f.setSerialNumberByParam(h.serial),"string"!=typeof h.sigalg.name)throw"unproper signature algorithm name";if(f.setSignatureAlgByParam(h.sigalg),void 0===h.issuer)throw"issuer name undefined.";if(f.setIssuerByParam(h.issuer),void 0===h.notbefore)throw"notbefore undefined.";if(f.setNotBeforeByParam(h.notbefore),void 0===h.notafter)throw"notafter undefined.";if(f.setNotAfterByParam(h.notafter),void 0===h.subject)throw"subject name undefined.";if(f.setSubjectByParam(h.subject),void 0===h.sbjpubkey)throw"subject public key undefined.";if(f.setSubjectPublicKeyByGetKey(h.sbjpubkey),void 0!==h.ext&&void 0!==h.ext.length)for(var d=0;d<h.ext.length;d++)for(key in h.ext[d])f.appendExtensionByName(key,h.ext[d][key]);if(void 0===h.cakey&&void 0===h.sighex)throw"param cakey and sighex undefined.";var c=null;return h.cakey&&(c=new a({tbscertobj:f,prvkeyobj:!0===h.cakey.isPrivate?h.cakey:KEYUTIL.getKey.apply(null,h.cakey)})).sign(),h.sighex&&(c=new a({tbscertobj:f})).setSignatureHex(h.sighex),c.getPEMString()},void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),void 0!==KJUR.asn1.cms&&KJUR.asn1.cms||(KJUR.asn1.cms={}),KJUR.asn1.cms.Attribute=function(d){var b=KJUR.asn1;b.cms.Attribute.superclass.constructor.call(this),this.getEncodedHex=function(){var h,g,e;h=new b.DERObjectIdentifier({oid:this.attrTypeOid}),g=new b.DERSet({array:this.valueList});try{g.getEncodedHex()}catch(f){throw"fail valueSet.getEncodedHex in Attribute(1)/"+f}e=new b.DERSequence({array:[h,g]});try{this.hTLV=e.getEncodedHex()}catch(f){throw"failed seq.getEncodedHex in Attribute(2)/"+f}return this.hTLV}},YAHOO.lang.extend(KJUR.asn1.cms.Attribute,KJUR.asn1.ASN1Object),KJUR.asn1.cms.ContentType=function(d){var b=KJUR.asn1;b.cms.ContentType.superclass.constructor.call(this),this.attrTypeOid="1.2.840.113549.1.9.3";var a=null;if(void 0!==d){a=new b.DERObjectIdentifier(d);this.valueList=[a]}},YAHOO.lang.extend(KJUR.asn1.cms.ContentType,KJUR.asn1.cms.Attribute),KJUR.asn1.cms.MessageDigest=function(d){var b=KJUR,e=b.asn1,g=e.DEROctetString,i=e.cms;if(i.MessageDigest.superclass.constructor.call(this),this.attrTypeOid="1.2.840.113549.1.9.4",void 0!==d)if(d.eciObj instanceof i.EncapsulatedContentInfo&&"string"==typeof d.hashAlg){var h=d.eciObj.eContentValueHex,c=d.hashAlg;(f=new g({hex:b.crypto.Util.hashHex(h,c)})).getEncodedHex(),this.valueList=[f]}else{var f;(f=new g(d)).getEncodedHex(),this.valueList=[f]}},YAHOO.lang.extend(KJUR.asn1.cms.MessageDigest,KJUR.asn1.cms.Attribute),KJUR.asn1.cms.SigningTime=function(e){var c=KJUR.asn1;if(c.cms.SigningTime.superclass.constructor.call(this),this.attrTypeOid="1.2.840.113549.1.9.5",void 0!==e){var a=new c.x509.Time(e);try{a.getEncodedHex()}catch(b){throw"SigningTime.getEncodedHex() failed/"+b}this.valueList=[a]}},YAHOO.lang.extend(KJUR.asn1.cms.SigningTime,KJUR.asn1.cms.Attribute),KJUR.asn1.cms.SigningCertificate=function(f){var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.cms;c.crypto;e.SigningCertificate.superclass.constructor.call(this),this.attrTypeOid="1.2.840.113549.1.9.16.2.12",this.setCerts=function(n){for(var l=[],k=0;k<n.length;k++){var h=pemtohex(n[k]),g=c.crypto.Util.hashHex(h,"sha1"),o=new b.DEROctetString({hex:g});o.getEncodedHex();var m=new e.IssuerAndSerialNumber({cert:n[k]});m.getEncodedHex();var p=new a({array:[o,m]});p.getEncodedHex(),l.push(p)}var j=new a({array:l});j.getEncodedHex(),this.valueList=[j]},void 0!==f&&"object"==typeof f.array&&this.setCerts(f.array)},YAHOO.lang.extend(KJUR.asn1.cms.SigningCertificate,KJUR.asn1.cms.Attribute),KJUR.asn1.cms.SigningCertificateV2=function(h){var d=KJUR,c=d.asn1,b=c.DERSequence,g=c.x509,f=c.cms,e=d.crypto;if(f.SigningCertificateV2.superclass.constructor.call(this),this.attrTypeOid="1.2.840.113549.1.9.16.2.47",this.setCerts=function(r,k){for(var p=[],n=0;n<r.length;n++){var l=pemtohex(r[n]),t=[];"sha256"!==k&&t.push(new g.AlgorithmIdentifier({name:k}));var j=e.Util.hashHex(l,k),s=new c.DEROctetString({hex:j});s.getEncodedHex(),t.push(s);var o=new f.IssuerAndSerialNumber({cert:r[n]});o.getEncodedHex(),t.push(o);var q=new b({array:t});q.getEncodedHex(),p.push(q)}var m=new b({array:p});m.getEncodedHex(),this.valueList=[m]},void 0!==h&&"object"==typeof h.array){var a="sha256";"string"==typeof h.hashAlg&&(a=h.hashAlg),this.setCerts(h.array,a)}},YAHOO.lang.extend(KJUR.asn1.cms.SigningCertificateV2,KJUR.asn1.cms.Attribute),KJUR.asn1.cms.IssuerAndSerialNumber=function(e){var g=KJUR.asn1,f=g.DERInteger,i=g.cms,a=g.x509.X500Name,c=X509;i.IssuerAndSerialNumber.superclass.constructor.call(this);this.setByCertPEM=function(n){var l=pemtohex(n),k=new c;k.hex=l;var o=k.getIssuerHex();this.dIssuer=new a,this.dIssuer.hTLV=o;var m=k.getSerialNumberHex();this.dSerial=new f({hex:m})},this.getEncodedHex=function(){var k=new g.DERSequence({array:[this.dIssuer,this.dSerial]});return this.hTLV=k.getEncodedHex(),this.hTLV},void 0!==e&&("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&this.setByCertPEM(e),e.issuer&&e.serial&&(e.issuer instanceof a?this.dIssuer=e.issuer:this.dIssuer=new a(e.issuer),e.serial instanceof f?this.dSerial=e.serial:this.dSerial=new f(e.serial)),"string"==typeof e.cert&&this.setByCertPEM(e.cert))},YAHOO.lang.extend(KJUR.asn1.cms.IssuerAndSerialNumber,KJUR.asn1.ASN1Object),KJUR.asn1.cms.AttributeList=function(d){var a=KJUR.asn1,c=a.cms;c.AttributeList.superclass.constructor.call(this),this.list=new Array,this.sortFlag=!0,this.add=function(e){e instanceof c.Attribute&&this.list.push(e)},this.length=function(){return this.list.length},this.clear=function(){this.list=new Array,this.hTLV=null,this.hV=null},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;var e=new a.DERSet({array:this.list,sortflag:this.sortFlag});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==d&&void 0!==d.sortflag&&0==d.sortflag&&(this.sortFlag=!1)},YAHOO.lang.extend(KJUR.asn1.cms.AttributeList,KJUR.asn1.ASN1Object),KJUR.asn1.cms.SignerInfo=function(e){var a=KJUR,h=a.asn1,b=h.DERTaggedObject,n=h.cms,j=n.AttributeList,g=n.ContentType,k=n.EncapsulatedContentInfo,c=n.MessageDigest,l=n.SignedData,m=h.x509.AlgorithmIdentifier,f=a.crypto,i=KEYUTIL;n.SignerInfo.superclass.constructor.call(this),this.dCMSVersion=new h.DERInteger({int:1}),this.dSignerIdentifier=null,this.dDigestAlgorithm=null,this.dSignedAttrs=new j,this.dSigAlg=null,this.dSig=null,this.dUnsignedAttrs=new j,this.setSignerIdentifier=function(p){if("string"==typeof p&&-1!=p.indexOf("CERTIFICATE")&&-1!=p.indexOf("BEGIN")&&-1!=p.indexOf("END")){this.dSignerIdentifier=new n.IssuerAndSerialNumber({cert:p})}},this.setForContentAndHash=function(o){void 0!==o&&(o.eciObj instanceof k&&(this.dSignedAttrs.add(new g({oid:"1.2.840.113549.1.7.1"})),this.dSignedAttrs.add(new c({eciObj:o.eciObj,hashAlg:o.hashAlg}))),void 0!==o.sdObj&&o.sdObj instanceof l&&-1==o.sdObj.digestAlgNameList.join(":").indexOf(o.hashAlg)&&o.sdObj.digestAlgNameList.push(o.hashAlg),"string"==typeof o.hashAlg&&(this.dDigestAlgorithm=new m({name:o.hashAlg})))},this.sign=function(t,p){this.dSigAlg=new m({name:p});var q=this.dSignedAttrs.getEncodedHex(),o=i.getKey(t),s=new f.Signature({alg:p});s.init(o),s.updateHex(q);var r=s.sign();this.dSig=new h.DEROctetString({hex:r})},this.addUnsigned=function(o){this.hTLV=null,this.dUnsignedAttrs.hTLV=null,this.dUnsignedAttrs.add(o)},this.getEncodedHex=function(){if(this.dSignedAttrs instanceof j&&0==this.dSignedAttrs.length())throw"SignedAttrs length = 0 (empty)";var o=new b({obj:this.dSignedAttrs,tag:"a0",explicit:!1}),r=null;this.dUnsignedAttrs.length()>0&&(r=new b({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig];null!=r&&q.push(r);var p=new h.DERSequence({array:q});return this.hTLV=p.getEncodedHex(),this.hTLV}},YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object),KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var b=KJUR.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString;b.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new h({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(i){i.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new h({oid:i}):this.dEContentType=new h({name:i})},this.setContentValue=function(i){void 0!==i&&("string"==typeof i.hex?this.eContentValueHex=i.hex:"string"==typeof i.str&&(this.eContentValueHex=utf8tohex(i.str)))},this.setContentValueHex=function(i){this.eContentValueHex=i},this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:"a0",explicit:!0});var i=[this.dEContentType];this.isDetached||i.push(this.dEContent);var j=new a({array:i});return this.hTLV=j.getEncodedHex(),this.hTLV}},YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object),KJUR.asn1.cms.ContentInfo=function(f){var b=KJUR.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(g){"string"==typeof g&&(this.dContentType=e.OID.name2obj(g))},this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:"a0",explicit:!0}),g=new a({array:[this.dContentType,h]});return this.hTLV=g.getEncodedHex(),this.hTLV},void 0!==f&&(f.type&&this.setContentType(f.type),f.obj&&f.obj instanceof b.ASN1Object&&(this.dContent=f.obj))},YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object),KJUR.asn1.cms.SignedData=function(e){var h=KJUR.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,k=h.x509.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new g({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new i,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new d],this.addCertificatesByPEM=function(p){var q=pemtohex(p),r=new j;r.hTLV=q,this.certificateList.push(r)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var u=[],t=0;t<this.digestAlgNameList.length;t++){var s=this.digestAlgNameList[t],w=new k({name:s});u.push(w)}this.dDigestAlgs=new m({array:u})}var p=[this.dCMSVersion,this.dDigestAlgs,this.dEncapContentInfo];if(null==this.dCerts&&this.certificateList.length>0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:"a0",explicit:!1})}null!=this.dCerts&&p.push(this.dCerts);var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});return this.hTLV=q.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new n({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),"CMS")}},YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object),KJUR.asn1.cms.CMSUtil=new function(){},KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var j=KJUR.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,e=j.cades.SignaturePolicyIdentifier,m=new n;if(m.dEncapContentInfo.setContentValue(d.content),"object"==typeof d.certs)for(var h=0;h<d.certs.length;h++)m.addCertificatesByPEM(d.certs[h]);m.signerInfoList=[];for(h=0;h<d.signerInfos.length;h++){var k=d.signerInfos[h],g=new f;for(attrName in g.setSignerIdentifier(k.signerCert),g.setForContentAndHash({sdObj:m,eciObj:m.dEncapContentInfo,hashAlg:k.hashAlg}),k.sAttr){var r=k.sAttr[attrName];if("SigningTime"==attrName){var l=new o(r);g.dSignedAttrs.add(l)}if("SigningCertificate"==attrName){l=new a(r);g.dSignedAttrs.add(l)}if("SigningCertificateV2"==attrName){l=new p(r);g.dSignedAttrs.add(l)}if("SignaturePolicyIdentifier"==attrName){l=new e(r);g.dSignedAttrs.add(l)}}g.sign(k.signerPrvKey,k.sigAlg),m.signerInfoList.push(g)}return m},KJUR.asn1.cms.CMSUtil.verifySignedData=function(n){var C=KJUR,p=C.asn1,s=p.cms,i=(s.SignerInfo,s.SignedData,s.SigningTime,s.SigningCertificate,s.SigningCertificateV2,p.cades.SignaturePolicyIdentifier,C.lang.String.isHex),v=ASN1HEX,h=v.getVbyList,a=v.getTLVbyList,t=v.getIdxbyList,z=v.getChildIdx,c=v.getTLV,B=v.oidname,j=C.crypto.Util.hashHex;void 0===n.cms&&i(n.cms);var E=n.cms,k=function(I,J){var F=J.idx;J.signerid_issuer1=a(I,F,[1,0],"30"),J.signerid_serial1=h(I,F,[1,1],"02"),J.hashalg=B(h(I,F,[2,0],"06"));var H=t(I,F,[3],"a0");J.idxSignedAttrs=H,f(I,J,H);var K=z(I,F).length;if(K<6)throw"malformed SignerInfo";J.sigalg=B(h(I,F,[K-2,0],"06")),J.sigval=h(I,F,[K-1],"04")},f=function(L,M,F){var J=z(L,F);M.signedAttrIdxList=J;for(var K=0;K<J.length;K++){var H,I=J[K],G=h(L,I,[0],"06");"2a864886f70d010905"===G?(H=hextoutf8(h(L,I,[1,0])),M.saSigningTime=H):"2a864886f70d010904"===G&&(H=h(L,I,[1,0],"04"),M.saMessageDigest=H)}},e=function(F,R,I,N){I.verifyDetail={};var Q=I.verifyDetail,K=R.parse.econtent,G=I.hashalg,L=I.saMessageDigest;Q.validMessageDigest=!1,j(K,G)===L&&(Q.validMessageDigest=!0),function(F,Q,J,P){var H,N=Q.parse.certsIdx;if(void 0===Q.certs){H=[],Q.certkeys=[];for(var K=z(F,N),I=0;I<K.length;I++){var M=c(F,K[I]),O=new X509;O.readCertHex(M),H[I]=O,Q.certkeys[I]=O.getPublicKey()}Q.certs=H}else H=Q.certs;Q.cccc=H.length,Q.cccci=K.length;for(I=0;I<H.length;I++){var L=O.getIssuerHex(),G=O.getSerialNumberHex();J.signerid_issuer1===L&&J.signerid_serial1===G&&(J.certkey_idx=I)}}(F,R,I),Q.validSignatureValue=!1;var H=I.sigalg,M="31"+c(F,I.idxSignedAttrs).substr(2);I.signedattrshex=M;var J=R.certs[I.certkey_idx].getPublicKey(),P=new KJUR.crypto.Signature({alg:H});P.init(J),P.updateHex(M);var O=P.verify(I.sigval);Q.validSignatureValue_isValid=O,!0===O&&(Q.validSignatureValue=!0),I.isValid=!1,Q.validMessageDigest&&Q.validSignatureValue&&(I.isValid=!0)},r={isValid:!1,parse:{}};return function(G,F){if("2a864886f70d010702"!==h(G,0,[0],"06"))return F;F.cmsType="signedData",F.econtent=h(G,0,[1,0,2,1,0]),function(J,H){for(var G,I=3;I<6;I++)if(void 0!==(G=t(J,0,[1,0,I]))){var F=J.substr(G,2);"a0"===F&&(H.certsIdx=G),"a1"===F&&(H.revinfosIdx=G),"31"===F&&(H.signerinfosIdx=G)}}(G,F),F.signerInfos=[],function(I,F){var H=F.signerinfosIdx;if(void 0!==H){var L=z(I,H);F.signerInfoIdxList=L;for(var G=0;G<L.length;G++){var J={idx:L[G]};k(I,J),F.signerInfos.push(J)}}}(G,F)}(E,r.parse),function(J,F){for(var G=F.parse.signerInfos,L=G.length,K=!0,I=0;I<L;I++){var H=G[I];e(J,F,H,I),H.isValid||(K=!1)}F.isValid=K}(E,r),r},void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),void 0!==KJUR.asn1.tsp&&KJUR.asn1.tsp||(KJUR.asn1.tsp={}),KJUR.asn1.tsp.Accuracy=function(f){var b=KJUR.asn1,e=b.DERInteger,a=b.DERSequence,d=b.DERTaggedObject;b.tsp.Accuracy.superclass.constructor.call(this),this.seconds=null,this.millis=null,this.micros=null,this.getEncodedHex=function(){var i=null,k=null,m=null,g=[];if(null!=this.seconds&&(i=new e({int:this.seconds}),g.push(i)),null!=this.millis){var l=new e({int:this.millis});k=new d({obj:l,tag:"80",explicit:!1}),g.push(k)}if(null!=this.micros){var j=new e({int:this.micros});m=new d({obj:j,tag:"81",explicit:!1}),g.push(m)}var h=new a({array:g});return this.hTLV=h.getEncodedHex(),this.hTLV},void 0!==f&&("number"==typeof f.seconds&&(this.seconds=f.seconds),"number"==typeof f.millis&&(this.millis=f.millis),"number"==typeof f.micros&&(this.micros=f.micros))},YAHOO.lang.extend(KJUR.asn1.tsp.Accuracy,KJUR.asn1.ASN1Object),KJUR.asn1.tsp.MessageImprint=function(g){var b=KJUR.asn1,a=b.DERSequence,d=b.DEROctetString,e=b.x509.AlgorithmIdentifier;b.tsp.MessageImprint.superclass.constructor.call(this),this.dHashAlg=null,this.dHashValue=null,this.getEncodedHex=function(){return"string"==typeof this.hTLV?this.hTLV:new a({array:[this.dHashAlg,this.dHashValue]}).getEncodedHex()},void 0!==g&&("string"==typeof g.hashAlg&&(this.dHashAlg=new e({name:g.hashAlg})),"string"==typeof g.hashValue&&(this.dHashValue=new d({hex:g.hashValue})))},YAHOO.lang.extend(KJUR.asn1.tsp.MessageImprint,KJUR.asn1.ASN1Object),KJUR.asn1.tsp.TimeStampReq=function(c){var f=KJUR.asn1,d=f.DERSequence,e=f.DERInteger,g=f.DERBoolean,i=f.DERObjectIdentifier,h=f.tsp,b=h.MessageImprint;h.TimeStampReq.superclass.constructor.call(this),this.dVersion=new e({int:1}),this.dMessageImprint=null,this.dPolicy=null,this.dNonce=null,this.certReq=!0,this.setMessageImprint=function(j){j instanceof b?this.dMessageImprint=j:"object"==typeof j&&(this.dMessageImprint=new b(j))},this.getEncodedHex=function(){if(null==this.dMessageImprint)throw"messageImprint shall be specified";var j=[this.dVersion,this.dMessageImprint];null!=this.dPolicy&&j.push(this.dPolicy),null!=this.dNonce&&j.push(this.dNonce),this.certReq&&j.push(new g);var k=new d({array:j});return this.hTLV=k.getEncodedHex(),this.hTLV},void 0!==c&&("object"==typeof c.mi&&this.setMessageImprint(c.mi),"object"==typeof c.policy&&(this.dPolicy=new i(c.policy)),"object"==typeof c.nonce&&(this.dNonce=new e(c.nonce)),"boolean"==typeof c.certreq&&(this.certReq=c.certreq))},YAHOO.lang.extend(KJUR.asn1.tsp.TimeStampReq,KJUR.asn1.ASN1Object),KJUR.asn1.tsp.TSTInfo=function(e){var i=KJUR.asn1,f=i.DERSequence,h=i.DERInteger,k=i.DERBoolean,g=i.DERGeneralizedTime,l=i.DERObjectIdentifier,j=i.tsp,d=j.MessageImprint,b=j.Accuracy,a=i.x509.X500Name;if(j.TSTInfo.superclass.constructor.call(this),this.dVersion=new h({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerialNumber=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.getEncodedHex=function(){var m=[this.dVersion];if(null==this.dPolicy)throw"policy shall be specified.";if(m.push(this.dPolicy),null==this.dMessageImprint)throw"messageImprint shall be specified.";if(m.push(this.dMessageImprint),null==this.dSerialNumber)throw"serialNumber shall be specified.";if(m.push(this.dSerialNumber),null==this.dGenTime)throw"genTime shall be specified.";m.push(this.dGenTime),null!=this.dAccuracy&&m.push(this.dAccuracy),null!=this.dOrdering&&m.push(this.dOrdering),null!=this.dNonce&&m.push(this.dNonce),null!=this.dTsa&&m.push(this.dTsa);var n=new f({array:m});return this.hTLV=n.getEncodedHex(),this.hTLV},void 0!==e){if("string"==typeof e.policy){if(!e.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new l({oid:e.policy})}void 0!==e.messageImprint&&(this.dMessageImprint=new d(e.messageImprint)),void 0!==e.serialNumber&&(this.dSerialNumber=new h(e.serialNumber)),void 0!==e.genTime&&(this.dGenTime=new g(e.genTime)),void 0!==e.accuracy&&(this.dAccuracy=new b(e.accuracy)),void 0!==e.ordering&&1==e.ordering&&(this.dOrdering=new k),void 0!==e.nonce&&(this.dNonce=new h(e.nonce)),void 0!==e.tsa&&(this.dTsa=new a(e.tsa))}},YAHOO.lang.extend(KJUR.asn1.tsp.TSTInfo,KJUR.asn1.ASN1Object),KJUR.asn1.tsp.TimeStampResp=function(g){var d=KJUR.asn1,c=d.DERSequence,f=d.ASN1Object,a=d.tsp,b=a.PKIStatusInfo;a.TimeStampResp.superclass.constructor.call(this),this.dStatus=null,this.dTST=null,this.getEncodedHex=function(){if(null==this.dStatus)throw"status shall be specified";var h=[this.dStatus];null!=this.dTST&&h.push(this.dTST);var i=new c({array:h});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==g&&("object"==typeof g.status&&(this.dStatus=new b(g.status)),void 0!==g.tst&&g.tst instanceof f&&(this.dTST=g.tst.getContentInfo()))},YAHOO.lang.extend(KJUR.asn1.tsp.TimeStampResp,KJUR.asn1.ASN1Object),KJUR.asn1.tsp.PKIStatusInfo=function(h){var f=KJUR.asn1,e=f.DERSequence,a=f.tsp,d=a.PKIStatus,c=a.PKIFreeText,b=a.PKIFailureInfo;a.PKIStatusInfo.superclass.constructor.call(this),this.dStatus=null,this.dStatusString=null,this.dFailureInfo=null,this.getEncodedHex=function(){if(null==this.dStatus)throw"status shall be specified";var i=[this.dStatus];null!=this.dStatusString&&i.push(this.dStatusString),null!=this.dFailureInfo&&i.push(this.dFailureInfo);var j=new e({array:i});return this.hTLV=j.getEncodedHex(),this.hTLV},void 0!==h&&("object"==typeof h.status&&(this.dStatus=new d(h.status)),"object"==typeof h.statstr&&(this.dStatusString=new c({array:h.statstr})),"object"==typeof h.failinfo&&(this.dFailureInfo=new b(h.failinfo)))},YAHOO.lang.extend(KJUR.asn1.tsp.PKIStatusInfo,KJUR.asn1.ASN1Object),KJUR.asn1.tsp.PKIStatus=function(h){var c=KJUR.asn1,g=c.DERInteger,a=c.tsp,b=a.PKIStatus;a.PKIStatus.superclass.constructor.call(this);if(this.getEncodedHex=function(){return this.hTLV=this.dStatus.getEncodedHex(),this.hTLV},void 0!==h)if(void 0!==h.name){var e=b.valueList;if(void 0===e[h.name])throw"name undefined: "+h.name;this.dStatus=new g({int:e[h.name]})}else this.dStatus=new g(h)},YAHOO.lang.extend(KJUR.asn1.tsp.PKIStatus,KJUR.asn1.ASN1Object),KJUR.asn1.tsp.PKIStatus.valueList={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5},KJUR.asn1.tsp.PKIFreeText=function(f){var d=KJUR.asn1,b=d.DERSequence,c=d.DERUTF8String;d.tsp.PKIFreeText.superclass.constructor.call(this),this.textList=[],this.getEncodedHex=function(){for(var g=[],j=0;j<this.textList.length;j++)g.push(new c({str:this.textList[j]}));var h=new b({array:g});return this.hTLV=h.getEncodedHex(),this.hTLV},void 0!==f&&"object"==typeof f.array&&(this.textList=f.array)},YAHOO.lang.extend(KJUR.asn1.tsp.PKIFreeText,KJUR.asn1.ASN1Object),KJUR.asn1.tsp.PKIFailureInfo=function(g){var c=KJUR.asn1,f=c.DERBitString,b=c.tsp.PKIFailureInfo;if(b.superclass.constructor.call(this),this.value=null,this.getEncodedHex=function(){if(null==this.value)throw"value shall be specified";var h=new Number(this.value).toString(2),i=new f;return i.setByBinaryString(h),this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==g)if("string"==typeof g.name){var e=b.valueList;if(void 0===e[g.name])throw"name undefined: "+g.name;this.value=e[g.name]}else"number"==typeof g.int&&(this.value=g.int)},YAHOO.lang.extend(KJUR.asn1.tsp.PKIFailureInfo,KJUR.asn1.ASN1Object),KJUR.asn1.tsp.PKIFailureInfo.valueList={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25},KJUR.asn1.tsp.AbstractTSAAdapter=function(a){this.getTSTHex=function(c,b){throw"not implemented yet"}},KJUR.asn1.tsp.SimpleTSAAdapter=function(e){var d=KJUR,a=d.asn1.tsp,b=d.crypto.Util.hashHex;a.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(g,f){var i=b(g,f);this.params.tstInfo.messageImprint={hashAlg:f,hashValue:i},this.params.tstInfo.serialNumber={int:this.serial++};var h=Math.floor(1e9*Math.random());return this.params.tstInfo.nonce={int:h},a.TSPUtil.newTimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==e&&(this.params=e)},YAHOO.lang.extend(KJUR.asn1.tsp.SimpleTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter),KJUR.asn1.tsp.FixedTSAAdapter=function(e){var d=KJUR,a=d.asn1.tsp,b=d.crypto.Util.hashHex;a.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(g,f){var h=b(g,f);return this.params.tstInfo.messageImprint={hashAlg:f,hashValue:h},a.TSPUtil.newTimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==e&&(this.params=e)},YAHOO.lang.extend(KJUR.asn1.tsp.FixedTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter),KJUR.asn1.tsp.TSPUtil=new function(){},KJUR.asn1.tsp.TSPUtil.newTimeStampToken=function(c){var h=KJUR.asn1,m=h.cms,a=(h.tsp,h.tsp.TSTInfo),j=new m.SignedData,f=new a(c.tstInfo).getEncodedHex();if(j.dEncapContentInfo.setContentValue({hex:f}),j.dEncapContentInfo.setContentType("tstinfo"),"object"==typeof c.certs)for(var e=0;e<c.certs.length;e++)j.addCertificatesByPEM(c.certs[e]);var d=j.signerInfoList[0];d.setSignerIdentifier(c.signerCert),d.setForContentAndHash({sdObj:j,eciObj:j.dEncapContentInfo,hashAlg:c.hashAlg});var l=new m.SigningCertificate({array:[c.signerCert]});return d.dSignedAttrs.add(l),d.sign(c.signerPrvKey,c.sigAlg),j},KJUR.asn1.tsp.TSPUtil.parseTimeStampReq=function(m){var l=ASN1HEX,h=l.getChildIdx,f=l.getV,b=l.getTLV,j={certreq:!1},a=h(m,0);if(a.length<2)throw"TimeStampReq must have at least 2 items";var e=b(m,a[1]);j.mi=KJUR.asn1.tsp.TSPUtil.parseMessageImprint(e);for(var d=2;d<a.length;d++){var g=a[d],k=m.substr(g,2);if("06"==k){var c=f(m,g);j.policy=l.hextooidstr(c)}"02"==k&&(j.nonce=f(m,g)),"01"==k&&(j.certreq=!0)}return j},KJUR.asn1.tsp.TSPUtil.parseMessageImprint=function(c){var m=ASN1HEX,j=m.getChildIdx,i=m.getV,g=m.getIdxbyList,k={};if("30"!=c.substr(0,2))throw"head of messageImprint hex shall be '30'";j(c,0);var e=i(c,g(c,0,[0,0])),d=m.hextooidstr(e),h=KJUR.asn1.x509.OID.oid2name(d);if(""==h)throw"hashAlg name undefined: "+d;var b=h,f=g(c,0,[1]);return k.hashAlg=b,k.hashValue=i(c,f),k},void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),void 0!==KJUR.asn1.cades&&KJUR.asn1.cades||(KJUR.asn1.cades={}),KJUR.asn1.cades.SignaturePolicyIdentifier=function(f){var h=KJUR.asn1,i=h.DERObjectIdentifier,g=h.DERSequence,e=h.cades,c=e.OtherHashAlgAndValue;if(e.SignaturePolicyIdentifier.superclass.constructor.call(this),this.attrTypeOid="1.2.840.113549.1.9.16.2.15",void 0!==f&&"string"==typeof f.oid&&"object"==typeof f.hash){var j=new g({array:[new i({oid:f.oid}),new c(f.hash)]});this.valueList=[j]}},YAHOO.lang.extend(KJUR.asn1.cades.SignaturePolicyIdentifier,KJUR.asn1.cms.Attribute),KJUR.asn1.cades.OtherHashAlgAndValue=function(e){var g=KJUR.asn1,f=g.DERSequence,h=g.DEROctetString,i=g.x509.AlgorithmIdentifier;g.cades.OtherHashAlgAndValue.superclass.constructor.call(this),this.dAlg=null,this.dHash=null,this.getEncodedHex=function(){var j=new f({array:[this.dAlg,this.dHash]});return this.hTLV=j.getEncodedHex(),this.hTLV},void 0!==e&&"string"==typeof e.alg&&"string"==typeof e.hash&&(this.dAlg=new i({name:e.alg}),this.dHash=new h({hex:e.hash}))},YAHOO.lang.extend(KJUR.asn1.cades.OtherHashAlgAndValue,KJUR.asn1.ASN1Object),KJUR.asn1.cades.SignatureTimeStamp=function(h){var b=KJUR.asn1,e=b.ASN1Object;b.x509;if(b.cades.SignatureTimeStamp.superclass.constructor.call(this),this.attrTypeOid="1.2.840.113549.1.9.16.2.14",this.tstHex=null,void 0!==h){if(void 0!==h.res)if("string"==typeof h.res&&h.res.match(/^[0-9A-Fa-f]+$/));else if(!(h.res instanceof e))throw"res param shall be ASN1Object or hex string";if(void 0!==h.tst)if("string"==typeof h.tst&&h.tst.match(/^[0-9A-Fa-f]+$/)){var f=new e;this.tstHex=h.tst,f.hTLV=this.tstHex,f.getEncodedHex(),this.valueList=[f]}else if(!(h.tst instanceof e))throw"tst param shall be ASN1Object or hex string"}},YAHOO.lang.extend(KJUR.asn1.cades.SignatureTimeStamp,KJUR.asn1.cms.Attribute),KJUR.asn1.cades.CompleteCertificateRefs=function(d){var a=KJUR.asn1.cades;a.CompleteCertificateRefs.superclass.constructor.call(this),this.attrTypeOid="1.2.840.113549.1.9.16.2.21",this.setByArray=function(e){this.valueList=[];for(var f=0;f<e.length;f++){var g=new a.OtherCertID(e[f]);this.valueList.push(g)}},void 0!==d&&"object"==typeof d&&"number"==typeof d.length&&this.setByArray(d)},YAHOO.lang.extend(KJUR.asn1.cades.CompleteCertificateRefs,KJUR.asn1.cms.Attribute),KJUR.asn1.cades.OtherCertID=function(e){var b=KJUR.asn1,d=b.cms,a=b.cades;a.OtherCertID.superclass.constructor.call(this),this.hasIssuerSerial=!0,this.dOtherCertHash=null,this.dIssuerSerial=null,this.setByCertPEM=function(f){this.dOtherCertHash=new a.OtherHash(f),this.hasIssuerSerial&&(this.dIssuerSerial=new d.IssuerAndSerialNumber(f))},this.getEncodedHex=function(){if(null!=this.hTLV)return this.hTLV;if(null==this.dOtherCertHash)throw"otherCertHash not set";var f=[this.dOtherCertHash];null!=this.dIssuerSerial&&f.push(this.dIssuerSerial);var g=new b.DERSequence({array:f});return this.hTLV=g.getEncodedHex(),this.hTLV},void 0!==e&&("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&this.setByCertPEM(e),"object"==typeof e&&(!1===e.hasis&&(this.hasIssuerSerial=!1),"string"==typeof e.cert&&this.setByCertPEM(e.cert)))},YAHOO.lang.extend(KJUR.asn1.cades.OtherCertID,KJUR.asn1.ASN1Object),KJUR.asn1.cades.OtherHash=function(f){var d=KJUR,c=d.asn1,b=(c.cms,c.cades),g=b.OtherHashAlgAndValue,a=d.crypto.Util.hashHex;if(b.OtherHash.superclass.constructor.call(this),this.alg="sha256",this.dOtherHash=null,this.setByCertPEM=function(h){if(-1==h.indexOf("-----BEGIN "))throw"certPEM not to seem PEM format";var i=pemtohex(h),j=a(i,this.alg);this.dOtherHash=new g({alg:this.alg,hash:j})},this.getEncodedHex=function(){if(null==this.dOtherHash)throw"OtherHash not set";return this.dOtherHash.getEncodedHex()},void 0!==f)if("string"==typeof f)if(-1!=f.indexOf("-----BEGIN "))this.setByCertPEM(f);else{if(!f.match(/^[0-9A-Fa-f]+$/))throw"unsupported string value for params";this.dOtherHash=new c.DEROctetString({hex:f})}else"object"==typeof f&&("string"==typeof f.cert?("string"==typeof f.alg&&(this.alg=f.alg),this.setByCertPEM(f.cert)):this.dOtherHash=new g(f))},YAHOO.lang.extend(KJUR.asn1.cades.OtherHash,KJUR.asn1.ASN1Object),KJUR.asn1.cades.CAdESUtil=new function(){},KJUR.asn1.cades.CAdESUtil.addSigTS=function(c,b,a){},KJUR.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(e){var p=ASN1HEX,u=p.getChildIdx,b=p.getTLV,a=p.getTLVbyList,k=p.getIdxbyList,g=KJUR.asn1,l=g.ASN1Object,h=g.cms.SignedData,z=g.cades.CAdESUtil,m={};if("06092a864886f70d010702"!=a(e,0,[0]))throw"hex is not CMS SignedData";var B=u(e,k(e,0,[1,0]));if(B.length<4)throw"num of SignedData elem shall be 4 at least";var d=B.shift();m.version=b(e,d);var w=B.shift();m.algs=b(e,w);var c=B.shift();m.encapcontent=b(e,c),m.certs=null,m.revs=null,m.si=[];var o=B.shift();"a0"==e.substr(o,2)&&(m.certs=b(e,o),o=B.shift()),"a1"==e.substr(o,2)&&(m.revs=b(e,o),o=B.shift());var t=o;if("31"!=e.substr(t,2))throw"Can't find signerInfos";for(var f=u(e,t),q=0;q<f.length;q++){var s=f[q],n=z.parseSignerInfoForAddingUnsigned(e,s,q);m.si[q]=n}var x=null;m.obj=new h,(x=new l).hTLV=m.version,m.obj.dCMSVersion=x,(x=new l).hTLV=m.algs,m.obj.dDigestAlgs=x,(x=new l).hTLV=m.encapcontent,m.obj.dEncapContentInfo=x,(x=new l).hTLV=m.certs,m.obj.dCerts=x,m.obj.signerInfoList=[];for(q=0;q<m.si.length;q++)m.obj.signerInfoList.push(m.si[q].obj);return m},KJUR.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(g,q,c){var p=ASN1HEX,s=p.getChildIdx,a=p.getTLV,l=p.getV,h=KJUR.asn1,n=h.ASN1Object,j=h.cms,k=j.AttributeList,w=j.SignerInfo,o={},t=s(g,q);if(6!=t.length)throw"not supported items for SignerInfo (!=6)";var d=t.shift();o.version=a(g,d);var e=t.shift();o.si=a(g,e);var m=t.shift();o.digalg=a(g,m);var f=t.shift();o.sattrs=a(g,f);var i=t.shift();o.sigalg=a(g,i);var b=t.shift();o.sig=a(g,b),o.sigval=l(g,b);var u=null;return o.obj=new w,(u=new n).hTLV=o.version,o.obj.dCMSVersion=u,(u=new n).hTLV=o.si,o.obj.dSignerIdentifier=u,(u=new n).hTLV=o.digalg,o.obj.dDigestAlgorithm=u,(u=new n).hTLV=o.sattrs,o.obj.dSignedAttrs=u,(u=new n).hTLV=o.sigalg,o.obj.dSigAlg=u,(u=new n).hTLV=o.sig,o.obj.dSig=u,o.obj.dUnsignedAttrs=new k,o},void 0!==KJUR.asn1.csr&&KJUR.asn1.csr||(KJUR.asn1.csr={}),KJUR.asn1.csr.CertificationRequest=function(d){var a=KJUR,f=a.asn1,b=f.DERBitString,e=f.DERSequence,k=f.csr,c=f.x509;k.CertificationRequest.superclass.constructor.call(this);this.sign=function(o,n){null==this.prvKey&&(this.prvKey=n),this.asn1SignatureAlg=new c.AlgorithmIdentifier({name:o}),sig=new a.crypto.Signature({alg:o}),sig.init(this.prvKey),sig.updateHex(this.asn1CSRInfo.getEncodedHex()),this.hexSig=sig.sign(),this.asn1Sig=new b({hex:"00"+this.hexSig});var m=new e({array:[this.asn1CSRInfo,this.asn1SignatureAlg,this.asn1Sig]});this.hTLV=m.getEncodedHex(),this.isModified=!1},this.getPEMString=function(){return hextopem(this.getEncodedHex(),"CERTIFICATE REQUEST")},this.getEncodedHex=function(){if(0==this.isModified&&null!=this.hTLV)return this.hTLV;throw"not signed yet"},void 0!==d&&void 0!==d.csrinfo&&(this.asn1CSRInfo=d.csrinfo)},YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequest,KJUR.asn1.ASN1Object),KJUR.asn1.csr.CertificationRequestInfo=function(e){var h=KJUR.asn1,g=h.DERInteger,f=h.DERSequence,m=h.DERSet,j=h.DERNull,c=h.DERTaggedObject,k=h.DERObjectIdentifier,l=h.csr,d=h.x509,a=d.X500Name,n=d.Extension,i=KEYUTIL;l.CertificationRequestInfo.superclass.constructor.call(this),this._initialize=function(){this.asn1Array=new Array,this.asn1Version=new g({int:0}),this.asn1Subject=null,this.asn1SubjPKey=null,this.extensionsArray=new Array},this.setSubjectByParam=function(o){this.asn1Subject=new a(o)},this.setSubjectPublicKeyByGetKey=function(p){var o=i.getKey(p);this.asn1SubjPKey=new d.SubjectPublicKeyInfo(o)},this.appendExtensionByName=function(p,o){n.appendByNameToArray(p,o,this.extensionsArray)},this.getEncodedHex=function(){if(this.asn1Array=new Array,this.asn1Array.push(this.asn1Version),this.asn1Array.push(this.asn1Subject),this.asn1Array.push(this.asn1SubjPKey),this.extensionsArray.length>0){var s=new f({array:this.extensionsArray}),r=new m({array:[s]}),q=new f({array:[new k({oid:"1.2.840.113549.1.9.14"}),r]}),p=new c({explicit:!0,tag:"a0",obj:q});this.asn1Array.push(p)}else{p=new c({explicit:!1,tag:"a0",obj:new j});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});return this.hTLV=t.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object),KJUR.asn1.csr.CSRUtil=new function(){},KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(void 0===h.subject)throw"parameter subject undefined";if(void 0===h.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===h.sigalg)throw"parameter sigalg undefined";if(void 0===h.sbjprvkey)throw"parameter sbjpubkey undefined";var d=new b.CertificationRequestInfo;if(d.setSubjectByParam(h.subject),d.setSubjectPublicKeyByGetKey(h.sbjpubkey),void 0!==h.ext&&void 0!==h.ext.length)for(var e=0;e<h.ext.length;e++)for(key in h.ext[e])d.appendExtensionByName(key,h.ext[e][key]);var f=new b.CertificationRequest({csrinfo:d}),a=c.getKey(h.sbjprvkey);return f.sign(h.sigalg,a),f.getPEMString()},KJUR.asn1.csr.CSRUtil.getInfo=function(b){var e=ASN1HEX.getTLVbyList,a={subject:{},pubkey:{}};if(-1==b.indexOf("-----BEGIN CERTIFICATE REQUEST"))throw"argument is not PEM file";var c=pemtohex(b,"CERTIFICATE REQUEST");return a.subject.hex=e(c,0,[0,1]),a.subject.name=X509.hex2dn(a.subject.hex),a.pubkey.hex=e(c,0,[0,2]),a.pubkey.obj=KEYUTIL.getKey(a.pubkey.hex,null,"pkcs8pub"),a},void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),void 0!==KJUR.asn1.ocsp&&KJUR.asn1.ocsp||(KJUR.asn1.ocsp={}),KJUR.asn1.ocsp.DEFAULT_HASH="sha1",KJUR.asn1.ocsp.CertID=function(g){var d=KJUR,k=d.asn1,m=k.DEROctetString,j=k.DERInteger,h=k.DERSequence,n=k.x509.AlgorithmIdentifier,o=k.ocsp,l=o.DEFAULT_HASH,e=d.crypto.Util.hashHex,c=X509,q=ASN1HEX;if(o.CertID.superclass.constructor.call(this),this.dHashAlg=null,this.dIssuerNameHash=null,this.dIssuerKeyHash=null,this.dSerialNumber=null,this.setByValue=function(t,s,p,r){void 0===r&&(r=l),this.dHashAlg=new n({name:r}),this.dIssuerNameHash=new m({hex:t}),this.dIssuerKeyHash=new m({hex:s}),this.dSerialNumber=new j({hex:p})},this.setByCert=function(x,t,v){void 0===v&&(v=l);var p=new c;p.readCertPEM(t);var y=new c;y.readCertPEM(x);var z=y.getPublicKeyHex(),w=q.getTLVbyList(z,0,[1,0],"30"),r=p.getSerialNumberHex(),s=e(y.getSubjectHex(),v),u=e(w,v);this.setByValue(s,u,r,v),this.hoge=p.getSerialNumberHex()},this.getEncodedHex=function(){if(null===this.dHashAlg&&null===this.dIssuerNameHash&&null===this.dIssuerKeyHash&&null===this.dSerialNumber)throw"not yet set values";var p=[this.dHashAlg,this.dIssuerNameHash,this.dIssuerKeyHash,this.dSerialNumber],r=new h({array:p});return this.hTLV=r.getEncodedHex(),this.hTLV},void 0!==g){var b=g;if(void 0!==b.issuerCert&&void 0!==b.subjectCert){var a=l;void 0===b.alg&&(a=void 0),this.setByCert(b.issuerCert,b.subjectCert,a)}else{if(void 0===b.namehash||void 0===b.keyhash||void 0===b.serial)throw"invalid constructor arguments";a=l;void 0===b.alg&&(a=void 0),this.setByValue(b.namehash,b.keyhash,b.serial,a)}}},YAHOO.lang.extend(KJUR.asn1.ocsp.CertID,KJUR.asn1.ASN1Object),KJUR.asn1.ocsp.Request=function(f){var b=KJUR.asn1,a=b.DERSequence,d=b.ocsp;if(d.Request.superclass.constructor.call(this),this.dReqCert=null,this.dExt=null,this.getEncodedHex=function(){var g=[];if(null===this.dReqCert)throw"reqCert not set";g.push(this.dReqCert);var h=new a({array:g});return this.hTLV=h.getEncodedHex(),this.hTLV},void 0!==f){var e=new d.CertID(f);this.dReqCert=e}},YAHOO.lang.extend(KJUR.asn1.ocsp.Request,KJUR.asn1.ASN1Object),KJUR.asn1.ocsp.TBSRequest=function(e){var b=KJUR.asn1,a=b.DERSequence,d=b.ocsp;d.TBSRequest.superclass.constructor.call(this),this.version=0,this.dRequestorName=null,this.dRequestList=[],this.dRequestExt=null,this.setRequestListByParam=function(h){for(var f=[],g=0;g<h.length;g++){var j=new d.Request(h[0]);f.push(j)}this.dRequestList=f},this.getEncodedHex=function(){var f=[];if(0!==this.version)throw"not supported version: "+this.version;if(null!==this.dRequestorName)throw"requestorName not supported";var h=new a({array:this.dRequestList});if(f.push(h),null!==this.dRequestExt)throw"requestExtensions not supported";var g=new a({array:f});return this.hTLV=g.getEncodedHex(),this.hTLV},void 0!==e&&void 0!==e.reqList&&this.setRequestListByParam(e.reqList)},YAHOO.lang.extend(KJUR.asn1.ocsp.TBSRequest,KJUR.asn1.ASN1Object),KJUR.asn1.ocsp.OCSPRequest=function(f){var b=KJUR.asn1,a=b.DERSequence,d=b.ocsp;if(d.OCSPRequest.superclass.constructor.call(this),this.dTbsRequest=null,this.dOptionalSignature=null,this.getEncodedHex=function(){var g=[];if(null===this.dTbsRequest)throw"tbsRequest not set";if(g.push(this.dTbsRequest),null!==this.dOptionalSignature)throw"optionalSignature not supported";var h=new a({array:g});return this.hTLV=h.getEncodedHex(),this.hTLV},void 0!==f&&void 0!==f.reqList){var e=new d.TBSRequest(f);this.dTbsRequest=e}},YAHOO.lang.extend(KJUR.asn1.ocsp.OCSPRequest,KJUR.asn1.ASN1Object),KJUR.asn1.ocsp.OCSPUtil={},KJUR.asn1.ocsp.OCSPUtil.getRequestHex=function(a,b,h){var e=KJUR.asn1.ocsp;void 0===h&&(h=e.DEFAULT_HASH);var g={alg:h,issuerCert:a,subjectCert:b};return new e.OCSPRequest({reqList:[g]}).getEncodedHex()},KJUR.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(b){var k=ASN1HEX,c=k.getVbyList,d=k.getIdxbyList,f=(c=k.getVbyList,k.getV),l={};try{var i=c(b,0,[0],"0a");l.responseStatus=parseInt(i,16)}catch(e){}if(0!==l.responseStatus)return l;try{var g=d(b,0,[1,0,1,0,0,2,0,1]);"80"===b.substr(g,2)?l.certStatus="good":"a1"===b.substr(g,2)?(l.certStatus="revoked",l.revocationTime=hextoutf8(c(b,g,[0]))):"82"===b.substr(g,2)&&(l.certStatus="unknown")}catch(e){}try{var a=d(b,0,[1,0,1,0,0,2,0,2]);l.thisUpdate=hextoutf8(f(b,a))}catch(e){}try{var j=d(b,0,[1,0,1,0,0,2,0,3]);"a0"===b.substr(j,2)&&(l.nextUpdate=hextoutf8(c(b,j,[0])))}catch(e){}return l},void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.lang&&KJUR.lang||(KJUR.lang={}),KJUR.lang.String=function(){},"function"==typeof Buffer?(utf8tob64u=function(a){return b64tob64u(new Buffer(a,"utf8").toString("base64"))},b64utoutf8=function(a){return new Buffer(b64utob64(a),"base64").toString("utf8")}):(utf8tob64u=function(a){return hextob64u(uricmptohex(encodeURIComponentAll(a)))},b64utoutf8=function(a){return decodeURIComponent(hextouricmp(b64utohex(a)))}),KJUR.lang.String.isInteger=function(a){return!!a.match(/^[0-9]+$/)||!!a.match(/^-[0-9]+$/)},KJUR.lang.String.isHex=function(a){return!(a.length%2!=0||!a.match(/^[0-9a-f]+$/)&&!a.match(/^[0-9A-F]+$/))},KJUR.lang.String.isBase64=function(a){return!(!(a=a.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||a.length%4!=0)},KJUR.lang.String.isBase64URL=function(a){return!a.match(/[+/=]/)&&(a=b64utob64(a),KJUR.lang.String.isBase64(a))},KJUR.lang.String.isIntegerArray=function(a){return!!(a=a.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)};void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.crypto&&KJUR.crypto||(KJUR.crypto={}),KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160},this.getDigestInfoHex=function(a,b){if(void 0===this.DIGESTINFOHEAD[b])throw"alg not supported in Util.DIGESTINFOHEAD: "+b;return this.DIGESTINFOHEAD[b]+a},this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a),d=j/4;if(c.length+22>d)throw"key is too short for SigAlg: keylen="+j+","+a;for(var b="0001",k="00"+c,g="",l=d-b.length-k.length,f=0;f<l;f+=2)g+="ff";return b+g+k},this.hashString=function(a,c){return new KJUR.crypto.MessageDigest({alg:c}).digestString(a)},this.hashHex=function(b,c){return new KJUR.crypto.MessageDigest({alg:c}).digestHex(b)},this.sha1=function(a){return new KJUR.crypto.MessageDigest({alg:"sha1",prov:"cryptojs"}).digestString(a)},this.sha256=function(a){return new KJUR.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"}).digestString(a)},this.sha256Hex=function(a){return new KJUR.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"}).digestHex(a)},this.sha512=function(a){return new KJUR.crypto.MessageDigest({alg:"sha512",prov:"cryptojs"}).digestString(a)},this.sha512Hex=function(a){return new KJUR.crypto.MessageDigest({alg:"sha512",prov:"cryptojs"}).digestHex(a)}},KJUR.crypto.Util.md5=function(a){return new KJUR.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(a)},KJUR.crypto.Util.ripemd160=function(a){return new KJUR.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(a)},KJUR.crypto.Util.SECURERANDOMGEN=new SecureRandom,KJUR.crypto.Util.getRandomHexOfNbytes=function(b){var a=new Array(b);return KJUR.crypto.Util.SECURERANDOMGEN.nextBytes(a),BAtohex(a)},KJUR.crypto.Util.getRandomBigIntegerOfNbytes=function(a){return new BigInteger(KJUR.crypto.Util.getRandomHexOfNbytes(a),16)},KJUR.crypto.Util.getRandomHexOfNbits=function(d){var c=d%8,b=new Array((d-c)/8+1);return KJUR.crypto.Util.SECURERANDOMGEN.nextBytes(b),b[0]=(255<<c&255^255)&b[0],BAtohex(b)},KJUR.crypto.Util.getRandomBigIntegerOfNbits=function(a){return new BigInteger(KJUR.crypto.Util.getRandomHexOfNbits(a),16)},KJUR.crypto.Util.getRandomBigIntegerZeroToMax=function(b){for(var a=b.bitLength();;){var c=KJUR.crypto.Util.getRandomBigIntegerOfNbits(a);if(-1!=b.compareTo(c))return c}},KJUR.crypto.Util.getRandomBigIntegerMinToMax=function(e,b){var c=e.compareTo(b);if(1==c)throw"biMin is greater than biMax";if(0==c)return e;var a=b.subtract(e);return KJUR.crypto.Util.getRandomBigIntegerZeroToMax(a).add(e)},KJUR.crypto.MessageDigest=function(c){this.setAlgAndProvider=function(g,f){if(null!==(g=KJUR.crypto.MessageDigest.getCanonicalAlgName(g))&&void 0===f&&(f=KJUR.crypto.Util.DEFAULTPROVIDER[g]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(g)&&"cryptojs"==f){try{this.md=KJUR.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[g].create()}catch(e){throw"setAlgAndProvider hash alg set fail alg="+g+"/"+e}this.updateString=function(h){this.md.update(h)},this.updateHex=function(h){var i=CryptoJS.enc.Hex.parse(h);this.md.update(i)},this.digest=function(){return this.md.finalize().toString(CryptoJS.enc.Hex)},this.digestString=function(h){return this.updateString(h),this.digest()},this.digestHex=function(h){return this.updateHex(h),this.digest()}}if(-1!=":sha256:".indexOf(g)&&"sjcl"==f){try{this.md=new sjcl.hash.sha256}catch(e){throw"setAlgAndProvider hash alg set fail alg="+g+"/"+e}this.updateString=function(h){this.md.update(h)},this.updateHex=function(i){var h=sjcl.codec.hex.toBits(i);this.md.update(h)},this.digest=function(){var h=this.md.finalize();return sjcl.codec.hex.fromBits(h)},this.digestString=function(h){return this.updateString(h),this.digest()},this.digestHex=function(h){return this.updateHex(h),this.digest()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(e){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==c&&void 0!==c.alg&&(this.algName=c.alg,void 0===c.prov&&(this.provName=KJUR.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},KJUR.crypto.MessageDigest.getCanonicalAlgName=function(a){return"string"==typeof a&&(a=(a=a.toLowerCase()).replace(/-/,"")),a},KJUR.crypto.MessageDigest.getHashLength=function(c){var b=KJUR.crypto.MessageDigest,a=b.getCanonicalAlgName(c);if(void 0===b.HASHLENGTH[a])throw"not supported algorithm: "+c;return b.HASHLENGTH[a]},KJUR.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},KJUR.crypto.Mac=function(d){this.setAlgAndProvider=function(k,i){if(null==(k=k.toLowerCase())&&(k="hmacsha1"),"hmac"!=(k=k.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+k;void 0===i&&(i=KJUR.crypto.Util.DEFAULTPROVIDER[k]),this.algProv=k+"/"+i;var g=k.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(g)&&"cryptojs"==i){try{var j=KJUR.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[g];this.mac=CryptoJS.algo.HMAC.create(j,this.pass)}catch(h){throw"setAlgAndProvider hash alg set fail hashAlg="+g+"/"+h}this.updateString=function(l){this.mac.update(l)},this.updateHex=function(l){var m=CryptoJS.enc.Hex.parse(l);this.mac.update(m)},this.doFinal=function(){return this.mac.finalize().toString(CryptoJS.enc.Hex)},this.doFinalString=function(l){return this.updateString(l),this.doFinal()},this.doFinalHex=function(l){return this.updateHex(l),this.doFinal()}}},this.updateString=function(g){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(g){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(g){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(g){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(h){if("string"==typeof h){var g=h;return h.length%2!=1&&h.match(/^[0-9A-Fa-f]+$/)||(g=rstrtohex(h)),void(this.pass=CryptoJS.enc.Hex.parse(g))}if("object"!=typeof h)throw"KJUR.crypto.Mac unsupported password type: "+h;g=null;if(void 0!==h.hex){if(h.hex.length%2!=0||!h.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+h.hex;g=h.hex}if(void 0!==h.utf8&&(g=utf8tohex(h.utf8)),void 0!==h.rstr&&(g=rstrtohex(h.rstr)),void 0!==h.b64&&(g=b64tohex(h.b64)),void 0!==h.b64u&&(g=b64utohex(h.b64u)),null==g)throw"KJUR.crypto.Mac unsupported password type: "+h;this.pass=CryptoJS.enc.Hex.parse(g)},void 0!==d&&(void 0!==d.pass&&this.setPassword(d.pass),void 0!==d.alg&&(this.algName=d.alg,void 0===d.prov&&(this.provName=KJUR.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},KJUR.crypto.Signature=function(o){var q=null;if(this._setAlgNames=function(){var s=this.algName.match(/^(.+)with(.+)$/);s&&(this.mdAlgName=s[1].toLowerCase(),this.pubkeyAlgName=s[2].toLowerCase())},this._zeroPaddingOfSignature=function(x,w){for(var v="",t=w/4-x.length,u=0;u<t;u++)v+="0";return v+x},this.setAlgAndProvider=function(u,t){if(this._setAlgNames(),"cryptojs/jsrsa"!=t)throw"provider not supported: "+t;if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new KJUR.crypto.MessageDigest({alg:this.mdAlgName})}catch(s){throw"setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+s}this.init=function(w,x){var y=null;try{y=void 0===x?KEYUTIL.getKey(w):KEYUTIL.getKey(w,x)}catch(v){throw"init failed:"+v}if(!0===y.isPrivate)this.prvKey=y,this.state="SIGN";else{if(!0!==y.isPublic)throw"init failed.:"+y;this.pubKey=y,this.state="VERIFY"}},this.updateString=function(v){this.md.updateString(v)},this.updateHex=function(v){this.md.updateHex(v)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0!==this.ecprvhex&&void 0!==this.eccurvename){var v=new KJUR.crypto.ECDSA({curve:this.eccurvename});this.hSign=v.signHex(this.sHashHex,this.ecprvhex)}else if(this.prvKey instanceof RSAKey&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof RSAKey&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof KJUR.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof KJUR.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(v){return this.updateString(v),this.sign()},this.signHex=function(v){return this.updateHex(v),this.sign()},this.verify=function(v){if(this.sHashHex=this.md.digest(),void 0!==this.ecpubhex&&void 0!==this.eccurvename)return new KJUR.crypto.ECDSA({curve:this.eccurvename}).verifyHex(this.sHashHex,v,this.ecpubhex);if(this.pubKey instanceof RSAKey&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,v,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof RSAKey&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,v);if(void 0!==KJUR.crypto.ECDSA&&this.pubKey instanceof KJUR.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,v);if(void 0!==KJUR.crypto.DSA&&this.pubKey instanceof KJUR.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,v);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(s,t){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(s){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(s){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(s){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(s){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(s){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=o,void 0!==o&&(void 0!==o.alg&&(this.algName=o.alg,void 0===o.prov?this.provName=KJUR.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=o.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==o.psssaltlen&&(this.pssSaltLen=o.psssaltlen),void 0!==o.prvkeypem)){if(void 0!==o.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{q=KEYUTIL.getKey(o.prvkeypem);this.init(q)}catch(m){throw"fatal error to load pem private key: "+m}}},KJUR.crypto.Cipher=function(a){},KJUR.crypto.Cipher.encrypt=function(e,f,d){if(f instanceof RSAKey&&f.isPublic){var c=KJUR.crypto.Cipher.getAlgByKeyAndName(f,d);if("RSA"===c)return f.encrypt(e);if("RSAOAEP"===c)return f.encryptOAEP(e,"sha1");var b=c.match(/^RSAOAEP(\d+)$/);if(null!==b)return f.encryptOAEP(e,"sha"+b[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+d}throw"Cipher.encrypt: unsupported key or algorithm"},KJUR.crypto.Cipher.decrypt=function(e,f,d){if(f instanceof RSAKey&&f.isPrivate){var c=KJUR.crypto.Cipher.getAlgByKeyAndName(f,d);if("RSA"===c)return f.decrypt(e);if("RSAOAEP"===c)return f.decryptOAEP(e,"sha1");var b=c.match(/^RSAOAEP(\d+)$/);if(null!==b)return f.decryptOAEP(e,"sha"+b[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+d}throw"Cipher.decrypt: unsupported key or algorithm"},KJUR.crypto.Cipher.getAlgByKeyAndName=function(b,a){if(b instanceof RSAKey){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(a))return a;if(null==a)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+a}throw"getAlgByKeyAndName: not supported algorithm name: "+a},KJUR.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040023":"secp521r1","2b81040022":"secp384r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.crypto&&KJUR.crypto||(KJUR.crypto={}),KJUR.crypto.ECDSA=function(h){var a=new SecureRandom;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)},this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=i},this.setPrivateKeyHex=function(i){this.isPrivate=!0,this.prvKeyHex=i},this.setPublicKeyHex=function(i){this.isPublic=!0,this.pubKeyHex=i},this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if("04"!==k.substr(0,2))throw"this method supports uncompressed format(04) only";var j=this.ecparams.keylen/4;if(k.length!==2+2*j)throw"malformed public key hex length";var i={};return i.x=k.substr(2,j),i.y=k.substr(2+j),i},this.getShortNISTPCurveName=function(){var i=this.curveName;return"secp256r1"===i||"NIST P-256"===i||"P-256"===i||"prime256v1"===i?"P-256":"secp384r1"===i||"NIST P-384"===i||"P-384"===i?"P-384":null},this.generateKeyPairHex=function(){var k=this.ecparams.n,n=this.getBigRandom(k),l=this.ecparams.G.multiply(n),q=l.getX().toBigInteger(),o=l.getY().toBigInteger(),i=this.ecparams.keylen/4,m=("0000000000"+n.toString(16)).slice(-i),j="04"+("0000000000"+q.toString(16)).slice(-i)+("0000000000"+o.toString(16)).slice(-i);return this.setPrivateKeyHex(m),this.setPublicKeyHex(j),{ecprvhex:m,ecpubhex:j}},this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)},this.signHex=function(o,j){var t=new BigInteger(j,16),l=this.ecparams.n,q=new BigInteger(o,16);do{var m=this.getBigRandom(l),i=this.ecparams.G.multiply(m).getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)},this.sign=function(m,u){var q=u,j=this.ecparams.n,p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j),i=this.ecparams.G.multiply(l).getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)},this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)},this.verifyHex=function(m,i,p){var l,j,k,o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r,j=o.s,k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)},this.verify=function(o,p,j){var l,i,k;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r,i=n.s}else{if("object"!=typeof p||!p.r||!p.s)throw"Invalid value for signature";l=p.r,i=p.s}if(j instanceof ECPointFp)k=j;else{if(!Bitcoin.Util.isArray(j))throw"Invalid format for pubkey value, must be byte array or ECPointFp";k=ECPointFp.decodeFrom(this.ecparams.curve,j)}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)},this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n,u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0)return!1;if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0)return!1;var p=w.modInverse(l),k=o.multiply(p).mod(l),j=i.multiply(p).mod(l);return u.multiply(k).add(m.multiply(j)).getX().toBigInteger().mod(l).equals(i)},this.serializeSig=function(k,j){var l=k.toByteArraySigned(),i=j.toByteArraySigned(),m=[];return m.push(2),m.push(l.length),(m=m.concat(l)).push(2),m.push(i.length),(m=m.concat(i)).unshift(m.length),m.unshift(48),m},this.parseSig=function(n){var m;if(48!=n[0])throw new Error("Signature not a valid DERSequence");if(2!=n[m=2])throw new Error("First element in signature must be a DERInteger");var l=n.slice(m+2,m+2+n[m+1]);if(2!=n[m+=2+n[m+1]])throw new Error("Second element in signature must be a DERInteger");var i=n.slice(m+2,m+2+n[m+1]);return m+=2+n[m+1],{r:BigInteger.fromByteArrayUnsigned(l),s:BigInteger.fromByteArrayUnsigned(i)}},this.parseSigCompact=function(m){if(65!==m.length)throw"Signature has the wrong length";var j=m[0]-27;if(j<0||j>7)throw"Invalid signature type";var o=this.ecparams.n;return{r:BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o),s:BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o),i:j}},this.readPKCS5PrvKeyHex=function(l){var i,k,o,n=ASN1HEX,m=KJUR.crypto.ECDSA.getName,p=n.getVbyList;if(!1===n.isASN1HEX(l))throw"not ASN.1 hex string";try{i=p(l,0,[2,0],"06"),k=p(l,0,[1],"04");try{o=p(l,0,[3,0],"03").substr(2)}catch(j){}}catch(j){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=m(i),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(o),this.setPrivateKeyHex(k),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(l){var p,m,k,q=ASN1HEX,i=KJUR.crypto.ECDSA.getName,n=q.getVbyList;if(!1===q.isASN1HEX(l))throw"not ASN.1 hex string";try{n(l,0,[1,0],"06"),p=n(l,0,[1,1],"06"),m=n(l,0,[2,0,1],"04");try{k=n(l,0,[2,0,2,0],"03").substr(2)}catch(o){}}catch(o){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=i(p),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(k),this.setPrivateKeyHex(m),this.isPublic=!1},this.readPKCS8PubKeyHex=function(l){var i,o,n=ASN1HEX,m=KJUR.crypto.ECDSA.getName,p=n.getVbyList;if(!1===n.isASN1HEX(l))throw"not ASN.1 hex string";try{p(l,0,[0,0],"06"),i=p(l,0,[0,1],"06"),o=p(l,0,[1],"03").substr(2)}catch(j){throw"malformed PKCS#8 ECC public key"}if(this.curveName=m(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(o)},this.readCertPubKeyHex=function(k,p){5!==p&&(p=6);var i,n,m=ASN1HEX,l=KJUR.crypto.ECDSA.getName,o=m.getVbyList;if(!1===m.isASN1HEX(k))throw"not ASN.1 hex string";try{i=o(k,0,[0,p,0,1],"06"),n=o(k,0,[0,p,1],"03").substr(2)}catch(j){throw"malformed X.509 certificate ECC public key"}if(this.curveName=l(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==h&&void 0!==h.curve&&(this.curveName=h.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==h&&(void 0!==h.prv&&this.setPrivateKeyHex(h.prv),void 0!==h.pub&&this.setPublicKeyHex(h.pub))},KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);return{r:new BigInteger(b.r,16),s:new BigInteger(b.s,16)}},KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX,i=j.getChildIdx,g=j.getV;if("30"!=f.substr(0,2))throw"signature is not a ASN.1 sequence";var h=i(f,0);if(2!=h.length)throw"number of signature ASN.1 sequence elements seem wrong";var e=h[0],d=h[1];if("02"!=f.substr(e,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=f.substr(d,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:g(f,e),s:g(f,d)}},KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c),b=d.r,a=d.s;if("00"==b.substr(0,2)&&b.length%32==2&&(b=b.substr(2)),"00"==a.substr(0,2)&&a.length%32==2&&(a=a.substr(2)),b.length%32==30&&(b="00"+b),a.length%32==30&&(a="00"+a),b.length%32!=0)throw"unknown ECDSA sig r length error";if(a.length%32!=0)throw"unknown ECDSA sig s length error";return b+a},KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if(a.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var c=a.substr(0,a.length/2),b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)},KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16),c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)},KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1,b=new c.DERInteger({bigint:f}),a=new c.DERInteger({bigint:d});return new c.DERSequence({array:[b,a]}).getEncodedHex()},KJUR.crypto.ECDSA.getName=function(a){return"2a8648ce3d030107"===a?"secp256r1":"2b8104000a"===a?"secp256k1":"2b81040022"===a?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(a)?"secp256r1":-1!=="|secp256k1|".indexOf(a)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(a)?"secp384r1":null},void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.crypto&&KJUR.crypto||(KJUR.crypto={}),KJUR.crypto.ECParameterDB=new function(){var b={},c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(void 0!==c[d]&&(d=c[e]),void 0!==b[d])return b[d];throw"unregistered EC curve name: "+d},this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o),z=a(g),y=a(m),t=a(e),w=a(j),r=new ECCurveFp(s,z,y),q=r.decodePointHex("04"+f+k);b[A].name=A,b[A].keylen=l,b[A].curve=r,b[A].G=q,b[A].n=t,b[A].h=w,b[A].oid=d,b[A].info=x;for(var v=0;v<u.length;v++)c[u[v]]=A}},KJUR.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),KJUR.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),KJUR.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),KJUR.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),KJUR.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),KJUR.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),KJUR.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),KJUR.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),KJUR.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),KJUR.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.crypto&&KJUR.crypto||(KJUR.crypto={}),KJUR.crypto.DSA=function(){this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(d,c,b,e,a){this.isPrivate=!0,this.p=d,this.q=c,this.g=b,this.y=e,this.x=a},this.setPrivateHex=function(d,b,f,i,j){var c,a,e,g,h;c=new BigInteger(d,16),a=new BigInteger(b,16),e=new BigInteger(f,16),g="string"==typeof i&&i.length>1?new BigInteger(i,16):null,h=new BigInteger(j,16),this.setPrivate(c,a,e,g,h)},this.setPublic=function(c,b,a,d){this.isPublic=!0,this.p=c,this.q=b,this.g=a,this.y=d,this.x=null},this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16),a=new BigInteger(e,16),h=new BigInteger(d,16),c=new BigInteger(g,16),this.setPublic(b,a,h,c)},this.signWithMessageHash=function(d){var c=this.p,b=this.q,f=this.g,j=(this.y,this.x),e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE)),h=new BigInteger(d.substr(0,b.bitLength()/4),16),a=f.modPow(e,c).mod(b),n=e.modInverse(b).multiply(h.add(j.multiply(a))).mod(b);return KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:n}}]})},this.verifyWithMessageHash=function(h,f){var d=this.p,b=this.q,j=this.g,l=this.y,i=this.parseASN1Signature(f),a=i[0],t=i[1],k=new BigInteger(h.substr(0,b.bitLength()/4),16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0)throw"invalid DSA signature";if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0)throw"invalid DSA signature";var m=t.modInverse(b),e=k.multiply(m).mod(b),c=a.multiply(m).mod(b);return 0==j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b).compareTo(a)},this.parseASN1Signature=function(a){try{return[new BigInteger(ASN1HEX.getVbyList(a,0,[0],"02"),16),new BigInteger(ASN1HEX.getVbyList(a,0,[1],"02"),16)]}catch(b){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i,j=ASN1HEX,d=j.getVbyList;if(!1===j.isASN1HEX(c))throw"not ASN.1 hex string";try{b=d(c,0,[1],"02"),a=d(c,0,[2],"02"),f=d(c,0,[3],"02"),g=d(c,0,[4],"02"),i=d(c,0,[5],"02")}catch(e){throw console.log("EXCEPTION:"+e),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(b,a,f,g,i)},this.readPKCS8PrvKeyHex=function(d){var f,c,b,g,e=ASN1HEX,i=e.getVbyList;if(!1===e.isASN1HEX(d))throw"not ASN.1 hex string";try{f=i(d,0,[1,1,0],"02"),c=i(d,0,[1,1,1],"02"),b=i(d,0,[1,1,2],"02"),g=i(d,0,[2,0],"02")}catch(a){throw console.log("EXCEPTION:"+a),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(f,c,b,null,g)},this.readPKCS8PubKeyHex=function(d){var f,c,b,g,e=ASN1HEX,i=e.getVbyList;if(!1===e.isASN1HEX(d))throw"not ASN.1 hex string";try{f=i(d,0,[0,1,0],"02"),c=i(d,0,[0,1,1],"02"),b=i(d,0,[0,1,2],"02"),g=i(d,0,[1,0],"02")}catch(a){throw console.log("EXCEPTION:"+a),"malformed PKCS#8 DSA public key"}this.setPublicHex(f,c,b,g)},this.readCertPubKeyHex=function(c,f){var b,a,g,i;5!==f&&(f=6);var j=ASN1HEX,d=j.getVbyList;if(!1===j.isASN1HEX(c))throw"not ASN.1 hex string";try{b=d(c,0,[0,f,0,1,0],"02"),a=d(c,0,[0,f,0,1,1],"02"),g=d(c,0,[0,f,0,1,2],"02"),i=d(c,0,[0,f,1,0],"02")}catch(e){throw console.log("EXCEPTION:"+e),"malformed X.509 certificate DSA public key"}this.setPublicHex(b,a,g,i)}};var KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)},k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x),w=CryptoJS.enc.Hex.parse(u),p=CryptoJS.enc.Hex.parse(q),t={};t.key=w,t.iv=p,t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)},l=function(p,r,q){return g(CryptoJS.AES,p,r,q)},g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y),x=CryptoJS.enc.Hex.parse(v),p=CryptoJS.enc.Hex.parse(q),w=t.encrypt(s,x,{iv:p}),r=CryptoJS.enc.Hex.parse(w.toString());return CryptoJS.enc.Base64.stringify(r)},i={"AES-256-CBC":{proc:d,eproc:l,keylen:32,ivlen:16},"AES-192-CBC":{proc:d,eproc:l,keylen:24,ivlen:16},"AES-128-CBC":{proc:d,eproc:l,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)},eproc:function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)},keylen:24,ivlen:8},"DES-CBC":{proc:function(p,r,q){return k(CryptoJS.DES,p,r,q)},eproc:function(p,r,q){return g(CryptoJS.DES,p,r,q)},keylen:8,ivlen:8}},n=function(v){var w={},q=v.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));q&&(w.cipher=q[1],w.ivsalt=q[2]);var p=v.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));p&&(w.type=p[1]);var u=-1,x=0;-1!=v.indexOf("\r\n\r\n")&&(u=v.indexOf("\r\n\r\n"),x=2),-1!=v.indexOf("\n\n")&&(u=v.indexOf("\n\n"),x=1);var t=v.indexOf("-----END");if(-1!=u&&-1!=t){var r=v.substring(u+2*x,t-x);r=r.replace(/\s+/g,""),w.data=r}return w},j=function(q,y,p){for(var v=p.substring(0,16),t=CryptoJS.enc.Hex.parse(v),r=CryptoJS.enc.Utf8.parse(y),u=i[q].keylen+i[q].ivlen,x="",w=null;;){var s=CryptoJS.algo.MD5.create();if(null!=w&&s.update(w),s.update(r),s.update(t),w=s.finalize(),(x+=CryptoJS.enc.Hex.stringify(w)).length>=2*u)break}var z={};return z.keyhex=x.substr(0,2*i[q].keylen),z.ivhex=x.substr(2*i[q].keylen,2*i[q].ivlen),z},b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p),q=CryptoJS.enc.Hex.stringify(s);return(0,i[v].proc)(q,r,w)};return{version:"1.0.0",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y),r=(q.type,q.cipher),p=q.ivsalt,s=q.data,v=j(r,x,p).keyhex;return b(s,r,v,p)},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p="";if(void 0!==t&&null!=t||(t="AES-256-CBC"),void 0===i[t])throw"KEYUTIL unsupported algorithm: "+t;void 0!==r&&null!=r||(r=function(p){var r=CryptoJS.lib.WordArray.random(p);return CryptoJS.enc.Hex.stringify(r)}(i[t].ivlen).toUpperCase());var w=function(p,s,q,u){return(0,i[s].eproc)(p,q,u)}(s,t,j(t,A,r).keyhex,r);p="-----BEGIN "+x+" PRIVATE KEY-----\r\n";return p+="Proc-Type: 4,ENCRYPTED\r\n",p+="DEK-Info: "+t+","+r+"\r\n",p+="\r\n",p+=w.replace(/(.{64})/g,"$1\r\n"),p+="\r\n-----END "+x+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX,z=B.getChildIdx,w=B.getV,t={},r=z(y,0);if(2!=r.length)throw"malformed format: SEQUENCE(0).items != 2: "+r.length;t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(2!=A.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+A.length;if("2a864886f70d01050d"!=w(y,A[0]))throw"this only supports pkcs5PBES2";var p=z(y,A[1]);if(2!=A.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+p.length;var q=z(y,p[1]);if(2!=q.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+q.length;if("2a864886f70d0307"!=w(y,q[0]))throw"this only supports TripleDES";t.encryptionSchemeAlg="TripleDES",t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(2!=s.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+s.length;if("2a864886f70d01050c"!=w(y,s[0]))throw"this only supports pkcs5PBKDF2";var x=z(y,s[1]);if(x.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+x.length;t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw"malformed format pbkdf2Iter: "+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt),q=u.pbkdf2Iter,s=CryptoJS.PBKDF2(p,t,{keySize:6,iterations:q});return CryptoJS.enc.Hex.stringify(s)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,"ENCRYPTED PRIVATE KEY"),p=this.parseHexOfEncryptedPKCS8(r),u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y),v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u),s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV),w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});return CryptoJS.enc.Hex.stringify(w)},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);return this.getKeyFromPlainPrivatePKCS8Hex(p)},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX,u=v.getChildIdx,t=v.getV,q={algparam:null};if("30"!=s.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var r=u(s,0);if(3!=r.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=s.substr(r[1],2))throw"malformed PKCS8 private key(code:003)";var p=u(s,r[1]);if(2!=p.length)throw"malformed PKCS8 private key(code:004)";if("06"!=s.substr(p[0],2))throw"malformed PKCS8 private key(code:005)";if(q.algoid=t(s,p[0]),"06"==s.substr(p[1],2)&&(q.algparam=t(s,p[1])),"04"!=s.substr(r[2],2))throw"malformed PKCS8 private key(code:006)";return q.keyidx=v.getVidx(s,r[2]),q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(p)},getKeyFromPlainPrivatePKCS8Hex:function(p){var r,q=this.parsePlainPrivatePKCS8Hex(p);if("2a864886f70d010101"==q.algoid)r=new RSAKey;else if("2a8648ce380401"==q.algoid)r=new KJUR.crypto.DSA;else{if("2a8648ce3d0201"!=q.algoid)throw"unsupported private key algorithm";r=new KJUR.crypto.ECDSA}return r.readPKCS8PrvKeyHex(p),r},_getKeyFromPublicPKCS8Hex:function(q){var p,r=ASN1HEX.getVbyList(q,0,[0,0],"06");if("2a864886f70d010101"===r)p=new RSAKey;else if("2a8648ce380401"===r)p=new KJUR.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw"unsupported PKCS#8 public key hex";p=new KJUR.crypto.ECDSA}return p.readPKCS8PubKeyHex(q),p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX,t=u.getChildIdx,s=u.getV,p={};if("30"!=r.substr(0,2))throw"malformed RSA key(code:001)";var q=t(r,0);if(2!=q.length)throw"malformed RSA key(code:002)";if("02"!=r.substr(q[0],2))throw"malformed RSA key(code:003)";if(p.n=s(r,q[0]),"02"!=r.substr(q[1],2))throw"malformed RSA key(code:004)";return p.e=s(r,q[1]),p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX,u=v.getChildIdx,s=v.getV,q={algparam:null},r=u(t,0);if(2!=r.length)throw"outer DERSequence shall have 2 elements: "+r.length;var w=r[0];if("30"!=t.substr(w,2))throw"malformed PKCS8 public key(code:001)";var p=u(t,w);if(2!=p.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(p[0],2))throw"malformed PKCS8 public key(code:003)";if(q.algoid=s(t,p[0]),"06"==t.substr(p[1],2)?q.algparam=s(t,p[1]):"30"==t.substr(p[1],2)&&(q.algparam={},q.algparam.p=v.getVbyList(t,p[1],[0],"02"),q.algparam.q=v.getVbyList(t,p[1],[1],"02"),q.algparam.g=v.getVbyList(t,p[1],[2],"02")),"03"!=t.substr(r[1],2))throw"malformed PKCS8 public key(code:004)";return q.key=s(t,r[1]).substr(2),q}}}();KEYUTIL.getKey=function(l,k,n){var L=(G=ASN1HEX).getChildIdx,d=(G.getV,G.getVbyList),c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(void 0!==w&&l instanceof w)return l;if(void 0!==i&&l instanceof i)return l;if(void 0!==C&&l instanceof C)return l;if(void 0!==l.curve&&void 0!==l.xy&&void 0===l.d)return new i({pub:l.xy,curve:l.curve});if(void 0!==l.curve&&void 0!==l.d)return new i({prv:l.d,curve:l.curve});if(void 0===l.kty&&void 0!==l.n&&void 0!==l.e&&void 0===l.d)return(P=new w).setPublic(l.n,l.e),P;if(void 0===l.kty&&void 0!==l.n&&void 0!==l.e&&void 0!==l.d&&void 0!==l.p&&void 0!==l.q&&void 0!==l.dp&&void 0!==l.dq&&void 0!==l.co&&void 0===l.qi)return(P=new w).setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co),P;if(void 0===l.kty&&void 0!==l.n&&void 0!==l.e&&void 0!==l.d&&void 0===l.p)return(P=new w).setPrivate(l.n,l.e,l.d),P;if(void 0!==l.p&&void 0!==l.q&&void 0!==l.g&&void 0!==l.y&&void 0===l.x)return(P=new C).setPublic(l.p,l.q,l.g,l.y),P;if(void 0!==l.p&&void 0!==l.q&&void 0!==l.g&&void 0!==l.y&&void 0!==l.x)return(P=new C).setPrivate(l.p,l.q,l.g,l.y,l.x),P;if("RSA"===l.kty&&void 0!==l.n&&void 0!==l.e&&void 0===l.d)return(P=new w).setPublic(b64utohex(l.n),b64utohex(l.e)),P;if("RSA"===l.kty&&void 0!==l.n&&void 0!==l.e&&void 0!==l.d&&void 0!==l.p&&void 0!==l.q&&void 0!==l.dp&&void 0!==l.dq&&void 0!==l.qi)return(P=new w).setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi)),P;if("RSA"===l.kty&&void 0!==l.n&&void 0!==l.e&&void 0!==l.d)return(P=new w).setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d)),P;if("EC"===l.kty&&void 0!==l.crv&&void 0!==l.x&&void 0!==l.y&&void 0===l.d){var t=(j=new i({curve:l.crv})).ecparams.keylen/4,u="04"+("0000000000"+b64utohex(l.x)).slice(-t)+("0000000000"+b64utohex(l.y)).slice(-t);return j.setPublicKeyHex(u),j}if("EC"===l.kty&&void 0!==l.crv&&void 0!==l.x&&void 0!==l.y&&void 0!==l.d){t=(j=new i({curve:l.crv})).ecparams.keylen/4,u="04"+("0000000000"+b64utohex(l.x)).slice(-t)+("0000000000"+b64utohex(l.y)).slice(-t);var b=("0000000000"+b64utohex(l.d)).slice(-t);return j.setPublicKeyHex(u),j.setPrivateKeyHex(b),j}if("pkcs5prv"===n){var N,J=l,G=ASN1HEX;if(9===(N=L(J,0)).length)(P=new w).readPKCS5PrvKeyHex(J);else if(6===N.length)(P=new C).readPKCS5PrvKeyHex(J);else{if(!(N.length>2&&"04"===J.substr(N[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(P=new i).readPKCS5PrvKeyHex(J)}return P}if("pkcs8prv"===n)return P=F.getKeyFromPlainPrivatePKCS8Hex(l);if("pkcs8pub"===n)return F._getKeyFromPublicPKCS8Hex(l);if("x509pub"===n)return X509.getPublicKeyFromCertHex(l);if(-1!=l.indexOf("-END CERTIFICATE-",0)||-1!=l.indexOf("-END X509 CERTIFICATE-",0)||-1!=l.indexOf("-END TRUSTED CERTIFICATE-",0))return X509.getPublicKeyFromCertPEM(l);if(-1!=l.indexOf("-END PUBLIC KEY-")){var O=pemtohex(l,"PUBLIC KEY");return F._getKeyFromPublicPKCS8Hex(O)}if(-1!=l.indexOf("-END RSA PRIVATE KEY-")&&-1==l.indexOf("4,ENCRYPTED")){var m=M(l,"RSA PRIVATE KEY");return F.getKey(m,null,"pkcs5prv")}if(-1!=l.indexOf("-END DSA PRIVATE KEY-")&&-1==l.indexOf("4,ENCRYPTED")){var E=d(I=M(l,"DSA PRIVATE KEY"),0,[1],"02"),D=d(I,0,[2],"02"),K=d(I,0,[3],"02"),r=d(I,0,[4],"02"),s=d(I,0,[5],"02");return(P=new C).setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16)),P}if(-1!=l.indexOf("-END PRIVATE KEY-"))return F.getKeyFromPlainPrivatePKCS8PEM(l);if(-1!=l.indexOf("-END RSA PRIVATE KEY-")&&-1!=l.indexOf("4,ENCRYPTED")){var o=F.getDecryptedKeyHex(l,k),H=new RSAKey;return H.readPKCS5PrvKeyHex(o),H}if(-1!=l.indexOf("-END EC PRIVATE KEY-")&&-1!=l.indexOf("4,ENCRYPTED")){var j,P=d(I=F.getDecryptedKeyHex(l,k),0,[1],"04"),f=d(I,0,[2,0],"06"),A=d(I,0,[3,0],"03").substr(2);if(void 0===KJUR.crypto.OID.oidhex2name[f])throw"undefined OID(hex) in KJUR.crypto.OID: "+f;return(j=new i({curve:KJUR.crypto.OID.oidhex2name[f]})).setPublicKeyHex(A),j.setPrivateKeyHex(P),j.isPublic=!1,j}if(-1!=l.indexOf("-END DSA PRIVATE KEY-")&&-1!=l.indexOf("4,ENCRYPTED")){var I;E=d(I=F.getDecryptedKeyHex(l,k),0,[1],"02"),D=d(I,0,[2],"02"),K=d(I,0,[3],"02"),r=d(I,0,[4],"02"),s=d(I,0,[5],"02");return(P=new C).setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16)),P}if(-1!=l.indexOf("-END ENCRYPTED PRIVATE KEY-"))return F.getKeyFromEncryptedPKCS8PEM(l,k);throw"not supported argument"},KEYUTIL.generateKeypair=function(a,c){if("RSA"==a){var b=c;(h=new RSAKey).generate(b,"10001"),h.isPrivate=!0,h.isPublic=!0;var f=new RSAKey,e=h.n.toString(16),i=h.e.toString(16);return f.setPublic(e,i),f.isPrivate=!1,f.isPublic=!0,(k={}).prvKeyObj=h,k.pubKeyObj=f,k}if("EC"==a){var h,k,d=c,j=new KJUR.crypto.ECDSA({curve:d}).generateKeyPairHex();return(h=new KJUR.crypto.ECDSA({curve:d})).setPublicKeyHex(j.ecpubhex),h.setPrivateKeyHex(j.ecprvhex),h.isPrivate=!0,h.isPublic=!1,(f=new KJUR.crypto.ECDSA({curve:d})).setPublicKeyHex(j.ecpubhex),f.isPrivate=!1,f.isPublic=!0,(k={}).prvKeyObj=h,k.pubKeyObj=f,k}throw"unknown algorithm: "+a},KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,C=k.x509.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){return l({seq:[{int:0},{int:{bigint:s.n}},{int:s.e},{int:{bigint:s.d}},{int:{bigint:s.p}},{int:{bigint:s.q}},{int:{bigint:s.dmp1}},{int:{bigint:s.dmq1}},{int:{bigint:s.coeff}}]})}function B(G){return l({seq:[{int:1},{octstr:{hex:G.prvKeyHex}},{tag:["a0",!0,{oid:{name:G.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+G.pubKeyHex}}]}]})}function x(s){return l({seq:[{int:0},{int:{bigint:s.p}},{int:{bigint:s.q}},{int:{bigint:s.g}},{int:{bigint:s.y}},{int:{bigint:s.x}}]})}if((void 0!==n&&b instanceof n||void 0!==u&&b instanceof u||void 0!==r&&b instanceof r)&&1==b.isPublic&&(void 0===D||"PKCS8PUB"==D))return hextopem(w=new C(b).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==D&&void 0!==n&&b instanceof n&&(void 0===y||null==y)&&1==b.isPrivate)return hextopem(w=A(b).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==D&&void 0!==r&&b instanceof r&&(void 0===y||null==y)&&1==b.isPrivate){var v=new z({name:b.curveName}).getEncodedHex(),t=B(b).getEncodedHex(),p="";return p+=hextopem(v,"EC PARAMETERS"),p+=hextopem(t,"EC PRIVATE KEY")}if("PKCS1PRV"==D&&void 0!==u&&b instanceof u&&(void 0===y||null==y)&&1==b.isPrivate)return hextopem(w=x(b).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==D&&void 0!==n&&b instanceof n&&void 0!==y&&null!=y&&1==b.isPrivate){var w=A(b).getEncodedHex();return void 0===m&&(m="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",w,y,m,j)}if("PKCS5PRV"==D&&void 0!==r&&b instanceof r&&void 0!==y&&null!=y&&1==b.isPrivate){w=B(b).getEncodedHex();return void 0===m&&(m="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",w,y,m,j)}if("PKCS5PRV"==D&&void 0!==u&&b instanceof u&&void 0!==y&&null!=y&&1==b.isPrivate){w=x(b).getEncodedHex();return void 0===m&&(m="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",w,y,m,j)}var o=function(G,s){var I=c(G,s);return new l({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{int:I.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]}).getEncodedHex()},c=function(N,O){var M=CryptoJS.lib.WordArray.random(8),s=CryptoJS.lib.WordArray.random(8),I=CryptoJS.PBKDF2(O,M,{keySize:6,iterations:100}),J=CryptoJS.enc.Hex.parse(N),K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+"",G={};return G.ciphertext=K,G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M),G.pbkdf2Iter=100,G.encryptionSchemeAlg="DES-EDE3-CBC",G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s),G};if("PKCS8PRV"==D&&null!=n&&b instanceof n&&1==b.isPrivate){var d=A(b).getEncodedHex();w=l({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:d}}]}).getEncodedHex();return void 0===y||null==y?hextopem(w,"PRIVATE KEY"):hextopem(t=o(w,y),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==D&&void 0!==r&&b instanceof r&&1==b.isPrivate){d=new l({seq:[{int:1},{octstr:{hex:b.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+b.pubKeyHex}}]}]}).getEncodedHex(),w=l({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]}).getEncodedHex();return void 0===y||null==y?hextopem(w,"PRIVATE KEY"):hextopem(t=o(w,y),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==D&&void 0!==u&&b instanceof u&&1==b.isPrivate){d=new f({bigint:b.x}).getEncodedHex(),w=l({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:b.p}},{int:{bigint:b.q}},{int:{bigint:b.g}}]}]},{octstr:{hex:d}}]}).getEncodedHex();return void 0===y||null==y?hextopem(w,"PRIVATE KEY"):hextopem(t=o(w,y),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,"CERTIFICATE REQUEST");return KEYUTIL.getKeyFromCSRHex(a)},KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);return KEYUTIL.getKey(c.p8pubkeyhex,null,"pkcs8pub")},KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX,f=i.getChildIdx,c=i.getTLV,b={},g=d;if("30"!=g.substr(0,2))throw"malformed CSR(code:001)";var e=f(g,0);if(e.length<1)throw"malformed CSR(code:002)";if("30"!=g.substr(e[0],2))throw"malformed CSR(code:003)";var a=f(g,e[0]);if(a.length<3)throw"malformed CSR(code:004)";return b.p8pubkeyhex=c(g,a[2]),b},KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate)return b.kty="RSA",b.n=hextob64u(d.n.toString(16)),b.e=hextob64u(d.e.toString(16)),b.d=hextob64u(d.d.toString(16)),b.p=hextob64u(d.p.toString(16)),b.q=hextob64u(d.q.toString(16)),b.dp=hextob64u(d.dmp1.toString(16)),b.dq=hextob64u(d.dmq1.toString(16)),b.qi=hextob64u(d.coeff.toString(16)),b;if(d instanceof RSAKey&&d.isPublic)return b.kty="RSA",b.n=hextob64u(d.n.toString(16)),b.e=hextob64u(d.e.toString(16)),b;if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){if("P-256"!==(a=d.getShortNISTPCurveName())&&"P-384"!==a)throw"unsupported curve name for JWT: "+a;var c=d.getPublicKeyXYHex();return b.kty="EC",b.crv=a,b.x=hextob64u(c.x),b.y=hextob64u(c.y),b.d=hextob64u(d.prvKeyHex),b}if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a;if("P-256"!==(a=d.getShortNISTPCurveName())&&"P-384"!==a)throw"unsupported curve name for JWT: "+a;c=d.getPublicKeyXYHex();return b.kty="EC",b.crv=a,b.x=hextob64u(c.x),b.y=hextob64u(c.y),b}throw"not supported key object"},RSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)},RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var k,i=ASN1HEX.getV,e=i(f,(k=RSAKey.getPosArrayOfChildrenFromHex(f))[0]),j=i(f,k[1]),b=i(f,k[2]),c=i(f,k[3]),h=i(f,k[4]),g=i(f,k[5]),m=i(f,k[6]),l=i(f,k[7]),d=i(f,k[8]);return(k=new Array).push(e,j,b,c,h,g,m,l,d),k},RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d),b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])},RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])},RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k,m=ASN1HEX,g=m.getVbyList;if(!1===m.isASN1HEX(e))throw"not ASN.1 hex string";try{c=g(e,0,[2,0,1],"02"),j=g(e,0,[2,0,2],"02"),l=g(e,0,[2,0,3],"02"),b=g(e,0,[2,0,4],"02"),a=g(e,0,[2,0,5],"02"),f=g(e,0,[2,0,6],"02"),d=g(e,0,[2,0,7],"02"),k=g(e,0,[2,0,8],"02")}catch(i){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(c,j,l,b,a,f,d,k)},RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX,b=e.getV;if(!1===e.isASN1HEX(c))throw"keyHex is not ASN.1 hex string";var a=e.getChildIdx(c,0);if(2!==a.length||"02"!==c.substr(a[0],2)||"02"!==c.substr(a[1],2))throw"wrong hex for PKCS#5 public key";var f=b(c,a[0]),d=b(c,a[1]);this.setPublic(f,d)},RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(!1===c.isASN1HEX(b))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==c.getTLVbyList(b,0,[0,0]))throw"not PKCS8 RSA public key";var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)},RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;(a=new X509).readCertHex(b),c=a.getPublicKeyHex(),this.readPKCS8PubKeyHex(c)};var _RE_HEXDECONLY=new RegExp("");function _zeroPaddingOfSignature(e,d){for(var c="",a=d/4-e.length,b=0;b<a;b++)c+="0";return c+e}function pss_mgf1_str(c,a,e){for(var b="",d=0;b.length<a;)b+=hextorstr(e(rstrtohex(c+String.fromCharCode.apply(String,[(4278190080&d)>>24,(16711680&d)>>16,(65280&d)>>8,255&d])))),d+=1;return b}function _rsasign_getAlgNameAndHashFromHexDisgestInfo(f){for(var e in KJUR.crypto.Util.DIGESTINFOHEAD){var d=KJUR.crypto.Util.DIGESTINFOHEAD[e],b=d.length;if(f.substring(0,b)==d)return[e,f.substring(b)]}return[]}function X509(){var k=ASN1HEX,j=k.getChildIdx,h=k.getV,b=k.getTLV,f=k.getVbyList,c=k.getTLVbyList,g=k.getIdxbyList,d=k.getVidx,i=k.oidname,a=X509,e=pemtohex;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==c(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return f(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return i(f(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return c(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return a.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return c(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return a.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var l=f(this.hex,0,[0,4+this.foffset,0]);return l=l.replace(/(..)/g,"%$1"),l=decodeURIComponent(l)},this.getNotAfter=function(){var l=f(this.hex,0,[0,4+this.foffset,1]);return l=l.replace(/(..)/g,"%$1"),l=decodeURIComponent(l)},this.getPublicKeyHex=function(){return k.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return g(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var l=this.getPublicKeyIdx();return g(this.hex,l,[1,0],"30")},this.getPublicKey=function(){return KEYUTIL.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return i(f(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return f(this.hex,0,[2],"03",!0)},this.verifySignature=function(n){var o=this.getSignatureAlgorithmName(),l=this.getSignatureValueHex(),m=c(this.hex,0,[0],"30"),p=new KJUR.crypto.Signature({alg:o});return p.init(n),p.updateHex(m),p.verify(l)},this.parseExt=function(){if(3!==this.version)return-1;var p=g(this.hex,0,[0,7,0],"30"),m=j(this.hex,p);this.aExtInfo=new Array;for(var n=0;n<m.length;n++){var q={critical:!1},r=0;3===j(this.hex,m[n]).length&&(q.critical=!0,r=1),q.oid=k.hextooidstr(f(this.hex,m[n],[0],"06"));var o=g(this.hex,m[n],[1+r]);q.vidx=d(this.hex,o),this.aExtInfo.push(q)}},this.getExtInfo=function(n){var l=this.aExtInfo,o=n;if(n.match(/^[0-9.]+$/)||(o=KJUR.asn1.x509.OID.name2oid(n)),""!==o)for(var m=0;m<l.length;m++)if(l[m].oid===o)return l[m]},this.getExtBasicConstraints=function(){var n=this.getExtInfo("basicConstraints");if(void 0===n)return n;var l=h(this.hex,n.vidx);if(""===l)return{};if("0101ff"===l)return{cA:!0};if("0101ff02"===l.substr(0,8)){var o=h(l,6);return{cA:!0,pathLen:parseInt(o,16)}}throw"basicConstraints parse error"},this.getExtKeyUsageBin=function(){var o=this.getExtInfo("keyUsage");if(void 0===o)return"";var m=h(this.hex,o.vidx);if(m.length%2!=0||m.length<=2)throw"malformed key usage value";var l=parseInt(m.substr(0,2)),n=parseInt(m.substr(2),16).toString(2);return n.substr(0,n.length-l)},this.getExtKeyUsageString=function(){for(var n=this.getExtKeyUsageBin(),l=new Array,m=0;m<n.length;m++)"1"==n.substr(m,1)&&l.push(X509.KEYUSAGE_NAME[m]);return l.join(",")},this.getExtSubjectKeyIdentifier=function(){var l=this.getExtInfo("subjectKeyIdentifier");return void 0===l?l:h(this.hex,l.vidx)},this.getExtAuthorityKeyIdentifier=function(){var p=this.getExtInfo("authorityKeyIdentifier");if(void 0===p)return p;for(var l={},o=b(this.hex,p.vidx),m=j(o,0),n=0;n<m.length;n++)"80"===o.substr(m[n],2)&&(l.kid=h(o,m[n]));return l},this.getExtExtKeyUsageName=function(){var p=this.getExtInfo("extKeyUsage");if(void 0===p)return p;var l=new Array,o=b(this.hex,p.vidx);if(""===o)return l;for(var m=j(o,0),n=0;n<m.length;n++)l.push(i(h(o,m[n])));return l},this.getExtSubjectAltName=function(){for(var m=this.getExtSubjectAltName2(),l=new Array,n=0;n<m.length;n++)"DNS"===m[n][0]&&l.push(m[n][1]);return l},this.getExtSubjectAltName2=function(){var p,s,r,q=this.getExtInfo("subjectAltName");if(void 0===q)return q;for(var l=new Array,o=b(this.hex,q.vidx),m=j(o,0),n=0;n<m.length;n++)r=o.substr(m[n],2),p=h(o,m[n]),"81"===r&&(s=hextoutf8(p),l.push(["MAIL",s])),"82"===r&&(s=hextoutf8(p),l.push(["DNS",s])),"84"===r&&(s=X509.hex2dn(p,0),l.push(["DN",s])),"86"===r&&(s=hextoutf8(p),l.push(["URI",s])),"87"===r&&(s=hextoip(p),l.push(["IP",s]));return l},this.getExtCRLDistributionPointsURI=function(){var q=this.getExtInfo("cRLDistributionPoints");if(void 0===q)return q;for(var l=new Array,m=j(this.hex,q.vidx),o=0;o<m.length;o++)try{var p=hextoutf8(f(this.hex,m[o],[0,0,0],"86"));l.push(p)}catch(n){}return l},this.getExtAIAInfo=function(){var p=this.getExtInfo("authorityInfoAccess");if(void 0===p)return p;for(var l={ocsp:[],caissuer:[]},m=j(this.hex,p.vidx),n=0;n<m.length;n++){var q=f(this.hex,m[n],[0],"06"),o=f(this.hex,m[n],[1],"86");"2b06010505073001"===q&&l.ocsp.push(hextoutf8(o)),"2b06010505073002"===q&&l.caissuer.push(hextoutf8(o))}return l},this.getExtCertificatePolicies=function(){var o=this.getExtInfo("certificatePolicies");if(void 0===o)return o;for(var l=b(this.hex,o.vidx),u=[],s=j(l,0),r=0;r<s.length;r++){var t={},n=j(l,s[r]);if(t.id=i(h(l,n[0])),2===n.length)for(var m=j(l,n[1]),q=0;q<m.length;q++){var p=f(l,m[q],[0],"06");"2b06010505070201"===p?t.cps=hextoutf8(f(l,m[q],[1])):"2b06010505070202"===p&&(t.unotice=hextoutf8(f(l,m[q],[1,0])))}u.push(t)}return u},this.readCertPEM=function(l){this.readCertHex(e(l))},this.readCertHex=function(l){this.hex=l,this.getVersion();try{g(this.hex,0,[0,7],"a3"),this.parseExt()}catch(m){}},this.getInfo=function(){var B,u,z;if(B="Basic Fields\n",B+=" serial number: "+this.getSerialNumberHex()+"\n",B+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",B+=" issuer: "+this.getIssuerString()+"\n",B+=" notBefore: "+this.getNotBefore()+"\n",B+=" notAfter: "+this.getNotAfter()+"\n",B+=" subject: "+this.getSubjectString()+"\n",B+=" subject public key info: \n",B+=" key algorithm: "+(u=this.getPublicKey()).type+"\n","RSA"===u.type&&(B+=" n="+hextoposhex(u.n.toString(16)).substr(0,16)+"...\n",B+=" e="+hextoposhex(u.e.toString(16))+"\n"),null!=(z=this.aExtInfo)){B+="X509v3 Extensions:\n";for(var r=0;r<z.length;r++){var n=z[r],A=KJUR.asn1.x509.OID.oid2name(n.oid);""===A&&(A=n.oid);var x="";if(!0===n.critical&&(x="CRITICAL"),B+=" "+A+" "+x+":\n","basicConstraints"===A){var v=this.getExtBasicConstraints();void 0===v.cA?B+=" {}\n":(B+=" cA=true",void 0!==v.pathLen&&(B+=", pathLen="+v.pathLen),B+="\n")}else if("keyUsage"===A)B+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===A)B+=" "+this.getExtSubjectKeyIdentifier()+"\n";else if("authorityKeyIdentifier"===A){var l=this.getExtAuthorityKeyIdentifier();void 0!==l.kid&&(B+=" kid="+l.kid+"\n")}else{if("extKeyUsage"===A)B+=" "+this.getExtExtKeyUsageName().join(", ")+"\n";else if("subjectAltName"===A)B+=" "+this.getExtSubjectAltName2()+"\n";else if("cRLDistributionPoints"===A)B+=" "+this.getExtCRLDistributionPointsURI()+"\n";else if("authorityInfoAccess"===A){var p=this.getExtAIAInfo();void 0!==p.ocsp&&(B+=" ocsp: "+p.ocsp.join(",")+"\n"),void 0!==p.caissuer&&(B+=" caissuer: "+p.caissuer.join(",")+"\n")}else if("certificatePolicies"===A)for(var o=this.getExtCertificatePolicies(),q=0;q<o.length;q++)void 0!==o[q].id&&(B+=" policy oid: "+o[q].id+"\n"),void 0!==o[q].cps&&(B+=" cps: "+o[q].cps+"\n")}}}return B+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",B+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"}}_RE_HEXDECONLY.compile("[^0-9a-f]","gi"),RSAKey.prototype.sign=function(d,a){var c=function(e){return KJUR.crypto.Util.hashString(e,a)}(d);return this.signWithMessageHash(c,a)},RSAKey.prototype.signWithMessageHash=function(e,c){var b=parseBigInt(KJUR.crypto.Util.getPaddedDigestInfoHex(e,c,this.n.bitLength()),16);return _zeroPaddingOfSignature(this.doPrivate(b).toString(16),this.n.bitLength())},RSAKey.prototype.signPSS=function(e,a,d){var f,b=(f=rstrtohex(e),KJUR.crypto.Util.hashHex(f,a));return void 0===d&&(d=-1),this.signWithMessageHashPSS(b,a,d)},RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var d,b=hextorstr(l),g=b.length,m=this.n.bitLength()-1,c=Math.ceil(m/8),o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(-1===k||void 0===k)k=g;else if(-2===k)k=c-g-2;else if(k<-2)throw"invalid salt length";if(c<g+k+2)throw"data too long";var f="";k>0&&(f=new Array(k),(new SecureRandom).nextBytes(f),f=String.fromCharCode.apply(String,f));var n=hextorstr(o(rstrtohex("\0\0\0\0\0\0\0\0"+b+f))),j=[];for(d=0;d<c-k-g-2;d+=1)j[d]=0;var e=String.fromCharCode.apply(String,j)+""+f,h=pss_mgf1_str(n,e.length,o),q=[];for(d=0;d<e.length;d+=1)q[d]=e.charCodeAt(d)^h.charCodeAt(d);var p=65280>>8*c-m&255;for(q[0]&=~p,d=0;d<g;d++)q.push(n.charCodeAt(d));return q.push(188),_zeroPaddingOfSignature(this.doPrivate(new BigInteger(q)).toString(16),this.n.bitLength())},RSAKey.prototype.verify=function(f,j){var b=parseBigInt(j=(j=j.replace(_RE_HEXDECONLY,"")).replace(/[ \n]+/g,""),16);if(b.bitLength()>this.n.bitLength())return 0;var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(this.doPublic(b).toString(16).replace(/^1f+00/,""));if(0==g.length)return!1;var d=g[0];return g[1]==function(k){return KJUR.crypto.Util.hashString(k,d)}(f)},RSAKey.prototype.verifyWithMessageHash=function(e,a){var b=parseBigInt(a=(a=a.replace(_RE_HEXDECONLY,"")).replace(/[ \n]+/g,""),16);if(b.bitLength()>this.n.bitLength())return 0;var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(this.doPublic(b).toString(16).replace(/^1f+00/,""));if(0==c.length)return!1;c[0];return c[1]==e},RSAKey.prototype.verifyPSS=function(c,b,a,f){var g,d=(g=rstrtohex(c),KJUR.crypto.Util.hashHex(g,a));return void 0===f&&(f=-1),this.verifyWithMessageHashPSS(d,b,a,f)},RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength())return!1;var q,r=function(i){return KJUR.crypto.Util.hashHex(i,l)},j=hextorstr(f),h=j.length,g=this.n.bitLength()-1,m=Math.ceil(g/8);if(-1===c||void 0===c)c=h;else if(-2===c)c=m-h-2;else if(c<-2)throw"invalid salt length";if(m<h+c+2)throw"data too long";var a=this.doPublic(k).toByteArray();for(q=0;q<a.length;q+=1)a[q]&=255;for(;a.length<m;)a.unshift(0);if(188!==a[m-1])throw"encoded message does not end in 0xbc";var d=(a=String.fromCharCode.apply(String,a)).substr(0,m-h-1),e=a.substr(d.length,h),p=65280>>8*m-g&255;if(0!=(d.charCodeAt(0)&p))throw"bits beyond keysize not zero";var n=pss_mgf1_str(e,d.length,r),o=[];for(q=0;q<d.length;q+=1)o[q]=d.charCodeAt(q)^n.charCodeAt(q);o[0]&=~p;var b=m-h-c-2;for(q=0;q<b;q+=1)if(0!==o[q])throw"leftmost octets not zero";if(1!==o[b])throw"0x01 marker not found";return e===hextorstr(r(rstrtohex("\0\0\0\0\0\0\0\0"+j+String.fromCharCode.apply(String,o.slice(-c)))))},RSAKey.SALT_LEN_HLEN=-1,RSAKey.SALT_LEN_MAX=-2,RSAKey.SALT_LEN_RECOVER=-2,X509.hex2dn=function(f,b){if(void 0===b&&(b=0),"30"!==f.substr(b,2))throw"malformed DN";for(var c=new Array,d=ASN1HEX.getChildIdx(f,b),e=0;e<d.length;e++)c.push(X509.hex2rdn(f,d[e]));return"/"+(c=c.map((function(a){return a.replace("/","\\/")}))).join("/")},X509.hex2rdn=function(f,b){if(void 0===b&&(b=0),"31"!==f.substr(b,2))throw"malformed RDN";for(var c=new Array,d=ASN1HEX.getChildIdx(f,b),e=0;e<d.length;e++)c.push(X509.hex2attrTypeValue(f,d[e]));return(c=c.map((function(a){return a.replace("+","\\+")}))).join("+")},X509.hex2attrTypeValue=function(d,i){var j=ASN1HEX,h=j.getV;if(void 0===i&&(i=0),"30"!==d.substr(i,2))throw"malformed attribute type and value";var g=j.getChildIdx(d,i);2!==g.length||d.substr(g[0],2);var b=h(d,g[0]),f=KJUR.asn1.ASN1Util.oidHexToInt(b);return KJUR.asn1.x509.OID.oid2atype(f)+"="+hextorstr(h(d,g[1]))},X509.getPublicKeyFromCertHex=function(b){var a=new X509;return a.readCertHex(b),a.getPublicKey()},X509.getPublicKeyFromCertPEM=function(b){var a=new X509;return a.readCertPEM(b),a.getPublicKey()},X509.getPublicKeyInfoPropOfCertPEM=function(c){var a,f,g=ASN1HEX.getVbyList,b={};return b.algparam=null,(a=new X509).readCertPEM(c),f=a.getPublicKeyHex(),b.keyhex=g(f,0,[1],"03").substr(2),b.algoid=g(f,0,[0,0],"06"),"2a8648ce3d0201"===b.algoid&&(b.algparam=g(f,0,[0,1],"06")),b},X509.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.jws&&KJUR.jws||(KJUR.jws={}),KJUR.jws.JWS=function(){var c=KJUR.jws.JWS.isSafeJSONString;this.parseJWS=function(g,j){if(void 0===this.parsedJWS||!j&&void 0===this.parsedJWS.sigvalH){var i=g.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==i)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var k=i[1],e=i[2],l=i[3],n=k+"."+e;if(this.parsedJWS={},this.parsedJWS.headB64U=k,this.parsedJWS.payloadB64U=e,this.parsedJWS.sigvalB64U=l,this.parsedJWS.si=n,!j){var h=b64utohex(l),f=parseBigInt(h,16);this.parsedJWS.sigvalH=h,this.parsedJWS.sigvalBI=f}var d=b64utoutf8(k),m=b64utoutf8(e);if(this.parsedJWS.headS=d,this.parsedJWS.payloadS=m,!c(d,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+d}}},KJUR.jws.JWS.sign=function(i,v,y,z,a){var s,j,n,w=KJUR,q=w.jws.JWS,g=q.readSafeJSONString,p=q.isSafeJSONString,d=w.crypto,o=(d.ECDSA,d.Mac),c=d.Signature,t=JSON;if("string"!=typeof v&&"object"!=typeof v)throw"spHeader must be JSON string or object: "+v;if("object"==typeof v&&(j=v,s=t.stringify(j)),"string"==typeof v){if(!p(s=v))throw"JWS Head is not safe JSON string: "+s;j=g(s)}if(n=y,"object"==typeof y&&(n=t.stringify(y)),""!=i&&null!=i||void 0===j.alg||(i=j.alg),""!=i&&null!=i&&void 0===j.alg&&(j.alg=i,s=t.stringify(j)),i!==j.alg)throw"alg and sHeader.alg doesn't match: "+i+"!="+j.alg;var r=null;if(void 0===q.jwsalg2sigalg[i])throw"unsupported alg name: "+i;r=q.jwsalg2sigalg[i];var b=utf8tob64u(s)+"."+utf8tob64u(n),x="";if("Hmac"==r.substr(0,4)){if(void 0===z)throw"mac key shall be specified for HS* alg";var h=new o({alg:r,prov:"cryptojs",pass:z});h.updateString(b),x=h.doFinal()}else{var f;if(-1!=r.indexOf("withECDSA"))(f=new c({alg:r})).init(z,a),f.updateString(b),hASN1Sig=f.sign(),x=KJUR.crypto.ECDSA.asn1SigToConcatSig(hASN1Sig);else if("none"!=r)(f=new c({alg:r})).init(z,a),f.updateString(b),x=f.sign()}return b+"."+hextob64u(x)},KJUR.jws.JWS.verify=function(w,B,n){var m,x=KJUR,t=x.jws.JWS,i=t.readSafeJSONString,e=x.crypto,p=e.ECDSA,s=e.Mac,d=e.Signature;m=RSAKey;var y=w.split(".");if(3!==y.length)return!1;var c=y[0]+"."+y[1],A=b64utohex(y[2]),l=i(b64utoutf8(y[0])),k=null,z=null;if(void 0===l.alg)throw"algorithm not specified in header";if((z=(k=l.alg).substr(0,2),null!=n&&"[object Array]"===Object.prototype.toString.call(n)&&n.length>0)&&-1==(":"+n.join(":")+":").indexOf(":"+k+":"))throw"algorithm '"+k+"' not accepted in the list";if("none"!=k&&null===B)throw"key shall be specified to verify.";if("string"==typeof B&&-1!=B.indexOf("-----BEGIN ")&&(B=KEYUTIL.getKey(B)),!("RS"!=z&&"PS"!=z||B instanceof m))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==z&&!(B instanceof p))throw"key shall be a ECDSA obj for ES* algs";var u=null;if(void 0===t.jwsalg2sigalg[l.alg])throw"unsupported alg name: "+k;if("none"==(u=t.jwsalg2sigalg[k]))throw"not supported";if("Hmac"==u.substr(0,4)){if(void 0===B)throw"hexadecimal key shall be specified for HMAC";var j=new s({alg:u,pass:B});return j.updateString(c),A==j.doFinal()}if(-1!=u.indexOf("withECDSA")){var g,h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return!1}return(g=new d({alg:u})).init(B),g.updateString(c),g.verify(h)}return(g=new d({alg:u})).init(B),g.updateString(c),g.verify(A)},KJUR.jws.JWS.parse=function(g){var f,e,d,c=g.split("."),b={};if(2!=c.length&&3!=c.length)throw"malformed sJWS: wrong number of '.' splitted elements";return f=c[0],e=c[1],3==c.length&&(d=c[2]),b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f)),b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e)),b.headerPP=JSON.stringify(b.headerObj,null," "),null==b.payloadObj?b.payloadPP=b64utoutf8(e):b.payloadPP=JSON.stringify(b.payloadObj,null," "),void 0!==d&&(b.sigHex=b64utohex(d)),b},KJUR.jws.JWS.verifyJWT=function(e,l,r){var j=KJUR.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray,k=e.split("."),c=k[0],i=k[1],h=(b64utohex(k[2]),n(b64utoutf8(c))),g=n(b64utoutf8(i));if(void 0===h.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!p(h.alg,r.alg))return!1;if(void 0!==g.iss&&"object"==typeof r.iss&&!p(g.iss,r.iss))return!1;if(void 0!==g.sub&&"object"==typeof r.sub&&!p(g.sub,r.sub))return!1;if(void 0!==g.aud&&"object"==typeof r.aud)if("string"==typeof g.aud){if(!p(g.aud,r.aud))return!1}else if("object"==typeof g.aud&&!f(g.aud,r.aud))return!1;var b=j.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(b=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==g.exp&&"number"==typeof g.exp&&g.exp+r.gracePeriod<b)&&(!(void 0!==g.nbf&&"number"==typeof g.nbf&&b<g.nbf-r.gracePeriod)&&(!(void 0!==g.iat&&"number"==typeof g.iat&&b<g.iat-r.gracePeriod)&&((void 0===g.jti||void 0===r.jti||g.jti===r.jti)&&!!o.verify(e,l,r.alg))))},KJUR.jws.JWS.includedArray=function(b,a){var c=KJUR.jws.JWS.inArray;if(null===b)return!1;if("object"!=typeof b)return!1;if("number"!=typeof b.length)return!1;for(var d=0;d<b.length;d++)if(!c(b[d],a))return!1;return!0},KJUR.jws.JWS.inArray=function(d,b){if(null===b)return!1;if("object"!=typeof b)return!1;if("number"!=typeof b.length)return!1;for(var c=0;c<b.length;c++)if(b[c]==d)return!0;return!1},KJUR.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},KJUR.jws.JWS.isSafeJSONString=function(c,b,d){var e=null;try{return"object"!=typeof(e=jsonParse(c))?0:e.constructor===Array?0:(b&&(b[d]=e),1)}catch(a){return 0}},KJUR.jws.JWS.readSafeJSONString=function(b){var c=null;try{return"object"!=typeof(c=jsonParse(b))?null:c.constructor===Array?null:c}catch(a){return null}},KJUR.jws.JWS.getEncodedSignatureValueFromJWS=function(b){var a=b.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==a)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return a[1]},KJUR.jws.JWS.getJWKthumbprint=function(d){if("RSA"!==d.kty&&"EC"!==d.kty&&"oct"!==d.kty)throw"unsupported algorithm for JWK Thumprint";var a="{";if("RSA"===d.kty){if("string"!=typeof d.n||"string"!=typeof d.e)throw"wrong n and e value for RSA key";a+='"e":"'+d.e+'",',a+='"kty":"'+d.kty+'",',a+='"n":"'+d.n+'"}'}else if("EC"===d.kty){if("string"!=typeof d.crv||"string"!=typeof d.x||"string"!=typeof d.y)throw"wrong crv, x and y value for EC key";a+='"crv":"'+d.crv+'",',a+='"kty":"'+d.kty+'",',a+='"x":"'+d.x+'",',a+='"y":"'+d.y+'"}'}else if("oct"===d.kty){if("string"!=typeof d.k)throw"wrong k value for oct(symmetric) key";a+='"kty":"'+d.kty+'",',a+='"k":"'+d.k+'"}'}var b=rstrtohex(a);return hextob64u(KJUR.crypto.Util.hashHex(b,"sha256"))},KJUR.jws.IntDate={},KJUR.jws.IntDate.get=function(c){var b=KJUR.jws.IntDate,d=b.getNow,a=b.getZulu;if("now"==c)return d();if("now + 1hour"==c)return d()+3600;if("now + 1day"==c)return d()+86400;if("now + 1month"==c)return d()+2592e3;if("now + 1year"==c)return d()+31536e3;if(c.match(/Z$/))return a(c);if(c.match(/^[0-9]+$/))return parseInt(c);throw"unsupported format: "+c},KJUR.jws.IntDate.getZulu=function(a){return zulutosec(a)},KJUR.jws.IntDate.getNow=function(){return~~(new Date/1e3)},KJUR.jws.IntDate.intDate2UTCString=function(a){return new Date(1e3*a).toUTCString()},KJUR.jws.IntDate.intDate2Zulu=function(e){var i=new Date(1e3*e);return("0000"+i.getUTCFullYear()).slice(-4)+("00"+(i.getUTCMonth()+1)).slice(-2)+("00"+i.getUTCDate()).slice(-2)+("00"+i.getUTCHours()).slice(-2)+("00"+i.getUTCMinutes()).slice(-2)+("00"+i.getUTCSeconds()).slice(-2)+"Z"},void 0!==KJUR&&KJUR||(KJUR={}),void 0!==KJUR.jws&&KJUR.jws||(KJUR.jws={}),KJUR.jws.JWSJS=function(){var a=KJUR.jws.JWS,d=a.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(f){this.init();var e=f.split(".");if(3!=e.length)throw"malformed input JWS";this.aHeader.push(e[0]),this.sPayload=e[1],this.aSignature.push(e[2])},this.addSignature=function(e,h,m,k){if(void 0===this.sPayload||null===this.sPayload)throw"there's no JSON-JS signature to add.";var l=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var j=KJUR.jws.JWS.sign(e,h,this.sPayload,m,k).split(".");j[0],j[2];this.aHeader.push(j[0]),this.aSignature.push(j[2])}catch(i){throw this.aHeader.length>l&&this.aHeader.pop(),this.aSignature.length>l&&this.aSignature.pop(),"addSignature failed: "+i}},this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length)return!1;for(var g=0;g<h.length;g++){var f=h[g];if(2!==f.length)return!1;if(!1===this.verifyNth(g,f[0],f[1]))return!1}return!0},this.verifyNth=function(f,j,g){if(this.aHeader.length<=f||this.aSignature.length<=f)return!1;var h=this.aHeader[f],k=this.aSignature[f],l=h+"."+this.sPayload+"."+k,e=!1;try{e=a.verify(l,j,g)}catch(i){return!1}return e},this.readJWSJS=function(g){if("string"==typeof g){var f=d(g);if(null==f)throw"argument is not safe JSON object string";this.aHeader=f.headers,this.sPayload=f.payload,this.aSignature=f.signatures}else try{if(!(g.headers.length>0))throw"malformed header";if(this.aHeader=g.headers,"string"!=typeof g.payload)throw"malformed signatures";if(this.sPayload=g.payload,!(g.signatures.length>0))throw"malformed signatures";this.aSignatures=g.signatures}catch(e){throw"malformed JWS-JS JSON object: "+e}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},exports.SecureRandom=SecureRandom,exports.rng_seed_time=rng_seed_time,exports.BigInteger=BigInteger,exports.RSAKey=RSAKey,exports.ECDSA=KJUR.crypto.ECDSA,exports.DSA=KJUR.crypto.DSA,exports.Signature=KJUR.crypto.Signature,exports.MessageDigest=KJUR.crypto.MessageDigest,exports.Mac=KJUR.crypto.Mac,exports.Cipher=KJUR.crypto.Cipher,exports.KEYUTIL=KEYUTIL,exports.ASN1HEX=ASN1HEX,exports.X509=X509,exports.CryptoJS=CryptoJS,exports.b64tohex=b64tohex,exports.b64toBA=b64toBA,exports.stoBA=stoBA,exports.BAtos=BAtos,exports.BAtohex=BAtohex,exports.stohex=stohex,exports.stob64=function(a){return hex2b64(stohex(a))},exports.stob64u=function(a){return b64tob64u(hex2b64(stohex(a)))},exports.b64utos=function(a){return BAtos(b64toBA(b64utob64(a)))},exports.b64tob64u=b64tob64u,exports.b64utob64=b64utob64,exports.hex2b64=hex2b64,exports.hextob64u=hextob64u,exports.b64utohex=b64utohex,exports.utf8tob64u=utf8tob64u,exports.b64utoutf8=b64utoutf8,exports.utf8tob64=function(a){return hex2b64(uricmptohex(encodeURIComponentAll(a)))},exports.b64toutf8=function(a){return decodeURIComponent(hextouricmp(b64tohex(a)))},exports.utf8tohex=utf8tohex,exports.hextoutf8=hextoutf8,exports.hextorstr=hextorstr,exports.rstrtohex=rstrtohex,exports.hextob64=hextob64,exports.hextob64nl=hextob64nl,exports.b64nltohex=b64nltohex,exports.hextopem=hextopem,exports.pemtohex=pemtohex,exports.hextoArrayBuffer=function(d){if(d.length%2!=0)throw"input is not even length";if(null==d.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var b=new ArrayBuffer(d.length/2),a=new DataView(b),c=0;c<d.length/2;c++)a.setUint8(c,parseInt(d.substr(2*c,2),16));return b},exports.ArrayBuffertohex=function(b){for(var d="",a=new DataView(b),c=0;c<b.byteLength;c++)d+=("00"+a.getUint8(c).toString(16)).slice(-2);return d},exports.zulutomsec=zulutomsec,exports.zulutosec=zulutosec,exports.zulutodate=function(a){return new Date(zulutomsec(a))},exports.datetozulu=function(g,e,f){var b,a=g.getUTCFullYear();if(e){if(a<1950||2049<a)throw"not proper year for UTCTime: "+a;b=(""+a).slice(-2)}else b=("000"+a).slice(-4);if(b+=("0"+(g.getUTCMonth()+1)).slice(-2),b+=("0"+g.getUTCDate()).slice(-2),b+=("0"+g.getUTCHours()).slice(-2),b+=("0"+g.getUTCMinutes()).slice(-2),b+=("0"+g.getUTCSeconds()).slice(-2),f){var c=g.getUTCMilliseconds();0!==c&&(b+="."+(c=(c=("00"+c).slice(-3)).replace(/0+$/g,"")))}return b+="Z"},exports.uricmptohex=uricmptohex,exports.hextouricmp=hextouricmp,exports.ipv6tohex=ipv6tohex,exports.hextoipv6=hextoipv6,exports.hextoip=hextoip,exports.iptohex=function(f){var j="malformed IP address";if(!(f=f.toLowerCase(f)).match(/^[0-9.]+$/)){if(f.match(/^[0-9a-f:]+$/)&&-1!==f.indexOf(":"))return ipv6tohex(f);throw j}var b=f.split(".");if(4!==b.length)throw j;var g="";try{for(var e=0;e<4;e++){g+=("0"+parseInt(b[e]).toString(16)).slice(-2)}return g}catch(c){throw j}},exports.encodeURIComponentAll=encodeURIComponentAll,exports.newline_toUnix=function(a){return a=a.replace(/\r\n/gm,"\n")},exports.newline_toDos=function(a){return a=(a=a.replace(/\r\n/gm,"\n")).replace(/\n/gm,"\r\n")},exports.hextoposhex=hextoposhex,exports.intarystrtohex=intarystrtohex,exports.strdiffidx=function(c,a){var d=c.length;c.length>a.length&&(d=a.length);for(var b=0;b<d;b++)if(c.charCodeAt(b)!=a.charCodeAt(b))return b;return c.length!=a.length?d:-1},exports.KJUR=KJUR,exports.crypto=KJUR.crypto,exports.asn1=KJUR.asn1,exports.jws=KJUR.jws,exports.lang=KJUR.lang}).call(this,require("buffer").Buffer)},{buffer:51}],252:[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=17976931348623157e292,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*$/,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|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",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{var types=freeModule&&freeModule.require&&freeModule.require("util").types;return types||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 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<length;){var value=array[index];setter(accumulator,value,iteratee(value),array)}return accumulator}function arrayEach(array,iteratee){for(var index=-1,length=null==array?0:array.length;++index<length&&!1!==iteratee(array[index],index,array););return array}function arrayEachRight(array,iteratee){for(var length=null==array?0:array.length;length--&&!1!==iteratee(array[length],length,array););return array}function arrayEvery(array,predicate){for(var index=-1,length=null==array?0:array.length;++index<length;)if(!predicate(array[index],index,array))return!1;return!0}function arrayFilter(array,predicate){for(var index=-1,length=null==array?0:array.length,resIndex=0,result=[];++index<length;){var value=array[index];predicate(value,index,array)&&(result[resIndex++]=value)}return result}function arrayIncludes(array,value){return!!(null==array?0:array.length)&&baseIndexOf(array,value,0)>-1}function arrayIncludesWith(array,value,comparator){for(var index=-1,length=null==array?0:array.length;++index<length;)if(comparator(value,array[index]))return!0;return!1}function arrayMap(array,iteratee){for(var index=-1,length=null==array?0:array.length,result=Array(length);++index<length;)result[index]=iteratee(array[index],index,array);return result}function arrayPush(array,values){for(var index=-1,length=values.length,offset=array.length;++index<length;)array[offset+index]=values[index];return array}function arrayReduce(array,iteratee,accumulator,initAccum){var index=-1,length=null==array?0:array.length;for(initAccum&&length&&(accumulator=array[++index]);++index<length;)accumulator=iteratee(accumulator,array[index],index,array);return accumulator}function arrayReduceRight(array,iteratee,accumulator,initAccum){var length=null==array?0:array.length;for(initAccum&&length&&(accumulator=array[--length]);length--;)accumulator=iteratee(accumulator,array[length],length,array);return accumulator}function arraySome(array,predicate){for(var index=-1,length=null==array?0:array.length;++index<length;)if(predicate(array[index],index,array))return!0;return!1}var asciiSize=baseProperty("length");function baseFindKey(collection,predicate,eachFunc){var result;return eachFunc(collection,(function(value,key,collection){if(predicate(value,key,collection))return result=key,!1})),result}function baseFindIndex(array,predicate,fromIndex,fromRight){for(var length=array.length,index=fromIndex+(fromRight?1:-1);fromRight?index--:++index<length;)if(predicate(array[index],index,array))return index;return-1}function baseIndexOf(array,value,fromIndex){return value==value?function(array,value,fromIndex){var index=fromIndex-1,length=array.length;for(;++index<length;)if(array[index]===value)return index;return-1}(array,value,fromIndex):baseFindIndex(array,baseIsNaN,fromIndex)}function baseIndexOfWith(array,value,fromIndex,comparator){for(var index=fromIndex-1,length=array.length;++index<length;)if(comparator(array[index],value))return index;return-1}function baseIsNaN(value){return value!=value}function baseMean(array,iteratee){var length=null==array?0:array.length;return length?baseSum(array,iteratee)/length:NAN}function baseProperty(key){return function(object){return null==object?undefined:object[key]}}function basePropertyOf(object){return function(key){return null==object?undefined:object[key]}}function baseReduce(collection,iteratee,accumulator,initAccum,eachFunc){return eachFunc(collection,(function(value,index,collection){accumulator=initAccum?(initAccum=!1,value):iteratee(accumulator,value,index,collection)})),accumulator}function baseSum(array,iteratee){for(var result,index=-1,length=array.length;++index<length;){var current=iteratee(array[index]);current!==undefined&&(result=result===undefined?current:result+current)}return result}function baseTimes(n,iteratee){for(var index=-1,result=Array(n);++index<n;)result[index]=iteratee(index);return result}function baseUnary(func){return function(value){return func(value)}}function baseValues(object,props){return arrayMap(props,(function(key){return object[key]}))}function cacheHas(cache,key){return cache.has(key)}function charsStartIndex(strSymbols,chrSymbols){for(var index=-1,length=strSymbols.length;++index<length&&baseIndexOf(chrSymbols,strSymbols[index],0)>-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<length;){var value=array[index];value!==placeholder&&value!==PLACEHOLDER||(array[index]=PLACEHOLDER,result[resIndex++]=index)}return result}function setToArray(set){var index=-1,result=Array(set.size);return set.forEach((function(value){result[++index]=value})),result}function setToPairs(set){var index=-1,result=Array(set.size);return set.forEach((function(value){result[++index]=[value,value]})),result}function stringSize(string){return hasUnicode(string)?function(string){var result=reUnicode.lastIndex=0;for(;reUnicode.test(string);)++result;return result}(string):asciiSize(string)}function stringToArray(string){return hasUnicode(string)?function(string){return string.match(reUnicode)||[]}(string):function(string){return string.split("")}(string)}var unescapeHtmlChar=basePropertyOf({"&":"&","<":"<",">":">",""":'"',"'":"'"});var _=function runInContext(context){var uid,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=(uid=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||""))?"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}function LazyWrapper(value){this.__wrapped__=value,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=MAX_ARRAY_LENGTH,this.__views__=[]}function Hash(entries){var index=-1,length=null==entries?0:entries.length;for(this.clear();++index<length;){var entry=entries[index];this.set(entry[0],entry[1])}}function ListCache(entries){var index=-1,length=null==entries?0:entries.length;for(this.clear();++index<length;){var entry=entries[index];this.set(entry[0],entry[1])}}function MapCache(entries){var index=-1,length=null==entries?0:entries.length;for(this.clear();++index<length;){var entry=entries[index];this.set(entry[0],entry[1])}}function SetCache(values){var index=-1,length=null==values?0:values.length;for(this.__data__=new MapCache;++index<length;)this.add(values[index])}function Stack(entries){var data=this.__data__=new ListCache(entries);this.size=data.size}function arrayLikeKeys(value,inherited){var isArr=isArray(value),isArg=!isArr&&isArguments(value),isBuff=!isArr&&!isArg&&isBuffer(value),isType=!isArr&&!isArg&&!isBuff&&isTypedArray(value),skipIndexes=isArr||isArg||isBuff||isType,result=skipIndexes?baseTimes(value.length,String):[],length=result.length;for(var key in value)!inherited&&!hasOwnProperty.call(value,key)||skipIndexes&&("length"==key||isBuff&&("offset"==key||"parent"==key)||isType&&("buffer"==key||"byteLength"==key||"byteOffset"==key)||isIndex(key,length))||result.push(key);return result}function arraySample(array){var length=array.length;return length?array[baseRandom(0,length-1)]:undefined}function arraySampleSize(array,n){return shuffleSelf(copyArray(array),baseClamp(n,0,array.length))}function arrayShuffle(array){return shuffleSelf(copyArray(array))}function assignMergeValue(object,key,value){(value===undefined||eq(object[key],value))&&(value!==undefined||key in object)||baseAssignValue(object,key,value)}function assignValue(object,key,value){var objValue=object[key];hasOwnProperty.call(object,key)&&eq(objValue,value)&&(value!==undefined||key in object)||baseAssignValue(object,key,value)}function assocIndexOf(array,key){for(var length=array.length;length--;)if(eq(array[length][0],key))return length;return-1}function baseAggregator(collection,setter,iteratee,accumulator){return baseEach(collection,(function(value,key,collection){setter(accumulator,value,iteratee(value),collection)})),accumulator}function baseAssign(object,source){return object&©Object(source,keys(source),object)}function baseAssignValue(object,key,value){"__proto__"==key&&defineProperty?defineProperty(object,key,{configurable:!0,enumerable:!0,value:value,writable:!0}):object[key]=value}function baseAt(object,paths){for(var index=-1,length=paths.length,result=Array(length),skip=null==object;++index<length;)result[index]=skip?undefined:get(object,paths[index]);return result}function baseClamp(number,lower,upper){return number==number&&(upper!==undefined&&(number=number<=upper?number:upper),lower!==undefined&&(number=number>=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=new array.constructor(length);length&&"string"==typeof array[0]&&hasOwnProperty.call(array,"index")&&(result.index=array.index,result.input=array.input);return 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,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 new Ctor;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 new Ctor;case symbolTag:return symbol=object,symbolValueOf?Object(symbolValueOf.call(symbol)):{}}var symbol}(value,tag,isDeep)}}stack||(stack=new Stack);var stacked=stack.get(value);if(stacked)return stacked;if(stack.set(value,result),isSet(value))return value.forEach((function(subValue){result.add(baseClone(subValue,bitmask,customizer,subValue,value,stack))})),result;if(isMap(value))return value.forEach((function(subValue,key){result.set(key,baseClone(subValue,bitmask,customizer,key,value,stack))})),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(;++index<length;){var value=array[index],computed=null==iteratee?value:iteratee(value);if(value=comparator||0!==value?value:0,isCommon&&computed==computed){for(var valuesIndex=valuesLength;valuesIndex--;)if(values[valuesIndex]===computed)continue outer;result.push(value)}else includes(values,computed,comparator)||result.push(value)}return result}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,LazyWrapper.prototype=baseCreate(baseLodash.prototype),LazyWrapper.prototype.constructor=LazyWrapper,Hash.prototype.clear=function(){this.__data__=nativeCreate?nativeCreate(null):{},this.size=0},Hash.prototype.delete=function(key){var result=this.has(key)&&delete this.__data__[key];return this.size-=result?1:0,result},Hash.prototype.get=function(key){var data=this.__data__;if(nativeCreate){var result=data[key];return result===HASH_UNDEFINED?undefined:result}return hasOwnProperty.call(data,key)?data[key]:undefined},Hash.prototype.has=function(key){var data=this.__data__;return nativeCreate?data[key]!==undefined:hasOwnProperty.call(data,key)},Hash.prototype.set=function(key,value){var data=this.__data__;return this.size+=this.has(key)?0:1,data[key]=nativeCreate&&value===undefined?HASH_UNDEFINED:value,this},ListCache.prototype.clear=function(){this.__data__=[],this.size=0},ListCache.prototype.delete=function(key){var data=this.__data__,index=assocIndexOf(data,key);return!(index<0)&&(index==data.length-1?data.pop():splice.call(data,index,1),--this.size,!0)},ListCache.prototype.get=function(key){var data=this.__data__,index=assocIndexOf(data,key);return index<0?undefined:data[index][1]},ListCache.prototype.has=function(key){return assocIndexOf(this.__data__,key)>-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},MapCache.prototype.clear=function(){this.size=0,this.__data__={hash:new Hash,map:new(Map||ListCache),string:new Hash}},MapCache.prototype.delete=function(key){var result=getMapData(this,key).delete(key);return this.size-=result?1:0,result},MapCache.prototype.get=function(key){return getMapData(this,key).get(key)},MapCache.prototype.has=function(key){return getMapData(this,key).has(key)},MapCache.prototype.set=function(key,value){var data=getMapData(this,key),size=data.size;return data.set(key,value),this.size+=data.size==size?0:1,this},SetCache.prototype.add=SetCache.prototype.push=function(value){return this.__data__.set(value,HASH_UNDEFINED),this},SetCache.prototype.has=function(value){return this.__data__.has(value)},Stack.prototype.clear=function(){this.__data__=new ListCache,this.size=0},Stack.prototype.delete=function(key){var data=this.__data__,result=data.delete(key);return this.size=data.size,result},Stack.prototype.get=function(key){return this.__data__.get(key)},Stack.prototype.has=function(key){return this.__data__.has(key)},Stack.prototype.set=function(key,value){var data=this.__data__;if(data instanceof ListCache){var pairs=data.__data__;if(!Map||pairs.length<LARGE_ARRAY_SIZE-1)return pairs.push([key,value]),this.size=++data.size,this;data=this.__data__=new MapCache(pairs)}return data.set(key,value),this.size=data.size,this};var baseEach=createBaseEach(baseForOwn),baseEachRight=createBaseEach(baseForOwnRight,!0);function baseEvery(collection,predicate){var result=!0;return baseEach(collection,(function(value,index,collection){return result=!!predicate(value,index,collection)})),result}function baseExtremum(array,iteratee,comparator){for(var index=-1,length=array.length;++index<length;){var value=array[index],current=iteratee(value);if(null!=current&&(computed===undefined?current==current&&!isSymbol(current):comparator(current,computed)))var computed=current,result=value}return result}function baseFilter(collection,predicate){var result=[];return baseEach(collection,(function(value,index,collection){predicate(value,index,collection)&&result.push(value)})),result}function baseFlatten(array,depth,predicate,isStrict,result){var index=-1,length=array.length;for(predicate||(predicate=isFlattenable),result||(result=[]);++index<length;){var value=array[index];depth>0&&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&&index<length;)object=object[toKey(path[index++])];return index&&index==length?object:undefined}function baseGetAllKeys(object,keysFunc,symbolsFunc){var result=keysFunc(object);return isArray(object)?result:arrayPush(result,symbolsFunc(object))}function baseGetTag(value){return null==value?value===undefined?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(value)?function(value){var isOwn=hasOwnProperty.call(value,symToStringTag),tag=value[symToStringTag];try{value[symToStringTag]=undefined;var unmasked=!0}catch(e){}var result=nativeObjectToString.call(value);unmasked&&(isOwn?value[symToStringTag]=tag:delete value[symToStringTag]);return result}(value):function(value){return nativeObjectToString.call(value)}(value)}function baseGt(value,other){return value>other}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<length&&result.length<maxLength;){var value=array[index],computed=iteratee?iteratee(value):value;if(value=comparator||0!==value?value:0,!(seen?cacheHas(seen,computed):includes(result,computed,comparator))){for(othIndex=othLength;--othIndex;){var cache=caches[othIndex];if(!(cache?cacheHas(cache,computed):includes(arrays[othIndex],computed,comparator)))continue outer}seen&&seen.push(computed),result.push(value)}}return result}function baseInvoke(object,path,args){var func=null==(object=parent(object,path=castPath(path,object)))?object:object[toKey(last(path))];return null==func?undefined:apply(func,object,args)}function baseIsArguments(value){return isObjectLike(value)&&baseGetTag(value)==argsTag}function baseIsEqual(value,other,bitmask,customizer,stack){return value===other||(null==value||null==other||!isObjectLike(value)&&!isObjectLike(other)?value!=value&&other!=other:function(object,other,bitmask,customizer,equalFunc,stack){var objIsArr=isArray(object),othIsArr=isArray(other),objTag=objIsArr?arrayTag:getTag(object),othTag=othIsArr?arrayTag:getTag(other),objIsObj=(objTag=objTag==argsTag?objectTag:objTag)==objectTag,othIsObj=(othTag=othTag==argsTag?objectTag:othTag)==objectTag,isSameTag=objTag==othTag;if(isSameTag&&isBuffer(object)){if(!isBuffer(other))return!1;objIsArr=!0,objIsObj=!1}if(isSameTag&&!objIsObj)return stack||(stack=new Stack),objIsArr||isTypedArray(object)?equalArrays(object,other,bitmask,customizer,equalFunc,stack):function(object,other,tag,bitmask,customizer,equalFunc,stack){switch(tag){case dataViewTag:if(object.byteLength!=other.byteLength||object.byteOffset!=other.byteOffset)return!1;object=object.buffer,other=other.buffer;case arrayBufferTag:return!(object.byteLength!=other.byteLength||!equalFunc(new Uint8Array(object),new Uint8Array(other)));case boolTag:case dateTag:case numberTag:return eq(+object,+other);case errorTag:return object.name==other.name&&object.message==other.message;case regexpTag:case stringTag:return object==other+"";case mapTag:var convert=mapToArray;case setTag:var isPartial=bitmask&COMPARE_PARTIAL_FLAG;if(convert||(convert=setToArray),object.size!=other.size&&!isPartial)return!1;var stacked=stack.get(object);if(stacked)return stacked==other;bitmask|=COMPARE_UNORDERED_FLAG,stack.set(object,other);var result=equalArrays(convert(object),convert(other),bitmask,customizer,equalFunc,stack);return stack.delete(object),result;case symbolTag:if(symbolValueOf)return symbolValueOf.call(object)==symbolValueOf.call(other)}return!1}(object,other,objTag,bitmask,customizer,equalFunc,stack);if(!(bitmask&COMPARE_PARTIAL_FLAG)){var objIsWrapped=objIsObj&&hasOwnProperty.call(object,"__wrapped__"),othIsWrapped=othIsObj&&hasOwnProperty.call(other,"__wrapped__");if(objIsWrapped||othIsWrapped){var objUnwrapped=objIsWrapped?object.value():object,othUnwrapped=othIsWrapped?other.value():other;return stack||(stack=new Stack),equalFunc(objUnwrapped,othUnwrapped,bitmask,customizer,stack)}}if(!isSameTag)return!1;return stack||(stack=new Stack),function(object,other,bitmask,customizer,equalFunc,stack){var isPartial=bitmask&COMPARE_PARTIAL_FLAG,objProps=getAllKeys(object),objLength=objProps.length,othLength=getAllKeys(other).length;if(objLength!=othLength&&!isPartial)return!1;var index=objLength;for(;index--;){var key=objProps[index];if(!(isPartial?key in other:hasOwnProperty.call(other,key)))return!1}var stacked=stack.get(object);if(stacked&&stack.get(other))return stacked==other;var result=!0;stack.set(object,other),stack.set(other,object);var skipCtor=isPartial;for(;++index<objLength;){key=objProps[index];var objValue=object[key],othValue=other[key];if(customizer)var compared=isPartial?customizer(othValue,objValue,key,other,object,stack):customizer(objValue,othValue,key,object,other,stack);if(!(compared===undefined?objValue===othValue||equalFunc(objValue,othValue,bitmask,customizer,stack):compared)){result=!1;break}skipCtor||(skipCtor="constructor"==key)}if(result&&!skipCtor){var objCtor=object.constructor,othCtor=other.constructor;objCtor!=othCtor&&"constructor"in object&&"constructor"in other&&!("function"==typeof objCtor&&objCtor instanceof objCtor&&"function"==typeof othCtor&&othCtor instanceof othCtor)&&(result=!1)}return stack.delete(object),stack.delete(other),result}(object,other,bitmask,customizer,equalFunc,stack)}(value,other,bitmask,customizer,baseIsEqual,stack))}function baseIsMatch(object,source,matchData,customizer){var index=matchData.length,length=index,noCustomizer=!customizer;if(null==object)return!length;for(object=Object(object);index--;){var data=matchData[index];if(noCustomizer&&data[2]?data[1]!==object[data[0]]:!(data[0]in object))return!1}for(;++index<length;){var key=(data=matchData[index])[0],objValue=object[key],srcValue=data[1];if(noCustomizer&&data[2]){if(objValue===undefined&&!(key in object))return!1}else{var stack=new Stack;if(customizer)var result=customizer(objValue,srcValue,key,object,source,stack);if(!(result===undefined?baseIsEqual(srcValue,objValue,COMPARE_PARTIAL_FLAG|COMPARE_UNORDERED_FLAG,customizer,stack):result))return!1}}return!0}function baseIsNative(value){return!(!isObject(value)||(func=value,maskSrcKey&&maskSrcKey in func))&&(isFunction(value)?reIsNative:reIsHostCtor).test(toSource(value));var func}function baseIteratee(value){return"function"==typeof value?value:null==value?identity:"object"==typeof value?isArray(value)?baseMatchesProperty(value[0],value[1]):baseMatches(value):property(value)}function baseKeys(object){if(!isPrototype(object))return nativeKeys(object);var result=[];for(var key in Object(object))hasOwnProperty.call(object,key)&&"constructor"!=key&&result.push(key);return result}function baseKeysIn(object){if(!isObject(object))return function(object){var result=[];if(null!=object)for(var key in Object(object))result.push(key);return result}(object);var isProto=isPrototype(object),result=[];for(var key in object)("constructor"!=key||!isProto&&hasOwnProperty.call(object,key))&&result.push(key);return result}function baseLt(value,other){return value<other}function baseMap(collection,iteratee){var index=-1,result=isArrayLike(collection)?Array(collection.length):[];return baseEach(collection,(function(value,key,collection){result[++index]=iteratee(value,key,collection)})),result}function baseMatches(source){var matchData=getMatchData(source);return 1==matchData.length&&matchData[0][2]?matchesStrictComparable(matchData[0][0],matchData[0][1]):function(object){return object===source||baseIsMatch(object,source,matchData)}}function baseMatchesProperty(path,srcValue){return isKey(path)&&isStrictComparable(srcValue)?matchesStrictComparable(toKey(path),srcValue):function(object){var objValue=get(object,path);return objValue===undefined&&objValue===srcValue?hasIn(object,path):baseIsEqual(srcValue,objValue,COMPARE_PARTIAL_FLAG|COMPARE_UNORDERED_FLAG)}}function baseMerge(object,source,srcIndex,customizer,stack){object!==source&&baseFor(source,(function(srcValue,key){if(isObject(srcValue))stack||(stack=new Stack),function(object,source,key,srcIndex,mergeFunc,customizer,stack){var objValue=safeGet(object,key),srcValue=safeGet(source,key),stacked=stack.get(srcValue);if(stacked)return void assignMergeValue(object,key,stacked);var newValue=customizer?customizer(objValue,srcValue,key+"",object,source,stack):undefined,isCommon=newValue===undefined;if(isCommon){var isArr=isArray(srcValue),isBuff=!isArr&&isBuffer(srcValue),isTyped=!isArr&&!isBuff&&isTypedArray(srcValue);newValue=srcValue,isArr||isBuff||isTyped?isArray(objValue)?newValue=objValue:isArrayLikeObject(objValue)?newValue=copyArray(objValue):isBuff?(isCommon=!1,newValue=cloneBuffer(srcValue,!0)):isTyped?(isCommon=!1,newValue=cloneTypedArray(srcValue,!0)):newValue=[]:isPlainObject(srcValue)||isArguments(srcValue)?(newValue=objValue,isArguments(objValue)?newValue=toPlainObject(objValue):isObject(objValue)&&!isFunction(objValue)||(newValue=initCloneObject(srcValue))):isCommon=!1}isCommon&&(stack.set(srcValue,newValue),mergeFunc(newValue,srcValue,srcIndex,customizer,stack),stack.delete(srcValue));assignMergeValue(object,key,newValue)}(object,source,key,srcIndex,baseMerge,customizer,stack);else{var newValue=customizer?customizer(safeGet(object,key),srcValue,key+"",object,source,stack):undefined;newValue===undefined&&(newValue=srcValue),assignMergeValue(object,key,newValue)}}),keysIn)}function baseNth(array,n){var length=array.length;if(length)return isIndex(n+=n<0?length:0,length)?array[n]:undefined}function baseOrderBy(collection,iteratees,orders){var index=-1;return iteratees=arrayMap(iteratees.length?iteratees:[identity],baseUnary(getIteratee())),function(array,comparer){var length=array.length;for(array.sort(comparer);length--;)array[length]=array[length].value;return array}(baseMap(collection,(function(value,key,collection){return{criteria:arrayMap(iteratees,(function(iteratee){return iteratee(value)})),index:++index,value:value}})),(function(object,other){return function(object,other,orders){var index=-1,objCriteria=object.criteria,othCriteria=other.criteria,length=objCriteria.length,ordersLength=orders.length;for(;++index<length;){var result=compareAscending(objCriteria[index],othCriteria[index]);if(result){if(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<length;){var path=paths[index],value=baseGet(object,path);predicate(value,path)&&baseSet(result,castPath(path,object),value)}return result}function basePullAll(array,values,iteratee,comparator){var indexOf=comparator?baseIndexOfWith:baseIndexOf,index=-1,length=values.length,seen=array;for(array===values&&(values=copyArray(values)),iteratee&&(seen=arrayMap(array,baseUnary(iteratee)));++index<length;)for(var fromIndex=0,value=values[index],computed=iteratee?iteratee(value):value;(fromIndex=indexOf(seen,computed,fromIndex,comparator))>-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&&++index<length;){var key=toKey(path[index]),newValue=value;if(index!=lastIndex){var objValue=nested[key];(newValue=customizer?customizer(objValue,key,nested):undefined)===undefined&&(newValue=isObject(objValue)?objValue:isIndex(path[index+1])?[]:{})}assignValue(nested,key,newValue),nested=nested[key]}return object}var baseSetData=metaMap?function(func,data){return metaMap.set(func,data),func}:identity,baseSetToString=defineProperty?function(func,string){return defineProperty(func,"toString",{configurable:!0,enumerable:!1,value:constant(string),writable:!0})}:identity;function baseShuffle(collection){return shuffleSelf(values(collection))}function baseSlice(array,start,end){var index=-1,length=array.length;start<0&&(start=-start>length?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<length;)result[index]=array[index+start];return result}function baseSome(collection,predicate){var result;return baseEach(collection,(function(value,index,collection){return!(result=predicate(value,index,collection))})),!!result}function baseSortedIndex(array,value,retHighest){var low=0,high=null==array?low:array.length;if("number"==typeof value&&value==value&&high<=HALF_MAX_ARRAY_LENGTH){for(;low<high;){var mid=low+high>>>1,computed=array[mid];null!==computed&&!isSymbol(computed)&&(retHighest?computed<=value:computed<value)?low=mid+1:high=mid}return high}return baseSortedIndexBy(array,value,identity,retHighest)}function baseSortedIndexBy(array,value,iteratee,retHighest){value=iteratee(value);for(var low=0,high=null==array?0:array.length,valIsNaN=value!=value,valIsNull=null===value,valIsSymbol=isSymbol(value),valIsUndefined=value===undefined;low<high;){var mid=nativeFloor((low+high)/2),computed=iteratee(array[mid]),othIsDefined=computed!==undefined,othIsNull=null===computed,othIsReflexive=computed==computed,othIsSymbol=isSymbol(computed);if(valIsNaN)var setLow=retHighest||othIsReflexive;else setLow=valIsUndefined?othIsReflexive&&(retHighest||othIsDefined):valIsNull?othIsReflexive&&othIsDefined&&(retHighest||!othIsNull):valIsSymbol?othIsReflexive&&othIsDefined&&!othIsNull&&(retHighest||!othIsSymbol):!othIsNull&&!othIsSymbol&&(retHighest?computed<=value:computed<value);setLow?low=mid+1:high=mid}return nativeMin(high,MAX_ARRAY_INDEX)}function baseSortedUniq(array,iteratee){for(var index=-1,length=array.length,resIndex=0,result=[];++index<length;){var value=array[index],computed=iteratee?iteratee(value):value;if(!index||!eq(computed,seen)){var seen=computed;result[resIndex++]=0===value?0:value}}return result}function baseToNumber(value){return"number"==typeof value?value:isSymbol(value)?NAN:+value}function baseToString(value){if("string"==typeof value)return value;if(isArray(value))return arrayMap(value,baseToString)+"";if(isSymbol(value))return symbolToString?symbolToString.call(value):"";var result=value+"";return"0"==result&&1/value==-INFINITY?"-0":result}function baseUniq(array,iteratee,comparator){var index=-1,includes=arrayIncludes,length=array.length,isCommon=!0,result=[],seen=result;if(comparator)isCommon=!1,includes=arrayIncludesWith;else if(length>=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;){var value=array[index],computed=iteratee?iteratee(value):value;if(value=comparator||0!==value?value:0,isCommon&&computed==computed){for(var seenIndex=seen.length;seenIndex--;)if(seen[seenIndex]===computed)continue outer;iteratee&&seen.push(computed),result.push(value)}else includes(seen,computed,comparator)||(seen!==result&&seen.push(computed),result.push(value))}return result}function baseUnset(object,path){return null==(object=parent(object,path=castPath(path,object)))||delete object[toKey(last(path))]}function baseUpdate(object,path,updater,customizer){return baseSet(object,path,updater(baseGet(object,path)),customizer)}function baseWhile(array,predicate,isDrop,fromRight){for(var length=array.length,index=fromRight?length:-1;(fromRight?index--:++index<length)&&predicate(array[index],index,array););return isDrop?baseSlice(array,fromRight?0:index,fromRight?index+1:length):baseSlice(array,fromRight?index+1:0,fromRight?length:index)}function baseWrapperValue(value,actions){var result=value;return result instanceof LazyWrapper&&(result=result.value()),arrayReduce(actions,(function(result,action){return action.func.apply(action.thisArg,arrayPush([result],action.args))}),result)}function baseXor(arrays,iteratee,comparator){var length=arrays.length;if(length<2)return length?baseUniq(arrays[0]):[];for(var index=-1,result=Array(length);++index<length;)for(var array=arrays[index],othIndex=-1;++othIndex<length;)othIndex!=index&&(result[index]=baseDifference(result[index]||array,arrays[othIndex],iteratee,comparator));return baseUniq(baseFlatten(result,1),iteratee,comparator)}function baseZipObject(props,values,assignFunc){for(var index=-1,length=props.length,valsLength=values.length,result={};++index<length;){var value=index<valsLength?values[index]:undefined;assignFunc(result,props[index],value)}return result}function castArrayLikeObject(value){return isArrayLikeObject(value)?value:[]}function castFunction(value){return"function"==typeof value?value:identity}function castPath(value,object){return isArray(value)?value:isKey(value,object)?[value]:stringToPath(toString(value))}var castRest=baseRest;function castSlice(array,start,end){var length=array.length;return end=end===undefined?length:end,!start&&end>=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&&value<other||othIsSymbol&&valIsDefined&&valIsReflexive&&!valIsNull&&!valIsSymbol||othIsNull&&valIsDefined&&valIsReflexive||!othIsDefined&&valIsReflexive||!othIsReflexive)return-1}return 0}function composeArgs(args,partials,holders,isCurried){for(var argsIndex=-1,argsLength=args.length,holdersLength=holders.length,leftIndex=-1,leftLength=partials.length,rangeLength=nativeMax(argsLength-holdersLength,0),result=Array(leftLength+rangeLength),isUncurried=!isCurried;++leftIndex<leftLength;)result[leftIndex]=partials[leftIndex];for(;++argsIndex<holdersLength;)(isUncurried||argsIndex<argsLength)&&(result[holders[argsIndex]]=args[argsIndex]);for(;rangeLength--;)result[leftIndex++]=args[argsIndex++];return result}function composeArgsRight(args,partials,holders,isCurried){for(var argsIndex=-1,argsLength=args.length,holdersIndex=-1,holdersLength=holders.length,rightIndex=-1,rightLength=partials.length,rangeLength=nativeMax(argsLength-holdersLength,0),result=Array(rangeLength+rightLength),isUncurried=!isCurried;++argsIndex<rangeLength;)result[argsIndex]=args[argsIndex];for(var offset=argsIndex;++rightIndex<rightLength;)result[offset+rightIndex]=partials[rightIndex];for(;++holdersIndex<holdersLength;)(isUncurried||argsIndex<argsLength)&&(result[offset+holders[holdersIndex]]=args[argsIndex++]);return result}function copyArray(source,array){var index=-1,length=source.length;for(array||(array=Array(length));++index<length;)array[index]=source[index];return array}function copyObject(source,props,object,customizer){var isNew=!object;object||(object={});for(var index=-1,length=props.length;++index<length;){var key=props[index],newValue=customizer?customizer(object[key],source[key],key,object,source):undefined;newValue===undefined&&(newValue=source[key]),isNew?baseAssignValue(object,key,newValue):assignValue(object,key,newValue)}return object}function createAggregator(setter,initializer){return function(collection,iteratee){var func=isArray(collection)?arrayAggregator:baseAggregator,accumulator=initializer?initializer():{};return func(collection,setter,getIteratee(iteratee,2),accumulator)}}function createAssigner(assigner){return baseRest((function(object,sources){var index=-1,length=sources.length,customizer=length>1?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<length;){var source=sources[index];source&&assigner(object,source,index,customizer)}return object}))}function createBaseEach(eachFunc,fromRight){return function(collection,iteratee){if(null==collection)return collection;if(!isArrayLike(collection))return eachFunc(collection,iteratee);for(var length=collection.length,index=fromRight?length:-1,iterable=Object(collection);(fromRight?index--:++index<length)&&!1!==iteratee(iterable[index],index,iterable););return collection}}function createBaseFor(fromRight){return function(object,iteratee,keysFunc){for(var index=-1,iterable=Object(object),props=keysFunc(object),length=props.length;length--;){var key=props[fromRight?length:++index];if(!1===iteratee(iterable[key],key,iterable))break}return object}}function createCaseFirst(methodName){return function(string){var strSymbols=hasUnicode(string=toString(string))?stringToArray(string):undefined,chr=strSymbols?strSymbols[0]:string.charAt(0),trailing=strSymbols?castSlice(strSymbols,1).join(""):string.slice(1);return chr[methodName]()+trailing}}function createCompounder(callback){return function(string){return arrayReduce(words(deburr(string).replace(reApos,"")),callback,"")}}function createCtor(Ctor){return function(){var args=arguments;switch(args.length){case 0:return new Ctor;case 1:return new Ctor(args[0]);case 2:return new Ctor(args[0],args[1]);case 3:return new Ctor(args[0],args[1],args[2]);case 4:return new Ctor(args[0],args[1],args[2],args[3]);case 5:return new Ctor(args[0],args[1],args[2],args[3],args[4]);case 6:return new Ctor(args[0],args[1],args[2],args[3],args[4],args[5]);case 7:return new Ctor(args[0],args[1],args[2],args[3],args[4],args[5],args[6])}var thisBinding=baseCreate(Ctor.prototype),result=Ctor.apply(thisBinding,args);return isObject(result)?result:thisBinding}}function createFind(findIndexFunc){return function(collection,predicate,fromIndex){var iterable=Object(collection);if(!isArrayLike(collection)){var iteratee=getIteratee(predicate,3);collection=keys(collection),predicate=function(key){return iteratee(iterable[key],key,iterable)}}var index=findIndexFunc(collection,predicate,fromIndex);return 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;++index<length;){var funcName=getFuncName(func=funcs[index]),data="wrapper"==funcName?getData(func):undefined;wrapper=data&&isLaziable(data[0])&&data[1]==(WRAP_ARY_FLAG|WRAP_CURRY_FLAG|WRAP_PARTIAL_FLAG|WRAP_REARG_FLAG)&&!data[4].length&&1==data[9]?wrapper[getFuncName(data[0])].apply(wrapper,data[3]):1==func.length&&isLaziable(func)?wrapper[funcName]():wrapper.thru(func)}return function(){var args=arguments,value=args[0];if(wrapper&&1==args.length&&isArray(value))return wrapper.plant(value).value();for(var index=0,result=length?funcs[index].apply(this,args):value;++index<length;)result=funcs[index].call(this,result);return result}}))}function createHybrid(func,bitmask,thisArg,partials,holders,partialsRight,holdersRight,argPos,ary,arity){var isAry=bitmask&WRAP_ARY_FLAG,isBind=bitmask&WRAP_BIND_FLAG,isBindKey=bitmask&WRAP_BIND_KEY_FLAG,isCurried=bitmask&(WRAP_CURRY_FLAG|WRAP_CURRY_RIGHT_FLAG),isFlip=bitmask&WRAP_FLIP_FLAG,Ctor=isBindKey?undefined:createCtor(func);return function wrapper(){for(var length=arguments.length,args=Array(length),index=length;index--;)args[index]=arguments[index];if(isCurried)var placeholder=getHolder(wrapper),holdersCount=function(array,placeholder){for(var length=array.length,result=0;length--;)array[length]===placeholder&&++result;return result}(args,placeholder);if(partials&&(args=composeArgs(args,partials,holders,isCurried)),partialsRight&&(args=composeArgsRight(args,partialsRight,holdersRight,isCurried)),length-=holdersCount,isCurried&&length<arity){var newHolders=replaceHolders(args,placeholder);return createRecurry(func,bitmask,createHybrid,wrapper.placeholder,thisArg,args,newHolders,argPos,ary,arity-length)}var thisBinding=isBind?thisArg:this,fn=isBindKey?thisBinding[func]:func;return length=args.length,argPos?args=function(array,indexes){var arrLength=array.length,length=nativeMin(indexes.length,arrLength),oldArray=copyArray(array);for(;length--;){var index=indexes[length];array[length]=isIndex(index,arrLength)?oldArray[index]:undefined}return array}(args,argPos):isFlip&&length>1&&args.reverse(),isAry&&ary<length&&(args.length=ary),this&&this!==root&&this instanceof wrapper&&(fn=Ctor||createCtor(fn)),fn.apply(thisBinding,args)}}function createInverter(setter,toIteratee){return function(object,iteratee){return function(object,setter,iteratee,accumulator){return baseForOwn(object,(function(value,key,object){setter(accumulator,iteratee(value),key,object)})),accumulator}(object,setter,toIteratee(iteratee),{})}}function createMathOperation(operator,defaultValue){return function(value,other){var result;if(value===undefined&&other===undefined)return defaultValue;if(value!==undefined&&(result=value),other!==undefined){if(result===undefined)return other;"string"==typeof value||"string"==typeof other?(value=baseToString(value),other=baseToString(other)):(value=baseToNumber(value),other=baseToNumber(other)),result=operator(value,other)}return result}}function createOver(arrayFunc){return flatRest((function(iteratees){return iteratees=arrayMap(iteratees,baseUnary(getIteratee())),baseRest((function(args){var thisArg=this;return arrayFunc(iteratees,(function(iteratee){return apply(iteratee,thisArg,args)}))}))}))}function createPadding(length,chars){var charsLength=(chars=chars===undefined?" ":baseToString(chars)).length;if(charsLength<2)return charsLength?baseRepeat(chars,length):chars;var result=baseRepeat(chars,nativeCeil(length/stringSize(chars)));return hasUnicode(chars)?castSlice(stringToArray(result),0,length).join(""):result.slice(0,length)}function createRange(fromRight){return function(start,end,step){return step&&"number"!=typeof step&&isIterateeCall(start,end,step)&&(end=step=undefined),start=toFinite(start),end===undefined?(end=start,start=0):end=toFinite(end),function(start,end,step,fromRight){for(var index=-1,length=nativeMax(nativeCeil((end-start)/(step||1)),0),result=Array(length);length--;)result[fromRight?length:++index]=start,start+=step;return result}(start,end,step=step===undefined?start<end?1:-1:toFinite(step),fromRight)}}function createRelationalOperation(operator){return function(value,other){return"string"==typeof value&&"string"==typeof other||(value=toNumber(value),other=toNumber(other)),operator(value,other)}}function createRecurry(func,bitmask,wrapFunc,placeholder,thisArg,partials,holders,argPos,ary,arity){var isCurry=bitmask&WRAP_CURRY_FLAG;bitmask|=isCurry?WRAP_PARTIAL_FLAG:WRAP_PARTIAL_RIGHT_FLAG,(bitmask&=~(isCurry?WRAP_PARTIAL_RIGHT_FLAG:WRAP_PARTIAL_FLAG))&WRAP_CURRY_BOUND_FLAG||(bitmask&=~(WRAP_BIND_FLAG|WRAP_BIND_KEY_FLAG));var newData=[func,bitmask,thisArg,isCurry?partials:undefined,isCurry?holders:undefined,isCurry?undefined:partials,isCurry?undefined:holders,argPos,ary,arity],result=wrapFunc.apply(undefined,newData);return isLaziable(func)&&setData(result,newData),result.placeholder=placeholder,setWrapToString(result,func,bitmask)}function createRound(methodName){var func=Math[methodName];return function(number,precision){if(number=toNumber(number),precision=null==precision?0:nativeMin(toInteger(precision),292)){var pair=(toString(number)+"e").split("e");return+((pair=(toString(func(pair[0]+"e"+(+pair[1]+precision)))+"e").split("e"))[0]+"e"+(+pair[1]-precision))}return func(number)}}var createSet=Set&&1/setToArray(new Set([,-0]))[1]==INFINITY?function(values){return new Set(values)}:noop;function createToPairs(keysFunc){return function(object){var tag=getTag(object);return tag==mapTag?mapToArray(object):tag==setTag?setToPairs(object):function(object,props){return arrayMap(props,(function(key){return[key,object[key]]}))}(object,keysFunc(object))}}function createWrap(func,bitmask,thisArg,partials,holders,argPos,ary,arity){var isBindKey=bitmask&WRAP_BIND_KEY_FLAG;if(!isBindKey&&"function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);var length=partials?partials.length:0;if(length||(bitmask&=~(WRAP_PARTIAL_FLAG|WRAP_PARTIAL_RIGHT_FLAG),partials=holders=undefined),ary=ary===undefined?ary:nativeMax(toInteger(ary),0),arity=arity===undefined?arity:toInteger(arity),length-=holders?holders.length:0,bitmask&WRAP_PARTIAL_RIGHT_FLAG){var partialsRight=partials,holdersRight=holders;partials=holders=undefined}var data=isBindKey?undefined:getData(func),newData=[func,bitmask,thisArg,partials,holders,partialsRight,holdersRight,argPos,ary,arity];if(data&&function(data,source){var bitmask=data[1],srcBitmask=source[1],newBitmask=bitmask|srcBitmask,isCommon=newBitmask<(WRAP_BIND_FLAG|WRAP_BIND_KEY_FLAG|WRAP_ARY_FLAG),isCombo=srcBitmask==WRAP_ARY_FLAG&&bitmask==WRAP_CURRY_FLAG||srcBitmask==WRAP_ARY_FLAG&&bitmask==WRAP_REARG_FLAG&&data[7].length<=source[8]||srcBitmask==(WRAP_ARY_FLAG|WRAP_REARG_FLAG)&&source[7].length<=source[8]&&bitmask==WRAP_CURRY_FLAG;if(!isCommon&&!isCombo)return data;srcBitmask&WRAP_BIND_FLAG&&(data[2]=source[2],newBitmask|=bitmask&WRAP_BIND_FLAG?0:WRAP_CURRY_BOUND_FLAG);var value=source[3];if(value){var partials=data[3];data[3]=partials?composeArgs(partials,value,source[4]):value,data[4]=partials?replaceHolders(data[3],PLACEHOLDER):source[4]}(value=source[5])&&(partials=data[5],data[5]=partials?composeArgsRight(partials,value,source[6]):value,data[6]=partials?replaceHolders(data[5],PLACEHOLDER):source[6]);(value=source[7])&&(data[7]=value);srcBitmask&WRAP_ARY_FLAG&&(data[8]=null==data[8]?source[8]:nativeMin(data[8],source[8]));null==data[9]&&(data[9]=source[9]);data[0]=source[0],data[1]=newBitmask}(newData,data),func=newData[0],bitmask=newData[1],thisArg=newData[2],partials=newData[3],holders=newData[4],!(arity=newData[9]=newData[9]===undefined?isBindKey?0:func.length:nativeMax(newData[9]-length,0))&&bitmask&(WRAP_CURRY_FLAG|WRAP_CURRY_RIGHT_FLAG)&&(bitmask&=~(WRAP_CURRY_FLAG|WRAP_CURRY_RIGHT_FLAG)),bitmask&&bitmask!=WRAP_BIND_FLAG)result=bitmask==WRAP_CURRY_FLAG||bitmask==WRAP_CURRY_RIGHT_FLAG?function(func,bitmask,arity){var Ctor=createCtor(func);return function wrapper(){for(var length=arguments.length,args=Array(length),index=length,placeholder=getHolder(wrapper);index--;)args[index]=arguments[index];var holders=length<3&&args[0]!==placeholder&&args[length-1]!==placeholder?[]:replaceHolders(args,placeholder);return(length-=holders.length)<arity?createRecurry(func,bitmask,createHybrid,wrapper.placeholder,undefined,args,holders,undefined,undefined,arity-length):apply(this&&this!==root&&this instanceof wrapper?Ctor:func,this,args)}}(func,bitmask,arity):bitmask!=WRAP_PARTIAL_FLAG&&bitmask!=(WRAP_BIND_FLAG|WRAP_PARTIAL_FLAG)||holders.length?createHybrid.apply(undefined,newData):function(func,bitmask,thisArg,partials){var isBind=bitmask&WRAP_BIND_FLAG,Ctor=createCtor(func);return function wrapper(){for(var argsIndex=-1,argsLength=arguments.length,leftIndex=-1,leftLength=partials.length,args=Array(leftLength+argsLength),fn=this&&this!==root&&this instanceof wrapper?Ctor:func;++leftIndex<leftLength;)args[leftIndex]=partials[leftIndex];for(;argsLength--;)args[leftIndex++]=arguments[++argsIndex];return apply(fn,isBind?thisArg:this,args)}}(func,bitmask,thisArg,partials);else var result=function(func,bitmask,thisArg){var isBind=bitmask&WRAP_BIND_FLAG,Ctor=createCtor(func);return function wrapper(){return(this&&this!==root&&this instanceof wrapper?Ctor:func).apply(isBind?thisArg:this,arguments)}}(func,bitmask,thisArg);return setWrapToString((data?baseSetData:setData)(result,newData),func,bitmask)}function customDefaultsAssignIn(objValue,srcValue,key,object){return objValue===undefined||eq(objValue,objectProto[key])&&!hasOwnProperty.call(object,key)?srcValue:objValue}function customDefaultsMerge(objValue,srcValue,key,object,source,stack){return isObject(objValue)&&isObject(srcValue)&&(stack.set(srcValue,objValue),baseMerge(objValue,srcValue,undefined,customDefaultsMerge,stack),stack.delete(srcValue)),objValue}function customOmitClone(value){return isPlainObject(value)?undefined:value}function equalArrays(array,other,bitmask,customizer,equalFunc,stack){var isPartial=bitmask&COMPARE_PARTIAL_FLAG,arrLength=array.length,othLength=other.length;if(arrLength!=othLength&&!(isPartial&&othLength>arrLength))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<arrLength;){var arrValue=array[index],othValue=other[index];if(customizer)var compared=isPartial?customizer(othValue,arrValue,index,other,array,stack):customizer(arrValue,othValue,index,array,other,stack);if(compared!==undefined){if(compared)continue;result=!1;break}if(seen){if(!arraySome(other,(function(othValue,othIndex){if(!cacheHas(seen,othIndex)&&(arrValue===othValue||equalFunc(arrValue,othValue,bitmask,customizer,stack)))return seen.push(othIndex)}))){result=!1;break}}else if(arrValue!==othValue&&!equalFunc(arrValue,othValue,bitmask,customizer,stack)){result=!1;break}}return stack.delete(array),stack.delete(other),result}function flatRest(func){return setToString(overRest(func,undefined,flatten),func+"")}function getAllKeys(object){return baseGetAllKeys(object,keys,getSymbols)}function getAllKeysIn(object){return baseGetAllKeys(object,keysIn,getSymbolsIn)}var getData=metaMap?function(func){return metaMap.get(func)}:noop;function getFuncName(func){for(var result=func.name+"",array=realNames[result],length=hasOwnProperty.call(realNames,result)?array.length:0;length--;){var data=array[length],otherFunc=data.func;if(null==otherFunc||otherFunc==func)return data.name}return result}function getHolder(func){return(hasOwnProperty.call(lodash,"placeholder")?lodash:func).placeholder}function getIteratee(){var result=lodash.iteratee||iteratee;return result=result===iteratee?baseIteratee:result,arguments.length?result(arguments[0],arguments[1]):result}function getMapData(map,key){var value,type,data=map.__data__;return("string"==(type=typeof(value=key))||"number"==type||"symbol"==type||"boolean"==type?"__proto__"!==value:null===value)?data["string"==typeof key?"string":"hash"]:data.map}function getMatchData(object){for(var result=keys(object),length=result.length;length--;){var key=result[length],value=object[key];result[length]=[key,value,isStrictComparable(value)]}return result}function getNative(object,key){var value=function(object,key){return null==object?undefined:object[key]}(object,key);return baseIsNative(value)?value:undefined}var getSymbols=nativeGetSymbols?function(object){return null==object?[]:(object=Object(object),arrayFilter(nativeGetSymbols(object),(function(symbol){return propertyIsEnumerable.call(object,symbol)})))}:stubArray,getSymbolsIn=nativeGetSymbols?function(object){for(var result=[];object;)arrayPush(result,getSymbols(object)),object=getPrototype(object);return result}:stubArray,getTag=baseGetTag;function hasPath(object,path,hasFunc){for(var index=-1,length=(path=castPath(path,object)).length,result=!1;++index<length;){var key=toKey(path[index]);if(!(result=null!=object&&hasFunc(object,key)))break;object=object[key]}return result||++index!=length?result:!!(length=null==object?0:object.length)&&isLength(length)&&isIndex(key,length)&&(isArray(object)||isArguments(object))}function initCloneObject(object){return"function"!=typeof object.constructor||isPrototype(object)?{}:baseCreate(getPrototype(object))}function isFlattenable(value){return isArray(value)||isArguments(value)||!!(spreadableSymbol&&value&&value[spreadableSymbol])}function isIndex(value,length){var type=typeof value;return!!(length=null==length?MAX_SAFE_INTEGER:length)&&("number"==type||"symbol"!=type&&reIsUint.test(value))&&value>-1&&value%1==0&&value<length}function isIterateeCall(value,index,object){if(!isObject(object))return!1;var type=typeof index;return!!("number"==type?isArrayLike(object)&&isIndex(index,object.length):"string"==type&&index in object)&&eq(object[index],value)}function isKey(value,object){if(isArray(value))return!1;var type=typeof value;return!("number"!=type&&"symbol"!=type&&"boolean"!=type&&null!=value&&!isSymbol(value))||(reIsPlainProp.test(value)||!reIsDeepProp.test(value)||null!=object&&value in Object(object))}function isLaziable(func){var funcName=getFuncName(func),other=lodash[funcName];if("function"!=typeof other||!(funcName in LazyWrapper.prototype))return!1;if(func===other)return!0;var data=getData(other);return!!data&&func===data[0]}(DataView&&getTag(new DataView(new ArrayBuffer(1)))!=dataViewTag||Map&&getTag(new Map)!=mapTag||Promise&&"[object Promise]"!=getTag(Promise.resolve())||Set&&getTag(new Set)!=setTag||WeakMap&&getTag(new WeakMap)!=weakMapTag)&&(getTag=function(value){var result=baseGetTag(value),Ctor=result==objectTag?value.constructor:undefined,ctorString=Ctor?toSource(Ctor):"";if(ctorString)switch(ctorString){case dataViewCtorString:return dataViewTag;case mapCtorString:return mapTag;case promiseCtorString:return"[object Promise]";case setCtorString:return setTag;case weakMapCtorString:return weakMapTag}return result});var isMaskable=coreJsData?isFunction:stubFalse;function isPrototype(value){var Ctor=value&&value.constructor;return value===("function"==typeof Ctor&&Ctor.prototype||objectProto)}function isStrictComparable(value){return value==value&&!isObject(value)}function matchesStrictComparable(key,srcValue){return function(object){return null!=object&&(object[key]===srcValue&&(srcValue!==undefined||key in Object(object)))}}function overRest(func,start,transform){return start=nativeMax(start===undefined?func.length-1:start,0),function(){for(var args=arguments,index=-1,length=nativeMax(args.length-start,0),array=Array(length);++index<length;)array[index]=args[start+index];index=-1;for(var otherArgs=Array(start+1);++index<start;)otherArgs[index]=args[index];return otherArgs[start]=transform(array),apply(func,this,otherArgs)}}function parent(object,path){return path.length<2?object:baseGet(object,baseSlice(path,0,-1))}function safeGet(object,key){if("__proto__"!=key)return object[key]}var setData=shortOut(baseSetData),setTimeout=ctxSetTimeout||function(func,wait){return root.setTimeout(func,wait)},setToString=shortOut(baseSetToString);function setWrapToString(wrapper,reference,bitmask){var source=reference+"";return setToString(wrapper,function(source,details){var length=details.length;if(!length)return source;var lastIndex=length-1;return details[lastIndex]=(length>1?"& ":"")+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;++index<size;){var rand=baseRandom(index,lastIndex),value=array[rand];array[rand]=array[index],array[index]=value}return array.length=size,array}var stringToPath=function(func){var result=memoize(func,(function(key){return cache.size===MAX_MEMOIZE_SIZE&&cache.clear(),key})),cache=result.cache;return result}((function(string){var result=[];return 46===string.charCodeAt(0)&&result.push(""),string.replace(rePropName,(function(match,number,quote,subString){result.push(quote?subString.replace(reEscapeChar,"$1"):number||match)})),result}));function toKey(value){if("string"==typeof value||isSymbol(value))return value;var result=value+"";return"0"==result&&1/value==-INFINITY?"-0":result}function toSource(func){if(null!=func){try{return funcToString.call(func)}catch(e){}try{return func+""}catch(e){}}return""}function wrapperClone(wrapper){if(wrapper instanceof LazyWrapper)return wrapper.clone();var result=new LodashWrapper(wrapper.__wrapped__,wrapper.__chain__);return result.__actions__=copyArray(wrapper.__actions__),result.__index__=wrapper.__index__,result.__values__=wrapper.__values__,result}var difference=baseRest((function(array,values){return isArrayLikeObject(array)?baseDifference(array,baseFlatten(values,1,isArrayLikeObject,!0)):[]})),differenceBy=baseRest((function(array,values){var iteratee=last(values);return isArrayLikeObject(iteratee)&&(iteratee=undefined),isArrayLikeObject(array)?baseDifference(array,baseFlatten(values,1,isArrayLikeObject,!0),getIteratee(iteratee,2)):[]})),differenceWith=baseRest((function(array,values){var comparator=last(values);return isArrayLikeObject(comparator)&&(comparator=undefined),isArrayLikeObject(array)?baseDifference(array,baseFlatten(values,1,isArrayLikeObject,!0),undefined,comparator):[]}));function findIndex(array,predicate,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)),baseFindIndex(array,getIteratee(predicate,3),index)}function findLastIndex(array,predicate,fromIndex){var length=null==array?0:array.length;if(!length)return-1;var index=length-1;return fromIndex!==undefined&&(index=toInteger(fromIndex),index=fromIndex<0?nativeMax(length+index,0):nativeMin(index,length-1)),baseFindIndex(array,getIteratee(predicate,3),index,!0)}function flatten(array){return(null==array?0:array.length)?baseFlatten(array,1):[]}function head(array){return array&&array.length?array[0]:undefined}var intersection=baseRest((function(arrays){var mapped=arrayMap(arrays,castArrayLikeObject);return mapped.length&&mapped[0]===arrays[0]?baseIntersection(mapped):[]})),intersectionBy=baseRest((function(arrays){var iteratee=last(arrays),mapped=arrayMap(arrays,castArrayLikeObject);return iteratee===last(mapped)?iteratee=undefined:mapped.pop(),mapped.length&&mapped[0]===arrays[0]?baseIntersection(mapped,getIteratee(iteratee,2)):[]})),intersectionWith=baseRest((function(arrays){var comparator=last(arrays),mapped=arrayMap(arrays,castArrayLikeObject);return(comparator="function"==typeof comparator?comparator:undefined)&&mapped.pop(),mapped.length&&mapped[0]===arrays[0]?baseIntersection(mapped,undefined,comparator):[]}));function last(array){var length=null==array?0:array.length;return length?array[length-1]:undefined}var pull=baseRest(pullAll);function pullAll(array,values){return array&&array.length&&values&&values.length?basePullAll(array,values):array}var pullAt=flatRest((function(array,indexes){var length=null==array?0:array.length,result=baseAt(array,indexes);return basePullAt(array,arrayMap(indexes,(function(index){return isIndex(index,length)?+index:index})).sort(compareAscending)),result}));function reverse(array){return null==array?array:nativeReverse.call(array)}var union=baseRest((function(arrays){return baseUniq(baseFlatten(arrays,1,isArrayLikeObject,!0))})),unionBy=baseRest((function(arrays){var iteratee=last(arrays);return isArrayLikeObject(iteratee)&&(iteratee=undefined),baseUniq(baseFlatten(arrays,1,isArrayLikeObject,!0),getIteratee(iteratee,2))})),unionWith=baseRest((function(arrays){var comparator=last(arrays);return comparator="function"==typeof comparator?comparator:undefined,baseUniq(baseFlatten(arrays,1,isArrayLikeObject,!0),undefined,comparator)}));function unzip(array){if(!array||!array.length)return[];var length=0;return array=arrayFilter(array,(function(group){if(isArrayLikeObject(group))return length=nativeMax(group.length,length),!0})),baseTimes(length,(function(index){return arrayMap(array,baseProperty(index))}))}function unzipWith(array,iteratee){if(!array||!array.length)return[];var result=unzip(array);return null==iteratee?result:arrayMap(result,(function(group){return apply(iteratee,undefined,group)}))}var without=baseRest((function(array,values){return isArrayLikeObject(array)?baseDifference(array,values):[]})),xor=baseRest((function(arrays){return baseXor(arrayFilter(arrays,isArrayLikeObject))})),xorBy=baseRest((function(arrays){var iteratee=last(arrays);return isArrayLikeObject(iteratee)&&(iteratee=undefined),baseXor(arrayFilter(arrays,isArrayLikeObject),getIteratee(iteratee,2))})),xorWith=baseRest((function(arrays){var comparator=last(arrays);return comparator="function"==typeof comparator?comparator:undefined,baseXor(arrayFilter(arrays,isArrayLikeObject),undefined,comparator)})),zip=baseRest(unzip);var zipWith=baseRest((function(arrays){var length=arrays.length,iteratee=length>1?arrays[length-1]:undefined;return iteratee="function"==typeof iteratee?(arrays.pop(),iteratee):undefined,unzipWith(arrays,iteratee)}));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);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 timeWaiting=wait-(time-lastCallTime);return maxing?nativeMin(timeWaiting,maxWait-(time-lastInvokeTime)):timeWaiting}(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 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),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}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)}}memoize.Cache=MapCache;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<length;)args[index]=transforms[index].call(this,args[index]);return apply(func,this,args)}))})),partial=baseRest((function(func,partials){var holders=replaceHolders(partials,getHolder(partial));return createWrap(func,WRAP_PARTIAL_FLAG,undefined,partials,holders)})),partialRight=baseRest((function(func,partials){var holders=replaceHolders(partials,getHolder(partialRight));return createWrap(func,WRAP_PARTIAL_RIGHT_FLAG,undefined,partials,holders)})),rearg=flatRest((function(func,indexes){return createWrap(func,WRAP_REARG_FLAG,undefined,undefined,undefined,indexes)}));function eq(value,other){return value===other||value!=value&&other!=other}var gt=createRelationalOperation(baseGt),gte=createRelationalOperation((function(value,other){return value>=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(object,sources){object=Object(object);var index=-1,length=sources.length,guard=length>2?sources[2]:undefined;for(guard&&isIterateeCall(sources[0],sources[1],guard)&&(length=1);++index<length;)for(var source=sources[index],props=keysIn(source),propsIndex=-1,propsLength=props.length;++propsIndex<propsLength;){var key=props[propsIndex],value=object[key];(value===undefined||eq(value,objectProto[key])&&!hasOwnProperty.call(object,key))&&(object[key]=source[key])}return object})),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){null!=value&&"function"!=typeof value.toString&&(value=nativeObjectToString.call(value)),result[value]=key}),constant(identity)),invertBy=createInverter((function(result,value,key){null!=value&&"function"!=typeof value.toString&&(value=nativeObjectToString.call(value)),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__),actions=result.__actions__=copyArray(this.__actions__);return 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 source,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));index<length;)result[resIndex++]=baseSlice(array,index,index+=size);return result},lodash.compact=function(array){for(var index=-1,length=null==array?0:array.length,resIndex=0,result=[];++index<length;){var value=array[index];value&&(result[resIndex++]=value)}return result},lodash.concat=function(){var length=arguments.length;if(!length)return[];for(var args=Array(length-1),array=arguments[0],index=length;index--;)args[index-1]=arguments[index];return arrayPush(isArray(array)?copyArray(array):[array],baseFlatten(args,1))},lodash.cond=function(pairs){var length=null==pairs?0:pairs.length,toIteratee=getIteratee();return pairs=length?arrayMap(pairs,(function(pair){if("function"!=typeof pair[1])throw new TypeError(FUNC_ERROR_TEXT);return[toIteratee(pair[0]),pair[1]]})):[],baseRest((function(args){for(var index=-1;++index<length;){var pair=pairs[index];if(apply(pair[0],this,args))return apply(pair[1],this,args)}}))},lodash.conforms=function(source){return function(source){var props=keys(source);return function(object){return baseConformsTo(object,source,props)}}(baseClone(source,CLONE_DEEP_FLAG))},lodash.constant=constant,lodash.countBy=countBy,lodash.create=function(prototype,properties){var result=baseCreate(prototype);return null==properties?result:baseAssign(result,properties)},lodash.curry=function curry(func,arity,guard){var result=createWrap(func,WRAP_CURRY_FLAG,undefined,undefined,undefined,undefined,undefined,arity=guard?undefined:arity);return result.placeholder=curry.placeholder,result},lodash.curryRight=function curryRight(func,arity,guard){var result=createWrap(func,WRAP_CURRY_RIGHT_FLAG,undefined,undefined,undefined,undefined,undefined,arity=guard?undefined:arity);return result.placeholder=curryRight.placeholder,result},lodash.debounce=debounce,lodash.defaults=defaults,lodash.defaultsDeep=defaultsDeep,lodash.defer=defer,lodash.delay=delay,lodash.difference=difference,lodash.differenceBy=differenceBy,lodash.differenceWith=differenceWith,lodash.drop=function(array,n,guard){var length=null==array?0:array.length;return length?baseSlice(array,(n=guard||n===undefined?1:toInteger(n))<0?0:n,length):[]},lodash.dropRight=function(array,n,guard){var length=null==array?0:array.length;return length?baseSlice(array,0,(n=length-(n=guard||n===undefined?1:toInteger(n)))<0?0:n):[]},lodash.dropRightWhile=function(array,predicate){return array&&array.length?baseWhile(array,getIteratee(predicate,3),!0,!0):[]},lodash.dropWhile=function(array,predicate){return array&&array.length?baseWhile(array,getIteratee(predicate,3),!0):[]},lodash.fill=function(array,value,start,end){var length=null==array?0:array.length;return length?(start&&"number"!=typeof start&&isIterateeCall(array,value,start)&&(start=0,end=length),function(array,value,start,end){var length=array.length;for((start=toInteger(start))<0&&(start=-start>length?0:length+start),(end=end===undefined||end>length?length:toInteger(end))<0&&(end+=length),end=start>end?0:toLength(end);start<end;)array[start++]=value;return array}(array,value,start,end)):[]},lodash.filter=function(collection,predicate){return(isArray(collection)?arrayFilter:baseFilter)(collection,getIteratee(predicate,3))},lodash.flatMap=function(collection,iteratee){return baseFlatten(map(collection,iteratee),1)},lodash.flatMapDeep=function(collection,iteratee){return baseFlatten(map(collection,iteratee),INFINITY)},lodash.flatMapDepth=function(collection,iteratee,depth){return depth=depth===undefined?1:toInteger(depth),baseFlatten(map(collection,iteratee),depth)},lodash.flatten=flatten,lodash.flattenDeep=function(array){return(null==array?0:array.length)?baseFlatten(array,INFINITY):[]},lodash.flattenDepth=function(array,depth){return(null==array?0:array.length)?baseFlatten(array,depth=depth===undefined?1:toInteger(depth)):[]},lodash.flip=function(func){return createWrap(func,WRAP_FLIP_FLAG)},lodash.flow=flow,lodash.flowRight=flowRight,lodash.fromPairs=function(pairs){for(var index=-1,length=null==pairs?0:pairs.length,result={};++index<length;){var pair=pairs[index];result[pair[0]]=pair[1]}return result},lodash.functions=function(object){return null==object?[]:baseFunctions(object,keys(object))},lodash.functionsIn=function(object){return null==object?[]:baseFunctions(object,keysIn(object))},lodash.groupBy=groupBy,lodash.initial=function(array){return(null==array?0:array.length)?baseSlice(array,0,-1):[]},lodash.intersection=intersection,lodash.intersectionBy=intersectionBy,lodash.intersectionWith=intersectionWith,lodash.invert=invert,lodash.invertBy=invertBy,lodash.invokeMap=invokeMap,lodash.iteratee=iteratee,lodash.keyBy=keyBy,lodash.keys=keys,lodash.keysIn=keysIn,lodash.map=map,lodash.mapKeys=function(object,iteratee){var result={};return iteratee=getIteratee(iteratee,3),baseForOwn(object,(function(value,key,object){baseAssignValue(result,iteratee(value,key,object),value)})),result},lodash.mapValues=function(object,iteratee){var result={};return iteratee=getIteratee(iteratee,3),baseForOwn(object,(function(value,key,object){baseAssignValue(result,key,iteratee(value,key,object))})),result},lodash.matches=function(source){return baseMatches(baseClone(source,CLONE_DEEP_FLAG))},lodash.matchesProperty=function(path,srcValue){return baseMatchesProperty(path,baseClone(srcValue,CLONE_DEEP_FLAG))},lodash.memoize=memoize,lodash.merge=merge,lodash.mergeWith=mergeWith,lodash.method=method,lodash.methodOf=methodOf,lodash.mixin=mixin,lodash.negate=negate,lodash.nthArg=function(n){return n=toInteger(n),baseRest((function(args){return baseNth(args,n)}))},lodash.omit=omit,lodash.omitBy=function(object,predicate){return pickBy(object,negate(getIteratee(predicate)))},lodash.once=function(func){return before(2,func)},lodash.orderBy=function(collection,iteratees,orders,guard){return null==collection?[]:(isArray(iteratees)||(iteratees=null==iteratees?[]:[iteratees]),isArray(orders=guard?undefined:orders)||(orders=null==orders?[]:[orders]),baseOrderBy(collection,iteratees,orders))},lodash.over=over,lodash.overArgs=overArgs,lodash.overEvery=overEvery,lodash.overSome=overSome,lodash.partial=partial,lodash.partialRight=partialRight,lodash.partition=partition,lodash.pick=pick,lodash.pickBy=pickBy,lodash.property=property,lodash.propertyOf=function(object){return function(path){return null==object?undefined:baseGet(object,path)}},lodash.pull=pull,lodash.pullAll=pullAll,lodash.pullAllBy=function(array,values,iteratee){return array&&array.length&&values&&values.length?basePullAll(array,values,getIteratee(iteratee,2)):array},lodash.pullAllWith=function(array,values,comparator){return array&&array.length&&values&&values.length?basePullAll(array,values,undefined,comparator):array},lodash.pullAt=pullAt,lodash.range=range,lodash.rangeRight=rangeRight,lodash.rearg=rearg,lodash.reject=function(collection,predicate){return(isArray(collection)?arrayFilter:baseFilter)(collection,negate(getIteratee(predicate,3)))},lodash.remove=function(array,predicate){var result=[];if(!array||!array.length)return result;var index=-1,indexes=[],length=array.length;for(predicate=getIteratee(predicate,3);++index<length;){var value=array[index];predicate(value,index,array)&&(result.push(value),indexes.push(index))}return basePullAt(array,indexes),result},lodash.rest=function(func,start){if("function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return baseRest(func,start=start===undefined?start:toInteger(start))},lodash.reverse=reverse,lodash.sampleSize=function(collection,n,guard){return n=(guard?isIterateeCall(collection,n,guard):n===undefined)?1:toInteger(n),(isArray(collection)?arraySampleSize:baseSampleSize)(collection,n)},lodash.set=function(object,path,value){return null==object?object:baseSet(object,path,value)},lodash.setWith=function(object,path,value,customizer){return customizer="function"==typeof customizer?customizer:undefined,null==object?object:baseSet(object,path,value,customizer)},lodash.shuffle=function(collection){return(isArray(collection)?arrayShuffle:baseShuffle)(collection)},lodash.slice=function(array,start,end){var length=null==array?0:array.length;return length?(end&&"number"!=typeof end&&isIterateeCall(array,start,end)?(start=0,end=length):(start=null==start?0:toInteger(start),end=end===undefined?length:toInteger(end)),baseSlice(array,start,end)):[]},lodash.sortBy=sortBy,lodash.sortedUniq=function(array){return array&&array.length?baseSortedUniq(array):[]},lodash.sortedUniqBy=function(array,iteratee){return array&&array.length?baseSortedUniq(array,getIteratee(iteratee,2)):[]},lodash.split=function(string,separator,limit){return limit&&"number"!=typeof limit&&isIterateeCall(string,separator,limit)&&(separator=limit=undefined),(limit=limit===undefined?MAX_ARRAY_LENGTH:limit>>>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<nativeMax(start,end)}(number=toNumber(number),start,end)},lodash.invoke=invoke,lodash.isArguments=isArguments,lodash.isArray=isArray,lodash.isArrayBuffer=isArrayBuffer,lodash.isArrayLike=isArrayLike,lodash.isArrayLikeObject=isArrayLikeObject,lodash.isBoolean=function(value){return!0===value||!1===value||isObjectLike(value)&&baseGetTag(value)==boolTag},lodash.isBuffer=isBuffer,lodash.isDate=isDate,lodash.isElement=function(value){return isObjectLike(value)&&1===value.nodeType&&!isPlainObject(value)},lodash.isEmpty=function(value){if(null==value)return!0;if(isArrayLike(value)&&(isArray(value)||"string"==typeof value||"function"==typeof value.splice||isBuffer(value)||isTypedArray(value)||isArguments(value)))return!value.length;var tag=getTag(value);if(tag==mapTag||tag==setTag)return!value.size;if(isPrototype(value))return!baseKeys(value).length;for(var key in value)if(hasOwnProperty.call(value,key))return!1;return!0},lodash.isEqual=function(value,other){return baseIsEqual(value,other)},lodash.isEqualWith=function(value,other,customizer){var result=(customizer="function"==typeof customizer?customizer:undefined)?customizer(value,other):undefined;return result===undefined?baseIsEqual(value,other,undefined,customizer):!!result},lodash.isError=isError,lodash.isFinite=function(value){return"number"==typeof value&&nativeIsFinite(value)},lodash.isFunction=isFunction,lodash.isInteger=isInteger,lodash.isLength=isLength,lodash.isMap=isMap,lodash.isMatch=function(object,source){return object===source||baseIsMatch(object,source,getMatchData(source))},lodash.isMatchWith=function(object,source,customizer){return customizer="function"==typeof customizer?customizer:undefined,baseIsMatch(object,source,getMatchData(source),customizer)},lodash.isNaN=function(value){return isNumber(value)&&value!=+value},lodash.isNative=function(value){if(isMaskable(value))throw new Error(CORE_ERROR_TEXT);return baseIsNative(value)},lodash.isNil=function(value){return null==value},lodash.isNull=function(value){return null===value},lodash.isNumber=isNumber,lodash.isObject=isObject,lodash.isObjectLike=isObjectLike,lodash.isPlainObject=isPlainObject,lodash.isRegExp=isRegExp,lodash.isSafeInteger=function(value){return isInteger(value)&&value>=-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&&strLength<length?string+createPadding(length-strLength,chars):string},lodash.padStart=function(string,length,chars){string=toString(string);var strLength=(length=toInteger(length))?stringSize(string):0;return length&&strLength<length?createPadding(length-strLength,chars)+string:string},lodash.parseInt=function(string,radix,guard){return guard||null==radix?radix=0:radix&&(radix=+radix),nativeParseInt(toString(string).replace(reTrimStart,""),radix||0)},lodash.random=function(lower,upper,floating){if(floating&&"boolean"!=typeof floating&&isIterateeCall(lower,upper,floating)&&(upper=floating=undefined),floating===undefined&&("boolean"==typeof upper?(floating=upper,upper=undefined):"boolean"==typeof lower&&(floating=lower,lower=undefined)),lower===undefined&&upper===undefined?(lower=0,upper=1):(lower=toFinite(lower),upper===undefined?(upper=lower,lower=0):upper=toFinite(upper)),lower>upper){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);++index<length;){var value=null==object?undefined:object[toKey(path[index])];value===undefined&&(index=length,value=defaultValue),object=isFunction(value)?value.call(object):value}return object},lodash.round=round,lodash.runInContext=runInContext,lodash.sample=function(collection){return(isArray(collection)?arraySample:baseSample)(collection)},lodash.size=function(collection){if(null==collection)return 0;if(isArrayLike(collection))return isString(collection)?stringSize(collection):collection.length;var tag=getTag(collection);return tag==mapTag||tag==setTag?collection.size:baseKeys(collection).length},lodash.snakeCase=snakeCase,lodash.some=function(collection,predicate,guard){var func=isArray(collection)?arraySome:baseSome;return guard&&isIterateeCall(collection,predicate,guard)&&(predicate=undefined),func(collection,getIteratee(predicate,3))},lodash.sortedIndex=function(array,value){return baseSortedIndex(array,value)},lodash.sortedIndexBy=function(array,value,iteratee){return baseSortedIndexBy(array,value,getIteratee(iteratee,2))},lodash.sortedIndexOf=function(array,value){var length=null==array?0:array.length;if(length){var index=baseSortedIndex(array,value);if(index<length&&eq(array[index],value))return index}return-1},lodash.sortedLastIndex=function(array,value){return baseSortedIndex(array,value,!0)},lodash.sortedLastIndexBy=function(array,value,iteratee){return baseSortedIndexBy(array,value,getIteratee(iteratee,2),!0)},lodash.sortedLastIndexOf=function(array,value){if(null==array?0:array.length){var index=baseSortedIndex(array,value,!0)-1;if(eq(array[index],value))return index}return-1},lodash.startCase=startCase,lodash.startsWith=function(string,target,position){return string=toString(string),position=null==position?0:baseClamp(toInteger(position),0,string.length),target=baseToString(target),string.slice(position,position+target.length)==target},lodash.subtract=subtract,lodash.sum=function(array){return array&&array.length?baseSum(array,identity):0},lodash.sumBy=function(array,iteratee){return array&&array.length?baseSum(array,getIteratee(iteratee,2)):0},lodash.template=function(string,options,guard){var settings=lodash.templateSettings;guard&&isIterateeCall(string,options,guard)&&(options=undefined),string=toString(string),options=assignInWith({},options,settings,customDefaultsAssignIn);var isEscaping,isEvaluating,imports=assignInWith({},options.imports,settings.imports,customDefaultsAssignIn),importsKeys=keys(imports),importsValues=baseValues(imports,importsKeys),index=0,interpolate=options.interpolate||reNoMatch,source="__p += '",reDelimiters=RegExp((options.escape||reNoMatch).source+"|"+interpolate.source+"|"+(interpolate===reInterpolate?reEsTemplate:reNoMatch).source+"|"+(options.evaluate||reNoMatch).source+"|$","g"),sourceURL="//# sourceURL="+("sourceURL"in options?options.sourceURL:"lodash.templateSources["+ ++templateCounter+"]")+"\n";string.replace(reDelimiters,(function(match,escapeValue,interpolateValue,esTemplateValue,evaluateValue,offset){return interpolateValue||(interpolateValue=esTemplateValue),source+=string.slice(index,offset).replace(reUnescapedString,escapeStringChar),escapeValue&&(isEscaping=!0,source+="' +\n__e("+escapeValue+") +\n'"),evaluateValue&&(isEvaluating=!0,source+="';\n"+evaluateValue+";\n__p += '"),interpolateValue&&(source+="' +\n((__t = ("+interpolateValue+")) == null ? '' : __t) +\n'"),index=offset+match.length,match})),source+="';\n";var variable=options.variable;variable||(source="with (obj) {\n"+source+"\n}\n"),source=(isEvaluating?source.replace(reEmptyStringLeading,""):source).replace(reEmptyStringMiddle,"$1").replace(reEmptyStringTrailing,"$1;"),source="function("+(variable||"obj")+") {\n"+(variable?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(isEscaping?", __e = _.escape":"")+(isEvaluating?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+source+"return __p\n}";var result=attempt((function(){return Function(importsKeys,sourceURL+"return "+source).apply(undefined,importsValues)}));if(result.source=source,isError(result))throw result;return result},lodash.times=function(n,iteratee){if((n=toInteger(n))<1||n>MAX_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<n;)iteratee(index);return result},lodash.toFinite=toFinite,lodash.toInteger=toInteger,lodash.toLength=toLength,lodash.toLower=function(value){return toString(value).toLowerCase()},lodash.toNumber=toNumber,lodash.toSafeInteger=function(value){return value?baseClamp(toInteger(value),-MAX_SAFE_INTEGER,MAX_SAFE_INTEGER):0===value?value:0},lodash.toString=toString,lodash.toUpper=function(value){return toString(value).toUpperCase()},lodash.trim=function(string,chars,guard){if((string=toString(string))&&(guard||chars===undefined))return string.replace(reTrim,"");if(!string||!(chars=baseToString(chars)))return string;var strSymbols=stringToArray(string),chrSymbols=stringToArray(chars);return castSlice(strSymbols,charsStartIndex(strSymbols,chrSymbols),charsEndIndex(strSymbols,chrSymbols)+1).join("")},lodash.trimEnd=function(string,chars,guard){if((string=toString(string))&&(guard||chars===undefined))return string.replace(reTrimEnd,"");if(!string||!(chars=baseToString(chars)))return string;var strSymbols=stringToArray(string);return castSlice(strSymbols,0,charsEndIndex(strSymbols,stringToArray(chars))+1).join("")},lodash.trimStart=function(string,chars,guard){if((string=toString(string))&&(guard||chars===undefined))return string.replace(reTrimStart,"");if(!string||!(chars=baseToString(chars)))return string;var strSymbols=stringToArray(string);return castSlice(strSymbols,charsStartIndex(strSymbols,stringToArray(chars))).join("")},lodash.truncate=function(string,options){var length=DEFAULT_TRUNC_LENGTH,omission=DEFAULT_TRUNC_OMISSION;if(isObject(options)){var separator="separator"in options?options.separator:separator;length="length"in options?toInteger(options.length):length,omission="omission"in options?baseToString(options.omission):omission}var strLength=(string=toString(string)).length;if(hasUnicode(string)){var strSymbols=stringToArray(string);strLength=strSymbols.length}if(length>=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,(source={},baseForOwn(lodash,(function(func,methodName){hasOwnProperty.call(lodash.prototype,methodName)||(source[methodName]=func)})),source),{chain:!1}),lodash.VERSION="4.17.11",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){var index=-1,length=transforms.length;for(;++index<length;){var data=transforms[index],size=data.size;switch(data.type){case"drop":start+=size;break;case"dropRight":end-=size;break;case"take":end=nativeMin(end,start+size);break;case"takeRight":start=nativeMax(start,end-size)}}return{start:start,end:end}}(0,arrLength,this.__views__),start=view.start,end=view.end,length=end-start,index=isRight?end:start-1,iteratees=this.__iteratees__,iterLength=iteratees.length,resIndex=0,takeCount=nativeMin(length,this.__takeCount__);if(!isArr||!isRight&&arrLength==length&&takeCount==length)return baseWrapperValue(array,this.__actions__);var result=[];outer:for(;length--&&resIndex<takeCount;){for(var iterIndex=-1,value=array[index+=dir];++iterIndex<iterLength;){var data=iteratees[iterIndex],iteratee=data.iteratee,type=data.type,computed=iteratee(value);if(type==LAZY_MAP_FLAG)value=computed;else if(!computed){if(type==LAZY_FILTER_FLAG)continue outer;break outer}}result[resIndex++]=value}return result},lodash.prototype.at=wrapperAt,lodash.prototype.chain=function(){return chain(this)},lodash.prototype.commit=function(){return new LodashWrapper(this.value(),this.__chain__)},lodash.prototype.next=function(){this.__values__===undefined&&(this.__values__=toArray(this.value()));var done=this.__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:{})},{}],253:[function(require,module,exports){arguments[4][108][0].apply(exports,arguments)},{dup:108}],254:[function(require,module,exports){arguments[4][109][0].apply(exports,arguments)},{dup:109}],255:[function(require,module,exports){arguments[4][144][0].apply(exports,arguments)},{buffer:51,dup:144}],256:[function(require,module,exports){const{crypto:crypto,encoding:encoding,PrivateKey:PrivateKey}=require("bitcore-lib-p256"),{getPublicKeyFromPrivateKey:getPublicKeyFromPrivateKey}=require("./Api"),{Buffer:Buffer}=require("buffer"),{compress:compress}=require("./Utils"),{BN:BN,Hash:Hash}=crypto,{Base58Check:Base58Check}=encoding,signTypeMap={ELA_STANDARD:{type:172,address:33},ELA_MULTISIG:{type:174,address:18},ELA_CROSSCHAIN:{type:175,address:72},ELA_IDCHAIN:{type:173,address:103},ELA_DESTROY:{type:170,address:0}},sortBigNumber=(a,b)=>{const bBigInt=BN.fromBuffer(Buffer.from(a,"hex").slice(1)),aBigInt=BN.fromBuffer(Buffer.from(b,"hex").slice(1));return bBigInt.gt(aBigInt)},toCode=(pubKeyBuf,signType)=>Buffer.concat([Buffer.from([33]),pubKeyBuf,Buffer.from([signType])]),getAddressBase=(pubKey,signType)=>{const pubKeyBuf=new Buffer(pubKey,"hex"),code=toCode(pubKeyBuf,signTypeMap[signType].type),hashBuf=Hash.sha256ripemd160(code),programHashBuf=Buffer.concat([Buffer.from([signTypeMap[signType].address]),hashBuf]);return Base58Check.encode(programHashBuf)},getAddress=pubKey=>getAddressBase(pubKey,"ELA_STANDARD");module.exports={toCode:toCode,getAddress:getAddress,getAddressFromPrivateKey:prvKey=>{const prvKeyBuf=Buffer.from(prvKey,"hex"),pubKeyObj=getPublicKeyFromPrivateKey(prvKeyBuf);return getAddress(compress(pubKeyObj))},getDid:pubKey=>getAddressBase(pubKey,"ELA_IDCHAIN"),getMultiSignAddress:(pubKeys,requiredCount)=>{const keysCount=pubKeys.length,sortedPubKeys=pubKeys.sort(sortBigNumber);let buf=Buffer.from([81+requiredCount-1]);sortedPubKeys.forEach(pub=>{const pubInHex=Buffer.from(pub,"hex");buf=Buffer.concat([buf,Buffer.from([pubInHex.length]),pubInHex])}),buf=Buffer.concat([buf,Buffer.from([81+keysCount-1,174])]);const hashBuf=Hash.sha256ripemd160(buf),programHashBuf=Buffer.concat([Buffer.from([18]),hashBuf]);return Base58Check.encode(programHashBuf)}}},{"./Api":257,"./Utils":258,"bitcore-lib-p256":169,buffer:51}],257:[function(require,module,exports){const{HDPrivateKey:HDPrivateKey,HDPublicKey:HDPublicKey,PublicKey:PublicKey,PrivateKey:PrivateKey,crypto:crypto}=require("bitcore-lib-p256"),{Buffer:Buffer}=require("buffer"),{ecdsa:ecdsa,hash:hash}=crypto,rs=require("jsrsasign"),{uncompress:uncompress}=require("./Utils"),getRootMultiWallet=(seed,coinType=2305)=>{const prvKey=HDPrivateKey.fromSeed(seed);return new HDPrivateKey(prvKey.xprivkey).deriveChild(44,!0).deriveChild(coinType,!0).deriveChild(0,!0)},getAccountExtendedMultiWallet=(seed,coinType=2305,account=0)=>{const prvKey=HDPrivateKey.fromSeed(seed);return new HDPrivateKey(prvKey.xprivkey).deriveChild(44,!0).deriveChild(coinType,!0).deriveChild(account,!0)},getBip32RootMultiWallet=(seed,coinType=2305,account=0,changeChain=0)=>{const prvKey=HDPrivateKey.fromSeed(seed);return new HDPrivateKey(prvKey.xprivkey).deriveChild(44,!0).deriveChild(coinType,!0).deriveChild(account,!0).deriveChild(changeChain,!1)},getDidWallet=(seed,index)=>{const prvKey=HDPrivateKey.fromSeed(seed);return new HDPrivateKey(prvKey.xprivkey).deriveChild(0,!0).deriveChild(0,!1).deriveChild(index,!1)},getSingleWallet=seed=>getMultiWallet(seed,2305,0,0,0),getMultiWallet=(seed,coinType,account,changeChain,index)=>{const prvKey=HDPrivateKey.fromSeed(seed);return new HDPrivateKey(prvKey.xprivkey).deriveChild(44,!0).deriveChild(coinType||2305,!0).deriveChild(account,!0).deriveChild(changeChain||0,!1).deriveChild(index||0,!1)};module.exports={getMasterPrivateKey:(seed,coinType=2305)=>getRootMultiWallet(seed,coinType).xprivkey,getMasterPublicKey:(seed,coinType=2305)=>getRootMultiWallet(seed,coinType).xpubkey,getBip32ExtendedPrivateKey:(seed,coinType=2305,account=0,changeChain=0)=>getBip32RootMultiWallet(seed,coinType,account,changeChain).xprivkey,getBip32ExtendedPublicKey:(seed,coinType=2305,account=0,changeChain=0)=>getBip32RootMultiWallet(seed,coinType,account,changeChain).xpubkey,getAccountExtendedPrivateKey:(seed,coinType=2305,account=0)=>getAccountExtendedMultiWallet(seed,coinType,account).xprivkey,getAccountExtendedPublicKey:(seed,coinType=2305,account=0)=>getAccountExtendedMultiWallet(seed,coinType,account).xpubkey,getDerivedPrivateKey:(seed,coinType,account,changeChain,index)=>getMultiWallet(seed,coinType,account,changeChain,index).privateKey,getDerivedPublicKey:(masterPublicKey,changeChain,index)=>{return new HDPublicKey(masterPublicKey).deriveChild(changeChain||0).deriveChild(index).publicKey},getRootPrivateKey:(seed,coinType=2305)=>{return HDPrivateKey.fromSeed(seed).xprivkey},getSinglePrivateKey:seed=>getSingleWallet(seed).privateKey,getSinglePublicKey:seed=>getSingleWallet(seed).publicKey,getPublicKeyFromPrivateKey:prvKey=>PrivateKey.fromBuffer(prvKey).publicKey,generateSubPrivateKey:(seed,coinType,changeChain,index)=>getMultiWallet(seed,coinType,0,changeChain,index).privateKey,generateSubPublicKey:(masterPublicKey,changeChain,index)=>{return new HDPublicKey(masterPublicKey).deriveChild(changeChain||0).deriveChild(index).publicKey},getIdChainMasterPublicKey:seed=>{const prvKey=HDPrivateKey.fromSeed(seed);return new HDPrivateKey(prvKey.xprivkey).deriveChild(0,!0).publicKey},generateIdChainSubPrivateKey:(seed,index)=>getDidWallet(seed,index).privateKey,generateIdChainSubPublicKey:(masterPublicKey,index)=>getDidWallet(seed,index).publicKey,sign:(data,prvKey,hex=!1)=>{hex||(data=Buffer.from(data,"utf8").toString("hex"));var signer=new rs.KJUR.crypto.Signature({alg:"SHA256withECDSA"});signer.init({d:prvKey,curve:"secp256r1"}),signer.updateHex(data);var signature=signer.sign();return rs.ECDSA.asn1SigToConcatSig(signature)},verify:(data,signature,pubKey,hex=!1)=>{hex||(data=Buffer.from(data,"utf8").toString("hex"));const pubKeyObj=PublicKey.fromString(pubKey),signer=new rs.KJUR.crypto.Signature({alg:"SHA256withECDSA"});return signer.init({xy:uncompress(pubKeyObj).toString("hex"),curve:"secp256r1"}),signer.updateHex(data),signer.verify(rs.ECDSA.concatSigToASN1Sig(signature))}}},{"./Utils":258,"bitcore-lib-p256":169,buffer:51,jsrsasign:251}],258:[function(require,module,exports){(function(Buffer){module.exports={compress:key=>{if(key.compressed)throw new Error("Publick key is already compressed.");const x=key.point.getX(),y=key.point.getY(),xbuf=x.toBuffer({size:32}),ybuf=y.toBuffer({size:32});let prefix;const odd=ybuf[ybuf.length-1]%2;return prefix=new Buffer(odd?[3]:[2]),Buffer.concat([prefix,xbuf])},uncompress:key=>{if(!key.compressed)throw new Error("Publick key is not compressed.");const x=key.point.getX(),y=key.point.getY(),xbuf=x.toBuffer({size:32}),ybuf=y.toBuffer({size:32});return Buffer.concat([Buffer.from([4]),xbuf,ybuf])},reverseByteBuffer:buffer=>{for(var i=0,j=buffer.length-1;i<j;++i,--j){var t=buffer[j];buffer[j]=buffer[i],buffer[i]=t}return buffer}}}).call(this,require("buffer").Buffer)},{buffer:51}]},{},[167])(167)})); | ||
diff --git a/src/js/index.js b/src/js/index.js index dc10d59..9ace962 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -607,7 +607,7 @@ | |||
607 | extendedKey = extendedKey.derive(index); | 607 | extendedKey = extendedKey.derive(index); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | return extendedKey | 610 | return extendedKey; |
611 | } | 611 | } |
612 | 612 | ||
613 | function showValidationError(errorText) { | 613 | function showValidationError(errorText) { |
@@ -650,9 +650,9 @@ | |||
650 | } | 650 | } |
651 | 651 | ||
652 | function validateRootKey(rootKeyBase58) { | 652 | function validateRootKey(rootKeyBase58) { |
653 | if(isGRS()) | 653 | if(isGRS()) |
654 | return validateRootKeyGRS(rootKeyBase58); | 654 | return validateRootKeyGRS(rootKeyBase58); |
655 | 655 | ||
656 | // try various segwit network params since this extended key may be from | 656 | // try various segwit network params since this extended key may be from |
657 | // any one of them. | 657 | // any one of them. |
658 | if (networkHasSegwit()) { | 658 | if (networkHasSegwit()) { |
@@ -848,6 +848,10 @@ | |||
848 | return networks[DOM.network.val()].name == "GRS - Groestlcoin" || networks[DOM.network.val()].name == "GRS - Groestlcoin Testnet"; | 848 | return networks[DOM.network.val()].name == "GRS - Groestlcoin" || networks[DOM.network.val()].name == "GRS - Groestlcoin Testnet"; |
849 | } | 849 | } |
850 | 850 | ||
851 | function isELA() { | ||
852 | return networks[DOM.network.val()].name == "ELA - Elastos" | ||
853 | } | ||
854 | |||
851 | function displayBip44Info() { | 855 | function displayBip44Info() { |
852 | // Get the derivation path for the account | 856 | // Get the derivation path for the account |
853 | var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44); | 857 | var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44); |
@@ -861,9 +865,14 @@ | |||
861 | var accountExtendedKey = calcBip32ExtendedKey(path); | 865 | var accountExtendedKey = calcBip32ExtendedKey(path); |
862 | var accountXprv = accountExtendedKey.toBase58(); | 866 | var accountXprv = accountExtendedKey.toBase58(); |
863 | var accountXpub = accountExtendedKey.neutered().toBase58(); | 867 | var accountXpub = accountExtendedKey.neutered().toBase58(); |
868 | |||
864 | // Display the extended keys | 869 | // Display the extended keys |
865 | DOM.bip44accountXprv.val(accountXprv); | 870 | DOM.bip44accountXprv.val(accountXprv); |
866 | DOM.bip44accountXpub.val(accountXpub); | 871 | DOM.bip44accountXpub.val(accountXpub); |
872 | |||
873 | if (isELA()) { | ||
874 | displayBip44InfoForELA(); | ||
875 | } | ||
867 | } | 876 | } |
868 | 877 | ||
869 | function displayBip49Info() { | 878 | function displayBip49Info() { |
@@ -919,6 +928,10 @@ | |||
919 | clearAddressesList(); | 928 | clearAddressesList(); |
920 | var initialAddressCount = parseInt(DOM.rowsToAdd.val()); | 929 | var initialAddressCount = parseInt(DOM.rowsToAdd.val()); |
921 | displayAddresses(0, initialAddressCount); | 930 | displayAddresses(0, initialAddressCount); |
931 | |||
932 | if (isELA()) { | ||
933 | displayBip32InfoForELA(); | ||
934 | } | ||
922 | } | 935 | } |
923 | 936 | ||
924 | function displayAddresses(start, total) { | 937 | function displayAddresses(start, total) { |
@@ -1004,7 +1017,7 @@ | |||
1004 | privkey = keyPair.toWIF(); | 1017 | privkey = keyPair.toWIF(); |
1005 | // BIP38 encode private key if required | 1018 | // BIP38 encode private key if required |
1006 | if (useBip38) { | 1019 | if (useBip38) { |
1007 | if(isGRS()) | 1020 | if(isGRS()) |
1008 | privkey = groestlcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) { | 1021 | privkey = groestlcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) { |
1009 | console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index); | 1022 | console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index); |
1010 | }, null, networks[DOM.network.val()].name.includes("Testnet")); | 1023 | }, null, networks[DOM.network.val()].name.includes("Testnet")); |
@@ -1135,10 +1148,23 @@ | |||
1135 | else if (isP2wpkhInP2sh) { | 1148 | else if (isP2wpkhInP2sh) { |
1136 | address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network) | 1149 | address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network) |
1137 | } | 1150 | } |
1138 | } | 1151 | } |
1139 | //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey | 1152 | //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey |
1140 | } | 1153 | } |
1141 | 1154 | ||
1155 | if (isELA()) { | ||
1156 | let elaAddress = calcAddressForELA( | ||
1157 | seed, | ||
1158 | parseIntNoNaN(DOM.bip44coin.val(), 0), | ||
1159 | parseIntNoNaN(DOM.bip44account.val(), 0), | ||
1160 | parseIntNoNaN(DOM.bip44change.val(), 0), | ||
1161 | index | ||
1162 | ); | ||
1163 | address = elaAddress.address; | ||
1164 | privkey = elaAddress.privateKey; | ||
1165 | pubkey = elaAddress.publicKey; | ||
1166 | } | ||
1167 | |||
1142 | addAddressToList(indexText, address, pubkey, privkey); | 1168 | addAddressToList(indexText, address, pubkey, privkey); |
1143 | if (isLast) { | 1169 | if (isLast) { |
1144 | hidePending(); | 1170 | hidePending(); |
@@ -2212,6 +2238,13 @@ | |||
2212 | }, | 2238 | }, |
2213 | }, | 2239 | }, |
2214 | { | 2240 | { |
2241 | name: "ELA - Elastos", | ||
2242 | onSelect: function () { | ||
2243 | network = bitcoinjs.bitcoin.networks.elastos; | ||
2244 | setHdCoin(2305); | ||
2245 | }, | ||
2246 | }, | ||
2247 | { | ||
2215 | name: "ELLA - Ellaism", | 2248 | name: "ELLA - Ellaism", |
2216 | segwitAvailable: false, | 2249 | segwitAvailable: false, |
2217 | onSelect: function() { | 2250 | onSelect: function() { |
@@ -3119,6 +3152,56 @@ | |||
3119 | } | 3152 | } |
3120 | ] | 3153 | ] |
3121 | 3154 | ||
3155 | // ELA - Elastos functions - begin | ||
3156 | function displayBip44InfoForELA() { | ||
3157 | if (!isELA()) { | ||
3158 | return; | ||
3159 | } | ||
3160 | |||
3161 | var coin = parseIntNoNaN(DOM.bip44coin.val(), 0); | ||
3162 | var account = parseIntNoNaN(DOM.bip44account.val(), 0); | ||
3163 | |||
3164 | // Calculate the account extended keys | ||
3165 | var accountXprv = elastosjs.getAccountExtendedPrivateKey(seed, coin, account); | ||
3166 | var accountXpub = elastosjs.getAccountExtendedPublicKey(seed, coin, account); | ||
3167 | |||
3168 | // Display the extended keys | ||
3169 | DOM.bip44accountXprv.val(accountXprv); | ||
3170 | DOM.bip44accountXpub.val(accountXpub); | ||
3171 | } | ||
3172 | |||
3173 | function displayBip32InfoForELA() { | ||
3174 | if (!isELA()) { | ||
3175 | return; | ||
3176 | } | ||
3177 | |||
3178 | var coin = parseIntNoNaN(DOM.bip44coin.val(), 0); | ||
3179 | var account = parseIntNoNaN(DOM.bip44account.val(), 0); | ||
3180 | var change = parseIntNoNaN(DOM.bip44change.val(), 0); | ||
3181 | |||
3182 | DOM.extendedPrivKey.val(elastosjs.getBip32ExtendedPrivateKey(seed, coin, account, change)); | ||
3183 | DOM.extendedPubKey.val(elastosjs.getBip32ExtendedPublicKey(seed, coin, account, change)); | ||
3184 | |||
3185 | // Display the addresses and privkeys | ||
3186 | clearAddressesList(); | ||
3187 | var initialAddressCount = parseInt(DOM.rowsToAdd.val()); | ||
3188 | displayAddresses(0, initialAddressCount); | ||
3189 | } | ||
3190 | |||
3191 | function calcAddressForELA(seed, coin, account, change, index) { | ||
3192 | if (!isELA()) { | ||
3193 | return; | ||
3194 | } | ||
3195 | |||
3196 | var publicKey = elastosjs.getDerivedPublicKey(elastosjs.getMasterPublicKey(seed), change, index); | ||
3197 | return { | ||
3198 | privateKey: elastosjs.getDerivedPrivateKey(seed, coin, account, change, index), | ||
3199 | publicKey: publicKey, | ||
3200 | address: elastosjs.getAddress(publicKey.toString('hex')) | ||
3201 | }; | ||
3202 | } | ||
3203 | // ELA - Elastos functions - end | ||
3204 | |||
3122 | init(); | 3205 | init(); |
3123 | 3206 | ||
3124 | })(); | 3207 | })(); |