<blockquote>
<p>How is it possible that bitcoin blocks store transaction data in 32-bit SHA256 strings</p>
</blockquote>
<p>They don't. Bitcoin blocks store the full transaction data in binary. There is no SHA256 involved in its storage. SHA256 also produces 256 bits of output (= 32 bytes), not 32 bits.</p>
<blockquote>
<p>a traditional bitcoin block has performed 2 SHA256 iterations on the raw hex data of a single transaction.</p>
</blockquote>
<p>There are multiple mistakes here.</p>
<p>A block hash is computed by double-SHA256'ing the block header, in binary (not hex). That block header contains a number of fields, including a version number, the hash of the previous blocks, a timestamp, a nonce, the difficulty, and a hash of the transactions in it.</p>
<p>That hash of the transaction data, also called the Merkle root, is computed as follows:</p>
<ul>
<li>Start with a list of the transaction hashes of all the transactions in the block, in order. Each hash is the binary result of applying double-SHA256 on the raw binary transaction data (not hex).</li>
<li>As long as this list contains more than one element:
<ul>
<li>If the list has an odd number of elements, duplicate the last element.</li>
<li>Replace the list with the list of obtained by double-SHA256 hashing the concatenation of two consecutive elements. This halves the length of the list.</li>
</ul>
</li>
<li>The Merkle root is the single remaining element in the list (if the block had only one transaction, the Merkle root is equal to the hash of the transaction directly).</li>
</ul>
<blockquote>
<p>Then it is stored in the block.</p>
</blockquote>
<p>No, the block just stores the full transaction data, unhashed. The hashes are only used to compute the block header, which indirectly contributes to the block's hash.</p>

CC BY-SA 4.0
2022-05-07T14:13:03.710Z
2022-05-07T14:13:03.710Z
Pieter Wuille
<p>What I mean is that a traditional Bitcoin block has performed 2 SHA256 iterations on the raw hex data of a single transaction. Then it is stored in the block. But since it has been SHA256'd, how can we know what that transaction was. Or am I completely wrong, that is, transactions are supposedly not SHA'd.</p>

<transaction-id>
How is it possible that Bitcoin blocks store transaction data in 32-bit SHA256 strings?
Jamo
# How is it possible that Bitcoin blocks store transaction data in 32-bit SHA256 strings?

(Asked by: username_0 on 2022-05-07)

What I mean is that a traditional Bitcoin block has performed 2 SHA256 iterations on the raw hex data of a single transaction. Then it is stored in the block. But since it has been SHA256'd, how can we know what that transaction was. Or am I completely wrong, that is, transactions are supposedly not SHA'd.

**Tags:** transaction-id


---

## 1 answers

### Answer by username_1 on 2022-05-07. Score: 2

> How is it possible that bitcoin blocks store transaction data in 32-bit SHA256 strings

They don't. Bitcoin blocks store the full transaction data in binary. There is no SHA256 involved in its storage. SHA256 also produces 256 bits of output (= 32 bytes), not 32 bits.

> a traditional bitcoin block has performed 2 SHA256 iterations on the raw hex data of a single transaction.

There are multiple mistakes here.

A block hash is computed by double-SHA256'ing the block header, in binary (not hex). That block header contains a number of fields, including a version number, the hash of the previous blocks, a timestamp, a nonce, the difficulty, and a hash of the transactions in it.

That hash of the transaction data, also called the Merkle root, is computed as follows:

* Start with a list of the transaction hashes of all the transactions in the block, in order. Each hash is the binary result of applying double-SHA256 on the raw binary transaction data (not hex).
* As long as this list contains more than one element:
  + If the list has an odd number of elements, duplicate the last element.
  + Replace the list with the list of obtained by double-SHA256 hashing the concatenation of two consecutive elements. This halves the length of the list.
* The Merkle root is the single remaining element in the list (if the block had only one transaction, the Merkle root is equal to the hash of the transaction directly).

> Then it is stored in the block.

No, the block just stores the full transaction data, unhashed. The hashes are only used to compute the block header, which indirectly contributes to the block's hash.


---

