SHARE
TWEET

DecryptWallet.html source

simcity42 Aug 15th, 2014 232 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.  
  3. <head>
  4. <script type="text/javascript">
  5.  
  6. (function(){var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",g=window.Crypto={},m=g.util={rotl:function(d,c){return d<<c|d>>>32-c},rotr:function(d,c){return d<<32-c|d>>>c},endian:function(d){if(d.constructor==Number){return m.rotl(d,8)&16711935|m.rotl(d,24)&4278255360}for(var c=0;c<d.length;c++){d[c]=m.endian(d[c])}return d},randomBytes:function(d){for(var c=[];d>0;d--){c.push(Math.floor(Math.random()*256))}return c},bytesToWords:function(f){for(var e=[],o=0,n=0;o<f.length;o++,n+=8){e[n>>>5]|=f[o]<<24-n%32}return e},wordsToBytes:function(e){for(var d=[],f=0;f<e.length*32;f+=8){d.push(e[f>>>5]>>>24-f%32&255)}return d},bytesToHex:function(e){for(var d=[],f=0;f<e.length;f++){d.push((e[f]>>>4).toString(16)),d.push((e[f]&15).toString(16))}return d.join("")},hexToBytes:function(e){for(var d=[],f=0;f<e.length;f+=2){d.push(parseInt(e.substr(f,2),16))}return d},bytesToBase64:function(a){if(typeof btoa=="function"){return btoa(j.bytesToString(a))}for(var p=[],o=0;o<a.length;o+=3){var n=a[o]<<16|a[o+1]<<8|a[o+2];for(var f=0;f<4;f++){o*8+f*6<=a.length*8?p.push(h.charAt(n>>>6*(3-f)&63)):p.push("=")}}return p.join("")},base64ToBytes:function(a){if(typeof atob=="function"){return j.stringToBytes(atob(a))}a=a.replace(/[^A-Z0-9+\/]/ig,"");for(var o=[],n=0,f=0;n<a.length;f=++n%4){if(f==0){continue}o.push((h.indexOf(a.charAt(n-1))&Math.pow(2,-2*f+8)-1)<<f*2|h.indexOf(a.charAt(n))>>>6-f*2)}return o}};g.mode={};var l=g.charenc={},k=l.UTF8={stringToBytes:function(b){return j.stringToBytes(unescape(encodeURIComponent(b)))},bytesToString:function(b){return decodeURIComponent(escape(j.bytesToString(b)))}},j=l.Binary={stringToBytes:function(e){for(var d=[],f=0;f<e.length;f++){d.push(e.charCodeAt(f))}return d},bytesToString:function(e){for(var d=[],f=0;f<e.length;f++){d.push(String.fromCharCode(e[f]))}return d.join("")}}})();(function(){var j=Crypto,h=j.util,o=j.charenc,n=o.UTF8,m=o.Binary,l=[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],k=j.SHA256=function(b,f){var e=h.wordsToBytes(k._sha256(b));return f&&f.asBytes?e:f&&f.asString?m.bytesToString(e):h.bytesToHex(e)};k._sha256=function(X){X.constructor==String&&(X=n.stringToBytes(X));var W=h.bytesToWords(X),V=X.length*8,U=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],T=[],S,R,Q,P,O,N,M,L,J,H,G,F;W[V>>5]|=128<<24-V%32,W[(V+64>>9<<4)+15]=V;for(var J=0;J<W.length;J+=16){S=U[0],R=U[1],Q=U[2],P=U[3],O=U[4],N=U[5],M=U[6],L=U[7];for(var H=0;H<64;H++){if(H<16){T[H]=W[H+J]}else{var E=T[H-15],D=T[H-2],C=(E<<25|E>>>7)^(E<<14|E>>>18)^E>>>3,f=(D<<15|D>>>17)^(D<<13|D>>>19)^D>>>10;T[H]=C+(T[H-7]>>>0)+f+(T[H-16]>>>0)}var d=O&N^~O&M,b=S&R^S&Q^R&Q,K=(S<<30|S>>>2)^(S<<19|S>>>13)^(S<<10|S>>>22),I=(O<<26|O>>>6)^(O<<21|O>>>11)^(O<<7|O>>>25);G=(L>>>0)+I+d+l[H]+(T[H]>>>0),F=K+b,L=M,M=N,N=O,O=P+G,P=Q,Q=R,R=S,S=G+F}U[0]+=S,U[1]+=R,U[2]+=Q,U[3]+=P,U[4]+=O,U[5]+=N,U[6]+=M,U[7]+=L}return U},k._blocksize=16})();(function(){function A(f,e,h,g){return 0<=f&&f<=15?e^h^g:16<=f&&f<=31?e&h|~e&g:32<=f&&f<=47?(e|~h)^g:48<=f&&f<=63?e&g|h&~g:64<=f&&f<=79?e^(h|~g):"rmd160_f: j out of range"}function y(b){return 0<=b&&b<=15?0:16<=b&&b<=31?1518500249:32<=b&&b<=47?1859775393:48<=b&&b<=63?2400959708:64<=b&&b<=79?2840853838:"rmd160_K1: j out of range"}function x(b){return 0<=b&&b<=15?1352829926:16<=b&&b<=31?1548603684:32<=b&&b<=47?1836072691:48<=b&&b<=63?2053994217:64<=b&&b<=79?0:"rmd160_K2: j out of range"}function q(f,e){var h=(f&65535)+(e&65535),g=(f>>16)+(e>>16)+(h>>16);return g<<16|h&65535}function p(d,c){return d<<c|d>>>32-c}var G=Crypto,F=G.util,E=G.charenc,D=E.UTF8,C=E.Binary;F.bytesToLWords=function(e){var d=Array(e.length>>2);for(var f=0;f<d.length;f++){d[f]=0}for(var f=0;f<e.length*8;f+=8){d[f>>5]|=(e[f/8]&255)<<f%32}return d},F.lWordsToBytes=function(e){var d=[];for(var f=0;f<e.length*32;f+=8){d.push(e[f>>5]>>>f%32&255)}return d};var B=G.RIPEMD160=function(b,f){var e=F.lWordsToBytes(B._rmd160(b));return f&&f.asBytes?e:f&&f.asString?C.bytesToString(e):F.bytesToHex(e)};B._rmd160=function(R){R.constructor==String&&(R=D.stringToBytes(R));var Q=F.bytesToLWords(R),P=R.length*8;Q[P>>5]|=128<<P%32,Q[(P+64>>>9<<4)+14]=P;var O=1732584193,N=4023233417,L=2562383102,J=271733878,H=3285377520;for(var n=0;n<Q.length;n+=16){var l,j=O,h=N,g=L,d=J,b=H,M=O,K=N,I=L,o=J,m=H;for(var k=0;k<=79;++k){l=q(j,A(k,h,g,d)),l=q(l,Q[n+w[k]]),l=q(l,y(k)),l=q(p(l,u[k]),b),j=b,b=d,d=p(g,10),g=h,h=l,l=q(M,A(79-k,K,I,o)),l=q(l,Q[n+v[k]]),l=q(l,x(k)),l=q(p(l,r[k]),m),M=m,m=o,o=p(I,10),I=K,K=l}l=q(N,q(g,o)),N=q(L,q(d,m)),L=q(J,q(b,M)),J=q(H,q(j,K)),H=q(O,q(h,I)),O=l}return[O,N,L,J,H]};var w=[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],v=[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],u=[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],r=[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]})();function Arcfour(){this.i=0,this.j=0,this.S=new Array}function ARC4init(f){var e,h,g;for(e=0;e<256;++e){this.S[e]=e}h=0;for(e=0;e<256;++e){h=h+this.S[e]+f[e%f.length]&255,g=this.S[e],this.S[e]=this.S[h],this.S[h]=g}this.i=0,this.j=0}function ARC4next(){var b;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,b=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=b,this.S[b+this.S[this.i]&255]}function prng_newstate(){return new Arcfour}Arcfour.prototype.init=ARC4init,Arcfour.prototype.next=ARC4next;var rng_psize=256;function rng_seed_int(b){rng_pool[rng_pptr++]^=b&255,rng_pool[rng_pptr++]^=b>>8&255,rng_pool[rng_pptr++]^=b>>16&255,rng_pool[rng_pptr++]^=b>>24&255,rng_pptr>=rng_psize&&(rng_pptr-=rng_psize)}function rng_seed_time(){rng_seed_int((new Date).getTime())}function rng_get_byte(){if(rng_state==null){rng_seed_time(),rng_state=prng_newstate(),rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr<rng_pool.length;++rng_pptr){rng_pool[rng_pptr]=0}rng_pptr=0}return rng_state.next()}function rng_get_bytes(d){var c;for(c=0;c<d.length;++c){d[c]=rng_get_byte()}}function SecureRandom(){}var rng_state,rng_pool,rng_pptr;if(rng_pool==null){rng_pool=new Array,rng_pptr=0;var t;if(navigator.appName=="Netscape"&&navigator.appVersion<"5"&&window.crypto){var z=window.crypto.random(32);for(t=0;t<z.length;++t){rng_pool[rng_pptr++]=z.charCodeAt(t)&255}}while(rng_pptr<rng_psize){t=Math.floor(65536*Math.random()),rng_pool[rng_pptr++]=t>>>8,rng_pool[rng_pptr++]=t&255}rng_pptr=0,rng_seed_time()}SecureRandom.prototype.nextBytes=rng_get_bytes;function BigInteger(e,d,f){e!=null&&("number"==typeof e?this.fromNumber(e,d,f):d==null&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,d))}function nbi(){return new BigInteger(null)}function am1(j,h,o,n,m,l){while(--l>=0){var k=h*this[j++]+o[n]+m;m=Math.floor(k/67108864),o[n++]=k&67108863}return m}function am2(x,w,v,u,r,q){var p=w&32767,o=w>>15;while(--q>=0){var n=this[x]&32767,m=this[x++]>>15,l=o*n+m*p;n=p*n+((l&32767)<<15)+v[u]+(r&1073741823),r=(n>>>30)+(l>>>15)+o*m+(r>>>30),v[u++]=n&1073741823}return r}function am3(x,w,v,u,r,q){var p=w&16383,o=w>>14;while(--q>=0){var n=this[x]&16383,m=this[x++]>>14,l=o*n+m*p;n=p*n+((l&16383)<<14)+v[u]+r,r=(n>>28)+(l>>14)+o*m,v[u++]=n&268435455}return r}function int2char(b){return BI_RM.charAt(b)}function intAt(e,d){var f=BI_RC[e.charCodeAt(d)];return f==null?-1:f}function bnpCopyTo(d){for(var c=this.t-1;c>=0;--c){d[c]=this[c]}d.t=this.t,d.s=this.s}function bnpFromInt(b){this.t=1,this.s=b<0?-1:0,b>0?this[0]=b:b<-1?this[0]=b+DV:this.t=0}function nbv(d){var c=nbi();return c.fromInt(d),c}function bnpFromString(j,h){var o;if(h==16){o=4}else{if(h==8){o=3}else{if(h==256){o=8}else{if(h==2){o=1}else{if(h==32){o=5}else{if(h==4){o=2}else{this.fromRadix(j,h);return}}}}}}this.t=0,this.s=0;var n=j.length,m=!1,l=0;while(--n>=0){var k=o==8?j[n]&255:intAt(j,n);if(k<0){j.charAt(n)=="-"&&(m=!0);continue}m=!1,l==0?this[this.t++]=k:l+o>this.DB?(this[this.t-1]|=(k&(1<<this.DB-l)-1)<<l,this[this.t++]=k>>this.DB-l):this[this.t-1]|=k<<l,l+=o,l>=this.DB&&(l-=this.DB)}o==8&&(j[0]&128)!=0&&(this.s=-1,l>0&&(this[this.t-1]|=(1<<this.DB-l)-1<<l)),this.clamp(),m&&BigInteger.ZERO.subTo(this,this)}function bnpClamp(){var b=this.s&this.DM;while(this.t>0&&this[this.t-1]==b){--this.t}}function bnToString(k){if(this.s<0){return"-"+this.negate().toString(k)}var j;if(k==16){j=4}else{if(k==8){j=3}else{if(k==2){j=1}else{if(k==32){j=5}else{if(k==4){j=2}else{return this.toRadix(k)}}}}}var q=(1<<j)-1,p,o=!1,n="",m=this.t,l=this.DB-m*this.DB%j;if(m-->0){l<this.DB&&(p=this[m]>>l)>0&&(o=!0,n=int2char(p));while(m>=0){l<j?(p=(this[m]&(1<<l)-1)<<j-l,p|=this[--m]>>(l+=this.DB-j)):(p=this[m]>>(l-=j)&q,l<=0&&(l+=this.DB,--m)),p>0&&(o=!0),o&&(n+=int2char(p))}}return o?n:"0"}function bnNegate(){var b=nbi();return BigInteger.ZERO.subTo(this,b),b}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(e){var d=this.s-e.s;if(d!=0){return d}var f=this.t;d=f-e.t;if(d!=0){return d}while(--f>=0){if((d=this[f]-e[f])!=0){return d}}return 0}function nbits(e){var d=1,f;return(f=e>>>16)!=0&&(e=f,d+=16),(f=e>>8)!=0&&(e=f,d+=8),(f=e>>4)!=0&&(e=f,d+=4),(f=e>>2)!=0&&(e=f,d+=2),(f=e>>1)!=0&&(e=f,d+=1),d}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(e,d){var f;for(f=this.t-1;f>=0;--f){d[f+e]=this[f]}for(f=e-1;f>=0;--f){d[f]=0}d.t=this.t+e,d.s=this.s}function bnpDRShiftTo(e,d){for(var f=e;f<this.t;++f){d[f-e]=this[f]}d.t=Math.max(this.t-e,0),d.s=this.s}function bnpLShiftTo(k,j){var q=k%this.DB,p=this.DB-q,o=(1<<p)-1,n=Math.floor(k/this.DB),m=this.s<<q&this.DM,l;for(l=this.t-1;l>=0;--l){j[l+n+1]=this[l]>>p|m,m=(this[l]&o)<<q}for(l=n-1;l>=0;--l){j[l]=0}j[n]=m,j.t=this.t+n+1,j.s=this.s,j.clamp()}function bnpRShiftTo(j,h){h.s=this.s;var o=Math.floor(j/this.DB);if(o>=this.t){h.t=0;return}var n=j%this.DB,m=this.DB-n,l=(1<<n)-1;h[0]=this[o]>>n;for(var k=o+1;k<this.t;++k){h[k-o-1]|=(this[k]&l)<<m,h[k-o]=this[k]>>n}n>0&&(h[this.t-o-1]|=(this.s&l)<<m),h.t=this.t-o,h.clamp()}function bnpSubTo(g,f){var k=0,j=0,h=Math.min(g.t,this.t);while(k<h){j+=this[k]-g[k],f[k++]=j&this.DM,j>>=this.DB}if(g.t<this.t){j-=g.s;while(k<this.t){j+=this[k],f[k++]=j&this.DM,j>>=this.DB}j+=this.s}else{j+=this.s;while(k<g.t){j-=g[k],f[k++]=j&this.DM,j>>=this.DB}j-=g.s}f.s=j<0?-1:0,j<-1?f[k++]=this.DV+j:j>0&&(f[k++]=j),f.t=k,f.clamp()}function bnpMultiplyTo(g,f){var k=this.abs(),j=g.abs(),h=k.t;f.t=h+j.t;while(--h>=0){f[h]=0}for(h=0;h<j.t;++h){f[h+k.t]=k.am(0,j[h],f,h,0,k.t)}f.s=0,f.clamp(),this.s!=g.s&&BigInteger.ZERO.subTo(f,f)}function bnpSquareTo(f){var e=this.abs(),h=f.t=2*e.t;while(--h>=0){f[h]=0}for(h=0;h<e.t-1;++h){var g=e.am(h,e[h],f,2*h,0,1);(f[h+e.t]+=e.am(h+1,2*e[h],f,2*h+1,g,e.t-h-1))>=e.DV&&(f[h+e.t]-=e.DV,f[h+e.t+1]=1)}f.t>0&&(f[f.t-1]+=e.am(h,e[h],f,2*h,0,1)),f.s=0,f.clamp()}function bnpDivRemTo(N,M,L){var K=N.abs();if(K.t<=0){return}var J=this.abs();if(J.t<K.t){M!=null&&M.fromInt(0),L!=null&&this.copyTo(L);return}L==null&&(L=nbi());var I=nbi(),H=this.s,G=N.s,F=this.DB-nbits(K[K.t-1]);F>0?(K.lShiftTo(F,I),J.lShiftTo(F,L)):(K.copyTo(I),J.copyTo(L));var E=I.t,D=I[E-1];if(D==0){return}var C=D*(1<<this.F1)+(E>1?I[E-2]>>this.F2:0),B=this.FV/C,A=(1<<this.F1)/C,y=1<<this.F2,x=L.t,w=x-E,v=M==null?nbi():M;I.dlShiftTo(w,v),L.compareTo(v)>=0&&(L[L.t++]=1,L.subTo(v,L)),BigInteger.ONE.dlShiftTo(E,v),v.subTo(I,I);while(I.t<E){I[I.t++]=0}while(--w>=0){var u=L[--x]==D?this.DM:Math.floor(L[x]*B+(L[x-1]+y)*A);if((L[x]+=I.am(0,u,L,w,0,E))<u){I.dlShiftTo(w,v),L.subTo(v,L);while(L[x]<--u){L.subTo(v,L)}}}M!=null&&(L.drShiftTo(E,M),H!=G&&BigInteger.ZERO.subTo(M,M)),L.t=E,L.clamp(),F>0&&L.rShiftTo(F,L),H<0&&BigInteger.ZERO.subTo(L,L)}function bnMod(d){var c=nbi();return this.abs().divRemTo(d,null,c),this.s<0&&c.compareTo(BigInteger.ZERO)>0&&d.subTo(c,c),c}function Classic(b){this.m=b}function cConvert(b){return b.s<0||b.compareTo(this.m)>=0?b.mod(this.m):b}function cRevert(b){return b}function cReduce(b){b.divRemTo(this.m,null,b)}function cMulTo(e,d,f){e.multiplyTo(d,f),this.reduce(f)}function cSqrTo(d,c){d.squareTo(c),this.reduce(c)}function bnpInvDigit(){if(this.t<1){return 0}var d=this[0];if((d&1)==0){return 0}var c=d&3;return c=c*(2-(d&15)*c)&15,c=c*(2-(d&255)*c)&255,c=c*(2-((d&65535)*c&65535))&65535,c=c*(2-d*c%this.DV)%this.DV,c>0?this.DV-c:-c}function Montgomery(b){this.m=b,this.mp=b.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<b.DB-15)-1,this.mt2=2*b.t}function montConvert(d){var c=nbi();return d.abs().dlShiftTo(this.m.t,c),c.divRemTo(this.m,null,c),d.s<0&&c.compareTo(BigInteger.ZERO)>0&&this.m.subTo(c,c),c}function montRevert(d){var c=nbi();return d.copyTo(c),this.reduce(c),c}function montReduce(f){while(f.t<=this.mt2){f[f.t++]=0}for(var e=0;e<this.m.t;++e){var h=f[e]&32767,g=h*this.mpl+((h*this.mph+(f[e]>>15)*this.mpl&this.um)<<15)&f.DM;h=e+this.m.t,f[h]+=this.m.am(0,g,f,e,0,this.m.t);while(f[h]>=f.DV){f[h]-=f.DV,f[++h]++}}f.clamp(),f.drShiftTo(this.m.t,f),f.compareTo(this.m)>=0&&f.subTo(this.m,f)}function montSqrTo(d,c){d.squareTo(c),this.reduce(c)}function montMulTo(e,d,f){e.multiplyTo(d,f),this.reduce(f)}function bnpIsEven(){return(this.t>0?this[0]&1:this.s)==0}function bnpExp(j,h){if(j>4294967295||j<1){return BigInteger.ONE}var o=nbi(),n=nbi(),m=h.convert(this),l=nbits(j)-1;m.copyTo(o);while(--l>=0){h.sqrTo(o,n);if((j&1<<l)>0){h.mulTo(n,m,o)}else{var k=o;o=n,n=k}}return h.revert(o)}function bnModPowInt(e,d){var f;return e<256||d.isEven()?f=new Classic(d):f=new Montgomery(d),this.exp(e,f)}var dbits,canary=244837814094590,j_lm=(canary&16777215)==15715070;j_lm&&navigator.appName=="Microsoft Internet Explorer"?(BigInteger.prototype.am=am2,dbits=30):j_lm&&navigator.appName!="Netscape"?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28),BigInteger.prototype.DB=dbits,BigInteger.prototype.DM=(1<<dbits)-1,BigInteger.prototype.DV=1<<dbits;var BI_FP=52;BigInteger.prototype.FV=Math.pow(2,BI_FP),BigInteger.prototype.F1=BI_FP-dbits,BigInteger.prototype.F2=2*dbits-BI_FP;var BI_RM="0123456789abcdefghijklmnopqrstuvwxyz",BI_RC=new Array,rr,vv;rr="0".charCodeAt(0);for(vv=0;vv<=9;++vv){BI_RC[rr++]=vv}rr="a".charCodeAt(0);for(vv=10;vv<36;++vv){BI_RC[rr++]=vv}rr="A".charCodeAt(0);for(vv=10;vv<36;++vv){BI_RC[rr++]=vv}Classic.prototype.convert=cConvert,Classic.prototype.revert=cRevert,Classic.prototype.reduce=cReduce,Classic.prototype.mulTo=cMulTo,Classic.prototype.sqrTo=cSqrTo,Montgomery.prototype.convert=montConvert,Montgomery.prototype.revert=montRevert,Montgomery.prototype.reduce=montReduce,Montgomery.prototype.mulTo=montMulTo,Montgomery.prototype.sqrTo=montSqrTo,BigInteger.prototype.copyTo=bnpCopyTo,BigInteger.prototype.fromInt=bnpFromInt,BigInteger.prototype.fromString=bnpFromString,BigInteger.prototype.clamp=bnpClamp,BigInteger.prototype.dlShiftTo=bnpDLShiftTo,BigInteger.prototype.drShiftTo=bnpDRShiftTo,BigInteger.prototype.lShiftTo=bnpLShiftTo,BigInteger.prototype.rShiftTo=bnpRShiftTo,BigInteger.prototype.subTo=bnpSubTo,BigInteger.prototype.multiplyTo=bnpMultiplyTo,BigInteger.prototype.squareTo=bnpSquareTo,BigInteger.prototype.divRemTo=bnpDivRemTo,BigInteger.prototype.invDigit=bnpInvDigit,BigInteger.prototype.isEven=bnpIsEven,BigInteger.prototype.exp=bnpExp,BigInteger.prototype.toString=bnToString,BigInteger.prototype.negate=bnNegate,BigInteger.prototype.abs=bnAbs,BigInteger.prototype.compareTo=bnCompareTo,BigInteger.prototype.bitLength=bnBitLength,BigInteger.prototype.mod=bnMod,BigInteger.prototype.modPowInt=bnModPowInt,BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1);function bnClone(){var b=nbi();return this.copyTo(b),b}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}if(this.t==0){return -1}}else{if(this.t==1){return this[0]}if(this.t==0){return 0}}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function bnByteValue(){return this.t==0?this.s:this[0]<<24>>24}function bnShortValue(){return this.t==0?this.s:this[0]<<16>>16}function bnpChunkSize(b){return Math.floor(Math.LN2*this.DB/Math.log(b))}function bnSigNum(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function bnpToRadix(j){j==null&&(j=10);if(this.signum()==0||j<2||j>36){return"0"}var h=this.chunkSize(j),o=Math.pow(j,h),n=nbv(o),m=nbi(),l=nbi(),k="";this.divRemTo(n,m,l);while(m.signum()>0){k=(o+l.intValue()).toString(j).substr(1)+k,m.divRemTo(n,m,l)}return l.intValue().toString(j)+k}function bnpFromRadix(r,q){this.fromInt(0),q==null&&(q=10);var p=this.chunkSize(q),o=Math.pow(q,p),n=!1,m=0,l=0;for(var k=0;k<r.length;++k){var j=intAt(r,k);if(j<0){r.charAt(k)=="-"&&this.signum()==0&&(n=!0);continue}l=q*l+j,++m>=p&&(this.dMultiply(o),this.dAddOffset(l,0),m=0,l=0)}m>0&&(this.dMultiply(Math.pow(q,m)),this.dAddOffset(l,0)),n&&BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(g,f,k){if("number"==typeof f){if(g<2){this.fromInt(1)}else{this.fromNumber(g,k),this.testBit(g-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(g-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);while(!this.isProbablePrime(f)){this.dAddOffset(2,0),this.bitLength()>g&&this.subTo(BigInteger.ONE.shiftLeft(g-1),this)}}}else{var j=new Array,h=g&7;j.length=(g>>3)+1,f.nextBytes(j),h>0?j[0]&=(1<<h)-1:j[0]=0,this.fromString(j,256)}}function bnToByteArray(){var g=this.t,f=new Array;f[0]=this.s;var k=this.DB-g*this.DB%8,j,h=0;if(g-->0){k<this.DB&&(j=this[g]>>k)!=(this.s&this.DM)>>k&&(f[h++]=j|this.s<<this.DB-k);while(g>=0){k<8?(j=(this[g]&(1<<k)-1)<<8-k,j|=this[--g]>>(k+=this.DB-8)):(j=this[g]>>(k-=8)&255,k<=0&&(k+=this.DB,--g)),(j&128)!=0&&(j|=-256),h==0&&(this.s&128)!=(j&128)&&++h;if(h>0||j!=this.s){f[h++]=j}}}return f}function bnEquals(b){return this.compareTo(b)==0}function bnMin(b){return this.compareTo(b)<0?this:b}function bnMax(b){return this.compareTo(b)>0?this:b}function bnpBitwiseTo(h,g,m){var l,k,j=Math.min(h.t,this.t);for(l=0;l<j;++l){m[l]=g(this[l],h[l])}if(h.t<this.t){k=h.s&this.DM;for(l=j;l<this.t;++l){m[l]=g(this[l],k)}m.t=this.t}else{k=this.s&this.DM;for(l=j;l<h.t;++l){m[l]=g(k,h[l])}m.t=h.t}m.s=g(this.s,h.s),m.clamp()}function op_and(d,c){return d&c}function bnAnd(d){var c=nbi();return this.bitwiseTo(d,op_and,c),c}function op_or(d,c){return d|c}function bnOr(d){var c=nbi();return this.bitwiseTo(d,op_or,c),c}function op_xor(d,c){return d^c}function bnXor(d){var c=nbi();return this.bitwiseTo(d,op_xor,c),c}function op_andnot(d,c){return d&~c}function bnAndNot(d){var c=nbi();return this.bitwiseTo(d,op_andnot,c),c}function bnNot(){var d=nbi();for(var c=0;c<this.t;++c){d[c]=this.DM&~this[c]}return d.t=this.t,d.s=~this.s,d}function bnShiftLeft(d){var c=nbi();return d<0?this.rShiftTo(-d,c):this.lShiftTo(d,c),c}function bnShiftRight(d){var c=nbi();return d<0?this.lShiftTo(-d,c):this.rShiftTo(d,c),c}function lbit(d){if(d==0){return -1}var c=0;return(d&65535)==0&&(d>>=16,c+=16),(d&255)==0&&(d>>=8,c+=8),(d&15)==0&&(d>>=4,c+=4),(d&3)==0&&(d>>=2,c+=2),(d&1)==0&&++c,c}function bnGetLowestSetBit(){for(var b=0;b<this.t;++b){if(this[b]!=0){return b*this.DB+lbit(this[b])}}return this.s<0?this.t*this.DB:-1}function cbit(d){var c=0;while(d!=0){d&=d-1,++c}return c}function bnBitCount(){var e=0,d=this.s&this.DM;for(var f=0;f<this.t;++f){e+=cbit(this[f]^d)}return e}function bnTestBit(d){var c=Math.floor(d/this.DB);return c>=this.t?this.s!=0:(this[c]&1<<d%this.DB)!=0}function bnpChangeBit(e,d){var f=BigInteger.ONE.shiftLeft(e);return this.bitwiseTo(f,d,f),f}function bnSetBit(b){return this.changeBit(b,op_or)}function bnClearBit(b){return this.changeBit(b,op_andnot)}function bnFlipBit(b){return this.changeBit(b,op_xor)}function bnpAddTo(g,f){var k=0,j=0,h=Math.min(g.t,this.t);while(k<h){j+=this[k]+g[k],f[k++]=j&this.DM,j>>=this.DB}if(g.t<this.t){j+=g.s;while(k<this.t){j+=this[k],f[k++]=j&this.DM,j>>=this.DB}j+=this.s}else{j+=this.s;while(k<g.t){j+=g[k],f[k++]=j&this.DM,j>>=this.DB}j+=g.s}f.s=j<0?-1:0,j>0?f[k++]=j:j<-1&&(f[k++]=this.DV+j),f.t=k,f.clamp()}function bnAdd(d){var c=nbi();return this.addTo(d,c),c}function bnSubtract(d){var c=nbi();return this.subTo(d,c),c}function bnMultiply(d){var c=nbi();return this.multiplyTo(d,c),c}function bnSquare(){var b=nbi();return this.squareTo(b),b}function bnDivide(d){var c=nbi();return this.divRemTo(d,c,null),c}function bnRemainder(d){var c=nbi();return this.divRemTo(d,null,c),c}function bnDivideAndRemainder(e){var d=nbi(),f=nbi();return this.divRemTo(e,d,f),new Array(d,f)}function bnpDMultiply(b){this[this.t]=this.am(0,b-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(d,c){if(d==0){return}while(this.t<=c){this[this.t++]=0}this[c]+=d;while(this[c]>=this.DV){this[c]-=this.DV,++c>=this.t&&(this[this.t++]=0),++this[c]}}function NullExp(){}function nNop(b){return b}function nMulTo(e,d,f){e.multiplyTo(d,f)}function nSqrTo(d,c){d.squareTo(c)}function bnPow(b){return this.exp(b,new NullExp)}function bnpMultiplyLowerTo(g,f,k){var j=Math.min(this.t+g.t,f);k.s=0,k.t=j;while(j>0){k[--j]=0}var h;for(h=k.t-this.t;j<h;++j){k[j+this.t]=this.am(0,g[j],k,j,0,this.t)}for(h=Math.min(g.t,f);j<h;++j){this.am(0,g[j],k,j,0,f-j)}k.clamp()}function bnpMultiplyUpperTo(f,e,h){--e;var g=h.t=this.t+f.t-e;h.s=0;while(--g>=0){h[g]=0}for(g=Math.max(e-this.t,0);g<f.t;++g){h[this.t+g-e]=this.am(e-g,f[g],h,0,0,this.t+g-e)}h.clamp(),h.drShiftTo(1,h)}function Barrett(b){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*b.t,this.r2),this.mu=this.r2.divide(b),this.m=b}function barrettConvert(d){if(d.s<0||d.t>2*this.m.t){return d.mod(this.m)}if(d.compareTo(this.m)<0){return d}var c=nbi();return d.copyTo(c),this.reduce(c),c}function barrettRevert(b){return b}function barrettReduce(b){b.drShiftTo(this.m.t-1,this.r2),b.t>this.m.t+1&&(b.t=this.m.t+1,b.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(b.compareTo(this.r2)<0){b.dAddOffset(1,this.m.t+1)}b.subTo(this.r2,b);while(b.compareTo(this.m)>=0){b.subTo(this.m,b)}}function barrettSqrTo(d,c){d.squareTo(c),this.reduce(c)}function barrettMulTo(e,d,f){e.multiplyTo(d,f),this.reduce(f)}function bnModPow(I,H){var G=I.bitLength(),F,E=nbv(1),D;if(G<=0){return E}G<18?F=1:G<48?F=3:G<144?F=4:G<768?F=5:F=6,G<8?D=new Classic(H):H.isEven()?D=new Barrett(H):D=new Montgomery(H);var C=new Array,B=3,A=F-1,y=(1<<F)-1;C[1]=D.convert(this);if(F>1){var x=nbi();D.sqrTo(C[1],x);while(B<=y){C[B]=nbi(),D.mulTo(x,C[B-2],C[B]),B+=2}}var w=I.t-1,v,u=!0,r=nbi(),q;G=nbits(I[w])-1;while(w>=0){G>=A?v=I[w]>>G-A&y:(v=(I[w]&(1<<G+1)-1)<<A-G,w>0&&(v|=I[w-1]>>this.DB+G-A)),B=F;while((v&1)==0){v>>=1,--B}(G-=B)<0&&(G+=this.DB,--w);if(u){C[v].copyTo(E),u=!1}else{while(B>1){D.sqrTo(E,r),D.sqrTo(r,E),B-=2}B>0?D.sqrTo(E,r):(q=E,E=r,r=q),D.mulTo(r,C[v],E)}while(w>=0&&(I[w]&1<<G)==0){D.sqrTo(E,r),q=E,E=r,r=q,--G<0&&(G=this.DB-1,--w)}}return D.revert(E)}function bnGCD(h){var g=this.s<0?this.negate():this.clone(),m=h.s<0?h.negate():h.clone();if(g.compareTo(m)<0){var l=g;g=m,m=l}var k=g.getLowestSetBit(),j=m.getLowestSetBit();if(j<0){return g}k<j&&(j=k),j>0&&(g.rShiftTo(j,g),m.rShiftTo(j,m));while(g.signum()>0){(k=g.getLowestSetBit())>0&&g.rShiftTo(k,g),(k=m.getLowestSetBit())>0&&m.rShiftTo(k,m),g.compareTo(m)>=0?(g.subTo(m,g),g.rShiftTo(1,g)):(m.subTo(g,m),m.rShiftTo(1,m))}return j>0&&m.lShiftTo(j,m),m}function bnpModInt(f){if(f<=0){return 0}var e=this.DV%f,h=this.s<0?f-1:0;if(this.t>0){if(e==0){h=this[0]%f}else{for(var g=this.t-1;g>=0;--g){h=(e*h+this[g])%f}}}return h}function bnModInverse(k){var j=k.isEven();if(this.isEven()&&j||k.signum()==0){return BigInteger.ZERO}var q=k.clone(),p=this.clone(),o=nbv(1),n=nbv(0),m=nbv(0),l=nbv(1);while(q.signum()!=0){while(q.isEven()){q.rShiftTo(1,q);if(j){if(!o.isEven()||!n.isEven()){o.addTo(this,o),n.subTo(k,n)}o.rShiftTo(1,o)}else{n.isEven()||n.subTo(k,n)}n.rShiftTo(1,n)}while(p.isEven()){p.rShiftTo(1,p);if(j){if(!m.isEven()||!l.isEven()){m.addTo(this,m),l.subTo(k,l)}m.rShiftTo(1,m)}else{l.isEven()||l.subTo(k,l)}l.rShiftTo(1,l)}q.compareTo(p)>=0?(q.subTo(p,q),j&&o.subTo(m,o),n.subTo(l,n)):(p.subTo(q,p),j&&m.subTo(o,m),l.subTo(n,l))}if(p.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(l.compareTo(k)>=0){return l.subtract(k)}if(l.signum()<0){l.addTo(k,l)}else{return l}return l.signum()<0?l.add(k):l}function bnIsProbablePrime(g){var f,k=this.abs();if(k.t==1&&k[0]<=lowprimes[lowprimes.length-1]){for(f=0;f<lowprimes.length;++f){if(k[0]==lowprimes[f]){return !0}}return !1}if(k.isEven()){return !1}f=1;while(f<lowprimes.length){var j=lowprimes[f],h=f+1;while(h<lowprimes.length&&j<lplim){j*=lowprimes[h++]}j=k.modInt(j);while(f<h){if(j%lowprimes[f++]==0){return !1}}}return k.millerRabin(g)}function bnpMillerRabin(k){var j=this.subtract(BigInteger.ONE),q=j.getLowestSetBit();if(q<=0){return !1}var p=j.shiftRight(q);k=k+1>>1,k>lowprimes.length&&(k=lowprimes.length);var o=nbi();for(var n=0;n<k;++n){o.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);var m=o.modPow(p,this);if(m.compareTo(BigInteger.ONE)!=0&&m.compareTo(j)!=0){var l=1;while(l++<q&&m.compareTo(j)!=0){m=m.modPowInt(2,this);if(m.compareTo(BigInteger.ONE)==0){return !1}}if(m.compareTo(j)!=0){return !1}}}return !0}NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=nMulTo,NullExp.prototype.sqrTo=nSqrTo,Barrett.prototype.convert=barrettConvert,Barrett.prototype.revert=barrettRevert,Barrett.prototype.reduce=barrettReduce,Barrett.prototype.mulTo=barrettMulTo,Barrett.prototype.sqrTo=barrettSqrTo;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];BigInteger.prototype.chunkSize=bnpChunkSize,BigInteger.prototype.toRadix=bnpToRadix,BigInteger.prototype.fromRadix=bnpFromRadix,BigInteger.prototype.fromNumber=bnpFromNumber,BigInteger.prototype.bitwiseTo=bnpBitwiseTo,BigInteger.prototype.changeBit=bnpChangeBit,BigInteger.prototype.addTo=bnpAddTo,BigInteger.prototype.dMultiply=bnpDMultiply,BigInteger.prototype.dAddOffset=bnpDAddOffset,BigInteger.prototype.multiplyLowerTo=bnpMultiplyLowerTo,BigInteger.prototype.multiplyUpperTo=bnpMultiplyUpperTo,BigInteger.prototype.modInt=bnpModInt,BigInteger.prototype.millerRabin=bnpMillerRabin,BigInteger.prototype.clone=bnClone,BigInteger.prototype.intValue=bnIntValue,BigInteger.prototype.byteValue=bnByteValue,BigInteger.prototype.shortValue=bnShortValue,BigInteger.prototype.signum=bnSigNum,BigInteger.prototype.toByteArray=bnToByteArray,BigInteger.prototype.equals=bnEquals,BigInteger.prototype.min=bnMin,BigInteger.prototype.max=bnMax,BigInteger.prototype.and=bnAnd,BigInteger.prototype.or=bnOr,BigInteger.prototype.xor=bnXor,BigInteger.prototype.andNot=bnAndNot,BigInteger.prototype.not=bnNot,BigInteger.prototype.shiftLeft=bnShiftLeft,BigInteger.prototype.shiftRight=bnShiftRight,BigInteger.prototype.getLowestSetBit=bnGetLowestSetBit,BigInteger.prototype.bitCount=bnBitCount,BigInteger.prototype.testBit=bnTestBit,BigInteger.prototype.setBit=bnSetBit,BigInteger.prototype.clearBit=bnClearBit,BigInteger.prototype.flipBit=bnFlipBit,BigInteger.prototype.add=bnAdd,BigInteger.prototype.subtract=bnSubtract,BigInteger.prototype.multiply=bnMultiply,BigInteger.prototype.divide=bnDivide,BigInteger.prototype.remainder=bnRemainder,BigInteger.prototype.divideAndRemainder=bnDivideAndRemainder,BigInteger.prototype.modPow=bnModPow,BigInteger.prototype.modInverse=bnModInverse,BigInteger.prototype.pow=bnPow,BigInteger.prototype.gcd=bnGCD,BigInteger.prototype.isProbablePrime=bnIsProbablePrime,BigInteger.prototype.square=bnSquare;function ECFieldElementFp(d,c){this.x=c,this.q=d}function feFpEquals(b){return b==this?!0:this.q.equals(b.q)&&this.x.equals(b.x)}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(b){return new ECFieldElementFp(this.q,this.x.add(b.toBigInteger()).mod(this.q))}function feFpSubtract(b){return new ECFieldElementFp(this.q,this.x.subtract(b.toBigInteger()).mod(this.q))}function feFpMultiply(b){return new ECFieldElementFp(this.q,this.x.multiply(b.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(b){return new ECFieldElementFp(this.q,this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q))}function ECPointFp(f,e,h,g){this.curve=f,this.x=e,this.y=h,g==null?this.z=BigInteger.ONE:this.z=g,this.zinv=null}function pointFpGetX(){return this.zinv==null&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){return this.zinv==null&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(e){if(e==this){return !0}if(this.isInfinity()){return e.isInfinity()}if(e.isInfinity()){return this.isInfinity()}var d,f;return d=e.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(e.z)).mod(this.curve.q),d.equals(BigInteger.ZERO)?(f=e.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(e.z)).mod(this.curve.q),f.equals(BigInteger.ZERO)):!1}function pointFpIsInfinity(){return this.x==null&&this.y==null?!0:this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(G){if(this.isInfinity()){return G}if(G.isInfinity()){return this}var F=G.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(G.z)).mod(this.curve.q),E=G.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(G.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(E)){return BigInteger.ZERO.equals(F)?this.twice():this.curve.getInfinity()}var D=new BigInteger("3"),C=this.x.toBigInteger(),B=this.y.toBigInteger(),A=G.x.toBigInteger(),y=G.y.toBigInteger(),x=E.square(),w=x.multiply(E),v=C.multiply(x),u=F.square().multiply(this.z),r=u.subtract(v.shiftLeft(1)).multiply(G.z).subtract(w).multiply(E).mod(this.curve.q),q=v.multiply(D).multiply(F).subtract(B.multiply(w)).subtract(u.multiply(F)).multiply(G.z).add(F.multiply(w)).mod(this.curve.q),p=w.multiply(this.z).multiply(G.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(r),this.curve.fromBigInteger(q),p)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var v=new BigInteger("3"),u=this.x.toBigInteger(),r=this.y.toBigInteger(),q=r.multiply(this.z),p=q.multiply(r).mod(this.curve.q),o=this.curve.a.toBigInteger(),n=u.square().multiply(v);BigInteger.ZERO.equals(o)||(n=n.add(this.z.square().multiply(o))),n=n.mod(this.curve.q);var m=n.square().subtract(u.shiftLeft(3).multiply(p)).shiftLeft(1).multiply(q).mod(this.curve.q),l=n.multiply(v).multiply(u).subtract(p.shiftLeft(1)).shiftLeft(2).multiply(p).subtract(n.square().multiply(n)).mod(this.curve.q),k=q.square().multiply(q).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(m),this.curve.fromBigInteger(l),k)}function pointFpMultiply(k){if(this.isInfinity()){return this}if(k.signum()==0){return this.curve.getInfinity()}var j=k,q=j.multiply(new BigInteger("3")),p=this.negate(),o=this,n;for(n=q.bitLength()-2;n>0;--n){o=o.twice();var m=q.testBit(n),l=j.testBit(n);m!=l&&(o=o.add(m?this:p))}return o}function pointFpMultiplyTwo(h,g,m){var l;h.bitLength()>m.bitLength()?l=h.bitLength()-1:l=m.bitLength()-1;var k=this.curve.getInfinity(),j=this.add(g);while(l>=0){k=k.twice(),h.testBit(l)?m.testBit(l)?k=k.add(j):k=k.add(this):m.testBit(l)&&(k=k.add(g)),--l}return k}function ECCurveFp(e,d,f){this.q=e,this.a=this.fromBigInteger(d),this.b=this.fromBigInteger(f),this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(b){return b==this?!0:this.q.equals(b.q)&&this.a.equals(b.a)&&this.b.equals(b.b)}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(b){return new ECFieldElementFp(this.q,b)}function curveFpDecodePointHex(f){switch(parseInt(f.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(f.length-2)/2,h=f.substr(2,e),g=f.substr(e+2,e);return new ECPointFp(this,this.fromBigInteger(new BigInteger(h,16)),this.fromBigInteger(new BigInteger(g,16)));default:return null}}ECFieldElementFp.prototype.equals=feFpEquals,ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger,ECFieldElementFp.prototype.negate=feFpNegate,ECFieldElementFp.prototype.add=feFpAdd,ECFieldElementFp.prototype.subtract=feFpSubtract,ECFieldElementFp.prototype.multiply=feFpMultiply,ECFieldElementFp.prototype.square=feFpSquare,ECFieldElementFp.prototype.divide=feFpDivide,ECPointFp.prototype.getX=pointFpGetX,ECPointFp.prototype.getY=pointFpGetY,ECPointFp.prototype.equals=pointFpEquals,ECPointFp.prototype.isInfinity=pointFpIsInfinity,ECPointFp.prototype.negate=pointFpNegate,ECPointFp.prototype.add=pointFpAdd,ECPointFp.prototype.twice=pointFpTwice,ECPointFp.prototype.multiply=pointFpMultiply,ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo,ECCurveFp.prototype.getQ=curveFpGetQ,ECCurveFp.prototype.getA=curveFpGetA,ECCurveFp.prototype.getB=curveFpGetB,ECCurveFp.prototype.equals=curveFpEquals,ECCurveFp.prototype.getInfinity=curveFpGetInfinity,ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger,ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;function X9ECParameters(f,e,h,g){this.curve=f,this.g=e,this.n=h,this.h=g}function x9getCurve(){return this.curve}function x9getG(){return this.g}function x9getN(){return this.n}function x9getH(){return this.h}function fromHex(b){return new BigInteger(b,16)}function secp128r1(){var j=fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF"),h=fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC"),o=fromHex("E87579C11079F43DD824993C2CEE5ED3"),n=fromHex("FFFFFFFE0000000075A30D1B9038A115"),m=BigInteger.ONE,l=new ECCurveFp(j,h,o),k=l.decodePointHex("04161FF7528B899B2D0C28607CA52C5B86CF5AC8395BAFEB13C02DA292DDED7A83");return new X9ECParameters(l,k,n,m)}function secp160k1(){var j=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73"),h=BigInteger.ZERO,o=fromHex("7"),n=fromHex("0100000000000000000001B8FA16DFAB9ACA16B6B3"),m=BigInteger.ONE,l=new ECCurveFp(j,h,o),k=l.decodePointHex("043B4C382CE37AA192A4019E763036F4F5DD4D7EBB938CF935318FDCED6BC28286531733C3F03C4FEE");return new X9ECParameters(l,k,n,m)}function secp160r1(){var j=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF"),h=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC"),o=fromHex("1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45"),n=fromHex("0100000000000000000001F4C8F927AED3CA752257"),m=BigInteger.ONE,l=new ECCurveFp(j,h,o),k=l.decodePointHex("044A96B5688EF573284664698968C38BB913CBFC8223A628553168947D59DCC912042351377AC5FB32");return new X9ECParameters(l,k,n,m)}function secp192k1(){var j=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37"),h=BigInteger.ZERO,o=fromHex("3"),n=fromHex("FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D"),m=BigInteger.ONE,l=new ECCurveFp(j,h,o),k=l.decodePointHex("04DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D");return new X9ECParameters(l,k,n,m)}function secp192r1(){var j=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"),h=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC"),o=fromHex("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1"),n=fromHex("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831"),m=BigInteger.ONE,l=new ECCurveFp(j,h,o),k=l.decodePointHex("04188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF101207192B95FFC8DA78631011ED6B24CDD573F977A11E794811");return new X9ECParameters(l,k,n,m)}function secp224r1(){var j=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001"),h=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE"),o=fromHex("B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4"),n=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D"),m=BigInteger.ONE,l=new ECCurveFp(j,h,o),k=l.decodePointHex("04B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34");return new X9ECParameters(l,k,n,m)}function secp256k1(){var j=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"),h=BigInteger.ZERO,o=fromHex("7"),n=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"),m=BigInteger.ONE,l=new ECCurveFp(j,h,o),k=l.decodePointHex("0479BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8");return new X9ECParameters(l,k,n,m)}function secp256r1(){var j=fromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF"),h=fromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC"),o=fromHex("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B"),n=fromHex("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551"),m=BigInteger.ONE,l=new ECCurveFp(j,h,o),k=l.decodePointHex("046B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C2964FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5");return new X9ECParameters(l,k,n,m)}function getSECCurveByName(b){return b=="secp128r1"?secp128r1():b=="secp160k1"?secp160k1():b=="secp160r1"?secp160r1():b=="secp192k1"?secp192k1():b=="secp192r1"?secp192r1():b=="secp224r1"?secp224r1():b=="secp256k1"?secp256k1():b=="secp256r1"?secp256r1():null}X9ECParameters.prototype.getCurve=x9getCurve,X9ECParameters.prototype.getG=x9getG,X9ECParameters.prototype.getN=x9getN,X9ECParameters.prototype.getH=x9getH;var EventEmitter=function(){};EventEmitter.prototype.on=function(f,e,h){h||(h=this),this._listeners||(this._listeners={}),this._listeners[f]||(this._listeners[f]=[]),this._unbinders||(this._unbinders={}),this._unbinders[f]||(this._unbinders[f]=[]);var g=function(b){e.apply(h,[b])};this._unbinders[f].push(e),this._listeners[f].push(g)},EventEmitter.prototype.trigger=function(e,d){d===undefined&&(d={}),this._listeners||(this._listeners={});if(!this._listeners[e]){return}var f=this._listeners[e].length;while(f--){this._listeners[e][f](d)}},EventEmitter.prototype.removeListener=function(e,d){this._unbinders||(this._unbinders={});if(!this._unbinders[e]){return}var f=this._unbinders[e].length;while(f--){this._unbinders[e][f]===d&&(this._unbinders[e].splice(f,1),this._listeners[e].splice(f,1))}},EventEmitter.augment=function(d){for(var c in EventEmitter.prototype){d[c]||(d[c]=EventEmitter.prototype[c])}};(function(d){var c=d;"object"!=typeof module&&(c.EventEmitter=EventEmitter)})("object"==typeof module?module.exports:window.Bitcoin={});BigInteger.valueOf=nbv,BigInteger.prototype.toByteArrayUnsigned=function(){var b=this.toByteArray();return b.length?(b[0]==0&&(b=b.slice(1)),b.map(function(c){return c<0?c+256:c})):b},BigInteger.fromByteArrayUnsigned=function(b){return b.length?b[0]&128?new BigInteger([0].concat(b)):new BigInteger(b):b.valueOf(0)};var names=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];"undefined"==typeof window.console&&(window.console={});for(var i=0;i<names.length;++i){"undefined"==typeof window.console[names[i]]&&(window.console[names[i]]=function(){})}Bitcoin.Util={isArray:Array.isArray||function(b){return Object.prototype.toString.call(b)==="[object Array]"},makeFilledArray:function(f,e){var h=[],g=0;while(g<f){h[g++]=e}return h},numToVarInt:function(b){return b<253?[b]:b<=65536?[253,b>>>8,b&255]:b<=1?[254].concat(Crypto.util.wordsToBytes([b])):[255].concat(Crypto.util.wordsToBytes([b>>>32,b]))},valueToBigInt:function(b){return b instanceof BigInteger?b:BigInteger.fromByteArrayUnsigned(b)},formatValue:function(f){var e=this.valueToBigInt(f).toString(),h=e.length>8?e.substr(0,e.length-8):"0",g=e.length>8?e.substr(e.length-8):e;while(g.length<8){g="0"+g}g=g.replace(/0*$/,"");while(g.length<2){g+="0"}return h+"."+g},parseValue:function(g){var f=g.split("."),k=f[0],j=f[1]||"0";while(j.length<8){j+="0"}j=j.replace(/^0+/g,"");var h=BigInteger.valueOf(parseInt(k));return h=h.multiply(BigInteger.valueOf(100000000)),h=h.add(BigInteger.valueOf(parseInt(j))),h},sha256ripe160:function(b){return Crypto.RIPEMD160(Crypto.SHA256(b,{asBytes:!0}),{asBytes:!0})}};for(var i in Crypto.util){Crypto.util.hasOwnProperty(i)&&(Bitcoin.Util[i]=Crypto.util[i])}(function(d){d.Base58={alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",base:BigInteger.valueOf(58),encode:function(b){var k=BigInteger.fromByteArrayUnsigned(b),j=[];while(k.compareTo(c.base)>=0){var h=k.mod(c.base);j.unshift(c.alphabet[h.intValue()]),k=k.subtract(h).divide(c.base)}j.unshift(c.alphabet[k.intValue()]);for(var g=0;g<b.length;g++){if(b[g]==0){j.unshift(c.alphabet[0])}else{break}}return s=j.join(""),s},decode:function(b){bi=BigInteger.valueOf(0);var k=0;for(var j=b.length-1;j>=0;j--){var h=c.alphabet.indexOf(b[j]);bi=bi.add(BigInteger.valueOf(h).multiply(c.base.pow(b.length-1-j))),b[j]=="1"?k++:k=0}var g=bi.toByteArrayUnsigned();while(k-->0){g.unshift(0)}return g}};var c=d.Base58})("undefined"!=typeof Bitcoin?Bitcoin:module.exports);Bitcoin.Address=function(b){"string"==typeof b&&(b=Bitcoin.Address.decodeString(b)),this.hash=b,this.version=0},Bitcoin.Address.prototype.toString=function(){var e=this.hash.slice(0);e.unshift(this.version);var d=Crypto.SHA256(Crypto.SHA256(e,{asBytes:!0}),{asBytes:!0}),f=e.concat(d.slice(0,4));return Bitcoin.Base58.encode(f)},Bitcoin.Address.prototype.getHashBase64=function(){return Crypto.util.bytesToBase64(this.hash)},Bitcoin.Address.decodeString=function(g){var f=Bitcoin.Base58.decode(g),k=f.slice(0,21),j=Crypto.SHA256(Crypto.SHA256(k,{asBytes:!0}),{asBytes:!0});if(j[0]!=f[21]||j[1]!=f[22]||j[2]!=f[23]||j[3]!=f[24]){throw"Checksum validation failed!"}var h=k.shift();if(h!=0){throw"Version "+h+" not supported!"}return k};function integerToBytes(e,d){var f=e.toByteArrayUnsigned();if(d<f.length){f=f.slice(f.length-d)}else{while(d>f.length){f.unshift(0)}}return f}function dmp(b){return b instanceof BigInteger||(b=b.toBigInteger()),Crypto.util.bytesToHex(b.toByteArrayUnsigned())}ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ECPointFp.prototype.getEncoded=function(f){var e=this.getX().toBigInteger(),h=this.getY().toBigInteger(),g=integerToBytes(e,32);return f?h.testBit(0)?g.unshift(2):g.unshift(3):(g.unshift(4),g=g.concat(integerToBytes(h,32))),g},ECPointFp.decodeFrom=function(k,j){var q=j[0],p=j.length-1,o=j.slice(1,1+p/2),n=j.slice(1+p/2,1+p);o.unshift(0),n.unshift(0);var m=new BigInteger(o),l=new BigInteger(n);return new ECPointFp(k,k.fromBigInteger(m),k.fromBigInteger(l))},ECPointFp.prototype.add2D=function(h){if(this.isInfinity()){return h}if(h.isInfinity()){return this}if(this.x.equals(h.x)){return this.y.equals(h.y)?this.twice():this.curve.getInfinity()}var g=h.x.subtract(this.x),m=h.y.subtract(this.y),l=m.divide(g),k=l.square().subtract(this.x).subtract(h.x),j=l.multiply(this.x.subtract(k)).subtract(this.y);return new ECPointFp(this.curve,k,j)},ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=this.curve.fromBigInteger(BigInteger.valueOf(2)),f=this.curve.fromBigInteger(BigInteger.valueOf(3)),k=this.x.square().multiply(f).add(this.curve.a).divide(this.y.multiply(g)),j=k.square().subtract(this.x.multiply(g)),h=k.multiply(this.x.subtract(j)).subtract(this.y);return new ECPointFp(this.curve,j,h)},ECPointFp.prototype.multiply2D=function(k){if(this.isInfinity()){return this}if(k.signum()==0){return this.curve.getInfinity()}var j=k,q=j.multiply(new BigInteger("3")),p=this.negate(),o=this,n;for(n=q.bitLength()-2;n>0;--n){o=o.twice();var m=q.testBit(n),l=j.testBit(n);m!=l&&(o=o.add2D(m?this:p))}return o},ECPointFp.prototype.isOnCurve=function(){var j=this.getX().toBigInteger(),h=this.getY().toBigInteger(),o=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),m=this.curve.getQ(),l=h.multiply(h).mod(m),k=j.multiply(j).multiply(j).add(o.multiply(j)).add(n).mod(m);return l.equals(k)},ECPointFp.prototype.validate=function(){var e=this.curve.getQ();if(this.isInfinity()){throw new Error("Point is at infinity.")}var d=this.getX().toBigInteger(),f=this.getY().toBigInteger();if(d.compareTo(BigInteger.ONE)<0||d.compareTo(e.subtract(BigInteger.ONE))>0){throw new Error("x coordinate out of bounds")}if(f.compareTo(BigInteger.ONE)<0||f.compareTo(e.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(e).isInfinity()){throw new Error("Point is not a scalar multiple of G.")}return !0},Bitcoin.ECDSA=function(){function h(k,j,q,p){var o=Math.max(j.bitLength(),p.bitLength()),n=k.add2D(q),m=k.curve.getInfinity();for(var l=o-1;l>=0;--l){m=m.twice2D(),m.z=BigInteger.ONE,j.testBit(l)?p.testBit(l)?m=m.add2D(n):m=m.add2D(k):p.testBit(l)&&(m=m.add2D(q))}return m}var f=getSECCurveByName("secp256k1"),e=new SecureRandom,g={getBigRandom:function(b){return(new BigInteger(b.bitLength(),e)).mod(b.subtract(BigInteger.ONE)).add(BigInteger.ONE)},sign:function(v,u){var r=u,q=f.getN(),p=BigInteger.fromByteArrayUnsigned(v);do{var o=g.getBigRandom(q),n=f.getG(),m=n.multiply(o),d=m.getX().toBigInteger().mod(q)}while(d.compareTo(BigInteger.ZERO)<=0);var a=o.modInverse(q).multiply(p.add(r.multiply(d))).mod(q);return{r:d,s:a}},serializeSig:function(k,j){var n=k.toByteArrayUnsigned(),m=j.toByteArrayUnsigned(),l=[];return l.push(2),l.push(n.length),l=l.concat(n),l.push(2),l.push(m.length),l=l.concat(m),l.unshift(l.length),l.unshift(48),l},verify:function(G,F,E){var D=g.parseSig(F),C=D.r,B=D.s,A=f.getN(),y=BigInteger.fromByteArrayUnsigned(G);if(C.compareTo(BigInteger.ONE)<0||C.compareTo(A)>=0){return !1}if(B.compareTo(BigInteger.ONE)<0||B.compareTo(A)>=0){return !1}var x=B.modInverse(A),w=y.multiply(x).mod(A),v=C.multiply(x).mod(A),u=f.getG(),d=ECPointFp.decodeFrom(f.getCurve(),E),c=h(u,w,d,v),a=c.x.toBigInteger().mod(A);return a.equals(C)},parseSig:function(k){var j;if(k[0]!=48){throw new Error("Signature not a valid DERSequence")}j=2;if(k[j]!=2){throw new Error("First element in signature must be a DERInteger")}var o=k.slice(j+2,j+2+k[j+1]);j+=2+k[j+1];if(k[j]!=2){throw new Error("Second element in signature must be a DERInteger")}var n=k.slice(j+2,j+2+k[j+1]);j+=2+k[j+1];var m=BigInteger.fromByteArrayUnsigned(o),l=BigInteger.fromByteArrayUnsigned(n);return{r:m,s:l}}};return g}();Bitcoin.ECKey=function(){var f=Bitcoin.ECDSA,e=getSECCurveByName("secp256k1"),h=new SecureRandom,g=function(b){if(!b){var a=e.getN();this.priv=f.getBigRandom(a)}else{b instanceof BigInteger?this.priv=b:Bitcoin.Util.isArray(b)?this.priv=BigInteger.fromByteArrayUnsigned(b):"string"==typeof b&&(this.priv=BigInteger.fromByteArrayUnsigned(Crypto.util.base64ToBytes(b)))}};return g.prototype.getPub=function(){return this.pub?this.pub:this.pub=e.getG().multiply(this.priv).getEncoded()},g.prototype.getPubKeyHash=function(){return this.pubKeyHash?this.pubKeyHash:this.pubKeyHash=Bitcoin.Util.sha256ripe160(this.getPub())},g.prototype.getBitcoinAddress=function(){var d=this.getPubKeyHash(),c=new Bitcoin.Address(d);return c},g.prototype.setPub=function(b){this.pub=b},g.prototype.toString=function(b){return b==="base64"?Crypto.util.bytesToBase64(this.priv.toByteArrayUnsigned()):Crypto.util.bytesToHex(this.priv.toByteArrayUnsigned())},g.prototype.sign=function(a){return f.sign(a,this.priv)},g.prototype.verify=function(a,d){return f.verify(a,d,this.getPub())},g}();(function(){var d=Bitcoin.Opcode=function(b){this.code=b};d.prototype.toString=function(){return d.reverseMap[this.code]},d.map={OP_0:0,OP_FALSE:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_1:81,OP_TRUE: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_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},d.reverseMap=[];for(var c in d.map){d.reverseMap[d.map[c]]=c}})();(function(){var Opcode=Bitcoin.Opcode;for(var i in Opcode.map){eval("var "+i+" = "+Opcode.map[i]+";")}var Script=Bitcoin.Script=function(a){if(!a){this.buffer=[]}else{if("string"==typeof a){this.buffer=Crypto.util.base64ToBytes(a)}else{if(Bitcoin.Util.isArray(a)){this.buffer=a}else{if(a instanceof Script){this.buffer=a.buffer}else{throw new Error("Invalid script")}}}}this.parse()};Script.prototype.parse=function(){function c(c){a.chunks.push(a.buffer.slice(b,b+c)),b+=c}var a=this;this.chunks=[];var b=0;while(b<this.buffer.length){var d=this.buffer[b++];d>=240&&(d=d<<8|this.buffer[b++]);var e;d>0&&d<OP_PUSHDATA1?c(d):d==OP_PUSHDATA1?(e=this.buffer[b++],c(e)):d==OP_PUSHDATA2?(e=this.buffer[b++]<<8|this.buffer[b++],c(e)):d==OP_PUSHDATA4?(e=this.buffer[b++]<<24|this.buffer[b++]<<16|this.buffer[b++]<<8|this.buffer[b++],c(e)):this.chunks.push(d)}},Script.prototype.getOutType=function(){if(this.chunks.length==5&&this.chunks[0]==OP_DUP&&this.chunks[1]==OP_HASH160&&this.chunks[3]==OP_EQUALVERIFY&&this.chunks[4]==OP_CHECKSIG){console.log("Address");return"Address"}else{if(this.chunks.length==2&&this.chunks[1]==OP_CHECKSIG){return"Pubkey"}else{return"Strange"}}},Script.prototype.simpleOutPubKeyHash=function(){switch(this.getOutType()){case"Address":return this.chunks[2];case"Pubkey":return Bitcoin.Util.sha256ripe160(this.chunks[0]);default:throw new Error("Encountered non-standard scriptPubKey")}},Script.prototype.getInType=function(){if(this.chunks.length==1){return"Pubkey"}if(this.chunks.length==2&&Bitcoin.Util.isArray(this.chunks[0])&&Bitcoin.Util.isArray(this.chunks[1])){return"Address"}throw console.log(this.chunks),new Error("Encountered non-standard scriptSig")},Script.prototype.simpleInPubKey=function(){switch(this.getInType()){case"Address":return this.chunks[1];case"Pubkey":return this.chunks[0];default:throw new Error("Encountered non-standard scriptSig")}},Script.prototype.simpleInPubKeyHash=function(){return Bitcoin.Util.sha256ripe160(this.simpleInPubKey())},Script.prototype.writeOp=function(a){this.buffer.push(a),this.chunks.push(a)},Script.prototype.writeBytes=function(a){a.length<OP_PUSHDATA1?this.buffer.push(a.length):a.length<=255?(this.buffer.push(OP_PUSHDATA1),this.buffer.push(a.length)):a.length<=65535?(this.buffer.push(OP_PUSHDATA2),this.buffer.push(a.length&255),this.buffer.push(a.length>>>8&255)):(this.buffer.push(OP_PUSHDATA4),this.buffer.push(a.length&255),this.buffer.push(a.length>>>8&255),this.buffer.push(a.length>>>16&255),this.buffer.push(a.length>>>24&255)),this.buffer=this.buffer.concat(a),this.chunks.push(a)},Script.createOutputScript=function(a){var b=new Script;return b.writeOp(OP_DUP),b.writeOp(OP_HASH160),b.writeBytes(a.hash),b.writeOp(OP_EQUALVERIFY),b.writeOp(OP_CHECKSIG),b},Script.createInputScript=function(a,b){var c=new Script;return c.writeBytes(a),c.writeBytes(b),c},Script.prototype.clone=function(){return new Script(this.buffer)}})();(function(){var r=Bitcoin.Script,q=Bitcoin.Transaction=function(d){this.version=1,this.lock_time=0,this.ins=[],this.outs=[],this.timestamp=null,this.block=null;if(d){d.hash&&(this.hash=d.hash),d.version&&(this.version=d.version),d.lock_time&&(this.lock_time=d.lock_time);if(d.ins&&d.ins.length){for(var c=0;c<d.ins.length;c++){this.addInput(new k(d.ins[c]))}}if(d.outs&&d.outs.length){for(var c=0;c<d.outs.length;c++){this.addOutput(new j(d.outs[c]))}}d.timestamp&&(this.timestamp=d.timestamp),d.block&&(this.block=d.block)}};q.objectify=function(b){var f=[];for(var e=0;e<b.length;e++){f.push(new q(b[e]))}return f},q.prototype.addInput=function(d,c){arguments[0] instanceof k?this.ins.push(arguments[0]):this.ins.push(new k({outpoint:{hash:d.hash,index:c},script:new Bitcoin.Script,sequence:4294967295}))},q.prototype.addOutput=function(a,d){if(arguments[0] instanceof j){this.outs.push(arguments[0])}else{if(d instanceof BigInteger){d=d.toByteArrayUnsigned().reverse();while(d.length<8){d.push(0)}}else{!Bitcoin.Util.isArray(d)}this.outs.push(new j({value:d,script:r.createOutputScript(a)}))}},q.prototype.serialize=function(){var g=[];g=g.concat(Crypto.util.wordsToBytes([parseInt(this.version)]).reverse()),g=g.concat(Bitcoin.Util.numToVarInt(this.ins.length));for(var f=0;f<this.ins.length;f++){var v=this.ins[f];g=g.concat(Crypto.util.base64ToBytes(v.outpoint.hash)),g=g.concat(Crypto.util.wordsToBytes([parseInt(v.outpoint.index)]).reverse());var u=v.script.buffer;g=g.concat(Bitcoin.Util.numToVarInt(u.length)),g=g.concat(u),g=g.concat(Crypto.util.wordsToBytes([parseInt(v.sequence)]).reverse())}g=g.concat(Bitcoin.Util.numToVarInt(this.outs.length));for(var f=0;f<this.outs.length;f++){var h=this.outs[f];g=g.concat(h.value);var u=h.script.buffer;g=g.concat(Bitcoin.Util.numToVarInt(u.length)),g=g.concat(u)}return g=g.concat(Crypto.util.wordsToBytes([parseInt(this.lock_time)]).reverse()),g};var p=171,o=1,n=2,m=3,l=80;q.prototype.hashTransactionForSignature=function(a,w,v){var u=this.clone();for(var g=0;g<u.ins.length;g++){u.ins[g].script=new r}u.ins[w].script=a;if((v&31)==n){u.outs=[];for(var g=0;g<u.ins.length;g++){g!=w&&(u.ins[g].sequence=0)}}else{(v&31)!=m}v&l&&(u.ins=[u.ins[w]]);var f=u.serialize();f=f.concat(Crypto.util.wordsToBytes([parseInt(v)]).reverse());var e=Crypto.SHA256(f,{asBytes:!0});return Crypto.SHA256(e,{asBytes:!0})},q.prototype.getHash=function(){var b=this.serialize();return Crypto.SHA256(Crypto.SHA256(b,{asBytes:!0}),{asBytes:!0})},q.prototype.clone=function(){var b=new q;b.version=this.version,b.lock_time=this.lock_time;for(var h=0;h<this.ins.length;h++){var g=this.ins[h].clone();b.addInput(g)}for(var h=0;h<this.outs.length;h++){var f=this.outs[h].clone();b.addOutput(f)}return b},q.prototype.analyze=function(G){if(G instanceof Bitcoin.Wallet){var F=!0,E=!0,D=null,C=null,B=null;for(var A=this.outs.length-1;A>=0;A--){var y=this.outs[A],x=y.script.simpleOutPubKeyHash();G.hasHash(x)?C=x:E=!1,D=x}for(var A=this.ins.length-1;A>=0;A--){var w=this.ins[A];B=w.script.simpleInPubKeyHash();if(!G.hasHash(B)){F=!1;break}}var v=this.calcImpact(G),u={};return u.impact=v,v.sign>0&&v.value.compareTo(BigInteger.ZERO)>0?(u.type="recv",u.addr=new Bitcoin.Address(C)):F&&E?u.type="self":F?(u.type="sent",u.addr=new Bitcoin.Address(D)):u.type="other",u}return null},q.prototype.getDescription=function(d){var c=this.analyze(d);if(!c){return""}switch(c.type){case"recv":return"Received with "+c.addr;case"sent":return"Payment to "+c.addr;case"self":return"Payment to yourself";case"other":default:return""}},q.prototype.getTotalValue=function(){var e=BigInteger.ZERO;for(var d=0;d<this.outs.length;d++){var f=this.outs[d];e=e.add(Bitcoin.Util.valueToBigInt(f.value))}return e},q.prototype.calcImpact=function(v){if(v instanceof Bitcoin.Wallet){var u=BigInteger.ZERO;for(var C=0;C<this.outs.length;C++){var B=this.outs[C],A=Crypto.util.bytesToBase64(B.script.simpleOutPubKeyHash());v.hasHash(A)&&(u=u.add(Bitcoin.Util.valueToBigInt(B.value)))}var y=BigInteger.ZERO;for(var C=0;C<this.ins.length;C++){var x=this.ins[C],A=Crypto.util.bytesToBase64(x.script.simpleInPubKeyHash());if(v.hasHash(A)){var w=v.txIndex[x.outpoint.hash];w&&(y=y.add(Bitcoin.Util.valueToBigInt(w.outs[x.outpoint.index].value)))}}return u.compareTo(y)>=0?{sign:1,value:u.subtract(y)}:{sign:-1,value:y.subtract(u)}}return BigInteger.ZERO};var k=Bitcoin.TransactionIn=function(a){this.outpoint=a.outpoint,a.script instanceof r?this.script=a.script:this.script=new r(a.script),this.sequence=a.sequence};k.prototype.clone=function(){var b=new k({outpoint:{hash:this.outpoint.hash,index:this.outpoint.index},script:this.script.clone(),sequence:this.sequence});return b};var j=Bitcoin.TransactionOut=function(a){a.script instanceof r?this.script=a.script:this.script=new r(a.script);if(Bitcoin.Util.isArray(a.value)){this.value=a.value}else{if("string"==typeof a.value){var d=(new BigInteger(a.value,10)).toString(16);while(d.length<16){d="0"+d}this.value=Crypto.util.hexToBytes(d)}}};j.prototype.clone=function(){var b=new j({script:this.script.clone(),value:this.value.slice(0)});return b}})();Bitcoin.Wallet=function(){var f=Bitcoin.Script,e=Bitcoin.TransactionIn,h=Bitcoin.TransactionOut,g=function(){var b=[];this.addressHashes=[],this.txIndex={},this.unspentOuts=[],this.addressPointer=0,this.addKey=function(a,d){a instanceof Bitcoin.ECKey||(a=new Bitcoin.ECKey(a)),b.push(a),d&&("string"==typeof d&&(d=Crypto.util.base64ToBytes(d)),a.pub=d),this.addressHashes.push(a.getBitcoinAddress().getHashBase64())},this.addKeys=function(j,d){"string"==typeof j&&(j=j.split(",")),"string"==typeof d&&(d=d.split(",")),console.log(d);if(Array.isArray(d)&&j.length==d.length){for(var k=0;k<j.length;k++){this.addKey(j[k],d[k])}}else{for(var k=0;k<j.length;k++){this.addKey(j[k])}}},this.getKeys=function(){var a=[];for(var d=0;d<b.length;d++){a.push(b[d].toString("base64"))}return a},this.getPubKeys=function(){var a=[];for(var d=0;d<b.length;d++){a.push(Crypto.util.bytesToBase64(b[d].getPub()))}return a},this.clear=function(){b=[]},this.getLength=function(){return b.length},this.getAllAddresses=function(){var a=[];for(var d=0;d<b.length;d++){a.push(b[d].getBitcoinAddress())}return a},this.getCurAddress=function(){return b[this.addressPointer]?b[this.addressPointer].getBitcoinAddress():null},this.getNextAddress=function(){return b.length?(this.addressPointer=(this.addressPointer+1)%b.length,b[this.addressPointer].getBitcoinAddress()):null},this.signWithKey=function(a,k){a=Crypto.util.bytesToBase64(a);for(var j=0;j<this.addressHashes.length;j++){if(this.addressHashes[j]==a){return b[j].sign(k)}}throw new Error("Missing key for signature")},this.getPubKeyFromHash=function(a){a=Crypto.util.bytesToBase64(a);for(var d=0;d<this.addressHashes.length;d++){if(this.addressHashes[d]==a){return console.log(Crypto.util.bytesToBase64(Bitcoin.Util.sha256ripe160(b[d].getPub())),a),b[d].getPub()}}throw new Error("Hash unknown")}};return g.prototype.generateAddress=function(){this.addKey(new Bitcoin.ECKey)},g.prototype.process=function(b){if(this.txIndex[b.hash]){return}for(var p=0;p<b.outs.length;p++){var o=new h(b.outs[p]),n=Crypto.util.bytesToBase64(o.script.simpleOutPubKeyHash());for(var m=0;m<this.addressHashes.length;m++){if(this.addressHashes[m]===n){this.unspentOuts.push({tx:b,index:p,out:o});break}}}for(var p=0;p<b.ins.length;p++){var l=new e(b.ins[p]),k=l.script.simpleInPubKey(),n=Crypto.util.bytesToBase64(Bitcoin.Util.sha256ripe160(k));for(var m=0;m<this.addressHashes.length;m++){if(this.addressHashes[m]===n){for(var c=0;c<this.unspentOuts.length;c++){l.outpoint.hash==this.unspentOuts[c].tx.hash&&l.outpoint.index==this.unspentOuts[c].index&&this.unspentOuts.splice(c,1)}break}}}this.txIndex[b.hash]=b},g.prototype.getBalance=function(){var j=BigInteger.valueOf(0);for(var d=0;d<this.unspentOuts.length;d++){var k=this.unspentOuts[d].out;j=j.add(Bitcoin.Util.valueToBigInt(k.value))}return j},g.prototype.createSend=function(C,B,A){var y=[],x=B.add(A),w=BigInteger.ZERO;for(var v=0;v<this.unspentOuts.length;v++){y.push(this.unspentOuts[v]),w=w.add(Bitcoin.Util.valueToBigInt(this.unspentOuts[v].out.value));if(w.compareTo(x)>=0){break}}if(w.compareTo(x)<0){throw new Error("Insufficient funds.")}console.log(y);var u=w.subtract(x),r=new Bitcoin.Transaction;for(var v=0;v<y.length;v++){r.addInput(y[v].tx,y[v].index)}r.addOutput(C,B),u.compareTo(BigInteger.ZERO)>0&&r.addOutput(this.getNextAddress(),u);var q=1;for(var v=0;v<r.ins.length;v++){var p=r.hashTransactionForSignature(y[v].out.script,v,q),o=y[v].out.script.simpleOutPubKeyHash(),a=this.signWithKey(o,p);a.push(parseInt(q)),r.ins[v].script=f.createInputScript(a,this.getPubKeyFromHash(o))}return console.log(r),console.log("pubkey: "+Crypto.util.bytesToHex(this.getPubKeyFromHash(o))),r},g.prototype.clearTransactions=function(){this.txIndex={},this.unspentOuts=[]},g.prototype.hasHash=function(d){Bitcoin.Util.isArray(d)&&(d=Crypto.util.bytesToBase64(d));for(var c=0;c<this.addressHashes.length;c++){if(this.addressHashes[c]===d){return !0}}return !1},g}();var TransactionDatabase=function(){this.txs=[],this.txIndex={}};EventEmitter.augment(TransactionDatabase.prototype),TransactionDatabase.prototype.addTransaction=function(b){this.addTransactionNoUpdate(b),$(this).trigger("update")},TransactionDatabase.prototype.addTransactionNoUpdate=function(b){if(this.txIndex[b.hash]){return}this.txs.push(new Bitcoin.Transaction(b)),this.txIndex[b.hash]=b},TransactionDatabase.prototype.removeTransaction=function(b){this.removeTransactionNoUpdate(b),$(this).trigger("update")},TransactionDatabase.prototype.removeTransactionNoUpdate=function(f){var e=this.txIndex[f];if(!e){return}for(var h=0,g=this.txs.length;h<g;h++){if(this.txs[h].hash==f){this.txs.splice(h,1);break}}delete this.txIndex[f]},TransactionDatabase.prototype.loadTransactions=function(d){for(var c=0;c<d.length;c++){this.addTransactionNoUpdate(d[c])}$(this).trigger("update")},TransactionDatabase.prototype.getTransactions=function(){return this.txs},TransactionDatabase.prototype.clear=function(){this.txs=[],this.txIndex={},$(this).trigger("update")};
  7.  
  8. (typeof Crypto=="undefined"||!Crypto.util)&&function(){var c=window.Crypto={},j=c.util={rotl:function(e,d){return e<<d|e>>>32-d},rotr:function(e,d){return e<<32-d|e>>>d},endian:function(e){if(e.constructor==Number)return j.rotl(e,8)&16711935|j.rotl(e,24)&4278255360;for(var d=0;d<e.length;d++)e[d]=j.endian(e[d]);return e},randomBytes:function(e){for(var d=[];e>0;e--)d.push(Math.floor(Math.random()*256));return d},bytesToWords:function(e){for(var d=[],b=0,a=0;b<e.length;b++,a+=8)d[a>>>5]|=(e[b]&255)<<
  9. 24-a%32;return d},wordsToBytes:function(e){for(var d=[],b=0;b<e.length*32;b+=8)d.push(e[b>>>5]>>>24-b%32&255);return d},bytesToHex:function(e){for(var d=[],b=0;b<e.length;b++)d.push((e[b]>>>4).toString(16)),d.push((e[b]&15).toString(16));return d.join("")},hexToBytes:function(e){for(var d=[],b=0;b<e.length;b+=2)d.push(parseInt(e.substr(b,2),16));return d},bytesToBase64:function(e){if(typeof btoa=="function")return btoa(f.bytesToString(e));for(var d=[],b=0;b<e.length;b+=3)for(var a=e[b]<<16|e[b+1]<<
  10. 8|e[b+2],k=0;k<4;k++)b*8+k*6<=e.length*8?d.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6*(3-k)&63)):d.push("=");return d.join("")},base64ToBytes:function(e){if(typeof atob=="function")return f.stringToBytes(atob(e));for(var e=e.replace(/[^A-Z0-9+\/]/ig,""),d=[],b=0,a=0;b<e.length;a=++b%4)a!=0&&d.push(("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e.charAt(b-1))&Math.pow(2,-2*a+8)-1)<<a*2|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e.charAt(b))>>>
  11. 6-a*2);return d}},c=c.charenc={};c.UTF8={stringToBytes:function(e){return f.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(f.bytesToString(e)))}};var f=c.Binary={stringToBytes:function(e){for(var d=[],b=0;b<e.length;b++)d.push(e.charCodeAt(b)&255);return d},bytesToString:function(e){for(var d=[],b=0;b<e.length;b++)d.push(String.fromCharCode(e[b]));return d.join("")}}}();
  12. (function(){var c=Crypto,j=c.util,f=c.charenc,e=f.UTF8,d=f.Binary,b=c.SHA1=function(a,k){var e=j.wordsToBytes(b._sha1(a));return k&&k.asBytes?e:k&&k.asString?d.bytesToString(e):j.bytesToHex(e)};b._sha1=function(a){a.constructor==String&&(a=e.stringToBytes(a));var b=j.bytesToWords(a),l=a.length*8,a=[],d=1732584193,h=-271733879,c=-1732584194,f=271733878,s=-1009589776;b[l>>5]|=128<<24-l%32;b[(l+64>>>9<<4)+15]=l;for(l=0;l<b.length;l+=16){for(var g=d,n=h,r=c,m=f,o=s,p=0;p<80;p++){if(p<16)a[p]=b[l+p];else{var v=
  13. a[p-3]^a[p-8]^a[p-14]^a[p-16];a[p]=v<<1|v>>>31}v=(d<<5|d>>>27)+s+(a[p]>>>0)+(p<20?(h&c|~h&f)+1518500249:p<40?(h^c^f)+1859775393:p<60?(h&c|h&f|c&f)-1894007588:(h^c^f)-899497514);s=f;f=c;c=h<<30|h>>>2;h=d;d=v}d+=g;h+=n;c+=r;f+=m;s+=o}return[d,h,c,f,s]};b._blocksize=16;b._digestsize=20})();
  14. (function(){var c=Crypto,j=c.util,f=c.charenc,e=f.UTF8,d=f.Binary;c.HMAC=function(b,a,k,l){a.constructor==String&&(a=e.stringToBytes(a));k.constructor==String&&(k=e.stringToBytes(k));k.length>b._blocksize*4&&(k=b(k,{asBytes:!0}));for(var c=k.slice(0),k=k.slice(0),h=0;h<b._blocksize*4;h++)c[h]^=92,k[h]^=54;b=b(c.concat(b(k.concat(a),{asBytes:!0})),{asBytes:!0});return l&&l.asBytes?b:l&&l.asString?d.bytesToString(b):j.bytesToHex(b)}})();
  15. (function(){var c=Crypto,j=c.util,f=c.charenc,e=f.UTF8,d=f.Binary;c.PBKDF2=function(b,a,k,l){function u(b,a){return c.HMAC(h,a,b,{asBytes:!0})}b.constructor==String&&(b=e.stringToBytes(b));a.constructor==String&&(a=e.stringToBytes(a));for(var h=l&&l.hasher||c.SHA1,f=l&&l.iterations||1,q=[],s=1;q.length<k;){for(var g=u(b,a.concat(j.wordsToBytes([s]))),n=g,r=1;r<f;r++)for(var n=u(b,n),m=0;m<g.length;m++)g[m]^=n[m];q=q.concat(g);s++}q.length=k;return l&&l.asBytes?q:l&&l.asString?d.bytesToString(q):j.bytesToHex(q)}})();
  16. (function(c){function j(b,a){var k=b._blocksize*4;return k-a.length%k}var f=c.pad={},e=function(b){for(var a=b.pop(),k=1;k<a;k++)b.pop()};f.NoPadding={pad:function(){},unpad:function(){}};f.ZeroPadding={pad:function(b,a){var k=b._blocksize*4,e=a.length%k;if(e!=0)for(e=k-e;e>0;e--)a.push(0)},unpad:function(){}};f.iso7816={pad:function(b,a){var e=j(b,a);for(a.push(128);e>1;e--)a.push(0)},unpad:function(b){for(;b.pop()!=128;);}};f.ansix923={pad:function(b,a){for(var e=j(b,a),d=1;d<e;d++)a.push(0);a.push(e)},
  17. unpad:e};f.iso10126={pad:function(b,a){for(var e=j(b,a),d=1;d<e;d++)a.push(Math.floor(Math.random()*256));a.push(e)},unpad:e};f.pkcs7={pad:function(b,a){for(var e=j(b,a),d=0;d<e;d++)a.push(e)},unpad:e};var c=c.mode={},d=c.Mode=function(b){if(b)this._padding=b};d.prototype={encrypt:function(b,a,e){this._padding.pad(b,a);this._doEncrypt(b,a,e)},decrypt:function(b,a,e){this._doDecrypt(b,a,e);this._padding.unpad(a)},_padding:f.iso7816};e=(c.ECB=function(){d.apply(this,arguments)}).prototype=new d;e._doEncrypt=
  18. function(b,a){for(var e=b._blocksize*4,d=0;d<a.length;d+=e)b._encryptblock(a,d)};e._doDecrypt=function(b,a){for(var e=b._blocksize*4,d=0;d<a.length;d+=e)b._decryptblock(a,d)};e.fixOptions=function(b){b.iv=[]};e=(c.CBC=function(){d.apply(this,arguments)}).prototype=new d;e._doEncrypt=function(b,a,e){for(var d=b._blocksize*4,c=0;c<a.length;c+=d){if(c==0)for(var h=0;h<d;h++)a[h]^=e[h];else for(h=0;h<d;h++)a[c+h]^=a[c+h-d];b._encryptblock(a,c)}};e._doDecrypt=function(b,a,e){for(var d=b._blocksize*4,c=
  19. 0;c<a.length;c+=d){var h=a.slice(c,c+d);b._decryptblock(a,c);for(var f=0;f<d;f++)a[c+f]^=e[f];e=h}};e=(c.CFB=function(){d.apply(this,arguments)}).prototype=new d;e._padding=f.NoPadding;e._doEncrypt=function(b,e,d){for(var c=b._blocksize*4,d=d.slice(0),f=0;f<e.length;f++){var h=f%c;h==0&&b._encryptblock(d,0);e[f]^=d[h];d[h]=e[f]}};e._doDecrypt=function(e,a,d){for(var c=e._blocksize*4,d=d.slice(0),f=0;f<a.length;f++){var h=f%c;h==0&&e._encryptblock(d,0);var j=a[f];a[f]^=d[h];d[h]=j}};e=(c.OFB=function(){d.apply(this,
  20. arguments)}).prototype=new d;e._padding=f.NoPadding;e._doEncrypt=function(e,d,c){for(var f=e._blocksize*4,c=c.slice(0),j=0;j<d.length;j++)j%f==0&&e._encryptblock(c,0),d[j]^=c[j%f]};e._doDecrypt=e._doEncrypt;c=(c.CTR=function(){d.apply(this,arguments)}).prototype=new d;c._padding=f.NoPadding;c._doEncrypt=function(e,d,c){for(var f=e._blocksize*4,c=c.slice(0),j=0;j<d.length;){var h=c.slice(0);e._encryptblock(h,0);for(var t=0;j<d.length&&t<f;t++,j++)d[j]^=h[t];++c[f-1]==256&&(c[f-1]=0,++c[f-2]==256&&
  21. (c[f-2]=0,++c[f-3]==256&&(c[f-3]=0,++c[f-4])))}};c._doDecrypt=c._doEncrypt})(Crypto);
  22. (function(){function c(e,d){for(var b=0,a=0;a<8;a++){d&1&&(b^=e);var c=e&128,e=e<<1&255;c&&(e^=27);d>>>=1}return b}for(var j=Crypto,f=j.util,e=j.charenc.UTF8,d=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,
  23. 208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,
  24. 206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],b=[],a=0;a<256;a++)b[d[a]]=a;for(var k=[],l=[],u=[],h=[],t=[],q=[],a=0;a<256;a++)k[a]=c(a,2),l[a]=c(a,3),u[a]=c(a,9),h[a]=c(a,11),t[a]=c(a,13),q[a]=c(a,14);var s=[0,1,2,4,8,16,32,64,128,27,54],g=[[],[],[],[]],n,r,m,o=j.AES={encrypt:function(d,b,a){var a=a||{},i=a.mode||new j.mode.OFB;i.fixOptions&&i.fixOptions(a);var d=d.constructor==String?e.stringToBytes(d):d,c=a.iv||f.randomBytes(o._blocksize*4),b=b.constructor==String?j.PBKDF2(b,
  25. c,32,{asBytes:!0}):b;o._init(b);i.encrypt(o,d,c);d=a.iv?d:c.concat(d);return a&&a.asBytes?d:f.bytesToBase64(d)},decrypt:function(d,b,a){var a=a||{},i=a.mode||new j.mode.OFB;i.fixOptions&&i.fixOptions(a);var d=d.constructor==String?f.base64ToBytes(d):d,c=a.iv||d.splice(0,o._blocksize*4),b=b.constructor==String?j.PBKDF2(b,c,32,{asBytes:!0}):b;o._init(b);i.decrypt(o,d,c);return a&&a.asBytes?d:e.bytesToString(d)},_blocksize:4,_encryptblock:function(e,a){for(var b=0;b<o._blocksize;b++)for(var i=0;i<4;i++)g[b][i]=
  26. e[a+i*4+b];for(b=0;b<4;b++)for(i=0;i<4;i++)g[b][i]^=m[i][b];for(var c=1;c<r;c++){for(b=0;b<4;b++)for(i=0;i<4;i++)g[b][i]=d[g[b][i]];g[1].push(g[1].shift());g[2].push(g[2].shift());g[2].push(g[2].shift());g[3].unshift(g[3].pop());for(i=0;i<4;i++){var b=g[0][i],f=g[1][i],h=g[2][i],j=g[3][i];g[0][i]=k[b]^l[f]^h^j;g[1][i]=b^k[f]^l[h]^j;g[2][i]=b^f^k[h]^l[j];g[3][i]=l[b]^f^h^k[j]}for(b=0;b<4;b++)for(i=0;i<4;i++)g[b][i]^=m[c*4+i][b]}for(b=0;b<4;b++)for(i=0;i<4;i++)g[b][i]=d[g[b][i]];g[1].push(g[1].shift());
  27. g[2].push(g[2].shift());g[2].push(g[2].shift());g[3].unshift(g[3].pop());for(b=0;b<4;b++)for(i=0;i<4;i++)g[b][i]^=m[r*4+i][b];for(b=0;b<o._blocksize;b++)for(i=0;i<4;i++)e[a+i*4+b]=g[b][i]},_decryptblock:function(d,e){for(var a=0;a<o._blocksize;a++)for(var c=0;c<4;c++)g[a][c]=d[e+c*4+a];for(a=0;a<4;a++)for(c=0;c<4;c++)g[a][c]^=m[r*4+c][a];for(var f=1;f<r;f++){g[1].unshift(g[1].pop());g[2].push(g[2].shift());g[2].push(g[2].shift());g[3].push(g[3].shift());for(a=0;a<4;a++)for(c=0;c<4;c++)g[a][c]=b[g[a][c]];
  28. for(a=0;a<4;a++)for(c=0;c<4;c++)g[a][c]^=m[(r-f)*4+c][a];for(c=0;c<4;c++){var a=g[0][c],j=g[1][c],k=g[2][c],l=g[3][c];g[0][c]=q[a]^h[j]^t[k]^u[l];g[1][c]=u[a]^q[j]^h[k]^t[l];g[2][c]=t[a]^u[j]^q[k]^h[l];g[3][c]=h[a]^t[j]^u[k]^q[l]}}g[1].unshift(g[1].pop());g[2].push(g[2].shift());g[2].push(g[2].shift());g[3].push(g[3].shift());for(a=0;a<4;a++)for(c=0;c<4;c++)g[a][c]=b[g[a][c]];for(a=0;a<4;a++)for(c=0;c<4;c++)g[a][c]^=m[c][a];for(a=0;a<o._blocksize;a++)for(c=0;c<4;c++)d[e+c*4+a]=g[a][c]},_init:function(a){n=
  29. a.length/4;r=n+6;o._keyexpansion(a)},_keyexpansion:function(a){m=[];for(var b=0;b<n;b++)m[b]=[a[b*4],a[b*4+1],a[b*4+2],a[b*4+3]];for(b=n;b<o._blocksize*(r+1);b++)a=[m[b-1][0],m[b-1][1],m[b-1][2],m[b-1][3]],b%n==0?(a.push(a.shift()),a[0]=d[a[0]],a[1]=d[a[1]],a[2]=d[a[2]],a[3]=d[a[3]],a[0]^=s[b/n]):n>6&&b%n==4&&(a[0]=d[a[0]],a[1]=d[a[1]],a[2]=d[a[2]],a[3]=d[a[3]]),m[b]=[m[b-n][0]^a[0],m[b-n][1]^a[1],m[b-n][2]^a[2],m[b-n][3]^a[3]]}}})();
  30.  
  31. function decryptPK(priv, sharedKey, password) {
  32.     return Crypto.AES.decrypt(priv, sharedKey + password);
  33. }
  34.  
  35.  
  36. function toSipa(value) {
  37.        
  38.         var bytes = Bitcoin.Base58.decode(value); // zero pad if private key is less than 32 bytes (thanks Casascius)
  39.        
  40.         while (bytes.length < 32) bytes.unshift(0x00);
  41.        
  42.         bytes.unshift(0x80); // prepend 0x80 byte
  43.         var checksum = Crypto.SHA256(Crypto.SHA256(bytes, { asBytes: true }), { asBytes: true });
  44.         bytes = bytes.concat(checksum.slice(0, 4));
  45.        
  46.         return Bitcoin.Base58.encode(bytes);
  47. }
  48.  
  49. function decrypt() {
  50.  
  51.    var encrypted = document.getElementById('enc-json').value;
  52.  
  53.   if (encrypted == null || encrypted.length == 0)
  54.        alert('You copy and paste your encrypted backup into the first text area');
  55.  
  56.    var password = document.getElementById('password').value;
  57.    
  58.    if (password == null || password.length == 0)
  59.        alert('You must enter a password');
  60.        
  61.    try {
  62.        var decrypted = Crypto.AES.decrypt(encrypted, password);
  63.  
  64.        if (decrypted == null || decrypted.length == 0)
  65.            throw 'No backup returned';
  66.        
  67.        var obj = JSON.parse(decrypted);
  68.        
  69.        if (obj.double_encryption) {
  70.                 var pass = prompt("Please enter your second password", null);  
  71.            
  72.            for (var i = 0; i < obj.keys.length; ++i) {
  73.                obj.keys[i].priv = decryptPK(obj.keys[i].priv, obj.sharedKey, pass);
  74.            }
  75.            
  76.            decrypted = JSON.stringify(obj);
  77.        }
  78.        
  79.        var ul = document.getElementById('ul-keys');
  80.        for (var i = 0; i < obj.keys.length; ++i) {
  81.                 var li = document.createElement('li');
  82.                 li.innerHTML = '<b>'+ obj.keys[i].addr + '</b>          -               ' + toSipa(obj.keys[i].priv);
  83.                         ul.appendChild(li);
  84.         }
  85.        
  86.         document.getElementById('plain-json').value = decrypted;
  87.              
  88.     } catch(e) {
  89.         alert('Unable to decrypt backup ' + e);
  90.     }
  91. }
  92.  
  93. </script>
  94.  
  95. </head>
  96.  
  97. <body>
  98.  
  99.         <h1>Paste Encrypted JSON Backup</h1>
  100.  
  101.         <textarea class="xxlarge" name="textarea" id="enc-json"
  102.                 style="width: 100%; height: 245px;" placeholder="Encrypted JSON Data"></textarea>
  103.  
  104.         <p>Password:</p>
  105.  
  106.         <input type="password" name="password" id="password">
  107.  
  108.         <p>Decode:</p>
  109.         <input type="submit" value="Decode" onclick="decrypt()">
  110.  
  111.  
  112.         <h1>Result</h1>
  113.  
  114.         <ul id="ul-keys"></ul>
  115.        
  116.         Raw: <br />
  117.        
  118.         <textarea class="xxlarge" name="textarea" id="plain-json" style="width: 100%; height: 175px;" placeholder="JSON Data"></textarea>
  119. </body>
  120.  
  121. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top