<p>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.</p>
<p>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.</p>
<p>The following code actually finds the correct number:</p>
<pre><code>for i in range(0, 20):
    d = int.to_bytes(i, 1, byteorder=&quot;big&quot;)
    h = hashlib.sha256(d)
    if h.hexdigest() == &quot;e7cf46a078fed4fafd0b5e3aff144802b853f8ae459a4f0c14add3314b7cc3a6&quot;:
        print(i)
        break
</code></pre>

CC BY-SA 4.0
2023-08-17T13:33:39.130Z
2023-08-17T13:33:39.130Z
Ava Chow
<p>I found this script puzzle post by ValentinoZ:</p>
<p><a href="https://twitter.com/vazertuche/status/1691814230129848473" rel="nofollow noreferrer">https://twitter.com/vazertuche/status/1691814230129848473</a></p>
<p>I've tried solving it and can't seem to get it. I get stuck at the op_equalverify for the hash e7cf46a078fed4fafd0b5e3aff144802b853f8ae459a4f0c14add3314b7cc3a6</p>
<p>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.</p>
<pre><code>for i in np.arange(0, 20, 0.1):
    num = round(i, 1)
    text = str(num)
    #print(text)
    hashstr = hashlib.sha256(text.encode('utf-8'))
    text_hashed = hashstr.hexdigest()
    #print(text_hashed)
    if text_hashed == &quot;e7cf46a078fed4fafd0b5e3aff144802b853f8ae459a4f0c14add3314b7cc3a6&quot;:
        print(i)
        break
</code></pre>
<p>I went through the rest of the op codes using <a href="https://siminchen.github.io/bitcoinIDE/build/editor.html" rel="nofollow noreferrer">https://siminchen.github.io/bitcoinIDE/build/editor.html</a> and found out it would be the first value in the input that would need to match.</p>
<p>It's my first time trying one of these. Maybe I'm just confused by the hint? What am I not understanding here?</p>

<script><opcodes>
Bitcoin Script Puzzle
Marco
# Bitcoin Script Puzzle

(Asked by: username_0 on 2023-08-16)

I found this script puzzle post by ValentinoZ:

<https://twitter.com/vazertuche/status/1691814230129848473>

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)
    #print(text)
    hashstr = hashlib.sha256(text.encode('utf-8'))
    text_hashed = hashstr.hexdigest()
    #print(text_hashed)
    if text_hashed == "e7cf46a078fed4fafd0b5e3aff144802b853f8ae459a4f0c14add3314b7cc3a6":
        print(i)
        break

```

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?

**Tags:** script, opcodes


---

## 1 answers

### Answer by username_1 on 2023-08-17. Score: 2 | Accepted answer

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":
        print(i)
        break

```


---

