function msg_numToVarInt(a){if(253>a)return[a];if(65535>=a)return[253,a&255,a>>>8];throw"message too large";}function msg_bytes(a){a=Crypto.charenc.UTF8.stringToBytes(a);return msg_numToVarInt(a.length).concat(a)}function msg_digest(a){a=msg_bytes("Bitcoin Signed Message:\n").concat(msg_bytes(a));return Crypto.SHA256(Crypto.SHA256(a,{asBytes:!0}),{asBytes:!0})} function verify_message(a,g,f){try{var e=Crypto.util.base64ToBytes(a)}catch(d){return!1}if(65!=e.length)return!1;var b=BigInteger.fromByteArrayUnsigned(e.slice(1,33));a=BigInteger.fromByteArrayUnsigned(e.slice(33,65));var c=!1,e=e[0];if(27>e||35<=e)return!1;31<=e&&(c=!0,e-=4);var h=BigInteger.valueOf(e-27),m=getSECCurveByName("secp256k1"),l=m.getCurve(),n=l.getA().toBigInteger(),p=l.getB().toBigInteger(),q=l.getQ(),e=m.getG(),m=m.getN(),r=b.add(m.multiply(h.divide(BigInteger.valueOf(2)))),n=r.multiply(r).multiply(r).add(n.multiply(r)).add(p).mod(q).modPow(q.add(BigInteger.ONE).divide(BigInteger.valueOf(4)),q),h=n.subtract(h).isEven()?n:q.subtract(n),l=new ECPointFp(l,l.fromBigInteger(r),l.fromBigInteger(h));g=BigInteger.fromByteArrayUnsigned(msg_digest(g)).negate().mod(m);b=b.modInverse(m);a=l.multiply(a).add(e.multiply(g)).multiply(b).getEncoded(c);a=new Bitcoin.Address(Bitcoin.Util.sha256ripe160(a));a.version=f?f:0;return a.toString()} function sign_message(a,g,f,e){if(!a)return!1;var d=a.sign(msg_digest(g));a=new Bitcoin.Address(a.getPubKeyHash());a.version=e?e:0;for(var b=Bitcoin.ECDSA.parseSig(d),d=[0],d=d.concat(b.r.toByteArrayUnsigned()),d=d.concat(b.s.toByteArrayUnsigned()),b=0;4>b;b++){var c=27+b;f&&(c+=4);d[0]=c;c=Crypto.util.bytesToBase64(d);if(verify_message(c,g,e)==a)return c}return!1} function bitcoinsig_test(){payload=Bitcoin.Base58.decode("5JeWZ1z6sRcLTJXdQEDdB986E6XfLAkj9CgNE4EHzr5GmjrVFpf");secret=payload.slice(1,33);compressed=38==payload.length;console.log(verify_message("HDiv4Oe9SjM1FFVbKk4m3N34efYiRgkQGGoEm564ldYt44jHVTuX23+WnihNMi4vujvpUs1M529P3kftjDezn9E=","test message"));sig=sign_message(new Bitcoin.ECKey(secret),"test message",compressed);console.log(verify_message(sig,"test message"))}"undefined"!=typeof require&&require.main===module&&(window=global,navigator={},Bitcoin={},eval(require("fs").readFileSync("./bitcoinjs-min.js")+""),eval(require("path").basename(module.filename,".js")+"_test()"));(function(){var a=window.Crypto={},g=a.util={rotl:function(a,d){return a<>>32-d},rotr:function(a,d){return a<<32-d|a>>>d},endian:function(a){if(a.constructor==Number)return g.rotl(a,8)&16711935|g.rotl(a,24)&4278255360;for(var d=0;d>>5]|=a[b]<<24-c%32;return d},wordsToBytes:function(a){for(var d=[],b=0;b<32*a.length;b+=8)d.push(a[b>>>5]>>>24-b%32&255);return d},bytesToHex:function(a){for(var d=[],b=0;b>>4).toString(16)),d.push((a[b]&15).toString(16));return d.join("")},hexToBytes:function(a){for(var d=[],b=0;bh;h++)8*b+6*h<=8*a.length?d.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c>>>6*(3-h)&63)):d.push("=");return d.join("")},base64ToBytes:function(a){if("function"==typeof atob)return f.stringToBytes(atob(a));a=a.replace(/[^A-Z0-9+\/]/ig,"");for(var d=[],b=0,c=0;b>>6-2*c);return d}};a.mode={};a=a.charenc={};a.UTF8={stringToBytes:function(a){return f.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(f.bytesToString(a)))}};var f=a.Binary={stringToBytes:function(a){for(var d=[],b=0;b>5]|=128<<24-c%32;d[(c+64>>9<<4)+15]=c;for(y=0;yB;B++){16>B?f[B]=d[B+y]:(w=f[B-15],x=f[B-2],f[B]=((w<<25|w>>>7)^(w<<14|w>>>18)^w>>>3)+(f[B-7]>>>0)+((x<<15|x>>>17)^(x<<13|x>>>19)^x>>>10)+(f[B-16]>>>0));x=c&p^c&q^p&q;var A=(c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22);w=(C>>>0)+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+ (s&v^~s&u)+b[B]+(f[B]>>>0);x=A+x;C=u;u=v;v=s;s=r+w;r=q;q=p;p=c;c=w+x}a[0]+=c;a[1]+=p;a[2]+=q;a[3]+=r;a[4]+=s;a[5]+=v;a[6]+=u;a[7]+=C}return a};c._blocksize=16})();(function(){function a(a,c,d,b){return 0<=a&&15>=a?c^d^b:16<=a&&31>=a?c&d|~c&b:32<=a&&47>=a?(c|~d)^b:48<=a&&63>=a?c&b|d&~b:64<=a&&79>=a?c^(d|~b):"rmd160_f: j out of range"}function g(a,c){var d=(a&65535)+(c&65535);return(a>>16)+(c>>16)+(d>>16)<<16|d&65535}function f(a,c){return a<>>32-c}var e=Crypto,d=e.util,b=e.charenc,c=b.UTF8,h=b.Binary;d.bytesToLWords=function(a){for(var c=Array(a.length>>2),d=0;d>5]|=(a[d/8]&255)<>5]>>>d%32&255);return c};var m=e.RIPEMD160=function(a,c){var b=d.lWordsToBytes(m._rmd160(a));return c&&c.asBytes?b:c&&c.asString?h.bytesToString(b):d.bytesToHex(b)};m._rmd160=function(b){b.constructor==String&&(b=c.stringToBytes(b));var h=d.bytesToLWords(b);b=8*b.length;h[b>>5]|=128<>>9<<4)+14]=b;b=1732584193;for(var e=4023233417,m=2562383102,C=271733878,y=3285377520,B=0;B=K;++K)w=g(x,a(K,A,N,I)),w=g(w,h[B+l[K]]),w=g(w,0<=K&&15>=K?0:16<=K&&31>=K?1518500249:32<=K&&47>=K?1859775393:48<=K&&63>=K?2400959708:64<=K&&79>=K?2840853838:"rmd160_K1: j out of range"),w=g(f(w,p[K]),J),x=J,J=I,I=f(N,10),N=A,A=w,w=g(F,a(79-K,L,E,R)),w=g(w,h[B+n[K]]),w=g(w,0<=K&&15>=K?1352829926:16<=K&&31>=K?1548603684:32<=K&&47>=K?1836072691:48<=K&&63>=K?2053994217:64<=K&&79>=K?0:"rmd160_K2: j out of range"),w=g(f(w,q[K]),Y),F=Y,Y=R,R=f(E,10),E=L,L=w;w=g(e,g(N,R));e=g(m,g(I,Y));m=g(C,g(J,F));C=g(y,g(x,L));y=g(b,g(A,E));b=w}return[b,e,m,C,y]};var l=[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],n=[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],p=[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],q=[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.j=this.i=0;this.S=[]} function ARC4init(a){var g,f,e;for(g=0;256>g;++g)this.S[g]=g;for(g=f=0;256>g;++g)f=f+this.S[g]+a[g%a.length]&255,e=this.S[g],this.S[g]=this.S[f],this.S[f]=e;this.j=this.i=0}function ARC4next(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}function prng_newstate(){return new Arcfour}Arcfour.prototype.init=ARC4init;Arcfour.prototype.next=ARC4next;var rng_psize=256;function rng_seed_int(a){rng_pool[rng_pptr++]^=a&255;rng_pool[rng_pptr++]^=a>>8&255;rng_pool[rng_pptr++]^=a>>16&255;rng_pool[rng_pptr++]^=a>>24&255;rng_pptr>=rng_psize&&(rng_pptr-=rng_psize)}function rng_seed_time(){rng_seed_int((new Date).getTime())}function rng_get_byte(){if(null==rng_state){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptrnavigator.appVersion&&window.crypto){var z=window.crypto.random(32);for(t=0;t>>8,rng_pool[rng_pptr++]=t&255;rng_pptr=0;rng_seed_time()} SecureRandom.prototype.nextBytes=rng_get_bytes;function BigInteger(a,g,f){null!=a&&("number"==typeof a?this.fromNumber(a,g,f):null==g&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,g))}function nbi(){return new BigInteger(null)}function am1(a,g,f,e,d,b){for(;0<=--b;){var c=g*this[a++]+f[e]+d;d=Math.floor(c/67108864);f[e++]=c&67108863}return d} function am2(a,g,f,e,d,b){var c=g&32767;for(g>>=15;0<=--b;){var h=this[a]&32767,m=this[a++]>>15,l=g*h+m*c,h=c*h+((l&32767)<<15)+f[e]+(d&1073741823);d=(h>>>30)+(l>>>15)+g*m+(d>>>30);f[e++]=h&1073741823}return d}function am3(a,g,f,e,d,b){var c=g&16383;for(g>>=14;0<=--b;){var h=this[a]&16383,m=this[a++]>>14,l=g*h+m*c,h=c*h+((l&16383)<<14)+f[e]+d;d=(h>>28)+(l>>14)+g*m;f[e++]=h&268435455}return d}function int2char(a){return BI_RM.charAt(a)} function intAt(a,g){var f=BI_RC[a.charCodeAt(g)];return null==f?-1:f}function bnpCopyTo(a){for(var g=this.t-1;0<=g;--g)a[g]=this[g];a.t=this.t;a.s=this.s}function bnpFromInt(a){this.t=1;this.s=0>a?-1:0;0a?this[0]=a+DV:this.t=0}function nbv(a){var g=nbi();return g.fromInt(a),g} function bnpFromString(a,g){var f;if(16==g)f=4;else if(8==g)f=3;else if(256==g)f=8;else if(2==g)f=1;else if(32==g)f=5;else{if(4!=g){this.fromRadix(a,g);return}f=2}this.s=this.t=0;for(var e=a.length,d=!1,b=0;0<=--e;){var c=8==f?a[e]&255:intAt(a,e);0>c?"-"==a.charAt(e)&&(d=!0):(d=!1,0==b?this[this.t++]=c:b+f>this.DB?(this[this.t-1]|=(c&(1<>this.DB-b):this[this.t-1]|=c<=this.DB&&(b-=this.DB))}8==f&&0!=(a[0]&128)&&(this.s=-1,0this.s)return"-"+this.negate().toString(a);if(16==a)a=4;else if(8==a)a=3;else if(2==a)a=1;else if(32==a)a=5;else{if(4!=a)return this.toRadix(a);a=2}var g=(1<>c)&&(e=!0,d=int2char(f));0<=b;)c>(c+=this.DB-a)):(f=this[b]>>(c-=a)&g,0>=c&&(c+=this.DB,--b)),0this.s?this.negate():this}function bnCompareTo(a){var g=this.s-a.s;if(0!=g)return g;var f=this.t,g=f-a.t;if(0!=g)return 0>this.s?-g:g;for(;0<=--f;)if(0!=(g=this[f]-a[f]))return g;return 0}function nbits(a){var g=1,f;return 0!=(f=a>>>16)&&(a=f,g+=16),0!=(f=a>>8)&&(a=f,g+=8),0!=(f=a>>4)&&(a=f,g+=4),0!=(f=a>>2)&&(a=f,g+=2),0!=a>>1&&(g+=1),g} function bnBitLength(){return 0>=this.t?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(a,g){var f;for(f=this.t-1;0<=f;--f)g[f+a]=this[f];for(f=a-1;0<=f;--f)g[f]=0;g.t=this.t+a;g.s=this.s}function bnpDRShiftTo(a,g){for(var f=a;f>e|c,c=(this[h]&d)<=this.t)g.t=0;else{var e=a%this.DB,d=this.DB-e,b=(1<>e;for(var c=f+1;c>e;0>=this.DB;if(a.t>=this.DB;e+=this.s}else{for(e+=this.s;f>=this.DB;e-=a.s}g.s=0>e?-1:0;-1>e?g[f++]=this.DV+e:0=g.DV&&(a[f+g.t]-=g.DV,a[f+g.t+1]=1)}0=e.t)){var d=this.abs();if(d.t>this.F2:0),l=this.FV/m,m=(1<c&&BigInteger.ZERO.subTo(f,f)}}}}function bnMod(a){var g=nbi();return this.abs().divRemTo(a,null,g),0>this.s&&0a.s||0<=a.compareTo(this.m)?a.mod(this.m):a}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,g,f){a.multiplyTo(g,f);this.reduce(f)}function cSqrTo(a,g){a.squareTo(g);this.reduce(g)}function bnpInvDigit(){if(1>this.t)return 0;var a=this[0];if(0==(a&1))return 0;var g=a&3;return g=g*(2-(a&15)*g)&15,g=g*(2-(a&255)*g)&255,g=g*(2-((a&65535)*g&65535))&65535,g=g*(2-a*g%this.DV)%this.DV,0>15;this.um=(1<a.s&&0>15)*this.mpl&this.um)<<15)&a.DM,f=g+this.m.t;for(a[f]+=this.m.am(0,e,a,g,0,this.m.t);a[f]>=a.DV;)a[f]-=a.DV,a[++f]++}a.clamp();a.drShiftTo(this.m.t,a);0<=a.compareTo(this.m)&&a.subTo(this.m,a)}function montSqrTo(a,g){a.squareTo(g);this.reduce(g)}function montMulTo(a,g,f){a.multiplyTo(g,f);this.reduce(f)}function bnpIsEven(){return 0==(0a)return BigInteger.ONE;var f=nbi(),e=nbi(),d=g.convert(this),b=nbits(a)-1;for(d.copyTo(f);0<=--b;)if(g.sqrTo(f,e),0<(a&1<a||g.isEven()?f=new Classic(g):f=new Montgomery(g),this.exp(a,f)}var dbits,canary=0xdeadbeefcafe,j_lm=15715070==(canary&16777215);j_lm&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,dbits=30):j_lm&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28);BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=(1<=vv;++vv)BI_RC[rr++]=vv;rr=97;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;rr=65;for(vv=10;36>vv;++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 a=nbi();return this.copyTo(a),a} function bnIntValue(){if(0>this.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this[0]?0:1} function bnpToRadix(a){null==a&&(a=10);if(0==this.signum()||2>a||36m?"-"==a.charAt(h)&&0==this.signum()&&(d=!0):(c=g*c+m,++b>=f&&(this.dMultiply(e),this.dAddOffset(c,0),b=0,c=0))}0a)this.fromInt(1);else for(this.fromNumber(a,f),this.testBit(a-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(g);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(BigInteger.ONE.shiftLeft(a-1),this);else{f=[];var e=a&7;f.length=(a>>3)+1;g.nextBytes(f);0>f)!=(this.s&this.DM)>>f&&(g[d++]=e|this.s<f?(e=(this[a]&(1<>(f+=this.DB-8)):(e=this[a]>>(f-=8)&255,0>=f&&(f+=this.DB,--a)),0!=(e&128)&&(e|=-256),0==d&&(this.s&128)!=(e&128)&&++d,0this.compareTo(a)?this:a} function bnMax(a){return 0a?this.rShiftTo(-a,g):this.lShiftTo(a,g),g} function bnShiftRight(a){var g=nbi();return 0>a?this.lShiftTo(-a,g):this.rShiftTo(a,g),g}function lbit(a){if(0==a)return-1;var g=0;return 0==(a&65535)&&(a>>=16,g+=16),0==(a&255)&&(a>>=8,g+=8),0==(a&15)&&(a>>=4,g+=4),0==(a&3)&&(a>>=2,g+=2),0==(a&1)&&++g,g}function bnGetLowestSetBit(){for(var a=0;athis.s?this.t*this.DB:-1}function cbit(a){for(var g=0;0!=a;)a&=a-1,++g;return g} function bnBitCount(){for(var a=0,g=this.s&this.DM,f=0;f=this.t?0!=this.s:0!=(this[g]&1<>=this.DB;if(a.t>=this.DB;e+=this.s}else{for(e+=this.s;f>=this.DB;e+=a.s}g.s=0>e?-1:0;0e&&(g[f++]=this.DV+e);g.t=f;g.clamp()}function bnAdd(a){var g=nbi();return this.addTo(a,g),g}function bnSubtract(a){var g=nbi();return this.subTo(a,g),g} function bnMultiply(a){var g=nbi();return this.multiplyTo(a,g),g}function bnSquare(){var a=nbi();return this.squareTo(a),a}function bnDivide(a){var g=nbi();return this.divRemTo(a,g,null),g}function bnRemainder(a){var g=nbi();return this.divRemTo(a,null,g),g}function bnDivideAndRemainder(a){var g=nbi(),f=nbi();return this.divRemTo(a,g,f),[g,f]}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()} function bnpDAddOffset(a,g){if(0!=a){for(;this.t<=g;)this[this.t++]=0;for(this[g]+=a;this[g]>=this.DV;)this[g]-=this.DV,++g>=this.t&&(this[this.t++]=0),++this[g]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,g,f){a.multiplyTo(g,f)}function nSqrTo(a,g){a.squareTo(g)}function bnPow(a){return this.exp(a,new NullExp)} function bnpMultiplyLowerTo(a,g,f){var e=Math.min(this.t+a.t,g);f.s=0;for(f.t=e;0a.s||a.t>2*this.m.t)return a.mod(this.m);if(0>a.compareTo(this.m))return a;var g=nbi();return a.copyTo(g),this.reduce(g),g}function barrettRevert(a){return a} function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp());this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>a.compareTo(this.r2);)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);0<=a.compareTo(this.m);)a.subTo(this.m,a)}function barrettSqrTo(a,g){a.squareTo(g);this.reduce(g)}function barrettMulTo(a,g,f){a.multiplyTo(g,f);this.reduce(f)} function bnModPow(a,g){var f=a.bitLength(),e,d=nbv(1),b;if(0>=f)return d;18>f?e=1:48>f?e=3:144>f?e=4:768>f?e=5:e=6;8>f?b=new Classic(g):g.isEven()?b=new Barrett(g):b=new Montgomery(g);var c=[],h=3,m=e-1,l=(1<=m?p=a[n]>>f-m&l:(p=(a[n]&(1<>this.DB+f-m));for(h=e;0==(p&1);)p>>=1,--h;0>(f-=h)&&(f+=this.DB,--n);if(q)c[p].copyTo(d),q=!1;else{for(;1--f&&(f=this.DB-1,--n)}return b.revert(d)} function bnGCD(a){var g=0>this.s?this.negate():this.clone();a=0>a.s?a.negate():a.clone();if(0>g.compareTo(a)){var f=g,g=a;a=f}var f=g.getLowestSetBit(),e=a.getLowestSetBit();if(0>e)return g;f=a)return 0;var g=this.DV%a,f=0>this.s?a-1:0;if(0h.signum()?(h.addTo(a,h),0>h.signum()?h.add(a):h):h} function bnIsProbablePrime(a){var g,f=this.abs();if(1==f.t&&f[0]<=lowprimes[lowprimes.length-1]){for(g=0;g=f)return!1;var e=g.shiftRight(f);a=a+1>>1;a>lowprimes.length&&(a=lowprimes.length);for(var d=nbi(),b=0;bf.bitLength()?e=a.bitLength()-1:e=f.bitLength()-1;for(var d=this.curve.getInfinity(),b=this.add(g);0<=e;)d=d.twice(),a.testBit(e)?f.testBit(e)?d=d.add(b):d=d.add(this):f.testBit(e)&&(d=d.add(g)),--e;return d}function ECCurveFp(a,g,f){this.q=a;this.a=this.fromBigInteger(g);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(a){return a==this?!0:this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b)}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)} function curveFpDecodePointHex(a){switch(parseInt(a.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var g=(a.length-2)/2,f=a.substr(2,g);a=a.substr(g+2,g);return new ECPointFp(this,this.fromBigInteger(new BigInteger(f,16)),this.fromBigInteger(new BigInteger(a,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(a,g,f,e){this.curve=a;this.g=g;this.n=f;this.h=e} function x9getCurve(){return this.curve}function x9getG(){return this.g}function x9getN(){return this.n}function x9getH(){return this.h}function fromHex(a){return new BigInteger(a,16)} function secp128r1(){var a=fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF"),g=fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC"),f=fromHex("E87579C11079F43DD824993C2CEE5ED3"),e=fromHex("FFFFFFFE0000000075A30D1B9038A115"),d=BigInteger.ONE,a=new ECCurveFp(a,g,f),g=a.decodePointHex("04161FF7528B899B2D0C28607CA52C5B86CF5AC8395BAFEB13C02DA292DDED7A83");return new X9ECParameters(a,g,e,d)} function secp160k1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73"),g=BigInteger.ZERO,f=fromHex("7"),e=fromHex("0100000000000000000001B8FA16DFAB9ACA16B6B3"),d=BigInteger.ONE,a=new ECCurveFp(a,g,f),g=a.decodePointHex("043B4C382CE37AA192A4019E763036F4F5DD4D7EBB938CF935318FDCED6BC28286531733C3F03C4FEE");return new X9ECParameters(a,g,e,d)} function secp160r1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF"),g=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC"),f=fromHex("1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45"),e=fromHex("0100000000000000000001F4C8F927AED3CA752257"),d=BigInteger.ONE,a=new ECCurveFp(a,g,f),g=a.decodePointHex("044A96B5688EF573284664698968C38BB913CBFC8223A628553168947D59DCC912042351377AC5FB32");return new X9ECParameters(a,g,e,d)} function secp192k1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37"),g=BigInteger.ZERO,f=fromHex("3"),e=fromHex("FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D"),d=BigInteger.ONE,a=new ECCurveFp(a,g,f),g=a.decodePointHex("04DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D");return new X9ECParameters(a,g,e,d)} function secp192r1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"),g=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC"),f=fromHex("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1"),e=fromHex("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831"),d=BigInteger.ONE,a=new ECCurveFp(a,g,f),g=a.decodePointHex("04188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF101207192B95FFC8DA78631011ED6B24CDD573F977A11E794811");return new X9ECParameters(a,g,e,d)} function secp224r1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001"),g=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE"),f=fromHex("B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4"),e=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D"),d=BigInteger.ONE,a=new ECCurveFp(a,g,f),g=a.decodePointHex("04B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34");return new X9ECParameters(a,g,e,d)}function secp256k1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"),g=BigInteger.ZERO,f=fromHex("7"),e=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"),d=BigInteger.ONE,a=new ECCurveFp(a,g,f),g=a.decodePointHex("0479BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8");return new X9ECParameters(a,g,e,d)} function secp256r1(){var a=fromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF"),g=fromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC"),f=fromHex("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B"),e=fromHex("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551"),d=BigInteger.ONE,a=new ECCurveFp(a,g,f),g=a.decodePointHex("046B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C2964FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5");return new X9ECParameters(a,g,e,d)}function getSECCurveByName(a){return"secp128r1"==a?secp128r1():"secp160k1"==a?secp160k1():"secp160r1"==a?secp160r1():"secp192k1"==a?secp192k1():"secp192r1"==a?secp192r1():"secp224r1"==a?secp224r1():"secp256k1"==a?secp256k1():"secp256r1"==a?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(a,g,f){f||(f=this);this._listeners||(this._listeners={});this._listeners[a]||(this._listeners[a]=[]);this._unbinders||(this._unbinders={});this._unbinders[a]||(this._unbinders[a]=[]);this._unbinders[a].push(g);this._listeners[a].push(function(a){g.apply(f,[a])})};EventEmitter.prototype.trigger=function(a,g){void 0===g&&(g={});this._listeners||(this._listeners={});if(this._listeners[a])for(var f=this._listeners[a].length;f--;)this._listeners[a][f](g)};EventEmitter.prototype.removeListener=function(a,g){this._unbinders||(this._unbinders={});if(this._unbinders[a])for(var f=this._unbinders[a].length;f--;)this._unbinders[a][f]===g&&(this._unbinders[a].splice(f,1),this._listeners[a].splice(f,1))};EventEmitter.augment=function(a){for(var g in EventEmitter.prototype)a[g]||(a[g]=EventEmitter.prototype[g])};(function(a){"object"!=typeof module&&(a.EventEmitter=EventEmitter)})("object"==typeof module?module.exports:window.Bitcoin={});BigInteger.valueOf=nbv;BigInteger.prototype.toByteArrayUnsigned=function(){var a=this.abs().toByteArray();return a.length?(0==a[0]&&(a=a.slice(1)),a.map(function(a){return 0>a?a+256:a})):a};BigInteger.fromByteArrayUnsigned=function(a){return a.length?a[0]&128?new BigInteger([0].concat(a)):new BigInteger(a):a.valueOf(0)};BigInteger.prototype.toByteArraySigned=function(){var a=this.abs().toByteArrayUnsigned();return 0>this.compareTo(BigInteger.ZERO)?a[0]&128?a.unshift(128):a[0]|=128:a[0]&128&&a.unshift(0),a};BigInteger.fromByteArraySigned=function(a){return a[0]&128?(a[0]&=127,BigInteger.fromByteArrayUnsigned(a).negate()):BigInteger.fromByteArrayUnsigned(a)};var names="log debug info warn error assert dir dirxml group groupEnd time timeEnd count trace profile profileEnd".split(" ");"undefined"==typeof window.console&&(window.console={});for(var i=0;ia?[a]:65536>=a?[253,a>>>8,a&255]:1>=a?[254].concat(Crypto.util.wordsToBytes([a])):[255].concat(Crypto.util.wordsToBytes([a>>>32,a]))},valueToBigInt:function(a){return a instanceof BigInteger?a:BigInteger.fromByteArrayUnsigned(a)},formatValue:function(a){var g=this.valueToBigInt(a).toString();a=8g.length;)g="0"+g;for(g=g.replace(/0*$/,"");2>g.length;)g+="0";return a+"."+g},parseValue:function(a){var g=a.split(".");a=g[0];for(g=g[1]||"0";8>g.length;)g+="0";g=g.replace(/^0+/g,"");a=BigInteger.valueOf(parseInt(a));return a=a.multiply(BigInteger.valueOf(1E8)),a=a.add(BigInteger.valueOf(parseInt(g))),a},sha256ripe160:function(a){return Crypto.RIPEMD160(Crypto.SHA256(a,{asBytes:!0}),{asBytes:!0})}};for(i in Crypto.util)Crypto.util.hasOwnProperty(i)&&(Bitcoin.Util[i]=Crypto.util[i]);(function(a){a.Base58={alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",validRegex:/^[1-9A-HJ-NP-Za-km-z]+$/,base:BigInteger.valueOf(58),encode:function(a){for(var e=BigInteger.fromByteArrayUnsigned(a),d=[];0<=e.compareTo(g.base);){var b=e.mod(g.base);d.unshift(g.alphabet[b.intValue()]);e=e.subtract(b).divide(g.base)}d.unshift(g.alphabet[e.intValue()]);for(e=0;ec)throw"Invalid character";e=e.add(BigInteger.valueOf(c).multiply(g.base.pow(a.length-1-b)));"1"==a[b]?d++:d=0}for(a=e.toByteArrayUnsigned();0f.length;)f.unshift(0);return f} function dmp(a){return a instanceof BigInteger||(a=a.toBigInteger()),Crypto.util.bytesToHex(a.toByteArrayUnsigned())}ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(a){var g=this.getX().toBigInteger(),f=this.getY().toBigInteger(),g=integerToBytes(g,32);return a?f.isEven()?g.unshift(2):g.unshift(3):(g.unshift(4),g=g.concat(integerToBytes(f,32))),g};ECPointFp.decodeFrom=function(a,g){var f=g.length-1,e=g.slice(1,1+f/2),f=g.slice(1+f/2,1+f);e.unshift(0);f.unshift(0);e=new BigInteger(e);f=new BigInteger(f);return new ECPointFp(a,a.fromBigInteger(e),a.fromBigInteger(f))};ECPointFp.prototype.add2D=function(a){if(this.isInfinity())return a;if(a.isInfinity())return this;if(this.x.equals(a.x))return this.y.equals(a.y)?this.twice():this.curve.getInfinity();var g=a.x.subtract(this.x),g=a.y.subtract(this.y).divide(g);a=g.square().subtract(this.x).subtract(a.x);g=g.multiply(this.x.subtract(a)).subtract(this.y);return new ECPointFp(this.curve,a,g)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var a=this.curve.fromBigInteger(BigInteger.valueOf(2)),g=this.curve.fromBigInteger(BigInteger.valueOf(3)),g=this.x.square().multiply(g).add(this.curve.a).divide(this.y.multiply(a)),a=g.square().subtract(this.x.multiply(a)),g=g.multiply(this.x.subtract(a)).subtract(this.y);return new ECPointFp(this.curve,a,g)};ECPointFp.prototype.multiply2D=function(a){if(this.isInfinity())return this;if(0==a.signum())return this.curve.getInfinity();var g=a.multiply(new BigInteger("3")),f=this.negate(),e=this,d;for(d=g.bitLength()-2;0g.compareTo(BigInteger.ONE)||0f.compareTo(BigInteger.ONE)||0=g.compareTo(BigInteger.ZERO));c=f.modInverse(c).multiply(h.add(b.multiply(g))).mod(c);return e.serializeSig(g,c)},verify:function(d,b,c){var h;if(Bitcoin.Util.isArray(b))b=e.parseSig(b);else if("object"!=typeof b||!b.r||!b.s)throw"Invalid value for signature";h=b.r;b=b.s;if(!(c instanceof ECPointFp)){if(!Bitcoin.Util.isArray(c))throw"Invalid format for pubkey value, must be byte array or ECPointFp";c=ECPointFp.decodeFrom(a.getCurve(),c)}d=BigInteger.fromByteArrayUnsigned(d);return e.verifyRaw(d,h,b,c)},verifyRaw:function(d,b,c,h){var e=a.getN(),f=a.getG();if(0>b.compareTo(BigInteger.ONE)||0<=b.compareTo(e)||0>c.compareTo(BigInteger.ONE)||0<=c.compareTo(e))return!1;c=c.modInverse(e);d=d.multiply(c).mod(e);c=b.multiply(c).mod(e);return f.multiply(d).add(h.multiply(c)).getX().toBigInteger().mod(e).equals(b)},serializeSig:function(a,b){var c=a.toByteArraySigned(),h=b.toByteArraySigned(),e=[];return e.push(2),e.push(c.length),e=e.concat(c),e.push(2),e.push(h.length),e=e.concat(h),e.unshift(e.length),e.unshift(48),e},parseSig:function(a){var b;if(48!=a[0])throw Error("Signature not a valid DERSequence");b=2;if(2!=a[b])throw Error("First element in signature must be a DERInteger");var c=a.slice(b+2,b+2+a[b+1]);b+=2+a[b+1];if(2!=a[b])throw Error("Second element in signature must be a DERInteger");a=a.slice(b+2,b+2+a[b+1]);c=BigInteger.fromByteArrayUnsigned(c);a=BigInteger.fromByteArrayUnsigned(a);return{r:c,s:a}},parseSigCompact:function(d){if(65!==d.length)throw"Signature has the wrong length";var b=d[0]-27;if(0>b||7>1,n=a.getN();h=a.getG();var p=a.getCurve(),q=p.getQ(),r=p.getA().toBigInteger(),s=p.getB().toBigInteger();f||(f=q.add(BigInteger.ONE).divide(BigInteger.valueOf(4)));l=l?d.add(n):d;r=l.multiply(l).multiply(l).add(r.multiply(l)).add(s).mod(q).modPow(f,q);r.isEven();g=(r.isEven()?!g:g)?r:q.subtract(r);g=new ECPointFp(p,p.fromBigInteger(l),p.fromBigInteger(g));g.validate();c=BigInteger.fromByteArrayUnsigned(c);p=BigInteger.ZERO.subtract(c).mod(n);n=d.modInverse(n);r=Math.max(b.bitLength(),p.bitLength());q=g.add2D(h);l=g.curve.getInfinity();for(r-=1;0<=r;--r)l=l.twice2D(),l.z=BigInteger.ONE,b.testBit(r)?p.testBit(r)?l=l.add2D(q):l=l.add2D(g):p.testBit(r)&&(l=l.add2D(h));g=l.multiply(n);console.log("G.x: ",Crypto.util.bytesToHex(h.x.toBigInteger().toByteArrayUnsigned()));console.log("G.y: ",Crypto.util.bytesToHex(h.y.toBigInteger().toByteArrayUnsigned()));console.log("s: ",Crypto.util.bytesToHex(n.toByteArrayUnsigned()));console.log("Q.x: ",Crypto.util.bytesToHex(g.x.toBigInteger().toByteArrayUnsigned()));console.log("Q.y: ",Crypto.util.bytesToHex(g.y.toBigInteger().toByteArrayUnsigned()));g.validate();if(!e.verifyRaw(c,d,b,g))throw"Pubkey recovery unsuccessful";d=new Bitcoin.ECKey;return d.pub=g,d},calcPubkeyRecoveryParam:function(a,b,c,h){for(var e=0;4>e;e++)try{if(Bitcoin.ECDSA.recoverPubKey(b,c,h,e).getBitcoinAddress().toString()==a)return e}catch(f){}throw"Unable to find valid recovery factor";}};return e}();Bitcoin.ECKey=function(){var a=Bitcoin.ECDSA,g=getSECCurveByName("secp256k1");new SecureRandom;var f=function(e){e?e instanceof BigInteger?this.priv=e:Bitcoin.Util.isArray(e)?this.priv=BigInteger.fromByteArrayUnsigned(e):"string"==typeof e&&(51==e.length&&"5"==e[0]?this.priv=BigInteger.fromByteArrayUnsigned(f.decodeString(e)):this.priv=BigInteger.fromByteArrayUnsigned(Crypto.util.base64ToBytes(e))):(e=g.getN(),this.priv=a.getBigRandom(e));this.compressed=!!f.compressByDefault};return f.compressByDefault=!1,f.prototype.setCompressed=function(a){this.compressed=!!a},f.prototype.getPub=function(){return this.getPubPoint().getEncoded(this.compressed)},f.prototype.getPubPoint=function(){return this.pub||(this.pub=g.getG().multiply(this.priv)),this.pub},f.prototype.getPubKeyHash=function(){return this.pubKeyHash?this.pubKeyHash:this.pubKeyHash=Bitcoin.Util.sha256ripe160(this.getPub())},f.prototype.getBitcoinAddress=function(){var a=this.getPubKeyHash();return new Bitcoin.Address(a)},f.prototype.getExportedPrivateKey=function(){for(var a=this.priv.toByteArrayUnsigned();32>a.length;)a.unshift(0);a.unshift(128);var d=Crypto.SHA256(Crypto.SHA256(a,{asBytes:!0}),{asBytes:!0}),a=a.concat(d.slice(0,4));return Bitcoin.Base58.encode(a)},f.prototype.setPub=function(a){this.pub=ECPointFp.decodeFrom(g.getCurve(),a)},f.prototype.toString=function(a){return"base64"===a?Crypto.util.bytesToBase64(this.priv.toByteArrayUnsigned()):Crypto.util.bytesToHex(this.priv.toByteArrayUnsigned())},f.prototype.sign=function(e){return a.sign(e,this.priv)},f.prototype.verify=function(e,d){return a.verify(e,d,this.getPub())},f.decodeString=function(a){var d=Bitcoin.Base58.decode(a);a=d.slice(0,33);var b=Crypto.SHA256(Crypto.SHA256(a,{asBytes:!0}),{asBytes:!0});if(b[0]!=d[33]||b[1]!=d[34]||b[2]!=d[35]||b[3]!=d[36])throw"Checksum validation failed!";d=a.shift();if(128!=d)throw"Version "+d+" not supported!";return a},f}();(function(){var a=Bitcoin.Opcode=function(a){this.code=a};a.prototype.toString=function(){return a.reverseMap[this.code]};a.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};a.reverseMap=[];for(var g in a.map)a.reverseMap[a.map[g]]=g})();(function(){var a=Bitcoin.Opcode,g;for(g in a.map)eval("var "+g+" = "+a.map[g]+";");var f=Bitcoin.Script=function(a){if(a)if("string"==typeof a)this.buffer=Crypto.util.base64ToBytes(a);else if(Bitcoin.Util.isArray(a))this.buffer=a;else{if(!(a instanceof f))throw Error("Invalid script");this.buffer=a.buffer}else this.buffer=[];this.parse()};f.prototype.parse=function(){function a(c){d.chunks.push(d.buffer.slice(b,b+c));b+=c}var d=this;this.chunks=[];for(var b=0;b=this.chunks[this.chunks.length-2]?"Multisig":5==this.chunks.length&&this.chunks[0]==OP_DUP&&this.chunks[1]==OP_HASH160&&this.chunks[3]==OP_EQUALVERIFY&&this.chunks[4]==OP_CHECKSIG?"Address":2==this.chunks.length&&this.chunks[1]==OP_CHECKSIG?"Pubkey":"Strange"};f.prototype.simpleOutHash=function(){switch(this.getOutType()){case"Address":return this.chunks[2];case"Pubkey":return Bitcoin.Util.sha256ripe160(this.chunks[0]);default:throw Error("Encountered non-standard scriptPubKey");}};f.prototype.simpleOutPubKeyHash=f.prototype.simpleOutHash;f.prototype.getInType=function(){return 1==this.chunks.length&&Bitcoin.Util.isArray(this.chunks[0])?"Pubkey":2==this.chunks.length&&Bitcoin.Util.isArray(this.chunks[0])&&Bitcoin.Util.isArray(this.chunks[1])?"Address":"Strange"};f.prototype.simpleInPubKey=function(){switch(this.getInType()){case"Address":return this.chunks[1];case"Pubkey":throw Error("Script does not contain pubkey.");default:throw Error("Encountered non-standard scriptSig");}};f.prototype.simpleInHash=function(){return Bitcoin.Util.sha256ripe160(this.simpleInPubKey())};f.prototype.simpleInPubKeyHash=f.prototype.simpleInHash;f.prototype.writeOp=function(a){this.buffer.push(a);this.chunks.push(a)};f.prototype.writeBytes=function(a){a.length=a.length?(this.buffer.push(OP_PUSHDATA1),this.buffer.push(a.length)):65535>=a.length?(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)};f.createOutputScript=function(a){var d=new f;return d.writeOp(OP_DUP),d.writeOp(OP_HASH160),d.writeBytes(a.hash),d.writeOp(OP_EQUALVERIFY),d.writeOp(OP_CHECKSIG),d};f.prototype.extractAddresses=function(a){switch(this.getOutType()){case"Address":return a.push(new Address(this.chunks[2])),1;case"Pubkey":return a.push(new Address(Util.sha256ripe160(this.chunks[0]))),1;case"Multisig":for(var d=1;db.length;)b.push(0);else Bitcoin.Util.isArray(b);this.outs.push(new e({value:b,script:a.createOutputScript(d)}))}};g.prototype.serialize=function(){for(var a=[],a=a.concat(Crypto.util.wordsToBytes([parseInt(this.version)]).reverse()),a=a.concat(Bitcoin.Util.numToVarInt(this.ins.length)),b=0;bd.length;)d="0"+d;this.value=Crypto.util.hexToBytes(d)}};e.prototype.clone=function(){return new e({script:this.script.clone(),value:this.value.slice(0)})}})();Bitcoin.Wallet=function(){var a=Bitcoin.Script,g=Bitcoin.TransactionIn,f=Bitcoin.TransactionOut,e=function(){var a=[];this.addressHashes=[];this.txIndex={};this.unspentOuts=[];this.addressPointer=0;this.addKey=function(b,c){b instanceof Bitcoin.ECKey||(b=new Bitcoin.ECKey(b));a.push(b);c&&("string"==typeof c&&(c=Crypto.util.base64ToBytes(c)),b.setPub(c));this.addressHashes.push(b.getBitcoinAddress().getHashBase64())};this.addKeys=function(a,c){"string"==typeof a&&(a=a.split(","));"string"==typeof c&&(c=c.split(","));var d;if(Array.isArray(c)&&a.length==c.length)for(d=0;df.compareTo(e))throw Error("Insufficient funds.");f=f.subtract(e);e=new Bitcoin.Transaction;for(c=0;cd;d++)k.event.add(c,b,f[b][d]);e.data&&(e.data=k.extend({},e.data))}}function B(a,c){var b,d,h=0,e=typeof a.getElementsByTagName!==aa?a.getElementsByTagName(c||"*"):typeof a.querySelectorAll!==aa?a.querySelectorAll(c||"*"):g;if(!e)for(e=[],b=a.childNodes||a;null!=(d=b[h]);h++)!c||k.nodeName(d,c)?e.push(d):k.merge(e,B(d,c));return c===g||c&&k.nodeName(a,c)?k.merge([a],e):e}function w(a){Ja.test(a.type)&&(a.defaultChecked=a.checked)}function x(a,c){if(c in a)return c;for(var b=c.charAt(0).toUpperCase()+c.slice(1),d=c,h=Za.length;h--;)if(c=Za[h]+b,c in a)return c;return d}function A(a,c){return a=c||a,"none"===k.css(a,"display")||!k.contains(a.ownerDocument,a)}function N(a,c){for(var b,d,h,e=[],f=0,g=a.length;g>f;f++)d=a[f],d.style&&(e[f]=k._data(d,"olddisplay"),b=d.style.display,c?(e[f]||"none"!==b||(d.style.display=""),""===d.style.display&&A(d)&&(e[f]=k._data(d,"olddisplay",L(d.nodeName)))):e[f]||(h=A(d),(b&&"none"!==b||!h)&&k._data(d,"olddisplay",h?b:k.css(d,"display"))));for(f=0;g>f;f++)d=a[f],d.style&&(c&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=c?e[f]||"":"none"));return a}function I(a,c,b){return(a=Bb.exec(c))?Math.max(0,a[1]-(b||0))+(a[2]||"px"):c}function J(a,c,b,d,h){c=b===(d?"border":"content")?4:"width"===c?1:0;for(var e=0;4>c;c+=2)"margin"===b&&(e+=k.css(a,b+na[c],!0,h)),d?("content"===b&&(e-=k.css(a,"padding"+na[c],!0,h)),"margin"!==b&&(e-=k.css(a,"border"+na[c]+"Width",!0,h))):(e+=k.css(a,"padding"+na[c],!0,h),"padding"!==b&&(e+=k.css(a,"border"+na[c]+"Width",!0,h)));return e}function F(a,c,b){var d=!0,h="width"===c?a.offsetWidth:a.offsetHeight,e=ia(a),f=k.support.boxSizing&&"border-box"===k.css(a,"boxSizing",!1,e);if(0>=h||null==h){if(h=ba(a,c,e),(0>h||null==h)&&(h=a.style[c]),xa.test(h))return h;d=f&&(k.support.boxSizingReliable||h===a.style[c]);h=parseFloat(h)||0}return h+J(a,c,b||(f?"border":"content"),d,e)+"px"}function L(a){var c=G,b=$a[a];return b||(b=E(a,c),"none"!==b&&b||(ja=(ja||k("