Bitcoin Forum
May 11, 2024, 09:43:42 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Why do we need double hashing in a Merkle tree?  (Read 813 times)
fevirfevir (OP)
Newbie
*
Offline Offline

Activity: 17
Merit: 6


View Profile
August 13, 2015, 11:32:33 AM
 #1

Hi,

In Bitcoin, the Merkle tree created from all transactions contains nodes that represent a double hash of each transaction: N = SHA256(SHA256(tx0)

What's the point of doing so? Can't we just do a N =  SHA256(tx0)?

Thanks.
1715463822
Hero Member
*
Offline Offline

Posts: 1715463822

View Profile Personal Message (Offline)

Ignore
1715463822
Reply with quote  #2

1715463822
Report to moderator
1715463822
Hero Member
*
Offline Offline

Posts: 1715463822

View Profile Personal Message (Offline)

Ignore
1715463822
Reply with quote  #2

1715463822
Report to moderator
1715463822
Hero Member
*
Offline Offline

Posts: 1715463822

View Profile Personal Message (Offline)

Ignore
1715463822
Reply with quote  #2

1715463822
Report to moderator
The block chain is the main innovation of Bitcoin. It is the first distributed timestamping system.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715463822
Hero Member
*
Offline Offline

Posts: 1715463822

View Profile Personal Message (Offline)

Ignore
1715463822
Reply with quote  #2

1715463822
Report to moderator
Kazimir
Legendary
*
Offline Offline

Activity: 1176
Merit: 1003



View Profile
August 13, 2015, 11:36:09 AM
 #2

Any hash would do, and Sha256(Sha256(x)) can also be considered "just a hash".

I assume Satoshi chose this double Sha256 (also called "Sha256d") just in case a future possible vulnerability is discovered with Sha256. It would give us more time to switch to something else (like Sha3).

In theory, there's no difference between theory and practice. In practice, there is.
Insert coin(s): 1KazimirL9MNcnFnoosGrEkmMsbYLxPPob
fevirfevir (OP)
Newbie
*
Offline Offline

Activity: 17
Merit: 6


View Profile
August 13, 2015, 11:49:02 AM
 #3

Thanks for your answer. I was thinking along the same lines, that it's somewhat of a security measure.

But if there would be a flaw in SHA256, wouldn't that impact both SHA256d hashed transactions, pretty much the same as SHA256 hashed transactions? It would of course depend on the flaw found, but reasoning that Satoshi choose this as a security measure, we're talking delay here.

Just wondering if the choice for SHA256d is a functional decision, like speed improvement.
Kazimir
Legendary
*
Offline Offline

Activity: 1176
Merit: 1003



View Profile
August 13, 2015, 12:41:50 PM
 #4

Not every kind of Sha256 vulnerability would also apply on Sha256d. So I guess it's for security.

Still, I would rather have seen something like Sha256(x+Sha256(x)) instead of just Sha256(Sha256(x)). But either way, it's fine.

In theory, there's no difference between theory and practice. In practice, there is.
Insert coin(s): 1KazimirL9MNcnFnoosGrEkmMsbYLxPPob
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!