<p>hash1 is a uint256 zero, padded to a multiple of 64 bytes by FormatHashBlocks() in main.cpp, and then reversed in 4 byte chunks.</p>

<p>FormatHashBlocks() puts a 0x80 right after the 32 zero bytes, and a 4 byte bit count at the end (00 00 01 00, meaning 256 bits).</p>

<pre><code>the uint256 zero is:
0000000000000000 0000000000000000 0000000000000000 0000000000000000

it's padded to 64 bytes:
0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000
                                                                    ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
has the 80 in the first byte of padding:
0000000000000000 0000000000000000 0000000000000000 0000000000000000 8000000000000000 0000000000000000 0000000000000000 0000000000000000
                                                                    ^^
and the length at the end:
0000000000000000 0000000000000000 0000000000000000 0000000000000000 8000000000000000 0000000000000000 0000000000000000 0000000000000100
                                                                                                                               ^^^^^^^^
and then has each group of 4 bytes reversed: 12 34 56 78 -&gt; 78 56 34 12
0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000008000000000 0000000000000000 0000000000000000 0000000000010000
                                                                    ^^^^^^^^                                                   ^^^^^^^^
</code></pre>

<p>A better question might be "why is hash1's value calculated like this"?</p>

<p>You didn't ask, but the <code>data</code> field returned by <code>getwork</code> is formatted the same way.  Instead of a uint256 zero though, the input is:</p>

<ul>
<li>version (4 bytes)</li>
<li>previous block's hash (32 bytes)</li>
<li>merkle root (32 bytes)</li>
<li>time (4 bytes)</li>
<li>bits (related to difficulty) (4 bytes)</li>
<li>nonce (4 bytes)</li>
</ul>

<p>That's a total of 80 bytes, which is padded to 128 bytes by FormatHashBlocks().</p>

<p>Example:</p>

<pre><code>00000001 (version)
0863bcb701d52fea 0e0c7b0d4696d7e7 8feb125a84e0911b 0000043e00000000 (prev hash)
bc656fe91e44907c 32d1704f900bd7a6 c2fa06386174477f a8b145addebc8d00 (merkle root)
4f35dde3 (time)
1a0c290b (bits)
00000000 (nonce)
0000008000000000 0000000000000000 0000000000000000 } (padding)
0000000000000000 0000000000000000 0000000080020000 } (80 bytes = 640 bits = 0x280)
</code></pre>

CC BY-SA 3.0
2012-02-11T03:23:20.757Z
So it's always 00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000 ? Interesting...
ThePiachu
CC BY-SA 3.0
2012-02-11T04:22:18.857Z
Yes.  Right.  That's it.
Chris Moore
CC BY-SA 3.0
2012-02-11T02:43:17.920Z
2012-02-11T19:30:25.273Z
2012-02-11T19:30:25.273Z
Chris Moore
<p>(I know the hash1 and midstate are eventually going to be deprecated, but I'm a little curious about them)</p>

<p>In Getwork there is a field hash1. From a sample call to bitcoind I received its value as:</p>

<pre><code>'hash1': '00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000'
</code></pre>

<p>How exactly is hash1's value calculated?</p>

CC BY-SA 3.0
2015-06-11T06:12:23.180Z
Why are they "eventually going to be deprecated"?
Geremia
CC BY-SA 3.0
2015-06-11T18:05:11.160Z
@Geremia since the information is redundant really - you can calculate that yourself.
ThePiachu
<protocol><hash><getwork>
In Getwork, how does one calculate the value of Hash1?
ThePiachu
# In Getwork, how does one calculate the value of Hash1?

(Asked by: username_0 on 2012-02-11)

(I know the hash1 and midstate are eventually going to be deprecated, but I'm a little curious about them)
In Getwork there is a field hash1. From a sample call to bitcoind I received its value as:
'hash1': '00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000'

How exactly is hash1's value calculated?

**Tags:** protocol, hash, getwork

> **Comments:**
> **username_1**: Why are they "eventually going to be deprecated"?  
> **username_0**: @username_1 since the information is redundant really - you can calculate that yourself.  

---

## 1 answers

### Answer by username_2 on 2012-02-11. Score: 6 | Accepted answer

hash1 is a uint256 zero, padded to a multiple of 64 bytes by FormatHashBlocks() in main.cpp, and then reversed in 4 byte chunks.
FormatHashBlocks() puts a 0x80 right after the 32 zero bytes, and a 4 byte bit count at the end (00 00 01 00, meaning 256 bits).
the uint256 zero is:
0000000000000000 0000000000000000 0000000000000000 0000000000000000

it's padded to 64 bytes:
0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000
                                                                    ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
has the 80 in the first byte of padding:
0000000000000000 0000000000000000 0000000000000000 0000000000000000 8000000000000000 0000000000000000 0000000000000000 0000000000000000
                                                                    ^^
and the length at the end:
0000000000000000 0000000000000000 0000000000000000 0000000000000000 8000000000000000 0000000000000000 0000000000000000 0000000000000100
                                                                                                                               ^^^^^^^^
and then has each group of 4 bytes reversed: 12 34 56 78 -> 78 56 34 12
0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000008000000000 0000000000000000 0000000000000000 0000000000010000
                                                                    ^^^^^^^^                                                   ^^^^^^^^

A better question might be "why is hash1's value calculated like this"?
You didn't ask, but the data field returned by getwork is formatted the same way.  Instead of a uint256 zero though, the input is:

version (4 bytes)
previous block's hash (32 bytes)
merkle root (32 bytes)
time (4 bytes)
bits (related to difficulty) (4 bytes)
nonce (4 bytes)

That's a total of 80 bytes, which is padded to 128 bytes by FormatHashBlocks().
Example:
00000001 (version)
0863bcb701d52fea 0e0c7b0d4696d7e7 8feb125a84e0911b 0000043e00000000 (prev hash)
bc656fe91e44907c 32d1704f900bd7a6 c2fa06386174477f a8b145addebc8d00 (merkle root)
4f35dde3 (time)
1a0c290b (bits)
00000000 (nonce)
0000008000000000 0000000000000000 0000000000000000 } (padding)
0000000000000000 0000000000000000 0000000080020000 } (80 bytes = 640 bits = 0x280)

> **Comments:**
> **username_0**: So it's always 00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000 ? Interesting...  
> **username_2**: Yes.  Right.  That's it.  

---

