Bitcoin Forum
July 08, 2024, 02:27:59 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Solving Hash Function  (Read 656 times)
JohnFromWIT (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10


View Profile
June 06, 2014, 07:10:42 AM
 #1

Hi, could you quickly run through how the math is done with a hash function.

So for the last block solved, the hash was
000000000000000046e8f67e6af143384d02ef9c3196ab21766f305c45273997
The nonce was
3646718036
And the difficulty is
11,756,551,916.90

Am I right in thinking that you feed the nonce to the hash and if the value returned is lower than the difficulty you win a cuddly toy?
And if so, how is it done, say, on a calculator or on paper?

Thanks

DannyHamilton
Legendary
*
Offline Offline

Activity: 3430
Merit: 4681



View Profile
June 06, 2014, 07:20:10 AM
 #2

Hi, could you quickly run through how the math is done with a hash function.

So for the last block solved, the hash was
000000000000000046e8f67e6af143384d02ef9c3196ab21766f305c45273997
The nonce was
3646718036
And the difficulty is
11,756,551,916.90

Am I right in thinking that you feed the nonce to the hash and if the value returned is lower than the difficulty you win a cuddly toy?

Well, sort of.

Place the nonce into the proper place in the block header (see here for a description of the data fields in the block header: http://james.lab6.com/2012/01/12/bitcoin-285-bytes-that-changed-the-world/ )

Then compute the SHA256 hash of that block header.

Then compute the SHA256 hash of the result of that hash result.

If the result is lower than the difficulty target then you win a cuddly toy.

And if so, how is it done, say, on a calculator or on paper?

Here's some pseudo code explaining the SHA2 process:

http://en.wikipedia.org/wiki/SHA2#Pseudocode
Salmon1989
Hero Member
*****
Offline Offline

Activity: 603
Merit: 500



View Profile
June 06, 2014, 07:31:46 AM
 #3

Am I right in thinking that you feed the nonce to the hash and if the value returned is lower than the difficulty you win a cuddly toy?
And if so, how is it done, say, on a calculator or on paper?

Long answer: Read DH's post above.
Short answer: The hash need to be lower than target value https://blockexplorer.com/q/hextarget, and you won't be able to compute sha256 hash with a hand calculator or with pen and paper correctly.

JohnFromWIT (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10


View Profile
June 06, 2014, 08:01:31 AM
 #4

Thanks for the replies,
It'll take me a while to get through it all, especially the hashing process, but i think i'll get it eventually.
Is the hextarget different to the difficulty factor? How do you find it?

Salmon1989
Hero Member
*****
Offline Offline

Activity: 603
Merit: 500



View Profile
June 06, 2014, 08:05:35 AM
 #5

Is the hextarget different to the difficulty factor? How do you find it?

For the relationship between "target" and "difficulty", please refer to https://en.bitcoin.it/wiki/Difficulty#What_is_the_formula_for_difficulty.3F

JohnFromWIT (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10


View Profile
June 06, 2014, 08:31:40 AM
 #6

Right, ok. Think I got that.
Already starting to see why a calculator wouldn't be much use,
and that's before even getting to the SHA.
Serious learning curve ahead of me.
Thanks for the help.

Salmon1989
Hero Member
*****
Offline Offline

Activity: 603
Merit: 500



View Profile
June 06, 2014, 08:42:38 AM
 #7

Right, ok. Think I got that.
Already starting to see why a calculator wouldn't be much use,
and that's before even getting to the SHA.
Serious learning curve ahead of me.
Thanks for the help.

No problem.
IMO, it is not easy to understand how bitcoin works in details, but it should be a fun experience (at least to me lol). Smiley

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!