Bitcoin Forum
May 06, 2024, 06:11:14 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Explain SHA 256 Algorithm  (Read 385 times)
Srujan007 (OP)
Jr. Member
*
Offline Offline

Activity: 99
Merit: 1


View Profile
August 03, 2018, 02:27:13 PM
 #1

Hi all,

Can someone explain me SHA 256 step by step mathematical operation taking an example,i want to know each step from conversion of word to ASCII code and binary code ,later right shift and all those stuffs till i get a hash.

And i have another question why bitcoin uses double SHA256,and how does double SHA 256 compared to normal SHA256 exactly work?

I want to be a blockchain developer so i need to learn all these from scratch.

Thank you
1715019074
Hero Member
*
Offline Offline

Posts: 1715019074

View Profile Personal Message (Offline)

Ignore
1715019074
Reply with quote  #2

1715019074
Report to moderator
1715019074
Hero Member
*
Offline Offline

Posts: 1715019074

View Profile Personal Message (Offline)

Ignore
1715019074
Reply with quote  #2

1715019074
Report to moderator
1715019074
Hero Member
*
Offline Offline

Posts: 1715019074

View Profile Personal Message (Offline)

Ignore
1715019074
Reply with quote  #2

1715019074
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
TheArchaeologist
Sr. Member
****
Offline Offline

Activity: 310
Merit: 727


---------> 1231006505


View Profile WWW
August 03, 2018, 03:41:56 PM
Merited by achow101 (3), Welsh (3), DdmrDdmr (2), ABCbits (1)
 #2

If you are looking for detailed information on the SHA-256 algorithm I suggest you read the document on Secure Hash Standard (SHS) here:
https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf

That's a 36 page PDF so a bit too long to reproduce here.

Regarding your question on double SHA-256 and how it works compared to SHA-256 itself. Double SHA-256 means you hash the value of an input using SHA-256 and you use the result from that as input for another round of SHA-256. So it's basically SHA-256(SHA-256(Message)). It's also stated in the protocol documentation:
https://en.bitcoin.it/wiki/Protocol_documentation#Hashes



Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
butka
Full Member
***
Offline Offline

Activity: 434
Merit: 246


View Profile
August 03, 2018, 04:03:47 PM
 #3

And i have another question why bitcoin uses double SHA256,and how does double SHA 256 compared to normal SHA256 exactly work?
This is an old dilemma as to why exactly Satoshi used double SHA256. It has likely to do with preventing possible length extension attacks:

https://crypto.stackexchange.com/questions/779/hashing-or-encrypting-twice-to-increase-security/884#884

Also check out this BCT thread devoted to this subject:

https://bitcointalk.org/index.php?topic=45456.0
odolvlobo
Legendary
*
Offline Offline

Activity: 4298
Merit: 3214



View Profile
August 03, 2018, 10:09:43 PM
Merited by ABCbits (1)
 #4

Hi all,

Can someone explain me SHA 256 step by step mathematical operation taking an example,i want to know each step from conversion of word to ASCII code and binary code ,later right shift and all those stuffs till i get a hash.

And i have another question why bitcoin uses double SHA256,and how does double SHA 256 compared to normal SHA256 exactly work?

I want to be a blockchain developer so i need to learn all these from scratch.

Thank you

I think this is what you are looking for: Mining Bitcoin with Pencil and Paper

This video is fun to watch too: https://www.youtube.com/watch?v=y3dqhixzGVo

The double hash is simply a hash of a hash of the data. It provides extra security in certain cases.

You don't need to know the details of the SHA-256 algorithm in order to use it. In fact, it is probably better that you not know it because if you know it, you might be tempted to implement it and make a mistake.

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
Srujan007 (OP)
Jr. Member
*
Offline Offline

Activity: 99
Merit: 1


View Profile
August 04, 2018, 05:40:54 AM
 #5

Hi all,

Can someone explain me SHA 256 step by step mathematical operation taking an example,i want to know each step from conversion of word to ASCII code and binary code ,later right shift and all those stuffs till i get a hash.

And i have another question why bitcoin uses double SHA256,and how does double SHA 256 compared to normal SHA256 exactly work?

I want to be a blockchain developer so i need to learn all these from scratch.

Thank you

I think this is what you are looking for: Mining Bitcoin with Pencil and Paper

This video is fun to watch too: https://www.youtube.com/watch?v=y3dqhixzGVo

The double hash is simply a hash of a hash of the data. It provides extra security in certain cases.

You don't need to know the details of the SHA-256 algorithm in order to use it. In fact, it is probably better that you not know it because if you know it, you might be tempted to implement it and make a mistake.


Thanks for providing the information,it was really fun but my brain got over clocked in the middle haha btw Mining Bitcoin with pencil and paper is it still profitable in 2018 ? Haha Cheesy Cheesy
Srujan007 (OP)
Jr. Member
*
Offline Offline

Activity: 99
Merit: 1


View Profile
August 04, 2018, 05:42:19 AM
 #6

If you are looking for detailed information on the SHA-256 algorithm I suggest you read the document on Secure Hash Standard (SHS) here:
https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf

That's a 36 page PDF so a bit too long to reproduce here.

Regarding your question on double SHA-256 and how it works compared to SHA-256 itself. Double SHA-256 means you hash the value of an input using SHA-256 and you use the result from that as input for another round of SHA-256. So it's basically SHA-256(SHA-256(Message)). It's also stated in the protocol documentation:
https://en.bitcoin.it/wiki/Protocol_documentation#Hashes




Hey thank you for providing pdf link, looks like i have to study more about it. Smiley
Srujan007 (OP)
Jr. Member
*
Offline Offline

Activity: 99
Merit: 1


View Profile
August 04, 2018, 05:45:29 AM
 #7

And i have another question why bitcoin uses double SHA256,and how does double SHA 256 compared to normal SHA256 exactly work?
This is an old dilemma as to why exactly Satoshi used double SHA256. It has likely to do with preventing possible length extension attacks:

https://crypto.stackexchange.com/questions/779/hashing-or-encrypting-twice-to-increase-security/884#884

Also check out this BCT thread devoted to this subject:

https://bitcointalk.org/index.php?topic=45456.0

So is it impossible to hack double SHA 256 ? because Sha 1 was tamper proof too until someone proved they were wrong.How many years can we expect double SHA256 will be reliable ?.And thanks for providing the link of thread let me have a look at it.
amaclin1
Sr. Member
****
Offline Offline

Activity: 770
Merit: 305


View Profile
August 04, 2018, 05:54:39 AM
 #8

So is it impossible to hack double SHA 256 ?
Nobody knows.
At least most of people in the world do not know a way to do it.
And we do not know any person who knows the hacking algorithm.

Bitcoin SV GUI client for Windows and Linux
https://github.com/AlisterMaclin/bitcoin-sv/releases
TheArchaeologist
Sr. Member
****
Offline Offline

Activity: 310
Merit: 727


---------> 1231006505


View Profile WWW
August 04, 2018, 06:56:18 AM
 #9

You don't need to know the details of the SHA-256 algorithm in order to use it. In fact, it is probably better that you not know it because if you know it, you might be tempted to implement it and make a mistake.
I couldn't agree more! I can understand you want to read up on hashing algorithms but you should never try to come up with your one solution. Instead, use a proven implementation (for example from a library) and treat it like a blackbox: you put something in and you will always get a 256 bit return.

Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
butka
Full Member
***
Offline Offline

Activity: 434
Merit: 246


View Profile
August 04, 2018, 07:01:43 AM
 #10

And i have another question why bitcoin uses double SHA256,and how does double SHA 256 compared to normal SHA256 exactly work?
This is an old dilemma as to why exactly Satoshi used double SHA256. It has likely to do with preventing possible length extension attacks:

https://crypto.stackexchange.com/questions/779/hashing-or-encrypting-twice-to-increase-security/884#884

Also check out this BCT thread devoted to this subject:

https://bitcointalk.org/index.php?topic=45456.0

So is it impossible to hack double SHA 256 ? because Sha 1 was tamper proof too until someone proved they were wrong.How many years can we expect double SHA256 will be reliable ?.And thanks for providing the link of thread let me have a look at it.
It has nothing to do with hacking SHA-256 (probably by hacking in your post you mean brute force attack ). The kind of attack that this double hash prevents is called length extension attack and it is something different from brute force attack. You can read more about the way this attack is done, for example, here.
Srujan007 (OP)
Jr. Member
*
Offline Offline

Activity: 99
Merit: 1


View Profile
August 04, 2018, 04:41:21 PM
 #11

You don't need to know the details of the SHA-256 algorithm in order to use it. In fact, it is probably better that you not know it because if you know it, you might be tempted to implement it and make a mistake.
I couldn't agree more! I can understand you want to read up on hashing algorithms but you should never try to come up with your one solution. Instead, use a proven implementation (for example from a library) and treat it like a blackbox: you put something in and you will always get a 256 bit return.

Ok i got that,so you mean don't worry about XOR gates or anything which is used ,consider it as some function which gives you a output,am i right?
Srujan007 (OP)
Jr. Member
*
Offline Offline

Activity: 99
Merit: 1


View Profile
August 05, 2018, 06:36:55 AM
 #12

And i have another question why bitcoin uses double SHA256,and how does double SHA 256 compared to normal SHA256 exactly work?
This is an old dilemma as to why exactly Satoshi used double SHA256. It has likely to do with preventing possible length extension attacks:

https://crypto.stackexchange.com/questions/779/hashing-or-encrypting-twice-to-increase-security/884#884

Also check out this BCT thread devoted to this subject:

https://bitcointalk.org/index.php?topic=45456.0

So is it impossible to hack double SHA 256 ? because Sha 1 was tamper proof too until someone proved they were wrong.How many years can we expect double SHA256 will be reliable ?.And thanks for providing the link of thread let me have a look at it.
It has nothing to do with hacking SHA-256 (probably by hacking in your post you mean brute force attack ). The kind of attack that this double hash prevents is called length extension attack and it is something different from brute force attack. You can read more about the way this attack is done, for example, here.

i got to read it then as i knew only about brute force attack.
TheArchaeologist
Sr. Member
****
Offline Offline

Activity: 310
Merit: 727


---------> 1231006505


View Profile WWW
August 06, 2018, 07:17:41 AM
 #13

Ok i got that,so you mean don't worry about XOR gates or anything which is used ,consider it as some function which gives you a output,am i right?

Exactly, you don't need to know exactly how it works under the hood to use it!

Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
bittab
Member
**
Offline Offline

Activity: 206
Merit: 11


View Profile WWW
August 08, 2018, 01:22:04 PM
 #14

It is easy for Mac users to generate SHA-256 checksum.

Via Terminal, "shasum -a 256 anyfilename.abc"
Srujan007 (OP)
Jr. Member
*
Offline Offline

Activity: 99
Merit: 1


View Profile
August 12, 2018, 09:31:10 AM
 #15

Thank you so much it worked.
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!