I found this script puzzle post by ValentinoZ:


I've tried solving it and can't seem to get it. I get stuck at the op_equalverify for the hash e7cf46a078fed4fafd0b5e3aff144802b853f8ae459a4f0c14add3314b7cc3a6

I wrote a program that goes through numbers 0-20 (decimals too) and hashes them all to see if I could get one to match. I tried different decimal places as well.

for i in np.arange(0, 20, 0.1):
    num = round(i, 1)
    text = str(num)
    hashstr = hashlib.sha256(text.encode('utf-8'))
    text_hashed = hashstr.hexdigest()
    if text_hashed == "e7cf46a078fed4fafd0b5e3aff144802b853f8ae459a4f0c14add3314b7cc3a6":

I went through the rest of the op codes using https://siminchen.github.io/bitcoinIDE/build/editor.html and found out it would be the first value in the input that would need to match.

It's my first time trying one of these. Maybe I'm just confused by the hint? What am I not understanding here?


1 Answer 1


The hashing opcodes hash the bytes of whatever is on the top of the stack. It doesn't matter if that's a byte vector, some text, or a number - they're all interpreted the same way (as bytes) and hashed.

This means that you are hashing the numbers incorrectly. You're turning the numbers into text, and those bytes are then hashed. However the bytes of the text representing those numbers do not match the actual bytes that the script interpreter will hash, so you're not finding the right match.

The following code actually finds the correct number:

for i in range(0, 20):
    d = int.to_bytes(i, 1, byteorder="big")
    h = hashlib.sha256(d)
    if h.hexdigest() == "e7cf46a078fed4fafd0b5e3aff144802b853f8ae459a4f0c14add3314b7cc3a6":

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.