0

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.

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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