Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save notcod/c2e52b6e834f083345d2f463d0d319c8 to your computer and use it in GitHub Desktop.

Select an option

Save notcod/c2e52b6e834f083345d2f463d0d319c8 to your computer and use it in GitHub Desktop.
MINIMUM ETHEREUM WALLET GENERATOR PYTHON 3
from operator import xor
from functools import reduce
from random import randrange
from web3.auto.infura import w3
from time import time
RoundConstants = [
0x0000000000000001, 0x0000000000008082, 0x800000000000808A, 0x8000000080008000,
0x000000000000808B, 0x0000000080000001, 0x8000000080008081, 0x8000000000008009,
0x000000000000008A, 0x0000000000000088, 0x0000000080008009, 0x000000008000000A,
0x000000008000808B, 0x800000000000008B, 0x8000000000008089, 0x8000000000008003,
0x8000000000008002, 0x8000000000000080, 0x000000000000800A, 0x800000008000000A,
0x8000000080008081, 0x8000000000008080, 0x0000000080000001, 0x8000000080008008
]
RotationConstants = [
[0, 1, 62, 28, 27, ],
[36, 44, 6, 55, 20, ],
[3, 10, 43, 25, 39, ],
[41, 45, 15, 21, 8, ],
[18, 2, 61, 56, 14, ]
]
Masks = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, 4294967295, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943, 549755813887, 1099511627775, 2199023255551, 4398046511103, 8796093022207,
17592186044415, 35184372088831, 70368744177663, 140737488355327, 281474976710655, 562949953421311, 1125899906842623, 2251799813685247, 4503599627370495, 9007199254740991, 18014398509481983, 36028797018963967, 72057594037927935, 144115188075855871, 288230376151711743, 576460752303423487, 1152921504606846975, 2305843009213693951, 4611686018427387903, 9223372036854775807, 18446744073709551615]
def keccak_f(state):
for ir in range(24):
C = [reduce(xor, state.s[x]) for x in range(5)]
D = [0] * 5
for x in range(5):
top = C[(x + 1) % 5] >> 63
bot = (C[(x + 1) % 5] & Masks[63]) << 1
D[x] = C[(x - 1) % 5] ^ (bot | top)
for y in range(5):
state.s[x][y] ^= D[x]
B = [[0] * 5 for x in range(5)]
for x in range(5):
for y in range(5):
top = state.s[x][y] >> (64 - RotationConstants[y][x])
bot = (
state.s[x][y] & Masks[64 - RotationConstants[y][x]]) << RotationConstants[y][x]
B[y % 5][(2 * x + 3 * y) % 5] = bot | top
for x in range(5):
for y in range(5):
state.s[x][y] = B[x][y] ^ (
(~ B[(x + 1) % 5][y]) & B[(x + 2) % 5][y])
state.s[0][0] ^= RoundConstants[ir]
class KeccakState(object):
def __init__(self):
self.s = [[0] * 5 for x in range(5)]
def absorb(self, bb):
bb += [0] * 64
i = 0
for y in range(5):
for x in range(5):
r = 0
for b in reversed(bb[i:i + 8]):
r = r << 8 | b
self.s[x][y] ^= r
i += 8
keccak_f(self)
def squeeze(self):
out = [0] * 200
i = 0
for y in range(5):
for x in range(5):
v = []
for b in range(0, 64, 8):
v.append((self.s[x][y] >> b) & 0xff)
out[i:i+8] = v
i += 8
keccak_f(self)
return out[:136]
def Keccak(s):
t = KeccakState()
b = []
b += s
t.absorb(b + [1] + [0] * (134 - len(b)) + [128])
Z = t.squeeze()
return ''.join(format(x, '02x') for x in Z[:32])
def secp256k1_fast(z):
z = str(bin(z))[2:]
l = len(z)
p = 115792089237316195423570985008687907853269984665640564039457584007908834671663
x = Gx = 55066263022277343669578718895168534326250603453777594175500187360389116729240
y = Gy = 32670510020758816978083085130507043184471273380659243275938904335757337482424
for i in range(1, l):
lm, hm = 1, 0
low, high = 2*y % p, p
while low > 1:
ratio = high//low
nm, new = hm-lm*ratio, high-low*ratio
lm, low, hm, high = nm, new, lm, low
R = lm % p
o = 3*x*x*R % p
u = o*o-2*x
y = (o*(x-u % p)-y) % p
x = u % p
if z[i] == "1":
lm, hm = 1, 0
low, high = (Gx - x) % p, p
while low > 1:
ratio = high//low
nm, new = hm-lm*ratio, high-low*ratio
lm, low, hm, high = nm, new, lm, low
R = lm % p
o = (Gy-y)*R % p
u = o*o-x-Gx
y = (o*(x-u % p)-y) % p
x = u % p
pubX = hex(x)[2:]
pubY = hex(y)[2:]
pubX = '0' * (64-len(pubX)) + pubX
pubY = '0' * (64-len(pubY)) + pubY
return bytes.fromhex(pubX + pubY)
def Addr(x):
c = '0x'
a = Keccak(secp256k1_fast(x))[24:]
k = Keccak(a.encode('utf-8'))
for i in range(40):
ac = a[i]
kc = k[i]
if int(kc, 16) >= 8:
ac = ac.upper()
c += str(ac)
return c
def Gen():
s = randrange(115792089237316195423570985008687907853269984665640564039457584007913129639935)
s = 60632113484415760704876662500027918575353797862027037938250656706703186624725
a = Addr(s)
k = hex(s)[2:]
k = '0'*(64-len(k)) + k
b = 0
if b != 0:
f = open("keys.txt", "a")
f.write("\n|" + k + "_" + a)
f.close()
print("Found!")
return (b, a, k)
for i in range(1):
data = Gen()
print(str(data[0]) + " " + data[1] + " " + data[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment