Bitcoin Forum
May 28, 2024, 03:06:41 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Why sha256(sha256()) ?  (Read 1056 times)
Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
November 21, 2015, 08:13:57 PM
 #1

In Bitcoin Developer Reference https://bitcoin.org/en/developer-reference is in many places sha256(sha256()) instead sha256(), it has any meaning?
virtualx
Hero Member
*****
Offline Offline

Activity: 672
Merit: 507


LOTEO


View Profile
November 21, 2015, 08:27:25 PM
 #2

In Bitcoin Developer Reference https://bitcoin.org/en/developer-reference is in many places sha256(sha256()) instead sha256(), it has any meaning?

Yes sha256 is a hashing function used in the protocol. A hashing function is 'easy' to compute one way but difficult to compute the other way. Other hashing functions are SHA1 and MD5. MD5 is partly broken, lots of collisions.

From satoshi:
Quote
SHA-256 is very strong.  It's not like the incremental step from MD5 to SHA1.  It can last several decades unless there's some massive breakthrough attack.

If SHA-256 became completely broken, I think we could come to some agreement about what the honest block chain was before the trouble started, lock that in and continue from there with a new hash function.

If the hash breakdown came gradually, we could transition to a new hash in an orderly way.  The software would be programmed to start using a new hash after a certain block number.  Everyone would have to upgrade by that time.  The software could save the new hash of all the old blocks to make sure a different block with the same old hash can't be used.


...loteo...
DIGITAL ERA LOTTERY


r

▄▄███████████▄▄
▄███████████████████▄
▄███████████████████████▄
▄██████████████████████████▄
▄██  ███████▌ ▐██████████████▄
▐██▌ ▐█▀  ▀█    ▐█▀   ▀██▀  ▀██▌
▐██  █▌ █▌ ██  ██▌ ██▌ █▌ █▌ ██▌
▐█▌ ▐█ ▐█ ▐█▌ ▐██  ▄▄▄██ ▐█ ▐██▌
▐█  ██▄  ▄██    █▄    ██▄  ▄███▌
▀████████████████████████████▀
▀██████████████████████████▀
▀███████████████████████▀
▀███████████████████▀
▀▀███████████▀▀
r

RPLAY NOWR
BE A MOON VISITOR!
[/center]
cr1776
Legendary
*
Offline Offline

Activity: 4046
Merit: 1303


View Profile
November 21, 2015, 09:06:56 PM
Merited by ABCbits (2)
 #3

I think he was asking why double hashing vs just a single sha256.

If so, it was to help prevent length-extension attacks:

see e.g.
http://crypto.stackexchange.com/a/884
DiamondCardz
Legendary
*
Offline Offline

Activity: 1134
Merit: 1112



View Profile WWW
November 21, 2015, 09:12:57 PM
 #4

In Bitcoin Developer Reference https://bitcoin.org/en/developer-reference is in many places sha256(sha256()) instead sha256(), it has any meaning?

Yes sha256 is a hashing function used in the protocol. A hashing function is 'easy' to compute one way but difficult to compute the other way. Other hashing functions are SHA1 and MD5. MD5 is partly broken, lots of collisions.

I don't think you actually read the OP properly. Unsure if that's due to your signature or just due to inattentiveness. His question does not ask why hashing is used, I'm fairly sure he knows why it is used and he did refer to "instead of sha256()". He's referring to double hashing.

BA Computer Science, University of Oxford
Dissertation was about threat modelling on distributed ledgers.
Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
November 22, 2015, 07:27:52 AM
 #5

Twice Sha256 is to prevent length-extension attacks. If in theory, instead SHA-2 would be SHA-3, not need twice SHA?
moneyart
Newbie
*
Offline Offline

Activity: 26
Merit: 0


View Profile
November 22, 2015, 04:15:56 PM
 #6

1. priv/pub key
2. SHA-256
3. RIPEMD-160
4. Add version byte 0
5. SHA-256
6. SHA-256
7. Take 4 bytes
8. Add 4 bytes to result of 4
9. Convert to base 58

The double SHA-256 is only for the 4 check bytes. Why is this important for security reasons?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3402
Merit: 6659


Just writing some code


View Profile WWW
November 22, 2015, 04:25:05 PM
 #7

1. priv/pub key
2. SHA-256
3. RIPEMD-160
4. Add version byte 0
5. SHA-256
6. SHA-256
7. Take 4 bytes
8. Add 4 bytes to result of 4
9. Convert to base 58

The double SHA-256 is only for the 4 check bytes. Why is this important for security reasons?
It is used for mining. The mining algorithm is sha256d

moneyart
Newbie
*
Offline Offline

Activity: 26
Merit: 0


View Profile
November 22, 2015, 04:30:50 PM
 #8

You also double SHA 256 when you build up the merkle tree.
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!