"use strict";function assignToObject(t,e){return"function"!=typeof Object.assign&&Object.defineProperties(Object,{assign:{value:function(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(t),n=1;nthis.length)&&(e=this.length),this.substring(e-t.length,e)===t}),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){e=e||window;for(var r=0;r0?Math.floor(t):Math.ceil(t)}function d(t,r){var n,i,o=t.length,s=r.length,a=new Array(o),c=0,l=e;for(i=0;i=l?1:0,a[i]=n-c*l;for(;i0&&a.push(c),a}function y(t,e){return t.length>=e.length?d(t,e):d(e,t)}function v(t,r){var n,i,o=t.length,s=new Array(o),a=e;for(i=0;i0;)s[i++]=r%a,r=Math.floor(r/a);return s}function m(t,r){var n,i,o=t.length,s=r.length,a=new Array(o),c=0,l=e;for(n=0;n0;)s[i++]=c%a,c=Math.floor(c/a);return s}function S(t,e){for(var r=[];e-- >0;)r.push(0);return r.concat(t)}function A(t,r,n){return new a(t=0;--n)o=(s=o*l+t[n])-(i=g(s/r))*r,c[n]=0|i;return[c,0|o]}function _(t,r){var n,i,o=V(r),l=t.value,d=o.value;if(0===d)throw new Error("Cannot divide by zero");if(t.isSmall)return o.isSmall?[new c(g(l/d)),new c(l%d)]:[s[0],t];if(o.isSmall){if(1===d)return[t,s[0]];if(-1==d)return[t.negate(),s[0]];var y=Math.abs(d);if(y=0;i--){for(n=g-1,m[i+p]!==y&&(n=Math.floor((m[i+p]*g+m[i+p-1])/y)),o=0,s=0,c=b.length,a=0;al&&(o=(o+1)*g),n=Math.ceil(o/s);do{if(L(a=j(r,n),f)<=0)break;n--}while(n);u.push(n),f=m(f,a)}return u.reverse(),[h(u),h(f)]}(l,d))[0];var w=t.sign!==o.sign,S=n[1],A=t.sign;return"number"==typeof i?(w&&(i=-i),i=new c(i)):i=new a(i,w),"number"==typeof S?(A&&(S=-S),S=new c(S)):S=new a(S,A),[i,S]}function L(t,e){if(t.length!==e.length)return t.length>e.length?1:-1;for(var r=t.length-1;r>=0;r--)if(t[r]!==e[r])return t[r]>e[r]?1:-1;return 0}function I(t){var e=t.abs();return!e.isUnit()&&(!!(e.equals(2)||e.equals(3)||e.equals(5))||!(e.isEven()||e.isDivisibleBy(3)||e.isDivisibleBy(5))&&(!!e.lesser(49)||void 0))}function B(t,e){for(var r,n,i,o,a=t.prev(),c=a;c.isEven();)c=c.divide(2);for(i=0;i=0?n=m(t,e):(n=m(e,t),r=!r),"number"==typeof(n=h(n))?(r&&(n=-n),new c(n)):new a(n,r)}(r,n,this.sign)},a.prototype.minus=a.prototype.subtract,c.prototype.subtract=function(t){var e=V(t),r=this.value;if(r<0!==e.sign)return this.add(e.negate());var n=e.value;return e.isSmall?new c(r-n):b(n,Math.abs(r),r>=0)},c.prototype.minus=c.prototype.subtract,a.prototype.negate=function(){return new a(this.value,!this.sign)},c.prototype.negate=function(){var t=this.sign,e=new c(-this.value);return e.sign=!t,e},a.prototype.abs=function(){return new a(this.value,!1)},c.prototype.abs=function(){return new c(Math.abs(this.value))},a.prototype.multiply=function(t){var r,n,i,o=V(t),c=this.value,l=o.value,h=this.sign!==o.sign;if(o.isSmall){if(0===l)return s[0];if(1===l)return this;if(-1===l)return this.negate();if((r=Math.abs(l))0?function t(e,r){var n=Math.max(e.length,r.length);if(n<=30)return w(e,r);n=Math.ceil(n/2);var i=e.slice(n),o=e.slice(0,n),s=r.slice(n),a=r.slice(0,n),c=t(o,a),l=t(i,s),u=y(y(c,S(m(m(t(y(o,i),y(a,s)),c),l),n)),S(l,2*n));return p(u),u}(c,l):w(c,l),h)},a.prototype.times=a.prototype.multiply,c.prototype._multiplyBySmall=function(t){return l(t.value*this.value)?new c(t.value*this.value):A(Math.abs(t.value),u(Math.abs(this.value)),this.sign!==t.sign)},a.prototype._multiplyBySmall=function(t){return 0===t.value?s[0]:1===t.value?this:-1===t.value?this.negate():A(Math.abs(t.value),this.value,this.sign!==t.sign)},c.prototype.multiply=function(t){return V(t)._multiplyBySmall(this)},c.prototype.times=c.prototype.multiply,a.prototype.square=function(){return new a(x(this.value),!1)},c.prototype.square=function(){var t=this.value*this.value;return l(t)?new c(t):new a(x(u(Math.abs(this.value))),!1)},a.prototype.divmod=function(t){var e=_(this,t);return{quotient:e[0],remainder:e[1]}},c.prototype.divmod=a.prototype.divmod,a.prototype.divide=function(t){return _(this,t)[0]},c.prototype.over=c.prototype.divide=a.prototype.over=a.prototype.divide,a.prototype.mod=function(t){return _(this,t)[1]},c.prototype.remainder=c.prototype.mod=a.prototype.remainder=a.prototype.mod,a.prototype.pow=function(t){var e,r,n,i=V(t),o=this.value,a=i.value;if(0===a)return s[1];if(0===o)return s[0];if(1===o)return s[1];if(-1===o)return i.isEven()?s[1]:s[-1];if(i.sign)return s[0];if(!i.isSmall)throw new Error("The exponent "+i.toString()+" is too large.");if(this.isSmall&&l(e=Math.pow(o,a)))return new c(g(e));for(r=this,n=s[1];!0&a&&(n=n.times(r),--a),0!==a;)a/=2,r=r.square();return n},c.prototype.pow=a.prototype.pow,a.prototype.modPow=function(t,e){if(t=V(t),(e=V(e)).isZero())throw new Error("Cannot take modPow with modulus 0");for(var r=s[1],n=this.mod(e);t.isPositive();){if(n.isZero())return s[0];t.isOdd()&&(r=r.multiply(n).mod(e)),t=t.divide(2),n=n.square().mod(e)}return r},c.prototype.modPow=a.prototype.modPow,a.prototype.compareAbs=function(t){var e=V(t),r=this.value,n=e.value;return e.isSmall?1:L(r,n)},c.prototype.compareAbs=function(t){var e=V(t),r=Math.abs(this.value),n=e.value;return e.isSmall?r===(n=Math.abs(n))?0:r>n?1:-1:-1},a.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=V(t),r=this.value,n=e.value;return this.sign!==e.sign?e.sign?1:-1:e.isSmall?this.sign?-1:1:L(r,n)*(this.sign?-1:1)},a.prototype.compareTo=a.prototype.compare,c.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=V(t),r=this.value,n=e.value;return e.isSmall?r==n?0:r>n?1:-1:r<0!==e.sign?r<0?-1:1:r<0?1:-1},c.prototype.compareTo=c.prototype.compare,a.prototype.equals=function(t){return 0===this.compare(t)},c.prototype.eq=c.prototype.equals=a.prototype.eq=a.prototype.equals,a.prototype.notEquals=function(t){return 0!==this.compare(t)},c.prototype.neq=c.prototype.notEquals=a.prototype.neq=a.prototype.notEquals,a.prototype.greater=function(t){return this.compare(t)>0},c.prototype.gt=c.prototype.greater=a.prototype.gt=a.prototype.greater,a.prototype.lesser=function(t){return this.compare(t)<0},c.prototype.lt=c.prototype.lesser=a.prototype.lt=a.prototype.lesser,a.prototype.greaterOrEquals=function(t){return this.compare(t)>=0},c.prototype.geq=c.prototype.greaterOrEquals=a.prototype.geq=a.prototype.greaterOrEquals,a.prototype.lesserOrEquals=function(t){return this.compare(t)<=0},c.prototype.leq=c.prototype.lesserOrEquals=a.prototype.leq=a.prototype.lesserOrEquals,a.prototype.isEven=function(){return 0==(1&this.value[0])},c.prototype.isEven=function(){return 0==(1&this.value)},a.prototype.isOdd=function(){return 1==(1&this.value[0])},c.prototype.isOdd=function(){return 1==(1&this.value)},a.prototype.isPositive=function(){return!this.sign},c.prototype.isPositive=function(){return this.value>0},a.prototype.isNegative=function(){return this.sign},c.prototype.isNegative=function(){return this.value<0},a.prototype.isUnit=function(){return!1},c.prototype.isUnit=function(){return 1===Math.abs(this.value)},a.prototype.isZero=function(){return!1},c.prototype.isZero=function(){return 0===this.value},a.prototype.isDivisibleBy=function(t){var e=V(t),r=e.value;return 0!==r&&(1===r||(2===r?this.isEven():this.mod(e).equals(s[0])))},c.prototype.isDivisibleBy=a.prototype.isDivisibleBy,a.prototype.isPrime=function(){var t=I(this);return void 0!==t?t:B(this.abs(),[2,325,9375,28178,450775,9780504,1795265022])},c.prototype.isPrime=a.prototype.isPrime,a.prototype.isProbablePrime=function(t){var e=I(this);if(void 0!==e)return e;for(var r=this.abs(),n=void 0===t?5:t,i=[],o=0;o-n?new c(t-1):new a(i,!0)};for(var M=[1];2*M[M.length-1]<=e;)M.push(2*M[M.length-1]);var O=M.length,C=M[O-1];function k(t){return("number"==typeof t||"string"==typeof t)&&+Math.abs(t)<=e||t instanceof a&&t.value.length<=1}function N(t,e,r){e=V(e);for(var n=t.isNegative(),i=e.isNegative(),o=n?t.not():t,s=i?e.not():e,a=0,c=0,l=null,u=null,h=[];!o.isZero()||!s.isZero();)a=(l=_(o,C))[1].toJSNumber(),n&&(a=C-1-a),c=(u=_(s,C))[1].toJSNumber(),i&&(c=C-1-c),o=l[0],s=u[0],h.push(r(a,c));for(var p=0!==r(n?1:0,i?1:0)?bigInt(-1):bigInt(0),f=h.length-1;f>=0;f-=1)p=p.multiply(C).add(bigInt(h[f]));return p}a.prototype.shiftLeft=function(t){if(!k(t))throw new Error(String(t)+" is too large for shifting.");if((t=+t)<0)return this.shiftRight(-t);var e=this;if(e.isZero())return e;for(;t>=O;)e=e.multiply(C),t-=O-1;return e.multiply(M[t])},c.prototype.shiftLeft=a.prototype.shiftLeft,a.prototype.shiftRight=function(t){var e;if(!k(t))throw new Error(String(t)+" is too large for shifting.");if((t=+t)<0)return this.shiftLeft(-t);for(var r=this;t>=O;){if(r.isZero()||r.isNegative()&&r.isUnit())return r;r=(e=_(r,C))[1].isNegative()?e[0].prev():e[0],t-=O-1}return(e=_(r,M[t]))[1].isNegative()?e[0].prev():e[0]},c.prototype.shiftRight=a.prototype.shiftRight,a.prototype.not=function(){return this.negate().prev()},c.prototype.not=a.prototype.not,a.prototype.and=function(t){return N(this,t,function(t,e){return t&e})},c.prototype.and=a.prototype.and,a.prototype.or=function(t){return N(this,t,function(t,e){return t|e})},c.prototype.or=a.prototype.or,a.prototype.xor=function(t){return N(this,t,function(t,e){return t^e})},c.prototype.xor=a.prototype.xor;var q=1<<30,P=(e&-e)*(e&-e)|q;function U(t){var r=t.value,n="number"==typeof r?r|q:r[0]+r[1]*e|P;return n&-n}function R(t,e){return t=V(t),e=V(e),t.greater(e)?t:e}function T(t,e){return t=V(t),e=V(e),t.lesser(e)?t:e}function z(t,e){if(t=V(t).abs(),e=V(e).abs(),t.equals(e))return t;if(t.isZero())return e;if(e.isZero())return t;for(var r,n,i=s[1];t.isEven()&&e.isEven();)r=Math.min(U(t),U(e)),t=t.divide(r),e=e.divide(r),i=i.multiply(r);for(;t.isEven();)t=t.divide(U(t));do{for(;e.isEven();)e=e.divide(U(e));t.greater(e)&&(n=e,e=t,t=n),e=e.subtract(t)}while(!e.isZero());return i.isUnit()?t:t.multiply(i)}a.prototype.bitLength=function(){var t=this;return t.compareTo(bigInt(0))<0&&(t=t.negate().subtract(bigInt(1))),0===t.compareTo(bigInt(0))?bigInt(0):bigInt(function t(e,r){if(r.compareTo(e)<=0){var n=t(e,r.square(r)),i=n.p,o=n.e,s=i.multiply(r);return s.compareTo(e)<=0?{p:s,e:2*o+1}:{p:i,e:2*o}}return{p:bigInt(1),e:0}}(t,bigInt(2)).e).add(bigInt(1))},c.prototype.bitLength=a.prototype.bitLength;var D=function(t,e){for(var r=t.length,n=Math.abs(e),i=0;i=n){if("1"===u&&1===n)continue;throw new Error(u+" is not a valid digit in base "+e+".")}if(u.charCodeAt(0)-87>=n)throw new Error(u+" is not a valid digit in base "+e+".")}}if(2<=e&&e<=36&&r<=o/Math.log(e)){var s=parseInt(t,e);if(isNaN(s))throw new Error(u+" is not a valid digit in base "+e+".");return new c(parseInt(t,e))}e=V(e);var a=[],l="-"===t[0];for(i=l?1:0;i"!==t[i]);a.push(V(t.slice(p+1,i)))}}return G(a,e,l)};function G(t,e,r){var n,i=s[0],o=s[1];for(n=t.length-1;n>=0;n--)i=i.add(t[n].times(o)),o=o.times(e);return r?i.negate():i}function Z(t){return t<=35?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t):"<"+t+">"}function J(t,e){if((e=bigInt(e)).isZero()){if(t.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(e.equals(-1)){if(t.isZero())return{value:[0],isNegative:!1};if(t.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-t)).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(+t-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var n=!1;if(t.isNegative()&&e.isPositive()&&(n=!0,t=t.abs()),e.equals(1))return t.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(+t)).map(Number.prototype.valueOf,1),isNegative:n};for(var i,o=[],s=t;s.isNegative()||s.compareAbs(e)>=0;){s=(i=s.divmod(e)).quotient;var a=i.remainder;a.isNegative()&&(a=e.minus(a).abs(),s=s.next()),o.push(a.toJSNumber())}return o.push(s.toJSNumber()),{value:o.reverse(),isNegative:n}}function F(t,e){var r=J(t,e);return(r.isNegative?"-":"")+r.value.map(Z).join("")}function H(t){if(l(+t)){var e=+t;if(e===g(e))return new c(e);throw new Error("Invalid integer: "+t)}var n="-"===t[0];n&&(t=t.slice(1));var i=t.split(/e/i);if(i.length>2)throw new Error("Invalid integer: "+i.join("e"));if(2===i.length){var o=i[1];if("+"===o[0]&&(o=o.slice(1)),(o=+o)!==g(o)||!l(o))throw new Error("Invalid integer: "+o+" is not a valid exponent.");var s=i[0],u=s.indexOf(".");if(u>=0&&(o-=s.length-u-1,s=s.slice(0,u)+s.slice(u+1)),o<0)throw new Error("Cannot include negative exponent part for integers");t=s+=new Array(o+1).join("0")}if(!/^([0-9][0-9]*)$/.test(t))throw new Error("Invalid integer: "+t);for(var h=[],f=t.length,d=r,y=f-d;f>0;)h.push(+t.slice(y,f)),(y-=d)<0&&(y=0),f-=d;return p(h),new a(h,n)}function V(t){return"number"==typeof t?function(t){if(l(t)){if(t!==g(t))throw new Error(t+" is not an integer.");return new c(t)}return H(t.toString())}(t):"string"==typeof t?H(t):t}a.prototype.toArray=function(t){return J(this,t)},c.prototype.toArray=function(t){return J(this,t)},a.prototype.toString=function(t){if(void 0===t&&(t=10),10!==t)return F(this,t);for(var e,r=this.value,n=r.length,i=String(r[--n]);--n>=0;)e=String(r[n]),i+="0000000".slice(e.length)+e;return(this.sign?"-":"")+i},c.prototype.toString=function(t){return void 0===t&&(t=10),10!=t?F(this,t):String(this.value)},a.prototype.toJSON=c.prototype.toJSON=function(){return this.toString()},a.prototype.valueOf=function(){return parseInt(this.toString(),10)},a.prototype.toJSNumber=a.prototype.valueOf,c.prototype.valueOf=function(){return this.value},c.prototype.toJSNumber=c.prototype.valueOf;for(var W=0;W<1e3;W++)s[W]=new c(W),W>0&&(s[-W]=new c(-W));return s.one=s[1],s.zero=s[0],s.minusOne=s[-1],s.max=R,s.min=T,s.gcd=z,s.lcm=function(t,e){return t=V(t).abs(),e=V(e).abs(),t.divide(z(t,e)).multiply(e)},s.isInstance=function(t){return t instanceof a||t instanceof c},s.randBetween=function(t,r){var n=T(t=V(t),r=V(r)),i=R(t,r).subtract(n).add(1);if(i.isSmall)return n.add(Math.floor(Math.random()*i));for(var o=[],s=!0,l=i.value.length-1;l>=0;l--){var u=s?i.value[l]:e,p=g(Math.random()*u);o.unshift(p),p64)throw new Error(e+"(): Number is not a 64bit integer")}function i(t){var e="0000000000000000"+t.toString(16);return e.substr(e.length-16,16)}this.x64=bigInt(t,e),n(this.x64.bitLength(),"init"),this.x64.toString64=function(){return("0000000000000000"+r).substr(-16)},this.x64.toString32=function(){return("00000000"+r).substr(-8)},this.x64.toString16=function(){return("0000"+r).substr(-4)},this.x64.toString8=function(){return("00"+r).substr(-2)},this.x64.add=function(t){var e=this.__proto__.add.call(this,t);return n(e.bitLength(),"add"),new UInt64(e.toString(16))},this.x64.plus=function(t){return this.add.call(this,t)},this.x64.subtract=function(t){var e=this.__proto__.subtract.call(this,t);return n(e.bitLength(),"subtract"),new UInt64(e.toString(16))},this.x64.minus=function(t){return this.subtract.call(this,t)},this.x64.negate=function(){var t=this.__proto__.negate.call(this);return n(t.bitLength(),"negate"),new UInt64(t.toString(16))},this.x64.abs=function(){var t=this.__proto__.abs.call(this);return n(t.bitLength(),"abs"),new UInt64(t.toString(16))},this.x64.multiply=function(t){var e=this.__proto__.multiply.call(this,t);return n(e.bitLength(),"multiply"),new UInt64(e.toString(16))},this.x64.times=function(t){return this.multiply.call(this,t)},this.x64._multiplyBySmall=function(t){var e=this.__proto__._multiplyBySmall.call(this,t);return n(e.bitLength(),"_multiplyBySmall"),new UInt64(e.toString(16))},this.x64.square=function(){var t=this.__proto__.square.call(this);return n(t.bitLength(),"square"),new UInt64(t.toString(16))},this.x64.divide=function(t){var e=this.__proto__.divide.call(this,t);return n(e.bitLength(),"divide"),new UInt64(e.toString(16))},this.x64.mod=function(t){var e=this.__proto__.mod.call(this,t);return n(e.bitLength(),"mod"),new UInt64(e.toString(16))},this.x64.pow=function(t){var e=this.__proto__.pow.call(this,t);return n(e.bitLength(),"pow"),new UInt64(e.toString(16))},this.x64.modInv=function(t){var e=this.__proto__.modInv.call(this,t);return n(e.bitLength(),"modInv"),new UInt64(e.toString(16))},this.x64.next=function(){var t=this.__proto__.next.call(this);return n(t.bitLength(),"next"),new UInt64(t.toString(16))},this.x64.prev=function(){var t=this.__proto__.prev.call(this);return n(t.bitLength(),"prev"),new UInt64(t.toString(16))},this.x64.shiftLeft=function(t){var e=this.__proto__.shiftLeft.call(this,t);return n(e.bitLength(),"shiftLeft"),new UInt64(e.toString(16))},this.x64.shiftRight=function(t){var e=this.__proto__.shiftRight.call(this,t);return n(e.bitLength(),"shiftRight"),new UInt64(e.toString(16))},this.x64.and=function(t){var e=this.__proto__.and.call(this,t);return n(e.bitLength(),"and"),new UInt64(e.toString(16))},this.x64.or=function(t){var e=this.__proto__.or.call(this,t);return n(e.bitLength(),"or"),new UInt64(e.toString(16))},this.x64.not=function(){var t=this.__proto__.not.call(this);return n(t.bitLength(),"not"),new UInt64(t.toString(16))},this.x64.xor=function(t){var e=this.__proto__.xor.call(this,t);return n(e.bitLength(),"xor"),new UInt64(e.toString(16))},this.x64.hi32=function(){return n(this.bitLength(),"hi32"),parseInt(i(this).substr(0,8),16)},this.x64.lo32=function(){return n(this.bitLength(),"lo32"),parseInt(i(this).substr(8,8),16)}}},sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function t(t,e,r){if(4!==e.length)throw new sjcl.exception.invalid("invalid aes block size");var n=t.b[r],i=e[0]^n[0],o=e[r?3:1]^n[1],s=e[2]^n[2];e=e[r?1:3]^n[3];var a,c,l,u,h=n.length/4-2,p=4,f=[0,0,0,0];t=(a=t.s[r])[0];var g=a[1],d=a[2],y=a[3],v=a[4];for(u=0;u>>24]^g[o>>16&255]^d[s>>8&255]^y[255&e]^n[p],c=t[o>>>24]^g[s>>16&255]^d[e>>8&255]^y[255&i]^n[p+1],l=t[s>>>24]^g[e>>16&255]^d[i>>8&255]^y[255&o]^n[p+2],e=t[e>>>24]^g[i>>16&255]^d[o>>8&255]^y[255&s]^n[p+3],p+=4,i=a,o=c,s=l;for(u=0;4>u;u++)f[r?3&-u:u]=v[i>>>24]<<24^v[o>>16&255]<<16^v[s>>8&255]<<8^v[255&e]^n[p++],a=i,i=o,o=s,s=e,e=a;return f}function u(t,e){var r,n,i,o=t.F,s=t.b,a=o[0],c=o[1],l=o[2],u=o[3],h=o[4],p=o[5],f=o[6],g=o[7];for(r=0;64>r;r++)16>r?n=e[r]:(n=e[r+1&15],i=e[r+14&15],n=e[15&r]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+e[15&r]+e[r+9&15]|0),n=n+g+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(f^h&(p^f))+s[r],g=f,f=p,p=h,h=u+n|0,u=l,l=c,a=n+((c=a)&l^u&(c^l))+(c>>>2^c>>>13^c>>>22^c<<30^c<<19^c<<10)|0;o[0]=o[0]+a|0,o[1]=o[1]+c|0,o[2]=o[2]+l|0,o[3]=o[3]+u|0,o[4]=o[4]+h|0,o[5]=o[5]+p|0,o[6]=o[6]+f|0,o[7]=o[7]+g|0}function A(t,e){var r,n=sjcl.random.K[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.h[e]=t.h[e]+1|0,!t.h[e]);e++);return t.L.encrypt(t.h)}function B(t,e){return function(){e.apply(t,arguments)}}sjcl.cipher.aes=function(t){this.s[0][0][0]||this.O();var e,r,n,i,o=this.s[0][4],s=this.s[1],a=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new sjcl.exception.invalid("invalid aes key size");for(this.b=[n=t.slice(0),i=[]],t=e;t<4*e+28;t++)r=n[t-1],(0==t%e||8===e&&4==t%e)&&(r=o[r>>>24]<<24^o[r>>16&255]<<16^o[r>>8&255]<<8^o[255&r],0==t%e&&(r=r<<8^r>>>24^a<<24,a=a<<1^283*(a>>7))),n[t]=n[t-e]^r;for(e=0;t;e++,t--)r=n[3&e?t:t-4],i[e]=4>=t||4>e?r:s[0][o[r>>>24]]^s[1][o[r>>16&255]]^s[2][o[r>>8&255]]^s[3][o[255&r]]},sjcl.cipher.aes.prototype={encrypt:function(e){return t(this,e,0)},decrypt:function(e){return t(this,e,1)},s:[[[],[],[],[],[]],[[],[],[],[],[]]],O:function(){var t,e,r,n,i,o,s,a=this.s[0],c=this.s[1],l=a[4],u=c[4],h=[],p=[];for(t=0;256>t;t++)p[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!l[e];e^=n||1,r=p[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,l[e]=o,u[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,c[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),c[t]=c[t].slice(0)}},sjcl.bitArray={bitSlice:function(t,e,r){return t=sjcl.bitArray.$(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:sjcl.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(sjcl.bitArray.bitLength(t)!==sjcl.bitArray.bitLength(e))return!1;var r,n=0;for(r=0;r>>e),r=t[i]<<32-e;return i=t.length?t[t.length-1]:0,t=sjcl.bitArray.getPartial(i),n.push(sjcl.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},sjcl.codec.utf8String={fromBits:function(t){var e,r,n="",i=sjcl.bitArray.bitLength(t);for(e=0;e>>8>>>8>>>8),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>s)>>>i),s(n=l.indexOf(t.charAt(r)))){if(!e)try{return sjcl.codec.base32hex.toBits(t)}catch(t){}throw new sjcl.exception.invalid("this isn't "+h+"!")}c>s?(c-=s,a.push(u^n>>>c),u=n<>>i)>>>26),6>i?(s=t[r]<<6-i,i+=26,r++):(s<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,n,i=[],o=0,s=sjcl.codec.base64.B,a=0;for(e&&(s=s.substr(0,62)+"-_"),r=0;r(n=s.indexOf(t.charAt(r))))throw new sjcl.exception.invalid("this isn't base64!");26>>o),a=n<<32-o):a^=n<<32-(o+=6)}return 56&o&&i.push(sjcl.bitArray.partial(56&o,a,1)),i}},sjcl.codec.base64url={fromBits:function(t){return sjcl.codec.base64.fromBits(t,1,1)},toBits:function(t){return sjcl.codec.base64.toBits(t,1)}},sjcl.hash.sha256=function(t){this.b[0]||this.O(),t?(this.F=t.F.slice(0),this.A=t.A.slice(0),this.l=t.l):this.reset()},sjcl.hash.sha256.hash=function(t){return(new sjcl.hash.sha256).update(t).finalize()},sjcl.hash.sha256.prototype={blockSize:512,reset:function(){return this.F=this.Y.slice(0),this.A=[],this.l=0,this},update:function(t){"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t));var e,r=this.A=sjcl.bitArray.concat(this.A,t);if(e=this.l,9007199254740991<(t=this.l=e+sjcl.bitArray.bitLength(t)))throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var n=new Uint32Array(r),i=0;for(e=512+e-(512+e&511);e<=t;e+=512)u(this,n.subarray(16*i,16*(i+1))),i+=1;r.splice(0,16*i)}else for(e=512+e-(512+e&511);e<=t;e+=512)u(this,r.splice(0,16));return this},finalize:function(){var t,e=this.A,r=this.F;for(t=(e=sjcl.bitArray.concat(e,[sjcl.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.l/4294967296)),e.push(0|this.l);e.length;)u(this,e.splice(0,16));return this.reset(),r},Y:[],b:[],O:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}for(var e,r,n=0,i=2;64>n;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.Y[n]=t(Math.pow(i,.5))),this.b[n]=t(Math.pow(i,1/3)),n++)}}},sjcl.mode.ccm={name:"ccm",G:[],listenProgress:function(t){sjcl.mode.ccm.G.push(t)},unListenProgress:function(t){-1<(t=sjcl.mode.ccm.G.indexOf(t))&&sjcl.mode.ccm.G.splice(t,1)},fa:function(t){var e,r=sjcl.mode.ccm.G.slice();for(e=0;ec)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&l>>>8*o;o++);return o<15-c&&(o=15-c),r=a.clamp(r,8*(15-o)),e=sjcl.mode.ccm.V(t,e,r,n,i,o),s=sjcl.mode.ccm.C(t,s,r,e,i,o),a.concat(s.data,s.tag)},decrypt:function(t,e,r,n,i){i=i||64,n=n||[];var o=sjcl.bitArray,s=o.bitLength(r)/8,a=o.bitLength(e),c=o.clamp(e,a-i),l=o.bitSlice(e,a-i);a=(a-i)/8;if(7>s)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&a>>>8*e;e++);if(e<15-s&&(e=15-s),r=o.clamp(r,8*(15-e)),c=sjcl.mode.ccm.C(t,c,r,l,i,e),t=sjcl.mode.ccm.V(t,c.data,r,n,i,e),!o.equal(c.tag,t))throw new sjcl.exception.corrupt("ccm: tag doesn't match");return c.data},na:function(t,e,r,n,i,o){var s=[],a=sjcl.bitArray,c=a.i;if(n=[a.partial(8,(e.length?64:0)|n-2<<2|o-1)],(n=a.concat(n,r))[3]|=i,n=t.encrypt(n),e.length)for(65279>=(r=a.bitLength(e)/8)?s=[a.partial(16,r)]:4294967295>=r&&(s=a.concat([a.partial(16,65534)],[r])),s=a.concat(s,e),e=0;ei||16u&&(sjcl.mode.ccm.fa(s/c),u+=h),r[3]++,i=t.encrypt(r),e[s]^=i[0],e[s+1]^=i[1],e[s+2]^=i[2],e[s+3]^=i[3];return{tag:n,data:a.clamp(e,l)}}},sjcl.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,n,i,o){if(128!==sjcl.bitArray.bitLength(r))throw new sjcl.exception.invalid("ocb iv must be 128 bits");var s,a=sjcl.mode.ocb2.S,c=sjcl.bitArray,l=c.i,u=[0,0,0,0];r=a(t.encrypt(r));var h,p=[];for(n=n||[],i=i||64,s=0;s+4i.bitLength(r)&&(a=o(a,n(a)),r=i.concat(r,[-2147483648,0,0,0])),s=o(s,r),t.encrypt(o(n(o(a,n(a))),s))},S:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},sjcl.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=sjcl.bitArray,n=n||[],t=sjcl.mode.gcm.C(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,n,i){var o=e.slice(0),s=sjcl.bitArray,a=s.bitLength(o);if(n=n||[],(i=i||128)<=a?(e=s.bitSlice(o,a-i),o=s.bitSlice(o,0,a-i)):(e=o,o=[]),t=sjcl.mode.gcm.C(!1,t,o,n,r,i),!s.equal(t.tag,e))throw new sjcl.exception.corrupt("gcm: tag doesn't match");return t.data},ka:function(t,e){var r,n,i,o,s,a=sjcl.bitArray.i;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=a(i,o)),s=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,s&&(o[0]^=-520093696)}return i},j:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;rn||0>r)throw new sjcl.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t)),"string"==typeof e&&(e=sjcl.codec.utf8String.toBits(e)),t=new(i=i||sjcl.misc.hmac)(t);var o,s,a,c,l=[],u=sjcl.bitArray;for(c=1;32*l.length<(n||1);c++){for(i=o=t.encrypt(u.concat(e,[c])),s=1;so;o++)n.push(4294967296*Math.random()|0);for(o=0;o=1<this.o&&(this.o=s),this.P++,this.b=sjcl.hash.sha256.hash(this.b.concat(n)),this.L=new sjcl.cipher.aes(this.b),r=0;4>r&&(this.h[r]=this.h[r]+1|0,!this.h[r]);r++);}for(r=0;r>>=1;this.c[s].update([n,this.N++,2,e,o,t.length].concat(t))}break;case"string":void 0===e&&(e=t.length),this.c[s].update([n,this.N++,3,e,o,t.length]),this.c[s].update(t);break;default:c=1}if(c)throw new sjcl.exception.bug("random: addEntropy only supports number, array of numbers or string");this.m[s]+=e,this.f+=e,a===this.u&&(this.isReady()!==this.u&&A("seeded",Math.max(this.o,this.f)),A("progress",this.getProgress()))},isReady:function(t){return t=this.T[void 0!==t?t:this.M],this.o&&this.o>=t?this.m[0]>this.ba&&(new Date).valueOf()>this.Z?this.J|this.I:this.I:this.f>=t?this.J|this.u:this.u},getProgress:function(t){return t=this.T[t||this.M],this.o>=t?1:this.f>t?1:this.f/t},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:B(this,this.ma),mouseCollector:B(this,this.oa),keyboardCollector:B(this,this.la),accelerometerCollector:B(this,this.ea),touchCollector:B(this,this.qa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else{if(!document.attachEvent)throw new sjcl.exception.bug("can't attach event");document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)}this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(t,e){this.K[t][this.ga++]=e},removeEventListener:function(t,e){var r,n,i=this.K[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=s.iter||64!==s.ts&&96!==s.ts&&128!==s.ts||128!==s.ks&&192!==s.ks&&256!==s.ks||2>s.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||4>>n:t[e/32|0]>>>n)&(1<0&&e&&(t[r-1]=sjcl.bitArray.partial(e,t[r-1]&2147483648>>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(sjcl.bitArray.bitLength(t)!==sjcl.bitArray.bitLength(e))return!1;var r,n=0;for(r=0;r=32;e-=32)n.push(r),r=0;if(0===e)return n.concat(t);for(i=0;i>>e),r=t[i]<<32-e;return o=t.length?t[t.length-1]:0,s=sjcl.bitArray.getPartial(o),n.push(sjcl.bitArray.partial(e+s&31,e+s>32?r:n.pop(),1)),n},_xor4:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,r;for(e=0;e>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},sjcl.misc.hkdf=function(t,e,r,n,i){var o,s,a,c,l,u,h=[];if(i=i||sjcl.hash.sha256,"string"==typeof n&&(n=sjcl.codec.utf8String.toBits(n)),"string"==typeof r?r=sjcl.codec.utf8String.toBits(r):r||(r=[]),s=(o=new sjcl.misc.hmac(r,i)).mac(t),c=sjcl.bitArray.bitLength(s),(l=Math.ceil(e/c))>255)throw new sjcl.exception.invalid("key bit length is too large for hkdf");for(o=new sjcl.misc.hmac(s,i),u=[],a=1;a<=l;a++)o.update(u),o.update(n),o.update([sjcl.bitArray.partial(8,a)]),u=o.digest(),h=sjcl.bitArray.concat(h,u);return sjcl.bitArray.clamp(h,e)};