├── LICENSE ├── OLD Versions ├── LICENSE ├── README.md ├── Start_webserver_ice.bat ├── Tamper Monkey │ ├── Mizogg Highlighter All Sites with Auto-Clicker.user.js │ └── joined.txt ├── btcaddress.txt ├── ethaddress.txt ├── ice_secp256k1.dll ├── ice_secp256k1.so ├── jquery-3.6.0.js ├── secp256k1.py ├── webserver_4.9.1.py └── webserver_ice.py ├── README.md ├── Webserver.exe ├── WebserverV2 ├── Install_libraries.bat ├── Start_Bonus.bat ├── Start_webserver_ice.bat ├── btc.bf ├── eth.bf ├── ice_secp256k1.dll ├── ice_secp256k1.so ├── jquery-3.6.0.js ├── secp256k1.py ├── success.mp3 ├── webserver_bonus.py └── webserver_ice.py ├── btc.bf ├── ice_secp256k1.dll ├── ice_secp256k1.so └── secp256k1.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Mizogg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /OLD Versions/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Mizogg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /OLD Versions/README.md: -------------------------------------------------------------------------------- 1 | # 🐍Python-WebServer🐍 and 🐒Tampermonkey🐒 2 | 3 | Webserver_ice.py Hunt for Bitcoin Adresses starting 1, 3 and bc1 and ETH. 4 | 5 | Webserver_4.9.1.py Hunt for Bitcoin. Just addresses starting with 1 6 | 7 | Includes Auto Random and Auto Sequential. No NEED for tamper monkey. Amazing Program. 8 | ``` 9 | search field added. To use:(paste and remove focus by clicking) 10 | WIF search by WIF 11 | 1878574747 search by page number 12 | @764523535 search page by privatekey decimal 13 | $ffff or $FFFFF search page by privatekey hex 14 | [123] change increment 15 | (2345-8856464646) change random range 16 | (72057594037927937-144115188075855873) random range puzzle 64 17 | ``` 18 | 😊 😇 🙂Special THanks to Alex Curl for All his hard work😊 😇 🙂 19 | 20 | https://user-images.githubusercontent.com/88630056/164995299-07b12034-c064-4133-bf87-d57b08239fb0.mp4 21 | 22 | ![image](https://user-images.githubusercontent.com/88630056/163732565-e298e77e-bb2c-46f7-9b77-e94a1be53a77.png) 23 | 24 | ![image](https://user-images.githubusercontent.com/88630056/163732575-846162fe-dc77-4160-a90b-4bac14696e26.png) 25 | 26 | --------- 27 | # Requirements: 28 | - Python3 29 | - pip install base58 30 | - https://github.com/iceland2k14/secp256k1 files 31 | - ice_secp256k1.dll 32 | - ice_secp256k1.so 33 | - secp256k1.py 34 | - btcaddress.txt (One address per line) 35 | - ethaddress.txt (One address per line) 36 | - jquery-3.6.0.js 37 | --------- 38 | To Start 🐍Python-WebServer🐍: 39 | > python webserver.py 40 | --------- 41 | Start Searching in your Web browser: 42 | - localhost:3333/1 (start from first page) 43 | - localhost:3333/1[256] (change next increment) 44 | - localhost:3333/1(100-500) (change random range) 45 | - Puzzle 64 Start = 72057594037927937 Page 46 | - Puzzle 64 Stop = 144115188075855873 Page 47 | - Random Puzzle 64= http://localhost:3333/1(144115188075855873-288230376151711745) (change random range) 48 | 49 | - wif search = http://localhost:3333/L3VVpPhkahdq7S3DQovZYXXLfFX96o4nfGAgGpGZyJXVw2Fx4XvV 50 | - or http://localhost:3333/5HpHagT65TZzG1PH3CSu64HcGh19CVFzq1pFa44r8FXZrQAaefe 51 | 52 | - Dec search = http://localhost:3333/73824873287973477289749872 53 | - or Dec search and Highlight found http://localhost:3333/@73824873287973477289749872 54 | 55 | - HEX Search and Highlight found = http://localhost:3333/$fffffffff 56 | - or http://localhost:3333/$FFFFF 57 | 58 | --------- 59 | # Detailed Information from HEX 60 | 61 | ![image](https://user-images.githubusercontent.com/88630056/164998242-aec51051-1733-4d94-acc9-f5ef26506dd3.png) 62 | 63 | --------- 64 | 65 | ``` 66 | 1100001011011110000110000011100000000000011111110111001001110001101001010010111101100000011110000000110100000101010011010111001110001011110101110101110101011111000101100111101011111011000001111011010001111110010110110101010000011001111000011111111100001111 67 | (256 bits) 68 | 69 | c2de1838007f7271a52f60780d054d738bd75d5f167afb07b47e5b5419e1ff0f 70 | 71 | 88141099825256245673553921999835541760225970015052508404838443368591216738063 72 | 73 | Public ECDSA Key 74 | x: 4774b0a2ac0b325e5ab7d4687b2a63c7540d2655dccab35f72c201da1149f68e 75 | 76 | y: 9be0b93c52e19c16b95edd82fd009b8ce5a3840b23a9f720838c29486765a493 77 | 78 | x: 32320385601912921618066559609108982423772771673443867077080816380047029565070 79 | 80 | y: 70505543722316022944178389399213156382852026814587996716514675175858874197139 81 | 82 | x: 034774b0a2ac0b325e5ab7d4687b2a63c7540d2655dccab35f72c201da1149f68e 83 | 84 | Additive Inverse Point 85 | 3d21e7c7ff808d8e5ad09f87f2fab28b2ed77f8798cda5340b540338b6544232 86 | 87 | x: 4774b0a2ac0b325e5ab7d4687b2a63c7540d2655dccab35f72c201da1149f68e 88 | 89 | y: 641f46c3ad1e63e946a1227d02ff64731a5c7bf4dc5608df7c73d6b6989a579c 90 | 91 | B:No U: 1M3Wfm1qnyuZgKM5b4QBVUtro6KeVqgoLi C: 19xbDGGGuqCyBcGTEbvZu16DinJqdjMHZ7 92 | 93 | Two More Points same Y different X 94 | x: 867e7fcddaca8b7f9f85a77c0cf81d02d5bd8066f07b318fe0d1f1e9ca29a01e 95 | 96 | y: 9be0b93c52e19c16b95edd82fd009b8ce5a3840b23a9f720838c29486765a493 97 | 98 | B:No U: 1KxCXLZsDoTxhUhAFzxAb4dq1vooj1Zi1d C: 1Avd9PfFq248v2M7MMSbXxNhfJhTY32ssN 99 | 100 | x: 320ccf8f792a422205c2841b77dd7f35d635594332ba1b10ac6c0c3b248c6583 101 | 102 | y: 9be0b93c52e19c16b95edd82fd009b8ce5a3840b23a9f720838c29486765a493 103 | 104 | B:No U: 1M2oE13jszzS6twUSBxotktgy8jWbbrSVm C: 13q8qmXFYSeJqLqemFYyK3z7zwUtb78Uom 105 | 106 | RIPEMD-160 Hash 107 | U: 664f5c265188f85ba8b0e80b6c946a586d8b0663 C: 444c2585216c5e469ac860ad7dde21e8cbc58a55 108 | ``` 109 | 110 | --------- 111 | ## 🐒Tampermonkey🐒 Auto Refresh (Get Tamper Monkey https://www.tampermonkey.net/) 112 | 113 | For Older Websever.py Version. This Includes addresses starting3 bc1 and ETH. 114 | 115 | --------- 116 | ![image](https://user-images.githubusercontent.com/88630056/164068392-cecd6564-2316-4d0b-8c3e-362c1869f833.png) 117 | --------- 118 | ``` 119 | // ==UserScript== 120 | // @name Reload Server 121 | // @namespace http://tampermonkey.net/ 122 | // @version 1.0 123 | // @description Reload the Server, find the Key 124 | // @author AlphaCentury 125 | // @match http://localhost:3333/* 126 | // @grant none 127 | // ==/UserScript== 128 | /* global BigInt */ 129 | (function() { 130 | console.log('Go'); 131 | let val = 0n; 132 | while (val < 1n || val > 904625697166532776746648320380374280100293470930272690489102837043110636674n) { 133 | let num = ''; 134 | for (let i = 0; i < 75; i++) { 135 | num += Math.floor(Math.random() * 10); 136 | } 137 | val = BigInt(num); 138 | } 139 | setTimeout(function() { 140 | if (document.getElementsByClassName('filled').length !== 0 || document.getElementsByClassName('used').length !== 0) { 141 | alert('Address found!'); 142 | return; 143 | }; 144 | document.location.href = val.toString(); 145 | },50); 146 | })(); 147 | ``` 148 | --------- 149 | ## 🐒Tampermonkey🐒 Highlight and Stop.To find out more on how to use this visit https://mizogg.co.uk/tampermonkey/ ) 150 | 151 | Or Join Telegram Cryptocracker https://t.me/CryptoCrackersUK for instant updates and changes bigger database files to help with your hunt. 152 | --------- 153 | ``` 154 | // ==UserScript== 155 | // @name Bitcoin Highlighter All Sites 156 | // @namespace https://mizogg.co.uk 157 | // @author mizogg.co.uk 158 | // @version 1.0 159 | // @description Highlights BTC Addresses 160 | // @match https://* 161 | // @grant GM_registerMenuCommand 162 | // @grant GM_setValue 163 | // @grant GM_getValue 164 | // ==/UserScript== 165 | 166 | 167 | (function() { 168 | 'use strict'; 169 | 170 | if (window.self !== window.top) { return; } 171 | 172 | function setUserPref(varName, defaultVal, menuText, promtText, sep){ 173 | GM_registerMenuCommand(menuText, function() { 174 | var val = prompt(promtText, GM_getValue(varName, defaultVal)); 175 | if (val === null) { return; } 176 | if (sep && val){ 177 | var pat1 = new RegExp('\\s*' + sep + '+\\s*', 'g'); 178 | var pat2 = new RegExp('(?:^' + sep + '+|' + sep + '+$)', 'g'); 179 | val = val.replace(pat1, sep).replace(pat2, ''); 180 | } 181 | val = val.replace(/\s{2,}/g, ' ').trim(); 182 | GM_setValue(varName, val); 183 | if(!document.body.querySelector(".THmo")) THmo_doHighlight(document.body); 184 | else location.reload(); 185 | }); 186 | } 187 | 188 | setUserPref( 189 | 'keywords', 190 | 'word 1,word 2,word 3', 191 | 'Set Keywords', 192 | 'Set keywords separated by comma\t\t\t\t\t\t\t\r\n\r\nExample:\r\nword 1,word 2,word 3', 193 | ',' 194 | ); 195 | 196 | setUserPref( 197 | 'highlightStyle', 198 | 'color: #f00; background-color: #ffebcd;', 199 | 'Set Highlight Style', 200 | 'Set the Highlight Style (use proper CSS)\r\n\r\nExample:\r\ncolor: #f00; font-weight: bold; background-color: #ffe4b5;' 201 | ); 202 | 203 | var THmo_MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver; 204 | if (THmo_MutOb){ 205 | var THmo_chgMon = new THmo_MutOb(function(mutationSet){ 206 | mutationSet.forEach(function(mutation){ 207 | for (var i=0; i$1'); 244 | node.parentNode.replaceChild(sp, node); 245 | alert("NICE ONE BITCOINS FOUND!!!!!") 246 | } 247 | } 248 | } 249 | } 250 | THmo_doHighlight(document.body); 251 | })(); 252 | ``` 253 | 254 | Find Out More Join more Like me on Telegram https://t.me/CryptoCrackersUK 255 | -------------------------------------------------------------------------------- /OLD Versions/Start_webserver_ice.bat: -------------------------------------------------------------------------------- 1 | @Echo off 2 | title webserver_ice.py 3 | Pushd "%~dp0" 4 | :loop 5 | python webserver_ice.py 6 | goto loop -------------------------------------------------------------------------------- /OLD Versions/Tamper Monkey/Mizogg Highlighter All Sites with Auto-Clicker.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name Mizogg Highlighter All Sites with Auto-Clicker 3 | // @namespace https://mizogg.co.uk 4 | // @author mizogg.co.uk 5 | // @version 2.1 6 | // @description Highlights BTC Addresses and Auto-Clicker 7 | // @match https://*/* 8 | // @grant GM_registerMenuCommand 9 | // @grant GM_setValue 10 | // @grant GM_getValue 11 | // ==/UserScript== 12 | 13 | (function() { 14 | 'use strict'; 15 | 16 | if (window.self !== window.top) { return; } 17 | 18 | function setUserPref(varName, defaultVal, menuText, promtText, sep){ 19 | GM_registerMenuCommand(menuText, function() { 20 | var val = prompt(promtText, GM_getValue(varName, defaultVal)); 21 | if (val === null) { return; } 22 | if (sep && val){ 23 | var pat1 = new RegExp('\\s*' + sep + '+\\s*', 'g'); 24 | var pat2 = new RegExp('(?:^' + sep + '+|' + sep + '+$)', 'g'); 25 | val = val.replace(pat1, sep).replace(pat2, ''); 26 | } 27 | val = val.replace(/\s{2,}/g, ' ').trim(); 28 | 29 | // Check for the number of keywords 30 | var numKeywords = val.split(sep).length; 31 | if (numKeywords > 300) { 32 | alert("Warning: You have provided a large number of keywords (" + numKeywords + "). This may slow down the script's performance. It's recommended to keep the number of keywords below 300."); 33 | } 34 | 35 | GM_setValue(varName, val); 36 | if (varName === 'clickInterval') { 37 | startAutoClicker(Number(val)); 38 | } else { 39 | if (!document.body.querySelector(".mizogg-highlight")) THmo_doHighlight(document.body); 40 | else location.reload(); 41 | } 42 | }); 43 | } 44 | 45 | setUserPref( 46 | 'keywords', 47 | 'word 1,word 2,word 3', 48 | 'Set Keywords', 49 | 'Set keywords separated by comma\t\t\t\t\t\t\t\r\n\r\nExample:\r\nword 1,word 2,word 3', 50 | ',' 51 | ); 52 | 53 | setUserPref( 54 | 'highlightStyle', 55 | 'color: #f00; background-color: #ffebcd;', 56 | 'Set Highlight Style', 57 | 'Set the Highlight Style (use proper CSS)\r\n\r\nExample:\r\ncolor: #f00; font-weight: bold; background-color: #ffe4b5;' 58 | ); 59 | 60 | setUserPref( 61 | 'showAlert', 62 | 'true', 63 | 'Toggle Alert for Found Keywords', 64 | 'Do you want to be alerted when keywords are found? (true/false)' 65 | ); 66 | 67 | setUserPref( 68 | 'clickInterval', 69 | '1000', 70 | 'Set Auto-Clicker Interval (ms)', 71 | 'Set the interval for auto-clicker (in milliseconds, e.g., 1000 for 1 second)' 72 | ); 73 | 74 | let currentMousePos = { x: -1, y: -1 }; 75 | document.addEventListener('mousemove', function(event) { 76 | currentMousePos.x = event.pageX; 77 | currentMousePos.y = event.pageY; 78 | }); 79 | 80 | let autoClickerInterval = null; 81 | let autoClickerActive = GM_getValue('autoClickerState', false); // Get the saved state on script start 82 | 83 | function toggleAutoClicker() { 84 | autoClickerActive = !autoClickerActive; 85 | GM_setValue('autoClickerState', autoClickerActive); // Save the state 86 | if (autoClickerActive) { 87 | let clickInterval = GM_getValue('clickInterval', 1000); 88 | startAutoClicker(clickInterval); 89 | } else { 90 | if (autoClickerInterval) { 91 | clearInterval(autoClickerInterval); 92 | autoClickerInterval = null; 93 | } 94 | } 95 | } 96 | 97 | document.addEventListener('keydown', function(e) { 98 | if (e.ctrlKey && e.shiftKey) { 99 | toggleAutoClicker(); 100 | alert(`Auto-clicker is now ${autoClickerActive ? 'ON' : 'OFF'}`); 101 | } 102 | }); 103 | 104 | function startAutoClicker(interval) { 105 | console.log('Starting auto-clicker with an interval of', interval, 'milliseconds.'); // Debugging line 106 | autoClickerInterval = setInterval(() => { 107 | if (autoClickerActive && currentMousePos.x > -1 && currentMousePos.y > -1) { 108 | console.log('Attempting to click at position:', currentMousePos.x, currentMousePos.y); // Debugging line 109 | var element = document.elementFromPoint(currentMousePos.x, currentMousePos.y); 110 | if (element) { 111 | console.log("Auto-clicking element:", element); 112 | var clickEvent = new MouseEvent('click', { 113 | bubbles: true, 114 | cancelable: true 115 | }); 116 | element.dispatchEvent(clickEvent); 117 | } else { 118 | console.log("No element found under cursor."); 119 | } 120 | } 121 | }, interval); 122 | } 123 | 124 | // Start the auto-clicker if it was previously active 125 | if (autoClickerActive) { 126 | let clickInterval = GM_getValue('clickInterval', 1000); 127 | startAutoClicker(clickInterval); 128 | } 129 | 130 | var THmo_MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver; 131 | if (THmo_MutOb){ 132 | var THmo_chgMon = new THmo_MutOb(function(mutationSet){ 133 | mutationSet.forEach(function(mutation){ 134 | for (var i=0; i' + matched + ''; 176 | }); 177 | node.parentNode.replaceChild(sp, node); 178 | } 179 | } 180 | } 181 | 182 | var showAlert = GM_getValue('showAlert') === 'true'; 183 | if(showAlert && foundKeywords.length) { 184 | alert("NICE ONE BITCOINS FOUND!!!!!\n\n" + foundKeywords.join(", ")); 185 | } 186 | } 187 | 188 | THmo_doHighlight(document.body); 189 | })(); 190 | -------------------------------------------------------------------------------- /OLD Versions/ethaddress.txt: -------------------------------------------------------------------------------- 1 | 0x7e5f4552091a69125d5dfcb7b8c2659029395bdf 2 | 0x2b5ad5c4795c026514f8317c7a215e218dccd6cf 3 | 0x37da28c050e3c0a1c0ac3be97913ec038783da4c 4 | 0x4a7a7c2e09209dbe44a582cd92b0edd7129e74be 5 | 0xD816Be1420aC291Acc76Bb5d6e750211B72e38b8 6 | 0x9C2F44EFAd0c1E852a09dF9939e6DaF061140CaF 7 | 0x8bd3A22B17BE4F1fFfe54eE1D2638444595c6fEb 8 | 0x2CC465A20B2211bad9D42b48F659ae42979C96be 9 | 0xF9807a8719AE154E74591CB2d452797707faDF73 10 | 0x39ADb812229aa99d72354ff406fee68d8781e7D1 -------------------------------------------------------------------------------- /OLD Versions/ice_secp256k1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/OLD Versions/ice_secp256k1.dll -------------------------------------------------------------------------------- /OLD Versions/ice_secp256k1.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/OLD Versions/ice_secp256k1.so -------------------------------------------------------------------------------- /OLD Versions/secp256k1.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 4 | @author: iceland 5 | """ 6 | 7 | import platform 8 | import os 9 | import sys 10 | import ctypes 11 | 12 | 13 | ############################################################################### 14 | N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 15 | Zero=b'\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 16 | #============================================================================== 17 | if platform.system().lower().startswith('win'): 18 | dllfile = 'ice_secp256k1.dll' 19 | if os.path.isfile(dllfile) == True: 20 | pathdll = os.path.realpath(dllfile) 21 | ice = ctypes.CDLL(pathdll) 22 | else: 23 | print('File {} not found'.format(dllfile)) 24 | 25 | elif platform.system().lower().startswith('lin'): 26 | dllfile = 'ice_secp256k1.so' 27 | if os.path.isfile(dllfile) == True: 28 | pathdll = os.path.realpath(dllfile) 29 | ice = ctypes.CDLL(pathdll) 30 | else: 31 | print('File {} not found'.format(dllfile)) 32 | 33 | else: 34 | print('[-] Unsupported Platform currently for ctypes dll method. Only [Windows and Linux] is working') 35 | sys.exit() 36 | ############################################################################### 37 | #============================================================================== 38 | # Coin type 39 | COIN_BTC = 0 40 | COIN_BSV = 1 41 | COIN_BTCD = 2 42 | COIN_ARG = 3 43 | COIN_AXE = 4 44 | COIN_BC = 5 45 | COIN_BCH = 6 46 | COIN_BSD = 7 47 | COIN_BTDX = 8 48 | COIN_BTG = 9 49 | COIN_BTX = 10 50 | COIN_CHA = 11 51 | COIN_DASH = 12 52 | COIN_DCR = 13 53 | COIN_DFC = 14 54 | COIN_DGB = 15 55 | COIN_DOGE = 16 56 | COIN_FAI = 17 57 | COIN_FTC = 18 58 | COIN_GRS = 19 59 | COIN_JBS = 20 60 | COIN_LTC = 21 61 | COIN_MEC = 22 62 | COIN_MONA = 23 63 | COIN_MZC = 24 64 | COIN_PIVX = 25 65 | COIN_POLIS= 26 66 | COIN_RIC = 27 67 | COIN_STRAT= 28 68 | COIN_SMART= 29 69 | COIN_VIA = 30 70 | COIN_XMY = 31 71 | COIN_ZEC = 32 72 | COIN_ZCL = 33 73 | COIN_ZERO = 34 74 | COIN_ZEN = 35 75 | COIN_TENT = 36 76 | COIN_ZEIT = 37 77 | COIN_VTC = 38 78 | COIN_UNO = 39 79 | COIN_SKC = 40 80 | COIN_RVN = 41 81 | COIN_PPC = 42 82 | COIN_OMC = 43 83 | COIN_OK = 44 84 | COIN_NMC = 45 85 | COIN_NLG = 46 86 | COIN_LBRY = 47 87 | COIN_DNR = 48 88 | COIN_BWK = 49 89 | 90 | #============================================================================== 91 | ice.scalar_multiplication.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # pvk,ret 92 | #============================================================================== 93 | # ice.scalar_multiplications.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p] # pvk,len,ret 94 | #============================================================================== 95 | ice.get_x_to_y.argtypes = [ctypes.c_char_p, ctypes.c_bool, ctypes.c_char_p] # x,even,ret 96 | #============================================================================== 97 | ice.point_increment.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 98 | #============================================================================== 99 | ice.point_negation.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 100 | #============================================================================== 101 | ice.point_doubling.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 102 | #============================================================================== 103 | ice.privatekey_to_coinaddress.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # intcoin,012,comp,pvk 104 | ice.privatekey_to_coinaddress.restype = ctypes.c_void_p 105 | #============================================================================== 106 | ice.privatekey_to_address.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # 012,comp,pvk 107 | ice.privatekey_to_address.restype = ctypes.c_void_p 108 | #============================================================================== 109 | ice.hash_to_address.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # 012,comp,hash 110 | ice.hash_to_address.restype = ctypes.c_void_p 111 | #============================================================================== 112 | ice.pubkey_to_address.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # 012,comp,upub 113 | ice.pubkey_to_address.restype = ctypes.c_void_p 114 | #============================================================================== 115 | ice.privatekey_to_h160.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # 012,comp,pvk,ret 116 | #============================================================================== 117 | ice.privatekey_loop_h160.argtypes = [ctypes.c_ulonglong, ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # num,012,comp,pvk,ret 118 | #============================================================================== 119 | ice.privatekey_loop_h160_sse.argtypes = [ctypes.c_ulonglong, ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # num,012,comp,pvk,ret 120 | #============================================================================== 121 | ice.pubkey_to_h160.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # 012,comp,upub,ret 122 | #============================================================================== 123 | ice.pbkdf2_hmac_sha512_dll.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int] # ret, words, len 124 | #============================================================================== 125 | ice.pbkdf2_hmac_sha512_list.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_int, ctypes.c_ulonglong] # ret,words,len,mnem_size,total 126 | #============================================================================== 127 | ice.pub_endo1.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 128 | #============================================================================== 129 | ice.pub_endo2.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 130 | #============================================================================== 131 | ice.b58_encode.argtypes = [ctypes.c_char_p] # _h 132 | ice.b58_encode.restype = ctypes.c_void_p 133 | #============================================================================== 134 | ice.b58_decode.argtypes = [ctypes.c_char_p] # addr 135 | ice.b58_decode.restype = ctypes.c_void_p 136 | #============================================================================== 137 | ice.bech32_address_decode.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_char_p] # coin,b32_addr,h160 138 | #============================================================================== 139 | ice.get_sha256.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p] # input, len, ret 140 | #============================================================================== 141 | ice.create_baby_table.argtypes = [ctypes.c_ulonglong, ctypes.c_ulonglong, ctypes.c_char_p] # start,end,ret 142 | #============================================================================== 143 | ice.point_addition.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # upub1,upub2,ret 144 | #============================================================================== 145 | ice.point_subtraction.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # upub1,upub2,ret 146 | #============================================================================== 147 | ice.point_loop_subtraction.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # k,upub1,upub2,ret 148 | #============================================================================== 149 | ice.point_loop_addition.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # k,upub1,upub2,ret 150 | #============================================================================== 151 | ice.point_vector_addition.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # num,upubs1,upubs2,ret 152 | #============================================================================== 153 | ice.point_sequential_increment_P2.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p] # num,upub1,ret 154 | #============================================================================== 155 | ice.point_sequential_increment_P2_mcpu.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p] # num,upub1,mcpu,ret 156 | #============================================================================== 157 | ice.point_sequential_increment.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p] # num,upub1,ret 158 | #============================================================================== 159 | ice.point_sequential_decrement.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p] # num,upub1,ret 160 | #============================================================================== 161 | ice.pubkeyxy_to_ETH_address.argtypes = [ctypes.c_char_p] # upub_xy 162 | ice.pubkeyxy_to_ETH_address.restype = ctypes.c_void_p 163 | #============================================================================== 164 | ice.pubkeyxy_to_ETH_address_bytes.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub_xy, ret 165 | #============================================================================== 166 | ice.privatekey_to_ETH_address.argtypes = [ctypes.c_char_p] # pvk 167 | ice.privatekey_to_ETH_address.restype = ctypes.c_void_p 168 | #============================================================================== 169 | ice.privatekey_to_ETH_address_bytes.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # pvk, ret 170 | #============================================================================== 171 | ice.privatekey_group_to_ETH_address.argtypes = [ctypes.c_char_p, ctypes.c_int] # pvk, m 172 | ice.privatekey_group_to_ETH_address.restype = ctypes.c_void_p 173 | #============================================================================== 174 | ice.privatekey_group_to_ETH_address_bytes.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p] # pvk,m,ret 175 | #============================================================================== 176 | ice.init_P2_Group.argtypes = [ctypes.c_char_p] # upub 177 | #============================================================================== 178 | ice.free_memory.argtypes = [ctypes.c_void_p] # pointer 179 | #============================================================================== 180 | ice.bloom_check_add.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong, ctypes.c_ubyte, ctypes.c_char_p] #buff, len, 0_1, _bits, _hashes, _bf 181 | ice.bloom_check_add.restype = ctypes.c_int 182 | #============================================================================== 183 | ice.bloom_batch_add.argtypes = [ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong, ctypes.c_ubyte, ctypes.c_char_p] #chunk, buff, len, 0_1, _bits, _hashes, _bf 184 | #============================================================================== 185 | ice.test_bit_set_bit.argtypes = [ctypes.c_char_p, ctypes.c_ulonglong, ctypes.c_int] #_bf, _bits, 0_1 186 | 187 | ice.init_secp256_lib() 188 | #============================================================================== 189 | ############################################################################### 190 | 191 | 192 | def version(): 193 | ice.version() 194 | #============================================================================== 195 | def _scalar_multiplication(pvk_int): 196 | ''' Integer value passed to function. 65 bytes uncompressed pubkey output ''' 197 | res = (b'\x00') * 65 198 | pass_int_value = fl(pvk_int).encode('utf8') 199 | ice.scalar_multiplication(pass_int_value, res) 200 | return res 201 | def scalar_multiplication(pvk_int): 202 | if pvk_int < 0: pvk_int = N+pvk_int 203 | res = _scalar_multiplication(pvk_int) 204 | return bytes(bytearray(res)) 205 | #============================================================================== 206 | # ============================================================================= 207 | # def _scalar_multiplications(pvk_int_list): 208 | # ''' Integer list passed to function. 65*len bytes uncompressed pubkey output. No Zero Point handling ''' 209 | # sz = len(pvk_int_list) 210 | # res = (b'\x00') * (65 * sz) 211 | # pvks = ''.join(pvk_int_list).encode('utf8') 212 | # ice.scalar_multiplications(pvks, sz, res) 213 | # return res 214 | # def scalar_multiplications(pvk_int_list): 215 | # pvk_int_list = [fl(N+i) if i < 0 else fl(i) for i in pvk_int_list] 216 | # res = _scalar_multiplications(pvk_int_list) 217 | # return bytes(bytearray(res)) 218 | # ============================================================================= 219 | #============================================================================== 220 | def point_multiplication(k, P): 221 | ''' k=scalar. P = Input Point. Output is 65 bytes uncompressed pubkey ''' 222 | if type(P) == int: k,P = P,k 223 | def bits(k): 224 | while k: 225 | yield k & 1 226 | k >>= 1 227 | result = Zero 228 | addend = P 229 | for bit in bits(k): 230 | if bit == 1: result=point_addition(result,addend) 231 | addend=point_doubling(addend) 232 | return result 233 | #============================================================================== 234 | def _get_x_to_y(x_hex, is_even): 235 | ''' Input x_hex encoded as bytes and bool is_even. 32 bytes y of point output ''' 236 | res = (b'\x00') * 32 237 | ice.get_x_to_y(x_hex.encode('utf8'), is_even, res) 238 | return res 239 | def get_x_to_y(x_hex, is_even): 240 | res = _get_x_to_y(x_hex, is_even) 241 | return bytes(bytearray(res)) 242 | #============================================================================== 243 | def _point_increment(pubkey_bytes): 244 | res = (b'\x00') * 65 245 | ice.point_increment(pubkey_bytes, res) 246 | return res 247 | def point_increment(pubkey_bytes): 248 | res = _point_increment(pubkey_bytes) 249 | return bytes(bytearray(res)) 250 | #============================================================================== 251 | def _point_negation(pubkey_bytes): 252 | res = (b'\x00') * 65 253 | ice.point_negation(pubkey_bytes, res) 254 | return res 255 | def point_negation(pubkey_bytes): 256 | res = _point_negation(pubkey_bytes) 257 | return bytes(bytearray(res)) 258 | #============================================================================== 259 | def _point_doubling(pubkey_bytes): 260 | res = (b'\x00') * 65 261 | ice.point_doubling(pubkey_bytes, res) 262 | return res 263 | def point_doubling(pubkey_bytes): 264 | res = _point_doubling(pubkey_bytes) 265 | return bytes(bytearray(res)) 266 | #============================================================================== 267 | def init_P2_Group(pubkey_bytes): 268 | ice.init_P2_Group(pubkey_bytes) 269 | #============================================================================== 270 | def privatekey_to_coinaddress(coin_type, addr_type, iscompressed, pvk_int): 271 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 272 | if pvk_int < 0: pvk_int = N+pvk_int 273 | pass_int_value = fl(pvk_int).encode('utf8') 274 | res = ice.privatekey_to_coinaddress(coin_type, addr_type, iscompressed, pass_int_value) 275 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 276 | ice.free_memory(res) 277 | return addr 278 | #============================================================================== 279 | def privatekey_to_address(addr_type, iscompressed, pvk_int): 280 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 281 | if pvk_int < 0: pvk_int = N+pvk_int 282 | pass_int_value = fl(pvk_int).encode('utf8') 283 | res = ice.privatekey_to_address(addr_type, iscompressed, pass_int_value) 284 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 285 | ice.free_memory(res) 286 | return addr 287 | #============================================================================== 288 | def hash_to_address(addr_type, iscompressed, hash160_bytes): 289 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 290 | res = ice.hash_to_address(addr_type, iscompressed, hash160_bytes) 291 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 292 | ice.free_memory(res) 293 | return addr 294 | #============================================================================== 295 | def pubkey_to_address(addr_type, iscompressed, pubkey_bytes): 296 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 297 | res = ice.pubkey_to_address(addr_type, iscompressed, pubkey_bytes) 298 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 299 | ice.free_memory(res) 300 | return addr 301 | #============================================================================== 302 | def _privatekey_to_h160(addr_type, iscompressed, pvk_int): 303 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 304 | if pvk_int < 0: pvk_int = N+pvk_int 305 | pass_int_value = fl(pvk_int).encode('utf8') 306 | res = (b'\x00') * 20 307 | ice.privatekey_to_h160(addr_type, iscompressed, pass_int_value, res) 308 | return res 309 | def privatekey_to_h160(addr_type, iscompressed, pvk_int): 310 | res = _privatekey_to_h160(addr_type, iscompressed, pvk_int) 311 | return bytes(bytearray(res)) 312 | #============================================================================== 313 | def _privatekey_loop_h160(num, addr_type, iscompressed, pvk_int): 314 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 315 | if pvk_int < 0: pvk_int = N+pvk_int 316 | pass_int_value = fl(pvk_int).encode('utf8') 317 | res = (b'\x00') * (20 * num) 318 | ice.privatekey_loop_h160(num, addr_type, iscompressed, pass_int_value, res) 319 | return res 320 | def privatekey_loop_h160(num, addr_type, iscompressed, pvk_int): 321 | if num <= 0: num = 1 322 | res = _privatekey_loop_h160(num, addr_type, iscompressed, pvk_int) 323 | return bytes(bytearray(res)) 324 | #============================================================================== 325 | def _privatekey_loop_h160_sse(num, addr_type, iscompressed, pvk_int): 326 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 327 | if pvk_int < 0: pvk_int = N+pvk_int 328 | pass_int_value = fl(pvk_int).encode('utf8') 329 | res = (b'\x00') * (20 * num) 330 | ice.privatekey_loop_h160_sse(num, addr_type, iscompressed, pass_int_value, res) 331 | return res 332 | def privatekey_loop_h160_sse(num, addr_type, iscompressed, pvk_int): 333 | if num <= 0: num = 1 334 | res = _privatekey_loop_h160_sse(num, addr_type, iscompressed, pvk_int) 335 | return bytes(bytearray(res)) 336 | #============================================================================== 337 | def _pubkey_to_h160(addr_type, iscompressed, pubkey_bytes): 338 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 339 | res = (b'\x00') * 20 340 | ice.pubkey_to_h160(addr_type, iscompressed, pubkey_bytes, res) 341 | return res 342 | def pubkey_to_h160(addr_type, iscompressed, pubkey_bytes): 343 | res = _pubkey_to_h160(addr_type, iscompressed, pubkey_bytes) 344 | return bytes(bytearray(res)) 345 | #============================================================================== 346 | def _pub_endo1(pubkey_bytes): 347 | res = (b'\x00') * 65 348 | ice.pub_endo1(pubkey_bytes, res) 349 | return res 350 | def pub_endo1(pubkey_bytes): 351 | res = _pub_endo1(pubkey_bytes) 352 | return bytes(bytearray(res)) 353 | #============================================================================== 354 | def _pub_endo2(pubkey_bytes): 355 | res = (b'\x00') * 65 356 | ice.pub_endo2(pubkey_bytes, res) 357 | return res 358 | def pub_endo2(pubkey_bytes): 359 | res = _pub_endo2(pubkey_bytes) 360 | return bytes(bytearray(res)) 361 | #============================================================================== 362 | def b58py(data): 363 | B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" 364 | 365 | if data[0] == 0: 366 | return "1" + b58py(data[1:]) 367 | 368 | x = sum([v * (256 ** i) for i, v in enumerate(data[::-1])]) 369 | ret = "" 370 | while x > 0: 371 | ret = B58[x % 58] + ret 372 | x = x // 58 373 | 374 | return ret 375 | #============================================================================== 376 | def b58_encode(inp_bytes): 377 | res = ice.b58_encode(inp_bytes, len(inp_bytes)) 378 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 379 | ice.free_memory(res) 380 | return addr 381 | #============================================================================== 382 | def b58_decode(inp): 383 | res = ice.b58_decode(inp.encode("utf-8")) 384 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 385 | ice.free_memory(res) 386 | return addr 387 | #============================================================================== 388 | def bech32_address_decode(addr, coin_type=0): 389 | ''' Input address in String format. Output h160 in hex string format 390 | [Note] p2wsh = bech32(sha256(21 + pubkey + ac)). So Decoding it not Needed ''' 391 | if len(addr) > 50: print('[Error] Bech32 p2wsh Not Supported. Result Truncated') 392 | h160 = (b'\x00') * 20 393 | ice.bech32_address_decode(coin_type, addr.encode("utf-8"), h160) 394 | return bytes(bytearray(h160)).hex() 395 | #============================================================================== 396 | def address_to_h160(p2pkh): 397 | ''' Input address in String format. Output h160 in hex string format''' 398 | h1 = b58_decode(p2pkh) 399 | return h1[2:-8] 400 | #============================================================================== 401 | def btc_wif_to_pvk_hex(wif): 402 | pvk = '' 403 | if wif[0] == '5': 404 | pvk = b58_decode(wif)[2:-8] 405 | elif wif[0] in ['L', 'K']: 406 | pvk = b58_decode(wif)[2:-10] 407 | else: print('[Error] Incorrect WIF Key') 408 | return pvk 409 | #============================================================================== 410 | def btc_wif_to_pvk_int(wif): 411 | pvk = '' 412 | pvk_hex = btc_wif_to_pvk_hex(wif) 413 | if pvk_hex != '': pvk = int(pvk_hex, 16) 414 | return pvk 415 | #============================================================================== 416 | def btc_pvk_to_wif(pvk, is_compressed=True): 417 | ''' Input Privatekey can in any 1 of these [Integer] [Hex] [Bytes] form''' 418 | inp = '' 419 | suff = '01' if is_compressed == True else '' 420 | if type(pvk) in [int, str]: inp = bytes.fromhex('80' + fl(pvk) + suff) 421 | elif type(pvk) == bytes: inp = b'\x80' + fl(pvk) + bytes.fromhex(suff) 422 | else: print("[Error] Input Privatekey format [Integer] [Hex] [Bytes] allowed only") 423 | if inp != '': 424 | res = get_sha256(inp) 425 | res2 = get_sha256(res) 426 | return b58_encode(inp + res2[:4]) 427 | else: return inp 428 | #============================================================================== 429 | def fl(sstr, length=64): 430 | ''' Fill input to exact 32 bytes. If input is int or str the return is str. if input is bytes return is bytes''' 431 | if type(sstr) == int: fixed = hex(sstr)[2:].zfill(length) 432 | elif type(sstr) == str: fixed = sstr[2:].zfill(length) if sstr[:2].lower() == '0x' else sstr.zfill(length) 433 | elif type(sstr) == bytes: fixed = (b'\x00') * (32 - len(sstr)) + sstr 434 | else: print("[Error] Input format [Integer] [Hex] [Bytes] allowed only") 435 | return fixed 436 | #============================================================================== 437 | def pbkdf2_hmac_sha512_dll(words): 438 | seed_bytes = (b'\x00') * 64 439 | # words = 'good push broken people salad bar mad squirrel joy dismiss merge jeans token wear boring manual doll near sniff turtle sunset lend invest foil' 440 | ice.pbkdf2_hmac_sha512_dll(seed_bytes, words.encode("utf-8"), len(words)) 441 | return seed_bytes 442 | #============================================================================== 443 | def pbkdf2_hmac_sha512_list(words_list): 444 | ''' strength is [12, 18, 24]. words_list is a list of strings with each line having valid mnemonics''' 445 | wl = len(words_list) 446 | strength = len(words_list[0].split()) 447 | words = ' '.join(words_list) 448 | seed_bytes = (b'\x00') * (64 * wl) 449 | # words = 'good push broken people salad bar mad squirrel joy dismiss merge jeans token wear boring manual doll near sniff turtle sunset lend invest foil' 450 | ice.pbkdf2_hmac_sha512_list(seed_bytes, words.encode("utf-8"), len(words), strength, wl) 451 | return seed_bytes 452 | #============================================================================== 453 | def get_sha256(input_bytes): 454 | digest_bytes = (b'\x00') * 32 455 | if type(input_bytes) == str: input_bytes = input_bytes.encode("utf-8") 456 | # MiniKey example 457 | ice.get_sha256(input_bytes, len(input_bytes), digest_bytes) 458 | return digest_bytes 459 | #============================================================================== 460 | def create_baby_table(start_value, end_value): 461 | res = (b'\x00') * ((1+end_value-start_value) * 32) 462 | ice.create_baby_table(start_value, end_value, res) 463 | return bytes(bytearray(res)) 464 | #============================================================================== 465 | def _point_addition(pubkey1_bytes, pubkey2_bytes): 466 | res = (b'\x00') * 65 467 | ice.point_addition(pubkey1_bytes, pubkey2_bytes, res) 468 | return res 469 | def point_addition(pubkey1_bytes, pubkey2_bytes): 470 | res = _point_addition(pubkey1_bytes, pubkey2_bytes) 471 | return bytes(bytearray(res)) 472 | #============================================================================== 473 | def _point_subtraction(pubkey1_bytes, pubkey2_bytes): 474 | res = (b'\x00') * 65 475 | ice.point_subtraction(pubkey1_bytes, pubkey2_bytes, res) 476 | return res 477 | def point_subtraction(pubkey1_bytes, pubkey2_bytes): 478 | res = _point_subtraction(pubkey1_bytes, pubkey2_bytes) 479 | return bytes(bytearray(res)) 480 | #============================================================================== 481 | def _point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes): 482 | res = (b'\x00') * (65 * num) 483 | ice.point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes, res) 484 | return res 485 | def point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes): 486 | ''' Continuously subtracting point2 into point1 in a loop of num times. 487 | Output is array of pubkeys P1-P2, P1-2P2, P1-3P2, P1-4P2....''' 488 | if num <= 0: num = 1 489 | res = _point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes) 490 | return bytes(bytearray(res)) 491 | #============================================================================== 492 | def _point_loop_addition(num, pubkey1_bytes, pubkey2_bytes): 493 | res = (b'\x00') * (65 * num) 494 | ice.point_loop_addition(num, pubkey1_bytes, pubkey2_bytes, res) 495 | return res 496 | def point_loop_addition(num, pubkey1_bytes, pubkey2_bytes): 497 | ''' Continuously adding point2 into point1 in a loop of num times. 498 | Output is array of pubkeys P1+P2, P1+2P2, P1+3P2, P1+4P2....''' 499 | if num <= 0: num = 1 500 | res = _point_loop_addition(num, pubkey1_bytes, pubkey2_bytes) 501 | return bytes(bytearray(res)) 502 | #============================================================================== 503 | def _point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes): 504 | res = (b'\x00') * (65 * num) 505 | ice.point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes, res) 506 | return res 507 | def point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes): 508 | ''' Adding two array of points of equal length. ''' 509 | if num <= 0: num = 1 510 | res = _point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes) 511 | return bytes(bytearray(res)) 512 | #============================================================================== 513 | def _point_sequential_increment_P2(num, pubkey1_bytes): 514 | res = (b'\x00') * (65 * num) 515 | ice.point_sequential_increment_P2(num, pubkey1_bytes, res) 516 | return res 517 | def point_sequential_increment_P2(num, pubkey1_bytes): 518 | ''' This is the fastest implementation to add point P2 in the given Point sequentially.''' 519 | if num <= 0: num = 1 520 | res = _point_sequential_increment_P2(num, pubkey1_bytes) 521 | return bytes(bytearray(res)) 522 | #============================================================================== 523 | def _point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu): 524 | res = (b'\x00') * (65 * num) 525 | ice.point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu, res) 526 | return res 527 | def point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu=os.cpu_count()): 528 | ''' This is the fastest multi CPU implementation to add point P2 in the given Point sequentially. Threads are Not optimised yet''' 529 | if num <= 0: num = 1 530 | res = _point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu) 531 | return bytes(bytearray(res)) 532 | #============================================================================== 533 | def _point_sequential_increment(num, pubkey1_bytes): 534 | res = (b'\x00') * (65 * num) 535 | ice.point_sequential_increment(num, pubkey1_bytes, res) 536 | return res 537 | def point_sequential_increment(num, pubkey1_bytes): 538 | ''' This is the fastest implementation using G''' 539 | if num <= 0: num = 1 540 | res = _point_sequential_increment(num, pubkey1_bytes) 541 | return bytes(bytearray(res)) 542 | #============================================================================== 543 | def _point_sequential_decrement(num, pubkey1_bytes): 544 | res = (b'\x00') * (65 * num) 545 | ice.point_sequential_decrement(num, pubkey1_bytes, res) 546 | return res 547 | def point_sequential_decrement(num, pubkey1_bytes): 548 | ''' This is the fastest implementation using -G.''' 549 | if num <= 0: num = 1 550 | res = _point_sequential_decrement(num, pubkey1_bytes) 551 | return bytes(bytearray(res)) 552 | #============================================================================== 553 | def pubkey_to_ETH_address(pubkey_bytes): 554 | ''' 65 Upub bytes input. Output is 20 bytes ETH address lowercase with 0x as hex string''' 555 | xy = pubkey_bytes[1:] 556 | res = ice.pubkeyxy_to_ETH_address(xy) 557 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 558 | ice.free_memory(res) 559 | return '0x'+addr 560 | #============================================================================== 561 | def _pubkey_to_ETH_address_bytes(xy): 562 | res = (b'\x00') * 20 563 | ice.pubkeyxy_to_ETH_address_bytes(xy, res) 564 | return res 565 | def pubkey_to_ETH_address_bytes(pubkey_bytes): 566 | ''' 65 Upub bytes input. Output is 20 bytes ETH address lowercase without 0x''' 567 | xy = pubkey_bytes[1:] 568 | res = _pubkey_to_ETH_address_bytes(xy) 569 | return bytes(bytearray(res)) 570 | #============================================================================== 571 | def privatekey_to_ETH_address(pvk_int): 572 | ''' Privatekey Integer value passed to function. Output is 20 bytes ETH address lowercase with 0x as hex string''' 573 | if pvk_int < 0: pvk_int = N+pvk_int 574 | pass_int_value = fl(pvk_int).encode('utf8') 575 | res = ice.privatekey_to_ETH_address(pass_int_value) 576 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 577 | ice.free_memory(res) 578 | return '0x'+addr 579 | #============================================================================== 580 | def _privatekey_to_ETH_address_bytes(pass_int_value): 581 | res = (b'\x00') * 20 582 | ice.privatekey_to_ETH_address_bytes(pass_int_value, res) 583 | return res 584 | def privatekey_to_ETH_address_bytes(pvk_int): 585 | ''' Privatekey Integer value passed to function. Output is 20 bytes ETH address lowercase without 0x''' 586 | if pvk_int < 0: pvk_int = N+pvk_int 587 | pass_int_value = fl(pvk_int).encode('utf8') 588 | res = _privatekey_to_ETH_address_bytes(pass_int_value) 589 | return bytes(bytearray(res)) 590 | #============================================================================== 591 | def privatekey_group_to_ETH_address(pvk_int, m): 592 | ''' Starting Privatekey Integer value passed to function as pvk_int. 593 | Integer m is, how many times sequential increment is done from the starting key. 594 | Output is bytes 20*m of ETH address lowercase without 0x as hex string''' 595 | if m<=0: m = 1 596 | if pvk_int < 0: pvk_int = N+pvk_int 597 | start_pvk = fl(pvk_int).encode('utf8') 598 | res = ice.privatekey_group_to_ETH_address(start_pvk, m) 599 | addrlist = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 600 | ice.free_memory(res) 601 | return addrlist 602 | #============================================================================== 603 | def _privatekey_group_to_ETH_address_bytes(start_pvk, m): 604 | res = (b'\x00') * (20 * m) 605 | ice.privatekey_group_to_ETH_address_bytes(start_pvk, m, res) 606 | return res 607 | def privatekey_group_to_ETH_address_bytes(pvk_int, m): 608 | ''' Starting Privatekey Integer value passed to function as pvk_int. 609 | Integer m is, how many times sequential increment is done from the starting key. 610 | Output is bytes 20*m of ETH address lowercase without 0x''' 611 | if m<=0: m = 1 612 | if pvk_int < 0: pvk_int = N+pvk_int 613 | start_pvk = fl(pvk_int).encode('utf8') 614 | res = _privatekey_group_to_ETH_address_bytes(start_pvk, m) 615 | return bytes(bytearray(res)) 616 | #============================================================================== -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🐍Python-WebServer🐍 and 🐒Tampermonkey🐒 2 | 3 | Webserver_ice.py Hunt for Bitcoin Adresses starting 1, 3 and bc1 and ETH. New BloomFilter for Quicker database loading and search. Auto database Update included. 4 | 5 | Webserver_4.9.1.py Hunt for Bitcoin. Just addresses starting with 1 6 | 7 | Includes Auto Random and Auto Sequential. No NEED for tamper monkey. Amazing Program. 8 | ``` 9 | search field added. To use:(paste and remove focus by clicking) 10 | WIF search by WIF 11 | 1878574747 search by page number 12 | @764523535 search page by privatekey decimal 13 | $ffff or $FFFFF search page by privatekey hex 14 | [123] change increment 15 | (2345-8856464646) change random range 16 | (72057594037927937-144115188075855873) random range puzzle 64 17 | ``` 18 | 😊 😇 🙂Special THanks to Alex Curl for All his hard work😊 😇 🙂 19 | 20 | Also Special Thanks to https://github.com/evgenyunholy/UnholyMegaBrut for more Ideas and Bloomfilter Files check out his GitHub to get database.Also they can be downloaded from here. https://mega.nz/folder/e15hgDZR#ypdx7ULcBR6rvleFM8_CIA 21 | 22 | https://user-images.githubusercontent.com/88630056/164995299-07b12034-c064-4133-bf87-d57b08239fb0.mp4 23 | 24 | ![image](https://user-images.githubusercontent.com/88630056/163732565-e298e77e-bb2c-46f7-9b77-e94a1be53a77.png) 25 | 26 | ![image](https://user-images.githubusercontent.com/88630056/163732575-846162fe-dc77-4160-a90b-4bac14696e26.png) 27 | 28 | --------- 29 | # Requirements: 30 | - Python3 31 | - pip install base58 32 | - https://github.com/iceland2k14/secp256k1 files 33 | - ice_secp256k1.dll 34 | - ice_secp256k1.so 35 | - secp256k1.py 36 | - btcaddress.txt (One address per line) 37 | - ethaddress.txt (One address per line) 38 | - jquery-3.6.0.js 39 | --------- 40 | To Start 🐍Python-WebServer🐍: 41 | > python webserver.py 42 | --------- 43 | Start Searching in your Web browser: 44 | - localhost:3333/1 (start from first page) 45 | - localhost:3333/1[256] (change next increment) 46 | - localhost:3333/1(100-500) (change random range) 47 | - Puzzle 64 Start = 72057594037927937 Page 48 | - Puzzle 64 Stop = 144115188075855873 Page 49 | - Random Puzzle 64= http://localhost:3333/1(144115188075855873-288230376151711745) (change random range) 50 | 51 | - wif search = http://localhost:3333/L3VVpPhkahdq7S3DQovZYXXLfFX96o4nfGAgGpGZyJXVw2Fx4XvV 52 | - or http://localhost:3333/5HpHagT65TZzG1PH3CSu64HcGh19CVFzq1pFa44r8FXZrQAaefe 53 | 54 | - Dec search = http://localhost:3333/73824873287973477289749872 55 | - or Dec search and Highlight found http://localhost:3333/@73824873287973477289749872 56 | 57 | - HEX Search and Highlight found = http://localhost:3333/$fffffffff 58 | - or http://localhost:3333/$FFFFF 59 | 60 | --------- 61 | # Detailed Information from HEX 62 | 63 | ![image](https://user-images.githubusercontent.com/88630056/164998242-aec51051-1733-4d94-acc9-f5ef26506dd3.png) 64 | 65 | --------- 66 | 67 | ``` 68 | 1100001011011110000110000011100000000000011111110111001001110001101001010010111101100000011110000000110100000101010011010111001110001011110101110101110101011111000101100111101011111011000001111011010001111110010110110101010000011001111000011111111100001111 69 | (256 bits) 70 | 71 | c2de1838007f7271a52f60780d054d738bd75d5f167afb07b47e5b5419e1ff0f 72 | 73 | 88141099825256245673553921999835541760225970015052508404838443368591216738063 74 | 75 | Public ECDSA Key 76 | x: 4774b0a2ac0b325e5ab7d4687b2a63c7540d2655dccab35f72c201da1149f68e 77 | 78 | y: 9be0b93c52e19c16b95edd82fd009b8ce5a3840b23a9f720838c29486765a493 79 | 80 | x: 32320385601912921618066559609108982423772771673443867077080816380047029565070 81 | 82 | y: 70505543722316022944178389399213156382852026814587996716514675175858874197139 83 | 84 | x: 034774b0a2ac0b325e5ab7d4687b2a63c7540d2655dccab35f72c201da1149f68e 85 | 86 | Additive Inverse Point 87 | 3d21e7c7ff808d8e5ad09f87f2fab28b2ed77f8798cda5340b540338b6544232 88 | 89 | x: 4774b0a2ac0b325e5ab7d4687b2a63c7540d2655dccab35f72c201da1149f68e 90 | 91 | y: 641f46c3ad1e63e946a1227d02ff64731a5c7bf4dc5608df7c73d6b6989a579c 92 | 93 | B:No U: 1M3Wfm1qnyuZgKM5b4QBVUtro6KeVqgoLi C: 19xbDGGGuqCyBcGTEbvZu16DinJqdjMHZ7 94 | 95 | Two More Points same Y different X 96 | x: 867e7fcddaca8b7f9f85a77c0cf81d02d5bd8066f07b318fe0d1f1e9ca29a01e 97 | 98 | y: 9be0b93c52e19c16b95edd82fd009b8ce5a3840b23a9f720838c29486765a493 99 | 100 | B:No U: 1KxCXLZsDoTxhUhAFzxAb4dq1vooj1Zi1d C: 1Avd9PfFq248v2M7MMSbXxNhfJhTY32ssN 101 | 102 | x: 320ccf8f792a422205c2841b77dd7f35d635594332ba1b10ac6c0c3b248c6583 103 | 104 | y: 9be0b93c52e19c16b95edd82fd009b8ce5a3840b23a9f720838c29486765a493 105 | 106 | B:No U: 1M2oE13jszzS6twUSBxotktgy8jWbbrSVm C: 13q8qmXFYSeJqLqemFYyK3z7zwUtb78Uom 107 | 108 | RIPEMD-160 Hash 109 | U: 664f5c265188f85ba8b0e80b6c946a586d8b0663 C: 444c2585216c5e469ac860ad7dde21e8cbc58a55 110 | ``` 111 | 112 | --------- 113 | ## 🐒Tampermonkey🐒 Auto Refresh (Get Tamper Monkey https://www.tampermonkey.net/) 114 | 115 | For Older Websever.py Version. This Includes addresses starting3 bc1 and ETH. 116 | 117 | --------- 118 | ![image](https://user-images.githubusercontent.com/88630056/164068392-cecd6564-2316-4d0b-8c3e-362c1869f833.png) 119 | --------- 120 | ``` 121 | // ==UserScript== 122 | // @name Reload Server 123 | // @namespace http://tampermonkey.net/ 124 | // @version 1.0 125 | // @description Reload the Server, find the Key 126 | // @author AlphaCentury 127 | // @match http://localhost:3333/* 128 | // @grant none 129 | // ==/UserScript== 130 | /* global BigInt */ 131 | (function() { 132 | console.log('Go'); 133 | let val = 0n; 134 | while (val < 1n || val > 904625697166532776746648320380374280100293470930272690489102837043110636674n) { 135 | let num = ''; 136 | for (let i = 0; i < 75; i++) { 137 | num += Math.floor(Math.random() * 10); 138 | } 139 | val = BigInt(num); 140 | } 141 | setTimeout(function() { 142 | if (document.getElementsByClassName('filled').length !== 0 || document.getElementsByClassName('used').length !== 0) { 143 | alert('Address found!'); 144 | return; 145 | }; 146 | document.location.href = val.toString(); 147 | },50); 148 | })(); 149 | ``` 150 | --------- 151 | ## 🐒Tampermonkey🐒 Highlight and Stop.To find out more on how to use this visit https://mizogg.co.uk/tampermonkey/ ) 152 | 153 | Or Join Telegram Cryptocracker https://t.me/TeamHunter_GUI for instant updates and changes bigger database files to help with your hunt. 154 | --------- 155 | ``` 156 | // ==UserScript== 157 | // @name Bitcoin Highlighter All Sites 158 | // @namespace https://mizogg.co.uk 159 | // @author mizogg.co.uk 160 | // @version 1.0 161 | // @description Highlights BTC Addresses 162 | // @match https://* 163 | // @grant GM_registerMenuCommand 164 | // @grant GM_setValue 165 | // @grant GM_getValue 166 | // ==/UserScript== 167 | 168 | 169 | (function() { 170 | 'use strict'; 171 | 172 | if (window.self !== window.top) { return; } 173 | 174 | function setUserPref(varName, defaultVal, menuText, promtText, sep){ 175 | GM_registerMenuCommand(menuText, function() { 176 | var val = prompt(promtText, GM_getValue(varName, defaultVal)); 177 | if (val === null) { return; } 178 | if (sep && val){ 179 | var pat1 = new RegExp('\\s*' + sep + '+\\s*', 'g'); 180 | var pat2 = new RegExp('(?:^' + sep + '+|' + sep + '+$)', 'g'); 181 | val = val.replace(pat1, sep).replace(pat2, ''); 182 | } 183 | val = val.replace(/\s{2,}/g, ' ').trim(); 184 | GM_setValue(varName, val); 185 | if(!document.body.querySelector(".THmo")) THmo_doHighlight(document.body); 186 | else location.reload(); 187 | }); 188 | } 189 | 190 | setUserPref( 191 | 'keywords', 192 | 'word 1,word 2,word 3', 193 | 'Set Keywords', 194 | 'Set keywords separated by comma\t\t\t\t\t\t\t\r\n\r\nExample:\r\nword 1,word 2,word 3', 195 | ',' 196 | ); 197 | 198 | setUserPref( 199 | 'highlightStyle', 200 | 'color: #f00; background-color: #ffebcd;', 201 | 'Set Highlight Style', 202 | 'Set the Highlight Style (use proper CSS)\r\n\r\nExample:\r\ncolor: #f00; font-weight: bold; background-color: #ffe4b5;' 203 | ); 204 | 205 | var THmo_MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver; 206 | if (THmo_MutOb){ 207 | var THmo_chgMon = new THmo_MutOb(function(mutationSet){ 208 | mutationSet.forEach(function(mutation){ 209 | for (var i=0; i$1'); 246 | node.parentNode.replaceChild(sp, node); 247 | alert("NICE ONE BITCOINS FOUND!!!!!") 248 | } 249 | } 250 | } 251 | } 252 | THmo_doHighlight(document.body); 253 | })(); 254 | ``` 255 | 256 | Find Out More Join more Like me on Telegram https://t.me/TeamHunter_GUI 257 | -------------------------------------------------------------------------------- /Webserver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/Webserver.exe -------------------------------------------------------------------------------- /WebserverV2/Install_libraries.bat: -------------------------------------------------------------------------------- 1 | pip install simplebloomfilter 2 | pip install bitarray==1.9.2 3 | pip install base58 4 | pip install rich 5 | -------------------------------------------------------------------------------- /WebserverV2/Start_Bonus.bat: -------------------------------------------------------------------------------- 1 | @Echo off 2 | title webserver_bonus.py 3 | Pushd "%~dp0" 4 | :loop 5 | python webserver_bonus.py 6 | goto loop -------------------------------------------------------------------------------- /WebserverV2/Start_webserver_ice.bat: -------------------------------------------------------------------------------- 1 | @Echo off 2 | title webserver_ice.py 3 | Pushd "%~dp0" 4 | :loop 5 | python webserver_ice.py 6 | goto loop -------------------------------------------------------------------------------- /WebserverV2/btc.bf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/WebserverV2/btc.bf -------------------------------------------------------------------------------- /WebserverV2/eth.bf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/WebserverV2/eth.bf -------------------------------------------------------------------------------- /WebserverV2/ice_secp256k1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/WebserverV2/ice_secp256k1.dll -------------------------------------------------------------------------------- /WebserverV2/ice_secp256k1.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/WebserverV2/ice_secp256k1.so -------------------------------------------------------------------------------- /WebserverV2/secp256k1.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 4 | @author: iceland 5 | """ 6 | 7 | import platform 8 | import os 9 | import sys 10 | import ctypes 11 | import math 12 | import pickle 13 | 14 | ############################################################################### 15 | N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 16 | Zero=b'\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 17 | #============================================================================== 18 | if platform.system().lower().startswith('win'): 19 | dir_path = os.path.dirname(os.path.realpath(__file__)) 20 | dllfile = dir_path + '/ice_secp256k1.dll' 21 | if os.path.isfile(dllfile) == True: 22 | pathdll = os.path.realpath(dllfile) 23 | ice = ctypes.CDLL(pathdll) 24 | else: 25 | print('File {} not found'.format(dllfile)) 26 | 27 | elif platform.system().lower().startswith('lin'): 28 | dir_path = os.path.dirname(os.path.realpath(__file__)) 29 | dllfile = dir_path + '/ice_secp256k1.so' 30 | if os.path.isfile(dllfile) == True: 31 | pathdll = os.path.realpath(dllfile) 32 | ice = ctypes.CDLL(pathdll) 33 | else: 34 | print('File {} not found'.format(dllfile)) 35 | 36 | else: 37 | print('[-] Unsupported Platform currently for ctypes dll method. Only [Windows and Linux] is working') 38 | sys.exit() 39 | ############################################################################### 40 | #============================================================================== 41 | # Coin type 42 | COIN_BTC = 0 43 | COIN_BSV = 1 44 | COIN_BTCD = 2 45 | COIN_ARG = 3 46 | COIN_AXE = 4 47 | COIN_BC = 5 48 | COIN_BCH = 6 49 | COIN_BSD = 7 50 | COIN_BTDX = 8 51 | COIN_BTG = 9 52 | COIN_BTX = 10 53 | COIN_CHA = 11 54 | COIN_DASH = 12 55 | COIN_DCR = 13 56 | COIN_DFC = 14 57 | COIN_DGB = 15 58 | COIN_DOGE = 16 59 | COIN_FAI = 17 60 | COIN_FTC = 18 61 | COIN_GRS = 19 62 | COIN_JBS = 20 63 | COIN_LTC = 21 64 | COIN_MEC = 22 65 | COIN_MONA = 23 66 | COIN_MZC = 24 67 | COIN_PIVX = 25 68 | COIN_POLIS= 26 69 | COIN_RIC = 27 70 | COIN_STRAT= 28 71 | COIN_SMART= 29 72 | COIN_VIA = 30 73 | COIN_XMY = 31 74 | COIN_ZEC = 32 75 | COIN_ZCL = 33 76 | COIN_ZERO = 34 77 | COIN_ZEN = 35 78 | COIN_TENT = 36 79 | COIN_ZEIT = 37 80 | COIN_VTC = 38 81 | COIN_UNO = 39 82 | COIN_SKC = 40 83 | COIN_RVN = 41 84 | COIN_PPC = 42 85 | COIN_OMC = 43 86 | COIN_OK = 44 87 | COIN_NMC = 45 88 | COIN_NLG = 46 89 | COIN_LBRY = 47 90 | COIN_DNR = 48 91 | COIN_BWK = 49 92 | 93 | #============================================================================== 94 | ice.scalar_multiplication.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # pvk,ret 95 | #============================================================================== 96 | ice.scalar_multiplications.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p] # pvk,len,ret 97 | #============================================================================== 98 | ice.get_x_to_y.argtypes = [ctypes.c_char_p, ctypes.c_bool, ctypes.c_char_p] # x,even,ret 99 | #============================================================================== 100 | ice.point_increment.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 101 | #============================================================================== 102 | ice.point_negation.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 103 | #============================================================================== 104 | ice.point_doubling.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 105 | #============================================================================== 106 | ice.privatekey_to_coinaddress.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # intcoin,012,comp,pvk 107 | ice.privatekey_to_coinaddress.restype = ctypes.c_void_p 108 | #============================================================================== 109 | ice.privatekey_to_address.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # 012,comp,pvk 110 | ice.privatekey_to_address.restype = ctypes.c_void_p 111 | #============================================================================== 112 | ice.hash_to_address.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # 012,comp,hash 113 | ice.hash_to_address.restype = ctypes.c_void_p 114 | #============================================================================== 115 | ice.pubkey_to_address.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # 012,comp,upub 116 | ice.pubkey_to_address.restype = ctypes.c_void_p 117 | #============================================================================== 118 | ice.privatekey_to_h160.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # 012,comp,pvk,ret 119 | #============================================================================== 120 | ice.privatekey_loop_h160.argtypes = [ctypes.c_ulonglong, ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # num,012,comp,pvk,ret 121 | #============================================================================== 122 | ice.privatekey_loop_h160_sse.argtypes = [ctypes.c_ulonglong, ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # num,012,comp,pvk,ret 123 | #============================================================================== 124 | ice.pubkey_to_h160.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # 012,comp,upub,ret 125 | #============================================================================== 126 | ice.pbkdf2_hmac_sha512_dll.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int] # ret, words, len 127 | #============================================================================== 128 | ice.pbkdf2_hmac_sha512_list.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_int, ctypes.c_ulonglong] # ret,words,len,mnem_size,total 129 | #============================================================================== 130 | ice.pub_endo1.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 131 | #============================================================================== 132 | ice.pub_endo2.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 133 | #============================================================================== 134 | ice.b58_encode.argtypes = [ctypes.c_char_p] # _h 135 | ice.b58_encode.restype = ctypes.c_void_p 136 | #============================================================================== 137 | ice.b58_decode.argtypes = [ctypes.c_char_p] # addr 138 | ice.b58_decode.restype = ctypes.c_void_p 139 | #============================================================================== 140 | ice.bech32_address_decode.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_char_p] # coin,b32_addr,h160 141 | #============================================================================== 142 | ice.get_sha256.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p] # input, len, ret 143 | #============================================================================== 144 | ice.create_baby_table.argtypes = [ctypes.c_ulonglong, ctypes.c_ulonglong, ctypes.c_char_p] # start,end,ret 145 | #============================================================================== 146 | ice.point_addition.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # upub1,upub2,ret 147 | #============================================================================== 148 | ice.point_subtraction.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # upub1,upub2,ret 149 | #============================================================================== 150 | ice.point_loop_subtraction.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # k,upub1,upub2,ret 151 | #============================================================================== 152 | ice.point_loop_addition.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # k,upub1,upub2,ret 153 | #============================================================================== 154 | ice.point_vector_addition.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # num,upubs1,upubs2,ret 155 | #============================================================================== 156 | ice.point_sequential_increment_P2.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p] # num,upub1,ret 157 | #============================================================================== 158 | ice.point_sequential_increment_P2_mcpu.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p] # num,upub1,mcpu,ret 159 | #============================================================================== 160 | ice.point_sequential_increment.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p] # num,upub1,ret 161 | #============================================================================== 162 | ice.point_sequential_decrement.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p] # num,upub1,ret 163 | #============================================================================== 164 | ice.pubkeyxy_to_ETH_address.argtypes = [ctypes.c_char_p] # upub_xy 165 | ice.pubkeyxy_to_ETH_address.restype = ctypes.c_void_p 166 | #============================================================================== 167 | ice.pubkeyxy_to_ETH_address_bytes.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub_xy, ret 168 | #============================================================================== 169 | ice.privatekey_to_ETH_address.argtypes = [ctypes.c_char_p] # pvk 170 | ice.privatekey_to_ETH_address.restype = ctypes.c_void_p 171 | #============================================================================== 172 | ice.privatekey_to_ETH_address_bytes.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # pvk, ret 173 | #============================================================================== 174 | ice.privatekey_group_to_ETH_address.argtypes = [ctypes.c_char_p, ctypes.c_int] # pvk, m 175 | ice.privatekey_group_to_ETH_address.restype = ctypes.c_void_p 176 | #============================================================================== 177 | ice.privatekey_group_to_ETH_address_bytes.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p] # pvk,m,ret 178 | #============================================================================== 179 | ice.init_P2_Group.argtypes = [ctypes.c_char_p] # upub 180 | #============================================================================== 181 | ice.free_memory.argtypes = [ctypes.c_void_p] # pointer 182 | #============================================================================== 183 | ice.bloom_check_add.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong, ctypes.c_ubyte, ctypes.c_char_p] #buff, len, 0_1, _bits, _hashes, _bf 184 | ice.bloom_check_add.restype = ctypes.c_int 185 | #============================================================================== 186 | ice.bloom_batch_add.argtypes = [ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong, ctypes.c_ubyte, ctypes.c_char_p] #chunk, buff, len, 0_1, _bits, _hashes, _bf 187 | #============================================================================== 188 | ice.bloom_check_add_mcpu.argtypes = [ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong, ctypes.c_ubyte, ctypes.c_char_p] #buff, num_items, found_array, len, mcpu, 0_1, _bits, _hashes, _bf 189 | #============================================================================== 190 | ice.test_bit_set_bit.argtypes = [ctypes.c_char_p, ctypes.c_ulonglong, ctypes.c_int] #_bf, _bits, 0_1 191 | #============================================================================== 192 | ice.create_bsgs_bloom_mcpu.argtypes = [ctypes.c_int, ctypes.c_ulonglong, ctypes.c_ulonglong, ctypes.c_ubyte, ctypes.c_char_p] #mcpu, num_items, _bits, _hashes, _bf 193 | #============================================================================== 194 | ice.bsgs_2nd_check_prepare.argtypes = [ctypes.c_ulonglong] # bP_elem 195 | #============================================================================== 196 | ice.bsgs_2nd_check.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulonglong, ctypes.c_char_p] # upub, z1, bP_elem, ret 197 | ice.bsgs_2nd_check.restype = ctypes.c_bool #True or False 198 | #============================================================================== 199 | ice.Load_data_to_memory.argtypes = [ctypes.c_char_p, ctypes.c_bool] #sorted_bin_file_h160, verbose 200 | #============================================================================== 201 | ice.check_collision.argtypes = [ctypes.c_char_p] #h160 202 | ice.check_collision.restype = ctypes.c_bool #True or False 203 | 204 | ice.init_secp256_lib() 205 | #============================================================================== 206 | ############################################################################### 207 | 208 | 209 | def version(): 210 | ice.version() 211 | #============================================================================== 212 | def _scalar_multiplication(pvk_int): 213 | ''' Integer value passed to function. 65 bytes uncompressed pubkey output ''' 214 | res = (b'\x00') * 65 215 | pass_int_value = fl(pvk_int).encode('utf8') 216 | ice.scalar_multiplication(pass_int_value, res) 217 | return res 218 | def scalar_multiplication(pvk_int): 219 | if pvk_int < 0: pvk_int = N+pvk_int 220 | res = _scalar_multiplication(pvk_int) 221 | return bytes(bytearray(res)) 222 | #============================================================================== 223 | def _scalar_multiplications(pvk_int_list): 224 | ''' Integer list passed to function. 65*len bytes uncompressed pubkey output. No Zero Point handling ''' 225 | sz = len(pvk_int_list) 226 | res = (b'\x00') * (65 * sz) 227 | pvks = b''.join(pvk_int_list) 228 | ice.scalar_multiplications(pvks, sz, res) 229 | return res 230 | def scalar_multiplications(pvk_int_list): 231 | pvk_int_list = [bytes.fromhex(fl(N+i)) if i < 0 else bytes.fromhex(fl(i)) for i in pvk_int_list] 232 | res = _scalar_multiplications(pvk_int_list) 233 | return bytes(bytearray(res)) 234 | #============================================================================== 235 | # ============================================================================= 236 | # def point_multiplication(k, P): 237 | # ''' k=scalar. P = Input Point. Output is 65 bytes uncompressed pubkey ''' 238 | # if type(P) == int: k,P = P,k 239 | # def bits(k): 240 | # while k: 241 | # yield k & 1 242 | # k >>= 1 243 | # result = Zero 244 | # addend = P 245 | # for bit in bits(k): 246 | # if bit == 1: result=point_addition(result,addend) 247 | # addend=point_doubling(addend) 248 | # return result 249 | # ============================================================================= 250 | #============================================================================== 251 | def _point_multiplication(pubkey_bytes, kk): 252 | ''' Input Point and Integer value passed to function. 65 bytes uncompressed pubkey output ''' 253 | res = (b'\x00') * 65 254 | bytes_value = bytes.fromhex(hex(kk)[2:].zfill(64)) # strict 32 bytes scalar 255 | ice.point_multiplication(pubkey_bytes, bytes_value, res) 256 | return res 257 | def point_multiplication(P, k): 258 | if type(P) == int: k,P = P,k 259 | res = _point_multiplication(P, k) 260 | return bytes(bytearray(res)) 261 | 262 | #============================================================================== 263 | def _get_x_to_y(x_hex, is_even): 264 | ''' Input x_hex encoded as bytes and bool is_even. 32 bytes y of point output ''' 265 | res = (b'\x00') * 32 266 | ice.get_x_to_y(x_hex.encode('utf8'), is_even, res) 267 | return res 268 | def get_x_to_y(x_hex, is_even): 269 | res = _get_x_to_y(x_hex, is_even) 270 | return bytes(bytearray(res)) 271 | #============================================================================== 272 | def _point_increment(pubkey_bytes): 273 | res = (b'\x00') * 65 274 | ice.point_increment(pubkey_bytes, res) 275 | return res 276 | def point_increment(pubkey_bytes): 277 | res = _point_increment(pubkey_bytes) 278 | return bytes(bytearray(res)) 279 | #============================================================================== 280 | def _point_negation(pubkey_bytes): 281 | res = (b'\x00') * 65 282 | ice.point_negation(pubkey_bytes, res) 283 | return res 284 | def point_negation(pubkey_bytes): 285 | res = _point_negation(pubkey_bytes) 286 | return bytes(bytearray(res)) 287 | #============================================================================== 288 | def _point_doubling(pubkey_bytes): 289 | res = (b'\x00') * 65 290 | ice.point_doubling(pubkey_bytes, res) 291 | return res 292 | def point_doubling(pubkey_bytes): 293 | res = _point_doubling(pubkey_bytes) 294 | return bytes(bytearray(res)) 295 | #============================================================================== 296 | def init_P2_Group(pubkey_bytes): 297 | ice.init_P2_Group(pubkey_bytes) 298 | #============================================================================== 299 | def privatekey_to_coinaddress(coin_type, addr_type, iscompressed, pvk_int): 300 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 301 | if pvk_int < 0: pvk_int = N+pvk_int 302 | pass_int_value = fl(pvk_int).encode('utf8') 303 | res = ice.privatekey_to_coinaddress(coin_type, addr_type, iscompressed, pass_int_value) 304 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 305 | ice.free_memory(res) 306 | return addr 307 | #============================================================================== 308 | def privatekey_to_address(addr_type, iscompressed, pvk_int): 309 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 310 | if pvk_int < 0: pvk_int = N+pvk_int 311 | pass_int_value = fl(pvk_int).encode('utf8') 312 | res = ice.privatekey_to_address(addr_type, iscompressed, pass_int_value) 313 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 314 | ice.free_memory(res) 315 | return addr 316 | #============================================================================== 317 | def hash_to_address(addr_type, iscompressed, hash160_bytes): 318 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 319 | res = ice.hash_to_address(addr_type, iscompressed, hash160_bytes) 320 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 321 | ice.free_memory(res) 322 | return addr 323 | #============================================================================== 324 | def pubkey_to_address(addr_type, iscompressed, pubkey_bytes): 325 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 326 | res = ice.pubkey_to_address(addr_type, iscompressed, pubkey_bytes) 327 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 328 | ice.free_memory(res) 329 | return addr 330 | #============================================================================== 331 | def _privatekey_to_h160(addr_type, iscompressed, pvk_int): 332 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 333 | if pvk_int < 0: pvk_int = N+pvk_int 334 | pass_int_value = fl(pvk_int).encode('utf8') 335 | res = (b'\x00') * 20 336 | ice.privatekey_to_h160(addr_type, iscompressed, pass_int_value, res) 337 | return res 338 | def privatekey_to_h160(addr_type, iscompressed, pvk_int): 339 | res = _privatekey_to_h160(addr_type, iscompressed, pvk_int) 340 | return bytes(bytearray(res)) 341 | #============================================================================== 342 | def _privatekey_loop_h160(num, addr_type, iscompressed, pvk_int): 343 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 344 | if pvk_int < 0: pvk_int = N+pvk_int 345 | pass_int_value = fl(pvk_int).encode('utf8') 346 | res = (b'\x00') * (20 * num) 347 | ice.privatekey_loop_h160(num, addr_type, iscompressed, pass_int_value, res) 348 | return res 349 | def privatekey_loop_h160(num, addr_type, iscompressed, pvk_int): 350 | if num <= 0: num = 1 351 | res = _privatekey_loop_h160(num, addr_type, iscompressed, pvk_int) 352 | return bytes(bytearray(res)) 353 | #============================================================================== 354 | def _privatekey_loop_h160_sse(num, addr_type, iscompressed, pvk_int): 355 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 356 | if pvk_int < 0: pvk_int = N+pvk_int 357 | pass_int_value = fl(pvk_int).encode('utf8') 358 | res = (b'\x00') * (20 * num) 359 | ice.privatekey_loop_h160_sse(num, addr_type, iscompressed, pass_int_value, res) 360 | return res 361 | def privatekey_loop_h160_sse(num, addr_type, iscompressed, pvk_int): 362 | if num <= 0: num = 1 363 | res = _privatekey_loop_h160_sse(num, addr_type, iscompressed, pvk_int) 364 | return bytes(bytearray(res)) 365 | #============================================================================== 366 | def _pubkey_to_h160(addr_type, iscompressed, pubkey_bytes): 367 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 368 | res = (b'\x00') * 20 369 | ice.pubkey_to_h160(addr_type, iscompressed, pubkey_bytes, res) 370 | return res 371 | def pubkey_to_h160(addr_type, iscompressed, pubkey_bytes): 372 | res = _pubkey_to_h160(addr_type, iscompressed, pubkey_bytes) 373 | return bytes(bytearray(res)) 374 | #============================================================================== 375 | def _pub_endo1(pubkey_bytes): 376 | res = (b'\x00') * 65 377 | ice.pub_endo1(pubkey_bytes, res) 378 | return res 379 | def pub_endo1(pubkey_bytes): 380 | res = _pub_endo1(pubkey_bytes) 381 | return bytes(bytearray(res)) 382 | #============================================================================== 383 | def _pub_endo2(pubkey_bytes): 384 | res = (b'\x00') * 65 385 | ice.pub_endo2(pubkey_bytes, res) 386 | return res 387 | def pub_endo2(pubkey_bytes): 388 | res = _pub_endo2(pubkey_bytes) 389 | return bytes(bytearray(res)) 390 | #============================================================================== 391 | def b58py(data): 392 | B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" 393 | 394 | if data[0] == 0: 395 | return "1" + b58py(data[1:]) 396 | 397 | x = sum([v * (256 ** i) for i, v in enumerate(data[::-1])]) 398 | ret = "" 399 | while x > 0: 400 | ret = B58[x % 58] + ret 401 | x = x // 58 402 | 403 | return ret 404 | #============================================================================== 405 | def b58_encode(inp_bytes): 406 | res = ice.b58_encode(inp_bytes, len(inp_bytes)) 407 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 408 | ice.free_memory(res) 409 | return addr 410 | #============================================================================== 411 | def b58_decode(inp): 412 | res = ice.b58_decode(inp.encode("utf-8")) 413 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 414 | ice.free_memory(res) 415 | return addr 416 | #============================================================================== 417 | def bech32_address_decode(addr, coin_type=0): 418 | ''' Input address in String format. Output h160 in hex string format 419 | [Note] p2wsh = bech32(sha256(21 + pubkey + ac)). So Decoding it not Needed ''' 420 | if len(addr) > 50: print('[Error] Bech32 p2wsh Not Supported. Result Truncated') 421 | h160 = (b'\x00') * 20 422 | ice.bech32_address_decode(coin_type, addr.encode("utf-8"), h160) 423 | return bytes(bytearray(h160)).hex() 424 | #============================================================================== 425 | def address_to_h160(p2pkh): 426 | ''' Input address in String format. Output h160 in hex string format''' 427 | h1 = b58_decode(p2pkh) 428 | return h1[2:-8] 429 | #============================================================================== 430 | def btc_wif_to_pvk_hex(wif): 431 | pvk = '' 432 | if wif[0] == '5': 433 | pvk = b58_decode(wif)[2:-8] 434 | elif wif[0] in ['L', 'K']: 435 | pvk = b58_decode(wif)[2:-10] 436 | else: print('[Error] Incorrect WIF Key') 437 | return pvk 438 | #============================================================================== 439 | def btc_wif_to_pvk_int(wif): 440 | pvk = '' 441 | pvk_hex = btc_wif_to_pvk_hex(wif) 442 | if pvk_hex != '': pvk = int(pvk_hex, 16) 443 | return pvk 444 | #============================================================================== 445 | def btc_pvk_to_wif(pvk, is_compressed=True): 446 | ''' Input Privatekey can in any 1 of these [Integer] [Hex] [Bytes] form''' 447 | inp = '' 448 | suff = '01' if is_compressed == True else '' 449 | if type(pvk) in [int, str]: inp = bytes.fromhex('80' + fl(pvk) + suff) 450 | elif type(pvk) == bytes: inp = b'\x80' + fl(pvk) + bytes.fromhex(suff) 451 | else: print("[Error] Input Privatekey format [Integer] [Hex] [Bytes] allowed only") 452 | if inp != '': 453 | res = get_sha256(inp) 454 | res2 = get_sha256(res) 455 | return b58_encode(inp + res2[:4]) 456 | else: return inp 457 | #============================================================================== 458 | def checksum(inp): 459 | ''' Input string output double sha256 checksum 4 bytes''' 460 | res = get_sha256(inp) 461 | res2 = get_sha256(res) 462 | return res2[:4] 463 | #============================================================================== 464 | def fl(sstr, length=64): 465 | ''' Fill input to exact 32 bytes. If input is int or str the return is str. if input is bytes return is bytes''' 466 | if type(sstr) == int: fixed = hex(sstr)[2:].zfill(length) 467 | elif type(sstr) == str: fixed = sstr[2:].zfill(length) if sstr[:2].lower() == '0x' else sstr.zfill(length) 468 | elif type(sstr) == bytes: fixed = (b'\x00') * (32 - len(sstr)) + sstr 469 | else: print("[Error] Input format [Integer] [Hex] [Bytes] allowed only. Detected : ", type(sstr)) 470 | return fixed 471 | #============================================================================== 472 | def pbkdf2_hmac_sha512_dll(words): 473 | seed_bytes = (b'\x00') * 64 474 | # words = 'good push broken people salad bar mad squirrel joy dismiss merge jeans token wear boring manual doll near sniff turtle sunset lend invest foil' 475 | ice.pbkdf2_hmac_sha512_dll(seed_bytes, words.encode("utf-8"), len(words)) 476 | return seed_bytes 477 | #============================================================================== 478 | def pbkdf2_hmac_sha512_list(words_list): 479 | ''' strength is [12, 18, 24]. words_list is a list of strings with each line having valid mnemonics''' 480 | wl = len(words_list) 481 | strength = len(words_list[0].split()) 482 | words = ' '.join(words_list) 483 | seed_bytes = (b'\x00') * (64 * wl) 484 | # words = 'good push broken people salad bar mad squirrel joy dismiss merge jeans token wear boring manual doll near sniff turtle sunset lend invest foil' 485 | ice.pbkdf2_hmac_sha512_list(seed_bytes, words.encode("utf-8"), len(words), strength, wl) 486 | return seed_bytes 487 | #============================================================================== 488 | def get_sha256(input_bytes): 489 | digest_bytes = (b'\x00') * 32 490 | if type(input_bytes) == str: input_bytes = input_bytes.encode("utf-8") 491 | # MiniKey example 492 | ice.get_sha256(input_bytes, len(input_bytes), digest_bytes) 493 | return digest_bytes 494 | #============================================================================== 495 | def create_baby_table(start_value, end_value): 496 | res = (b'\x00') * ((1+end_value-start_value) * 32) 497 | ice.create_baby_table(start_value, end_value, res) 498 | return bytes(bytearray(res)) 499 | #============================================================================== 500 | def _point_addition(pubkey1_bytes, pubkey2_bytes): 501 | res = (b'\x00') * 65 502 | ice.point_addition(pubkey1_bytes, pubkey2_bytes, res) 503 | return res 504 | def point_addition(pubkey1_bytes, pubkey2_bytes): 505 | res = _point_addition(pubkey1_bytes, pubkey2_bytes) 506 | return bytes(bytearray(res)) 507 | #============================================================================== 508 | def _point_subtraction(pubkey1_bytes, pubkey2_bytes): 509 | res = (b'\x00') * 65 510 | ice.point_subtraction(pubkey1_bytes, pubkey2_bytes, res) 511 | return res 512 | def point_subtraction(pubkey1_bytes, pubkey2_bytes): 513 | res = _point_subtraction(pubkey1_bytes, pubkey2_bytes) 514 | return bytes(bytearray(res)) 515 | #============================================================================== 516 | def _point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes): 517 | res = (b'\x00') * (65 * num) 518 | ice.point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes, res) 519 | return res 520 | def point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes): 521 | ''' Continuously subtracting point2 into point1 in a loop of num times. 522 | Output is array of pubkeys P1-P2, P1-2P2, P1-3P2, P1-4P2....''' 523 | if num <= 0: num = 1 524 | res = _point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes) 525 | return bytes(bytearray(res)) 526 | #============================================================================== 527 | def _point_loop_addition(num, pubkey1_bytes, pubkey2_bytes): 528 | res = (b'\x00') * (65 * num) 529 | ice.point_loop_addition(num, pubkey1_bytes, pubkey2_bytes, res) 530 | return res 531 | def point_loop_addition(num, pubkey1_bytes, pubkey2_bytes): 532 | ''' Continuously adding point2 into point1 in a loop of num times. 533 | Output is array of pubkeys P1+P2, P1+2P2, P1+3P2, P1+4P2....''' 534 | if num <= 0: num = 1 535 | res = _point_loop_addition(num, pubkey1_bytes, pubkey2_bytes) 536 | return bytes(bytearray(res)) 537 | #============================================================================== 538 | def _point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes): 539 | res = (b'\x00') * (65 * num) 540 | ice.point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes, res) 541 | return res 542 | def point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes): 543 | ''' Adding two array of points of equal length. ''' 544 | if num <= 0: num = 1 545 | res = _point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes) 546 | return bytes(bytearray(res)) 547 | #============================================================================== 548 | def _point_sequential_increment_P2(num, pubkey1_bytes): 549 | res = (b'\x00') * (65 * num) 550 | ice.point_sequential_increment_P2(num, pubkey1_bytes, res) 551 | return res 552 | def point_sequential_increment_P2(num, pubkey1_bytes): 553 | ''' This is the fastest implementation to add point P2 in the given Point sequentially.''' 554 | if num <= 0: num = 1 555 | res = _point_sequential_increment_P2(num, pubkey1_bytes) 556 | return bytes(bytearray(res)) 557 | #============================================================================== 558 | def _point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu): 559 | res = (b'\x00') * (65 * num) 560 | ice.point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu, res) 561 | return res 562 | def point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu=os.cpu_count()): 563 | ''' This is the fastest multi CPU implementation to add point P2 in the given Point sequentially. Threads are Not optimised yet''' 564 | if num <= 0: num = 1 565 | res = _point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu) 566 | return bytes(bytearray(res)) 567 | #============================================================================== 568 | def _point_sequential_increment(num, pubkey1_bytes): 569 | res = (b'\x00') * (65 * num) 570 | ice.point_sequential_increment(num, pubkey1_bytes, res) 571 | return res 572 | def point_sequential_increment(num, pubkey1_bytes): 573 | ''' This is the fastest implementation using G''' 574 | if num <= 0: num = 1 575 | res = _point_sequential_increment(num, pubkey1_bytes) 576 | return bytes(bytearray(res)) 577 | #============================================================================== 578 | def _point_sequential_decrement(num, pubkey1_bytes): 579 | res = (b'\x00') * (65 * num) 580 | ice.point_sequential_decrement(num, pubkey1_bytes, res) 581 | return res 582 | def point_sequential_decrement(num, pubkey1_bytes): 583 | ''' This is the fastest implementation using -G.''' 584 | if num <= 0: num = 1 585 | res = _point_sequential_decrement(num, pubkey1_bytes) 586 | return bytes(bytearray(res)) 587 | #============================================================================== 588 | def pubkey_to_ETH_address(pubkey_bytes): 589 | ''' 65 Upub bytes input. Output is 20 bytes ETH address lowercase with 0x as hex string''' 590 | xy = pubkey_bytes[1:] 591 | res = ice.pubkeyxy_to_ETH_address(xy) 592 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 593 | ice.free_memory(res) 594 | return '0x'+addr 595 | #============================================================================== 596 | def _pubkey_to_ETH_address_bytes(xy): 597 | res = (b'\x00') * 20 598 | ice.pubkeyxy_to_ETH_address_bytes(xy, res) 599 | return res 600 | def pubkey_to_ETH_address_bytes(pubkey_bytes): 601 | ''' 65 Upub bytes input. Output is 20 bytes ETH address lowercase without 0x''' 602 | xy = pubkey_bytes[1:] 603 | res = _pubkey_to_ETH_address_bytes(xy) 604 | return bytes(bytearray(res)) 605 | #============================================================================== 606 | def privatekey_to_ETH_address(pvk_int): 607 | ''' Privatekey Integer value passed to function. Output is 20 bytes ETH address lowercase with 0x as hex string''' 608 | if pvk_int < 0: pvk_int = N+pvk_int 609 | pass_int_value = fl(pvk_int).encode('utf8') 610 | res = ice.privatekey_to_ETH_address(pass_int_value) 611 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 612 | ice.free_memory(res) 613 | return '0x'+addr 614 | #============================================================================== 615 | def _privatekey_to_ETH_address_bytes(pass_int_value): 616 | res = (b'\x00') * 20 617 | ice.privatekey_to_ETH_address_bytes(pass_int_value, res) 618 | return res 619 | def privatekey_to_ETH_address_bytes(pvk_int): 620 | ''' Privatekey Integer value passed to function. Output is 20 bytes ETH address lowercase without 0x''' 621 | if pvk_int < 0: pvk_int = N+pvk_int 622 | pass_int_value = fl(pvk_int).encode('utf8') 623 | res = _privatekey_to_ETH_address_bytes(pass_int_value) 624 | return bytes(bytearray(res)) 625 | #============================================================================== 626 | def privatekey_group_to_ETH_address(pvk_int, m): 627 | ''' Starting Privatekey Integer value passed to function as pvk_int. 628 | Integer m is, how many times sequential increment is done from the starting key. 629 | Output is bytes 20*m of ETH address lowercase without 0x as hex string''' 630 | if m<=0: m = 1 631 | if pvk_int < 0: pvk_int = N+pvk_int 632 | start_pvk = fl(pvk_int).encode('utf8') 633 | res = ice.privatekey_group_to_ETH_address(start_pvk, m) 634 | addrlist = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 635 | ice.free_memory(res) 636 | return addrlist 637 | #============================================================================== 638 | def _privatekey_group_to_ETH_address_bytes(start_pvk, m): 639 | res = (b'\x00') * (20 * m) 640 | ice.privatekey_group_to_ETH_address_bytes(start_pvk, m, res) 641 | return res 642 | def privatekey_group_to_ETH_address_bytes(pvk_int, m): 643 | ''' Starting Privatekey Integer value passed to function as pvk_int. 644 | Integer m is, how many times sequential increment is done from the starting key. 645 | Output is bytes 20*m of ETH address lowercase without 0x''' 646 | if m<=0: m = 1 647 | if pvk_int < 0: pvk_int = N+pvk_int 648 | start_pvk = fl(pvk_int).encode('utf8') 649 | res = _privatekey_group_to_ETH_address_bytes(start_pvk, m) 650 | return bytes(bytearray(res)) 651 | #============================================================================== 652 | def bloom_check_add_mcpu(bigbuff, num_items, sz, mcpu, check_add, bloom_bits, bloom_hashes, bloom_filter): 653 | found_array = (b'\x00') * num_items 654 | # sz = 32; check_add = 0 for check and 1 for add 655 | ice.bloom_check_add_mcpu(bigbuff, num_items, found_array, sz, mcpu, check_add, bloom_bits, bloom_hashes, bloom_filter) 656 | return found_array 657 | #============================================================================== 658 | def to_cpub(pub_hex): 659 | P = pub_hex 660 | if len(pub_hex) > 70: 661 | P = '02' + pub_hex[2:66] if int(pub_hex[66:],16)%2 == 0 else '03' + pub_hex[2:66] 662 | return P 663 | #============================================================================== 664 | def point_to_cpub(pubkey_bytes): 665 | P = pubkey_bytes.hex() 666 | if len(P) > 70: 667 | P = '02' + P[2:66] if int(P[66:],16)%2 == 0 else '03' + P[2:66] 668 | return P 669 | #============================================================================== 670 | def pub2upub(pub_hex): 671 | ''' Covert [C or U] pubkey to Point''' 672 | x = pub_hex[2:66] 673 | if len(pub_hex) < 70: 674 | y = get_x_to_y(x, int(pub_hex[:2],16)%2 == 0).hex() 675 | else: 676 | y = pub_hex[66:].zfill(64) 677 | return bytes.fromhex('04'+ x + y) 678 | #============================================================================== 679 | def bloom_para(_items, _fp = 0.000001): 680 | _bits = math.ceil((_items * math.log(_fp)) / math.log(1 / pow(2, math.log(2)))) 681 | if _bits % 8: _bits = 8*(1 + (_bits//8)) 682 | _hashes = round((_bits / _items) * math.log(2)) 683 | return _bits, _hashes 684 | #============================================================================== 685 | def Fill_in_bloom(inp_list, _fp = 0.000001): 686 | _bits, _hashes = bloom_para(len(inp_list), _fp) 687 | _bf = (b'\x00') * (_bits//8) 688 | for line in inp_list: 689 | if type(line) != bytes: tt = str(line).encode("utf-8") 690 | else: tt = line 691 | res = ice.bloom_check_add(tt, len(tt), 1, _bits, _hashes, _bf) # 1 = Add 692 | del res 693 | return _bits, _hashes, _bf, _fp, len(inp_list) 694 | #============================================================================== 695 | def dump_bloom_file(output_bloom_file_name, _bits, _hashes, _bf, _fp, _elem): 696 | with open(output_bloom_file_name, 'wb') as f: 697 | pickle.dump((_bits, _hashes, _bf, _fp, _elem), f) 698 | 699 | def read_bloom_file(bloom_file_name): 700 | '''It will return the 5 output as _bits, _hashes, _bf, _fp, _elem''' 701 | with open(bloom_file_name, 'rb') as f: 702 | return pickle.load(f) 703 | #============================================================================== 704 | def check_in_bloom(this_line, _bits, _hashes, _bf): 705 | if type(this_line) != bytes: tt = str(this_line).encode("utf-8") 706 | else: tt = this_line 707 | if ice.bloom_check_add(tt, len(tt), 0, _bits, _hashes, _bf) > 0: return True 708 | else: return False 709 | #============================================================================== 710 | def create_bsgs_bloom_mcpu(mcpu, total_entries, _fp = 0.0000001): 711 | if total_entries%(mcpu*1000) != 0: 712 | total_entries = mcpu*1000*(total_entries//(mcpu*1000)) 713 | if total_entries == 0: total_entries = mcpu * 1000 714 | print('[*] Number of elements should be a multiple of 1000*mcpu. Automatically corrected it to nearest value:',total_entries) 715 | _bits, _hashes = bloom_para(total_entries, _fp) 716 | _bf = bytes(b'\x00') * (_bits//8) 717 | print(f'[+] bloom [bits: {_bits}] [hashes: {_hashes}] [size: {_bits//8} Bytes] [false prob: {_fp}]') 718 | ice.create_bsgs_bloom_mcpu(mcpu, total_entries, _bits, _hashes, _bf) 719 | return _bits, _hashes, _bf, _fp, total_entries 720 | #============================================================================== 721 | def bsgs_2nd_check_prepare(bP_elem = 2000000000): 722 | if bP_elem < 8000000: bP_elem = 8000000 # Less than 8 million is not allowed 723 | ice.bsgs_2nd_check_prepare(bP_elem) 724 | #============================================================================== 725 | def bsgs_2nd_check(pubkey_bytes, z1_int, bP_elem): 726 | if z1_int < 0: z1_int = N+z1_int 727 | hex_value = fl(z1_int).encode('utf8') 728 | res = (b'\x00') * 32 729 | found = ice.bsgs_2nd_check(pubkey_bytes, hex_value, bP_elem, res) 730 | return found, res 731 | #============================================================================== 732 | def prepare_bin_file_work(in_file, out_file, lower = False): 733 | use0x = False 734 | inp_list = [line.split()[0].lower() if lower else line.split()[0] for line in open(in_file,'r')] 735 | if inp_list[0][:2] == '0x': use0x = True 736 | 737 | with open(out_file, 'wb') as f: 738 | if use0x: 739 | inp_list = [line[2:] for line in inp_list] 740 | inp_list.sort() 741 | for line in inp_list: 742 | f.write(bytes.fromhex(line)) 743 | #============================================================================== 744 | def prepare_bin_file(in_file, out_file, overwrite = False, lower = False): 745 | 746 | if os.path.isfile(out_file) == False: 747 | prepare_bin_file_work(in_file, out_file, lower) 748 | 749 | else: 750 | if not overwrite: 751 | print(f'[+] File {out_file} already exist. It will be used as it is...') 752 | 753 | else: 754 | print(f'[+] File {out_file} already exist. Overwriting it...') 755 | prepare_bin_file_work(in_file, out_file) 756 | #============================================================================== 757 | def Load_data_to_memory(input_bin_file, verbose = False): 758 | '''input_bin_file is sorted h160 data of 20 bytes each element. 759 | ETH address can also work without 0x if sorted binary format''' 760 | ice.Load_data_to_memory(input_bin_file.encode("utf-8"), verbose) 761 | 762 | #============================================================================== 763 | def check_collision(h160): 764 | ''' h160 is the 20 byte hash to check for collision in data, already loaded in RAM. 765 | Use the function Load_data_to_memory before calling this check''' 766 | 767 | found = ice.check_collision(h160) 768 | return found 769 | -------------------------------------------------------------------------------- /WebserverV2/success.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/WebserverV2/success.mp3 -------------------------------------------------------------------------------- /WebserverV2/webserver_bonus.py: -------------------------------------------------------------------------------- 1 | #29/07/2022 BTC & ETH 2 | from __future__ import annotations 3 | from http.server import BaseHTTPRequestHandler, HTTPServer 4 | from socketserver import ThreadingMixIn 5 | import threading 6 | import hashlib 7 | import base58 8 | import binascii 9 | from typing import Optional, Tuple 10 | import secp256k1 as ice 11 | from bloomfilter import BloomFilter, ScalableBloomFilter, SizeGrowthRate 12 | from pathlib import Path 13 | from pygame import mixer 14 | from rich import print 15 | Mizogg = '''[red] 16 | ╔═╗╔═╗ 17 | ║║╚╝║║ 18 | ║╔╗╔╗║╔╗╔═══╗╔══╗╔══╗╔══╗ 19 | ║║║║║║╠╣╠══║║║╔╗║║╔╗║║╔╗║ 20 | ║║║║║║║║║║══╣║╚╝║║╚╝║║╚╝║ 21 | ╚╝╚╝╚╝╚╝╚═══╝╚══╝╚═╗║╚═╗║ 22 | ╔═╝║╔═╝║ 23 | ╚══╝╚══╝ 24 | ___ ___ 25 | (o o) (o o) 26 | ( V ) MIZOGG ( V ) 27 | --m-m------------m-m-- 28 | Webserver.py BTC & ETH 29 | BONUS 30 | [/red]''' 31 | print (Mizogg) 32 | 33 | hostName = "localhost" 34 | serverPort = 3334 35 | G = bytes(bytearray.fromhex('0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8')) 36 | 37 | class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): 38 | pass 39 | 40 | #**************************************************************Jacobian 41 | p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F 42 | r = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 43 | gx = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798 44 | gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 45 | gz = 0x1 46 | 47 | def inverse_mod(a, m): 48 | if a < 0 or m <= a: a = a % m 49 | c, d = a, m 50 | uc, vc, ud, vd = 1, 0, 0, 1 51 | while c != 0: 52 | q, c, d = divmod(d, c) + (c,) 53 | uc, vc, ud, vd = ud - q*uc, vd - q*vc, uc, vc 54 | if ud > 0: return ud 55 | else: return ud + m 56 | 57 | def from_jacobian(Xp, Yp, Zp): 58 | z = inverse_mod(Zp, p) 59 | return (Xp * z**2) % p, (Yp * z**3) % p 60 | 61 | def checkpoint(x, y): 62 | if (x**3 + 7) % p == y**2 % p : return True 63 | else: return False 64 | 65 | def bit_to_add(a): 66 | d=[] 67 | bitl= a.bit_length() 68 | for i in range(bitl): 69 | c = a | (1 << i) 70 | if c == a: d.append(2**i) 71 | return d 72 | 73 | def double_gen_point(x, y, z): 74 | points = {1: [x, y, z]} 75 | for i in range(1, r.bit_length()): 76 | x, y, z = double(x, y, z) 77 | points[2**i] = [x, y, z] 78 | return points 79 | 80 | def double(x, y, z): 81 | s = 4 * x * y**2 % p 82 | m = 3 * x**2 % p 83 | x1 = (m**2 - 2 * s) % p 84 | y1 = (m * (s - x1) - 8 * y**4) % p 85 | z1 = 2 * y * z % p 86 | return x1, y1, z1 87 | 88 | def add(Xp, Yp, Zp, Xq, Yq, Zq): 89 | if not Yp: return (Xq, Yq, Zq) 90 | if not Yq: return(Xp, Yp, Zp) 91 | u1 = (Xp * Zq**2) % p 92 | u2 = (Xq * Zp**2) % p 93 | s1 = (Yp * Zq**3) % p 94 | s2 = (Yq * Zp**3) % p 95 | if u1 == u2: 96 | if s1 != s2: return(0, 0, 1) 97 | return jacobian_double(Xp, Yp, Zp) 98 | h = u2 - u1 99 | rs = s2 - s1 100 | h2 = (h * h) % p 101 | h3 = (h * h2) % p 102 | u1h2 = (u1 * h2) % p 103 | nx = (rs**2 - h3 - 2 * u1h2) % p 104 | ny = (rs * (u1h2 - nx) - s1 * h3) % p 105 | nz = (h * Zp * Zq) % p 106 | return nx, ny, nz 107 | 108 | dbgen = double_gen_point(gx, gy, gz) 109 | 110 | def get_pubkey(n): 111 | if n >= r: return 'Out of range' 112 | if n in dbgen: return from_jacobian(dbgen[n][0], dbgen[n][1], dbgen[n][2]) 113 | btad = bit_to_add(n) 114 | point = dbgen[btad[0]] 115 | for i in btad[1:]: 116 | point = add(point[0], point[1], point[2], dbgen[i][0], dbgen[i][1], dbgen[i][2]) 117 | point = from_jacobian(point[0], point[1], point[2]) 118 | check = checkpoint(point[0], point[1]) 119 | if check : return point 120 | else: return 0, 0 121 | 122 | #****************************************************************************************** 123 | class WebServer(BaseHTTPRequestHandler): 124 | ##########_class_attributes_########################################################### 125 | num=startPrivKey=0 126 | previous = 0 127 | next = 0 128 | max = 904625697166532776746648320380374280100293470930272690489102837043110636675 129 | middle = 452312848583266388373324160190187140050146735465136345244551418521555318338 130 | hj = 85966769946697919304477156997851416897897452779964215616135418886216209408 131 | jk = 551340488851368173693535237984541213163631919119002481700768830238824024064 132 | L1 = 398639737335773246472125555160783623763937797351505550641748492138749584881 133 | L2 = 504075970525112600982146526634330530730393262381443907801548249398324792889 134 | L3 = 609512203714451955492167498107877437696848727411382264961348006657900000897 135 | L4 = 714948436903791310002188469581424344663304192441320622121147763917475208905 136 | L5 = 820384670093130664512209441054971251629759657471258979280947521177050416913 137 | Kx = 82331037767755182942062640740142902864571402261690479162349220360023960857 138 | Ky = 187767270957094537452083612213689809831026867291628836322148977619599168865 139 | Kz = 293203504146433891962104583687236716797482332321567193481948734879174376873 140 | first = 1; 141 | stride = 1; 142 | #------------------------------------------------------------------------------------- 143 | p1 = 1 144 | p2 = 1 145 | p3 = 1 146 | p4 = 1 147 | p5 = 1 148 | p6 = 1 149 | p7 = 2 150 | p8 = 3 151 | p9 = 5 152 | p10 = 9 153 | p11 = 17 154 | p12 = 33 155 | p13 = 65 156 | p14 = 129 157 | p15 = 257 158 | p16 = 513 159 | p17 = 1025 160 | p18 = 2049 161 | p19 = 4097 162 | p20 = 8193 163 | p21 = 16385 164 | p22 = 32769 165 | p23 = 65537 166 | p24 = 131073 167 | p25 = 262145 168 | p26 = 524289 169 | p27 = 1048577 170 | p28 = 2097153 171 | p29 = 4194305 172 | p30 = 8388609 173 | p31 = 16777217 174 | p32 = 33554433 175 | p33 = 67108865 176 | p34 = 134217729 177 | p35 = 268435457 178 | p36 = 536870913 179 | p37 = 1073741825 180 | p38 = 2147483649 181 | p39 = 4294967297 182 | p40 = 8589934593 183 | p41 = 17179869185 184 | p42 = 34359738369 185 | p43 = 68719476737 186 | p44 = 137438953473 187 | p45 = 274877906945 188 | p46 = 549755813889 189 | p47 = 1099511627777 190 | p48 = 2199023255553 191 | p49 = 4398046511105 192 | p50 = 8796093022209 193 | p51 = 17592186044417 194 | p52 = 35184372088833 195 | p53 = 70368744177665 196 | p54 = 140737488355329 197 | p55 = 281474976710657 198 | p56 = 562949953421313 199 | p57 = 1125899906842625 200 | p58 = 2251799813685249 201 | p59 = 4503599627370497 202 | p60 = 9007199254740993 203 | p61 = 18014398509481985 204 | p62 = 36028797018963969 205 | p63 = 72057594037927937 206 | p64 = 144115188075855873 207 | p65 = 288230376151711745 208 | p66 = 576460752303423489 209 | p67 = 1152921504606846977 210 | p68 = 2305843009213693953 211 | p69 = 4611686018427387905 212 | p70 = 9223372036854775809 213 | p71 = 18446744073709551617 214 | p72 = 36893488147419103233 215 | p73 = 73786976294838206465 216 | p74 = 147573952589676412929 217 | p75 = 295147905179352825857 218 | p76 = 590295810358705651713 219 | p77 = 1180591620717411303425 220 | p78 = 2361183241434822606849 221 | p79 = 4722366482869645213697 222 | p80 = 9444732965739290427393 223 | p81 = 18889465931478580854785 224 | p82 = 37778931862957161709569 225 | p83 = 75557863725914323419137 226 | p84 = 151115727451828646838273 227 | p85 = 302231454903657293676545 228 | p86 = 604462909807314587353089 229 | p87 = 1208925819614629174706177 230 | p88 = 2417851639229258349412353 231 | p89 = 4835703278458516698824705 232 | p90 = 9671406556917033397649409 233 | p91 = 19342813113834066795298817 234 | p92 = 38685626227668133590597633 235 | p93 = 77371252455336267181195265 236 | p94 = 154742504910672534362390529 237 | p95 = 309485009821345068724781057 238 | p96 = 618970019642690137449562113 239 | p97 = 1237940039285380274899124225 240 | p98 = 2475880078570760549798248449 241 | p99 = 4951760157141521099596496897 242 | p100 = 9903520314283042199192993793 243 | p101 = 19807040628566084398385987585 244 | p102 = 39614081257132168796771975169 245 | p103 = 79228162514264337593543950337 246 | p104 = 158456325028528675187087900673 247 | p105 = 316912650057057350374175801345 248 | p106 = 633825300114114700748351602689 249 | p107 = 1267650600228229401496703205377 250 | p108 = 2535301200456458802993406410753 251 | p109 = 5070602400912917605986812821505 252 | p110 = 10141204801825835211973625643009 253 | p111 = 20282409603651670423947251286017 254 | p112 = 40564819207303340847894502572033 255 | p113 = 81129638414606681695789005144065 256 | p114 = 162259276829213363391578010288129 257 | p115 = 324518553658426726783156020576257 258 | p116 = 649037107316853453566312041152513 259 | p117 = 1298074214633706907132624082305025 260 | p118 = 2596148429267413814265248164610049 261 | p119 = 5192296858534827628530496329220097 262 | p120 = 10384593717069655257060992658440193 263 | p121 = 20769187434139310514121985316880385 264 | p122 = 41538374868278621028243970633760769 265 | p123 = 83076749736557242056487941267521537 266 | p124 = 166153499473114484112975882535043073 267 | p125 = 332306998946228968225951765070086145 268 | p126 = 664613997892457936451903530140172289 269 | p127 = 1329227995784915872903807060280344577 270 | p128 = 2658455991569831745807614120560689153 271 | p129 = 5316911983139663491615228241121378305 272 | p130 = 10633823966279326983230456482242756609 273 | p131 = 21267647932558653966460912964485513217 274 | p132 = 42535295865117307932921825928971026433 275 | p133 = 85070591730234615865843651857942052865 276 | p134 = 170141183460469231731687303715884105729 277 | p135 = 340282366920938463463374607431768211457 278 | p136 = 680564733841876926926749214863536422913 279 | p137 = 1361129467683753853853498429727072845825 280 | p138 = 2722258935367507707706996859454145691649 281 | p139 = 5444517870735015415413993718908291383297 282 | p140 = 10889035741470030830827987437816582766593 283 | p141 = 21778071482940061661655974875633165533185 284 | p142 = 43556142965880123323311949751266331066369 285 | p143 = 87112285931760246646623899502532662132737 286 | p144 = 174224571863520493293247799005065324265473 287 | p145 = 348449143727040986586495598010130648530945 288 | p146 = 696898287454081973172991196020261297061889 289 | p147 = 1393796574908163946345982392040522594123777 290 | p148 = 2787593149816327892691964784081045188247553 291 | p149 = 5575186299632655785383929568162090376495105 292 | p150 = 11150372599265311570767859136324180752990209 293 | p151 = 22300745198530623141535718272648361505980417 294 | p152 = 44601490397061246283071436545296723011960833 295 | p153 = 89202980794122492566142873090593446023921665 296 | p154 = 178405961588244985132285746181186892047843329 297 | p155 = 356811923176489970264571492362373784095686657 298 | p156 = 713623846352979940529142984724747568191373313 299 | p157 = 1427247692705959881058285969449495136382746625 300 | p158 = 2854495385411919762116571938898990272765493249 301 | p159 = 5708990770823839524233143877797980545530986497 302 | p160 = 11417981541647679048466287755595961091061972993 303 | p161 = 22835963083295358096932575511191922182123945985 304 | p162 = 45671926166590716193865151022383844364247891969 305 | p163 = 91343852333181432387730302044767688728495783937 306 | p164 = 182687704666362864775460604089535377456991567873 307 | p165 = 365375409332725729550921208179070754913983135745 308 | p166 = 730750818665451459101842416358141509827966271489 309 | p167 = 1461501637330902918203684832716283019655932542977 310 | p168 = 2923003274661805836407369665432566039311865085953 311 | p169 = 5846006549323611672814739330865132078623730171905 312 | p170 = 11692013098647223345629478661730264157247460343809 313 | p171 = 23384026197294446691258957323460528314494920687617 314 | p172 = 46768052394588893382517914646921056628989841375233 315 | p173 = 93536104789177786765035829293842113257979682750465 316 | p174 = 187072209578355573530071658587684226515959365500929 317 | p175 = 374144419156711147060143317175368453031918731001857 318 | p176 = 748288838313422294120286634350736906063837462003713 319 | p177 = 1496577676626844588240573268701473812127674924007425 320 | p178 = 2993155353253689176481146537402947624255349848014849 321 | p179 = 5986310706507378352962293074805895248510699696029697 322 | p180 = 11972621413014756705924586149611790497021399392059393 323 | p181 = 23945242826029513411849172299223580994042798784118785 324 | p182 = 47890485652059026823698344598447161988085597568237569 325 | p183 = 95780971304118053647396689196894323976171195136475137 326 | p184 = 191561942608236107294793378393788647952342390272950273 327 | p185 = 383123885216472214589586756787577295904684780545900545 328 | p186 = 766247770432944429179173513575154591809369561091801089 329 | p187 = 1532495540865888858358347027150309183618739122183602177 330 | p188 = 3064991081731777716716694054300618367237478244367204353 331 | p189 = 6129982163463555433433388108601236734474956488734408705 332 | p190 = 12259964326927110866866776217202473468949912977468817409 333 | p191 = 24519928653854221733733552434404946937899825954937634817 334 | p192 = 49039857307708443467467104868809893875799651909875269633 335 | p193 = 98079714615416886934934209737619787751599303819750539265 336 | p194 = 196159429230833773869868419475239575503198607639501078529 337 | p195 = 392318858461667547739736838950479151006397215279002157057 338 | p196 = 784637716923335095479473677900958302012794430558004314113 339 | p197 = 1569275433846670190958947355801916604025588861116008628225 340 | p198 = 3138550867693340381917894711603833208051177722232017256449 341 | p199 = 6277101735386680763835789423207666416102355444464034512897 342 | p200 = 12554203470773361527671578846415332832204710888928069025793 343 | p201 = 25108406941546723055343157692830665664409421777856138051585 344 | p202 = 50216813883093446110686315385661331328818843555712276103169 345 | p203 = 100433627766186892221372630771322662657637687111424552206337 346 | p204 = 200867255532373784442745261542645325315275374222849104412673 347 | p205 = 401734511064747568885490523085290650630550748445698208825345 348 | p206 = 803469022129495137770981046170581301261101496891396417650689 349 | p207 = 1606938044258990275541962092341162602522202993782792835301377 350 | p208 = 3213876088517980551083924184682325205044405987565585670602753 351 | p209 = 6427752177035961102167848369364650410088811975131171341205505 352 | p210 = 12855504354071922204335696738729300820177623950262342682411009 353 | p211 = 25711008708143844408671393477458601640355247900524685364822017 354 | p212 = 51422017416287688817342786954917203280710495801049370729644033 355 | p213 = 102844034832575377634685573909834406561420991602098741459288065 356 | p214 = 205688069665150755269371147819668813122841983204197482918576129 357 | p215 = 411376139330301510538742295639337626245683966408394965837152257 358 | p216 = 822752278660603021077484591278675252491367932816789931674304513 359 | p217 = 1645504557321206042154969182557350504982735865633579863348609025 360 | p218 = 3291009114642412084309938365114701009965471731267159726697218049 361 | p219 = 6582018229284824168619876730229402019930943462534319453394436097 362 | p220 = 13164036458569648337239753460458804039861886925068638906788872193 363 | p221 = 26328072917139296674479506920917608079723773850137277813577744385 364 | p222 = 52656145834278593348959013841835216159447547700274555627155488769 365 | p223 = 105312291668557186697918027683670432318895095400549111254310977537 366 | p224 = 210624583337114373395836055367340864637790190801098222508621955073 367 | p225 = 421249166674228746791672110734681729275580381602196445017243910145 368 | p226 = 842498333348457493583344221469363458551160763204392890034487820289 369 | p227 = 1684996666696914987166688442938726917102321526408785780068975640577 370 | p228 = 3369993333393829974333376885877453834204643052817571560137951281153 371 | p229 = 6739986666787659948666753771754907668409286105635143120275902562305 372 | p230 = 13479973333575319897333507543509815336818572211270286240551805124609 373 | p231 = 26959946667150639794667015087019630673637144422540572481103610249217 374 | p232 = 53919893334301279589334030174039261347274288845081144962207220498433 375 | p233 = 107839786668602559178668060348078522694548577690162289924414440996865 376 | p234 = 215679573337205118357336120696157045389097155380324579848828881993729 377 | p235 = 431359146674410236714672241392314090778194310760649159697657763987457 378 | p236 = 862718293348820473429344482784628181556388621521298319395315527974913 379 | p237 = 1725436586697640946858688965569256363112777243042596638790631055949825 380 | p238 = 3450873173395281893717377931138512726225554486085193277581262111899649 381 | p239 = 6901746346790563787434755862277025452451108972170386555162524223799297 382 | p240 = 13803492693581127574869511724554050904902217944340773110325048447598593 383 | p241 = 27606985387162255149739023449108101809804435888681546220650096895197185 384 | p242 = 55213970774324510299478046898216203619608871777363092441300193790394369 385 | p243 = 110427941548649020598956093796432407239217743554726184882600387580788737 386 | p244 = 220855883097298041197912187592864814478435487109452369765200775161577473 387 | p245 = 441711766194596082395824375185729628956870974218904739530401550323154945 388 | p246 = 883423532389192164791648750371459257913741948437809479060803100646309889 389 | p247 = 1766847064778384329583297500742918515827483896875618958121606201292619777 390 | p248 = 3533694129556768659166595001485837031654967793751237916243212402585239553 391 | p249 = 7067388259113537318333190002971674063309935587502475832486424805170479105 392 | p250 = 14134776518227074636666380005943348126619871175004951664972849610340958209 393 | p251 = 28269553036454149273332760011886696253239742350009903329945699220681916417 394 | p252 = 56539106072908298546665520023773392506479484700019806659891398441363832833 395 | p253 = 113078212145816597093331040047546785012958969400039613319782796882727665665 396 | p254 = 226156424291633194186662080095093570025917938800079226639565593765455331329 397 | p255 = 452312848583266388373324160190187140051835877600158453279131187530910662657 398 | 399 | addresses = list() 400 | arr = set() 401 | bloombtc = Path(__file__).resolve() 402 | ressbtc = bloombtc.parents[0] / 'btc.bf' 403 | bloometh = Path(__file__).resolve() 404 | resseth = bloometh.parents[0] / 'eth.bf' 405 | 406 | 407 | with open(resseth, "rb") as fp: 408 | bloom_filter1 = BloomFilter.load(fp) 409 | 410 | with open(ressbtc, "rb") as fp: 411 | bloom_filter = BloomFilter.load(fp) 412 | 413 | addr_countbtc = len(bloom_filter) 414 | addr_countETH = len(bloom_filter1) 415 | addr_count = len(bloom_filter)+len(bloom_filter1) 416 | 417 | ##########_webserver_work_############################################################ 418 | def do_GET(self): 419 | self.send_response(200) 420 | self.send_header("Content-type", "text/html") 421 | self.end_headers() 422 | str_url = self.path[1:] 423 | addresses = list() 424 | if str_url.startswith("A"): #Ajax 425 | str_url = self.path[2:] 426 | __class__.num = int(str_url,10) 427 | __class__.previous = __class__.num - 1; 428 | if __class__.previous == 0: 429 | __class__.previous = 1 430 | __class__.next = __class__.num + __class__.stride 431 | if __class__.next > __class__.max: 432 | __class__.next = __class__.max 433 | __class__.startPrivKey = (__class__.num - 1) * 128+1 434 | self.wfile.write(bytes("

**********MAIN VERSION********** BACK TO MAIN **********MAIN VERSION**********

'", "utf-8")) 435 | self.wfile.write(bytes("

   Bitcoin & ETH Addresses Database. Total Addresses Loaded ***| " + str(__class__.addr_count) + " |

", "utf-8")) 436 | self.wfile.write(bytes("

   Bitcoin Total Addresses Loaded ***| " + str(__class__.addr_countbtc) + " |

", "utf-8")) 437 | self.wfile.write(bytes("

    ETH Addresses Total Loaded ***| " + str(__class__.addr_countETH) + " |

", "utf-8")) 438 | self.wfile.write(bytes("

   Python-WebServer for more information about Python-WebServer.py Visit" + " Python-WebServer GitHub " + " or " + " Mizogg Home Website

", "utf-8")) 439 | self.wfile.write(bytes("

Page # " + str(__class__.num) + " << out of >> 904625697166532776746648320380374280100293470930272690489102837043110636675

", "utf-8")) 440 | self.wfile.write(bytes("
previous | ", "utf-8"))
441 |             self.wfile.write(bytes("next ]   ", "utf-8"))
442 |             self.wfile.write(bytes("[ first | ", "utf-8"))
443 |             self.wfile.write(bytes("middle | ", "utf-8"))
444 |             self.wfile.write(bytes("last ]", "utf-8"))
445 |             self.wfile.write(bytes("
", "utf-8")) 446 | self.wfile.write(bytes("
", "utf-8"))
447 |             self.wfile.write(bytes("2^255|2^254|2^253|2^252|2^251|2^250", "utf-8"))
448 |             self.wfile.write(bytes("|2^249|2^248|2^247|2^246|2^245|2^244", "utf-8"))
449 |             self.wfile.write(bytes("|2^243|2^242|2^241|2^240|2^239|2^238", "utf-8"))
450 |             self.wfile.write(bytes("|2^237|2^236|2^235|2^234|2^233|2^232", "utf-8"))
451 |             self.wfile.write(bytes("|2^231|2^230|2^229|2^228|2^227|2^226", "utf-8"))
452 |             self.wfile.write(bytes("|2^225|2^224|2^223|2^222|2^221|2^220
", "utf-8")) 453 | self.wfile.write(bytes("2^219|2^218|2^217|2^216|2^215|2^214", "utf-8")) 454 | self.wfile.write(bytes("|2^213|2^212|2^211|2^210|2^209|2^208", "utf-8")) 455 | self.wfile.write(bytes("|2^207|2^206|2^205|2^204|2^203|2^202", "utf-8")) 456 | self.wfile.write(bytes("|2^201|2^200|2^199|2^198|2^197|2^196", "utf-8")) 457 | self.wfile.write(bytes("|2^195|2^194|2^193|2^192|2^191|2^190", "utf-8")) 458 | self.wfile.write(bytes("|2^189|2^188|2^187|2^186|2^185|2^184
", "utf-8")) 459 | self.wfile.write(bytes("2^183|2^182|2^181|2^180|2^179|2^178", "utf-8")) 460 | self.wfile.write(bytes("|2^177|2^176|2^175|2^174|2^173|2^172", "utf-8")) 461 | self.wfile.write(bytes("|2^171|2^170|2^169|2^168|2^167|2^166", "utf-8")) 462 | self.wfile.write(bytes("|2^165|2^164|2^163|2^162|2^161|2^160", "utf-8")) 463 | self.wfile.write(bytes("|2^159|2^158|2^157|2^156|2^155|2^154", "utf-8")) 464 | self.wfile.write(bytes("|2^153|2^152|2^151|2^150|2^149|2^148
", "utf-8")) 465 | self.wfile.write(bytes("2^147|2^146|2^145|2^144|2^143|2^142", "utf-8")) 466 | self.wfile.write(bytes("|2^141|2^140|2^139|2^138|2^137|2^136", "utf-8")) 467 | self.wfile.write(bytes("|2^135|2^134|2^133|2^132|2^131|2^130", "utf-8")) 468 | self.wfile.write(bytes("|2^129|2^128|2^127|2^126|2^125|2^124", "utf-8")) 469 | self.wfile.write(bytes("|2^123|2^122|2^121|2^120|2^119|2^118", "utf-8")) 470 | self.wfile.write(bytes("|2^117|2^116|2^115|2^114|2^113|2^112
", "utf-8")) 471 | self.wfile.write(bytes("2^111|2^110|2^109|2^108|2^107|2^106", "utf-8")) 472 | self.wfile.write(bytes("|2^105|2^104|2^103|2^102|2^101|2^100", "utf-8")) 473 | self.wfile.write(bytes("|2^99|2^98|2^97|2^96|2^95|2^94", "utf-8")) 474 | self.wfile.write(bytes("|2^93|2^92|2^91|2^90|2^89|2^88", "utf-8")) 475 | self.wfile.write(bytes("|2^87|2^86|2^85|2^84|2^83|2^82", "utf-8")) 476 | self.wfile.write(bytes("|2^81|2^82|2^81|2^80|2^79|2^78", "utf-8")) 477 | self.wfile.write(bytes("|2^77|2^76|2^75|2^74|2^73
2^72", "utf-8")) 478 | self.wfile.write(bytes("|2^71|2^70|2^69|2^68|2^67|2^66", "utf-8")) 479 | self.wfile.write(bytes("|2^65|2^64|2^63|2^62|2^61|2^60", "utf-8")) 480 | self.wfile.write(bytes("|2^59|2^58|2^57|2^56|2^55|2^54", "utf-8")) 481 | self.wfile.write(bytes("|2^53|2^52|2^51|2^50|2^49|2^48", "utf-8")) 482 | self.wfile.write(bytes("|2^47|2^46|2^45|2^44|2^43|2^42", "utf-8")) 483 | self.wfile.write(bytes("|2^41|2^40|2^39|2^38|2^37|2^36", "utf-8")) 484 | self.wfile.write(bytes("|2^35|2^34|2^33|2^32|2^31|2^30
", "utf-8")) 485 | self.wfile.write(bytes("2^29|2^28|2^27|2^26|2^25|2^24", "utf-8")) 486 | self.wfile.write(bytes("|2^23|2^22|2^21|2^20|2^19|2^18", "utf-8")) 487 | self.wfile.write(bytes("|2^17|2^16|2^15|2^14|2^13|2^12", "utf-8")) 488 | self.wfile.write(bytes("|2^11|2^10|2^9|2^8|2^7|2^6", "utf-8")) 489 | self.wfile.write(bytes("|2^5|2^4|2^3|2^2|2^1", "utf-8")) 490 | self.wfile.write(bytes("
", "utf-8")) 491 | ###---Loop---****************************************************************** 492 | for i in range(0,128): 493 | #pubkey = get_pubkey(__class__.startPrivKey) 494 | pub = ice.point_multiplication(__class__.startPrivKey,G).hex() 495 | addrU = ice.pubkey_to_address(0, False, bytes(bytearray.fromhex(pub))) 496 | addrC = ice.pubkey_to_address(0, True, bytes(bytearray.fromhex(pub))) 497 | addrS = ice.privatekey_to_address(1, True, __class__.startPrivKey) #p2sh 498 | addrbech32 = ice.privatekey_to_address(2, True, __class__.startPrivKey) #bech32 499 | addrETH = ice.privatekey_to_ETH_address(__class__.startPrivKey)[2:] 500 | self.wfile.write(bytes("
", "utf-8")) 501 | self.wfile.write(bytes("

U: "+addrU+"   C: "+addrC+"   3: "+addrS+"   BC1: "+addrbech32+"   ETH: 0x"+addrETH+"

","utf-8")) 502 | self.wfile.write(bytes("

DEC: "+str(__class__.startPrivKey)+"HEX: "+str(hex(__class__.startPrivKey)[2:].zfill(64))+""+str(len(bin(__class__.startPrivKey)[2:]))+"bit

", "utf-8")) 503 | self.wfile.write(bytes("

"+str(bin(__class__.startPrivKey)[2:])+"", "utf-8")) 504 | self.wfile.write(bytes("

"+"X: "+str(int(pub[2:66],16))+" "+"Y: "+str(int(pub[66:],16))+"

", "utf-8")) 505 | self.wfile.write(bytes("

"+"X: "+str(pub[2:66])+" "+"Y: "+str(pub[66:])+"

", "utf-8")) 506 | self.wfile.write(bytes("
", "utf-8")) 507 | if __class__.startPrivKey == 115792089237316195423570985008687907852837564279074904382605163141518161494336: 508 | break 509 | __class__.startPrivKey += 1 510 | for addr in addresses: 511 | if addr in __class__.bloom_filter: 512 | status = 'Yes' 513 | with open("found.txt", "a", encoding="utf-8") as f: 514 | f.write(f"Bitcoin Address: {addr} Found on Page# {__class__.num} \n") 515 | if addr in __class__.bloom_filter1: 516 | status = 'Yes' 517 | with open("found.txt", "a", encoding="utf-8") as f: 518 | f.write(f"ETH Address: 0x{addr} Found on Page# {__class__.num} \n") 519 | if status == "Yes": 520 | mixer.init() 521 | mixer.music.load("success.mp3") 522 | mixer.music.play() 523 | ###---Loop---****************************************************************** 524 | self.wfile.write(bytes("
previous | ", "utf-8"))
525 |             self.wfile.write(bytes("next ]", "utf-8"))
526 |             self.wfile.write(bytes("
", "utf-8")) 527 | self.wfile.write(bytes(""" 528 | """, "utf-8")) 538 | else: #Full Page 539 | #str_url = self.path[1:] 540 | __class__.num = int(str_url,10) 541 | __class__.previous = __class__.num - 1; 542 | if __class__.previous == 0: 543 | __class__.previous = 1 544 | __class__.next = __class__.num + __class__.stride 545 | if __class__.next > __class__.max: 546 | __class__.next = __class__.max 547 | __class__.startPrivKey = (__class__.num - 1) * 128+1 548 | 549 | self.wfile.write(bytes("","utf-8")) 550 | self.wfile.write(bytes("","utf-8")) 551 | self.wfile.write(bytes("","utf-8")) 552 | self.wfile.write(bytes("Webserver.py Bonus","utf-8")) 553 | self.wfile.write(bytes("", "utf-8")) 554 | self.wfile.write(bytes(""" 555 | """, "utf-8")) 562 | self.wfile.write(bytes("","utf-8")) 563 | self.wfile.write(bytes("","utf-8")) 564 | self.wfile.write(bytes("","utf-8")) 565 | self.wfile.write(bytes("
", "utf-8")) 566 | self.wfile.write(bytes("

**********MAIN VERSION********** BACK TO MAIN **********MAIN VERSION**********

'", "utf-8")) 567 | self.wfile.write(bytes("

Bitcoin Address Loaded " + str(__class__.addr_countbtc) + " ETH Address Loaded " + str(__class__.addr_countETH) + " Total Bitcoin & ETH Addresses Database. Total Addresses Loaded ***| " + str(__class__.addr_count) + " |

", "utf-8")) 568 | self.wfile.write(bytes("

   Python-WebServer for more information about Python-WebServer.py Visit" + " Python-WebServer GitHub " + " or " + " Mizogg Home Website

", "utf-8")) 569 | self.wfile.write(bytes("

Page # " + str(__class__.num) + " << out of >> 904625697166532776746648320380374280100293470930272690489102837043110636675

", "utf-8")) 570 | self.wfile.write(bytes("
previous | ", "utf-8"))
571 |             self.wfile.write(bytes("next ]   ", "utf-8"))
572 |             self.wfile.write(bytes("[ first | ", "utf-8"))
573 |             self.wfile.write(bytes("middle | ", "utf-8"))
574 |             self.wfile.write(bytes("last ]", "utf-8"))
575 |             self.wfile.write(bytes("
", "utf-8")) 576 | 577 | self.wfile.write(bytes("
", "utf-8"))
578 |             self.wfile.write(bytes("2^255|2^254|2^253|2^252|2^251|2^250", "utf-8"))
579 |             self.wfile.write(bytes("|2^249|2^248|2^247|2^246|2^245|2^244", "utf-8"))
580 |             self.wfile.write(bytes("|2^243|2^242|2^241|2^240|2^239|2^238", "utf-8"))
581 |             self.wfile.write(bytes("|2^237|2^236|2^235|2^234|2^233|2^232", "utf-8"))
582 |             self.wfile.write(bytes("|2^231|2^230|2^229|2^228|2^227|2^226", "utf-8"))
583 |             self.wfile.write(bytes("|2^225|2^224|2^223|2^222|2^221|2^220
", "utf-8")) 584 | self.wfile.write(bytes("2^219|2^218|2^217|2^216|2^215|2^214", "utf-8")) 585 | self.wfile.write(bytes("|2^213|2^212|2^211|2^210|2^209|2^208", "utf-8")) 586 | self.wfile.write(bytes("|2^207|2^206|2^205|2^204|2^203|2^202", "utf-8")) 587 | self.wfile.write(bytes("|2^201|2^200|2^199|2^198|2^197|2^196", "utf-8")) 588 | self.wfile.write(bytes("|2^195|2^194|2^193|2^192|2^191|2^190", "utf-8")) 589 | self.wfile.write(bytes("|2^189|2^188|2^187|2^186|2^185|2^184
", "utf-8")) 590 | self.wfile.write(bytes("2^183|2^182|2^181|2^180|2^179|2^178", "utf-8")) 591 | self.wfile.write(bytes("|2^177|2^176|2^175|2^174|2^173|2^172", "utf-8")) 592 | self.wfile.write(bytes("|2^171|2^170|2^169|2^168|2^167|2^166", "utf-8")) 593 | self.wfile.write(bytes("|2^165|2^164|2^163|2^162|2^161|2^160", "utf-8")) 594 | self.wfile.write(bytes("|2^159|2^158|2^157|2^156|2^155|2^154", "utf-8")) 595 | self.wfile.write(bytes("|2^153|2^152|2^151|2^150|2^149|2^148
", "utf-8")) 596 | self.wfile.write(bytes("2^147|2^146|2^145|2^144|2^143|2^142", "utf-8")) 597 | self.wfile.write(bytes("|2^141|2^140|2^139|2^138|2^137|2^136", "utf-8")) 598 | self.wfile.write(bytes("|2^135|2^134|2^133|2^132|2^131|2^130", "utf-8")) 599 | self.wfile.write(bytes("|2^129|2^128|2^127|2^126|2^125|2^124", "utf-8")) 600 | self.wfile.write(bytes("|2^123|2^122|2^121|2^120|2^119|2^118", "utf-8")) 601 | self.wfile.write(bytes("|2^117|2^116|2^115|2^114|2^113|2^112
", "utf-8")) 602 | self.wfile.write(bytes("2^111|2^110|2^109|2^108|2^107|2^106", "utf-8")) 603 | self.wfile.write(bytes("|2^105|2^104|2^103|2^102|2^101|2^100", "utf-8")) 604 | self.wfile.write(bytes("|2^99|2^98|2^97|2^96|2^95|2^94", "utf-8")) 605 | self.wfile.write(bytes("|2^93|2^92|2^91|2^90|2^89|2^88", "utf-8")) 606 | self.wfile.write(bytes("|2^87|2^86|2^85|2^84|2^83|2^82", "utf-8")) 607 | self.wfile.write(bytes("|2^81|2^82|2^81|2^80|2^79|2^78", "utf-8")) 608 | self.wfile.write(bytes("|2^77|2^76|2^75|2^74|2^73
2^72", "utf-8")) 609 | self.wfile.write(bytes("|2^71|2^70|2^69|2^68|2^67|2^66", "utf-8")) 610 | self.wfile.write(bytes("|2^65|2^64|2^63|2^62|2^61|2^60", "utf-8")) 611 | self.wfile.write(bytes("|2^59|2^58|2^57|2^56|2^55|2^54", "utf-8")) 612 | self.wfile.write(bytes("|2^53|2^52|2^51|2^50|2^49|2^48", "utf-8")) 613 | self.wfile.write(bytes("|2^47|2^46|2^45|2^44|2^43|2^42", "utf-8")) 614 | self.wfile.write(bytes("|2^41|2^40|2^39|2^38|2^37|2^36", "utf-8")) 615 | self.wfile.write(bytes("|2^35|2^34|2^33|2^32|2^31|2^30
", "utf-8")) 616 | self.wfile.write(bytes("2^29|2^28|2^27|2^26|2^25|2^24", "utf-8")) 617 | self.wfile.write(bytes("|2^23|2^22|2^21|2^20|2^19|2^18", "utf-8")) 618 | self.wfile.write(bytes("|2^17|2^16|2^15|2^14|2^13|2^12", "utf-8")) 619 | self.wfile.write(bytes("|2^11|2^10|2^9|2^8|2^7|2^6", "utf-8")) 620 | self.wfile.write(bytes("|2^5|2^4|2^3|2^2|2^1", "utf-8")) 621 | self.wfile.write(bytes("
", "utf-8")) 622 | ###---Loop---****************************************************************** 623 | for i in range(0,128): 624 | #pubkey = get_pubkey(__class__.startPrivKey) 625 | pub = ice.point_multiplication(__class__.startPrivKey,G).hex() 626 | addrU = ice.pubkey_to_address(0, False, bytes(bytearray.fromhex(pub))) 627 | addrC = ice.pubkey_to_address(0, True, bytes(bytearray.fromhex(pub))) 628 | addrS = ice.privatekey_to_address(1, True, __class__.startPrivKey) #p2sh 629 | addrbech32 = ice.privatekey_to_address(2, True, __class__.startPrivKey) #bech32 630 | addrETH = ice.privatekey_to_ETH_address(__class__.startPrivKey)[2:] 631 | addresses.append(addrU.strip()); 632 | addresses.append(addrC.strip()); 633 | addresses.append(addrS.strip()); 634 | addresses.append(addrbech32.strip()); 635 | addresses.append(addrETH.strip()); 636 | self.wfile.write(bytes("
", "utf-8")) 637 | self.wfile.write(bytes("

U: "+addrU+"   C: "+addrC+"   3: "+addrS+"   BC1: "+addrbech32+"   ETH: 0x"+addrETH+"

","utf-8")) 638 | self.wfile.write(bytes("

DEC: "+str(__class__.startPrivKey)+"HEX: "+str(hex(__class__.startPrivKey)[2:].zfill(64))+""+str(len(bin(__class__.startPrivKey)[2:]))+"bit

", "utf-8")) 639 | self.wfile.write(bytes("

"+str(bin(__class__.startPrivKey)[2:])+"", "utf-8")) 640 | self.wfile.write(bytes("

"+"X: "+str(int(pub[2:66],16))+" "+"Y: "+str(int(pub[66:],16))+"

", "utf-8")) 641 | self.wfile.write(bytes("

"+"X: "+str(pub[2:66])+" "+"Y: "+str(pub[66:])+"

", "utf-8")) 642 | self.wfile.write(bytes("
", "utf-8")) 643 | if __class__.startPrivKey == 115792089237316195423570985008687907852837564279074904382605163141518161494336: 644 | break 645 | __class__.startPrivKey += 1 646 | for addr in addresses: 647 | if addr in __class__.bloom_filter: 648 | status = 'Yes' 649 | with open("found.txt", "a", encoding="utf-8") as f: 650 | f.write(f"Bitcoin Address: {addr} Found on Page# {__class__.num} \n") 651 | if addr in __class__.bloom_filter1: 652 | status = 'Yes' 653 | with open("found.txt", "a", encoding="utf-8") as f: 654 | f.write(f"ETH Address: 0x{addr} Found on Page# {__class__.num} \n") 655 | if status == "Yes": 656 | mixer.init() 657 | mixer.music.load("success.mp3") 658 | mixer.music.play() 659 | ###---Loop---****************************************************************** 660 | self.wfile.write(bytes("
previous | ", "utf-8"))
661 |             self.wfile.write(bytes("next ]", "utf-8"))
662 |             self.wfile.write(bytes("
", "utf-8")) 663 | self.wfile.write(bytes("
", "utf-8")) 664 | self.wfile.write(bytes(""" 665 | """, "utf-8")) 680 | self.wfile.write(bytes("", "utf-8")) 681 | self.wfile.write(bytes("", "utf-8")) 682 | ###################################################################################### 683 | if __name__ == "__main__": 684 | webServer = ThreadedHTTPServer((hostName, serverPort), WebServer) 685 | print("Server started at http://%s:%s" % (hostName, serverPort)) 686 | 687 | try: 688 | webServer.serve_forever() 689 | except KeyboardInterrupt: 690 | pass 691 | 692 | webServer.server_close() 693 | print("Server stopped.") 694 | -------------------------------------------------------------------------------- /btc.bf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/btc.bf -------------------------------------------------------------------------------- /ice_secp256k1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/ice_secp256k1.dll -------------------------------------------------------------------------------- /ice_secp256k1.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mizogg/Python-WebServer/0979c92e2e61ccbada586747d87c69726d9dc3f6/ice_secp256k1.so -------------------------------------------------------------------------------- /secp256k1.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 4 | @author: iceland 5 | """ 6 | 7 | import platform 8 | import os 9 | import sys 10 | import ctypes 11 | import math 12 | import pickle 13 | 14 | ############################################################################### 15 | N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 16 | Zero=b'\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 17 | #============================================================================== 18 | if platform.system().lower().startswith('win'): 19 | dir_path = os.path.dirname(os.path.realpath(__file__)) 20 | dllfile = dir_path + '/ice_secp256k1.dll' 21 | if os.path.isfile(dllfile) == True: 22 | pathdll = os.path.realpath(dllfile) 23 | ice = ctypes.CDLL(pathdll) 24 | else: 25 | print('File {} not found'.format(dllfile)) 26 | 27 | elif platform.system().lower().startswith('lin'): 28 | dir_path = os.path.dirname(os.path.realpath(__file__)) 29 | dllfile = dir_path + '/ice_secp256k1.so' 30 | if os.path.isfile(dllfile) == True: 31 | pathdll = os.path.realpath(dllfile) 32 | ice = ctypes.CDLL(pathdll) 33 | else: 34 | print('File {} not found'.format(dllfile)) 35 | 36 | else: 37 | print('[-] Unsupported Platform currently for ctypes dll method. Only [Windows and Linux] is working') 38 | sys.exit() 39 | ############################################################################### 40 | #============================================================================== 41 | # Coin type 42 | COIN_BTC = 0 43 | COIN_BSV = 1 44 | COIN_BTCD = 2 45 | COIN_ARG = 3 46 | COIN_AXE = 4 47 | COIN_BC = 5 48 | COIN_BCH = 6 49 | COIN_BSD = 7 50 | COIN_BTDX = 8 51 | COIN_BTG = 9 52 | COIN_BTX = 10 53 | COIN_CHA = 11 54 | COIN_DASH = 12 55 | COIN_DCR = 13 56 | COIN_DFC = 14 57 | COIN_DGB = 15 58 | COIN_DOGE = 16 59 | COIN_FAI = 17 60 | COIN_FTC = 18 61 | COIN_GRS = 19 62 | COIN_JBS = 20 63 | COIN_LTC = 21 64 | COIN_MEC = 22 65 | COIN_MONA = 23 66 | COIN_MZC = 24 67 | COIN_PIVX = 25 68 | COIN_POLIS= 26 69 | COIN_RIC = 27 70 | COIN_STRAT= 28 71 | COIN_SMART= 29 72 | COIN_VIA = 30 73 | COIN_XMY = 31 74 | COIN_ZEC = 32 75 | COIN_ZCL = 33 76 | COIN_ZERO = 34 77 | COIN_ZEN = 35 78 | COIN_TENT = 36 79 | COIN_ZEIT = 37 80 | COIN_VTC = 38 81 | COIN_UNO = 39 82 | COIN_SKC = 40 83 | COIN_RVN = 41 84 | COIN_PPC = 42 85 | COIN_OMC = 43 86 | COIN_OK = 44 87 | COIN_NMC = 45 88 | COIN_NLG = 46 89 | COIN_LBRY = 47 90 | COIN_DNR = 48 91 | COIN_BWK = 49 92 | 93 | #============================================================================== 94 | ice.scalar_multiplication.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # pvk,ret 95 | #============================================================================== 96 | ice.scalar_multiplications.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p] # pvk,len,ret 97 | #============================================================================== 98 | ice.get_x_to_y.argtypes = [ctypes.c_char_p, ctypes.c_bool, ctypes.c_char_p] # x,even,ret 99 | #============================================================================== 100 | ice.point_increment.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 101 | #============================================================================== 102 | ice.point_negation.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 103 | #============================================================================== 104 | ice.point_doubling.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 105 | #============================================================================== 106 | ice.privatekey_to_coinaddress.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # intcoin,012,comp,pvk 107 | ice.privatekey_to_coinaddress.restype = ctypes.c_void_p 108 | #============================================================================== 109 | ice.privatekey_to_address.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # 012,comp,pvk 110 | ice.privatekey_to_address.restype = ctypes.c_void_p 111 | #============================================================================== 112 | ice.hash_to_address.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # 012,comp,hash 113 | ice.hash_to_address.restype = ctypes.c_void_p 114 | #============================================================================== 115 | ice.pubkey_to_address.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p] # 012,comp,upub 116 | ice.pubkey_to_address.restype = ctypes.c_void_p 117 | #============================================================================== 118 | ice.privatekey_to_h160.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # 012,comp,pvk,ret 119 | #============================================================================== 120 | ice.privatekey_loop_h160.argtypes = [ctypes.c_ulonglong, ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # num,012,comp,pvk,ret 121 | #============================================================================== 122 | ice.privatekey_loop_h160_sse.argtypes = [ctypes.c_ulonglong, ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # num,012,comp,pvk,ret 123 | #============================================================================== 124 | ice.pubkey_to_h160.argtypes = [ctypes.c_int, ctypes.c_bool, ctypes.c_char_p, ctypes.c_char_p] # 012,comp,upub,ret 125 | #============================================================================== 126 | ice.pbkdf2_hmac_sha512_dll.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int] # ret, words, len 127 | #============================================================================== 128 | ice.pbkdf2_hmac_sha512_list.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_int, ctypes.c_ulonglong] # ret,words,len,mnem_size,total 129 | #============================================================================== 130 | ice.pub_endo1.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 131 | #============================================================================== 132 | ice.pub_endo2.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub,ret 133 | #============================================================================== 134 | ice.b58_encode.argtypes = [ctypes.c_char_p] # _h 135 | ice.b58_encode.restype = ctypes.c_void_p 136 | #============================================================================== 137 | ice.b58_decode.argtypes = [ctypes.c_char_p] # addr 138 | ice.b58_decode.restype = ctypes.c_void_p 139 | #============================================================================== 140 | ice.bech32_address_decode.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_char_p] # coin,b32_addr,h160 141 | #============================================================================== 142 | ice.get_sha256.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p] # input, len, ret 143 | #============================================================================== 144 | ice.create_baby_table.argtypes = [ctypes.c_ulonglong, ctypes.c_ulonglong, ctypes.c_char_p] # start,end,ret 145 | #============================================================================== 146 | ice.point_addition.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # upub1,upub2,ret 147 | #============================================================================== 148 | ice.point_subtraction.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # upub1,upub2,ret 149 | #============================================================================== 150 | ice.point_loop_subtraction.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # k,upub1,upub2,ret 151 | #============================================================================== 152 | ice.point_loop_addition.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # k,upub1,upub2,ret 153 | #============================================================================== 154 | ice.point_vector_addition.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p] # num,upubs1,upubs2,ret 155 | #============================================================================== 156 | ice.point_sequential_increment_P2.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p] # num,upub1,ret 157 | #============================================================================== 158 | ice.point_sequential_increment_P2_mcpu.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p] # num,upub1,mcpu,ret 159 | #============================================================================== 160 | ice.point_sequential_increment.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p] # num,upub1,ret 161 | #============================================================================== 162 | ice.point_sequential_decrement.argtypes = [ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_char_p] # num,upub1,ret 163 | #============================================================================== 164 | ice.pubkeyxy_to_ETH_address.argtypes = [ctypes.c_char_p] # upub_xy 165 | ice.pubkeyxy_to_ETH_address.restype = ctypes.c_void_p 166 | #============================================================================== 167 | ice.pubkeyxy_to_ETH_address_bytes.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # upub_xy, ret 168 | #============================================================================== 169 | ice.privatekey_to_ETH_address.argtypes = [ctypes.c_char_p] # pvk 170 | ice.privatekey_to_ETH_address.restype = ctypes.c_void_p 171 | #============================================================================== 172 | ice.privatekey_to_ETH_address_bytes.argtypes = [ctypes.c_char_p, ctypes.c_char_p] # pvk, ret 173 | #============================================================================== 174 | ice.privatekey_group_to_ETH_address.argtypes = [ctypes.c_char_p, ctypes.c_int] # pvk, m 175 | ice.privatekey_group_to_ETH_address.restype = ctypes.c_void_p 176 | #============================================================================== 177 | ice.privatekey_group_to_ETH_address_bytes.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p] # pvk,m,ret 178 | #============================================================================== 179 | ice.init_P2_Group.argtypes = [ctypes.c_char_p] # upub 180 | #============================================================================== 181 | ice.free_memory.argtypes = [ctypes.c_void_p] # pointer 182 | #============================================================================== 183 | ice.bloom_check_add.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong, ctypes.c_ubyte, ctypes.c_char_p] #buff, len, 0_1, _bits, _hashes, _bf 184 | ice.bloom_check_add.restype = ctypes.c_int 185 | #============================================================================== 186 | ice.bloom_batch_add.argtypes = [ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong, ctypes.c_ubyte, ctypes.c_char_p] #chunk, buff, len, 0_1, _bits, _hashes, _bf 187 | #============================================================================== 188 | ice.bloom_check_add_mcpu.argtypes = [ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_char_p, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong, ctypes.c_ubyte, ctypes.c_char_p] #buff, num_items, found_array, len, mcpu, 0_1, _bits, _hashes, _bf 189 | #============================================================================== 190 | ice.test_bit_set_bit.argtypes = [ctypes.c_char_p, ctypes.c_ulonglong, ctypes.c_int] #_bf, _bits, 0_1 191 | #============================================================================== 192 | ice.create_bsgs_bloom_mcpu.argtypes = [ctypes.c_int, ctypes.c_ulonglong, ctypes.c_ulonglong, ctypes.c_ubyte, ctypes.c_char_p] #mcpu, num_items, _bits, _hashes, _bf 193 | #============================================================================== 194 | ice.bsgs_2nd_check_prepare.argtypes = [ctypes.c_ulonglong] # bP_elem 195 | #============================================================================== 196 | ice.bsgs_2nd_check.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulonglong, ctypes.c_char_p] # upub, z1, bP_elem, ret 197 | ice.bsgs_2nd_check.restype = ctypes.c_bool #True or False 198 | #============================================================================== 199 | ice.Load_data_to_memory.argtypes = [ctypes.c_char_p, ctypes.c_bool] #sorted_bin_file_h160, verbose 200 | #============================================================================== 201 | ice.check_collision.argtypes = [ctypes.c_char_p] #h160 202 | ice.check_collision.restype = ctypes.c_bool #True or False 203 | 204 | ice.init_secp256_lib() 205 | #============================================================================== 206 | ############################################################################### 207 | 208 | 209 | def version(): 210 | ice.version() 211 | #============================================================================== 212 | def _scalar_multiplication(pvk_int): 213 | ''' Integer value passed to function. 65 bytes uncompressed pubkey output ''' 214 | res = (b'\x00') * 65 215 | pass_int_value = fl(pvk_int).encode('utf8') 216 | ice.scalar_multiplication(pass_int_value, res) 217 | return res 218 | def scalar_multiplication(pvk_int): 219 | if pvk_int < 0: pvk_int = N+pvk_int 220 | res = _scalar_multiplication(pvk_int) 221 | return bytes(bytearray(res)) 222 | #============================================================================== 223 | def _scalar_multiplications(pvk_int_list): 224 | ''' Integer list passed to function. 65*len bytes uncompressed pubkey output. No Zero Point handling ''' 225 | sz = len(pvk_int_list) 226 | res = (b'\x00') * (65 * sz) 227 | pvks = b''.join(pvk_int_list) 228 | ice.scalar_multiplications(pvks, sz, res) 229 | return res 230 | def scalar_multiplications(pvk_int_list): 231 | pvk_int_list = [bytes.fromhex(fl(N+i)) if i < 0 else bytes.fromhex(fl(i)) for i in pvk_int_list] 232 | res = _scalar_multiplications(pvk_int_list) 233 | return bytes(bytearray(res)) 234 | #============================================================================== 235 | # ============================================================================= 236 | # def point_multiplication(k, P): 237 | # ''' k=scalar. P = Input Point. Output is 65 bytes uncompressed pubkey ''' 238 | # if type(P) == int: k,P = P,k 239 | # def bits(k): 240 | # while k: 241 | # yield k & 1 242 | # k >>= 1 243 | # result = Zero 244 | # addend = P 245 | # for bit in bits(k): 246 | # if bit == 1: result=point_addition(result,addend) 247 | # addend=point_doubling(addend) 248 | # return result 249 | # ============================================================================= 250 | #============================================================================== 251 | def _point_multiplication(pubkey_bytes, kk): 252 | ''' Input Point and Integer value passed to function. 65 bytes uncompressed pubkey output ''' 253 | res = (b'\x00') * 65 254 | bytes_value = bytes.fromhex(hex(kk)[2:].zfill(64)) # strict 32 bytes scalar 255 | ice.point_multiplication(pubkey_bytes, bytes_value, res) 256 | return res 257 | def point_multiplication(P, k): 258 | if type(P) == int: k,P = P,k 259 | res = _point_multiplication(P, k) 260 | return bytes(bytearray(res)) 261 | 262 | #============================================================================== 263 | def _get_x_to_y(x_hex, is_even): 264 | ''' Input x_hex encoded as bytes and bool is_even. 32 bytes y of point output ''' 265 | res = (b'\x00') * 32 266 | ice.get_x_to_y(x_hex.encode('utf8'), is_even, res) 267 | return res 268 | def get_x_to_y(x_hex, is_even): 269 | res = _get_x_to_y(x_hex, is_even) 270 | return bytes(bytearray(res)) 271 | #============================================================================== 272 | def _point_increment(pubkey_bytes): 273 | res = (b'\x00') * 65 274 | ice.point_increment(pubkey_bytes, res) 275 | return res 276 | def point_increment(pubkey_bytes): 277 | res = _point_increment(pubkey_bytes) 278 | return bytes(bytearray(res)) 279 | #============================================================================== 280 | def _point_negation(pubkey_bytes): 281 | res = (b'\x00') * 65 282 | ice.point_negation(pubkey_bytes, res) 283 | return res 284 | def point_negation(pubkey_bytes): 285 | res = _point_negation(pubkey_bytes) 286 | return bytes(bytearray(res)) 287 | #============================================================================== 288 | def _point_doubling(pubkey_bytes): 289 | res = (b'\x00') * 65 290 | ice.point_doubling(pubkey_bytes, res) 291 | return res 292 | def point_doubling(pubkey_bytes): 293 | res = _point_doubling(pubkey_bytes) 294 | return bytes(bytearray(res)) 295 | #============================================================================== 296 | def init_P2_Group(pubkey_bytes): 297 | ice.init_P2_Group(pubkey_bytes) 298 | #============================================================================== 299 | def privatekey_to_coinaddress(coin_type, addr_type, iscompressed, pvk_int): 300 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 301 | if pvk_int < 0: pvk_int = N+pvk_int 302 | pass_int_value = fl(pvk_int).encode('utf8') 303 | res = ice.privatekey_to_coinaddress(coin_type, addr_type, iscompressed, pass_int_value) 304 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 305 | ice.free_memory(res) 306 | return addr 307 | #============================================================================== 308 | def privatekey_to_address(addr_type, iscompressed, pvk_int): 309 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 310 | if pvk_int < 0: pvk_int = N+pvk_int 311 | pass_int_value = fl(pvk_int).encode('utf8') 312 | res = ice.privatekey_to_address(addr_type, iscompressed, pass_int_value) 313 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 314 | ice.free_memory(res) 315 | return addr 316 | #============================================================================== 317 | def hash_to_address(addr_type, iscompressed, hash160_bytes): 318 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 319 | res = ice.hash_to_address(addr_type, iscompressed, hash160_bytes) 320 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 321 | ice.free_memory(res) 322 | return addr 323 | #============================================================================== 324 | def pubkey_to_address(addr_type, iscompressed, pubkey_bytes): 325 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 326 | res = ice.pubkey_to_address(addr_type, iscompressed, pubkey_bytes) 327 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 328 | ice.free_memory(res) 329 | return addr 330 | #============================================================================== 331 | def _privatekey_to_h160(addr_type, iscompressed, pvk_int): 332 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 333 | if pvk_int < 0: pvk_int = N+pvk_int 334 | pass_int_value = fl(pvk_int).encode('utf8') 335 | res = (b'\x00') * 20 336 | ice.privatekey_to_h160(addr_type, iscompressed, pass_int_value, res) 337 | return res 338 | def privatekey_to_h160(addr_type, iscompressed, pvk_int): 339 | res = _privatekey_to_h160(addr_type, iscompressed, pvk_int) 340 | return bytes(bytearray(res)) 341 | #============================================================================== 342 | def _privatekey_loop_h160(num, addr_type, iscompressed, pvk_int): 343 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 344 | if pvk_int < 0: pvk_int = N+pvk_int 345 | pass_int_value = fl(pvk_int).encode('utf8') 346 | res = (b'\x00') * (20 * num) 347 | ice.privatekey_loop_h160(num, addr_type, iscompressed, pass_int_value, res) 348 | return res 349 | def privatekey_loop_h160(num, addr_type, iscompressed, pvk_int): 350 | if num <= 0: num = 1 351 | res = _privatekey_loop_h160(num, addr_type, iscompressed, pvk_int) 352 | return bytes(bytearray(res)) 353 | #============================================================================== 354 | def _privatekey_loop_h160_sse(num, addr_type, iscompressed, pvk_int): 355 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 356 | if pvk_int < 0: pvk_int = N+pvk_int 357 | pass_int_value = fl(pvk_int).encode('utf8') 358 | res = (b'\x00') * (20 * num) 359 | ice.privatekey_loop_h160_sse(num, addr_type, iscompressed, pass_int_value, res) 360 | return res 361 | def privatekey_loop_h160_sse(num, addr_type, iscompressed, pvk_int): 362 | if num <= 0: num = 1 363 | res = _privatekey_loop_h160_sse(num, addr_type, iscompressed, pvk_int) 364 | return bytes(bytearray(res)) 365 | #============================================================================== 366 | def _pubkey_to_h160(addr_type, iscompressed, pubkey_bytes): 367 | # type = 0 [p2pkh], 1 [p2sh], 2 [bech32] 368 | res = (b'\x00') * 20 369 | ice.pubkey_to_h160(addr_type, iscompressed, pubkey_bytes, res) 370 | return res 371 | def pubkey_to_h160(addr_type, iscompressed, pubkey_bytes): 372 | res = _pubkey_to_h160(addr_type, iscompressed, pubkey_bytes) 373 | return bytes(bytearray(res)) 374 | #============================================================================== 375 | def _pub_endo1(pubkey_bytes): 376 | res = (b'\x00') * 65 377 | ice.pub_endo1(pubkey_bytes, res) 378 | return res 379 | def pub_endo1(pubkey_bytes): 380 | res = _pub_endo1(pubkey_bytes) 381 | return bytes(bytearray(res)) 382 | #============================================================================== 383 | def _pub_endo2(pubkey_bytes): 384 | res = (b'\x00') * 65 385 | ice.pub_endo2(pubkey_bytes, res) 386 | return res 387 | def pub_endo2(pubkey_bytes): 388 | res = _pub_endo2(pubkey_bytes) 389 | return bytes(bytearray(res)) 390 | #============================================================================== 391 | def b58py(data): 392 | B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" 393 | 394 | if data[0] == 0: 395 | return "1" + b58py(data[1:]) 396 | 397 | x = sum([v * (256 ** i) for i, v in enumerate(data[::-1])]) 398 | ret = "" 399 | while x > 0: 400 | ret = B58[x % 58] + ret 401 | x = x // 58 402 | 403 | return ret 404 | #============================================================================== 405 | def b58_encode(inp_bytes): 406 | res = ice.b58_encode(inp_bytes, len(inp_bytes)) 407 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 408 | ice.free_memory(res) 409 | return addr 410 | #============================================================================== 411 | def b58_decode(inp): 412 | res = ice.b58_decode(inp.encode("utf-8")) 413 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 414 | ice.free_memory(res) 415 | return addr 416 | #============================================================================== 417 | def bech32_address_decode(addr, coin_type=0): 418 | ''' Input address in String format. Output h160 in hex string format 419 | [Note] p2wsh = bech32(sha256(21 + pubkey + ac)). So Decoding it not Needed ''' 420 | if len(addr) > 50: print('[Error] Bech32 p2wsh Not Supported. Result Truncated') 421 | h160 = (b'\x00') * 20 422 | ice.bech32_address_decode(coin_type, addr.encode("utf-8"), h160) 423 | return bytes(bytearray(h160)).hex() 424 | #============================================================================== 425 | def address_to_h160(p2pkh): 426 | ''' Input address in String format. Output h160 in hex string format''' 427 | h1 = b58_decode(p2pkh) 428 | return h1[2:-8] 429 | #============================================================================== 430 | def btc_wif_to_pvk_hex(wif): 431 | pvk = '' 432 | if wif[0] == '5': 433 | pvk = b58_decode(wif)[2:-8] 434 | elif wif[0] in ['L', 'K']: 435 | pvk = b58_decode(wif)[2:-10] 436 | else: print('[Error] Incorrect WIF Key') 437 | return pvk 438 | #============================================================================== 439 | def btc_wif_to_pvk_int(wif): 440 | pvk = '' 441 | pvk_hex = btc_wif_to_pvk_hex(wif) 442 | if pvk_hex != '': pvk = int(pvk_hex, 16) 443 | return pvk 444 | #============================================================================== 445 | def btc_pvk_to_wif(pvk, is_compressed=True): 446 | ''' Input Privatekey can in any 1 of these [Integer] [Hex] [Bytes] form''' 447 | inp = '' 448 | suff = '01' if is_compressed == True else '' 449 | if type(pvk) in [int, str]: inp = bytes.fromhex('80' + fl(pvk) + suff) 450 | elif type(pvk) == bytes: inp = b'\x80' + fl(pvk) + bytes.fromhex(suff) 451 | else: print("[Error] Input Privatekey format [Integer] [Hex] [Bytes] allowed only") 452 | if inp != '': 453 | res = get_sha256(inp) 454 | res2 = get_sha256(res) 455 | return b58_encode(inp + res2[:4]) 456 | else: return inp 457 | #============================================================================== 458 | def checksum(inp): 459 | ''' Input string output double sha256 checksum 4 bytes''' 460 | res = get_sha256(inp) 461 | res2 = get_sha256(res) 462 | return res2[:4] 463 | #============================================================================== 464 | def fl(sstr, length=64): 465 | ''' Fill input to exact 32 bytes. If input is int or str the return is str. if input is bytes return is bytes''' 466 | if type(sstr) == int: fixed = hex(sstr)[2:].zfill(length) 467 | elif type(sstr) == str: fixed = sstr[2:].zfill(length) if sstr[:2].lower() == '0x' else sstr.zfill(length) 468 | elif type(sstr) == bytes: fixed = (b'\x00') * (32 - len(sstr)) + sstr 469 | else: print("[Error] Input format [Integer] [Hex] [Bytes] allowed only. Detected : ", type(sstr)) 470 | return fixed 471 | #============================================================================== 472 | def pbkdf2_hmac_sha512_dll(words): 473 | seed_bytes = (b'\x00') * 64 474 | # words = 'good push broken people salad bar mad squirrel joy dismiss merge jeans token wear boring manual doll near sniff turtle sunset lend invest foil' 475 | ice.pbkdf2_hmac_sha512_dll(seed_bytes, words.encode("utf-8"), len(words)) 476 | return seed_bytes 477 | #============================================================================== 478 | def pbkdf2_hmac_sha512_list(words_list): 479 | ''' strength is [12, 18, 24]. words_list is a list of strings with each line having valid mnemonics''' 480 | wl = len(words_list) 481 | strength = len(words_list[0].split()) 482 | words = ' '.join(words_list) 483 | seed_bytes = (b'\x00') * (64 * wl) 484 | # words = 'good push broken people salad bar mad squirrel joy dismiss merge jeans token wear boring manual doll near sniff turtle sunset lend invest foil' 485 | ice.pbkdf2_hmac_sha512_list(seed_bytes, words.encode("utf-8"), len(words), strength, wl) 486 | return seed_bytes 487 | #============================================================================== 488 | def get_sha256(input_bytes): 489 | digest_bytes = (b'\x00') * 32 490 | if type(input_bytes) == str: input_bytes = input_bytes.encode("utf-8") 491 | # MiniKey example 492 | ice.get_sha256(input_bytes, len(input_bytes), digest_bytes) 493 | return digest_bytes 494 | #============================================================================== 495 | def create_baby_table(start_value, end_value): 496 | res = (b'\x00') * ((1+end_value-start_value) * 32) 497 | ice.create_baby_table(start_value, end_value, res) 498 | return bytes(bytearray(res)) 499 | #============================================================================== 500 | def _point_addition(pubkey1_bytes, pubkey2_bytes): 501 | res = (b'\x00') * 65 502 | ice.point_addition(pubkey1_bytes, pubkey2_bytes, res) 503 | return res 504 | def point_addition(pubkey1_bytes, pubkey2_bytes): 505 | res = _point_addition(pubkey1_bytes, pubkey2_bytes) 506 | return bytes(bytearray(res)) 507 | #============================================================================== 508 | def _point_subtraction(pubkey1_bytes, pubkey2_bytes): 509 | res = (b'\x00') * 65 510 | ice.point_subtraction(pubkey1_bytes, pubkey2_bytes, res) 511 | return res 512 | def point_subtraction(pubkey1_bytes, pubkey2_bytes): 513 | res = _point_subtraction(pubkey1_bytes, pubkey2_bytes) 514 | return bytes(bytearray(res)) 515 | #============================================================================== 516 | def _point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes): 517 | res = (b'\x00') * (65 * num) 518 | ice.point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes, res) 519 | return res 520 | def point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes): 521 | ''' Continuously subtracting point2 into point1 in a loop of num times. 522 | Output is array of pubkeys P1-P2, P1-2P2, P1-3P2, P1-4P2....''' 523 | if num <= 0: num = 1 524 | res = _point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes) 525 | return bytes(bytearray(res)) 526 | #============================================================================== 527 | def _point_loop_addition(num, pubkey1_bytes, pubkey2_bytes): 528 | res = (b'\x00') * (65 * num) 529 | ice.point_loop_addition(num, pubkey1_bytes, pubkey2_bytes, res) 530 | return res 531 | def point_loop_addition(num, pubkey1_bytes, pubkey2_bytes): 532 | ''' Continuously adding point2 into point1 in a loop of num times. 533 | Output is array of pubkeys P1+P2, P1+2P2, P1+3P2, P1+4P2....''' 534 | if num <= 0: num = 1 535 | res = _point_loop_addition(num, pubkey1_bytes, pubkey2_bytes) 536 | return bytes(bytearray(res)) 537 | #============================================================================== 538 | def _point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes): 539 | res = (b'\x00') * (65 * num) 540 | ice.point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes, res) 541 | return res 542 | def point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes): 543 | ''' Adding two array of points of equal length. ''' 544 | if num <= 0: num = 1 545 | res = _point_vector_addition(num, pubkeys1_bytes, pubkeys2_bytes) 546 | return bytes(bytearray(res)) 547 | #============================================================================== 548 | def _point_sequential_increment_P2(num, pubkey1_bytes): 549 | res = (b'\x00') * (65 * num) 550 | ice.point_sequential_increment_P2(num, pubkey1_bytes, res) 551 | return res 552 | def point_sequential_increment_P2(num, pubkey1_bytes): 553 | ''' This is the fastest implementation to add point P2 in the given Point sequentially.''' 554 | if num <= 0: num = 1 555 | res = _point_sequential_increment_P2(num, pubkey1_bytes) 556 | return bytes(bytearray(res)) 557 | #============================================================================== 558 | def _point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu): 559 | res = (b'\x00') * (65 * num) 560 | ice.point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu, res) 561 | return res 562 | def point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu=os.cpu_count()): 563 | ''' This is the fastest multi CPU implementation to add point P2 in the given Point sequentially. Threads are Not optimised yet''' 564 | if num <= 0: num = 1 565 | res = _point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu) 566 | return bytes(bytearray(res)) 567 | #============================================================================== 568 | def _point_sequential_increment(num, pubkey1_bytes): 569 | res = (b'\x00') * (65 * num) 570 | ice.point_sequential_increment(num, pubkey1_bytes, res) 571 | return res 572 | def point_sequential_increment(num, pubkey1_bytes): 573 | ''' This is the fastest implementation using G''' 574 | if num <= 0: num = 1 575 | res = _point_sequential_increment(num, pubkey1_bytes) 576 | return bytes(bytearray(res)) 577 | #============================================================================== 578 | def _point_sequential_decrement(num, pubkey1_bytes): 579 | res = (b'\x00') * (65 * num) 580 | ice.point_sequential_decrement(num, pubkey1_bytes, res) 581 | return res 582 | def point_sequential_decrement(num, pubkey1_bytes): 583 | ''' This is the fastest implementation using -G.''' 584 | if num <= 0: num = 1 585 | res = _point_sequential_decrement(num, pubkey1_bytes) 586 | return bytes(bytearray(res)) 587 | #============================================================================== 588 | def pubkey_to_ETH_address(pubkey_bytes): 589 | ''' 65 Upub bytes input. Output is 20 bytes ETH address lowercase with 0x as hex string''' 590 | xy = pubkey_bytes[1:] 591 | res = ice.pubkeyxy_to_ETH_address(xy) 592 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 593 | ice.free_memory(res) 594 | return '0x'+addr 595 | #============================================================================== 596 | def _pubkey_to_ETH_address_bytes(xy): 597 | res = (b'\x00') * 20 598 | ice.pubkeyxy_to_ETH_address_bytes(xy, res) 599 | return res 600 | def pubkey_to_ETH_address_bytes(pubkey_bytes): 601 | ''' 65 Upub bytes input. Output is 20 bytes ETH address lowercase without 0x''' 602 | xy = pubkey_bytes[1:] 603 | res = _pubkey_to_ETH_address_bytes(xy) 604 | return bytes(bytearray(res)) 605 | #============================================================================== 606 | def privatekey_to_ETH_address(pvk_int): 607 | ''' Privatekey Integer value passed to function. Output is 20 bytes ETH address lowercase with 0x as hex string''' 608 | if pvk_int < 0: pvk_int = N+pvk_int 609 | pass_int_value = fl(pvk_int).encode('utf8') 610 | res = ice.privatekey_to_ETH_address(pass_int_value) 611 | addr = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 612 | ice.free_memory(res) 613 | return '0x'+addr 614 | #============================================================================== 615 | def _privatekey_to_ETH_address_bytes(pass_int_value): 616 | res = (b'\x00') * 20 617 | ice.privatekey_to_ETH_address_bytes(pass_int_value, res) 618 | return res 619 | def privatekey_to_ETH_address_bytes(pvk_int): 620 | ''' Privatekey Integer value passed to function. Output is 20 bytes ETH address lowercase without 0x''' 621 | if pvk_int < 0: pvk_int = N+pvk_int 622 | pass_int_value = fl(pvk_int).encode('utf8') 623 | res = _privatekey_to_ETH_address_bytes(pass_int_value) 624 | return bytes(bytearray(res)) 625 | #============================================================================== 626 | def privatekey_group_to_ETH_address(pvk_int, m): 627 | ''' Starting Privatekey Integer value passed to function as pvk_int. 628 | Integer m is, how many times sequential increment is done from the starting key. 629 | Output is bytes 20*m of ETH address lowercase without 0x as hex string''' 630 | if m<=0: m = 1 631 | if pvk_int < 0: pvk_int = N+pvk_int 632 | start_pvk = fl(pvk_int).encode('utf8') 633 | res = ice.privatekey_group_to_ETH_address(start_pvk, m) 634 | addrlist = (ctypes.cast(res, ctypes.c_char_p).value).decode('utf8') 635 | ice.free_memory(res) 636 | return addrlist 637 | #============================================================================== 638 | def _privatekey_group_to_ETH_address_bytes(start_pvk, m): 639 | res = (b'\x00') * (20 * m) 640 | ice.privatekey_group_to_ETH_address_bytes(start_pvk, m, res) 641 | return res 642 | def privatekey_group_to_ETH_address_bytes(pvk_int, m): 643 | ''' Starting Privatekey Integer value passed to function as pvk_int. 644 | Integer m is, how many times sequential increment is done from the starting key. 645 | Output is bytes 20*m of ETH address lowercase without 0x''' 646 | if m<=0: m = 1 647 | if pvk_int < 0: pvk_int = N+pvk_int 648 | start_pvk = fl(pvk_int).encode('utf8') 649 | res = _privatekey_group_to_ETH_address_bytes(start_pvk, m) 650 | return bytes(bytearray(res)) 651 | #============================================================================== 652 | def bloom_check_add_mcpu(bigbuff, num_items, sz, mcpu, check_add, bloom_bits, bloom_hashes, bloom_filter): 653 | found_array = (b'\x00') * num_items 654 | # sz = 32; check_add = 0 for check and 1 for add 655 | ice.bloom_check_add_mcpu(bigbuff, num_items, found_array, sz, mcpu, check_add, bloom_bits, bloom_hashes, bloom_filter) 656 | return found_array 657 | #============================================================================== 658 | def to_cpub(pub_hex): 659 | P = pub_hex 660 | if len(pub_hex) > 70: 661 | P = '02' + pub_hex[2:66] if int(pub_hex[66:],16)%2 == 0 else '03' + pub_hex[2:66] 662 | return P 663 | #============================================================================== 664 | def point_to_cpub(pubkey_bytes): 665 | P = pubkey_bytes.hex() 666 | if len(P) > 70: 667 | P = '02' + P[2:66] if int(P[66:],16)%2 == 0 else '03' + P[2:66] 668 | return P 669 | #============================================================================== 670 | def pub2upub(pub_hex): 671 | ''' Covert [C or U] pubkey to Point''' 672 | x = pub_hex[2:66] 673 | if len(pub_hex) < 70: 674 | y = get_x_to_y(x, int(pub_hex[:2],16)%2 == 0).hex() 675 | else: 676 | y = pub_hex[66:].zfill(64) 677 | return bytes.fromhex('04'+ x + y) 678 | #============================================================================== 679 | def bloom_para(_items, _fp = 0.000001): 680 | _bits = math.ceil((_items * math.log(_fp)) / math.log(1 / pow(2, math.log(2)))) 681 | if _bits % 8: _bits = 8*(1 + (_bits//8)) 682 | _hashes = round((_bits / _items) * math.log(2)) 683 | return _bits, _hashes 684 | #============================================================================== 685 | def Fill_in_bloom(inp_list, _fp = 0.000001): 686 | _bits, _hashes = bloom_para(len(inp_list), _fp) 687 | _bf = (b'\x00') * (_bits//8) 688 | for line in inp_list: 689 | if type(line) != bytes: tt = str(line).encode("utf-8") 690 | else: tt = line 691 | res = ice.bloom_check_add(tt, len(tt), 1, _bits, _hashes, _bf) # 1 = Add 692 | del res 693 | return _bits, _hashes, _bf, _fp, len(inp_list) 694 | #============================================================================== 695 | def dump_bloom_file(output_bloom_file_name, _bits, _hashes, _bf, _fp, _elem): 696 | with open(output_bloom_file_name, 'wb') as f: 697 | pickle.dump((_bits, _hashes, _bf, _fp, _elem), f) 698 | 699 | def read_bloom_file(bloom_file_name): 700 | '''It will return the 5 output as _bits, _hashes, _bf, _fp, _elem''' 701 | with open(bloom_file_name, 'rb') as f: 702 | return pickle.load(f) 703 | #============================================================================== 704 | def check_in_bloom(this_line, _bits, _hashes, _bf): 705 | if type(this_line) != bytes: tt = str(this_line).encode("utf-8") 706 | else: tt = this_line 707 | if ice.bloom_check_add(tt, len(tt), 0, _bits, _hashes, _bf) > 0: return True 708 | else: return False 709 | #============================================================================== 710 | def create_bsgs_bloom_mcpu(mcpu, total_entries, _fp = 0.0000001): 711 | if total_entries%(mcpu*1000) != 0: 712 | total_entries = mcpu*1000*(total_entries//(mcpu*1000)) 713 | if total_entries == 0: total_entries = mcpu * 1000 714 | print('[*] Number of elements should be a multiple of 1000*mcpu. Automatically corrected it to nearest value:',total_entries) 715 | _bits, _hashes = bloom_para(total_entries, _fp) 716 | _bf = bytes(b'\x00') * (_bits//8) 717 | print(f'[+] bloom [bits: {_bits}] [hashes: {_hashes}] [size: {_bits//8} Bytes] [false prob: {_fp}]') 718 | ice.create_bsgs_bloom_mcpu(mcpu, total_entries, _bits, _hashes, _bf) 719 | return _bits, _hashes, _bf, _fp, total_entries 720 | #============================================================================== 721 | def bsgs_2nd_check_prepare(bP_elem = 2000000000): 722 | if bP_elem < 8000000: bP_elem = 8000000 # Less than 8 million is not allowed 723 | ice.bsgs_2nd_check_prepare(bP_elem) 724 | #============================================================================== 725 | def bsgs_2nd_check(pubkey_bytes, z1_int, bP_elem): 726 | if z1_int < 0: z1_int = N+z1_int 727 | hex_value = fl(z1_int).encode('utf8') 728 | res = (b'\x00') * 32 729 | found = ice.bsgs_2nd_check(pubkey_bytes, hex_value, bP_elem, res) 730 | return found, res 731 | #============================================================================== 732 | def prepare_bin_file_work(in_file, out_file, lower = False): 733 | use0x = False 734 | inp_list = [line.split()[0].lower() if lower else line.split()[0] for line in open(in_file,'r')] 735 | if inp_list[0][:2] == '0x': use0x = True 736 | 737 | with open(out_file, 'wb') as f: 738 | if use0x: 739 | inp_list = [line[2:] for line in inp_list] 740 | inp_list.sort() 741 | for line in inp_list: 742 | f.write(bytes.fromhex(line)) 743 | #============================================================================== 744 | def prepare_bin_file(in_file, out_file, overwrite = False, lower = False): 745 | 746 | if os.path.isfile(out_file) == False: 747 | prepare_bin_file_work(in_file, out_file, lower) 748 | 749 | else: 750 | if not overwrite: 751 | print(f'[+] File {out_file} already exist. It will be used as it is...') 752 | 753 | else: 754 | print(f'[+] File {out_file} already exist. Overwriting it...') 755 | prepare_bin_file_work(in_file, out_file) 756 | #============================================================================== 757 | def Load_data_to_memory(input_bin_file, verbose = False): 758 | '''input_bin_file is sorted h160 data of 20 bytes each element. 759 | ETH address can also work without 0x if sorted binary format''' 760 | ice.Load_data_to_memory(input_bin_file.encode("utf-8"), verbose) 761 | 762 | #============================================================================== 763 | def check_collision(h160): 764 | ''' h160 is the 20 byte hash to check for collision in data, already loaded in RAM. 765 | Use the function Load_data_to_memory before calling this check''' 766 | 767 | found = ice.check_collision(h160) 768 | return found 769 | --------------------------------------------------------------------------------