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

6 lines
187 KiB
JavaScript
Raw Normal View History

2017-04-05 01:53:59 +03:00
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){b.exports=void 0},{}],2:[function(a,b,c){function d(a){"string"==typeof a&&a.match(/^0x[0-9A-Fa-f]{40}$/)||h("invalid address",{input:a}),a=a.toLowerCase();for(var b=a.substring(2).split(""),c=0;c<b.length;c++)b[c]=b[c].charCodeAt(0);b=g.arrayify(i(b)),a=a.substring(2).split("");for(var c=0;c<40;c+=2)b[c>>1]>>4>=8&&(a[c]=a[c].toUpperCase()),(15&b[c>>1])>=8&&(a[c+1]=a[c+1].toUpperCase());return"0x"+a.join("")}function e(a,b){var c=null;if("string"!=typeof a&&h("invalid address",{input:a}),a.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==a.substring(0,2)&&(a="0x"+a),c=d(a),a.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&c!==a&&h("invalid address checksum",{input:a,expected:c});else if(a.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(a.substring(2,4)!==j(a)&&h("invalid address icap checksum",{input:a}),c=new f(a.substring(4),36).toString(16);c.length<40;)c="0"+c;c=d("0x"+c)}else h("invalid address",{input:a});if(b){for(var e=new f(c.substring(2),16).toString(36).toUpperCase();e.length<30;)e="0"+e;return"XE"+j("XE00"+e)+e}return c}var f=a("bn.js"),g=a("./convert"),h=a("./throw-error"),i=a("./keccak256"),j=function(){for(var a={},b=0;b<10;b++)a[String(b)]=String(b);for(var b=0;b<26;b++)a[String.fromCharCode(65+b)]=String(10+b);var c=Math.floor(Math.log10(Number.MAX_SAFE_INTEGER));return function(b){b=b.toUpperCase(),b=b.substring(4)+b.substring(0,2)+"00";for(var d=b.split(""),e=0;e<d.length;e++)d[e]=a[d[e]];for(d=d.join("");d.length>=c;){var f=d.substring(0,c);d=parseInt(f,10)%97+d.substring(f.length)}for(var g=String(98-parseInt(d,10)%97);g.length<2;)g="0"+g;return g}}();b.exports={getAddress:e}},{"./convert":6,"./keccak256":9,"./throw-error":24,"bn.js":10}],3:[function(a,b,c){function d(a){if(!(this instanceof d))throw new Error("missing new");i.isHexString(a)?("0x"==a&&(a="0x0"),a=new g(a.substring(2),16)):"string"==typeof a&&a.match(/^-?[0-9]*$/)?(""==a&&(a="0"),a=new g(a)):"number"==typeof a&&parseInt(a)==a?a=new g(a):g.isBN(a)||(a instanceof d?a=a._bn:i.isArrayish(a)?a=new g(i.hexlify(a).substring(2),16):j("invalid BigNumber value",{input:a})),h(this,"_bn",a)}function e(a){return a instanceof d}function f(a){return a instanceof d?a:new d(a)}var g=a("bn.js"),h=a("./properties").defineProperty,i=a("./convert"),j=a("./throw-error");h(d,"constantNegativeOne",f(-1)),h(d,"constantZero",f(0)),h(d,"constantOne",f(1)),h(d,"constantTwo",f(2)),h(d,"constantWeiPerEther",f(new g("1000000000000000000"))),h(d.prototype,"fromTwos",function(a){return new d(this._bn.fromTwos(a))}),h(d.prototype,"toTwos",function(a){return new d(this._bn.toTwos(a))}),h(d.prototype,"add",function(a){return new d(this._bn.add(f(a)._bn))}),h(d.prototype,"sub",function(a){return new d(this._bn.sub(f(a)._bn))}),h(d.prototype,"div",function(a){return new d(this._bn.div(f(a)._bn))}),h(d.prototype,"mul",function(a){return new d(this._bn.mul(f(a)._bn))}),h(d.prototype,"mod",function(a){return new d(this._bn.mod(f(a)._bn))}),h(d.prototype,"maskn",function(a){return new d(this._bn.maskn(a))}),h(d.prototype,"eq",function(a){return this._bn.eq(f(a)._bn)}),h(d.prototype,"lt",function(a){return this._bn.lt(f(a)._bn)}),h(d.prototype,"lte",function(a){return this._bn.lte(f(a)._bn)}),h(d.prototype,"gte",function(a){return this._bn.gte(f(a)._bn)}),h(d.prototype,"isZero",function(){return this._bn.isZero()}),h(d.prototype,"toNumber",function(a){return this._bn.toNumber()}),h(d.prototype,"toString",function(){return this._bn.toString(10)}),h(d.prototype,"toHexString",function(){var a=this._bn.toString(16);return a.length%2&&(a="0"+a),"0x"+a}),b.exports={isBigNumber:e,bigNumberify:f}},{"./convert":6,"./properties":20,"./throw-error":24,"bn.js
for(var b=new Array(a),c=f.prototype._countBits(a)-1,d=0;d<a;d++)b[d]=this.revBin(d,c,a);return b},m.prototype.revBin=function(a,b,c){if(0===a||a===c-1)return a;for(var d=0,e=0;e<b;e++)d|=(1&a)<<b-e-1,a>>=1;return d},m.prototype.permute=function(a,b,c,d,e,f){for(var g=0;g<f;g++)d[g]=b[a[g]],e[g]=c[a[g]]},m.prototype.transform=function(a,b,c,d,e,f){this.permute(f,a,b,c,d,e);for(var g=1;g<e;g<<=1)for(var h=g<<1,i=Math.cos(2*Math.PI/h),j=Math.sin(2*Math.PI/h),k=0;k<e;k+=h)for(var l=i,m=j,n=0;n<g;n++){var o=c[k+n],p=d[k+n],q=c[k+n+g],r=d[k+n+g],s=l*q-m*r;r=l*r+m*q,q=s,c[k+n]=o+q,d[k+n]=p+r,c[k+n+g]=o-q,d[k+n+g]=p-r,n!==h&&(s=i*l-j*m,m=i*m+j*l,l=s)}},m.prototype.guessLen13b=function(a,b){var c=1|Math.max(b,a),d=1&c,e=0;for(c=c/2|0;c;c>>>=1)e++;return 1<<e+1+d},m.prototype.conjugate=function(a,b,c){if(!(c<=1))for(var d=0;d<c/2;d++){var e=a[d];a[d]=a[c-d-1],a[c-d-1]=e,e=b[d],b[d]=-b[c-d-1],b[c-d-1]=-e}},m.prototype.normalize13b=function(a,b){for(var c=0,d=0;d<b/2;d++){var e=8192*Math.round(a[2*d+1]/b)+Math.round(a[2*d]/b)+c;a[d]=67108863&e,c=e<67108864?0:e/67108864|0}return a},m.prototype.convert13b=function(a,b,c,e){for(var f=0,g=0;g<b;g++)f+=0|a[g],c[2*g]=8191&f,f>>>=13,c[2*g+1]=8191&f,f>>>=13;for(g=2*b;g<e;++g)c[g]=0;d(0===f),d(0===(f&-8192))},m.prototype.stub=function(a){for(var b=new Array(a),c=0;c<a;c++)b[c]=0;return b},m.prototype.mulp=function(a,b,c){var d=2*this.guessLen13b(a.length,b.length),e=this.makeRBT(d),f=this.stub(d),g=new Array(d),h=new Array(d),i=new Array(d),j=new Array(d),k=new Array(d),l=new Array(d),m=c.words;m.length=d,this.convert13b(a.words,a.length,g,d),this.convert13b(b.words,b.length,j,d),this.transform(g,f,h,i,d,e),this.transform(j,f,k,l,d,e);for(var n=0;n<d;n++){var o=h[n]*k[n]-i[n]*l[n];i[n]=h[n]*l[n]+i[n]*k[n],h[n]=o}return this.conjugate(h,i,d),this.transform(h,i,m,f,d,e),this.conjugate(m,f,d),this.normalize13b(m,d),c.negative=a.negative^b.negative,c.length=a.length+b.length,c.strip()},f.prototype.mul=function(a){var b=new f(null);return b.words=new Array(this.length+a.length),this.mulTo(a,b)},f.prototype.mulf=function(a){var b=new f(null);return b.words=new Array(this.length+a.length),l(this,a,b)},f.prototype.imul=function(a){return this.clone().mulTo(a,this)},f.prototype.imuln=function(a){d("number"==typeof a),d(a<67108864);for(var b=0,c=0;c<this.length;c++){var e=(0|this.words[c])*a,f=(67108863&e)+(67108863&b);b>>=26,b+=e/67108864|0,b+=f>>>26,this.words[c]=67108863&f}return 0!==b&&(this.words[c]=b,this.length++),this},f.prototype.muln=function(a){return this.clone().imuln(a)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(a){var b=i(a);if(0===b.length)return new f(1);for(var c=this,d=0;d<b.length&&0===b[d];d++,c=c.sqr());if(++d<b.length)for(var e=c.sqr();d<b.length;d++,e=e.sqr())0!==b[d]&&(c=c.mul(e));return c},f.prototype.iushln=function(a){d("number"==typeof a&&a>=0);var b,c=a%26,e=(a-c)/26,f=67108863>>>26-c<<26-c;if(0!==c){var g=0;for(b=0;b<this.length;b++){var h=this.words[b]&f,i=(0|this.words[b])-h<<c;this.words[b]=i|g,g=h>>>26-c}g&&(this.words[b]=g,this.length++)}if(0!==e){for(b=this.length-1;b>=0;b--)this.words[b+e]=this.words[b];for(b=0;b<e;b++)this.words[b]=0;this.length+=e}return this.strip()},f.prototype.ishln=function(a){return d(0===this.negative),this.iushln(a)},f.prototype.iushrn=function(a,b,c){d("number"==typeof a&&a>=0);var e;e=b?(b-b%26)/26:0;var f=a%26,g=Math.min((a-f)/26,this.length),h=67108863^67108863>>>f<<f,i=c;if(e-=g,e=Math.max(0,e),i){for(var j=0;j<g;j++)i.words[j]=this.words[j];i.length=g}if(0===g);else if(this.length>g)for(this.length-=g,j=0;j<this.length;j++)this.words[j]=this.words[j+g];else this.words[0]=0,this.length=1;var k=0;for(j=this.length-1;j>=0&&(0!==k||j>=e);j--){var l=0|this.words[j];this.words[j]=k<<26-f|l>>>f,k=l&h}return i&&0!==k&&(i.words[i.length++]=k),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(a,b,c){return d(0===this.negative),this.iushrn(a,b,c)},f.prototype.shln=function(a){return this.clone().ishln(a)},f.pro
var e=b+d;return e>>>0}function v(a,b,c,d,e,f,g,h){var i=0,j=b;j=j+d>>>0,i+=j<b?1:0,j=j+f>>>0,i+=j<f?1:0,j=j+h>>>0,i+=j<h?1:0;var k=a+c+e+g+i;return k>>>0}function w(a,b,c,d,e,f,g,h){var i=b+d+f+h;return i>>>0}function x(a,b,c,d,e,f,g,h,i,j){var k=0,l=b;l=l+d>>>0,k+=l<b?1:0,l=l+f>>>0,k+=l<f?1:0,l=l+h>>>0,k+=l<h?1:0,l=l+j>>>0,k+=l<j?1:0;var m=a+c+e+g+i+k;return m>>>0}function y(a,b,c,d,e,f,g,h,i,j){var k=b+d+f+h+j;return k>>>0}function z(a,b,c){var d=b<<32-c|a>>>c;return d>>>0}function A(a,b,c){var d=a<<32-c|b>>>c;return d>>>0}function B(a,b,c){return a>>>c}function C(a,b,c){var d=a<<32-c|b>>>c;return d>>>0}var D=c,E=a("inherits");D.toArray=d,D.toHex=e,D.htonl=f,D.toHex32=g,D.zero2=h,D.zero8=i,D.join32=j,D.split32=k,D.rotr32=l,D.rotl32=m,D.sum32=n,D.sum32_3=o,D.sum32_4=p,D.sum32_5=q,D.assert=r,D.inherits=E,c.sum64=s,c.sum64_hi=t,c.sum64_lo=u,c.sum64_4_hi=v,c.sum64_4_lo=w,c.sum64_5_hi=x,c.sum64_5_lo=y,c.rotr64_hi=z,c.rotr64_lo=A,c.shr64_hi=B,c.shr64_lo=C},{inherits:17}],17:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:b.exports=function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],18:[function(a,b,c){(function(a,c){!function(){"use strict";function d(a,b,c){this.blocks=[],this.s=[],this.padding=b,this.outputBits=c,this.reset=!0,this.block=0,this.start=0,this.blockCount=1600-(a<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=c>>5,this.extraBytes=(31&c)>>3;for(var d=0;d<50;++d)this.s[d]=0}var e="object"==typeof window?window:{},f=!e.JS_SHA3_NO_NODE_JS&&"object"==typeof a&&a.versions&&a.versions.node;f&&(e=c);for(var g=!e.JS_SHA3_NO_COMMON_JS&&"object"==typeof b&&b.exports,h="0123456789abcdef".split(""),i=[31,7936,2031616,520093696],j=[1,256,65536,16777216],k=[6,1536,393216,100663296],l=[0,8,16,24],m=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],n=[224,256,384,512],o=[128,256],p=["hex","buffer","arrayBuffer","array"],q=function(a,b,c){return function(e){return new d(a,b,a).update(e)[c]()}},r=function(a,b,c){return function(e,f){return new d(a,b,f).update(e)[c]()}},s=function(a,b){var c=q(a,b,"hex");c.create=function(){return new d(a,b,a)},c.update=function(a){return c.create().update(a)};for(var e=0;e<p.length;++e){var f=p[e];c[f]=q(a,b,f)}return c},t=function(a,b){var c=r(a,b,"hex");c.create=function(c){return new d(a,b,c)},c.update=function(a,b){return c.create(b).update(a)};for(var e=0;e<p.length;++e){var f=p[e];c[f]=r(a,b,f)}return c},u=[{name:"keccak",padding:j,bits:n,createMethod:s},{name:"sha3",padding:k,bits:n,createMethod:s},{name:"shake",padding:i,bits:o,createMethod:t}],v={},w=[],x=0;x<u.length;++x)for(var y=u[x],z=y.bits,A=0;A<z.length;++A){var B=y.name+"_"+z[A];w.push(B),v[B]=y.createMethod(z[A],y.padding)}d.prototype.update=function(a){var b="string"!=typeof a;b&&a.constructor===ArrayBuffer&&(a=new Uint8Array(a));for(var c,d,e=a.length,f=this.blocks,g=this.byteCount,h=this.blockCount,i=0,j=this.s;i<e;){if(this.reset)for(this.reset=!1,f[0]=this.block,c=1;c<h+1;++c)f[c]=0;if(b)for(c=this.start;i<e&&c<g;++i)f[c>>2]|=a[i]<<l[3&c++];else for(c=this.start;i<e&&c<g;++i)d=a.charCodeAt(i),d<128?f[c>>2]|=d<<l[3&c++]:d<2048?(f[c>>2]|=(192|d>>6)<<l[3&c++],f[c>>2]|=(128|63&d)<<l[3&c++]):d<55296||d>=57344?(f[c>>2]|=(224|d>>12)<<l[3&c++],f[c>>2]|=(128|d>>6&63)<<l[3&c++],f[c>>2]|=(128|63&d)<<l[3&c++]):(d=65536+((1023&d)<<10|1023&a.charCodeAt(++i)),f[c>>2]|=(240|d>>18)<<l[3&c++],f[c>>2]|=(128|d>>12&63)<<l[3&c++],f[c>>2]|=(128|d>>6&63)<<l[3&c++],f[c>>2]|=(128|63&d)<<l[3&c++]);if(this.lastByteIndex=c,c>=g){for(this.start=c-g,this.block=f[h],c=0;c<h;++c)j[c]^=f[c];C(j),this.reset=!0}else this.start=c}return this},d.pr
if(!(this instanceof D))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:f(a,!0)}),this._prepare()};D.prototype._prepare=function(){var a=n[this.key.length];if(null==a)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var b=0;b<=a;b++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var c,d=4*(a+1),e=this.key.length/4,f=i(this.key),b=0;b<e;b++)c=b>>2,this._Ke[c][b%4]=f[b],this._Kd[a-c][b%4]=f[b];for(var g,h=0,j=e;j<d;){if(g=f[e-1],f[0]^=p[g>>16&255]<<24^p[g>>8&255]<<16^p[255&g]<<8^p[g>>24&255]^o[h]<<24,h+=1,8!=e)for(var b=1;b<e;b++)f[b]^=f[b-1];else{for(var b=1;b<e/2;b++)f[b]^=f[b-1];g=f[e/2-1],f[e/2]^=p[255&g]^p[g>>8&255]<<8^p[g>>16&255]<<16^p[g>>24&255]<<24;for(var b=e/2+1;b<e;b++)f[b]^=f[b-1]}for(var k,l,b=0;b<e&&j<d;)k=j>>2,l=j%4,this._Ke[k][l]=f[b],this._Kd[a-k][l]=f[b++],j++}for(var k=1;k<a;k++)for(var l=0;l<4;l++)g=this._Kd[k][l],this._Kd[k][l]=z[g>>24&255]^A[g>>16&255]^B[g>>8&255]^C[255&g]},D.prototype.encrypt=function(a){if(16!=a.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var b=this._Ke.length-1,c=[0,0,0,0],d=i(a),e=0;e<4;e++)d[e]^=this._Ke[0][e];for(var f=1;f<b;f++){for(var e=0;e<4;e++)c[e]=r[d[e]>>24&255]^s[d[(e+1)%4]>>16&255]^t[d[(e+2)%4]>>8&255]^u[255&d[(e+3)%4]]^this._Ke[f][e];d=c.slice()}for(var h,j=g(16),e=0;e<4;e++)h=this._Ke[b][e],j[4*e]=255&(p[d[e]>>24&255]^h>>24),j[4*e+1]=255&(p[d[(e+1)%4]>>16&255]^h>>16),j[4*e+2]=255&(p[d[(e+2)%4]>>8&255]^h>>8),j[4*e+3]=255&(p[255&d[(e+3)%4]]^h);return j},D.prototype.decrypt=function(a){if(16!=a.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var b=this._Kd.length-1,c=[0,0,0,0],d=i(a),e=0;e<4;e++)d[e]^=this._Kd[0][e];for(var f=1;f<b;f++){for(var e=0;e<4;e++)c[e]=v[d[e]>>24&255]^w[d[(e+3)%4]>>16&255]^x[d[(e+2)%4]>>8&255]^y[255&d[(e+1)%4]]^this._Kd[f][e];d=c.slice()}for(var h,j=g(16),e=0;e<4;e++)h=this._Kd[b][e],j[4*e]=255&(q[d[e]>>24&255]^h>>24),j[4*e+1]=255&(q[d[(e+3)%4]>>16&255]^h>>16),j[4*e+2]=255&(q[d[(e+2)%4]>>8&255]^h>>8),j[4*e+3]=255&(q[255&d[(e+1)%4]]^h);return j};var E=function(a){if(!(this instanceof E))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new D(a)};E.prototype.encrypt=function(a){if(a=f(a),a.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var b=g(a.length),c=g(16),d=0;d<a.length;d+=16)h(a,c,0,d,d+16),c=this._aes.encrypt(c),h(c,b,d);return b},E.prototype.decrypt=function(a){if(a=f(a),a.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var b=g(a.length),c=g(16),d=0;d<a.length;d+=16)h(a,c,0,d,d+16),c=this._aes.decrypt(c),h(c,b,d);return b};var F=function(a,b){if(!(this instanceof F))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",b){if(16!=b.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else b=g(16);this._lastCipherblock=f(b,!0),this._aes=new D(a)};F.prototype.encrypt=function(a){if(a=f(a),a.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var b=g(a.length),c=g(16),d=0;d<a.length;d+=16){h(a,c,0,d,d+16);for(var e=0;e<16;e++)c[e]^=this._lastCipherblock[e];this._lastCipherblock=this._aes.encrypt(c),h(this._lastCipherblock,b,d)}return b},F.prototype.decrypt=function(a){if(a=f(a),a.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var b=g(a.length),c=g(16),d=0;d<a.length;d+=16){h(a,c,0,d,d+16),c=this._aes.decrypt(c);for(var e=0;e<16;e++)b[d+e]=c[e]^this._lastCipherblock[e];h(a,this._lastCipherblock,0,d,d+16)}return b};var G=function(a,b,c){if(!(this instanceof G))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",b){if(16!=b.length)throw new Error("invalid initialation vector size (must be 16 size)")}else b=g(16);c||(c=1),this.segmentSize=c,this._shiftRegister=f(b,!0),this._aes=new D(a)};G.prototype.encrypt=function(a){if(a.length%
persEnc:d.persEnc}),l=this.n.sub(new e(1)),m=0;!0;m++){var n=d.k?d.k(m):new e(k.generate(this.n.byteLength()));if(n=this._truncateToN(n,!0),!(n.cmpn(1)<=0||n.cmp(l)>=0)){var o=this.g.mul(n);if(!o.isInfinity()){var p=o.getX(),q=p.umod(this.n);if(0!==q.cmpn(0)){var r=n.invm(this.n).mul(q.mul(b.getPrivate()).iadd(a));if(r=r.umod(this.n),0!==r.cmpn(0)){var s=(o.getY().isOdd()?1:0)|(0!==p.cmp(q)?2:0);return d.canonical&&r.cmp(this.nh)>0&&(r=this.n.sub(r),s^=1),new j({r:q,s:r,recoveryParam:s})}}}}}},d.prototype.verify=function(a,b,c,d){a=this._truncateToN(new e(a,16)),c=this.keyFromPublic(c,d),b=new j(b,"hex");var f=b.r,g=b.s;if(f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;if(g.cmpn(1)<0||g.cmp(this.n)>=0)return!1;var h=g.invm(this.n),i=h.mul(a).umod(this.n),k=h.mul(f).umod(this.n);if(!this.curve._maxwellTrick){var l=this.g.mulAdd(i,c.getPublic(),k);return!l.isInfinity()&&0===l.getX().umod(this.n).cmp(f)}var l=this.g.jmulAdd(i,c.getPublic(),k);return!l.isInfinity()&&l.eqXToP(f)},d.prototype.recoverPubKey=function(a,b,c,d){h((3&c)===c,"The recovery param is more than two bits"),b=new j(b,d);var f=this.n,g=new e(a),i=b.r,k=b.s,l=1&c,m=c>>1;if(i.cmp(this.curve.p.umod(this.curve.n))>=0&&m)throw new Error("Unable to find sencond key candinate");i=m?this.curve.pointFromX(i.add(this.curve.n),l):this.curve.pointFromX(i,l);var n=b.r.invm(f),o=f.sub(g).mul(n).umod(f),p=k.mul(n).umod(f);return this.g.mulAdd(o,i,p)},d.prototype.getKeyRecoveryParam=function(a,b,c,d){if(b=new j(b,d),null!==b.recoveryParam)return b.recoveryParam;for(var e=0;e<4;e++){var f;try{f=this.recoverPubKey(a,b,e)}catch(a){continue}if(f.eq(c))return e}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":32,"./key":40,"./signature":41,"bn.js":30}],40:[function(a,b,c){"use strict";function d(a,b){this.ec=a,this.priv=null,this.pub=null,b.priv&&this._importPrivate(b.priv,b.privEnc),b.pub&&this._importPublic(b.pub,b.pubEnc)}var e=a("bn.js"),f=a("../../elliptic"),g=f.utils,h=g.assert;b.exports=d,d.fromPublic=function(a,b,c){return b instanceof d?b:new d(a,{pub:b,pubEnc:c})},d.fromPrivate=function(a,b,c){return b instanceof d?b:new d(a,{priv:b,privEnc:c})},d.prototype.validate=function(){var a=this.getPublic();return a.isInfinity()?{result:!1,reason:"Invalid public key"}:a.validate()?a.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"}},d.prototype.getPublic=function(a,b){return"string"==typeof a&&(b=a,a=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),b?this.pub.encode(b,a):this.pub},d.prototype.getPrivate=function(a){return"hex"===a?this.priv.toString(16,2):this.priv},d.prototype._importPrivate=function(a,b){this.priv=new e(a,b||16),this.priv=this.priv.umod(this.ec.curve.n)},d.prototype._importPublic=function(a,b){return a.x||a.y?("mont"===this.ec.curve.type?h(a.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||h(a.x&&a.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(a.x,a.y))):void(this.pub=this.ec.curve.decodePoint(a,b))},d.prototype.derive=function(a){return a.mul(this.priv).getX()},d.prototype.sign=function(a,b,c){return this.ec.sign(a,this,b,c)},d.prototype.verify=function(a,b){return this.ec.verify(a,b,this)},d.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},{"../../elliptic":32,"bn.js":30}],41:[function(a,b,c){"use strict";function d(a,b){return a instanceof d?a:void(this._importDER(a,b)||(l(a.r&&a.s,"Signature without r or s"),this.r=new i(a.r,16),this.s=new i(a.s,16),void 0===a.recoveryParam?this.recoveryParam=null:this.recoveryParam=a.recoveryParam))}function e(){this.place=0}function f(a,b){var c=a[b.place++];if(!(128&c))return c;for(var d=15&c,e=0,f=0,g=b.place;f<d;f++,g++)e<<=8,e|=a[g];return b.place=g,e}function g(a){for(var b=0,c=a.length-1;!a[b]&&!(128&a[b+1])&&b<c;)b++;return 0===b?a:a.slice(b)}function h(a,b){if(b<128)return void a.push(b);var c=1+(Math.log(b)/Math.LN2>>>3);for(a.push(128|c);--c;)a.push(
},{}]},{},[28]);