PS3_Toolset/files/biginteger.min.js

1 line
51 KiB
JavaScript

"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;n<arguments.length;n++){var i=arguments[n];if(null!=i)for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])}return r},writable:!0,configurable:!0}}),Object.assign(t,e)}function cloneObject(t){var e={};for(var r in t)null!=t[r]&&"object"==typeof t[r]?e[r]=cloneObject(t[r]):e[r]=t[r];return e}"function"!=typeof Object.create&&(Object.create=function(t,e){var r=function(t){t&&Object.defineProperties(this,t)};return r.prototype=t,new r(e)}),Object.keys||(Object.keys=function(t){if(t!==Object(t))throw new TypeError("Object.keys called on a non-object");var e,r=[];for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.push(e);return r}),String.prototype.includes||(String.prototype.includes=function(t,e){if(t instanceof RegExp)throw TypeError("first argument must not be a RegExp");return void 0===e&&(e=0),-1!==this.indexOf(t,e)}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=!e||e<0?0:+e,this.substring(e,e+t.length)===t}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){return(void 0===e||e>this.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;r<this.length;r++)t.call(e,this[r],r,this)}),window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=function(t,e){e=e||window;for(var r=0;r<this.length;r++)t.call(e,this[r],r,this)}),Number.prototype.toString64=function(t){return t=t||16,("0000000000000000"+this.toString(t)).substr(-16)},Number.prototype.toString32=function(t){return t=t||16,("00000000"+this.toString(t)).substr(-8)},Number.prototype.toString16=function(t){return t=t||16,("0000"+this.toString(t)).substr(-4)},Number.prototype.toString8=function(t){return t=t||16,("00"+this.toString(t)).substr(-2)},Number.prototype.noExponents=function(){var t=String(this).split(/[eE]/);if(1===t.length)return t[0];var e="",r=this<0?"-":"",n=t[0].replace(".",""),i=Number(t[1])+1;if(i<0){for(e=r+"0.";i++;)e+="0";return e+n.replace(/^\-/,"")}for(i-=n.length;i--;)e+="0";return n+e},String.prototype.repeat=function(t){return new Array(t+1).join(this)},String.prototype.fromAscii=function(){for(var t="",e=0;e<this.length/2;)t+=String.fromCharCode(parseInt(this.substr(2*e,2),16)),e++;return t},String.prototype.toAscii=function(){for(var t="",e=0;e<this.length;e++)t+=this.charCodeAt(e).toString16();return t},String.prototype.toAscii8=function(){for(var t="",e=0;e<this.length;e++)t+=this.charCodeAt(e).toString8();for(var r=0;r<t.length%8;r++)t+="00";return t+"00000000"};var bigInt=function(t){var e=1e7,r=7,n=9007199254740992,i=u(n),o=Math.log(n);function s(t,e){return void 0===t?s[0]:void 0!==e?10==+e?V(t):D(t,e):V(t)}function a(t,e){this.value=t,this.sign=e,this.isSmall=!1}function c(t){this.value=t,this.sign=t<0,this.isSmall=!0}function l(t){return-n<t&&t<n}function u(t){return t<1e7?[t]:t<1e14?[t%1e7,Math.floor(t/1e7)]:[t%1e7,Math.floor(t/1e7)%1e7,Math.floor(t/1e14)]}function h(t){p(t);var r=t.length;if(r<4&&L(t,i)<0)switch(r){case 0:return 0;case 1:return t[0];case 2:return t[0]+t[1]*e;default:return t[0]+(t[1]+t[2]*e)*e}return t}function p(t){for(var e=t.length;0===t[--e];);t.length=e+1}function f(t){for(var e=new Array(t),r=-1;++r<t;)e[r]=0;return e}function g(t){return t>0?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<s;i++)c=(n=t[i]+r[i]+c)>=l?1:0,a[i]=n-c*l;for(;i<o;)c=(n=t[i]+c)===l?1:0,a[i++]=n-c*l;return c>0&&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;i<o;i++)n=t[i]-a+r,r=Math.floor(n/a),s[i]=n-r*a,r+=1;for(;r>0;)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;n<s;n++)(i=t[n]-c-r[n])<0?(i+=l,c=1):c=0,a[n]=i;for(n=s;n<o;n++){if(!((i=t[n]-c)<0)){a[n++]=i;break}i+=l,a[n]=i}for(;n<o;n++)a[n]=t[n];return p(a),a}function b(t,r,n){var i,o,s=t.length,l=new Array(s),u=-r,p=e;for(i=0;i<s;i++)o=t[i]+u,u=Math.floor(o/p),o%=p,l[i]=o<0?o+p:o;return"number"==typeof(l=h(l))?(n&&(l=-l),new c(l)):new a(l,n)}function w(t,r){var n,i,o,s,a=t.length,c=r.length,l=f(a+c),u=e;for(o=0;o<a;++o){s=t[o];for(var h=0;h<c;++h)n=s*r[h]+l[o+h],i=Math.floor(n/u),l[o+h]=n-i*u,l[o+h+1]+=i}return p(l),l}function j(t,r){var n,i,o=t.length,s=new Array(o),a=e,c=0;for(i=0;i<o;i++)n=t[i]*r+c,c=Math.floor(n/a),s[i]=n-c*a;for(;c>0;)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<e?j(r,t):w(r,u(t)),n)}function x(t){var r,n,i,o,s=t.length,a=f(s+s),c=e;for(i=0;i<s;i++){n=0-(o=t[i])*o;for(var l=i;l<s;l++)r=o*t[l]*2+a[i+l]+n,n=Math.floor(r/c),a[i+l]=r-n*c;a[i+s]=n}return p(a),a}function E(t,r){var n,i,o,s,a=t.length,c=f(a),l=e;for(o=0,n=a-1;n>=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<e){i=h((n=E(l,y))[0]);var v=n[1];return t.sign&&(v=-v),"number"==typeof i?(t.sign!==o.sign&&(i=-i),[new c(i),new c(v)]):[new a(i,t.sign!==o.sign),new c(v)]}d=u(y)}var b=L(l,d);if(-1===b)return[s[0],t];if(0===b)return[s[t.sign===o.sign?1:-1],s[0]];i=(n=l.length+d.length<=200?function(t,r){var n,i,o,s,a,c,l,u=t.length,p=r.length,g=e,d=f(r.length),y=r[p-1],v=Math.ceil(g/(2*y)),m=j(t,v),b=j(r,v);for(m.length<=u&&m.push(0),b.push(0),y=b[p-1],i=u-p;i>=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;a<c;a++)o+=n*b[a],l=Math.floor(o/g),s+=m[i+a]-(o-l*g),o=l,s<0?(m[i+a]=s+g,s=-1):(m[i+a]=s,s=0);for(;0!==s;){for(n-=1,o=0,a=0;a<c;a++)(o+=m[i+a]-g+b[a])<0?(m[i+a]=o+g,o=0):(m[i+a]=o,o=1);s+=o}d[i]=n}return m=E(m,v)[0],[h(d),h(m)]}(l,d):function(t,r){for(var n,i,o,s,a,c=t.length,l=r.length,u=[],f=[],g=e;c;)if(f.unshift(t[--c]),p(f),L(f,r)<0)u.push(0);else{o=f[(i=f.length)-1]*g+f[i-2],s=r[l-1]*g+r[l-2],i>l&&(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<e.length;i++)if(!t.lesser(e[i])&&!(o=bigInt(e[i]).modPow(c,t)).equals(s[1])&&!o.equals(a)){for(n=!0,r=c;n&&r.lesser(a);r=r.multiply(2))(o=o.square().mod(t)).equals(a)&&(n=!1);if(n)return!1}return!0}a.prototype=Object.create(s.prototype),c.prototype=Object.create(s.prototype),a.prototype.add=function(t){var e=V(t);if(this.sign!==e.sign)return this.subtract(e.negate());var r=this.value,n=e.value;return e.isSmall?new a(v(r,Math.abs(n)),this.sign):new a(y(r,n),this.sign)},a.prototype.plus=a.prototype.add,c.prototype.add=function(t){var e=V(t),r=this.value;if(r<0!==e.sign)return this.subtract(e.negate());var n=e.value;if(e.isSmall){if(l(r+n))return new c(r+n);n=u(Math.abs(n))}return new a(v(n,Math.abs(r)),r<0)},c.prototype.plus=c.prototype.add,a.prototype.subtract=function(t){var e=V(t);if(this.sign!==e.sign)return this.add(e.negate());var r=this.value,n=e.value;return e.isSmall?b(r,Math.abs(n),this.sign):function(t,e,r){var n;return L(t,e)>=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))<e)return new a(j(c,r),h);l=u(r)}return n=c.length,i=l.length,new a(-.012*n-.012*i+15e-6*n*i>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;o++)i.push(bigInt.randBetween(2,r.minus(2)));return B(r,i)},c.prototype.isProbablePrime=a.prototype.isProbablePrime,a.prototype.modInv=function(t){for(var e,r,n,i=bigInt.zero,o=bigInt.one,s=V(t),a=this.abs();!a.equals(bigInt.zero);)e=s.divide(a),r=i,n=s,i=o,s=a,o=r.subtract(e.multiply(o)),a=n.subtract(e.multiply(a));if(!s.equals(1))throw new Error(this.toString()+" and "+t.toString()+" are not co-prime");return-1===i.compare(0)&&(i=i.add(t)),this.isNegative()?i.negate():i},c.prototype.modInv=a.prototype.modInv,a.prototype.next=function(){var t=this.value;return this.sign?b(t,1,this.sign):new a(v(t,1),this.sign)},c.prototype.next=function(){var t=this.value;return t+1<n?new c(t+1):new a(i,!1)},a.prototype.prev=function(){var t=this.value;return this.sign?new a(v(t,1),!0):b(t,1,this.sign)},c.prototype.prev=function(){var t=this.value;return t-1>-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<r;i++){if("-"!==(u=t[i].toLowerCase())&&/[a-z0-9]/.test(u)){if(/[0-9]/.test(u)&&+u>=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.length;i++){var u,h=(u=t[i].toLowerCase()).charCodeAt(0);if(48<=h&&h<=57)a.push(V(u));else if(97<=h&&h<=122)a.push(V(u.charCodeAt(0)-87));else{if("<"!==u)throw new Error(u+" is not a valid character");var p=i;do{i++}while(">"!==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),p<u&&(s=!1)}return o=h(o),n.add("number"==typeof o?new c(o):new a(o,!1))},s.isUInt64=function(t){return!(!(t instanceof a||t instanceof c)||!t.hi32)},s.fromArray=function(t,e,r){return G(t.map(V),V(e||10),r)},s}();function UInt64(t,e){function r(){}r.prototype=UInt64Prototype;var n=new r;return e||(e=16),n.init(t,e),n.x64}var UInt64Prototype={init:function(t,e){var r=t;function n(t,e){if(t>64)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<h;u++)a=t[i>>>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;r<i.length;r++)i[r](e)}function C(t,e){"undefined"!=typeof window&&window.performance&&"function"==typeof window.performance.now?t.addEntropy(window.performance.now(),e,"loadtime"):t.addEntropy((new Date).valueOf(),e,"loadtime")}function y(t){t.b=z(t).concat(z(t)),t.L=new sjcl.cipher.aes(t.b)}function z(t){for(var e=0;4>e&&(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<<r)-1},concat:function(t,e){if(0===t.length||0===e.length)return t.concat(e);var r=t[t.length-1],n=sjcl.bitArray.getPartial(r);return 32===n?t.concat(e):sjcl.bitArray.$(e,n,0|r,t.slice(0,t.length-1))},bitLength:function(t){var e=t.length;return 0===e?0:32*(e-1)+sjcl.bitArray.getPartial(t[e-1])},clamp:function(t,e){if(32*t.length<e)return t;var r=(t=t.slice(0,Math.ceil(e/32))).length;return e&=31,0<r&&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<t.length;r++)n|=t[r]^e[r];return 0===n},$:function(t,e,r,n){var i;for(i=0,void 0===n&&(n=[]);32<=e;e-=32)n.push(r),r=0;if(0===e)return n.concat(t);for(i=0;i<t.length;i++)n.push(r|t[i]>>>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<e+t?r:n.pop(),1)),n},i: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<t.length;++e)r=t[e],t[e]=r>>>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<i/8;e++)0==(3&e)&&(r=t[e/4]),n+=String.fromCharCode(r>>>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<t.length;e++)n=n<<8|t.charCodeAt(e),3==(3&e)&&(r.push(n),n=0);return 3&e&&r.push(sjcl.bitArray.partial(8*(3&e),n)),r}},sjcl.codec.hex={fromBits:function(t){var e,r="";for(e=0;e<t.length;e++)r+=(0xf00000000000+(0|t[e])).toString(16).substr(4);return r.substr(0,sjcl.bitArray.bitLength(t)/4)},toBits:function(t){var e,r,n=[];for(r=(t=t.replace(/\s|0x/g,"")).length,t+="00000000",e=0;e<t.length;e+=8)n.push(0^parseInt(t.substr(e,8),16));return sjcl.bitArray.clamp(n,4*r)}},sjcl.codec.base32={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",X:"0123456789ABCDEFGHIJKLMNOPQRSTUV",BITS:32,BASE:5,REMAINING:27,fromBits:function(t,e,r){var n=sjcl.codec.base32.BASE,i=sjcl.codec.base32.REMAINING,o="",s=0,a=sjcl.codec.base32.B,c=0,l=sjcl.bitArray.bitLength(t);for(r&&(a=sjcl.codec.base32.X),r=0;o.length*n<l;)o+=a.charAt((c^t[r]>>>s)>>>i),s<n?(c=t[r]<<n-s,s+=i,r++):(c<<=n,s-=n);for(;7&o.length&&!e;)o+="=";return o},toBits:function(t,e){t=t.replace(/\s|=/g,"").toUpperCase();var r,n,i=sjcl.codec.base32.BITS,o=sjcl.codec.base32.BASE,s=sjcl.codec.base32.REMAINING,a=[],c=0,l=sjcl.codec.base32.B,u=0,h="base32";for(e&&(l=sjcl.codec.base32.X,h="base32hex"),r=0;r<t.length;r++){if(0>(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-c):u^=n<<i-(c+=o)}return 56&c&&a.push(sjcl.bitArray.partial(56&c,u,1)),a}},sjcl.codec.base32hex={fromBits:function(t,e){return sjcl.codec.base32.fromBits(t,e,1)},toBits:function(t){return sjcl.codec.base32.toBits(t,1)}},sjcl.codec.base64={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,r){var n="",i=0,o=sjcl.codec.base64.B,s=0,a=sjcl.bitArray.bitLength(t);for(r&&(o=o.substr(0,62)+"-_"),r=0;6*n.length<a;)n+=o.charAt((s^t[r]>>>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<t.length;r++){if(0>(n=s.indexOf(t.charAt(r))))throw new sjcl.exception.invalid("this isn't base64!");26<o?(o-=26,i.push(a^n>>>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;e<r.length;e+=1)r[e](t)},encrypt:function(t,e,r,n,i){var o,s=e.slice(0),a=sjcl.bitArray,c=a.bitLength(r)/8,l=a.bitLength(s)/8;if(i=i||64,n=n||[],7>c)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;e<s.length;e+=4)n=t.encrypt(c(n,s.slice(e,e+4).concat([0,0,0])));return n},V:function(t,e,r,n,i,o){var s=sjcl.bitArray,a=s.i;if((i/=8)%2||4>i||16<i)throw new sjcl.exception.invalid("ccm: invalid tag length");if(4294967295<n.length||4294967295<e.length)throw new sjcl.exception.bug("ccm: can't deal with 4GiB or more data");for(r=sjcl.mode.ccm.na(t,n,r,i,s.bitLength(e)/8,o),n=0;n<e.length;n+=4)r=t.encrypt(a(r,e.slice(n,n+4).concat([0,0,0])));return s.clamp(r,8*i)},C:function(t,e,r,n,i,o){var s,a=sjcl.bitArray;s=a.i;var c=e.length,l=a.bitLength(e),u=c/50,h=u;if(r=a.concat([a.partial(8,o-1)],r).concat([0,0,0]).slice(0,4),n=a.bitSlice(s(n,t.encrypt(r)),0,i),!c)return{tag:n,data:[]};for(s=0;s<c;s+=4)s>u&&(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+4<e.length;s+=4)u=l(u,h=e.slice(s,s+4)),p=p.concat(l(r,t.encrypt(l(r,h)))),r=a(r);return h=e.slice(s),e=c.bitLength(h),s=t.encrypt(l(r,[0,0,0,e])),u=l(u,l((h=c.clamp(l(h.concat([0,0,0]),s),e)).concat([0,0,0]),s)),u=t.encrypt(l(u,l(r,a(r)))),n.length&&(u=l(u,o?n:sjcl.mode.ocb2.pmac(t,n))),p.concat(c.concat(h,c.clamp(u,i)))},decrypt:function(t,e,r,n,i,o){if(128!==sjcl.bitArray.bitLength(r))throw new sjcl.exception.invalid("ocb iv must be 128 bits");i=i||64;var s,a,c=sjcl.mode.ocb2.S,l=sjcl.bitArray,u=l.i,h=[0,0,0,0],p=c(t.encrypt(r)),f=sjcl.bitArray.bitLength(e)-i,g=[];for(n=n||[],r=0;r+4<f/32;r+=4)h=u(h,s=u(p,t.decrypt(u(p,e.slice(r,r+4))))),g=g.concat(s),p=c(p);if(a=f-32*r,h=u(h,s=u(s=t.encrypt(u(p,[0,0,0,a])),l.clamp(e.slice(r),a).concat([0,0,0]))),h=t.encrypt(u(h,u(p,c(p)))),n.length&&(h=u(h,o?n:sjcl.mode.ocb2.pmac(t,n))),!l.equal(l.clamp(h,i),l.bitSlice(e,f)))throw new sjcl.exception.corrupt("ocb: tag doesn't match");return g.concat(l.clamp(s,a))},pmac:function(t,e){var r,n=sjcl.mode.ocb2.S,i=sjcl.bitArray,o=i.i,s=[0,0,0,0],a=o(a=t.encrypt([0,0,0,0]),n(n(a)));for(r=0;r+4<e.length;r+=4)a=n(a),s=o(s,t.encrypt(o(a,e.slice(r,r+4))));return r=e.slice(r),128>i.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<n;n--)o[n]=o[n]>>>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;n<i;n+=4)e[0]^=4294967295&r[n],e[1]^=4294967295&r[n+1],e[2]^=4294967295&r[n+2],e[3]^=4294967295&r[n+3],e=sjcl.mode.gcm.ka(e,t);return e},C:function(t,e,r,n,i,o){var s,a,c,l,u,h,p,f,g=sjcl.bitArray;for(h=r.length,p=g.bitLength(r),f=g.bitLength(n),a=g.bitLength(i),s=e.encrypt([0,0,0,0]),96===a?(i=i.slice(0),i=g.concat(i,[1])):(i=sjcl.mode.gcm.j(s,[0,0,0,0],i),i=sjcl.mode.gcm.j(s,i,[0,0,Math.floor(a/4294967296),4294967295&a])),a=sjcl.mode.gcm.j(s,[0,0,0,0],n),u=i.slice(0),n=a.slice(0),t||(n=sjcl.mode.gcm.j(s,a,r)),l=0;l<h;l+=4)u[3]++,c=e.encrypt(u),r[l]^=c[0],r[l+1]^=c[1],r[l+2]^=c[2],r[l+3]^=c[3];return r=g.clamp(r,p),t&&(n=sjcl.mode.gcm.j(s,a,r)),t=[Math.floor(f/4294967296),4294967295&f,Math.floor(p/4294967296),4294967295&p],n=sjcl.mode.gcm.j(s,n,t),c=e.encrypt(i),n[0]^=c[0],n[1]^=c[1],n[2]^=c[2],n[3]^=c[3],{tag:g.bitSlice(n,0,o),data:r}}},sjcl.misc.hmac=function(t,e){this.W=e=e||sjcl.hash.sha256;var r,n=[[],[]],i=e.prototype.blockSize/32;for(this.w=[new e,new e],t.length>i&&(t=e.hash(t)),r=0;r<i;r++)n[0][r]=909522486^t[r],n[1][r]=1549556828^t[r];this.w[0].update(n[0]),this.w[1].update(n[1]),this.R=new e(this.w[0])},sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(t){if(this.aa)throw new sjcl.exception.invalid("encrypt on already updated hmac called!");return this.update(t),this.digest(t)},sjcl.misc.hmac.prototype.reset=function(){this.R=new this.W(this.w[0]),this.aa=!1},sjcl.misc.hmac.prototype.update=function(t){this.aa=!0,this.R.update(t)},sjcl.misc.hmac.prototype.digest=function(){var t=this.R.finalize();t=new this.W(this.w[1]).update(t).finalize();return this.reset(),t},sjcl.misc.pbkdf2=function(t,e,r,n,i){if(r=r||1e4,0>n||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;s<r;s++)for(o=t.encrypt(o),a=0;a<o.length;a++)i[a]^=o[a];l=l.concat(i)}return n&&(l=u.clamp(l,n)),l},sjcl.prng=function(t){this.c=[new sjcl.hash.sha256],this.m=[0],this.P=0,this.H={},this.N=0,this.U={},this.Z=this.f=this.o=this.ha=0,this.b=[0,0,0,0,0,0,0,0],this.h=[0,0,0,0],this.L=void 0,this.M=t,this.D=!1,this.K={progress:{},seeded:{}},this.u=this.ga=0,this.I=1,this.J=2,this.ca=65536,this.T=[0,48,64,96,128,192,256,384,512,768,1024],this.da=3e4,this.ba=80},sjcl.prng.prototype={randomWords:function(t,e){var r,n,i=[];if((r=this.isReady(e))===this.u)throw new sjcl.exception.notReady("generator isn't seeded");if(r&this.J){r=!(r&this.I),n=[];var o,s=0;for(this.Z=n[0]=(new Date).valueOf()+this.da,o=0;16>o;o++)n.push(4294967296*Math.random()|0);for(o=0;o<this.c.length&&(n=n.concat(this.c[o].finalize()),s+=this.m[o],this.m[o]=0,r||!(this.P&1<<o));o++);for(this.P>=1<<this.c.length&&(this.c.push(new sjcl.hash.sha256),this.m.push(0)),this.f-=s,s>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<t;r+=4)0==(r+1)%this.ca&&y(this),n=z(this),i.push(n[0],n[1],n[2],n[3]);return y(this),i.slice(0,t)},setDefaultParanoia:function(t,e){if(0===t&&"Setting paranoia=0 will ruin your security; use it only for testing"!==e)throw new sjcl.exception.invalid("Setting paranoia=0 will ruin your security; use it only for testing");this.M=t},addEntropy:function(t,e,r){r=r||"user";var n,i,o=(new Date).valueOf(),s=this.H[r],a=this.isReady(),c=0;switch(void 0===(n=this.U[r])&&(n=this.U[r]=this.ha++),void 0===s&&(s=this.H[r]=0),this.H[r]=(this.H[r]+1)%this.c.length,typeof t){case"number":void 0===e&&(e=1),this.c[s].update([n,this.N++,1,e,o,1,0|t]);break;case"object":if("[object Uint32Array]"===(r=Object.prototype.toString.call(t))){for(i=[],r=0;r<t.length;r++)i.push(t[r]);t=i}else for("[object Array]"!==r&&(c=1),r=0;r<t.length&&!c;r++)"number"!=typeof t[r]&&(c=1);if(!c){if(void 0===e)for(r=e=0;r<t.length;r++)for(i=t[r];0<i;)e++,i>>>=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<o.length;r++)delete i[n=o[r]]},la:function(){C(this,1)},oa:function(t){var e,r;try{e=t.x||t.clientX||t.offsetX||0,r=t.y||t.clientY||t.offsetY||0}catch(t){r=e=0}0!=e&&0!=r&&this.addEntropy([e,r],2,"mouse"),C(this,0)},qa:function(t){t=t.touches[0]||t.changedTouches[0],this.addEntropy([t.pageX||t.clientX,t.pageY||t.clientY],1,"touch"),C(this,0)},ma:function(){C(this,2)},ea:function(t){if(t=t.accelerationIncludingGravity.x||t.accelerationIncludingGravity.y||t.accelerationIncludingGravity.z,window.orientation){var e=window.orientation;"number"==typeof e&&this.addEntropy(e,1,"accelerometer")}t&&this.addEntropy(t,2,"accelerometer"),C(this,0)}},sjcl.random=new sjcl.prng(6);t:try{var D,E,F,G;if(G="undefined"!=typeof module&&module.exports){var H;try{H=require("crypto")}catch(t){H=null}G=E=H}if(G&&E.randomBytes)D=E.randomBytes(128),D=new Uint32Array(new Uint8Array(D).buffer),sjcl.random.addEntropy(D,1024,"crypto['randomBytes']");else if("undefined"!=typeof window&&"undefined"!=typeof Uint32Array){if(F=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(F);else{if(!window.msCrypto||!window.msCrypto.getRandomValues)break t;window.msCrypto.getRandomValues(F)}sjcl.random.addEntropy(F,1024,"crypto['getRandomValues']")}}catch(t){"undefined"!=typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(t))}sjcl.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ja:function(t,e,r,n){r=r||{},n=n||{};var i,o=sjcl.json,s=o.g({iv:sjcl.random.randomWords(4,0)},o.defaults);if(o.g(s,r),r=s.adata,"string"==typeof s.salt&&(s.salt=sjcl.codec.base64.toBits(s.salt)),"string"==typeof s.iv&&(s.iv=sjcl.codec.base64.toBits(s.iv)),!sjcl.mode[s.mode]||!sjcl.cipher[s.cipher]||"string"==typeof t&&100>=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<s.iv.length)throw new sjcl.exception.invalid("json encrypt: invalid parameters");return"string"==typeof t?(t=(i=sjcl.misc.cachedPbkdf2(t,s)).key.slice(0,s.ks/32),s.salt=i.salt):sjcl.ecc&&t instanceof sjcl.ecc.elGamal.publicKey&&(i=t.kem(),s.kemtag=i.tag,t=i.key.slice(0,s.ks/32)),"string"==typeof e&&(e=sjcl.codec.utf8String.toBits(e)),"string"==typeof r&&(s.adata=r=sjcl.codec.utf8String.toBits(r)),i=new sjcl.cipher[s.cipher](t),o.g(n,s),n.key=t,s.ct="ccm"===s.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&e instanceof ArrayBuffer?sjcl.arrayBuffer.ccm.encrypt(i,e,s.iv,r,s.ts):sjcl.mode[s.mode].encrypt(i,e,s.iv,r,s.ts),s},encrypt:function(t,e,r,n){var i=sjcl.json,o=i.ja.apply(i,arguments);return i.encode(o)},ia:function(t,e,r,n){r=r||{},n=n||{};var i,o,s=sjcl.json;if(i=(e=s.g(s.g(s.g({},s.defaults),e),r,!0)).adata,"string"==typeof e.salt&&(e.salt=sjcl.codec.base64.toBits(e.salt)),"string"==typeof e.iv&&(e.iv=sjcl.codec.base64.toBits(e.iv)),!sjcl.mode[e.mode]||!sjcl.cipher[e.cipher]||"string"==typeof t&&100>=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<e.iv.length)throw new sjcl.exception.invalid("json decrypt: invalid parameters");return"string"==typeof t?(t=(o=sjcl.misc.cachedPbkdf2(t,e)).key.slice(0,e.ks/32),e.salt=o.salt):sjcl.ecc&&t instanceof sjcl.ecc.elGamal.secretKey&&(t=t.unkem(sjcl.codec.base64.toBits(e.kemtag)).slice(0,e.ks/32)),"string"==typeof i&&(i=sjcl.codec.utf8String.toBits(i)),o=new sjcl.cipher[e.cipher](t),i="ccm"===e.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&e.ct instanceof ArrayBuffer?sjcl.arrayBuffer.ccm.decrypt(o,e.ct,e.iv,e.tag,i,e.ts):sjcl.mode[e.mode].decrypt(o,e.ct,e.iv,i,e.ts),s.g(n,e),n.key=t,1===r.raw?i:sjcl.codec.utf8String.fromBits(i)},decrypt:function(t,e,r,n){var i=sjcl.json;return i.ia(t,i.decode(e),r,n)},encode:function(t){var e,r="{",n="";for(e in t)if(t.hasOwnProperty(e)){if(!e.match(/^[a-z0-9]+$/i))throw new sjcl.exception.invalid("json encode: invalid property name");switch(r+=n+'"'+e+'":',n=",",typeof t[e]){case"number":case"boolean":r+=t[e];break;case"string":r+='"'+escape(t[e])+'"';break;case"object":r+='"'+sjcl.codec.base64.fromBits(t[e],0)+'"';break;default:throw new sjcl.exception.bug("json encode: unsupported type")}}return r+"}"},decode:function(t){if(!(t=t.replace(/\s/g,"")).match(/^\{.*\}$/))throw new sjcl.exception.invalid("json decode: this isn't json!");t=t.replace(/^\{|\}$/g,"").split(/,/);var e,r,n={};for(e=0;e<t.length;e++){if(!(r=t[e].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i)))throw new sjcl.exception.invalid("json decode: this isn't json!");null!=r[3]?n[r[2]]=parseInt(r[3],10):null!=r[4]?n[r[2]]=r[2].match(/^(ct|adata|salt|iv)$/)?sjcl.codec.base64.toBits(r[4]):unescape(r[4]):null!=r[5]&&(n[r[2]]="true"===r[5])}return n},g:function(t,e,r){if(void 0===t&&(t={}),void 0===e)return t;for(var n in e)if(e.hasOwnProperty(n)){if(r&&void 0!==t[n]&&t[n]!==e[n])throw new sjcl.exception.invalid("required parameter overridden");t[n]=e[n]}return t},sa:function(t,e){var r,n={};for(r in t)t.hasOwnProperty(r)&&t[r]!==e[r]&&(n[r]=t[r]);return n},ra:function(t,e){var r,n={};for(r=0;r<e.length;r++)void 0!==t[e[r]]&&(n[e[r]]=t[e[r]]);return n}},sjcl.encrypt=sjcl.json.encrypt,sjcl.decrypt=sjcl.json.decrypt,sjcl.misc.pa={},sjcl.misc.cachedPbkdf2=function(t,e){var r,n=sjcl.misc.pa;return r=(e=e||{}).iter||1e3,(r=(n=n[t]=n[t]||{})[r]=n[r]||{firstSalt:e.salt&&e.salt.length?e.salt.slice(0):sjcl.random.randomWords(2,0)})[n=void 0===e.salt?r.firstSalt:e.salt]=r[n]||sjcl.misc.pbkdf2(t,n,e.iter),{key:r[n].slice(0),salt:n.slice(0)}},"undefined"!=typeof module&&module.exports&&(module.exports=sjcl),"function"==typeof define&&define([],function(){return sjcl}),sjcl.bitArray={bitSlice:function(t,e,r){return t=sjcl.bitArray._shiftRight(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<<r)-1},concat:function(t,e){if(0===t.length||0===e.length)return t.concat(e);var r=t[t.length-1],n=sjcl.bitArray.getPartial(r);return 32===n?t.concat(e):sjcl.bitArray._shiftRight(e,n,0|r,t.slice(0,t.length-1))},bitLength:function(t){var e,r=t.length;return 0===r?0:(e=t[r-1],32*(r-1)+sjcl.bitArray.getPartial(e))},clamp:function(t,e){if(32*t.length<e)return t;var r=(t=t.slice(0,Math.ceil(e/32))).length;return e&=31,r>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<t.length;r++)n|=t[r]^e[r];return 0===n},_shiftRight:function(t,e,r,n){var i,o,s;for(void 0===n&&(n=[]);e>=32;e-=32)n.push(r),r=0;if(0===e)return n.concat(t);for(i=0;i<t.length;i++)n.push(r|t[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<t.length;++e)r=t[e],t[e]=r>>>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)};