if(!(thisinstanceofE))throwError("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:g(a,!0)}),this._prepare()};E.prototype._prepare=function(){vara=o[this.key.length];if(null==a)thrownewError("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(varb=0;b<=a;b++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(varc,d=4*(a+1),e=this.key.length/4,f=j(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(varg,h=0,i=e;i<d;){if(g=f[e-1],f[0]^=q[g>>16&255]<<24^q[g>>8&255]<<16^q[255&g]<<8^q[g>>24&255]^p[h]<<24,h+=1,8!=e)for(varb=1;b<e;b++)f[b]^=f[b-1];else{for(varb=1;b<e/2;b++)f[b]^=f[b-1];g=f[e/2-1],f[e/2]^=q[255&g]^q[g>>8&255]<<8^q[g>>16&255]<<16^q[g>>24&255]<<24;for(varb=e/2+1;b<e;b++)f[b]^=f[b-1]}for(vark,l,b=0;b<e&&i<d;)k=i>>2,l=i%4,this._Ke[k][l]=f[b],this._Kd[a-k][l]=f[b++],i++}for(vark=1;k<a;k++)for(varl=0;l<4;l++)g=this._Kd[k][l],this._Kd[k][l]=A[g>>24&255]^B[g>>16&255]^C[g>>8&255]^D[255&g]},E.prototype.encrypt=function(a){if(16!=a.length)thrownewError("invalid plaintext size (must be 16 bytes)");for(varb=this._Ke.length-1,c=[0,0,0,0],d=j(a),e=0;e<4;e++)d[e]^=this._Ke[0][e];for(varf=1;f<b;f++){for(vare=0;e<4;e++)c[e]=s[d[e]>>24&255]^t[d[(e+1)%4]>>16&255]^u[d[(e+2)%4]>>8&255]^v[255&d[(e+3)%4]]^this._Ke[f][e];d=c.slice()}for(varg,i=h(16),e=0;e<4;e++)g=this._Ke[b][e],i[4*e]=255&(q[d[e]>>24&255]^g>>24),i[4*e+1]=255&(q[d[(e+1)%4]>>16&255]^g>>16),i[4*e+2]=255&(q[d[(e+2)%4]>>8&255]^g>>8),i[4*e+3]=255&(q[255&d[(e+3)%4]]^g);returni},E.prototype.decrypt=function(a){if(16!=a.length)thrownewError("invalid ciphertext size (must be 16 bytes)");for(varb=this._Kd.length-1,c=[0,0,0,0],d=j(a),e=0;e<4;e++)d[e]^=this._Kd[0][e];for(varf=1;f<b;f++){for(vare=0;e<4;e++)c[e]=w[d[e]>>24&255]^x[d[(e+3)%4]>>16&255]^y[d[(e+2)%4]>>8&255]^z[255&d[(e+1)%4]]^this._Kd[f][e];d=c.slice()}for(varg,i=h(16),e=0;e<4;e++)g=this._Kd[b][e],i[4*e]=255&(r[d[e]>>24&255]^g>>24),i[4*e+1]=255&(r[d[(e+3)%4]>>16&255]^g>>16),i[4*e+2]=255&(r[d[(e+2)%4]>>8&255]^g>>8),i[4*e+3]=255&(r[255&d[(e+1)%4]]^g);returni};varF=function(a){if(!(thisinstanceofF))throwError("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=newE(a)};F.prototype.encrypt=function(a){if(a=g(a),a.length%16!==0)thrownewError("invalid plaintext size (must be multiple of 16 bytes)");for(varb=h(a.length),c=h(16),d=0;d<a.length;d+=16)i(a,c,0,d,d+16),c=this._aes.encrypt(c),i(c,b,d);returnb},F.prototype.decrypt=function(a){if(a=g(a),a.length%16!==0)thrownewError("invalid ciphertext size (must be multiple of 16 bytes)");for(varb=h(a.length),c=h(16),d=0;d<a.length;d+=16)i(a,c,0,d,d+16),c=this._aes.decrypt(c),i(c,b,d);returnb};varG=function(a,b){if(!(thisinstanceofG))throwError("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",b){if(16!=b.length)thrownewError("invalid initialation vector size (must be 16 bytes)")}elseb=h(16);this._lastCipherblock=g(b,!0),this._aes=newE(a)};G.prototype.encrypt=function(a){if(a=g(a),a.length%16!==0)thrownewError("invalid plaintext size (must be multiple of 16 bytes)");for(varb=h(a.length),c=h(16),d=0;d<a.length;d+=16){i(a,c,0,d,d+16);for(vare=0;e<16;e++)c[e]^=this._lastCipherblock[e];this._lastCipherblock=this._aes.encrypt(c),i(this._lastCipherblock,b,d)}returnb},G.prototype.decrypt=function(a){if(a=g(a),a.length%16!==0)thrownewError("invalid ciphertext size (must be multiple of 16 bytes)");for(varb=h(a.length),c=h(16),d=0;d<a.length;d+=16){i(a,c,0,d,d+16),c=this._aes.decrypt(c);for(vare=0;e<16;e++)b[d+e]=c[e]^this._lastCipherblock[e];i(a,this._lastCipherblock,0,d,d+16)}returnb};varH=function(a,b,c){if(!(thisinstanceofH))throwError("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",b){if(16!=b.length)thrownewError("invalid initialation vector size (must be 16 size)")}elseb=h(16);c||(c=1),this.segmentSize=c,this._shiftRegister=g(b,!0),this._aes=newE(a)};H.prototype.encrypt=function(a){if(a.length%
returni.fromPublic(this,a,b)},d.prototype.genKeyPair=function(a){a||(a={});for(varb=newf.hmacDRBG({hash:this.hash,pers:a.pers,entropy:a.entropy||f.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),c=this.n.byteLength(),d=this.n.sub(newe(2));;){varg=newe(b.generate(c));if(!(g.cmp(d)>0))returng.iaddn(1),this.keyFromPrivate(g)}},d.prototype._truncateToN=function(a,b){varc=8*a.byteLength()-this.n.bitLength();returnc>0&&(a=a.ushrn(c)),!b&&a.cmp(this.n)>=0?a.sub(this.n):a},d.prototype.sign=function(a,b,c,d){"object"==typeofc&&(d=c,c=null),d||(d={}),b=this.keyFromPrivate(b,c),a=this._truncateToN(newe(a,16));for(varg=this.n.byteLength(),h=b.getPrivate().toArray("be",g),i=a.toArray("be",g),k=newf.hmacDRBG({hash:this.hash,entropy:h,nonce:i,pers:d.pers,persEnc:d.persEnc}),l=this.n.sub(newe(1)),m=0;!0;m++){varn=d.k?d.k(m):newe(k.generate(this.n.byteLength()));if(n=this._truncateToN(n,!0),!(n.cmpn(1)<=0||n.cmp(l)>=0)){varo=this.g.mul(n);if(!o.isInfinity()){varp=o.getX(),q=p.umod(this.n);if(0!==q.cmpn(0)){varr=n.invm(this.n).mul(q.mul(b.getPrivate()).iadd(a));if(r=r.umod(this.n),0!==r.cmpn(0)){vars=(o.getY().isOdd()?1:0)|(0!==p.cmp(q)?2:0);returnd.canonical&&r.cmp(this.nh)>0&&(r=this.n.sub(r),s^=1),newj({r:q,s:r,recoveryParam:s})}}}}}},d.prototype.verify=function(a,b,c,d){a=this._truncateToN(newe(a,16)),c=this.keyFromPublic(c,d),b=newj(b,"hex");varf=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;varh=g.invm(this.n),i=h.mul(a).umod(this.n),k=h.mul(f).umod(this.n);if(!this.curve._maxwellTrick){varl=this.g.mulAdd(i,c.getPublic(),k);return!l.isInfinity()&&0===l.getX().umod(this.n).cmp(f)}varl=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=newj(b,d);varf=this.n,g=newe(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)thrownewError("Unable to find sencond key candinate");i=m?this.curve.pointFromX(i.add(this.curve.n),l):this.curve.pointFromX(i,l);varn=b.r.invm(f),o=f.sub(g).mul(n).umod(f),p=k.mul(n).umod(f);returnthis.g.mulAdd(o,i,p)},d.prototype.getKeyRecoveryParam=function(a,b,c,d){if(b=newj(b,d),null!==b.recoveryParam)returnb.recoveryParam;for(vare=0;e<4;e++){varf;try{f=this.recoverPubKey(a,b,e)}catch(a){continue}if(f.eq(c))returne}thrownewError("Unable to find valid recovery factor")}},{"../../elliptic":31,"./key":39,"./signature":40,"bn.js":29}],39:[function(a,b,c){"use strict";functiond(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)}vare=a("bn.js"),f=a("../../elliptic"),g=f.utils,h=g.assert;b.exports=d,d.fromPublic=function(a,b,c){returnbinstanceofd?b:newd(a,{pub:b,pubEnc:c})},d.fromPrivate=function(a,b,c){returnbinstanceofd?b:newd(a,{priv:b,privEnc:c})},d.prototype.validate=function(){vara=this.getPublic();returna.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"==typeofa&&(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=newe(a,b||16),this.priv=this.priv.umod(this.ec.curve.n)},d.prototype._importPublic=function(a,b){returna.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){returna.mul(this.priv).getX()},d.prototype.sign=function(a,b,c){returnthis.ec.sign(a,this,b,c)},d.prototype.verify=function(a,b){returnthis.ec.verify(a,b,this)},d.prototype.inspect=function(){return