"use strict";var r=void 0,z=!1;var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}}; "undefined"!==typeof module&&module.exports&&(module.exports=sjcl);"function"===typeof define&&define([],function(){return sjcl}); sjcl.cipher.aes=function(a){this.l[0][0][0]||this.o();var b,c,e,d,g=this.l[0][4],f=this.l[1];b=a.length;var h=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid("invalid aes key size");this.b=[e=a.slice(0),d=[]];for(a=b;a<4*b+28;a++){c=e[a-1];if(0===a%b||8===b&&4===a%b)c=g[c>>>24]<<24^g[c>>16&255]<<16^g[c>>8&255]<<8^g[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));e[a]=e[a-b]^c}for(b=0;a;b++,a--)c=e[b&3?a:a-4],d[b]=4>=a||4>b?c:f[0][g[c>>>24]]^f[1][g[c>>16&255]]^f[2][g[c>>8&255]]^f[3][g[c& 255]]}; sjcl.cipher.aes.prototype={encrypt:function(a){return aa(this,a,0)},decrypt:function(a){return aa(this,a,1)},l:[[[],[],[],[],[]],[[],[],[],[],[]]],o:function(){var a=this.l[0],b=this.l[1],c=a[4],e=b[4],d,g,f,h=[],k=[],n,m,l,p;for(d=0;0x100>d;d++)k[(h[d]=d<<1^283*(d>>7))^d]=d;for(g=f=0;!c[g];g^=n||1,f=k[f]||1){l=f^f<<1^f<<2^f<<3^f<<4;l=l>>8^l&255^99;c[g]=l;e[l]=g;m=h[d=h[n=h[g]]];p=0x1010101*m^0x10001*d^0x101*n^0x1010100*g;m=0x101*h[l]^0x1010100*l;for(d=0;4>d;d++)a[d][g]=m=m<<24^m>>>8,b[d][l]=p=p<<24^p>>>8}for(d= 0;5>d;d++)a[d]=a[d].slice(0),b[d]=b[d].slice(0)}}; function aa(a,b,c){if(4!==b.length)throw new sjcl.exception.invalid("invalid aes block size");var e=a.b[c],d=b[0]^e[0],g=b[c?3:1]^e[1],f=b[2]^e[2];b=b[c?1:3]^e[3];var h,k,n,m=e.length/4-2,l,p=4,u=[0,0,0,0];h=a.l[c];a=h[0];var C=h[1],A=h[2],D=h[3],B=h[4];for(l=0;l>>24]^C[g>>16&255]^A[f>>8&255]^D[b&255]^e[p],k=a[g>>>24]^C[f>>16&255]^A[b>>8&255]^D[d&255]^e[p+1],n=a[f>>>24]^C[b>>16&255]^A[d>>8&255]^D[g&255]^e[p+2],b=a[b>>>24]^C[d>>16&255]^A[g>>8&255]^D[f&255]^e[p+3],p+=4,d=h,g=k,f=n;for(l= 0;4>l;l++)u[c?3&-l:l]=B[d>>>24]<<24^B[g>>16&255]<<16^B[f>>8&255]<<8^B[b&255]^e[p++],h=d,d=g,g=f,f=b,b=h;return u} sjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.K(a.slice(b/32),32-(b&31)).slice(1);return c===r?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var e=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-e^a[b/32+1|0]>>>e:a[b/32|0]>>>e)&(1<>b-1,1));return a},partial:function(a,b,c){return 32===a?b:(c?b|0:b<<32-a)+0x10000000000*a},getPartial:function(a){return Math.round(a/0x10000000000)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return z;var c=0,e;for(e=0;e>>b),c=a[d]<<32-b;d=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(d);e.push(sjcl.bitArray.partial(b+a&31,32>>24|c>>>8&0xff00|(c&0xff00)<<8|c<<24;return a}}; sjcl.codec.utf8String={fromBits:function(a){var b="",c=sjcl.bitArray.bitLength(a),e,d;for(e=0;e>>24),d<<=8;return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,e=0;for(c=0;c>>d)>>>26),6>d?(f=a[c]<<6-d,d+=26,c++):(f<<=6,d-=6);for(;e.length&3&&!b;)e+="=";return e},toBits:function(a,b){a=a.replace(/\s|=/g,"");var c=[],e,d=0,g=sjcl.codec.base64.F,f=0,h;b&&(g=g.substr(0,62)+"-_");for(e=0;eh)throw new sjcl.exception.invalid("this isn't base64!");26>>d),f=h<<32-d):(d+=6,f^=h<<32-d)}d&56&&c.push(sjcl.bitArray.partial(d&56,f,1));return c}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}}; sjcl.codec.bytes={fromBits:function(a){var b=[],c=sjcl.bitArray.bitLength(a),e,d;for(e=0;e>>24),d<<=8;return b},toBits:function(a){var b=[],c,e=0;for(c=0;cb;c++){for(e=2;e*e<=c;e++)if(0===c%e)continue a;8>b&&(this.i[b]=a(Math.pow(c,0.5)));this.b[b]=a(Math.pow(c,1/3));b++}},n:function(a){var b,c,e=a.slice(0),d=this.e,g=this.b,f=d[0],h=d[1],k=d[2],n=d[3],m=d[4],l=d[5],p=d[6],u=d[7];for(a=0;64>a;a++)16>a?b=e[a]:(b=e[a+1&15],c=e[a+14&15],b=e[a&15]=(b>>>7^b>>>18^b>>>3^ b<<25^b<<14)+(c>>>17^c>>>19^c>>>10^c<<15^c<<13)+e[a&15]+e[a+9&15]|0),b=b+u+(m>>>6^m>>>11^m>>>25^m<<26^m<<21^m<<7)+(p^m&(l^p))+g[a],u=p,p=l,l=m,m=n+b|0,n=k,k=h,h=f,f=b+(h&k^n&(h^k))+(h>>>2^h>>>13^h>>>22^h<<30^h<<19^h<<10)|0;d[0]=d[0]+f|0;d[1]=d[1]+h|0;d[2]=d[2]+k|0;d[3]=d[3]+n|0;d[4]=d[4]+m|0;d[5]=d[5]+l|0;d[6]=d[6]+p|0;d[7]=d[7]+u|0}};sjcl.hash.sha512=function(a){this.b[0]||this.o();a?(this.e=a.e.slice(0),this.d=a.d.slice(0),this.c=a.c):this.reset()};sjcl.hash.sha512.hash=function(a){return(new sjcl.hash.sha512).update(a).finalize()}; sjcl.hash.sha512.prototype={blockSize:1024,reset:function(){this.e=this.i.slice(0);this.d=[];this.c=0;return this},update:function(a){"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));var b,c=this.d=sjcl.bitArray.concat(this.d,a);b=this.c;a=this.c=b+sjcl.bitArray.bitLength(a);for(b=1024+b&-1024;b<=a;b+=1024)this.n(c.splice(0,32));return this},finalize:function(){var a,b=this.d,c=this.e,b=sjcl.bitArray.concat(b,[sjcl.bitArray.partial(1,1)]);for(a=b.length+4;a&31;a++)b.push(0);b.push(0);b.push(0); b.push(Math.floor(this.c/0x100000000));for(b.push(this.c|0);b.length;)this.n(b.splice(0,32));this.reset();return c},i:[],S:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],U:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366, 7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],o:function(){function a(a){return 0x100000000*(a-Math.floor(a))|0}function b(a){return 0x10000000000*(a-Math.floor(a))&255}var c=0,e=2,d;a:for(;80> c;e++){for(d=2;d*d<=e;d++)if(0===e%d)continue a;8>c&&(this.i[2*c]=a(Math.pow(e,0.5)),this.i[2*c+1]=b(Math.pow(e,0.5))<<24|this.S[c]);this.b[2*c]=a(Math.pow(e,1/3));this.b[2*c+1]=b(Math.pow(e,1/3))<<24|this.U[c];c++}},n:function(a){var b,c,e=a.slice(0),d=this.e,g=this.b,f=d[0],h=d[1],k=d[2],n=d[3],m=d[4],l=d[5],p=d[6],u=d[7],C=d[8],A=d[9],D=d[10],B=d[11],ea=d[12],P=d[13],fa=d[14],Q=d[15],v=f,s=h,G=k,E=n,H=m,F=l,V=p,I=u,w=C,t=A,R=D,J=B,S=ea,K=P,W=fa,L=Q;for(a=0;80>a;a++){if(16>a)b=e[2*a],c=e[2*a+1]; else{c=e[2*(a-15)];var q=e[2*(a-15)+1];b=(q<<31|c>>>1)^(q<<24|c>>>8)^c>>>7;var x=(c<<31|q>>>1)^(c<<24|q>>>8)^(c<<25|q>>>7);c=e[2*(a-2)];var y=e[2*(a-2)+1],q=(y<<13|c>>>19)^(c<<3|y>>>29)^c>>>6,y=(c<<13|y>>>19)^(y<<3|c>>>29)^(c<<26|y>>>6),X=e[2*(a-7)],Y=e[2*(a-16)],M=e[2*(a-16)+1];c=x+e[2*(a-7)+1];b=b+X+(c>>>0>>0?1:0);c+=y;b+=q+(c>>>0>>0?1:0);c+=M;b+=Y+(c>>>0>>0?1:0)}e[2*a]=b|=0;e[2*a+1]=c|=0;var X=w&R^~w&S,ga=t&J^~t&K,y=v&G^v&H^G&H,ka=s&E^s&F^E&F,Y=(s<<4|v>>>28)^(v<<30|s>>>2)^(v<<25|s>>>7), M=(v<<4|s>>>28)^(s<<30|v>>>2)^(s<<25|v>>>7),la=g[2*a],ha=g[2*a+1],q=L+((w<<18|t>>>14)^(w<<14|t>>>18)^(t<<23|w>>>9)),x=W+((t<<18|w>>>14)^(t<<14|w>>>18)^(w<<23|t>>>9))+(q>>>0>>0?1:0),q=q+ga,x=x+(X+(q>>>0>>0?1:0)),q=q+ha,x=x+(la+(q>>>0>>0?1:0)),q=q+c|0,x=x+(b+(q>>>0>>0?1:0));c=M+ka;b=Y+y+(c>>>0>>0?1:0);W=S;L=K;S=R;K=J;R=w;J=t;t=I+q|0;w=V+x+(t>>>0>>0?1:0)|0;V=H;I=F;H=G;F=E;G=v;E=s;s=q+c|0;v=x+b+(s>>>0>>0?1:0)|0}h=d[1]=h+s|0;d[0]=f+v+(h>>>0>>0?1:0)|0;n=d[3]=n+E|0;d[2]=k+G+(n>>> 0>>0?1:0)|0;l=d[5]=l+F|0;d[4]=m+H+(l>>>0>>0?1:0)|0;u=d[7]=u+I|0;d[6]=p+V+(u>>>0>>0?1:0)|0;A=d[9]=A+t|0;d[8]=C+w+(A>>>0>>0?1:0)|0;B=d[11]=B+J|0;d[10]=D+R+(B>>>0>>0?1:0)|0;P=d[13]=P+K|0;d[12]=ea+S+(P>>>0>>0?1:0)|0;Q=d[15]=Q+L|0;d[14]=fa+W+(Q>>>0>>0?1:0)|0}}; sjcl.mode.ccm={name:"ccm",q:[],listenProgress:function(a){sjcl.mode.ccm.q.push(a)},unListenProgress:function(a){a=sjcl.mode.ccm.q.indexOf(a);-1k)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(g=2;4>g&&n>>>8*g;g++);g<15-k&&(g=15-k);c=h.clamp(c, 8*(15-g));b=sjcl.mode.ccm.H(a,b,c,e,d,g);f=sjcl.mode.ccm.I(a,f,c,b,d,g);return h.concat(f.data,f.tag)},decrypt:function(a,b,c,e,d){d=d||64;e=e||[];var g=sjcl.bitArray,f=g.bitLength(c)/8,h=g.bitLength(b),k=g.clamp(b,h-d),n=g.bitSlice(b,h-d),h=(h-d)/8;if(7>f)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(b=2;4>b&&h>>>8*b;b++);b<15-f&&(b=15-f);c=g.clamp(c,8*(15-b));k=sjcl.mode.ccm.I(a,k,c,n,d,b);a=sjcl.mode.ccm.H(a,k.data,c,e,d,b);if(!g.equal(k.tag,a))throw new sjcl.exception.corrupt("ccm: tag doesn't match"); return k.data},W:function(a,b,c,e,d,g){var f=[],h=sjcl.bitArray,k=h.C;e=[h.partial(8,(b.length?64:0)|e-2<<2|g-1)];e=h.concat(e,c);e[3]|=d;e=a.encrypt(e);if(b.length){c=h.bitLength(b)/8;65279>=c?f=[h.partial(16,c)]:0xffffffff>=c&&(f=h.concat([h.partial(16,65534)],[c]));f=h.concat(f,b);for(b=0;bd||16m&&(sjcl.mode.ccm.P(f/ k),m+=l),c[3]++,d=a.encrypt(c),b[f]^=d[0],b[f+1]^=d[1],b[f+2]^=d[2],b[f+3]^=d[3];return{tag:e,data:h.clamp(b,n)}}};sjcl.prng=function(a){this.f=[new sjcl.hash.sha256];this.j=[0];this.B=0;this.r={};this.A=0;this.G={};this.J=this.g=this.k=this.R=0;this.b=[0,0,0,0,0,0,0,0];this.h=[0,0,0,0];this.v=r;this.w=a;this.p=z;this.u={progress:{},seeded:{}};this.m=this.Q=0;this.s=1;this.t=2;this.M=0x10000;this.D=[0,48,64,96,128,192,0x100,384,512,768,1024];this.N=3E4;this.L=80}; sjcl.prng.prototype={randomWords:function(a,b){var c=[],e;e=this.isReady(b);var d;if(e===this.m)throw new sjcl.exception.notReady("generator isn't seeded");if(e&this.t){e=!(e&this.s);d=[];var g=0,f;this.J=d[0]=(new Date).valueOf()+this.N;for(f=0;16>f;f++)d.push(0x100000000*Math.random()|0);for(f=0;f=1<this.k&&(this.k= g);this.B++;this.b=sjcl.hash.sha256.hash(this.b.concat(d));this.v=new sjcl.cipher.aes(this.b);for(e=0;4>e&&!(this.h[e]=this.h[e]+1|0,this.h[e]);e++);}for(e=0;e>>=1;this.f[f].update([e,this.A++,2,b,g,a.length].concat(a))}break;case "string":b===r&&(b=a.length);this.f[f].update([e,this.A++,3,b,g,a.length]);this.f[f].update(a);break;default:k=1}if(k)throw new sjcl.exception.bug("random: addEntropy only supports number, array of numbers or string");this.j[f]+=b;this.g+=b;h===this.m&&(this.isReady()!==this.m&&ca("seeded",Math.max(this.k,this.g)),ca("progress",this.getProgress()))},isReady:function(a){a=this.D[a!==r?a:this.w]; return this.k&&this.k>=a?this.j[0]>this.L&&(new Date).valueOf()>this.J?this.t|this.s:this.s:this.g>=a?this.t|this.m:this.m},getProgress:function(a){a=this.D[a?a:this.w];return this.k>=a?1:this.g>a?1:this.g/a},startCollectors:function(){if(!this.p){this.a={loadTimeCollector:O(this,this.V),mouseCollector:O(this,this.X),keyboardCollector:O(this,this.T),accelerometerCollector:O(this,this.O),touchCollector:O(this,this.Y)};if(window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector, z),window.addEventListener("mousemove",this.a.mouseCollector,z),window.addEventListener("keypress",this.a.keyboardCollector,z),window.addEventListener("devicemotion",this.a.accelerometerCollector,z),window.addEventListener("touchmove",this.a.touchCollector,z);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new sjcl.exception.bug("can't attach event"); this.p=!0}},stopCollectors:function(){this.p&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,z),window.removeEventListener("mousemove",this.a.mouseCollector,z),window.removeEventListener("keypress",this.a.keyboardCollector,z),window.removeEventListener("devicemotion",this.a.accelerometerCollector,z),window.removeEventListener("touchmove",this.a.touchCollector,z)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove", this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.p=z)},addEventListener:function(a,b){this.u[a][this.Q++]=b},removeEventListener:function(a,b){var c,e,d=this.u[a],g=[];for(e in d)d.hasOwnProperty(e)&&d[e]===b&&g.push(e);for(c=0;cb&&!(a.h[b]=a.h[b]+1|0,a.h[b]);b++);return a.v.encrypt(a.h)}function O(a,b){return function(){b.apply(a,arguments)}}sjcl.random=new sjcl.prng(6); a:try{var U,Z,$,da;if(da="undefined"!==typeof module){var ia;if(ia=module.exports){var ja;try{ja=require("crypto")}catch(ma){ja=null}ia=(Z=ja)&&Z.randomBytes}da=ia}if(da)U=Z.randomBytes(128),U=new Uint32Array((new Uint8Array(U)).buffer),sjcl.random.addEntropy(U,1024,"crypto['randomBytes']");else if("undefined"!==typeof window&&"undefined"!==typeof Uint32Array){$=new Uint32Array(32);if(window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues($);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues($); else break a;sjcl.random.addEntropy($,1024,"crypto['getRandomValues']")}}catch(na){"undefined"!==typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(na))};