diff --git a/common.js b/common.js index c569a61..83b74e1 100755 --- a/common.js +++ b/common.js @@ -328,51 +328,59 @@ var common = (function() { return true; } - function retmsg(msg) + function retmsg(msg, cb) { - common.naclModule.postMessage(msg); - console.log("sent: "+msg); + console.log(cb); + postCall("js", msg, cb, function() { + // nothing + }); + console.log("sent: "+msg+" "+cb); } function handleMessage(message_event) { if(isJson(message_event.data)) { - console.log("AAAA"); var request = JSON.parse(message_event.data); + var cb = request.pointer; console.log(request); if(request.method == "NxtAPI") { console.log(request.requestType); + if(request.params == undefined) request.params = "{}"; Jay.request(request.requestType, JSON.parse(request.params), function(ans) { - retmsg(ans); + retmsg(ans, cb); }) } else if(request.method == "status") { - retmsg("{'status':'doing alright'}"); + retmsg("{'status':'doing alright'}", cb); } else if(request.method == "signBytes") { var out = converters.byteArrayToHexString(signBytes(converters.hexStringToByteArray(request.bytes), request.secretPhrase)); var ret = {}; ret.signature = out; - retmsg(JSON.stringify(ret)); + retmsg(JSON.stringify(ret), cb); } else if(request.method == "createToken") { var out = createToken(request.data, request.secretPhrase); var ret = {}; ret.token = out; - retmsg(JSON.stringify(ret)); + retmsg(JSON.stringify(ret), cb); } else if(request.method == "parseToken") { var out = parseToken(request.token, request.data); - retmsg(JSON.stringify(out)); + retmsg(JSON.stringify(out), cb); } - console.log(request); + else + { + retmsg('{"error":"method not found"}', cb); } + } + if (typeof message_event.data === 'string') { for (var type in defaultMessageTypes) { @@ -464,6 +472,8 @@ var common = (function() { hideModule: hideModule, removeModule: removeModule, logMessage: logMessage, + postMessage: postMessage, + handleMessage: handleMessage, updateStatus: updateStatus }; diff --git a/handlers.c b/handlers.c index b8973ac..c1c4d53 100755 --- a/handlers.c +++ b/handlers.c @@ -1214,3 +1214,20 @@ int HandleSuperNET(struct PP_Var params,struct PP_Var *output,const char **out_e RESPONSE_STRING(retstr); return 0; } + +int HandleJS(struct PP_Var params, struct PP_Var* output, const char** out_error) { + PostMessage("JS?"); + CHECK_PARAM_COUNT(js, 2); + PARAM_STRING(0, jsonstr); + PARAM_STRING(1, ptr); + + int64_t nptr = strtoll(ptr, NULL, 10); + + char * addr = (char *)nptr; + + strcpy(addr, jsonstr); + + CREATE_RESPONSE(js); + RESPONSE_STRING(ptr); + return 0; +} diff --git a/handlers.h b/handlers.h index ecf3c1c..1b21a4a 100755 --- a/handlers.h +++ b/handlers.h @@ -37,5 +37,6 @@ int HandleConnect(struct PP_Var params, struct PP_Var* out, const char** error); int HandleSend(struct PP_Var params, struct PP_Var* out, const char** error); int HandleRecv(struct PP_Var params, struct PP_Var* out, const char** error); int HandleClose(struct PP_Var params, struct PP_Var* out, const char** error); +int HandleJS(struct PP_Var params, struct PP_Var* out, const char** error); #endif /* HANDLERS_H_ */ diff --git a/js/api.js b/js/api.js index 68240b7..660f5e2 100755 --- a/js/api.js +++ b/js/api.js @@ -31,12 +31,6 @@ var SPNAPI = (function(SPNAPI, $, undefined) { else SPNAPI.submitRequest(); }); - $(".submit_api_request").on("click", function () { - - SPNAPI.submitRequest(); - - }); - $(".clear-response").on("click", function () { $(".hljs").html("JSON response"); diff --git a/js/jay.min.js b/js/jay.min.js index 05ff17c..d4109b6 100755 --- a/js/jay.min.js +++ b/js/jay.min.js @@ -1,2 +1,51 @@ +(function($) { + $.ajaxMultiQueue = function(n) { + return new MultiQueue(~~n); + }; + + function MultiQueue(number) { + var queues, i, + current = 0; + + if (!queues) { + queues = new Array(number); + + for (i = 0; i < number; i++) { + queues[i] = $({}); + } + } + + function queue(ajaxOpts) { + var jqXHR, + dfd = $.Deferred(), + promise = dfd.promise(); + + queues[current].queue(doRequest); + current = (current + 1) % number; + + function doRequest(next) { + if (ajaxOpts.currentPage && ajaxOpts.currentPage != NRS.currentPage) { + next(); + } else if (ajaxOpts.currentSubPage && ajaxOpts.currentSubPage != NRS.currentSubPage) { + next(); + } else { + jqXHR = $.ajax(ajaxOpts); + + jqXHR.done(dfd.resolve) + .fail(dfd.reject) + .then(next, next); + } + } + + return promise; + }; + + return { + queue: queue + }; + } + +})(jQuery); + function BigInteger(t,i,r){null!=t&&("number"==typeof t?this.fromNumber(t,i,r):null==i&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,i))}function nbi(){return new BigInteger(null)}function am1(t,i,r,n,e,o){for(;--o>=0;){var s=i*this[t++]+r[n]+e;e=Math.floor(s/67108864),r[n++]=67108863&s}return e}function am2(t,i,r,n,e,o){for(var s=32767&i,h=i>>15;--o>=0;){var p=32767&this[t],u=this[t++]>>15,f=h*p+u*s;p=s*p+((32767&f)<<15)+r[n]+(1073741823&e),e=(p>>>30)+(f>>>15)+h*u+(e>>>30),r[n++]=1073741823&p}return e}function am3(t,i,r,n,e,o){for(var s=16383&i,h=i>>14;--o>=0;){var p=16383&this[t],u=this[t++]>>14,f=h*p+u*s;p=s*p+((16383&f)<<14)+r[n]+e,e=(p>>28)+(f>>14)+h*u,r[n++]=268435455&p}return e}function int2char(t){return BI_RM.charAt(t)}function intAt(t,i){var r=BI_RC[t.charCodeAt(i)];return null==r?-1:r}function bnpCopyTo(t){for(var i=this.t-1;i>=0;--i)t[i]=this[i];t.t=this.t,t.s=this.s}function bnpFromInt(t){this.t=1,this.s=0>t?-1:0,t>0?this[0]=t:-1>t?this[0]=t+this.DV:this.t=0}function nbv(t){var i=nbi();return i.fromInt(t),i}function bnpFromString(t,i){var r;if(16==i)r=4;else if(8==i)r=3;else if(256==i)r=8;else if(2==i)r=1;else if(32==i)r=5;else{if(4!=i)return void this.fromRadix(t,i);r=2}this.t=0,this.s=0;for(var n=t.length,e=!1,o=0;--n>=0;){var s=8==r?255&t[n]:intAt(t,n);0>s?"-"==t.charAt(n)&&(e=!0):(e=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t}function bnToString(t){if(this.s<0)return"-"+this.negate().toString(t);var i;if(16==t)i=4;else if(8==t)i=3;else if(2==t)i=1;else if(32==t)i=5;else{if(4!=t)return this.toRadix(t);i=2}var r,n=(1<0)for(h>h)>0&&(e=!0,o=int2char(r));s>=0;)i>h?(r=(this[s]&(1<>(h+=this.DB-i)):(r=this[s]>>(h-=i)&n,0>=h&&(h+=this.DB,--s)),r>0&&(e=!0),e&&(o+=int2char(r));return e?o:"0"}function bnNegate(){var t=nbi();return BigInteger.ZERO.subTo(this,t),t}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(t){var i=this.s-t.s;if(0!=i)return i;var r=this.t;if(i=r-t.t,0!=i)return this.s<0?-i:i;for(;--r>=0;)if(0!=(i=this[r]-t[r]))return i;return 0}function nbits(t){var i,r=1;return 0!=(i=t>>>16)&&(t=i,r+=16),0!=(i=t>>8)&&(t=i,r+=8),0!=(i=t>>4)&&(t=i,r+=4),0!=(i=t>>2)&&(t=i,r+=2),0!=(i=t>>1)&&(t=i,r+=1),r}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(t,i){var r;for(r=this.t-1;r>=0;--r)i[r+t]=this[r];for(r=t-1;r>=0;--r)i[r]=0;i.t=this.t+t,i.s=this.s}function bnpDRShiftTo(t,i){for(var r=t;r=0;--r)i[r+s+1]=this[r]>>e|h,h=(this[r]&o)<=0;--r)i[r]=0;i[s]=h,i.t=this.t+s+1,i.s=this.s,i.clamp()}function bnpRShiftTo(t,i){i.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)return void(i.t=0);var n=t%this.DB,e=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(i[this.t-r-1]|=(this.s&o)<r;)n+=this[r]-t[r],i[r++]=n&this.DM,n>>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}i.s=0>n?-1:0,-1>n?i[r++]=this.DV+n:n>0&&(i[r++]=n),i.t=r,i.clamp()}function bnpMultiplyTo(t,i){var r=this.abs(),n=t.abs(),e=r.t;for(i.t=e+n.t;--e>=0;)i[e]=0;for(e=0;e=0;)t[r]=0;for(r=0;r=i.DV&&(t[r+i.t]-=i.DV,t[r+i.t+1]=1)}t.t>0&&(t[t.t-1]+=i.am(r,i[r],t,2*r,0,1)),t.s=0,t.clamp()}function bnpDivRemTo(t,i,r){var n=t.abs();if(!(n.t<=0)){var e=this.abs();if(e.t0?(n.lShiftTo(p,o),e.lShiftTo(p,r)):(n.copyTo(o),e.copyTo(r));var u=o.t,f=o[u-1];if(0!=f){var a=f*(1<1?o[u-2]>>this.F2:0),b=this.FV/a,g=(1<=0&&(r[r.t++]=1,r.subTo(v,r)),BigInteger.ONE.dlShiftTo(u,v),v.subTo(o,o);o.t=0;){var B=r[--m]==f?this.DM:Math.floor(r[m]*b+(r[m-1]+l)*g);if((r[m]+=o.am(0,B,r,c,0,u))0&&r.rShiftTo(p,r),0>s&&BigInteger.ZERO.subTo(r,r)}}}function bnMod(t){var i=nbi();return this.abs().divRemTo(t,null,i),this.s<0&&i.compareTo(BigInteger.ZERO)>0&&t.subTo(i,i),i}function Classic(t){this.m=t}function cConvert(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function cRevert(t){return t}function cReduce(t){t.divRemTo(this.m,null,t)}function cMulTo(t,i,r){t.multiplyTo(i,r),this.reduce(r)}function cSqrTo(t,i){t.squareTo(i),this.reduce(i)}function bnpInvDigit(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var i=3&t;return i=i*(2-(15&t)*i)&15,i=i*(2-(255&t)*i)&255,i=i*(2-((65535&t)*i&65535))&65535,i=i*(2-t*i%this.DV)%this.DV,i>0?this.DV-i:-i}function Montgomery(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(i,i),i}function montRevert(t){var i=nbi();return t.copyTo(i),this.reduce(i),i}function montReduce(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var i=0;i>15)*this.mpl&this.um)<<15)&t.DM;for(r=i+this.m.t,t[r]+=this.m.am(0,n,t,i,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function montSqrTo(t,i){t.squareTo(i),this.reduce(i)}function montMulTo(t,i,r){t.multiplyTo(i,r),this.reduce(r)}function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)}function bnpExp(t,i){if(t>4294967295||1>t)return BigInteger.ONE;var r=nbi(),n=nbi(),e=i.convert(this),o=nbits(t)-1;for(e.copyTo(r);--o>=0;)if(i.sqrTo(r,n),(t&1<0)i.mulTo(n,e,r);else{var s=r;r=n,n=s}return i.revert(r)}function bnModPowInt(t,i){var r;return r=256>t||i.isEven()?new Classic(i):new Montgomery(i),this.exp(t,r)}function bnClone(){var t=nbi();return this.copyTo(t),t}function bnIntValue(){if(this.s<0){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(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function bnpToRadix(t){if(null==t&&(t=10),0==this.signum()||2>t||t>36)return"0";var i=this.chunkSize(t),r=Math.pow(t,i),n=nbv(r),e=nbi(),o=nbi(),s="";for(this.divRemTo(n,e,o);e.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,e.divRemTo(n,e,o);return o.intValue().toString(t)+s}function bnpFromRadix(t,i){this.fromInt(0),null==i&&(i=10);for(var r=this.chunkSize(i),n=Math.pow(i,r),e=!1,o=0,s=0,h=0;hp?"-"==t.charAt(h)&&0==this.signum()&&(e=!0):(s=i*s+p,++o>=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(i,o)),this.dAddOffset(s,0)),e&&BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(t,i,r){if("number"==typeof i)if(2>t)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,e=7&t;n.length=(t>>3)+1,i.nextBytes(n),e>0?n[0]&=(1<0)for(n>n)!=(this.s&this.DM)>>n&&(i[e++]=r|this.s<=0;)8>n?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,0>=n&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==e&&(128&this.s)!=(128&r)&&++e,(e>0||r!=this.s)&&(i[e++]=r);return i}function bnEquals(t){return 0==this.compareTo(t)}function bnMin(t){return this.compareTo(t)<0?this:t}function bnMax(t){return this.compareTo(t)>0?this:t}function bnpBitwiseTo(t,i,r){var n,e,o=Math.min(t.t,this.t);for(n=0;o>n;++n)r[n]=i(this[n],t[n]);if(t.tt?this.rShiftTo(-t,i):this.lShiftTo(t,i),i}function bnShiftRight(t){var i=nbi();return 0>t?this.lShiftTo(-t,i):this.rShiftTo(t,i),i}function lbit(t){if(0==t)return-1;var i=0;return 0==(65535&t)&&(t>>=16,i+=16),0==(255&t)&&(t>>=8,i+=8),0==(15&t)&&(t>>=4,i+=4),0==(3&t)&&(t>>=2,i+=2),0==(1&t)&&++i,i}function bnGetLowestSetBit(){for(var t=0;t=this.t?0!=this.s:0!=(this[i]&1<r;)n+=this[r]+t[r],i[r++]=n&this.DM,n>>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}i.s=0>n?-1:0,n>0?i[r++]=n:-1>n&&(i[r++]=this.DV+n),i.t=r,i.clamp()}function bnAdd(t){var i=nbi();return this.addTo(t,i),i}function bnSubtract(t){var i=nbi();return this.subTo(t,i),i}function bnMultiply(t){var i=nbi();return this.multiplyTo(t,i),i}function bnSquare(){var t=nbi();return this.squareTo(t),t}function bnDivide(t){var i=nbi();return this.divRemTo(t,i,null),i}function bnRemainder(t){var i=nbi();return this.divRemTo(t,null,i),i}function bnDivideAndRemainder(t){var i=nbi(),r=nbi();return this.divRemTo(t,i,r),new Array(i,r)}function bnpDMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(t,i){if(0!=t){for(;this.t<=i;)this[this.t++]=0;for(this[i]+=t;this[i]>=this.DV;)this[i]-=this.DV,++i>=this.t&&(this[this.t++]=0),++this[i]}}function NullExp(){}function nNop(t){return t}function nMulTo(t,i,r){t.multiplyTo(i,r)}function nSqrTo(t,i){t.squareTo(i)}function bnPow(t){return this.exp(t,new NullExp)}function bnpMultiplyLowerTo(t,i,r){var n=Math.min(this.t+t.t,i);for(r.s=0,r.t=n;n>0;)r[--n]=0;var e;for(e=r.t-this.t;e>n;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(e=Math.min(t.t,i);e>n;++n)this.am(0,t[n],r,n,0,i-n);r.clamp()}function bnpMultiplyUpperTo(t,i,r){--i;var n=r.t=this.t+t.t-i;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(i-this.t,0);n2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var i=nbi();return t.copyTo(i),this.reduce(i),i}function barrettRevert(t){return t}function barrettReduce(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function barrettSqrTo(t,i){t.squareTo(i),this.reduce(i)}function barrettMulTo(t,i,r){t.multiplyTo(i,r),this.reduce(r)}function bnModPow(t,i){var r,n,e=t.bitLength(),o=nbv(1);if(0>=e)return o;r=18>e?1:48>e?3:144>e?4:768>e?5:6,n=8>e?new Classic(i):i.isEven()?new Barrett(i):new Montgomery(i);var s=new Array,h=3,p=r-1,u=(1<1){var f=nbi();for(n.sqrTo(s[1],f);u>=h;)s[h]=nbi(),n.mulTo(f,s[h-2],s[h]),h+=2}var a,b,g=t.t-1,l=!0,m=nbi();for(e=nbits(t[g])-1;g>=0;){for(e>=p?a=t[g]>>e-p&u:(a=(t[g]&(1<0&&(a|=t[g-1]>>this.DB+e-p)),h=r;0==(1&a);)a>>=1,--h;if((e-=h)<0&&(e+=this.DB,--g),l)s[a].copyTo(o),l=!1;else{for(;h>1;)n.sqrTo(o,m),n.sqrTo(m,o),h-=2;h>0?n.sqrTo(o,m):(b=o,o=m,m=b),n.mulTo(m,s[a],o)}for(;g>=0&&0==(t[g]&1<o)return i;for(o>e&&(o=e),o>0&&(i.rShiftTo(o,i),r.rShiftTo(o,r));i.signum()>0;)(e=i.getLowestSetBit())>0&&i.rShiftTo(e,i),(e=r.getLowestSetBit())>0&&r.rShiftTo(e,r),i.compareTo(r)>=0?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r}function bnpModInt(t){if(0>=t)return 0;var i=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==i)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(i*r+this[n])%t;return r}function bnModInverse(t){var i=t.isEven();if(this.isEven()&&i||0==t.signum())return BigInteger.ZERO;for(var r=t.clone(),n=this.clone(),e=nbv(1),o=nbv(0),s=nbv(0),h=nbv(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),i?(e.isEven()&&o.isEven()||(e.addTo(this,e),o.subTo(t,o)),e.rShiftTo(1,e)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),i?(s.isEven()&&h.isEven()||(s.addTo(this,s),h.subTo(t,h)),s.rShiftTo(1,s)):h.isEven()||h.subTo(t,h),h.rShiftTo(1,h);r.compareTo(n)>=0?(r.subTo(n,r),i&&e.subTo(s,e),o.subTo(h,o)):(n.subTo(r,n),i&&s.subTo(e,s),h.subTo(o,h))}return 0!=n.compareTo(BigInteger.ONE)?BigInteger.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h}function bnIsProbablePrime(t){var i,r=this.abs();if(1==r.t&&r[0]<=lowprimes[lowprimes.length-1]){for(i=0;in;)n*=lowprimes[e++];for(n=r.modInt(n);e>i;)if(n%lowprimes[i++]==0)return!1}return r.millerRabin(t)}function bnpMillerRabin(t){var i=this.subtract(BigInteger.ONE),r=i.getLowestSetBit();if(0>=r)return!1;var n=i.shiftRight(r);t=t+1>>1,t>lowprimes.length&&(t=lowprimes.length);for(var e=nbi(),o=0;t>o;++o){e.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);var s=e.modPow(n,this);if(0!=s.compareTo(BigInteger.ONE)&&0!=s.compareTo(i)){for(var h=1;h++=vv;++vv)BI_RC[rr++]=vv;for(rr="a".charCodeAt(0),vv=10;36>vv;++vv)BI_RC[rr++]=vv;for(rr="A".charCodeAt(0),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),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;var converters=function(){var r,t={},n=[];for(r=0;9>=r;++r){var e=r.toString();t[e]=r,n.push(e)}for(r=10;15>=r;++r){var o=String.fromCharCode("a".charCodeAt(0)+r-10),a=String.fromCharCode("A".charCodeAt(0)+r-10);t[o]=r,t[a]=r,n.push(o)}return{byteArrayToHexString:function(r){for(var t="",e=0;e>4]+n[15&r[e]];return t},stringToByteArray:function(r){r=unescape(encodeURIComponent(r));for(var t=new Array(r.length),n=0;ne)throw new Error("Start index should not be negative");if(r.length=0;a--)n=o.multiply(new BigInteger("256",10)),e=n.add(new BigInteger(r[t+a].toString(10),10)),o=e;return o},byteArrayToWordArray:function(r){for(var t=0,n=0,e=0,o=r.length,a=new Uint32Array((o/4|0)+(o%4==0?0:1));o-o%4>t;)a[n++]=r[t++]<<24|r[t++]<<16|r[t++]<<8|r[t++];o%4!=0&&(e=r[t++]<<24,o%4>1&&(e|=r[t++]<<16),o%4>2&&(e|=r[t++]<<8),a[n]=e);var i=new Object;return i.sigBytes=o,i.words=a,i},wordArrayToByteArray:function(r){var t=r.words.length;if(0==t)return new Array(0);var n,e,o=new Array(r.sigBytes),a=0;for(e=0;t-1>e;e++)n=r.words[e],o[a++]=n>>24,o[a++]=n>>16&255,o[a++]=n>>8&255,o[a++]=255&n;return n=r.words[t-1],o[a++]=n>>24,r.sigBytes%4==0&&(o[a++]=n>>16&255,o[a++]=n>>8&255,o[a++]=255&n),r.sigBytes%4>1&&(o[a++]=n>>16&255),r.sigBytes%4>2&&(o[a++]=n>>8&255),o},byteArrayToString:function(r,t,n){if(0==n)return"";if(t&&n){{this.checkBytesToIntInput(r,parseInt(n,10),parseInt(t,10))}r=r.slice(t,t+n)}return decodeURIComponent(escape(String.fromCharCode.apply(null,r)))},byteArrayToShortArray:function(r){var t,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;16>t;t++)n[t]=r[2*t]|r[2*t+1]<<8;return n},shortArrayToByteArray:function(r){var t,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;16>t;t++)n[2*t]=255&r[t],n[2*t+1]=r[t]>>8;return n},shortArrayToHexString:function(r){for(var t="",e=0;e>4&15]+n[15&r[e]]+n[r[e]>>12&15]+n[r[e]>>8&15];return t},intToBytes_:function(r,t,n,e){var o=Math.floor(n/2),a=-1*(o+1);if(r!=Math.floor(r)||a>r||r>n)throw new Error(r+" is not a "+8*t+" bit integer");var i,u=[],y=r>=0&&o>=r?0:r>o&&n>=r?1:2;2==y&&(r=-1*r-1);for(var s=0;t>s;s++)i=2==y?255-r%256:r%256,e?u.unshift(i):u.push(i),1==y?r=Math.floor(r/256):r>>=8;return u},int32ToBytes:function(r,t){return converters.intToBytes_(r,4,4294967295,t)}}}();function string_to_array(_){for(var H=_.length,A=new Array(H),r=0;H>r;r++)A[r]=_.charCodeAt(r);return A}function array_to_hex_string(_){for(var H="",A=0;A<_.length;A++)H+=SHA256_hexchars[_[A]>>4]+SHA256_hexchars[15&_[A]];return H}function SHA256_init(){SHA256_H=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),SHA256_buf=new Array,SHA256_len=0}function SHA256_write(_){SHA256_buf=SHA256_buf.concat("string"==typeof _?string_to_array(_):_);for(var H=0;H+64<=SHA256_buf.length;H+=64)SHA256_Hash_Byte_Block(SHA256_H,SHA256_buf.slice(H,H+64));SHA256_buf=SHA256_buf.slice(H),SHA256_len+=_.length}function SHA256_finalize(){if(SHA256_buf[SHA256_buf.length]=128,SHA256_buf.length>56){for(var _=SHA256_buf.length;64>_;_++)SHA256_buf[_]=0;SHA256_Hash_Byte_Block(SHA256_H,SHA256_buf),SHA256_buf.length=0}for(var _=SHA256_buf.length;59>_;_++)SHA256_buf[_]=0;SHA256_buf[59]=SHA256_len>>>29&255,SHA256_buf[60]=SHA256_len>>>21&255,SHA256_buf[61]=SHA256_len>>>13&255,SHA256_buf[62]=SHA256_len>>>5&255,SHA256_buf[63]=SHA256_len<<3&255,SHA256_Hash_Byte_Block(SHA256_H,SHA256_buf);for(var H=new Array(32),_=0;8>_;_++)H[4*_+0]=SHA256_H[_]>>>24,H[4*_+1]=SHA256_H[_]>>16&255,H[4*_+2]=SHA256_H[_]>>8&255,H[4*_+3]=255&SHA256_H[_];return delete SHA256_H,delete SHA256_buf,delete SHA256_len,H}function SHA256_hash(_,H){var A;return SHA256_init(),SHA256_write(_),A=SHA256_finalize(),H?A:array_to_hex_string(A)}function HMAC_SHA256_init(_){HMAC_SHA256_key="string"==typeof _?string_to_array(_):(new Array).concat(_),HMAC_SHA256_key.length>64&&(SHA256_init(),SHA256_write(HMAC_SHA256_key),HMAC_SHA256_key=SHA256_finalize());for(var H=HMAC_SHA256_key.length;64>H;H++)HMAC_SHA256_key[H]=0;for(var H=0;64>H;H++)HMAC_SHA256_key[H]^=54;SHA256_init(),SHA256_write(HMAC_SHA256_key)}function HMAC_SHA256_write(_){SHA256_write(_)}function HMAC_SHA256_finalize(){for(var _=SHA256_finalize(),H=0;64>H;H++)HMAC_SHA256_key[H]^=106;SHA256_init(),SHA256_write(HMAC_SHA256_key),SHA256_write(_);for(var H=0;64>H;H++)HMAC_SHA256_key[H]=0;return delete HMAC_SHA256_key,SHA256_finalize()}function HMAC_SHA256_MAC(_,H){var A;return HMAC_SHA256_init(_),HMAC_SHA256_write(H),A=HMAC_SHA256_finalize(),array_to_hex_string(A)}function SHA256_sigma0(_){return(_>>>7|_<<25)^(_>>>18|_<<14)^_>>>3}function SHA256_sigma1(_){return(_>>>17|_<<15)^(_>>>19|_<<13)^_>>>10}function SHA256_Sigma0(_){return(_>>>2|_<<30)^(_>>>13|_<<19)^(_>>>22|_<<10)}function SHA256_Sigma1(_){return(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7)}function SHA256_Ch(_,H,A){return A^_&(H^A)}function SHA256_Maj(_,H,A){return _&H^A&(_^H)}function SHA256_Hash_Word_Block(_,H){for(var A=16;64>A;A++)H[A]=SHA256_sigma1(H[A-2])+H[A-7]+SHA256_sigma0(H[A-15])+H[A-16]&4294967295;for(var r=(new Array).concat(_),A=0;64>A;A++){var S=r[7]+SHA256_Sigma1(r[4])+SHA256_Ch(r[4],r[5],r[6])+SHA256_K[A]+H[A],n=SHA256_Sigma0(r[0])+SHA256_Maj(r[0],r[1],r[2]);r.pop(),r.unshift(S+n&4294967295),r[4]=r[4]+S&4294967295}for(var A=0;8>A;A++)_[A]=_[A]+r[A]&4294967295}function SHA256_Hash_Byte_Block(_,H){for(var A=new Array(16),r=0;16>r;r++)A[r]=H[4*r+0]<<24|H[4*r+1]<<16|H[4*r+2]<<8|H[4*r+3];SHA256_Hash_Word_Block(_,A)}var SHA256_buf=new Array,SHA256_len=0,SHA256_H=new Array;SHA256_hexchars=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"),SHA256_K=new Array(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);var curve25519=function(){function r(r){r[31]&=127,r[31]|=64,r[0]&=248}function n(r,n){for(var f=0;32>f;f++)r[f]=n[f]}function f(r,n,f,o,a,u){f=0|f,a=0|a,u=0|u;for(var t=0,v=0;a>v;++v)t+=(255&n[v+f])+u*(255&o[v]),r[v+f]=255&t,t>>=8;return t}function o(r,n,o,a,u){a=0|a,u=0|u;for(var t=31,v=0,i=0;a>i;i++){var c=u*(255&o[i]);v+=f(r,r,i,n,t,c)+(255&r[i+t])+c*(255&n[t]),r[i+t]=255&v,v>>=8}return r[i+t]=v+(255&r[i+t])&255,v>>8}function a(r,n,o,a,u){o=0|o,u=0|u;var t=0,v=(255&a[u-1])<<8;for(u>1&&(v|=255&a[u-2]);o-->=u;){var i=t<<16|(255&n[o])<<8;o>0&&(i|=255&n[o-1]);var c=o-u+1;i/=v,t+=f(n,n,c,a,u,-i),r[c]=i+t&255,f(n,n,c,a,u,-t),t=255&n[o],n[o]=0}n[u-1]=255&t}function u(r,n){for(;0!==n--&&0===r[n];);return n+1}function t(r,n,f,t){var v,i,c,e=32;for(c=0;32>c;c++)r[c]=n[c]=0;if(r[0]=1,v=u(f,32),0===v)return n;for(var y=new Array(32);;){if(i=e-v+1,a(y,t,e,f,v),e=u(t,e),0===e)return r;if(o(n,r,y,i,-1),i=v-e+1,a(y,f,v,t,e),v=u(f,v),0===v)return n;o(r,n,y,i,-1)}}function v(r,n){for(var f=0;F>f;f+=2)r[f/2]=255&n[f]|(255&n[f+1])<<8}function i(r){return r[0]>Q-19&&(r[1]&r[3]&r[5]&r[7]&r[9])===P&&(r[2]&r[4]&r[6]&r[8])===Q||r[9]>P}function c(r,n){for(var f=0;G>f;++f)n[2*f]=255&r[f],n[2*f+1]=(65280&r[f])>>8}function e(){return new Uint16Array(G)}function y(r,n){for(var f=0;G>f;++f)r[f]=n[f]}function w(r,n){r[0]=n;for(var f=1;G>f;++f)r[f]=0}function A(r,n,f){var o,a=e(),u=e(),t=e(),v=e(),i=e();for(W(u,n),W(t,u),W(a,t),V(t,a,n),V(a,t,u),W(u,a),V(v,u,t),W(u,v),W(t,u),W(u,t),W(t,u),W(u,t),V(t,u,v),W(u,t),W(v,u),o=1;5>o;o++)W(u,v),W(v,u);for(V(u,v,t),W(v,u),W(i,v),o=1;10>o;o++)W(v,i),W(i,v);for(V(v,i,u),o=0;5>o;o++)W(u,v),W(v,u);for(V(u,v,t),W(t,u),W(v,t),o=1;25>o;o++)W(t,v),W(v,t);for(V(t,v,u),W(v,t),W(i,v),o=1;50>o;o++)W(v,i),W(i,v);for(V(v,i,t),o=0;25>o;o++)W(i,v),W(v,i);V(t,v,u),W(u,t),W(t,u),0!==f?V(r,n,t):(W(u,t),W(t,u),W(u,t),V(r,u,a))}function l(r){var n=i(r)||r[9]<0,f=1&r[0];return 4294967295&((n?1:0)^f)}function g(r,n){var f=e(),o=e(),a=e();R(o,n,n),A(f,o,1),W(r,f),V(a,o,r),S(a,a,L),V(o,f,a),V(r,n,o)}function k(r,n,f,o,a,u,t,v){var i,c=[];return c[0]=65535&(i=v*v),c[1]=65535&(i=(i/65536|0)+2*v*t),c[2]=65535&(i=(i/65536|0)+2*v*u+t*t),c[3]=65535&(i=(i/65536|0)+2*v*a+2*t*u),c[4]=65535&(i=(i/65536|0)+2*v*o+2*t*a+u*u),c[5]=65535&(i=(i/65536|0)+2*v*f+2*t*o+2*u*a),c[6]=65535&(i=(i/65536|0)+2*v*n+2*t*f+2*u*o+a*a),c[7]=65535&(i=(i/65536|0)+2*v*r+2*t*n+2*u*f+2*a*o),c[8]=65535&(i=(i/65536|0)+2*t*r+2*u*n+2*a*f+o*o),c[9]=65535&(i=(i/65536|0)+2*u*r+2*a*n+2*o*f),c[10]=65535&(i=(i/65536|0)+2*a*r+2*o*n+f*f),c[11]=65535&(i=(i/65536|0)+2*o*r+2*f*n),c[12]=65535&(i=(i/65536|0)+2*f*r+n*n),c[13]=65535&(i=(i/65536|0)+2*n*r),c[14]=65535&(i=(i/65536|0)+r*r),c[15]=i/65536|0,c}function s(r,n){var f,o=k(n[15],n[14],n[13],n[12],n[11],n[10],n[9],n[8]),a=k(n[7],n[6],n[5],n[4],n[3],n[2],n[1],n[0]),u=k(n[15]+n[7],n[14]+n[6],n[13]+n[5],n[12]+n[4],n[11]+n[3],n[10]+n[2],n[9]+n[1],n[8]+n[0]);r[0]=65535&(f=8388608+a[0]+38*(u[8]-o[8]-a[8]+o[0]-128)),r[1]=65535&(f=8388480+(f/65536|0)+a[1]+38*(u[9]-o[9]-a[9]+o[1])),r[2]=65535&(f=8388480+(f/65536|0)+a[2]+38*(u[10]-o[10]-a[10]+o[2])),r[3]=65535&(f=8388480+(f/65536|0)+a[3]+38*(u[11]-o[11]-a[11]+o[3])),r[4]=65535&(f=8388480+(f/65536|0)+a[4]+38*(u[12]-o[12]-a[12]+o[4])),r[5]=65535&(f=8388480+(f/65536|0)+a[5]+38*(u[13]-o[13]-a[13]+o[5])),r[6]=65535&(f=8388480+(f/65536|0)+a[6]+38*(u[14]-o[14]-a[14]+o[6])),r[7]=65535&(f=8388480+(f/65536|0)+a[7]+38*(u[15]-o[15]-a[15]+o[7])),r[8]=65535&(f=8388480+(f/65536|0)+a[8]+u[0]-o[0]-a[0]+38*o[8]),r[9]=65535&(f=8388480+(f/65536|0)+a[9]+u[1]-o[1]-a[1]+38*o[9]),r[10]=65535&(f=8388480+(f/65536|0)+a[10]+u[2]-o[2]-a[2]+38*o[10]),r[11]=65535&(f=8388480+(f/65536|0)+a[11]+u[3]-o[3]-a[3]+38*o[11]),r[12]=65535&(f=8388480+(f/65536|0)+a[12]+u[4]-o[4]-a[4]+38*o[12]),r[13]=65535&(f=8388480+(f/65536|0)+a[13]+u[5]-o[5]-a[5]+38*o[13]),r[14]=65535&(f=8388480+(f/65536|0)+a[14]+u[6]-o[6]-a[6]+38*o[14]);var t=8388480+(f/65536|0)+a[15]+u[7]-o[7]-a[7]+38*o[15];U(r,t)}function d(r,n,f,o,a,u,t,v,i,c,e,y,w,A,l,g){var k,s=[];return s[0]=65535&(k=v*g),s[1]=65535&(k=(k/65536|0)+v*l+t*g),s[2]=65535&(k=(k/65536|0)+v*A+t*l+u*g),s[3]=65535&(k=(k/65536|0)+v*w+t*A+u*l+a*g),s[4]=65535&(k=(k/65536|0)+v*y+t*w+u*A+a*l+o*g),s[5]=65535&(k=(k/65536|0)+v*e+t*y+u*w+a*A+o*l+f*g),s[6]=65535&(k=(k/65536|0)+v*c+t*e+u*y+a*w+o*A+f*l+n*g),s[7]=65535&(k=(k/65536|0)+v*i+t*c+u*e+a*y+o*w+f*A+n*l+r*g),s[8]=65535&(k=(k/65536|0)+t*i+u*c+a*e+o*y+f*w+n*A+r*l),s[9]=65535&(k=(k/65536|0)+u*i+a*c+o*e+f*y+n*w+r*A),s[10]=65535&(k=(k/65536|0)+a*i+o*c+f*e+n*y+r*w),s[11]=65535&(k=(k/65536|0)+o*i+f*c+n*e+r*y),s[12]=65535&(k=(k/65536|0)+f*i+n*c+r*e),s[13]=65535&(k=(k/65536|0)+n*i+r*c),s[14]=65535&(k=(k/65536|0)+r*i),s[15]=k/65536|0,s}function p(r,n,f){var o,a=d(n[15],n[14],n[13],n[12],n[11],n[10],n[9],n[8],f[15],f[14],f[13],f[12],f[11],f[10],f[9],f[8]),u=d(n[7],n[6],n[5],n[4],n[3],n[2],n[1],n[0],f[7],f[6],f[5],f[4],f[3],f[2],f[1],f[0]),t=d(n[15]+n[7],n[14]+n[6],n[13]+n[5],n[12]+n[4],n[11]+n[3],n[10]+n[2],n[9]+n[1],n[8]+n[0],f[15]+f[7],f[14]+f[6],f[13]+f[5],f[12]+f[4],f[11]+f[3],f[10]+f[2],f[9]+f[1],f[8]+f[0]);r[0]=65535&(o=8388608+u[0]+38*(t[8]-a[8]-u[8]+a[0]-128)),r[1]=65535&(o=8388480+(o/65536|0)+u[1]+38*(t[9]-a[9]-u[9]+a[1])),r[2]=65535&(o=8388480+(o/65536|0)+u[2]+38*(t[10]-a[10]-u[10]+a[2])),r[3]=65535&(o=8388480+(o/65536|0)+u[3]+38*(t[11]-a[11]-u[11]+a[3])),r[4]=65535&(o=8388480+(o/65536|0)+u[4]+38*(t[12]-a[12]-u[12]+a[4])),r[5]=65535&(o=8388480+(o/65536|0)+u[5]+38*(t[13]-a[13]-u[13]+a[5])),r[6]=65535&(o=8388480+(o/65536|0)+u[6]+38*(t[14]-a[14]-u[14]+a[6])),r[7]=65535&(o=8388480+(o/65536|0)+u[7]+38*(t[15]-a[15]-u[15]+a[7])),r[8]=65535&(o=8388480+(o/65536|0)+u[8]+t[0]-a[0]-u[0]+38*a[8]),r[9]=65535&(o=8388480+(o/65536|0)+u[9]+t[1]-a[1]-u[1]+38*a[9]),r[10]=65535&(o=8388480+(o/65536|0)+u[10]+t[2]-a[2]-u[2]+38*a[10]),r[11]=65535&(o=8388480+(o/65536|0)+u[11]+t[3]-a[3]-u[3]+38*a[11]),r[12]=65535&(o=8388480+(o/65536|0)+u[12]+t[4]-a[4]-u[4]+38*a[12]),r[13]=65535&(o=8388480+(o/65536|0)+u[13]+t[5]-a[5]-u[5]+38*a[13]),r[14]=65535&(o=8388480+(o/65536|0)+u[14]+t[6]-a[6]-u[6]+38*a[14]);var v=8388480+(o/65536|0)+u[15]+t[7]-a[7]-u[7]+38*a[15];U(r,v)}function U(r,n){var f=n;r[15]=32767&f,f=19*(f/32768|0);for(var o=0;14>=o;++o)r[o]=65535&(f+=r[o]),f=f/65536|0;r[15]+=f}function b(r,n,f){var o;r[0]=65535&(o=19*((n[15]/32768|0)+(f[15]/32768|0))+n[0]+f[0]);for(var a=1;14>=a;++a)r[a]=65535&(o=(o/65536|0)+n[a]+f[a]);r[15]=(o/65536|0)+(32767&n[15])+(32767&f[15])}function h(r,n,f){var o;r[0]=65535&(o=524288+19*((n[15]/32768|0)-(f[15]/32768|0)-1)+n[0]-f[0]);for(var a=1;14>=a;++a)r[a]=65535&(o=(o/65536|0)+524280+n[a]-f[a]);r[15]=(o/65536|0)+32760+(32767&n[15])-(32767&f[15])}function j(r,n,f){var o;r[0]=65535&(o=n[0]*f);for(var a=1;14>=a;++a)r[a]=65535&(o=(o/65536|0)+n[a]*f);var u=(o/65536|0)+n[15]*f;U(r,u)}function m(r,n,f,o){R(r,f,o),S(n,f,o)}function q(r,n,f,o,a,u,t){V(a,n,f),V(u,r,o),R(r,a,u),S(n,a,u),W(a,r),W(r,n),V(u,r,t)}function x(r,n,f,o,a,u){W(r,f),W(n,o),V(a,r,n),S(n,r,n),T(u,n,121665),R(r,r,u),V(u,r,n)}function z(r,n,f){W(r,f),T(n,f,486662),R(r,r,n),R(r,r,L),V(n,r,f)}function B(r,o,a,u){var i,g,k=e(),s=e(),d=e(),p=e(),U=e(),b=[e(),e()],h=[e(),e()];for(null!==u?v(k,u):w(k,9),w(b[0],1),w(h[0],0),y(b[1],k),w(h[1],1),i=32;0!==i--;)for(g=8;0!==g--;){var j=(255&a[i])>>g&1,B=~(255&a[i])>>g&1,C=b[B],D=h[B],E=b[j],F=h[j];m(s,d,C,D),m(p,U,E,F),q(s,d,p,U,C,D,k),x(s,d,p,U,E,F)}if(A(s,h[0],0),V(k,b[0],s),c(k,r),null!==o){z(d,s,k),A(p,h[1],0),V(d,b[1],p),R(d,d,k),R(d,d,N),S(k,k,M),W(p,k),V(k,d,p),S(k,k,s),S(k,k,O),V(s,k,K),0!==l(s)?n(o,a):f(o,I,0,a,32,-1);var G=new Array(32),J=new Array(64),L=new Array(64);n(G,H),n(o,t(J,L,o,G)),0!==(128&o[31])&&f(o,o,0,H,32,1)}}function C(r,u,t){var v,i,c=new Array(32),e=new Array(32),y=new Array(64),w=new Array(64);n(c,r),n(e,u);var A=new Array(32);a(A,c,32,H,32),a(A,e,32,H,32);var l=new Array(32);for(f(l,e,0,c,32,-1),f(l,l,0,H,32,1),o(y,l,t,32,1),a(w,y,64,H,32),v=0,i=0;32>i;i++)v|=l[i]=y[i];return 0!==v?l:void 0}function D(r,n,f){var o,a,u,t=new Array(32),i=[e(),e()],k=[e(),e()],s=[e(),e(),e()],d=[e(),e(),e()],p=[e(),e(),e()],U=[e(),e(),e()],b=0,h=0,j=0,B=0;for(w(i[0],9),v(i[1],f),z(p[0],U[0],i[1]),g(p[0],U[0]),a=l(p[0]),R(U[0],U[0],O),V(U[1],J,p[0]),S(p[a],U[0],U[1]),R(p[1-a],U[0],U[1]),y(U[0],i[1]),S(U[0],U[0],M),W(U[1],U[0]),A(U[0],U[1],0),V(k[0],p[0],U[0]),S(k[0],k[0],i[1]),S(k[0],k[0],N),V(k[1],p[1],U[0]),S(k[1],k[1],i[1]),S(k[1],k[1],N),T(k[0],k[0],1),T(k[1],k[1],1),o=0;32>o;o++)b=b>>8^255&r[o]^(255&r[o])<<1,h=h>>8^255&n[o]^(255&n[o])<<1,B=~(b^h),j=B&(128&j)>>7^b,j^=B&(1&j)<<1,j^=B&(2&j)<<1,j^=B&(4&j)<<1,j^=B&(8&j)<<1,j^=B&(16&j)<<1,j^=B&(32&j)<<1,j^=B&(64&j)<<1,t[o]=255&j;for(j=(B&(128&j)<<1^b)>>8,w(s[0],1),y(s[1],i[j]),y(s[2],k[0]),w(d[0],0),w(d[1],1),w(d[2],1),b=0,h=0,o=32;0!==o--;)for(b=b<<8|255&r[o],h=h<<8|255&n[o],j=j<<8|255&t[o],a=8;0!==a--;)m(p[0],U[0],s[0],d[0]),m(p[1],U[1],s[1],d[1]),m(p[2],U[2],s[2],d[2]),u=((b^b>>1)>>a&1)+((h^h>>1)>>a&1),x(s[2],d[2],p[u],U[u],s[0],d[0]),u=j>>a&2^(j>>a&1)<<1,q(p[1],U[1],p[u],U[u],s[1],d[1],i[j>>a&1]),q(p[2],U[2],p[0],U[0],s[2],d[2],k[((b^h)>>a&2)>>1]);u=(1&b)+(1&h),A(p[0],d[u],0),V(p[1],s[u],p[0]);var C=[];return c(p[1],C),C}function E(n){var f=[],o=[];return n=n||[],r(n),B(f,o,n,null),{p:f,s:o,k:n}}var F=32,G=16,H=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16],I=[104,159,174,231,210,24,147,192,178,230,188,23,245,206,247,166,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128],J=[22587,610,29883,44076,15515,9479,25859,56197,23910,4462,17831,16322,62102,36542,52412,16035],K=[5744,16384,61977,54121,8776,18501,26522,34893,23833,5823,55924,58749,24147,14085,13606,6080],L=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],M=[9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],N=[27919,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0],O=[33224,601,0,0,0,0,0,0,0,0,0,0,0,0,0,0],P=33554431,Q=67108863,R=b,S=h,T=j,V=p,W=s;return{sign:C,verify:D,keygen:E}}();function NxtAddress(){function r(r){return v[31-c[r]]}function t(r,t){if(0==r||0==t)return 0;var e=(c[r]+c[t])%31;return v[e]}function e(r,e){for(var f=0,n=0;e>n;n++)f^=t(r[n],h[e-n]);return f}function f(r){for(var e=[],f=1;31>=f;f++){for(var n=0,i=0;5>i;i++)n^=t(v[i*f%31],r[i]);if(0==n){var o=31-f;if(o>12&&27>o)return[];e[e.length]=o}}return e}function n(){for(var n=0,i=[0,0,0,0,0],o=[],a=0,s=[1,0,0,0,0],c=0;4>c;c++){var d=e(s,c+1);if(0!=d){a=0;for(var g=0;5>g;g++)o[g]=s[g]^t(d,i[g]),o[g]&&(a=g);if(c>=2*n)for(n=c+1-n,g=0;5>g;g++)i[g]=t(s[g],r(d));s=o.slice()}i.unshift(0)}var l=f(s),p=l.length;if(1>p||p>2)return!1;if(a!=p)return!1;for(var C=[0,0,0,0,0],g=0;4>g;g++){for(var o=0,A=0;g>A;A++)o^=t(h[g+1-A],s[A]);C[g]=o}for(c=0;p>c;c++){var o=0,b=l[c],k=31-b;for(g=0;4>g;g++)o^=t(C[g],v[k*g%31]);if(o){var _=t(s[1],1)^t(s[3],v[2*k%31]);if(0==_)return!1;b>12&&(b-=14),u[b]^=t(o,r(_))}}return!0}function i(){for(var r=[0,0,0,0],e=12;e>=0;e--){var f=u[e]^r[3];r[3]=r[2]^t(30,f),r[2]=r[1]^t(6,f),r[1]=r[0]^t(9,f),r[0]=t(17,f)}u[13]=r[0],u[14]=r[1],u[15]=r[2],u[16]=r[3]}function o(){for(var r=0;17>r;r++)u[r]=1}function a(r,t,e){"undefined"==typeof t&&(t=17),"undefined"==typeof e&&(e=-1);for(var f=0,n=0;t>f;f++)f!=e&&(u[d[n++]]=r[f])}function s(r){var t=[],e=[],f=0,n=r.length;if(20==n&&"1"!=r.charAt(0))return!1;for(var o=0;n>o;o++)t[o]=r.charCodeAt(o)-"0".charCodeAt(0);do{var a=0,s=0;for(o=0;n>o;o++)a=10*a+t[o],a>=32?(t[s++]=a>>5,a&=31):s>0&&(t[s++]=0);n=s,e[f++]=a}while(s);for(o=0;13>o;o++)u[o]=--f>=0?e[o]:0;return i(),!0}var u=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],h=[0,0,0,0,0],v=[1,2,4,8,16,5,10,20,13,26,17,7,14,28,29,31,27,19,3,6,12,24,21,15,30,25,23,11,22,9,18,1],c=[0,0,1,18,2,5,19,11,3,29,6,27,20,8,12,23,4,10,30,17,7,22,28,26,21,25,9,16,13,14,24,15],d=[3,2,1,0,7,6,5,4,13,14,15,16,12,8,9,10,11],g="23456789ABCDEFGHJKLMNPQRSTUVWXYZ";this.guess=[],this.add_guess=function(){var r=this.toString(),t=this.guess.length;if(!(t>2)){for(var e=0;t>e;e++)if(this.guess[e]==r)return;this.guess[t]=r}},this.ok=function(){for(var r=0,e=1;5>e;e++){for(var f=0,n=0;31>f;f++)if(!(f>12&&27>f)){var i=f;f>26&&(i-=14),n^=t(u[i],v[e*f%31])}r|=n,h[e]=n}return 0==r},this.toString=function(){for(var r="NXT-",t=0;17>t;t++)r+=g[u[d[t]]],3==(3&t)&&13>t&&(r+="-");return r},this.account_id=function(){for(var r="",t=[],e=13,f=0;13>f;f++)t[f]=u[12-f];do{var n=0,i=0;for(f=0;e>f;f++)n=32*n+t[f],n>=10?(t[i++]=Math.floor(n/10),n%=10):i>0&&(t[i++]=0);e=i,r+=String.fromCharCode(n+"0".charCodeAt(0))}while(i);return r.split("").reverse().join("")},this.set=function(r,t){"undefined"==typeof t&&(t=!0);var e=0;if(this.guess=[],o(),r=String(r),r=r.replace(/(^\s+)|(\s+$)/g,"").toUpperCase(),0==r.indexOf("NXT-")&&(r=r.substr(4)),r.match(/^\d{1,20}$/g)){if(t)return s(r)}else for(var f=[],i=0;i=0&&(f[e++]=u,e>18))return!1}if(16==e)for(var i=16;i>=0;i--){for(var h=0;32>h;h++)f[i]=h,a(f),this.ok()&&this.add_guess();if(i>0){var v=f[i-1];f[i-1]=f[i],f[i]=v}}if(18==e)for(var i=0;18>i;i++)a(f,18,i),this.ok()&&this.add_guess();if(17==e){if(a(f),this.ok())return!0;n()&&this.ok()&&this.add_guess()}return o(),!1},this.format_guess=function(r,t){var e="",f=[];r=r.toUpperCase(),t=t.toUpperCase();for(var n=0;n=f[o].e)for(var s;o=s)););e+=n>=f[o].s&&n'+r.charAt(n)+""}return e}} function objectEquals(e,a){"use strict";if(null===e||void 0===e||null===a||void 0===a)return e===a;if(e.constructor!==a.constructor)return!1;if(e instanceof Function)return e===a;if(e===a||e.valueOf()===a.valueOf())return!0;if(Array.isArray(e)&&e.length!==a.length)return!1;if(e instanceof Date)return!1;if(!(e instanceof Object))return!1;if(!(a instanceof Object))return!1;var t=Object.keys(e);return Object.keys(a).every(function(e){return-1!==t.indexOf(e)})?t.every(function(t){return objectEquals(e[t],a[t])}):!1}function byteArrayToBigInteger(e){for(var a,t,n=new BigInteger("0",10),r=e.length-1;r>=0;r--)a=n.multiply(new BigInteger("256",10)),t=a.add(new BigInteger(e[r].toString(10),10)),n=t;return n}function simpleHash(e){return _hash.init(),_hash.update(e),_hash.getBytes()}function getPublicKey(e){SHA256_init(),SHA256_write(converters.stringToByteArray(e));var a=converters.byteArrayToHexString(curve25519.keygen(SHA256_finalize()).p);return converters.hexStringToByteArray(a)}function toByteArray(e){for(var a=[0,0,0,0],t=0;tr;r++)n[r]=e({});return{queue:t}}e.ajaxMultiQueue=function(e){return new a(~~e)}}(jQuery);var Jay={};Jay.commonNodes=["69.163.40.132","jnxt.org","nxt.noip.me","23.88.59.40","162.243.122.251", "127.0.0.1"],Jay.msTimeout=1e3,Jay.requestMethods={},Jay.requestMethods.single=0,Jay.requestMethods.fastest=1,Jay.requestMethods.validate=2,Jay.requestMethods.cautious=3,Jay.requestMethods["default"]=Jay.requestMethods.fastest,Jay.requestMethod=Jay.requestMethods["default"],Jay.req=$.ajaxMultiQueue(6),Jay.singleNode="",Jay.bestNodes=[],Jay.isTestnet=!1,Jay.queue=function(e,a,t,n){var r={};r.url=Jay.resolveNode(e),r.data=a,r.beforeSend=function(t){t.node=e,t.parameters=a},r.method="POST",r.success=t,r.error=void 0!=n?n:t,r.timeout=Jay.msTimeout,Jay.req.queue(r)},Jay.setNode=function(e){Jay.singleNode=e},Jay.setRequestMethod=function(e){Jay.requestMethod=e},Jay.resolveNode=function(e){var a="http://";return a+=e,a+=Jay.isTestnet?":6876":":7876",a+="/nxt"},Jay.nodeScan=function(e){for(var a=0,t=0;to;o++)Jay.queue(Jay.bestNodes[o],a,function(e,a,r){y.push(e),3==y.length&&(Jay.objectCompare(y[0],y[1])?t(y[0],"success",r):Jay.objectCompare(y[1],y[2])?t(y[1],"success",r):Jay.objectCompare(y[0],y[2])?t(y[2],"success",r):n({error:"Unable to Validate"},"error",r))})},Jay.objectCompare=function(e,a,t){if(void 0===t)return e.requestProcessingTime=0,a.requestProcessingTime=0,alert(t),objectEquals(e,a);for(var n=0;nn;n++)t[n]=a;return t},Jay.positiveByteArray=function(e){return converters.hexStringToByteArray(converters.byteArrayToHexString(e))},Jay.rsToBytes=function(e){var a=new NxtAddress;a.set(e);var t=new BigInteger(a.account_id()).toByteArray().reverse();for(9==t.length&&(t=t.slice(0,8));t.length<8;)t=t.concat(Jay.pad(1,0));return t},Jay.secretPhraseToPublicKey=function(e){var a=converters.stringToByteArray(e),t=simpleHash(a);return curve25519.keygen(t).p},Jay.publicKeyToAccountId=function(e,a){var t=converters.hexStringToByteArray(e);_hash.init(),_hash.update(t);var n=_hash.getBytes();n=converters.byteArrayToHexString(n);var r=converters.hexStringToByteArray(n).slice(0,8),s=byteArrayToBigInteger(r).toString();if(a){var y=new NxtAddress;return y.set(s)?y.toString():""}return s},Jay.numberToBytes=function(e){var a=new BigInteger(e.toString()).toByteArray().reverse();for(9==a.length&&(a=a.slice(0,8));a.length<8;)a=a.concat(Jay.pad(1,0));return a},Jay.createTrfBytes=function(e,a,t,n,r,s,y){var o=[];return o.push(Jay.TRFVersion),o.push(e),o.push(a+(Jay.transactionVersion<<4)),o=o.concat(Jay.rsToBytes(t)),o=o.concat(Jay.numberToBytes(Math.round(n*Jay.oneNxt))),o=o.concat(Jay.numberToBytes(Math.round(r*Jay.oneNxt))),o=o.concat(void 0==y?[0,0,0,0]:y.flags),void 0!=s&&(o=o.concat(s)),void 0!=y&&(o=o.concat(Jay.combineAppendages(y))),Jay.positiveByteArray(o)},Jay.createTrf=function(e,a,t,n,r,s,y){var o=Jay.createTrfBytes(e,a,t,n,r,s,y);return Jay.finishTrf(o)},Jay.bytesToBigInteger=function(e){for(var a=new BigInteger("0"),t=0;tr?r+"0".charCodeAt(0):36>r?r+"A".charCodeAt(0)-10:r+"a".charCodeAt(0)-10-26),a=n[0]}return t=t.split("").reverse().join("")},Jay.finishTrf=function(e){return"TX_"+Jay.base62_encode(e)},Jay.sendMoney=function(e,a,t){return Jay.createTrf(Jay.types.payment,Jay.subtypes.ordinaryPayment,e,a,1,void 0,t)},Jay.sendMessage=function(e,a,t){var n=Jay.addAppendage(Jay.appendages.message,a,t);return Jay.createTrf(Jay.types.messaging,Jay.subtypes.arbitraryMessage,e,0,1,void 0,n)},Jay.setAlias=function(e,a,t){var n=[];return n.push(Jay.transactionVersion),n.push(e.length),n=n.concat(converters.stringToByteArray(e)),n=n.concat(Jay.wordBytes(a.length)),n=n.concat(converters.stringToByteArray(a)),Jay.createTrf(Jay.types.messaging,Jay.subtypes.aliasAssignment,Jay.genesisRS,0,1,n,t)},Jay.setAccountInfo=function(e,a,t){var n=[];return n.push(Jay.transactionVersion),n.push(e.length),n=n.concat(converters.stringToByteArray(e)),n=n.concat(Jay.wordBytes(a.length)),n=n.concat(converters.stringToByteArray(a)),Jay.createTrf(Jay.types.messaging,Jay.subtypes.accountInfo,Jay.genesisRS,0,1,n,t)},Jay.sellAlias=function(e,a,t,n){var r=[];return r.push(Jay.transactionVersion),r.push(e.length),r=r.concat(converters.stringToByteArray(e)),r=r.concat(Jay.numberToBytes(Math.round(a*Jay.oneNxt))),void 0==t||"anyone"==t||""==t?Jay.createTrf(Jay.types.messaging,Jay.subtypes.aliasSell,[0,0,0,0,0,0,0,0],0,1,r,n):Jay.createTrf(Jay.types.messaging,Jay.subtypes.aliasSell,t,0,1,r,n)},Jay.buyAlias=function(e,a,t,n){var r=[];return r.push(Jay.transactionVersion),r.push(e.length),r=r.concat(converters.stringToByteArray(e)),Jay.createTrf(Jay.types.messaging,Jay.subtypes.aliasBuy,recipient,a,1,r,n)},Jay.deleteAlias=function(e){var a=[];return a.push(Jay.transactionVersion),a.push(e.length),a=a.concat(converters.stringToByteArray(e)),Jay.createTrf(Jay.types.messaging,Jay.subtypes.aliasDelete,Jay.genesisRS,0,1,a,appendages)},Jay.issueAsset=function(e,a,t,n,r){var s=[];return s.push(Jay.transactionVersion),s.push(e.length),s=s.concat(converters.stringToByteArray(e)),s=s.concat(Jay.wordBytes(a.length)),s=s.concat(converters.stringToByteArray(a)),s=s.concat(Jay.numberToBytes(Math.round(t*Math.pow(10,n)))),s.push(n),Jay.createTrf(Jay.types.asset,Jay.subtypes.assetIssuance,Jay.genesisRS,0,1e3,s,r)},Jay.transferAsset=function(e,a,t,n){var r=[];return r.push(Jay.transactionVersion),r=r.concat(Jay.numberToBytes(a)),r=r.concat(Jay.numberToBytes(t)),Jay.createTrf(Jay.types.asset,Jay.subtypes.assetTransfer,e,0,1,r,n)},Jay.placeAskOrder=function(e,a,t,n,r){var s=[];return s.push(Jay.transactionVersion),s=s.concat(Jay.numberToBytes(e)),void 0==n||"number"!=typeof n?(s=s.concat(Jay.numberToBytes(a)),s=s.concat(Jay.numberToBytes(t)),r=n):(s=s.concat(Jay.numberToBytes(Math.round(a*Math.pow(10,n)))),s=s.concat(Jay.numberToBytes(Math.round(t*Math.pow(10,8-n))))),Jay.createTrf(Jay.types.asset,Jay.subtypes.askOrderPlacement,Jay.genesisRS,0,1,s,r)},Jay.placeBidOrder=function(e,a,t,n,r){var s=[];return s.push(Jay.transactionVersion),s=s.concat(Jay.numberToBytes(e)),void 0==n||"number"!=typeof n?(s=s.concat(Jay.numberToBytes(a)),s=s.concat(Jay.numberToBytes(t)),r=n):(s=s.concat(Jay.numberToBytes(Math.round(a*Math.pow(10,n)))),s=s.concat(Jay.numberToBytes(Math.round(t*Math.pow(10,8-n))))),Jay.createTrf(Jay.types.asset,Jay.subtypes.bidOrderPlacement,Jay.genesisRS,0,1,s,r)},Jay.cancelAskOrder=function(e,a){var t=[];return t.push(Jay.transactionVersion),t=t.concat(Jay.numberToBytes(e)),Jay.createTrf(Jay.types.asset,Jay.subtypes.askOrderCancellation,Jay.genesisRS,0,1,t,a)},Jay.cancelBidOrder=function(e,a){var t=[];return t.push(Jay.transactionVersion),t=t.concat(Jay.numberToBytes(e)),Jay.createTrf(Jay.types.asset,Jay.subtypes.bidOrderCancellation,Jay.genesisRS,0,1,t,a)},Jay.dgsListing=function(e,a,t,n,r,s){var y=[];return y.push(Jay.transactionVersion),y=y.concat(Jay.wordBytes(e.length)),y=y.concat(converters.stringToByteArray(e)),y=y.concat(Jay.wordBytes(a.length)),y=y.concat(converters.stringToByteArray(a)),y=y.concat(Jay.wordBytes(t.length)),y=y.concat(converters.stringToByteArray(t)),y=y.concat(converters.int32ToBytes(n)),y=y.concat(Jay.numberToBytes(Math.round(r*Jay.oneNxt))),Jay.createTrf(Jay.types.marketplace,Jay.subtypes.goodsListing,Jay.genesisRS,0,1,y,s)},Jay.dgsDelisting=function(e,a){return attachment.push(Jay.transactionVersion),attachment=attachment.concat(Jay.numberToBytes(e)),Jay.createTrf(Jay.types.marketplace,Jay.subtypes.goodsDelisting,Jay.genesisRS,0,1,attachment,a)},Jay.dgsPriceChange=function(e,a,t){var n=[];return n.push(Jay.transactionVersion),n=n.concat(Jay.numberToBytes(e)),n=n.concat(Jay.numberToBytes(Math.round(a*Jay.oneNxt))),Jay.createTrf(Jay.types.marketplace,Jay.subtypes.priceChange,Jay.genesisRS,0,1,n,t)},Jay.dgsQuantityChange=function(e,a,t){var n=[];return n.push(Jay.transactionVersion),n=n.concat(Jay.numberToBytes(e)),n=n.concat(converters.int32ToBytes(a)),Jay.createTrf(Jay.types.marketplace,Jay.subtypes.quantityChange,Jay.genesisRS,0,1,n,t)},Jay.dgsPurchase=function(e,a,t,n){var r=[];return r.push(Jay.transactionVersion),r=r.concat(Jay.numberToBytes(e)),r=r.concat(converters.int32ToBytes(a)),r=r.concat(Jay.numberToBytes(Math.round(t*Jay.oneNxt))),Jay.createTrf(Jay.types.marketplace,Jay.subtypes.purchase,Jay.genesisRS,0,1,r,n)},Jay.dgsDelivery=function(){},Jay.dgsFeedback=function(e,a,t){var n=[];return n.push(Jay.transactionVersion),n=n.concat(Jay.numberToBytes(e)),t=Jay.addAppendage(Jay.appendages.arbitraryMessage,a,t),Jay.createTrf(Jay.types.marketplace,Jay.subtypes.feedback,Jay.genesisRS,0,1,n,t)},Jay.dgsRefund=function(e,a,t){var n=[];return n.push(transactionVersion),n=n.concat(Jay.numberToBytes(e)),n=n.concat(Jay.numberToBytes(Math.round(a*Jay.oneNxt))),Jay.createTrf(Jay.types.marketplace,Jay.subtypes.refund,Jay.genesisRS,0,1,n,t)},Jay.leaseBalance=function(e,a,t){var n=[];return n.push(Jay.transactionVersion),n=n.concat(Jay.wordBytes(a)),Jay.createTrf(Jay.types.accountControl,Jay.subtypes.balanceLeasing,e,0,1,n,t)},Jay.currencyReserveIncrease=function(e,a,t){var n=[];return n.push(Jay.transactionVersion),n=n.concat(Jay.numberToBytes(e)),n=n.concat(Math.round(a*Jay.oneNxt)),Jay.createTrf(Jay.types.monetarySystem,Jay.subtypes.reserveIncrease,Jay.genesisRS,0,1,n,t)},Jay.transferCurrency=function(e,a,t,n){var r=[];return r.push(Jay.transactionVersion),r=r.concat(Jay.numberToBytes(a)),r=r.concat(Jay.numberToBytes(t)),Jay.createTrf(Jay.types.monetarySystem,Jay.subtypes.currencyTransfer,e,0,1,r,n)},Jay.currencyMint=function(e,a,t,n,r){var s=[];return s.push(Jay.transactionVersion),s=s.concat(Jay.numberToBytes(e)),s=s.concat(Jay.numberToBytes(a)),s=s.concat(Jay.numberToBytes(t)),s=s.concat(Jay.numberToBytes(n)),Jay.createTrf(Jay.types.monetarySystem,Jay.subtypes.currencyMinting,Jay.genesisRS,0,1,s,r)},Jay.wordBytes=function(e){return[Math.floor(e%256),Math.floor(e/256)]},Jay.addAppendage=function(e,a,t){var n;if(void 0!=t?n=converters.byteArrayToSignedInt32(t.flags):(t={},n=0),n+=e,e==Jay.appendages.message){var r=[];r.push(Jay.transactionVersion),r=r.concat(Jay.wordBytes(a.length)),r.push(0),r.push(128),r=r.concat(converters.stringToByteArray(a)),t.message=r}if(e==Jay.appendages.publicKeyAnnouncement){var r=[];r.push(Jay.transactionVersion),r=r.concat(converters.hexStringToByteArray(a)),t.publicKeyAnnouncement=r}return t.flags=converters.int32ToBytes(n),t},Jay.combineAppendages=function(e){var a=[];return void 0!=e.message&&(a=a.concat(e.message)),void 0!=e.encryptedMessage&&(a=a.concat(e.encryptedMessage)),void 0!=e.encryptedMessageToSelf&&(a=a.concat(e.encryptedMessageToSelf)),void 0!=e.publicKeyAnnouncement&&(a=a.concat(e.publicKeyAnnouncement)),a};var _hash={init:SHA256_init,update:SHA256_write,getBytes:SHA256_finalize},epochNum=1385294400;Jay.signBytes=function(e,a){var t=e,n=converters.stringToByteArray(a),r=simpleHash(n),s=curve25519.keygen(r).s,y=simpleHash(t);_hash.init(),_hash.update(y),_hash.update(s);var o=_hash.getBytes(),c=curve25519.keygen(o).p;_hash.init(),_hash.update(y),_hash.update(c);var u=_hash.getBytes(),i=curve25519.sign(u,o,s);return i.concat(u)},Jay.verifyBytes=function(e,a,t){var n=e,r=a,s=t,y=n.slice(0,32),o=n.slice(32),c=curve25519.verify(y,o,s),u=simpleHash(r);_hash.init(),_hash.update(u),_hash.update(c);var i=_hash.getBytes();return areByteArraysEqual(o,i)},Jay.createToken=function(e,a){var t=converters.stringToHexString(e),n=converters.hexStringToByteArray(t),r=[];r=n.concat(getPublicKey(a));var s=Math.round(+new Date/1e3),y=s-epochNum,o=toByteArray(y);r=r.concat(o);var c=[];c=getPublicKey(a).concat(o);var u=Jay.signBytes(r,a);c=c.concat(u);for(var i="",J=0;100>J;J+=5){var p=[];p[0]=255&c[J],p[1]=255&c[J+1],p[2]=255&c[J+2],p[3]=255&c[J+3],p[4]=255&c[J+4];var g=byteArrayToBigInteger(p);32>g?i+="0000000":1024>g?i+="000000":32768>g?i+="00000":1048576>g?i+="0000":33554432>g?i+="000":1073741824>g?i+="00":34359738368>g&&(i+="0"),i+=g.toString(32)}return i},Jay.parseToken=function(e,a){for(var t=converters.stringToByteArray(a),n=[],r=0,s=0;r