Created
April 1, 2018 19:54
-
-
Save pawlos/64d63fa73d6b871eba566a9599e809e4 to your computer and use it in GitHub Desktop.
Trying to find block of bytes that will construct a valid SpyCoin block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import struct | |
import hashlib | |
import itertools | |
def verify_block(hash): | |
# Difficulty history: | |
# We increased difficulty starting from block 52, have to match "Spy". | |
# We increased difficulty starting from block 138, have to match "SpyCoinXoXo". | |
#if self.block_num < 52: | |
#return hash.startswith("Sp") | |
#if self.block_num < 138: | |
# return hash.startswith("Spy") | |
return hash.startswith("SpyCoinXoXo") | |
def block_hash(block): | |
step1 = hashlib.md5(block).digest() | |
step2 = hashlib.md5(step1).digest() | |
return step2 | |
data = bytearray("0253707927c4f79853d74aef754374a86d03627269736f74770053656372657432305c2c020003626973686f7000005365637265743230e6810100036b6179000000000053656372657432301e650100036167656e743939005365637265743230c660010003646f6e706564726f5365637265743230e1af0000036e617461736861005365637265743230197d0000".decode('hex')) | |
#print len(data) | |
#print block_hash(data).encode('hex') | |
for k in range(1,10): | |
print 'Testing: ',k | |
for i in itertools.product(range(255), repeat=k): | |
#print i | |
b = data + (''.join(map(chr,i))) | |
#print b | |
if verify_block(block_hash(b)): | |
print 'Found!',i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment