PHP WebShell

Текущая директория: /opt/BitGoJS/node_modules/secrets.js-grempe

Просмотр файла: secrets.min.js

/*! secrets.js-grempe 2015-02-28 */
// @preserve author Alexander Stetsyuk
// @preserve author Glenn Rempe <glenn@rempe.us>
// @license MIT
!function(a,b){"use strict";"function"==typeof define&&define.amd?define([],function(){return a.secrets=b()}):"object"==typeof exports?module.exports=b(require("crypto")):a.secrets=b(a.crypto)}(this,function(a){"use strict";function b(){m={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},n={},o=new Array(1024).join("0"),p=!0,q=10,r=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","browserSJCLRandom","testRandom"]}function c(){return n&&n.rng&&"function"==typeof n.rng?!0:!1}function d(a,b){var c;if(0===b||1===b)return a;if(b&&b>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return b=b||n.bits,a&&(c=a.length%b),c?(o+a).slice(-(b-c+a.length)):a}function e(a){var b,c,e="";for(c=a.length-1;c>=0;c--){if(b=parseInt(a[c],16),isNaN(b))throw new Error("Invalid hex character.");e=d(b.toString(2),4)+e}return e}function f(a){var b,c,e="";for(a=d(a,4),c=a.length;c>=4;c-=4){if(b=parseInt(a.slice(c-4,c),2),isNaN(b))throw new Error("Invalid binary character.");e=b.toString(16)+e}return e}function g(b){function c(a,b,c,e){var f,g,h=0,i="";for(b&&(f=b.length-1);f>h||i.length<a;)g=Math.abs(parseInt(b[h],c)),i+=d(g.toString(2),e),h++;return i=i.substr(-a),(i.match(/0/g)||[]).length===i.length?null:i}function e(b){var d,e,f,g,h=null;for(f=16,g=4,e=Math.ceil(b/8);null===h;)d=a.randomBytes(e),h=c(b,d.toString("hex"),f,g);return h}function f(a){var b,d,e,f=null;for(d=10,e=32,b=Math.ceil(a/32);null===f;)f=c(a,window.crypto.getRandomValues(new Uint32Array(b)),d,e);return f}function g(a){var b,d,e,f=null;if(d=10,e=32,b=Math.ceil(a/32),!sjcl.random.isReady(q))throw new Error("SJCL isn't finished seeding the RNG yet.");return f=c(a,sjcl.random.randomWords(b,q),d,e)}function h(a){var b,d,e,f,g,h=null;f=10,g=32,d=Math.ceil(a/32),e=123456789,b=new Uint32Array(d);for(var i=0;i<b.length;i++)b[i]=e;for(;null===h;)h=c(a,b,f,g);return h}return b&&"testRandom"===b?(n.typeCSPRNG=b,h):b&&"nodeCryptoRandomBytes"===b?(n.typeCSPRNG=b,e):b&&"browserCryptoGetRandomValues"===b?(n.typeCSPRNG=b,f):b&&"browserSJCLRandom"===b?(p=!1,n.typeCSPRNG=b,g):"object"==typeof a&&"function"==typeof a.randomBytes?(n.typeCSPRNG="nodeCryptoRandomBytes",e):!window||!window.crypto||"function"!=typeof window.crypto.getRandomValues&&"object"!=typeof window.crypto.getRandomValues||"function"!=typeof Uint32Array&&"object"!=typeof Uint32Array?window&&window.sjcl&&"object"==typeof window.sjcl&&"object"==typeof window.sjcl.random?(p=!1,n.typeCSPRNG="browserSJCLRandom",g):void 0:(n.typeCSPRNG="browserCryptoGetRandomValues",f)}function h(a,b){var c,e=[];for(b&&(a=d(a,b)),c=a.length;c>n.bits;c-=n.bits)e.push(parseInt(a.slice(c-n.bits,c),2));return e.push(parseInt(a.slice(0,c),2)),e}function i(a,b){var c,d=n.logs[a],e=0;for(c=b.length-1;c>=0;c--)e=0!==e?n.exps[(d+n.logs[e])%n.maxShares]^b[c]:b[c];return e}function j(a,b,c){var d,e,f,g,h=0;for(f=0,d=b.length;d>f;f++)if(c[f]){for(e=n.logs[c[f]],g=0;d>g;g++)if(f!==g){if(a===b[g]){e=-1;break}e=(e+n.logs[a^b[g]]-n.logs[b[f]^b[g]]+n.maxShares)%n.maxShares}h=-1===e?h:h^n.exps[e]}return h}function k(a,b,c){var d,e,f=[],g=[a];for(d=1;c>d;d++)g[d]=parseInt(n.rng(n.bits),2);for(d=1,e=b+1;e>d;d++)f[d-1]={x:d,y:i(d,g)};return f}function l(a,b,c){var e,f,g,h,i;if(b=parseInt(b,n.radix),a=parseInt(a,10)||n.bits,e=a.toString(36).toUpperCase(),g=Math.pow(2,a)-1,h=g.toString(n.radix).length,f=d(b.toString(n.radix),h),"number"!=typeof b||b%1!==0||1>b||b>g)throw new Error("Share id must be an integer between 1 and "+g+", inclusive.");return i=e+f+c}var m,n,o,p,q,r,s={init:function(a,d){var e,f,g=[],h=[],i=1;if(b(),a&&("number"!=typeof a||a%1!==0||a<m.minBits||a>m.maxBits))throw new Error("Number of bits must be an integer between "+m.minBits+" and "+m.maxBits+", inclusive.");if(d&&-1===r.indexOf(d))throw new Error("Invalid RNG type argument : '"+d+"'");for(n.radix=m.radix,n.bits=a||m.bits,n.size=Math.pow(2,n.bits),n.maxShares=n.size-1,e=m.primitivePolynomials[n.bits],f=0;f<n.size;f++)h[f]=i,g[i]=f,i<<=1,i>=n.size&&(i^=e,i&=n.maxShares);if(n.logs=g,n.exps=h,d&&this.setRNG(d),c()||this.setRNG(),"browserSJCLRandom"===n.typeCSPRNG&&(sjcl.random=new sjcl.prng(q),sjcl.random.startCollectors()),!(c()&&n.bits&&n.size&&n.maxShares&&n.logs&&n.exps&&n.logs.length===n.size&&n.exps.length===n.size))throw new Error("Initialization failed.")},combine:function(a,b){var c,g,i,k,l,m,o,p,q="",r=[],s=[];for(b=b||0,c=0,k=a.length;k>c;c++){if(o=this.extractShareComponents(a[c]),void 0===m)m=o.bits;else if(o.bits!==m)throw new Error("Mismatched shares: Different bit settings.");if(n.bits!==m&&this.init(m),-1===r.indexOf(o.id))for(g=r.push(o.id)-1,p=h(e(o.data)),i=0,l=p.length;l>i;i++)s[i]=s[i]||[],s[i][g]=p[i]}for(c=0,k=s.length;k>c;c++)q=d(j(b,r,s[c]).toString(2))+q;return 0===b?(g=q.indexOf("1"),f(q.slice(g+1))):f(q)},getConfig:function(){var a={};return a.radix=n.radix,a.bits=n.bits,a.maxShares=n.maxShares,a.hasCSPRNG=c(),a.typeCSPRNG=n.typeCSPRNG,a},extractShareComponents:function(a){var b,c,d,e,f,g,h={};if(b=parseInt(a.substr(0,1),36),b&&("number"!=typeof b||b%1!==0||b<m.minBits||b>m.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+m.minBits+" and "+m.maxBits+", inclusive.");if(e=Math.pow(2,b)-1,d=(Math.pow(2,b)-1).toString(n.radix).length,f="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+d+"})([a-fA-F0-9]+)$",g=new RegExp(f).exec(a),g&&(c=parseInt(g[2],n.radix)),"number"!=typeof c||c%1!==0||1>c||c>e)throw new Error("Invalid share : Share id must be an integer between 1 and "+n.maxShares+", inclusive.");if(g&&g[3])return h.bits=b,h.id=c,h.data=g[3],h;throw new Error("The share data provided is invalid : "+a)},setRNG:function(a){var b="Random number generator is invalid ",c=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(a&&"string"==typeof a&&-1===r.indexOf(a))throw new Error("Invalid RNG type argument : '"+a+"'");if(a||(a=g()),a&&"string"==typeof a&&(a=g(a)),p){if(a&&"function"!=typeof a)throw new Error(b+"(Not a function)."+c);if(a&&"string"!=typeof a(n.bits))throw new Error(b+"(Output is not a string)."+c);if(a&&!parseInt(a(n.bits),2))throw new Error(b+"(Binary string output not parseable to an Integer)."+c);if(a&&a(n.bits).length>n.bits)throw new Error(b+"(Output length is greater than config.bits)."+c);if(a&&a(n.bits).length<n.bits)throw new Error(b+"(Output length is less than config.bits)."+c)}return n.rng=a,!0},str2hex:function(a,b){var c,e,f,g,h,i,j="";if("string"!=typeof a)throw new Error("Input must be a character string.");if(b||(b=m.bytesPerChar),"number"!=typeof b||1>b||b>m.maxBytesPerChar||b%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+m.maxBytesPerChar+", inclusive.");for(c=2*b,e=Math.pow(16,c)-1,h=0,i=a.length;i>h;h++){if(g=a[h].charCodeAt(),isNaN(g))throw new Error("Invalid character: "+a[h]);if(g>e)throw f=Math.ceil(Math.log(g+1)/Math.log(256)),new Error("Invalid character code ("+g+"). Maximum allowable is 256^bytes-1 ("+e+"). To convert this character, use at least "+f+" bytes.");j=d(g.toString(16),c)+j}return j},hex2str:function(a,b){var c,e,f,g="";if("string"!=typeof a)throw new Error("Input must be a hexadecimal string.");if(b=b||m.bytesPerChar,"number"!=typeof b||b%1!==0||1>b||b>m.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+m.maxBytesPerChar+", inclusive.");for(c=2*b,a=d(a,c),e=0,f=a.length;f>e;e+=c)g=String.fromCharCode(parseInt(a.slice(e,e+c),16))+g;return g},random:function(a){if("number"!=typeof a||a%1!==0||2>a||a>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");if("browserSJCLRandom"===n.typeCSPRNG&&sjcl.random.isReady(q)<1)throw new Error("SJCL isn't finished seeding the RNG yet. Needs new entropy added or more mouse movement.");return f(n.rng(a))},share:function(a,b,c,g){var i,j,m,o,p,q=new Array(b),r=new Array(b);if(g=g||128,"string"!=typeof a)throw new Error("Secret must be a string.");if("number"!=typeof b||b%1!==0||2>b)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(b>n.maxShares)throw i=Math.ceil(Math.log(b+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To create "+b+" shares, use at least "+i+" bits.");if("number"!=typeof c||c%1!==0||2>c)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(c>n.maxShares)throw i=Math.ceil(Math.log(c+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.  To use a threshold of "+c+", use at least "+i+" bits.");if(c>b)throw new Error("Threshold number of shares was "+c+" but must be less than or equal to the "+b+" shares specified as the total to generate.");if("number"!=typeof g||g%1!==0||0>g||g>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(a="1"+e(a),a=h(a,g),m=0,p=a.length;p>m;m++)for(j=k(a[m],b,c),o=0;b>o;o++)q[o]=q[o]||j[o].x.toString(n.radix),r[o]=d(j[o].y.toString(2))+(r[o]||"");for(m=0;b>m;m++)q[m]=l(n.bits,q[m],f(r[m]));return q},newShare:function(a,b){var c;if(a&&"string"==typeof a&&(a=parseInt(a,n.radix)),a&&b&&b[0])return c=this.extractShareComponents(b[0]),l(c.bits,a,this.combine(b,a));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:b,_padLeft:d,_hex2bin:e,_bin2hex:f,_getRNG:g,_isSetRNG:c,_splitNumStringToIntArray:h,_horner:i,_lagrange:j,_getShares:k,_constructPublicShareString:l};return s.init(),s});

Выполнить команду


Для локальной разработки. Не используйте в интернете!