UNPKG

jcc-call-utils

Version:

Toolkit of crossing chain from Call chain to SWTC chain

7 lines 844 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("call-lib")):"function"==typeof define&&define.amd?define(["call-lib"],t):"object"==typeof exports?exports.jcc_call_utils=t(require("call-lib")):e.jcc_call_utils=t(e["call-lib"])}(window,function(d){return f={},g.m=e=[function(e,t,r){"use strict";var n=t;n.version=r(44).version,n.utils=r(45),n.rand=r(11),n.hmacDRBG=r(46),n.curve=r(8),n.curves=r(51),n.ec=r(53),n.eddsa=r(56)},function(e,t,r){(function(e){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){function r(){}e.super_=t,r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(null!==e&&"object"==typeof e&&Array.isArray(e.words))return e;this.sign=!1,this.words=null,this.length=0,"le"!==t&&"be"!==t||(r=t,t=10),(this.red=null)!==e&&this._init(e||0,t||10,r||"be")}function o(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o<i;o++){var s=e.charCodeAt(o)-48;n<<=4,n|=49<=s&&s<=54?s-49+10:17<=s&&s<=22?s-17+10:15&s}return n}function s(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s<o;s++){var a=e.charCodeAt(s)-48;i*=n,i+=49<=a?a-49+10:17<=a?a-17+10:a}return i}"object"==typeof e?e.exports=i:t.BN=i,(i.BN=i).wordSize=26,i.max=function(e,t){return 0<e.cmp(t)?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&2<=t&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.sign=!0),this.strip(),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initNumber=function(e,t,n){e<0&&(this.sign=!0,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o=0;if("be"===n){i=e.length-1;for(var s=0;0<=i;i-=3){var a=e[i]|e[i-1]<<8|e[i-2]<<16;this.words[s]|=a<<o&67108863,this.words[s+1]=a>>>26-o&67108863,26<=(o+=24)&&(o-=26,s++)}}else if("le"===n)for(i=0,s=0;i<e.length;i+=3)a=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[s]|=a<<o&67108863,this.words[s+1]=a>>>26-o&67108863,26<=(o+=24)&&(o-=26,s++);return this.strip()},i.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;for(var n=0,i=(r=e.length-6,0);t<=r;r-=6){var s=o(e,r,r+6);this.words[i]|=s<<n&67108863,this.words[i+1]|=s>>>26-n&4194303,26<=(n+=24)&&(n-=26,i++)}r+6!==t&&(s=o(e,t,r+6),this.words[i]|=s<<n&67108863,this.words[i+1]|=s>>>26-n&4194303),this.strip()},i.prototype._parseBase=function(e,t,r){this.words=[0];for(var n=0,i=this.length=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,c=Math.min(o,o-a)+r,f=0,u=r;u<c;u+=n)f=s(e,u,u+n,t),this.imuln(i),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(0!=a){var d=1;for(f=s(e,u,e.length,t),u=0;u<a;u++)d*=t;this.imuln(d),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}},i.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.sign=this.sign,e.red=this.red},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype.strip=function(){for(;1<this.length&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var a=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function u(e){for(var t=new Array(e.bitLength()),r=0;r<t.length;r++){var n=r/26|0,i=r%26;t[r]=(e.words[n]&1<<i)>>>i}return t}i.prototype.toString=function(e,t){if(t=0|t||1,16===(e=e||10)||"hex"===e){for(var n="",i=0,o=0,s=0;s<this.length;s++){var u=this.words[s],d=(16777215&(u<<i|o)).toString(16);n=0!=(o=u>>>24-i&16777215)||s!==this.length-1?a[6-d.length]+d+n:d+n,26<=(i+=2)&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return this.sign&&(n="-"+n),n}if(e===(0|e)&&2<=e&&e<=36){var h=c[e],l=f[e],p=(n="",this.clone());for(p.sign=!1;0!==p.cmpn(0);){var b=p.modn(l).toString(e);n=0!==(p=p.idivn(l)).cmpn(0)?a[h-b.length]+b+n:b+n}for(0===this.cmpn(0)&&(n="0"+n);n.length%t!=0;)n="0"+n;return this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(e,t){this.strip();var n="le"===e,i=new Array(this.byteLength());i[0]=0;var o=this.clone();if(n)for(s=0;0!==o.cmpn(0);s++)a=o.andln(255),o.iushrn(8),i[s]=a;else for(var s=0;0!==o.cmpn(0);s++){var a=o.andln(255);o.iushrn(8),i[i.length-s-1]=a}if(t)for(r(i.length<=t,"byte array longer than desired length");i.length<t;)n?i.push(0):i.unshift(0);return i},i.prototype._countBits=Math.clz32?function(e){return 32-Math.clz32(e)}:function(e){var t=e,r=0;return 4096<=t&&(r+=13,t>>>=13),64<=t&&(r+=7,t>>>=7),8<=t&&(r+=4,t>>>=4),2<=t&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.neg=function(){if(0===this.cmpn(0))return this.clone();var e=this.clone();return e.sign=!this.sign,e},i.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},i.prototype.ior=function(e){return r(!this.sign&&!e.sign),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this.strip()},i.prototype.iand=function(e){return r(!this.sign&&!e.sign),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,r;r=this.length>e.length?(t=this,e):(t=e,this);for(var n=0;n<r.length;n++)this.words[n]=t.words[n]^r.words[n];if(this!==t)for(;n<t.length;n++)this.words[n]=t.words[n];return this.length=t.length,this.strip()},i.prototype.ixor=function(e){return r(!this.sign&&!e.sign),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.setn=function(e,t){r("number"==typeof e&&0<=e);for(var n=e/26|0,i=e%26;this.length<=n;)this.words[this.length++]=0;return this.words[n]=t?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(e){if(this.sign&&!e.sign){this.sign=!1;var t=this.isub(e);return this.sign=!this.sign,this._normSign()}if(!this.sign&&e.sign)return e.sign=!1,t=this.isub(e),e.sign=!0,t._normSign();var r,n;n=this.length>e.length?(r=this,e):(r=e,this);for(var i=0,o=0;o<n.length;o++)t=r.words[o]+n.words[o]+i,this.words[o]=67108863&t,i=t>>>26;for(;0!==i&&o<r.length;o++)t=r.words[o]+i,this.words[o]=67108863&t,i=t>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(e){if(e.sign&&!this.sign){e.sign=!1;var t=this.sub(e);return e.sign=!0,t}return e.sign||!this.sign?this.length>e.length?this.clone().iadd(e):e.clone().iadd(this):(this.sign=!1,t=e.sub(this),this.sign=!0,t)},i.prototype.isub=function(e){if(e.sign){e.sign=!1;var t=this.iadd(e);return e.sign=!0,t._normSign()}if(this.sign)return this.sign=!1,this.iadd(e),this.sign=!0,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.sign=!1,this.length=1,this.words[0]=0,this;n=0<i?(r=this,e):(r=e,this);for(var o=0,s=0;s<n.length;s++)o=(t=r.words[s]-n.words[s]+o)>>26,this.words[s]=67108863&t;for(;0!==o&&s<r.length;s++)o=(t=r.words[s]+o)>>26,this.words[s]=67108863&t;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.sign=!0),this.strip()},i.prototype.sub=function(e){return this.clone().isub(e)},i.prototype._smallMulTo=function(e,t){t.sign=e.sign!==this.sign,t.length=this.length+e.length;for(var r=0,n=0;n<t.length-1;n++){for(var i=r>>>26,o=67108863&r,s=Math.min(n,e.length-1),a=Math.max(0,n-this.length+1);a<=s;a++){var c=n-a,f=(0|this.words[c])*(0|e.words[a]),u=67108863&f;o=67108863&(u=u+o|0),i=(i=i+(f/67108864|0)|0)+(u>>>26)|0}t.words[n]=o,r=i}return 0!==r?t.words[n]=r:t.length--,t.strip()},i.prototype._bigMulTo=function(e,t){t.sign=e.sign!==this.sign,t.length=this.length+e.length;for(var r=0,n=0,i=0;i<t.length-1;i++){var o=n;n=0;for(var s=67108863&r,a=Math.min(i,e.length-1),c=Math.max(0,i-this.length+1);c<=a;c++){var f=i-c,u=(0|this.words[f])*(0|e.words[c]),d=67108863&u;s=67108863&(d=d+s|0),n+=(o=(o=o+(u/67108864|0)|0)+(d>>>26)|0)>>>26,o&=67108863}t.words[i]=s,r=o,o=n}return 0!==r?t.words[i]=r:t.length--,t.strip()},i.prototype.mulTo=function(e,t){return this.length+e.length<63?this._smallMulTo(e,t):this._bigMulTo(e,t)},i.prototype.mul=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},i.prototype.imul=function(e){if(0===this.cmpn(0)||0===e.cmpn(0))return this.words[0]=0,this.length=1,this;var t=this.length,r=e.length;this.sign=e.sign!==this.sign,this.length=this.length+e.length,this.words[this.length-1]=0;for(var n=this.length-2;0<=n;n--){for(var i=0,o=0,s=Math.min(n,r-1),a=Math.max(0,n-t+1);a<=s;a++){var c=n-a,f=this.words[c]*e.words[a],u=67108863&f;i+=f/67108864|0,o=67108863&(u+=o),i+=u>>>26}this.words[n]=o,this.words[n+1]+=i,i=0}for(i=0,c=1;c<this.length;c++){var d=this.words[c]+i;this.words[c]=67108863&d,i=d>>>26}return this.strip()},i.prototype.imuln=function(e){r("number"==typeof e);for(var t=0,n=0;n<this.length;n++){var i=this.words[n]*e,o=(67108863&i)+(67108863&t);t>>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.pow=function(e){var t=u(e);if(0===t.length)return new i(1);for(var r=this,n=0;n<t.length&&0===t[n];n++,r=r.sqr());if(++n<t.length)for(var o=r.sqr();n<t.length;n++,o=o.sqr())0!==t[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(e){r("number"==typeof e&&0<=e);var t=e%26,n=(e-t)/26,i=67108863>>>26-t<<26-t;if(0!=t){for(var o=0,s=0;s<this.length;s++){var a=this.words[s]&i,c=this.words[s]-a<<t;this.words[s]=c|o,o=a>>>26-t}o&&(this.words[s]=o,this.length++)}if(0!=n){for(s=this.length-1;0<=s;s--)this.words[s+n]=this.words[s];for(s=0;s<n;s++)this.words[s]=0;this.length+=n}return this.strip()},i.prototype.ishln=function(e){return r(!this.sign),this.iushln(e)},i.prototype.iushrn=function(e,t,n){var i;r("number"==typeof e&&0<=e),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<<o,c=n;if(i-=s,i=Math.max(0,i),c){for(var f=0;f<s;f++)c.words[f]=this.words[f];c.length=s}if(0===s);else if(this.length>s)for(this.length-=s,f=0;f<this.length;f++)this.words[f]=this.words[f+s];else this.words[0]=0,this.length=1;var u=0;for(f=this.length-1;0<=f&&(0!==u||i<=f);f--){var d=this.words[f];this.words[f]=u<<26-o|d>>>o,u=d&a}return c&&0!==u&&(c.words[c.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.ishrn=function(e,t,n){return r(!this.sign),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&0<=e);var t=e%26,n=(e-t)/26,i=1<<t;return!(this.length<=n||!(this.words[n]&i))},i.prototype.imaskn=function(e){r("number"==typeof e&&0<=e);var t=e%26,n=(e-t)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!=t&&n++,this.length=Math.min(n,this.length),0!=t){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return r("number"==typeof e),e<0?this.isubn(-e):this.sign?(1===this.length&&this.words[0]<e?(this.words[0]=e-this.words[0],this.sign=!1):(this.sign=!1,this.isubn(e),this.sign=!0),this):this._iaddn(e)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&67108864<=this.words[t];t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),e<0)return this.iaddn(-e);if(this.sign)return this.sign=!1,this.iaddn(e),this.sign=!0,this;this.words[0]-=e;for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.sign=!1,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,n){var i=e.length+n;if(this.words.length<i){for(var o=new Array(i),s=0;s<this.length;s++)o[s]=this.words[s];this.words=o}else s=this.length;for(this.length=Math.max(this.length,i);s<this.length;s++)this.words[s]=0;var a=0;for(s=0;s<e.length;s++){var c=this.words[s+n]+a,f=e.words[s]*t;a=((c-=67108863&f)>>26)-(f/67108864|0),this.words[s+n]=67108863&c}for(;s<this.length-n;s++)a=(c=this.words[s+n]+a)>>26,this.words[s+n]=67108863&c;if(0===a)return this.strip();for(r(-1===a),s=a=0;s<this.length;s++)a=(c=-this.words[s]+a)>>26,this.words[s]=67108863&c;return this.sign=!0,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,s=o.words[o.length-1];0!=(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=o.words[o.length-1]);var a,c=n.length-o.length;if("mod"!==t){(a=new i(null)).length=1+c,a.words=new Array(a.length);for(var f=0;f<a.length;f++)a.words[f]=0}var u=n.clone()._ishlnsubmul(o,1,c);u.sign||(n=u,a&&(a.words[c]=1));for(var d=c-1;0<=d;d--){var h=67108864*n.words[o.length+d]+n.words[o.length+d-1];for(h=Math.min(h/s|0,67108863),n._ishlnsubmul(o,h,d);n.sign;)h--,n.sign=!1,n._ishlnsubmul(o,1,d),0!==n.cmpn(0)&&(n.sign=!n.sign);a&&(a.words[d]=h)}return a&&a.strip(),n.strip(),"div"!==t&&0!=r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(e,t,n){if(r(0!==e.cmpn(0)),this.sign&&!e.sign){var o=this.neg().divmod(e,t);return"mod"!==t&&(s=o.div.neg()),"div"!==t&&(a=o.mod.neg(),n&&a.neg&&(a=a.add(e))),{div:s,mod:a}}var s,a;return!this.sign&&e.sign?(o=this.divmod(e.neg(),t),"mod"!==t&&(s=o.div.neg()),{div:s,mod:o.mod}):this.sign&&e.sign?(o=this.neg().divmod(e.neg(),t),"div"!==t&&(a=o.mod.neg(),n&&a.neg&&(a=a.isub(e))),{div:o.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t)},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(0===t.mod.cmpn(0))return t.div;var r=t.div.sign?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:t.div.sign?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;0<=i;i--)n=(t*n+this.words[i])%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;0<=n;n--){var i=this.words[n]+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(!e.sign),r(0!==e.cmpn(0));var t=this,n=e.clone();t=t.sign?t.umod(e):t.clone();for(var o=new i(1),s=new i(0),a=new i(0),c=new i(1),f=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++f;for(var u=n.clone(),d=t.clone();0!==t.cmpn(0);){for(;t.isEven();)t.iushrn(1),o.isEven()&&s.isEven()?(o.iushrn(1),s.iushrn(1)):(o.iadd(u).iushrn(1),s.isub(d).iushrn(1));for(;n.isEven();)n.iushrn(1),a.isEven()&&c.isEven()?(a.iushrn(1),c.iushrn(1)):(a.iadd(u).iushrn(1),c.isub(d).iushrn(1));0<=t.cmp(n)?(t.isub(n),o.isub(a),s.isub(c)):(n.isub(t),a.isub(o),c.isub(s))}return{a:a,b:c,gcd:n.iushln(f)}},i.prototype._invmp=function(e){r(!e.sign),r(0!==e.cmpn(0));var t=this,n=e.clone();t=t.sign?t.umod(e):t.clone();for(var o,s=new i(1),a=new i(0),c=n.clone();0<t.cmpn(1)&&0<n.cmpn(1);){for(;t.isEven();)t.iushrn(1),s.isEven()?s.iushrn(1):s.iadd(c).iushrn(1);for(;n.isEven();)n.iushrn(1),a.isEven()?a.iushrn(1):a.iadd(c).iushrn(1);0<=t.cmp(n)?(t.isub(n),s.isub(a)):(n.isub(t),a.isub(s))}return(o=0===t.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(0===this.cmpn(0))return e.clone();if(0===e.cmpn(0))return this.clone();var t=this.clone(),r=e.clone();t.sign=!1,r.sign=!1;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<<t;if(this.length<=n){for(var o=this.length;o<1+n;o++)this.words[o]=0;return this.words[n]|=i,this.length=1+n,this}var s=i;for(o=n;0!==s&&o<this.length;o++){var a=this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},i.prototype.cmpn=function(e){var t,r=e<0;if(r&&(e=-e),this.sign&&!r)return-1;if(!this.sign&&r)return 1;if(e&=67108863,this.strip(),1<this.length)t=1;else{var n=this.words[0];t=n===e?0:n<e?-1:1}return this.sign&&(t=-t),t},i.prototype.cmp=function(e){if(this.sign&&!e.sign)return-1;if(!this.sign&&e.sign)return 1;var t=this.ucmp(e);return this.sign?-t:t},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,r=this.length-1;0<=r;r--){var n=this.words[r],i=e.words[r];if(n!==i){n<i?t=-1:i<n&&(t=1);break}}return t},i.red=function(e){return new g(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.ushl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var d={k256:null,p224:null,p192:null,p25519:null};function h(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function l(){h.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function p(){h.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){h.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function m(){h.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function g(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else this.m=e,this.prime=null}function y(e){g.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}h.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},h.prototype.ireduce=function(e){for(var t,r=e;this.split(r,this.tmp),(t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength())>this.n;);var n=t<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):0<n?r.isub(this.p):r.strip(),r},h.prototype.split=function(e,t){e.iushrn(this.n,0,t)},h.prototype.imulK=function(e){return e.imul(this.k)},n(l,h),l.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n<r;n++)t.words[n]=e.words[n];if(t.length=r,e.length<=9)return e.words[0]=0,void(e.length=1);var i=e.words[9];for(t.words[t.length++]=4194303&i,n=10;n<e.length;n++){var o=e.words[n];e.words[n-10]=(4194303&o)<<4|i>>>22,i=o}e.words[n-10]=i>>>22,e.length-=9},l.prototype.imulK=function(e){var t;e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var r=0,n=0;n<e.length;n++){var i=e.words[n];t=64*i,t+=(r+=977*i)/67108864|0,r&=67108863,e.words[n]=r,r=t}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},n(p,h),n(b,h),n(m,h),m.prototype.imulK=function(e){for(var t=0,r=0;r<e.length;r++){var n=19*e.words[r]+t,i=67108863&n;n>>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(d[e])return d[e];var t;if("k256"===e)t=new l;else if("p224"===e)t=new p;else if("p192"===e)t=new b;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new m}return d[e]=t},g.prototype._verify1=function(e){r(!e.sign,"red works only with positives"),r(e.red,"red works only with red numbers")},g.prototype._verify2=function(e,t){r(!e.sign&&!t.sign,"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},g.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},g.prototype.neg=function(e){var t=e.clone();return t.sign=!t.sign,t.iadd(this.m)._forceRed(this)},g.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return 0<=r.cmp(this.m)&&r.isub(this.m),r._forceRed(this)},g.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return 0<=r.cmp(this.m)&&r.isub(this.m),r},g.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},g.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},g.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},g.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},g.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},g.prototype.isqr=function(e){return this.imul(e,e)},g.prototype.sqr=function(e){return this.mul(e,e)},g.prototype.sqrt=function(e){if(0===e.cmpn(0))return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.iushrn(1);r(0!==o.cmpn(0));var a=new i(1).toRed(this),c=a.redNeg(),f=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);0!==this.pow(u,f).cmp(c);)u.redIAdd(c);for(var d=this.pow(u,o),h=this.pow(e,o.addn(1).iushrn(1)),l=this.pow(e,o),p=s;0!==l.cmp(a);){for(var b=l,m=0;0!==b.cmp(a);m++)b=b.redSqr();r(m<p);var g=this.pow(d,new i(1).iushln(p-m-1));h=h.redMul(g),d=g.redSqr(),l=l.redMul(d),p=m}return h},g.prototype.invm=function(e){var t=e._invmp(this.m);return t.sign?(t.sign=!1,this.imod(t).redNeg()):this.imod(t)},g.prototype.pow=function(e,t){var r=u(t);if(0===r.length)return new i(1);for(var n=e,o=0;o<r.length&&0===r[o];o++,n=this.sqr(n));if(++o<r.length)for(var s=this.sqr(n);o<r.length;o++,s=this.sqr(s))0!==r[o]&&(n=this.mul(n,s));return n},g.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},g.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new y(e)},n(y,g),y.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},y.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},y.prototype.imul=function(e,t){if(0===e.cmpn(0)||0===t.cmpn(0))return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return 0<=i.cmp(this.m)?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},y.prototype.mul=function(e,t){if(0===e.cmpn(0)||0===t.cmpn(0))return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return 0<=o.cmp(this.m)?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},y.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(20)(e))},function(e,t,r){var n=t;n.utils=r(3),n.common=r(6),n.sha=r(29),n.ripemd=r(33),n.hmac=r(34),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},function(e,t,r){"use strict";var n=r(4),i=r(5);function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function a(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r,n,i=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),s=0;s<e.length;s+=2)i.push(parseInt(e[s]+e[s+1],16))}else for(var o=0,s=0;s<e.length;s++){var a=e.charCodeAt(s);a<128?i[o++]=a:a<2048?(i[o++]=a>>6|192,i[o++]=63&a|128):(n=s,55296!=(64512&(r=e).charCodeAt(n))||n<0||n+1>=r.length||56320!=(64512&r.charCodeAt(n+1))?i[o++]=a>>12|224:(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++s)),i[o++]=a>>18|240,i[o++]=a>>12&63|128),i[o++]=a>>6&63|128,i[o++]=63&a|128)}else for(s=0;s<e.length;s++)i[s]=0|e[s];return i},t.toHex=function(e){for(var t="",r=0;r<e.length;r++)t+=s(e[r].toString(16));return t},t.htonl=o,t.toHex32=function(e,t){for(var r="",n=0;n<e.length;n++){var i=e[n];"little"===t&&(i=o(i)),r+=a(i.toString(16))}return r},t.zero2=s,t.zero8=a,t.join32=function(e,t,r,i){var o=r-t;n(o%4==0);for(var s=new Array(o/4),a=0,c=t;a<s.length;a++,c+=4){var f;f="big"===i?e[c]<<24|e[c+1]<<16|e[c+2]<<8|e[c+3]:e[c+3]<<24|e[c+2]<<16|e[c+1]<<8|e[c],s[a]=f>>>0}return s},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n<e.length;n++,i+=4){var o=e[n];"big"===t?(r[i]=o>>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,s=(o<n?1:0)+r+i;e[t]=s>>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0<t?1:0)+e+r>>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,s,a){var c=0,f=t;return c+=(f=f+n>>>0)<t?1:0,c+=(f=f+o>>>0)<o?1:0,e+r+i+s+(c+=(f=f+a>>>0)<a?1:0)>>>0},t.sum64_4_lo=function(e,t,r,n,i,o,s,a){return t+n+o+a>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,s,a,c,f){var u=0,d=t;return u+=(d=d+n>>>0)<t?1:0,u+=(d=d+o>>>0)<o?1:0,u+=(d=d+a>>>0)<a?1:0,e+r+i+s+c+(u+=(d=d+f>>>0)<f?1:0)>>>0},t.sum64_5_lo=function(e,t,r,n,i,o,s,a,c,f){return t+n+o+a+f>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},function(e,t){(e.exports=function(e,t){if(!e)throw new Error(t||"Assertion failed")}).equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){function r(){}e.super_=t,r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},function(e,t,r){"use strict";var n=r(3),i=r(4);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}(t.BlockHash=o).prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i<e.length;i+=this._delta32)this._update(e,i,i+this._delta32)}return this},o.prototype.digest=function(e){return this.update(this._pad()),i(null===this.pending),this._digest(e)},o.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,r=t-(e+this.padLength)%t,n=new Array(r+this.padLength);n[0]=128;for(var i=1;i<r;i++)n[i]=0;if(e<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)n[i++]=0;n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=e>>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o<this.padLength;o++)n[i++]=0;return n}},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var n=t;n.base=r(47),n.short=r(48),n.mont=r(49),n.edwards=r(50)},function(e,t,r){"use strict";var n=r(1),i=r(10);t.bytesToHex=function(e){return e.map(function(e){var t=e.toString(16).toUpperCase();return 1<t.length?t:"0"+t}).join("")},t.hexToBytes=function(e){return i(e.length%2==0),new n(e,16).toArray(null,e.length/2)}},function(e,t,r){"use strict";(function(t){var n=r(39); /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> * @license MIT */function i(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}function o(e){return t.Buffer&&"function"==typeof t.Buffer.isBuffer?t.Buffer.isBuffer(e):!(null==e||!e._isBuffer)}var s=r(40),a=Object.prototype.hasOwnProperty,c=Array.prototype.slice,f="foo"===function(){}.name;function u(e){return Object.prototype.toString.call(e)}function d(e){return!o(e)&&"function"==typeof t.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):!!e&&(e instanceof DataView||!!(e.buffer&&e.buffer instanceof ArrayBuffer)))}var h=e.exports=y,l=/\s*function\s+([^\(\s]*)\s*/;function p(e){if(s.isFunction(e)){if(f)return e.name;var t=e.toString().match(l);return t&&t[1]}}function b(e,t){return"string"==typeof e?e.length<t?e:e.slice(0,t):e}function m(e){if(f||!s.isFunction(e))return s.inspect(e);var t=p(e);return"[Function"+(t?": "+t:"")+"]"}function g(e,t,r,n,i){throw new h.AssertionError({message:r,actual:e,expected:t,operator:n,stackStartFunction:i})}function y(e,t){e||g(e,!0,t,"==",h.ok)}function v(e,t,r,n){if(e===t)return!0;if(o(e)&&o(t))return 0===i(e,t);if(s.isDate(e)&&s.isDate(t))return e.getTime()===t.getTime();if(s.isRegExp(e)&&s.isRegExp(t))return e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase;if(null!==e&&"object"==typeof e||null!==t&&"object"==typeof t){if(d(e)&&d(t)&&u(e)===u(t)&&!(e instanceof Float32Array||e instanceof Float64Array))return 0===i(new Uint8Array(e.buffer),new Uint8Array(t.buffer));if(o(e)!==o(t))return!1;var a=(n=n||{actual:[],expected:[]}).actual.indexOf(e);return-1!==a&&a===n.expected.indexOf(t)||(n.actual.push(e),n.expected.push(t),function(e,t,r,n){if(null==e||null==t)return!1;if(s.isPrimitive(e)||s.isPrimitive(t))return e===t;if(r&&Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;var i=w(e),o=w(t);if(i&&!o||!i&&o)return!1;if(i)return v(e=c.call(e),t=c.call(t),r);var a,f,u=A(e),d=A(t);if(u.length!==d.length)return!1;for(u.sort(),d.sort(),f=u.length-1;0<=f;f--)if(u[f]!==d[f])return!1;for(f=u.length-1;0<=f;f--)if(!v(e[a=u[f]],t[a],r,n))return!1;return!0}(e,t,r,n))}return r?e===t:e==t}function w(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function _(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function S(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&g(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!e&&i&&!r;if((!e&&s.isError(i)&&o&&_(i,r)||a)&&g(i,r,"Got unwanted exception"+n),e&&i&&r&&!_(i,r)||!e&&i)throw i}h.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return b(m(e.actual),128)+" "+e.operator+" "+b(m(e.expected),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=p(t),o=n.indexOf("\n"+i);if(0<=o){var s=n.indexOf("\n",o+1);n=n.substring(s+1)}this.stack=n}}},s.inherits(h.AssertionError,Error),h.fail=g,h.ok=y,h.equal=function(e,t,r){e!=t&&g(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&g(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||g(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||g(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&g(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&g(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&g(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&g(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){S(!0,e,t,r)},h.doesNotThrow=function(e,t,r){S(!1,e,t,r)},h.ifError=function(e){if(e)throw e},h.strict=n(function e(t,r){t||g(t,!0,r,"==",e)},h,{equal:h.strictEqual,deepEqual:h.deepStrictEqual,notEqual:h.notStrictEqual,notDeepEqual:h.notDeepStrictEqual}),h.strict.strict=h.strict;var A=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this,r(7))},function(e,t,r){var n;function i(e){this.rand=e}if(e.exports=function(e){return(n=n||new i(null)).generate(e)},(e.exports.Rand=i).prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r<t.length;r++)t[r]=this.rand.getByte();return t},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?i.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?i.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:"object"==typeof window&&(i.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var o=r(43);if("function"!=typeof o.randomBytes)throw new Error("Not supported");i.prototype._rand=function(e){return o.randomBytes(e)}}catch(e){}},function(e,t,r){!function(e){"use strict";var t="undefined"!=typeof Uint8Array?Uint8Array:Array,r="+".charCodeAt(0),n="/".charCodeAt(0),i="0".charCodeAt(0),o="a".charCodeAt(0),s="A".charCodeAt(0),a="-".charCodeAt(0),c="_".charCodeAt(0);function f(e){var t=e.charCodeAt(0);return t===r||t===a?62:t===n||t===c?63:t<i?-1:t<i+10?t-i+26+26:t<s+26?t-s:t<o+26?t-o+26:void 0}e.toByteArray=function(e){var r,n,i,o,s;if(0<e.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var a=e.length;o="="===e.charAt(a-2)?2:"="===e.charAt(a-1)?1:0,s=new t(3*e.length/4-o),n=0<o?e.length-4:e.length;var c=0;function u(e){s[c++]=e}for(r=0;r<n;r+=4,3)u((16711680&(i=f(e.charAt(r))<<18|f(e.charAt(r+1))<<12|f(e.charAt(r+2))<<6|f(e.charAt(r+3))))>>16),u((65280&i)>>8),u(255&i);return 2==o?u(255&(i=f(e.charAt(r))<<2|f(e.charAt(r+1))>>4)):1==o&&(u((i=f(e.charAt(r))<<10|f(e.charAt(r+1))<<4|f(e.charAt(r+2))>>2)>>8&255),u(255&i)),s},e.fromByteArray=function(e){var t,r,n,i,o=e.length%3,s="";function a(e){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)}for(t=0,n=e.length-o;t<n;t+=3)s+=a((i=r=(e[t]<<16)+(e[t+1]<<8)+e[t+2])>>18&63)+a(i>>12&63)+a(i>>6&63)+a(63&i);switch(o){case 1:s+=a((r=e[e.length-1])>>2),s+=a(r<<4&63),s+="==";break;case 2:s+=a((r=(e[e.length-2]<<8)+e[e.length-1])>>10),s+=a(r>>4&63),s+=a(r<<2&63),s+="="}return s}}(t)},function(e,t,r){"use strict";(function(e){var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;0<=a;a--)(i=e[a])&&(s=(o<3?i(s):3<o?i(t,r,s):i(t,r))||s);return 3<o&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}},o=this&&this.__awaiter||function(e,t,r,n){return new(r=r||Promise)(function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new r(function(t){t(e.value)}).then(s,a)}c((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=0<(i=s.trys).length&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(14),c=r(28),f=r(65),u=(e.Window?r(86):r(88)).CallAPI,d=(h.createWallet=function(){return c.createWallet()},h.isValidAddress=function(e){return c.isValidAddress(e)},h.isValidSecret=function(e){return c.isValidSecret(e)},h.getAddress=function(e){return c.getAddress(e)},Object.defineProperty(h.prototype,"remote",{get:function(){return this._remote},enumerable:!0,configurable:!0}),h.prototype.connect=function(){return o(this,void 0,void 0,function(){var e=this;return s(this,function(t){return[2,new Promise(function(t,r){e._remote.connect().then(function(){return t()}).catch(function(e){return r(e)})})]})})},h.prototype.isConnected=function(){return this._remote.isConnected()},h.prototype.disconnect=function(){this._remote&&this._remote.disconnect()},h.prototype.getCallBalance=function(e){return o(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._remote.getBalances(e)];case 1:return[2,t.sent().find(function(e){return"CALL"===e.currency.toUpperCase()}).value];case 2:throw t.sent();case 3:return[2]}})})},h.prototype.sign=function(e,t){try{return this._remote.sign(e,t)}catch(e){throw e}},h.prototype.preparePayment=function(e,t){var r=this;return new Promise(function(n,i){r._remote.preparePayment(e,t).then(function(e){return n(e)}).catch(function(e){return i(e)})})},h.prototype.submit=function(e){var t=this;return new Promise(function(r,n){t._remote.submit(e,!0).then(function(e){return r(e)}).catch(function(e){return n(e)})})},h.prototype.formatPayment=function(e,t,r,n){return{destination:{address:t,amount:{currency:"CALL",value:r}},memos:[{data:n,format:"plain/text",type:"payment"}],source:{address:e,maxAmount:{currency:"CALL",value:r}}}},h.prototype.transfer=function(e,t,r,n){return o(this,void 0,void 0,function(){var i,o,c,f,u;return s(this,function(s){switch(s.label){case 0:i=h.getAddress(e),o=this.formatPayment(i,t,new a.default(r).toString(10),JSON.stringify(n)),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.preparePayment(i,o)];case 2:return c=s.sent(),[4,this.sign(c.tx_json,e)];case 3:return f=s.sent(),[4,this.submit(f)];case 4:if("tesSUCCESS"===(u=s.sent()).resultCode)return[2,f.id];throw new Error(u.resultMessage);case 5:throw s.sent();case 6:return[2]}})})},n([f.validate,i(0,f.isValidCallSecret),i(1,f.isValidCallAddress),i(2,f.isValidAmount),i(3,f.isValidMemo)],h.prototype,"transfer",null),h);function h(e){this._remote=null,this._remote=new u({server:e})}t.default=d}).call(this,r(7))},function(e,t,r){var n;!function(){"use strict";var i,o=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,a=Math.floor,c="[BigNumber Error] ",f=c+"Number primitive has more than 15 significant digits: ",u=1e14,d=14,h=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,b=1e9;function m(e){var t=0|e;return 0<e||e===t?t:t-1}function g(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(t=e[n++]+"",r=d-t.length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function y(e,t){var r,n,i=e.c,o=t.c,s=e.s,a=t.s,c=e.e,f=t.e;if(!s||!a)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=c==f,!i||!o)return n?0:!i^r?1:-1;if(!n)return f<c^r?1:-1;for(a=(c=i.length)<(f=o.length)?c:f,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^r?1:-1;return c==f?0:f<c^r?1:-1}function v(e,t,r,n){if(e<t||r<e||e!==a(e))throw Error(c+(n||"Argument")+("number"==typeof e?e<t||r<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function w(e){var t=e.c.length-1;return m(e.e/d)==t&&e.c[t]%2!=0}function _(e,t){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function S(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}(i=function e(t){var r,n,i,A,x,E,T,M,I,P,C,O=$.prototype={constructor:$,toString:null,valueOf:null},k=new $(1),L=20,R=4,N=-7,j=21,F=-1e7,B=1e7,q=!1,z=1,U=0,D={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},V="0123456789abcdefghijklmnopqrstuvwxyz";function $(e,t){var r,s,c,u,l,p,b,m,g=this;if(!(g instanceof $))return new $(e,t);if(null==t){if(e&&!0===e._isBigNumber)return g.s=e.s,void(!e.c||e.e>B?g.c=g.e=null:e.e<F?g.c=[g.e=0]:(g.e=e.e,g.c=e.c.slice()));if((p="number"==typeof e)&&0*e==0){if(g.s=1/e<0?(e=-e,-1):1,e===~~e){for(u=0,l=e;10<=l;l/=10,u++);return void(B<u?g.c=g.e=null:(g.e=u,g.c=[e]))}m=String(e)}else{if(!o.test(m=String(e)))return i(g,m,p);g.s=45==m.charCodeAt(0)?(m=m.slice(1),-1):1}-1<(u=m.indexOf("."))&&(m=m.replace(".","")),0<(l=m.search(/e/i))?(u<0&&(u=l),u+=+m.slice(l+1),m=m.substring(0,l)):u<0&&(u=m.length)}else{if(v(t,2,V.length,"Base"),10==t)return X(g=new $(e),L+g.e+1,R);if(m=String(e),p="number"==typeof e){if(0*e!=0)return i(g,m,p,t);if(g.s=1/e<0?(m=m.slice(1),-1):1,$.DEBUG&&15<m.replace(/^0\.0*|\./,"").length)throw Error(f+e)}else g.s=45===m.charCodeAt(0)?(m=m.slice(1),-1):1;for(r=V.slice(0,t),u=l=0,b=m.length;l<b;l++)if(r.indexOf(s=m.charAt(l))<0){if("."==s){if(u<l){u=b;continue}}else if(!c&&(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase()))){c=!0,l=-1,u=0;continue}return i(g,String(e),p,t)}p=!1,-1<(u=(m=n(m,t,10,g.s)).indexOf("."))?m=m.replace(".",""):u=m.length}for(l=0;48===m.charCodeAt(l);l++);for(b=m.length;48===m.charCodeAt(--b););if(m=m.slice(l,++b)){if(b-=l,p&&$.DEBUG&&15<b&&(h<e||e!==a(e)))throw Error(f+g.s*e);if((u=u-l-1)>B)g.c=g.e=null;else if(u<F)g.c=[g.e=0];else{if(g.e=u,g.c=[],l=(u+1)%d,u<0&&(l+=d),l<b){for(l&&g.c.push(+m.slice(0,l)),b-=d;l<b;)g.c.push(+m.slice(l,l+=d));l=d-(m=m.slice(l)).length}else l-=b;for(;l--;m+="0");g.c.push(+m)}}else g.c=[g.e=0]}function H(e,t,r,n){for(var i,o,s=[0],a=0,c=e.length;a<c;){for(o=s.length;o--;s[o]*=t);for(s[0]+=n.indexOf(e.charAt(a++)),i=0;i<s.length;i++)s[i]>r-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}function K(e,t,r){var n,i,o,s,a=0,c=e.length,f=t%p,u=t/p|0;for(e=e.slice();c--;)a=((i=f*(o=e[c]%p)+(n=u*o+(s=e[c]/p|0)*f)%p*p+a)/r|0)+(n/p|0)+u*s,e[c]=i%r;return a&&(e=[a].concat(e)),e}function Y(e,t,r,n){var i,o;if(r!=n)o=n<r?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function W(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&1<e.length;e.splice(0,1));}function J(e,t,r,n){var i,o,s,a,c;if(null==r?r=R:v(r,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==t)c=g(e.c),c=1==n||2==n&&(s<=N||j<=s)?_(c,s):S(c,s,"0");else if(o=(e=X(new $(e),t,r)).e,a=(c=g(e.c)).length,1==n||2==n&&(t<=o||o<=N)){for(;a<t;c+="0",a++);c=_(c,o)}else if(t-=s,c=S(c,o,"0"),a<o+1){if(0<--t)for(c+=".";t--;c+="0");}else if(0<(t+=o-a))for(o+1==a&&(c+=".");t--;c+="0");return e.s<0&&i?"-"+c:c}function G(e,t){for(var r,n=1,i=new $(e[0]);n<e.length;n++){if(!(r=new $(e[n])).s){i=r;break}t.call(i,r)&&(i=r)}return i}function Z(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];10<=i;i/=10,n++);return(r=n+r*d-1)>B?e.c=e.e=null:r<F?e.c=[e.e=0]:(e.e=r,e.c=t),e}function X(e,t,r,n){var i,o,c,f,h,p,b,m=e.c,g=l;if(m){e:{for(i=1,f=m[0];10<=f;f/=10,i++);if((o=t-i)<0)o+=d,c=t,b=(h=m[p=0])/g[i-c-1]%10|0;else if((p=s((o+1)/d))>=m.length){if(!n)break e;for(;m.length<=p;m.push(0));h=b=0,c=(o%=d)-d+(i=1)}else{for(h=f=m[p],i=1;10<=f;f/=10,i++);b=(c=(o%=d)-d+i)<0?0:h/g[i-c-1]%10|0}if(n=n||t<0||null!=m[p+1]||(c<0