if(!(thisinstanceofD))throwError("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:f(a,!0)}),this._prepare()};D.prototype._prepare=function(){vara=n[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=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(varg,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(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]^=p[255&g]^p[g>>8&255]<<8^p[g>>16&255]<<16^p[g>>24&255]<<24;for(varb=e/2+1;b<e;b++)f[b]^=f[b-1]}for(vark,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(vark=1;k<a;k++)for(varl=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)thrownewError("invalid plaintext size (must be 16 bytes)");for(varb=this._Ke.length-1,c=[0,0,0,0],d=i(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]=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(varh,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);returnj},D.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=i(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]=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(varh,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);returnj};varE=function(a){if(!(thisinstanceofE))throwError("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=newD(a)};E.prototype.encrypt=function(a){if(a=f(a),a.length%16!==0)thrownewError("invalid plaintext size (must be multiple of 16 bytes)");for(varb=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);returnb},E.prototype.decrypt=function(a){if(a=f(a),a.length%16!==0)thrownewError("invalid ciphertext size (must be multiple of 16 bytes)");for(varb=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);returnb};varF=function(a,b){if(!(thisinstanceofF))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=g(16);this._lastCipherblock=f(b,!0),this._aes=newD(a)};F.prototype.encrypt=function(a){if(a=f(a),a.length%16!==0)thrownewError("invalid plaintext size (must be multiple of 16 bytes)");for(varb=g(a.length),c=g(16),d=0;d<a.length;d+=16){h(a,c,0,d,d+16);for(vare=0;e<16;e++)c[e]^=this._lastCipherblock[e];this._lastCipherblock=this._aes.encrypt(c),h(this._lastCipherblock,b,d)}returnb},F.prototype.decrypt=function(a){if(a=f(a),a.length%16!==0)thrownewError("invalid ciphertext size (must be multiple of 16 bytes)");for(varb=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(vare=0;e<16;e++)b[d+e]=c[e]^this._lastCipherblock[e];h(a,this._lastCipherblock,0,d,d+16)}returnb};varG=function(a,b,c){if(!(thisinstanceofG))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=g(16);c||(c=1),this.segmentSize=c,this._shiftRegister=f(b,!0),this._aes=newD(a)};G.prototype.encrypt=function(a){if(a.length%
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":32,"./key":40,"./signature":41,"bn.js":30}],40:[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"<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";functiond(a,b){returnainstanceofd?a:void(this._importDER(a,b)||(l(a.r&&a.s,"Signature without r or s"),this.r=newi(a.r,16),this.s=newi(a.s,16),void0===a.recoveryParam?this.recoveryParam=null:this.recoveryParam=a.recoveryParam))}functione(){this.place=0}functionf(a,b){varc=a[b.place++];if(!(128&c))returnc;for(vard=15&c,e=0,f=0,g=b.place;f<d;f++,g++)e<<=8,e|=a[g];returnb.place=g,e}functiong(a){for(varb=0,c=a.length-1;!a[b]&&!(128&a[b+1])&&b<c;)b++;return0===b?a:a.slice(b)}functionh(a,b){if(b<128)returnvoida.push(b);varc=1+(Math.log(b)/Math.LN2>>>3);for(a.push(128|c);--c;)a.push(