def getPubkey(new_prvkey, flag_compress): if flag_gmpy2: Ptmp = mul_ka(new_prvkey) Xcoord = Ptmp.x Ycoord = Ptmp.y elif flag_coincurve: Ptmp = PublicKey.from_valid_secret(int_to_bytes_padded(new_prvkey)) if flag_cffi: tmp_pubkey = ffi.buffer(Ptmp.public_key, 64)[:] Xcoord = bytes_to_int(tmp_pubkey[31::-1]) Ycoord = bytes_to_int(tmp_pubkey[:31:-1]) else: Xcoord, Ycoord = Ptmp.point() else: Ptmp = mul_ka(new_prvkey) Xcoord = Ptmp.x Ycoord = Ptmp.y if flag_compress: if (Ycoord % 2) == 0: new_pubkey = '02%064x' % int(hex(Xcoord)[2:66], 16) else: new_pubkey = '03%064x' % int(hex(Xcoord)[2:66], 16) else: new_pubkey = '04%064x%064x' % (int(hex(Xcoord)[2:66], 16), int(hex(Ycoord)[2:66], 16)) return new_pubkey
def generate(clan_tag): try: _ = int(clan_tag, 16) except ValueError: print(f'Error: "{clan_tag}" is not valid hex.') exit(1) n = len(clan_tag) while True: # Generate a private key p_hash_obj = keccak.new(digest_bits=256) seed = secrets.token_bytes(32) p_hash_obj.update(seed) p = p_hash_obj.digest() # Derive the public key q = PublicKey.from_valid_secret(p).format(compressed=False)[1:] # Hash public key into account address addr_hash_obj = keccak.new(digest_bits=256) addr_hash_obj.update(q) address = addr_hash_obj.digest()[-20:] if address.hex()[-n:] == clan_tag: print('Seed : ' + seed.hex()) print('Private key: ' + p_hash_obj.hexdigest()) print('Public key : ' + q.hex()) print('Address : ' + address.hex()) print('Never share the seed or private key with anyone!') print('Never share the seed or private key with anyone!') print('Never share the seed or private key with anyone!') break
def generate(): gen = {} gen["private_key"] = keccak_256(token_bytes(32)).digest() gen["public_key"] = PublicKey.from_valid_secret( gen["private_key"]).format(compressed=False)[1:] gen["address"] = keccak_256(gen["public_key"]).digest()[-20:] return gen
def generate_wallet(): """ simple function to generate a wallet address """ private_key = keccak_256(token_bytes(32)).digest() public_key = PublicKey.from_valid_secret(private_key).format(compressed=False)[1:] addr = keccak_256(public_key).digest()[-20:] return [private_key, public_key, addr]
def _private_key_to_address(self, private_key): if private_key[0:2] == "0x": private_key = private_key[2:] private_key = bytes.fromhex(private_key) public_key = PublicKey.from_valid_secret(private_key).format( compressed=False)[1:] addr = keccak_256(public_key).digest()[-20:] return addr.hex()
def priv_to_addr(hex_priv: str): try: if len(hex_priv) != 64: raise Exception("length err") else: return "0x" + keccak_256( PublicKey.from_valid_secret(bytes.fromhex(hex_priv)).format( compressed=False)[1:]).digest()[-20:].hex() except: return "0x" + "0" * 40
def hello_world(): from coincurve import PublicKey from sha3 import keccak_256 import os import time import etherscan import time start_time = time.time() es = etherscan.Client(api_key='HB88FQKBAIKSSVX1BQWDP1KJ9BKTUSJVT2', ) addrss = [] pvkeys = [] bolfnd = 0 x = 0 y = 0 while y < 50: y = y + 1 x = 0 while x < 20: x = x + 1 private_key = keccak_256(os.urandom(32)).digest() public_key = PublicKey.from_valid_secret(private_key).format( compressed=False)[1:] addr = keccak_256(public_key).digest()[-20:] addr = addr.hex() private_key = private_key.hex() addrss.append("0x" + str(addr)) pvkeys.append(str(private_key)) eth_balance = es.get_eth_balances(addrss) aa = list(eth_balance.values()) for bl in aa: if bl != 0: bolfnd = 1 if bolfnd != 0: break time.sleep(500 / 1000) addrss = [] pvkeys = [] #return "<xmp>" + "bl:"+str(bolfnd)+"\n" +str(addrss)+ "\n"+str(pvkeys)+"</xmp>" return html("<h1>bl:" + str(bolfnd) + "</h1> <br> " + str(addrss) + " <br> " + str(pvkeys) + "<br>" + str(addr))
def eth(): global num_threads for n in range(10000): start = time.time() private_key = sha3_256(token_bytes(32)).digest() public_key = PublicKey.from_valid_secret(private_key).format( compressed=False)[1:] addr = sha3_256(public_key).digest()[-20:] addr1 = addr.hex() address = Web3.toChecksumAddress(addr1) priv = private_key.hex() f1 = open("ETH/OUT/addr.txt", "a") f1.write(address + ' ' + "\n") f2 = open("ETH/OUT/PrvKeys.txt", "a") f2.write(priv + ' ' + "\n") f1.close() f1.close() end = time.time() print('time/s', (end - start))
def send_welcome(message): user_id = message.from_user.id print(user_id) if (not user_exists(user_id)): private_key = keccak_256(token_bytes(32)).digest() public_key = PublicKey.from_valid_secret(private_key).format( compressed=False)[1:] addr = keccak_256(public_key).digest()[-20:] addr = addr.hex() print('private_key:', private_key.hex()) print('eth addr:', '0x' + addr) unique_code = extract_uid(message.text) if unique_code: # create new user with wallet newuserdata = { 'balance': 0, 'tg_id': user_id, 'wallet_addr': '0x' + str(addr), 'wallet_key': '' + str(private_key.hex()), 'ref_tg_id': int(unique_code) } else: # create new user with wallet newuserdata = { 'balance': 0, 'tg_id': user_id, 'wallet_addr': '0x' + str(addr), 'wallet_key': '' + str(private_key.hex()), 'ref_tg_id': 0 } add_new_user(newuserdata) bot.send_message( message.chat.id, "Это тотализатор BetEther для p2p ставок на курс Ethereum \n\nℹ️ Подробнее о том, как играть: \nhttps://graph.org/Instrukciya-kak-stavit-08-02", reply_markup=menu_keyboard, disable_web_page_preview=True) bot.register_next_step_handler(message, menu)
#!/usr/bin/python3 from secrets import token_bytes from coincurve import PublicKey from sha3 import keccak_256 with open('keys.txt') as fp: key = fp.readline() # Debug print("readed key: ", key) encoded_key = key.encode() print("encoded_key: ", encoded_key.decode()) striped_key = encoded_key.strip() print("striped_key: ", striped_key.strip()) cnt = 1 while key: # private_key = keccak_256(token_bytes(32)).digest() public_key = PublicKey.from_valid_secret(striped_key).format( compressed=False)[1:] addr = keccak_256(public_key).digest()[-20:] print('private_key:', striped_key.hex()) print('eth addr: 0x' + addr.hex()) key = fp.readline() cnt += 1
from coincurve import PublicKey from sha3 import keccak_256 import os f = open("addr.txt", "r") s = f.read() while True: private_key = keccak_256(os.urandom(128)).digest() public_key = PublicKey.from_valid_secret(private_key).format( compressed=False)[1:] addr = keccak_256(public_key).digest()[-20:] addr = addr.hex() private_key = private_key.hex() if addr in s: f = open("foooond.txt", "a") f.write(" add: " + str(addr) + " pk " + str(private_key) + "\n") f.close() print(" add: " + str(addr) + " pk " + str(private_key) + "\n")
def callback_processing(call): global walletn global wallet global EthToken if call.data == "refreshbal": telegram_user_id = call.from_user.id bal_ = 1 bot.answer_callback_query(call.id) usr = get_user(call.from_user.id, False) addr = usr['wallet_addr'] response = requests.get( f"https://api.etherscan.io/api?module=account&action=balance&address={addr}&tag=latest&apikey={EthToken}" ) balnowwal = int(response.json()["result"]) / 1000000000000000000 #берет нынешний баланс адреса эфириум usr = get_user(call.from_user.id, False) baloldwal = usr['balance'] #берет старый баланс адреса из бд user_wallet razbal = check_ref_system(balnowwal - baloldwal, telegram_user_id) #находит разницу балансов(новго от старого) wallet = get_user_ballance(call.from_user.id, False) oldbalhum = wallet['balance'] #берет старый баланс человека из бд user_ballance newbalhum = oldbalhum + razbal #суммирует разницу балансов адресов и нынешний баланс и получает новый баланс update_user(call.from_user.id, {'balance': balnowwal}) #записывает нынешний баланс адреса в бд user_wallet update_user_ballance(telegram_user_id, {'balance': newbalhum}) #записывает новый баланс юзера в бд user_ballance wallet = get_user_ballance(call.from_user.id, False) bal_ = wallet['balance'] message = bot.send_message(call.from_user.id, f"Ваш баланс: {bal_}") if call.data == "upst": bot.answer_callback_query(call.id) message = bot.send_message( call.from_user.id, f"Какую сумму ты хочешь поставить на повышение?", reply_markup=back_keyboard) bot.register_next_step_handler(message, upstavkaa) if call.data == "outst": bot.answer_callback_query(call.id) message = bot.send_message( call.from_user.id, f"Какую сумму ты хочешь поставить на понижение?", reply_markup=back_keyboard) bot.register_next_step_handler(message, outstavkaa) if call.data == "out-money": user = get_user(call.from_user.id) if (get_user_ballance(call.from_user.id).balance <= MOB): message = bot.send_message( call.from_user.id, f"Не достаточно денег на балансе. Минимальная сумма для вывода {MOB}", reply_markup=back_keyboard) bot.register_next_step_handler(message, menu) else: message = bot.send_message(call.from_user.id, f"Какую сумму ты хочешь вывести?", reply_markup=back_keyboard) bot.register_next_step_handler(message, inputoutsumm) if call.data == "in-money": # check if user exsist or not if (not user_exists(call.from_user.id)): private_key = keccak_256(token_bytes(32)).digest() public_key = PublicKey.from_valid_secret(private_key).format( compressed=False)[1:] addr = keccak_256(public_key).digest()[-20:] addr = addr.hex() print('private_key:', private_key.hex()) print('eth addr:', '0x' + addr) #create new user with wallet newuserdata = { 'balance': 0, 'tg_id': call.from_user.id, 'wallet_addr': '0x' + str(addr), 'wallet_key': '' + str(private_key.hex()) } add_new_user(newuserdata) else: usr = get_user(call.from_user.id, False) private_key = usr['wallet_key'] addr = usr['wallet_addr'] print('private_key:', private_key) print('eth addr:', addr) bot.answer_callback_query(call.id) bot.send_message(call.from_user.id, f"Вот твой ETH адрес для пополнения:") bot.send_message(call.from_user.id, f"{addr}", reply_markup=refreshbaba) if call.data == "igra": nowm = datetime.now().minute if 0 <= nowm <= 10 or 30 <= nowm <= 40: bot.answer_callback_query(call.id) bot.send_message(call.from_user.id, "Доступные интервалы на данный момент:", reply_markup=interv) else: bot.answer_callback_query(call.id) ost = 2 if 40 <= nowm <= 60: ost = 60 - nowm - 1 if 10 <= nowm <= 30: ost = 30 - nowm - 1 bot.send_message( call.from_user.id, f"😔 На данный момент нет доступных интервалов\n\nДо начала розыгрыша осталось {ost} минут" ) if call.data == "30min": r = requests.get( 'https://www.coingecko.com/price_charts/279/usd/24_hours.json' ).json() priceprice = r['stats'][-1][1] # цена eth в usd nowm = datetime.now().minute bot.answer_callback_query(call.id) if 30 <= nowm <= 59: ost2 = 60 - nowm if 0 <= nowm <= 29: ost2 = 30 - nowm textvopr = get_user(call.from_user.id) print(textvopr) bot.send_message( call.from_user.id, f"💥🎰 30 минутный интервал\n\nУ тебя есть время чтобы сделать ставку что курс ETH будет выше или ниже чем {pricestart}$ через {ost2} минуты\n\nПоставили Выше: 0.0000 ETH\n\nПоставили Ниже: 0.0000 ETH\n\nETH будет выше или ниже чем {pricestart}$ через {ost2} минуты по паре Binance ETH/USDT ?\n\nАктуальный курс Binance: {priceprice}$", reply_markup=stavka) elif call.data == "my-igra": bot.answer_callback_query(call.id) textvopr = get_user(call.from_user.id) print(textvopr) bot.send_message( call.from_user.id, "🚀 Тут ты можешь посмотреть информацию о розыгрышах, в которых ты принимаешь участие прямо сейчас\n\nНа данный момент ты не принимаешь участие ни в одном розыгрыше" )