├── TheGalacticLotteryScript.html ├── README.md ├── TheGalacticLotteryScript.js ├── hashfunctions.js └── BigInteger.min.js /TheGalacticLotteryScript.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | The Galactic Lottery and Satoshi Lost Keys - Run Script 9 | 10 | 11 |
12 |
13 |
14 |
15 |
16 |
17 |

terminal

18 |
19 |
timer: ::: 20 |
21 |
22 |
23 |
24 |
number of trials:   0 25 |
26 |
27 |
    28 |
  • in case the script finds a match to one of satoshi's lost private keys, the script will print the winning private key in bitcoin WIF format and finish running. to claim your reward copy the winning private key and restore it on any bitcoin wallet.
  • 29 |   30 |
  • for more information about the galactic lottery script you can read our white paper or audit the script on github.
  • 31 |
32 |
33 |
34 |
35 | 36 |
37 |
38 |

BE AN AWESOME CYBER GALACTIC FRIEND AND DONATE SOME BITCOIN.

39 | 40 |
41 |
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Galactic Lottery Script! 2 | 3 | 4 | 5 | to see the implementation of the galactic lottery script: http://www.thegalacticlottery.com/script/ 6 |
7 | 8 |   9 |
Abstract: The website “The Galactic Lottery and Satoshi’s Lost Keys" offers users (regardless of religion, race, sex, or technological background) a chance to try their luck in uncovering Satoshi’s lost keys. The website is completely free, and connectable via any personal computer or smartphone. If the user's computer successfully guesses Satoshi's private key, that user becomes Satoshi himself !!!The user gains the opportunity to copy the private key that he uncovered, to restore it in any ordinary Bitcoin wallet, and to unlock the lost Bitcoins that are stored in that private key.
10 |
11 |   12 |
13 | 14 | On 31 October 2008, an unknown human being, known to the virtual community as the venerable Satoshi Nakamoto, published a white paper (much like this one) in a Cryptographic Mailing List. This white paper described a new project on which this admired personality was working on: Bitcoin, A Peer-to-Peer Electronic Cash System. 15 | 16 | Unlike any financial system hitherto (or henceforth) known to humanity, the system that Satoshi created does not require any central body in order to function. It is not dependent upon a central bank, a private bank, a proprietary Ltd., a Switzerland-based company with the word “foundation” in it, a company with a BitLicense, a private person, galactic aliens, or God. Satoshi’s white paper contained strong words such as: peer-to-peer, double spend, block, hash, proof of work, CPU, merkel brunch, nodes, network, digital signatures, and more. 17 | 18 | When the Bitcoin system first launched into the open cyberspace, Satoshi was the only one using it ?. Satoshi performed an action called Mining, which earned him fifty new Bitcoins every ten minutes, adding to the economic circulation he himself founded. He stored these Bitcoins in different wallets with different public addresses in order to give the impression that there were many different Bitcoin users (Satoshi was something of sneaky bastard). This went on for a long period of time, and Satoshi produced more than 20,000 such Bitcoin addresses, nearly all of which still contain fifty Bitcoins. Satoshi currently holds more than a million Bitcoins in his various wallets, accounting for 6% of the total amount of Bitcoins in circulation, an estimated $15,000,000,000 (as of the 2018th year of our Lord, the late Jesus). 19 | 20 | The mysterious personality named Satoshi Nakamoto is most likely no longer with us/ has lost all his private keys to his Bitcoin accounts and committed suicide/ is afraid to use the Bitcoins and thus to expose his secret identity. 21 | 22 | The Galactic Lottery Team saw fit to create a platform that makes it possible for people with no background in statistics whatsoever to try and uncover Satoshi's private keys, and to participate in the most brutal Brute Force in the history of mankind. This idea first came from the following mathematical equation: 23 |
D2+U2+M2+B2 = G2
24 |   25 |
D = Basic lack of understanding in statistics,U =  unexploited resources of private computers,M =  desire to get rich and get there fast, B =  luck, G =  Genius. 26 | (The power 2* is intended to illustrate that this is a bona fide  mathematical equation.)
27 |   28 | 29 | How does the Galactic Lottery actually work? 30 | 31 | 32 | We created a database using a very simple script. Looking at Bitcoin’s transaction history, we copied  all the public keys that were loaded with fifty Bitcoins, which were mined directly from blocks #1 (Genesis Block) thru  #25,000. The absolute vast majority of these keys belong to the so-called Satoshi Nakamoto, and contain fifty Bitcoins to this day. The following key is an example: 33 | 34 | 35 |
1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb
36 | 37 | 38 | For convenience, we converted all the public addresses to a Hexadecimal format (base 16) and dropped the "00" prefix that characterizes all public valid keys on the Bitcoin network (this prefix causes all public addresses in WIF format to begin with the number “1”). Here is how it looks like: 39 | 40 | 41 |
42 | 43 | b3407d4b4d1fca87fb930abe3fa6c2baed6e6fd8 44 |
The main script is quite simple:
45 |   46 |
    47 |
  • The browser generates a pseudo-random number from 0 to n / 100.
  • 48 |
  • Converts the decimal number to a hexadecimal format.
  • 49 |
  • Generates a public key according to the elliptic curve secp265k1.
  • 50 |
  • Enters the full public key of the two coordinates (x, y) into a one-way function called sha256.
  • 51 |
  • Enters the result into another one-way function called ripemd160.
  • 52 |
  • Determines whether the result matches one of the keys in the database. If it is a match, the script stops running, and prints the winning private key to the user. You now have access to a Satoshi private key!
  • 53 |
  • If the public key does not exist in the database, the script adds (+1) to the number last tested, and repeats the process. This process is repeated 100 times.
  • 54 |
  • If no match is made within the created range of 100 private keys, the entire script is repeated with a new pseudo-random number.
  • 55 |
56 |   57 |
58 | 59 | The reason we only target Satoshi's keys, and not all Bitcoin keys, is efficiency. We have no desire to run a huge database on a server that would cost a lot of money and would require unnecessary communication between the user and the server. By having the user's browser download a small database containing the Satoshi keys alone, the user can produce and test a much greater amount of private addresses per second than he would if he were using a huge database or a communication-requiring server that contains a huge database. 60 | 61 | Because the user's chances of actually finding one of Satoshi’s private keys are possible but insignificant, we decided not to write a code that would steal the private key from that lucky user. Not only that, but because we are nice and because we don’t really care, we allow users to go on the website on their browsers, disconnect from the Internet, and search for the keys locally. 62 | 63 | What’s in it for us?  The most valuable thing in the world: Fame and Glory! We advocate contributing to the Bitcoin ecosystem, and doing so with a tint of humor. We will be placing advertisements on the website in order to finance our server and domain expenses. For this same reason, a Bitcoin address for contributions will also be posted. We should also mention that we have very low standards, and that we will be willing to sell the platform to the highest bidder (in Bitcoin), and even to sell-out for a financial gain. 64 | 65 |   66 | 67 | Yours Truly, 68 | 69 | The GoingCrypto Crew 70 | 71 | 72 | BE A GALACTIC FRIEND AND DONATE SOME BITCOIN: 12sdX7hw9ZiquKPtzdPDsYuBiSs42t4ov8 73 | 74 |
75 |
76 |
-------------------------------------------------------------------------------- /TheGalacticLotteryScript.js: -------------------------------------------------------------------------------- 1 | 2 | /*FOR ALL THE GALACTIC FRIENDS OUT.. FUCK THE GALACTIC FEDERATION!!!!/* 3 | 4 | ******************************************************************************** 5 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 6 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMO$$777IIII777$$ZZZ8MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 7 | MMMMMMMMMMMMMMMMMMMMMMMMMMO$7?==?I7$77$7777777777$ZZONMMMMMMMMMMMMMMMMMMMMMMMMMM 8 | MMMMMMMMMMMMMMMMMMMMMMNZ7?~=7$$$$$$$$$$777777777$$77$$ZONMMMMMMMMMMMMMMMMMMMMMMM 9 | MMMMMMMMMMMMMMMMMMMMO$?:=7$$$$$$$$$$$$$7777777777777$$$$ZO8MMMMMMMMMMMMMMMMMMMMM 10 | MMMMMMMMMMMMMMMMMMO$~,7$$$$$$$$$$$$$$$$$777777777777777$$$ZO8MMMMMMMMMMMMMMMMMMM 11 | MMMMMMMMMMMMMMMMM$+,$$$$$$$$$$$$$$$$$$$$$77777777777777777$$Z8MMMMMMMMMMMMMMMMMM 12 | MMMMMMMMMMMMMMMM$:?$$$$$$$$$$$$$$$$$$$$$$$777777777777777777$ZODMMMMMMMMMMMMMMMM 13 | MMMMMMMMMMMMMMD7,I$$$$$$$$$$$$$$$$$$$$$$$$$777777777777777777$Z8NMMMMMMMMMMMMMMM 14 | MMMMMMMMMMMMMM7,$$$$$$$$$$$$$$$$$$$$$$$$$$$$777777777777777777$Z8NMMMMMMMMMMMMMM 15 | MMMMMMMMMMMMM$:7$$$$$$$$$$$$$$$$$$$$$$$$$$$$7777777777777777777$ODMMMMMMMMMMMMMM 16 | MMMMMMMMMMMMZ+?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$777777777777777777$ZONMMMMMMMMMMMMM 17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MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 54 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 55 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 56 | ******************************************************************************** 57 | 58 | /* PRINT TO DIV FUNCTIONS*/ 59 | function print(str){ 60 | $('#myLog').append('
'); 61 | $('#myLog div:last').text(str) ; 62 | var objDiv = document.getElementById("myLog"); 63 | objDiv.scrollTop = objDiv.scrollHeight; 64 | linecount = linecount+1; 65 | if(linecount>100){ 66 | $("#myLog div").first().remove(); 67 | } 68 | return (linecount); 69 | } 70 | 71 | function printN(str){ 72 | $('#keyCountS').text(str) ; 73 | } 74 | 75 | /* TIMER*/ 76 | var daysLabel = document.getElementById("days"); 77 | var hoursLabel = document.getElementById("hours"); 78 | var minutesLabel = document.getElementById("minutes"); 79 | var secondsLabel = document.getElementById("seconds"); 80 | var totalSeconds = 0; 81 | setInterval(setTime, 1000); 82 | function setTime() { 83 | ++totalSeconds; 84 | secondsLabel.innerHTML = pad(totalSeconds % 60); 85 | var minu = Math.floor(totalSeconds/60); 86 | minutesLabel.innerHTML = pad(minu % 60); 87 | var hou = Math.floor(totalSeconds/60/60); 88 | hoursLabel.innerHTML = pad(hou % 24); 89 | daysLabel.innerHTML = pad(parseInt(totalSeconds/ 86400)); 90 | } 91 | function pad(val) { 92 | var valString = val + ""; 93 | if (valString.length < 2) { 94 | return "0" + valString; 95 | } 96 | else { 97 | return valString; 98 | } 99 | } 100 | 101 | /*ELLIPTIC CURVE SECP256K*/ 102 | Pcurve = bigInt("115792089237316195423570985008687907853269984665640564039457584007908834671663"); 103 | N= bigInt("115792089237316195423570985008687907852837564279074904382605163141518161494337"); 104 | Acurve = bigInt("0"); Bcurve = bigInt("7"); 105 | Gx = bigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"); 106 | Gy = bigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"); 107 | var GPoint = [Gx,Gy]; 108 | var stop = 0; 109 | 110 | function modinv(a,n){ 111 | lm = 1; 112 | hm = 0; 113 | low1 = bigInt(a).mod(bigInt(n)); 114 | low2 = bigInt(low1).add(bigInt(n)); 115 | low = bigInt(low2).mod(bigInt(n)); 116 | high = bigInt(n); 117 | while (bigInt(low).compare(bigInt(1)) == 1){ 118 | ratio = bigInt(high).divide(bigInt(low)); 119 | nm1 = bigInt(lm).multiply(bigInt(ratio)); 120 | nm = bigInt(hm).subtract(bigInt(nm1)); 121 | new2 = bigInt(low).multiply(bigInt(ratio)); 122 | new1 = bigInt(high).subtract(new2); 123 | high = bigInt(low); 124 | hm = bigInt(lm); 125 | lm = bigInt(nm); 126 | low = bigInt(new1); 127 | } 128 | re1 = bigInt(lm).mod(bigInt(n)); 129 | re2 = bigInt(re1).add(bigInt(n)); 130 | re = bigInt(re2).mod(bigInt(n)); 131 | return (re); 132 | } 133 | 134 | function ECadd(a,b){ 135 | b0 = bigInt(b[0]); 136 | b1 = bigInt(b[1]); 137 | a0 = bigInt(a[0]); 138 | a1 = bigInt(a[1]); 139 | LamAdd1 = bigInt(b1).subtract(bigInt(a1)); 140 | LamAdd2 = bigInt(b0).subtract(bigInt(a0)); 141 | LamAdd3 = modinv(bigInt(LamAdd2),bigInt(Pcurve)); 142 | LamAdd4 = bigInt(LamAdd1).multiply(bigInt(LamAdd3)); 143 | LamAdd5 = bigInt(LamAdd4).mod(bigInt(Pcurve)); 144 | LamAdd6 = bigInt(LamAdd5).add(bigInt(Pcurve)); 145 | LamAdd = bigInt(LamAdd6).mod(bigInt(Pcurve)); 146 | x1 = bigInt(LamAdd).multiply(bigInt(LamAdd)); 147 | x2 = bigInt(x1).subtract(bigInt(a0)); 148 | x3 = bigInt(x2).subtract(bigInt(b0)); 149 | x4 = bigInt(x3).mod(bigInt(Pcurve)); 150 | x5 = bigInt(x4).add(bigInt(Pcurve)); 151 | x = bigInt(x5).mod(bigInt(Pcurve)); 152 | y1 = bigInt(a0).subtract(bigInt(x)); 153 | y2 = bigInt(LamAdd).multiply(bigInt(y1)); 154 | y3 = bigInt(y2).subtract(bigInt(a1)); 155 | y4 = bigInt(y3).mod(bigInt(Pcurve)); 156 | y5 = bigInt(y4).add(bigInt(Pcurve)); 157 | y = bigInt(y5).mod(bigInt(Pcurve)); 158 | return [x,y]; 159 | } 160 | 161 | function ECdouble(a){ 162 | a0 = bigInt(a[0]); 163 | a1 = bigInt(a[1]); 164 | lamA1 = bigInt(3).multiply(a0); 165 | lamA2 = bigInt(lamA1).multiply(bigInt(a0)); 166 | lamA3 = bigInt(lamA2).add(bigInt(Acurve)); 167 | lamB1 = bigInt(2).multiply(bigInt(a1)); 168 | lamB2 = modinv(bigInt(lamB1),bigInt(Pcurve)); 169 | lamB3 = bigInt(lamB2).multiply(bigInt(lamA3)); 170 | Lam1 = bigInt(lamB3).mod(bigInt(Pcurve)); 171 | Lam2 = bigInt(Lam1).add(bigInt(Pcurve)); 172 | Lam = bigInt(Lam2).mod(bigInt(Pcurve)); 173 | x1 = bigInt(Lam).multiply(bigInt(Lam)); 174 | x2 = bigInt(2).multiply(bigInt(a[0])); 175 | x3 = bigInt(x1).subtract(bigInt(x2)); 176 | x4 = bigInt(x3).mod(bigInt(Pcurve)); 177 | x5 = bigInt(x4).add(bigInt(Pcurve)); 178 | x = bigInt(x5).mod(bigInt(Pcurve)); 179 | y1 = bigInt(a[0]).subtract(bigInt(x)); 180 | y2 = bigInt(Lam).multiply(bigInt(y1)); 181 | y3 = bigInt(y2).subtract(bigInt(a[1])); 182 | y4 = bigInt(y3).mod(bigInt(Pcurve)); 183 | y5 = bigInt(y4).add(bigInt(Pcurve)); 184 | y = bigInt(y5).mod(bigInt(Pcurve)); 185 | return [x,y]; 186 | }; 187 | 188 | 189 | function EccMultiply(GenPoint,Scalar){ 190 | ScalarSub = bigInt(N).subtract(Scalar); 191 | if (bigInt(N).compare(Scalar) == -1 || bigInt(Scalar).compare(0) == 0){ 192 | print("Invalid Private Key"); 193 | } 194 | else{ 195 | ScalarBin = bigInt(Scalar).toString(2); 196 | var Q=GenPoint; 197 | var i = 1; 198 | while (i < ScalarBin.length){ 199 | Q=ECdouble(bigInt(Q)); 200 | if (ScalarBin[i] == "1"){ 201 | Q=ECadd(bigInt(Q),bigInt(GenPoint)); 202 | } 203 | var i = i+1; 204 | } 205 | return (Q); 206 | } 207 | } 208 | 209 | 210 | /*pseudo-random function*/ 211 | function randomval(){ 212 | array = new Uint8Array(totalBytesf); 213 | var crypto = window.crypto || window.msCrypto; 214 | randomNum = crypto.getRandomValues(array); 215 | var wloop = 1; 216 | var sumBytes = randomNum[0].toString(16); 217 | while (bigInt(totalBytesf).subtract(wloop)>0){ 218 | sumBytes = sumBytes.concat(randomNum[wloop].toString(16)); 219 | wloop = bigInt(wloop).add(1); 220 | } 221 | window.sumBytesf=sumBytes; 222 | } 223 | 224 | 225 | /*PRIVATE KEY DEC2WIF*/ 226 | function privDec2Wif(dec){ 227 | privBin= dec.toString(2); 228 | prifix = "10000000"; 229 | prepend0a= 256-privBin.length; 230 | prepend0b= prifix.concat(Array(prepend0a + 1).join("0"),privBin); 231 | bin2Hex= bigInt(prepend0b, 2).toString(16); 232 | binDecode= hex2a(bin2Hex); 233 | sha256x1 = SHA256(binDecode); 234 | binDecodesha= hex2a(sha256x1); 235 | sha256x2 = SHA256(binDecodesha); 236 | checksum = sha256x2.substr(0, 8); 237 | prewif= bin2Hex.concat(checksum); 238 | privWif = enc64_58(prewif); 239 | 240 | return (privWif); 241 | } 242 | 243 | 244 | /*START FUNCTION*/ 245 | function start1(){ 246 | blockSize = bigInt("100"); 247 | blocklimit = bigInt(N).divide(blockSize); 248 | blocklimitHex = blocklimit.toString(16); 249 | totalBytes = blocklimit.toString(16).length; 250 | if (totalBytes % 2 == 0){ 251 | totalBytesf= (totalBytes)/2; 252 | firstByte = blocklimitHex.charAt(0)+blocklimitHex.charAt(1); 253 | firstByte1 = parseInt(firstByte, 16); 254 | priHex = (Math.floor(Math.random() * firstByte1) + 0).toString(16); 255 | } 256 | else{ 257 | totalBytesf =(totalBytes-1)/2; 258 | firstByte = blocklimitHex.charAt(0); 259 | firstByte1 = parseInt(firstByte, 16); 260 | priHex = (Math.floor(Math.random() * firstByte1) + 0).toString(16); 261 | } 262 | randomval(totalBytesf); 263 | userInputHex = priHex.concat(sumBytesf); 264 | userInput = bigInt(userInputHex,16); 265 | if (bigInt(userInput).subtract(blocklimit)>0){ 266 | start1(); 267 | } 268 | else { 269 | blockNumber = userInput; 270 | } 271 | } 272 | 273 | 274 | /*MAIN FUNCTION*/ 275 | function hashing(){ 276 | start1() 277 | var loopCount = blockSize; 278 | startRangeMul = bigInt(blockNumber).multiply(blockSize); 279 | startRange = bigInt(startRangeMul).add("1"); 280 | endRange =bigInt(startRange).add(blockSize); 281 | var key = startRange; 282 | var y =0; 283 | print("******************************************************************"); 284 | var sVar = setInterval(function(){ 285 | if (loopCount<1 && y<1) { 286 | clearInterval(sVar); 287 | hashing(); 288 | } 289 | PublicKey = EccMultiply(bigInt(GPoint),bigInt(key)); 290 | uncompress = "04" + bigInt(PublicKey[0]).toString(16) + PublicKey[1].toString(16); 291 | uncompressbin = hex2a(uncompress); 292 | outputsha256 = SHA256(uncompressbin); 293 | outbin = hex2a(outputsha256); 294 | outputripemd160 = RMDstring(outbin); 295 | if (satoshiKeys.indexOf(outputripemd160) != -1){ 296 | lr = bigInt(key); 297 | lt = "It's a Match!!!!!!"; 298 | text= "Private Key Decimal: "; 299 | text1= "Private Key WIF: "; 300 | y = y+1; 301 | print("*********************************************************"); 302 | print(lt); 303 | print(text.concat(lr)); 304 | print(text1.concat(privDec2Wif(bigInt(key)))); 305 | clearInterval(sVar); 306 | } 307 | else{ 308 | lr = bigInt(key); 309 | lt = "No Match!"; 310 | n= n+1; 311 | text= "Private Key Decimal: "; 312 | text1= "Public Key Hex: "; 313 | print(text.concat(lr)); 314 | print(text1.concat(outputripemd160)); 315 | print(lt); 316 | print("."); 317 | printN(n); 318 | } 319 | key = bigInt(key).add("1"); 320 | loopCount = bigInt(loopCount).subtract("1"); 321 | return [key,loopCount,y,n]; 322 | },0); 323 | }; 324 | 325 | 326 | /*TRIGGER*/ 327 | var linecount = 0; 328 | var n =0; 329 | hashing(); 330 | 331 | 332 | 333 | 334 | -------------------------------------------------------------------------------- /hashfunctions.js: -------------------------------------------------------------------------------- 1 | 2 | function hex2a(hex) { 3 | var str = ''; 4 | for (var i = 0; i < hex.length; i += 2) str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); 5 | return str; 6 | } 7 | 8 | 9 | function SHA256(s){ 10 | var chrsz = 8; 11 | var hexcase = 0; 12 | 13 | function safe_add (x, y) { 14 | var lsw = (x & 0xFFFF) + (y & 0xFFFF); 15 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16); 16 | return (msw << 16) | (lsw & 0xFFFF); 17 | } 18 | 19 | 20 | 21 | 22 | function S (X, n) { return ( X >>> n ) | (X << (32 - n)); } 23 | function R (X, n) { return ( X >>> n ); } 24 | function Ch(x, y, z) { return ((x & y) ^ ((~x) & z)); } 25 | function Maj(x, y, z) { return ((x & y) ^ (x & z) ^ (y & z)); } 26 | function Sigma0256(x) { return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); } 27 | function Sigma1256(x) { return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); } 28 | function Gamma0256(x) { return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); } 29 | function Gamma1256(x) { return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); } 30 | 31 | 32 | 33 | 34 | function core_sha256 (m, l) { 35 | var K = new Array(0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0xFC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x6CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2); 36 | var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19); 37 | var W = new Array(64); 38 | var a, b, c, d, e, f, g, h, i, j; 39 | var T1, T2; 40 | m[l >> 5] |= 0x80 << (24 - l % 32); 41 | m[((l + 64 >> 9) << 4) + 15] = l; 42 | for ( var i = 0; i>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32); 85 | } 86 | return bin; 87 | } 88 | 89 | 90 | 91 | 92 | function Utf8Encode(string) { 93 | string = string.replace(/\r\n/g,"\n"); 94 | var utftext = ""; 95 | for (var n = 0; n < string.length; n++) { 96 | var c = string.charCodeAt(n); 97 | if (c < 128) { 98 | utftext += String.fromCharCode(c); 99 | } 100 | else if((c > 127) && (c < 2048)) { 101 | utftext += String.fromCharCode((c >> 6) | 192); 102 | utftext += String.fromCharCode((c & 63) | 128); 103 | } 104 | else { 105 | utftext += String.fromCharCode((c >> 12) | 224); 106 | utftext += String.fromCharCode(((c >> 6) & 63) | 128); 107 | utftext += String.fromCharCode((c & 63) | 128); 108 | } 109 | } 110 | return utftext; 111 | } 112 | 113 | 114 | function binb2hex (binarray) { 115 | var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; 116 | var str = ""; 117 | for(var i = 0; i < binarray.length * 4; i++) { 118 | str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + 119 | hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF); 120 | } 121 | return str; 122 | } 123 | 124 | 125 | return binb2hex(core_sha256(str2binb(s), s.length * chrsz)); 126 | } 127 | 128 | 129 | var RMDsize = 160; 130 | var X = new Array(); 131 | 132 | function ROL(x, n){ 133 | return new Number ((x << n) | ( x >>> (32 - n))); 134 | } 135 | 136 | function F(x, y, z){ 137 | return new Number(x ^ y ^ z); 138 | } 139 | 140 | function G(x, y, z){ 141 | return new Number((x & y) | (~x & z)); 142 | } 143 | 144 | function H(x, y, z){ 145 | return new Number((x | ~y) ^ z); 146 | } 147 | 148 | function I(x, y, z){ 149 | return new Number((x & z) | (y & ~z)); 150 | } 151 | 152 | function J(x, y, z){ 153 | return new Number(x ^ (y | ~z)); 154 | } 155 | 156 | function mixOneRound(a, b, c, d, e, x, s, roundNumber){ 157 | switch (roundNumber){ 158 | case 0 : a += F(b, c, d) + x + 0x00000000; break; 159 | case 1 : a += G(b, c, d) + x + 0x5a827999; break; 160 | case 2 : a += H(b, c, d) + x + 0x6ed9eba1; break; 161 | case 3 : a += I(b, c, d) + x + 0x8f1bbcdc; break; 162 | case 4 : a += J(b, c, d) + x + 0xa953fd4e; break; 163 | case 5 : a += J(b, c, d) + x + 0x50a28be6; break; 164 | case 6 : a += I(b, c, d) + x + 0x5c4dd124; break; 165 | case 7 : a += H(b, c, d) + x + 0x6d703ef3; break; 166 | case 8 : a += G(b, c, d) + x + 0x7a6d76e9; break; 167 | case 9 : a += F(b, c, d) + x + 0x00000000; break; 168 | default : document.write("Bogus round number"); break; 169 | } 170 | a = ROL(a, s) + e; 171 | c = ROL(c, 10); 172 | a &= 0xffffffff; 173 | b &= 0xffffffff; 174 | c &= 0xffffffff; 175 | d &= 0xffffffff; 176 | e &= 0xffffffff; 177 | var retBlock = new Array(); 178 | retBlock[0] = a; 179 | retBlock[1] = b; 180 | retBlock[2] = c; 181 | retBlock[3] = d; 182 | retBlock[4] = e; 183 | retBlock[5] = x; 184 | retBlock[6] = s; 185 | return retBlock; 186 | } 187 | 188 | function MDinit (MDbuf){ 189 | MDbuf[0] = 0x67452301; 190 | MDbuf[1] = 0xefcdab89; 191 | MDbuf[2] = 0x98badcfe; 192 | MDbuf[3] = 0x10325476; 193 | MDbuf[4] = 0xc3d2e1f0; 194 | } 195 | 196 | var ROLs = [ 197 | [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8], 198 | [ 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12], 199 | [11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5], 200 | [11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12], 201 | [ 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6], 202 | [ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6], 203 | [ 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11], 204 | [ 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5], 205 | [15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8], 206 | [ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11] 207 | ]; 208 | var indexes = [ 209 | [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 210 | [ 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8], 211 | [ 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12], 212 | [ 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2], 213 | [ 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13], 214 | [ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12], 215 | [ 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2], 216 | [15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13], 217 | [ 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14], 218 | [12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11] 219 | ]; 220 | 221 | function compress (MDbuf, X){ 222 | blockA = new Array(); 223 | blockB = new Array(); 224 | var retBlock; 225 | for (var i=0; i < 5; i++){ 226 | blockA[i] = new Number(MDbuf[i]); 227 | blockB[i] = new Number(MDbuf[i]); 228 | } 229 | var step = 0; 230 | for (var j = 0; j < 5; j++){ 231 | for (var i = 0; i < 16; i++){ 232 | retBlock = mixOneRound( 233 | blockA[(step+0) % 5], 234 | blockA[(step+1) % 5], 235 | blockA[(step+2) % 5], 236 | blockA[(step+3) % 5], 237 | blockA[(step+4) % 5], 238 | X[indexes[j][i]], 239 | ROLs[j][i], 240 | j 241 | ); 242 | blockA[(step+0) % 5] = retBlock[0]; 243 | blockA[(step+1) % 5] = retBlock[1]; 244 | blockA[(step+2) % 5] = retBlock[2]; 245 | blockA[(step+3) % 5] = retBlock[3]; 246 | blockA[(step+4) % 5] = retBlock[4]; 247 | step += 4; 248 | } 249 | } 250 | step = 0; 251 | for (var j = 5; j < 10; j++){ 252 | for (var i = 0; i < 16; i++){ 253 | retBlock = mixOneRound( 254 | blockB[(step+0) % 5], 255 | blockB[(step+1) % 5], 256 | blockB[(step+2) % 5], 257 | blockB[(step+3) % 5], 258 | blockB[(step+4) % 5], 259 | X[indexes[j][i]], 260 | ROLs[j][i], 261 | j 262 | ); 263 | blockB[(step+0) % 5] = retBlock[0]; 264 | blockB[(step+1) % 5] = retBlock[1]; 265 | blockB[(step+2) % 5] = retBlock[2]; 266 | blockB[(step+3) % 5] = retBlock[3]; 267 | blockB[(step+4) % 5] = retBlock[4]; 268 | step += 4; 269 | } 270 | } 271 | blockB[3] += blockA[2] + MDbuf[1]; 272 | MDbuf[1] = MDbuf[2] + blockA[3] + blockB[4]; 273 | MDbuf[2] = MDbuf[3] + blockA[4] + blockB[0]; 274 | MDbuf[3] = MDbuf[4] + blockA[0] + blockB[1]; 275 | MDbuf[4] = MDbuf[0] + blockA[1] + blockB[2]; 276 | MDbuf[0] = blockB[3]; 277 | } 278 | 279 | function zeroX(X) 280 | { 281 | for (var i = 0; i < 16; i++) { X[i] = 0; } 282 | } 283 | 284 | function MDfinish (MDbuf, strptr, lswlen, mswlen) 285 | { 286 | var X = new Array(16); 287 | zeroX(X); 288 | 289 | var j = 0; 290 | for (var i=0; i < (lswlen & 63); i++) 291 | { 292 | X[i >>> 2] ^= (strptr.charCodeAt(j++) & 255) << (8 * (i & 3)); 293 | } 294 | 295 | X[(lswlen >>> 2) & 15] ^= 1 << (8 * (lswlen & 3) + 7); 296 | 297 | if ((lswlen & 63) > 55) 298 | { 299 | compress(MDbuf, X); 300 | var X = new Array(16); 301 | zeroX(X); 302 | } 303 | 304 | X[14] = lswlen << 3; 305 | X[15] = (lswlen >>> 29) | (mswlen << 3); 306 | 307 | compress(MDbuf, X); 308 | } 309 | 310 | function BYTES_TO_DWORD(fourChars) 311 | { 312 | var tmp = (fourChars.charCodeAt(3) & 255) << 24; 313 | tmp |= (fourChars.charCodeAt(2) & 255) << 16; 314 | tmp |= (fourChars.charCodeAt(1) & 255) << 8; 315 | tmp |= (fourChars.charCodeAt(0) & 255); 316 | 317 | return tmp; 318 | } 319 | 320 | function RMD(message) 321 | { 322 | var MDbuf = new Array(RMDsize / 32); 323 | var hashcode = new Array(RMDsize / 8); 324 | var length; 325 | var nbytes; 326 | 327 | MDinit(MDbuf); 328 | length = message.length; 329 | 330 | var X = new Array(16); 331 | zeroX(X); 332 | 333 | var j=0; 334 | for (var nbytes=length; nbytes > 63; nbytes -= 64) 335 | { 336 | for (var i=0; i < 16; i++) 337 | { 338 | X[i] = BYTES_TO_DWORD(message.substr(j, 4)); 339 | j += 4; 340 | } 341 | compress(MDbuf, X); 342 | } 343 | 344 | MDfinish(MDbuf, message.substr(j), length, 0); 345 | 346 | for (var i=0; i < RMDsize / 8; i += 4) 347 | { 348 | hashcode[i] = MDbuf[i >>> 2] & 255; 349 | hashcode[i+1] = (MDbuf[i >>> 2] >>> 8) & 255; 350 | hashcode[i+2] = (MDbuf[i >>> 2] >>> 16) & 255; 351 | hashcode[i+3] = (MDbuf[i >>> 2] >>> 24) & 255; 352 | } 353 | 354 | return hashcode; 355 | } 356 | 357 | function toHex32(x) 358 | { 359 | var hexChars = "0123456789abcdef"; 360 | var hex = ""; 361 | 362 | for (var i = 0; i < 2; i++) 363 | { 364 | hex = String(hexChars.charAt(x & 0xf)).concat(hex); 365 | x >>>= 4; 366 | } 367 | 368 | return hex; 369 | } 370 | 371 | function toRMDstring(hashcode) 372 | { 373 | var retString = ""; 374 | 375 | for (var i=0; i < RMDsize/8; i++) 376 | { 377 | retString += toHex32(hashcode[i]); 378 | } 379 | 380 | return retString; 381 | } 382 | 383 | 384 | function RMDstring(message) 385 | { 386 | var hashcode = RMD(message); 387 | var retString = ""; 388 | 389 | for (var i=0; i < RMDsize/8; i++) 390 | { 391 | retString += toHex32(hashcode[i]); 392 | } 393 | 394 | return retString; 395 | } 396 | 397 | 398 | 399 | function enc64_58(entrada) { 400 | var test_max_val = 0; 401 | var ALPHABET_16 = '0123456789ABCDEF'; 402 | var ALPHABET_58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; 403 | var ALP_16_MAP = {}; 404 | var array_64 = []; 405 | var array_58 = []; 406 | for (var i = 0; i < ALPHABET_16.length; i++) ALP_16_MAP[ALPHABET_16.charAt(i)] = i; // Ini alphabet map array 407 | entrada = entrada.toUpperCase(); 408 | 409 | for (var t = entrada.length - 1; t >= 0; t = t - 3) { 410 | if (t > 1) var hex1 = ALP_16_MAP[entrada.charAt(t - 2)]; else var hex1 = 0; 411 | if (t > 0) var hex2 = ALP_16_MAP[entrada.charAt(t - 1)]; else var hex2 = 0; 412 | var tiple_hex = (hex1 * 256) + (hex2 * 16) + ALP_16_MAP[entrada.charAt(t)]; 413 | var low_val = tiple_hex % 64; 414 | var hig_val = tiple_hex >> 6; 415 | array_64.unshift(low_val); 416 | if (hig_val > 0 || t > 2) array_64.unshift(hig_val); 417 | } 418 | array_64.reverse(); 419 | var output_base = 58; 420 | for (var base = 63; base >= output_base; base--) { 421 | 422 | array_58 = []; for (var t = 0; t < array_64.length; t++) array_58.push(0); 423 | var buffer_mult = $.extend(true, [], array_58); 424 | buffer_mult[0] = 1; 425 | 426 | for (var cdig = 0; cdig < buffer_mult.length; cdig++) { 427 | 428 | for (var t = cdig; t > 0; t--) buffer_mult[t] += (buffer_mult[t - 1] || 0); 429 | 430 | for (var t = 0; t < cdig; t++) { 431 | if (buffer_mult[t] >= base) { 432 | var carry_v = 0; 433 | var q = t; 434 | do { 435 | buffer_mult[q] += carry_v; 436 | if (q < cdig - 1) { 437 | carry_v = Math.floor(buffer_mult[q] / base); 438 | buffer_mult[q] %= base; 439 | } else { carry_v = 0; } 440 | q++; 441 | } while (carry_v > 0); 442 | } 443 | } 444 | 445 | for (var t = 0; t < buffer_mult.length; t++) { 446 | var carry_v = buffer_mult[t] * (array_64[cdig] || 0); 447 | var q = t; 448 | while (carry_v > 0) { 449 | if (q >= array_58.length) array_58.push(0); 450 | array_58[q] += carry_v; 451 | carry_v = Math.floor(array_58[q] / base); 452 | array_58[q] %= base; 453 | q++; 454 | } 455 | } 456 | } 457 | array_64 = $.extend(true, [], array_58); 458 | } 459 | array_58.reverse(); 460 | var string_result = ''; 461 | for (var t = 0; t < array_58.length; t++) string_result += ALPHABET_58.charAt(array_58[t]); 462 | return string_result; 463 | } 464 | function set_random_val(long_bytes) { 465 | var res = ''; 466 | for (var t = 0; t < long_bytes; t++) { 467 | val_byte = Math.floor(Math.random() * 256); 468 | if (val_byte < 16) res += '0'; 469 | res += val_byte.toString(16); 470 | } 471 | $('#id_input_addres').val(res); 472 | } 473 | -------------------------------------------------------------------------------- /BigInteger.min.js: -------------------------------------------------------------------------------- 1 | var bigInt=function(undefined){"use strict";var BASE=1e7,LOG_BASE=7,MAX_INT=9007199254740992,MAX_INT_ARR=smallToArray(MAX_INT),LOG_MAX_INT=Math.log(MAX_INT);function Integer(v,radix){if(typeof v==="undefined")return Integer[0];if(typeof radix!=="undefined")return+radix===10?parseValue(v):parseBase(v,radix);return parseValue(v)}function BigInteger(value,sign){this.value=value;this.sign=sign;this.isSmall=false}BigInteger.prototype=Object.create(Integer.prototype);function SmallInteger(value){this.value=value;this.sign=value<0;this.isSmall=true}SmallInteger.prototype=Object.create(Integer.prototype);function isPrecise(n){return-MAX_INT0)return Math.floor(n);return Math.ceil(n)}function add(a,b){var l_a=a.length,l_b=b.length,r=new Array(l_a),carry=0,base=BASE,sum,i;for(i=0;i=base?1:0;r[i]=sum-carry*base}while(i0)r.push(carry);return r}function addAny(a,b){if(a.length>=b.length)return add(a,b);return add(b,a)}function addSmall(a,carry){var l=a.length,r=new Array(l),base=BASE,sum,i;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}BigInteger.prototype.add=function(v){var n=parseValue(v);if(this.sign!==n.sign){return this.subtract(n.negate())}var a=this.value,b=n.value;if(n.isSmall){return new BigInteger(addSmall(a,Math.abs(b)),this.sign)}return new BigInteger(addAny(a,b),this.sign)};BigInteger.prototype.plus=BigInteger.prototype.add;SmallInteger.prototype.add=function(v){var n=parseValue(v);var a=this.value;if(a<0!==n.sign){return this.subtract(n.negate())}var b=n.value;if(n.isSmall){if(isPrecise(a+b))return new SmallInteger(a+b);b=smallToArray(Math.abs(b))}return new BigInteger(addSmall(b,Math.abs(a)),a<0)};SmallInteger.prototype.plus=SmallInteger.prototype.add;function subtract(a,b){var a_l=a.length,b_l=b.length,r=new Array(a_l),borrow=0,base=BASE,i,difference;for(i=0;i=0){value=subtract(a,b)}else{value=subtract(b,a);sign=!sign}value=arrayToSmall(value);if(typeof value==="number"){if(sign)value=-value;return new SmallInteger(value)}return new BigInteger(value,sign)}function subtractSmall(a,b,sign){var l=a.length,r=new Array(l),carry=-b,base=BASE,i,difference;for(i=0;i=0)};SmallInteger.prototype.minus=SmallInteger.prototype.subtract;BigInteger.prototype.negate=function(){return new BigInteger(this.value,!this.sign)};SmallInteger.prototype.negate=function(){var sign=this.sign;var small=new SmallInteger(-this.value);small.sign=!sign;return small};BigInteger.prototype.abs=function(){return new BigInteger(this.value,false)};SmallInteger.prototype.abs=function(){return new SmallInteger(Math.abs(this.value))};function multiplyLong(a,b){var a_l=a.length,b_l=b.length,l=a_l+b_l,r=createArray(l),base=BASE,product,carry,i,a_i,b_j;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}function shiftLeft(x,n){var r=[];while(n-- >0)r.push(0);return r.concat(x)}function multiplyKaratsuba(x,y){var n=Math.max(x.length,y.length);if(n<=30)return multiplyLong(x,y);n=Math.ceil(n/2);var b=x.slice(n),a=x.slice(0,n),d=y.slice(n),c=y.slice(0,n);var ac=multiplyKaratsuba(a,c),bd=multiplyKaratsuba(b,d),abcd=multiplyKaratsuba(addAny(a,b),addAny(c,d));var product=addAny(addAny(ac,shiftLeft(subtract(subtract(abcd,ac),bd),n)),shiftLeft(bd,2*n));trim(product);return product}function useKaratsuba(l1,l2){return-.012*l1-.012*l2+15e-6*l1*l2>0}BigInteger.prototype.multiply=function(v){var n=parseValue(v),a=this.value,b=n.value,sign=this.sign!==n.sign,abs;if(n.isSmall){if(b===0)return Integer[0];if(b===1)return this;if(b===-1)return this.negate();abs=Math.abs(b);if(abs=0;shift--){quotientDigit=base-1;if(remainder[shift+b_l]!==divisorMostSignificantDigit){quotientDigit=Math.floor((remainder[shift+b_l]*base+remainder[shift+b_l-1])/divisorMostSignificantDigit)}carry=0;borrow=0;l=divisor.length;for(i=0;ib_l){highx=(highx+1)*base}guess=Math.ceil(highx/highy);do{check=multiplySmall(b,guess);if(compareAbs(check,part)<=0)break;guess--}while(guess);result.push(guess);part=subtract(part,check)}result.reverse();return[arrayToSmall(result),arrayToSmall(part)]}function divModSmall(value,lambda){var length=value.length,quotient=createArray(length),base=BASE,i,q,remainder,divisor;remainder=0;for(i=length-1;i>=0;--i){divisor=remainder*base+value[i];q=truncate(divisor/lambda);remainder=divisor-q*lambda;quotient[i]=q|0}return[quotient,remainder|0]}function divModAny(self,v){var value,n=parseValue(v);var a=self.value,b=n.value;var quotient;if(b===0)throw new Error("Cannot divide by zero");if(self.isSmall){if(n.isSmall){return[new SmallInteger(truncate(a/b)),new SmallInteger(a%b)]}return[Integer[0],self]}if(n.isSmall){if(b===1)return[self,Integer[0]];if(b==-1)return[self.negate(),Integer[0]];var abs=Math.abs(b);if(absb.length?1:-1}for(var i=a.length-1;i>=0;i--){if(a[i]!==b[i])return a[i]>b[i]?1:-1}return 0}BigInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall)return 1;return compareAbs(a,b)};SmallInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=Math.abs(this.value),b=n.value;if(n.isSmall){b=Math.abs(b);return a===b?0:a>b?1:-1}return-1};BigInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(this.sign!==n.sign){return n.sign?1:-1}if(n.isSmall){return this.sign?-1:1}return compareAbs(a,b)*(this.sign?-1:1)};BigInteger.prototype.compareTo=BigInteger.prototype.compare;SmallInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall){return a==b?0:a>b?1:-1}if(a<0!==n.sign){return a<0?-1:1}return a<0?1:-1};SmallInteger.prototype.compareTo=SmallInteger.prototype.compare;BigInteger.prototype.equals=function(v){return this.compare(v)===0};SmallInteger.prototype.eq=SmallInteger.prototype.equals=BigInteger.prototype.eq=BigInteger.prototype.equals;BigInteger.prototype.notEquals=function(v){return this.compare(v)!==0};SmallInteger.prototype.neq=SmallInteger.prototype.notEquals=BigInteger.prototype.neq=BigInteger.prototype.notEquals;BigInteger.prototype.greater=function(v){return this.compare(v)>0};SmallInteger.prototype.gt=SmallInteger.prototype.greater=BigInteger.prototype.gt=BigInteger.prototype.greater;BigInteger.prototype.lesser=function(v){return this.compare(v)<0};SmallInteger.prototype.lt=SmallInteger.prototype.lesser=BigInteger.prototype.lt=BigInteger.prototype.lesser;BigInteger.prototype.greaterOrEquals=function(v){return this.compare(v)>=0};SmallInteger.prototype.geq=SmallInteger.prototype.greaterOrEquals=BigInteger.prototype.geq=BigInteger.prototype.greaterOrEquals;BigInteger.prototype.lesserOrEquals=function(v){return this.compare(v)<=0};SmallInteger.prototype.leq=SmallInteger.prototype.lesserOrEquals=BigInteger.prototype.leq=BigInteger.prototype.lesserOrEquals;BigInteger.prototype.isEven=function(){return(this.value[0]&1)===0};SmallInteger.prototype.isEven=function(){return(this.value&1)===0};BigInteger.prototype.isOdd=function(){return(this.value[0]&1)===1};SmallInteger.prototype.isOdd=function(){return(this.value&1)===1};BigInteger.prototype.isPositive=function(){return!this.sign};SmallInteger.prototype.isPositive=function(){return this.value>0};BigInteger.prototype.isNegative=function(){return this.sign};SmallInteger.prototype.isNegative=function(){return this.value<0};BigInteger.prototype.isUnit=function(){return false};SmallInteger.prototype.isUnit=function(){return Math.abs(this.value)===1};BigInteger.prototype.isZero=function(){return false};SmallInteger.prototype.isZero=function(){return this.value===0};BigInteger.prototype.isDivisibleBy=function(v){var n=parseValue(v);var value=n.value;if(value===0)return false;if(value===1)return true;if(value===2)return this.isEven();return this.mod(n).equals(Integer[0])};SmallInteger.prototype.isDivisibleBy=BigInteger.prototype.isDivisibleBy;function isBasicPrime(v){var n=v.abs();if(n.isUnit())return false;if(n.equals(2)||n.equals(3)||n.equals(5))return true;if(n.isEven()||n.isDivisibleBy(3)||n.isDivisibleBy(5))return false;if(n.lesser(25))return true}BigInteger.prototype.isPrime=function(){var isPrime=isBasicPrime(this);if(isPrime!==undefined)return isPrime;var n=this.abs(),nPrev=n.prev();var a=[2,3,5,7,11,13,17,19],b=nPrev,d,t,i,x;while(b.isEven())b=b.divide(2);for(i=0;i-MAX_INT)return new SmallInteger(value-1);return new BigInteger(MAX_INT_ARR,true)};var powersOfTwo=[1];while(2*powersOfTwo[powersOfTwo.length-1]<=BASE)powersOfTwo.push(2*powersOfTwo[powersOfTwo.length-1]);var powers2Length=powersOfTwo.length,highestPower2=powersOfTwo[powers2Length-1];function shift_isSmall(n){return(typeof n==="number"||typeof n==="string")&&+Math.abs(n)<=BASE||n instanceof BigInteger&&n.value.length<=1}BigInteger.prototype.shiftLeft=function(n){if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}n=+n;if(n<0)return this.shiftRight(-n);var result=this;while(n>=powers2Length){result=result.multiply(highestPower2);n-=powers2Length-1}return result.multiply(powersOfTwo[n])};SmallInteger.prototype.shiftLeft=BigInteger.prototype.shiftLeft;BigInteger.prototype.shiftRight=function(n){var remQuo;if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}n=+n;if(n<0)return this.shiftLeft(-n);var result=this;while(n>=powers2Length){if(result.isZero())return result;remQuo=divModAny(result,highestPower2);result=remQuo[1].isNegative()?remQuo[0].prev():remQuo[0];n-=powers2Length-1}remQuo=divModAny(result,powersOfTwo[n]);return remQuo[1].isNegative()?remQuo[0].prev():remQuo[0]};SmallInteger.prototype.shiftRight=BigInteger.prototype.shiftRight;function bitwise(x,y,fn){y=parseValue(y);var xSign=x.isNegative(),ySign=y.isNegative();var xRem=xSign?x.not():x,yRem=ySign?y.not():y;var xDigit=0,yDigit=0;var xDivMod=null,yDivMod=null;var result=[];while(!xRem.isZero()||!yRem.isZero()){xDivMod=divModAny(xRem,highestPower2);xDigit=xDivMod[1].toJSNumber();if(xSign){xDigit=highestPower2-1-xDigit}yDivMod=divModAny(yRem,highestPower2);yDigit=yDivMod[1].toJSNumber();if(ySign){yDigit=highestPower2-1-yDigit}xRem=xDivMod[0];yRem=yDivMod[0];result.push(fn(xDigit,yDigit))}var sum=fn(xSign?1:0,ySign?1:0)!==0?bigInt(-1):bigInt(0);for(var i=result.length-1;i>=0;i-=1){sum=sum.multiply(highestPower2).add(bigInt(result[i]))}return sum}BigInteger.prototype.not=function(){return this.negate().prev()};SmallInteger.prototype.not=BigInteger.prototype.not;BigInteger.prototype.and=function(n){return bitwise(this,n,function(a,b){return a&b})};SmallInteger.prototype.and=BigInteger.prototype.and;BigInteger.prototype.or=function(n){return bitwise(this,n,function(a,b){return a|b})};SmallInteger.prototype.or=BigInteger.prototype.or;BigInteger.prototype.xor=function(n){return bitwise(this,n,function(a,b){return a^b})};SmallInteger.prototype.xor=BigInteger.prototype.xor;var LOBMASK_I=1<<30,LOBMASK_BI=(BASE&-BASE)*(BASE&-BASE)|LOBMASK_I;function roughLOB(n){var v=n.value,x=typeof v==="number"?v|LOBMASK_I:v[0]+v[1]*BASE|LOBMASK_BI;return x&-x}function max(a,b){a=parseValue(a);b=parseValue(b);return a.greater(b)?a:b}function min(a,b){a=parseValue(a);b=parseValue(b);return a.lesser(b)?a:b}function gcd(a,b){a=parseValue(a).abs();b=parseValue(b).abs();if(a.equals(b))return a;if(a.isZero())return b;if(b.isZero())return a;var c=Integer[1],d,t;while(a.isEven()&&b.isEven()){d=Math.min(roughLOB(a),roughLOB(b));a=a.divide(d);b=b.divide(d);c=c.multiply(d)}while(a.isEven()){a=a.divide(roughLOB(a))}do{while(b.isEven()){b=b.divide(roughLOB(b))}if(a.greater(b)){t=b;b=a;a=t}b=b.subtract(a)}while(!b.isZero());return c.isUnit()?a:a.multiply(c)}function lcm(a,b){a=parseValue(a).abs();b=parseValue(b).abs();return a.divide(gcd(a,b)).multiply(b)}function randBetween(a,b){a=parseValue(a);b=parseValue(b);var low=min(a,b),high=max(a,b);var range=high.subtract(low).add(1);if(range.isSmall)return low.add(Math.floor(Math.random()*range));var length=range.value.length-1;var result=[],restricted=true;for(var i=length;i>=0;i--){var top=restricted?range.value[i]:BASE;var digit=truncate(Math.random()*top);result.unshift(digit);if(digit=absBase){if(c==="1"&&absBase===1)continue;throw new Error(c+" is not a valid digit in base "+base+".")}else if(c.charCodeAt(0)-87>=absBase){throw new Error(c+" is not a valid digit in base "+base+".")}}}if(2<=base&&base<=36){if(length<=LOG_MAX_INT/Math.log(base)){var result=parseInt(text,base);if(isNaN(result)){throw new Error(c+" is not a valid digit in base "+base+".")}return new SmallInteger(parseInt(text,base))}}base=parseValue(base);var digits=[];var isNegative=text[0]==="-";for(i=isNegative?1:0;i");digits.push(parseValue(text.slice(start+1,i)))}else throw new Error(c+" is not a valid character")}return parseBaseFromArray(digits,base,isNegative)};function parseBaseFromArray(digits,base,isNegative){var val=Integer[0],pow=Integer[1],i;for(i=digits.length-1;i>=0;i--){val=val.add(digits[i].times(pow));pow=pow.times(base)}return isNegative?val.negate():val}function stringify(digit){var v=digit.value;if(typeof v==="number")v=[v];if(v.length===1&&v[0]<=35){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(v[0])}return"<"+v+">"}function toBase(n,base){base=bigInt(base);if(base.isZero()){if(n.isZero())return"0";throw new Error("Cannot convert nonzero numbers to base 0.")}if(base.equals(-1)){if(n.isZero())return"0";if(n.isNegative())return new Array(1-n).join("10");return"1"+new Array(+n).join("01")}var minusSign="";if(n.isNegative()&&base.isPositive()){minusSign="-";n=n.abs()}if(base.equals(1)){if(n.isZero())return"0";return minusSign+new Array(+n+1).join(1)}var out=[];var left=n,divmod;while(left.isNegative()||left.compareAbs(base)>=0){divmod=left.divmod(base);left=divmod.quotient;var digit=divmod.remainder;if(digit.isNegative()){digit=base.minus(digit).abs();left=left.next()}out.push(stringify(digit))}out.push(stringify(left));return minusSign+out.reverse().join("")}BigInteger.prototype.toString=function(radix){if(radix===undefined)radix=10;if(radix!==10)return toBase(this,radix);var v=this.value,l=v.length,str=String(v[--l]),zeros="0000000",digit;while(--l>=0){digit=String(v[l]);str+=zeros.slice(digit.length)+digit}var sign=this.sign?"-":"";return sign+str};SmallInteger.prototype.toString=function(radix){if(radix===undefined)radix=10;if(radix!=10)return toBase(this,radix);return String(this.value)};BigInteger.prototype.toJSON=SmallInteger.prototype.toJSON=function(){return this.toString()};BigInteger.prototype.valueOf=function(){return+this.toString()};BigInteger.prototype.toJSNumber=BigInteger.prototype.valueOf;SmallInteger.prototype.valueOf=function(){return this.value};SmallInteger.prototype.toJSNumber=SmallInteger.prototype.valueOf;function parseStringValue(v){if(isPrecise(+v)){var x=+v;if(x===truncate(x))return new SmallInteger(x);throw"Invalid integer: "+v}var sign=v[0]==="-";if(sign)v=v.slice(1);var split=v.split(/e/i);if(split.length>2)throw new Error("Invalid integer: "+split.join("e"));if(split.length===2){var exp=split[1];if(exp[0]==="+")exp=exp.slice(1);exp=+exp;if(exp!==truncate(exp)||!isPrecise(exp))throw new Error("Invalid integer: "+exp+" is not a valid exponent.");var text=split[0];var decimalPlace=text.indexOf(".");if(decimalPlace>=0){exp-=text.length-decimalPlace-1;text=text.slice(0,decimalPlace)+text.slice(decimalPlace+1)}if(exp<0)throw new Error("Cannot include negative exponent part for integers");text+=new Array(exp+1).join("0");v=text}var isValid=/^([0-9][0-9]*)$/.test(v);if(!isValid)throw new Error("Invalid integer: "+v);var r=[],max=v.length,l=LOG_BASE,min=max-l;while(max>0){r.push(+v.slice(min,max));min-=l;if(min<0)min=0;max-=l}trim(r);return new BigInteger(r,sign)}function parseNumberValue(v){if(isPrecise(v)){if(v!==truncate(v))throw new Error(v+" is not an integer.");return new SmallInteger(v)}return parseStringValue(v.toString())}function parseValue(v){if(typeof v==="number"){return parseNumberValue(v)}if(typeof v==="string"){return parseStringValue(v)}return v}for(var i=0;i<1e3;i++){Integer[i]=new SmallInteger(i);if(i>0)Integer[-i]=new SmallInteger(-i)}Integer.one=Integer[1];Integer.zero=Integer[0];Integer.minusOne=Integer[-1];Integer.max=max;Integer.min=min;Integer.gcd=gcd;Integer.lcm=lcm;Integer.isInstance=function(x){return x instanceof BigInteger||x instanceof SmallInteger};Integer.randBetween=randBetween;Integer.fromArray=function(digits,base,isNegative){return parseBaseFromArray(digits.map(parseValue),parseValue(base||10),isNegative)};return Integer}();if(typeof module!=="undefined"&&module.hasOwnProperty("exports")){module.exports=bigInt}if(typeof define==="function"&&define.amd){define("big-integer",[],function(){return bigInt})} --------------------------------------------------------------------------------