Bitcoin Forum
May 29, 2024, 02:53:42 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Mining process - SHA256 - Probability  (Read 171 times)
radjan (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
August 19, 2020, 08:38:01 AM
 #1



I would like to get your opinion on the following reasoning to define the number of tries needed to find the solution to a PoW problem at 95%.

    Consider a function SHA(256), the probability that this function contains just one zero is (1/16). Since the latter must be at the hash goal, the probability that it is at the very beginning is 1/64.
    In conclusion the probability that function SHA(256) returns a hash containing a zero at the very beginning is (1/64*16)=1/1024
    If the PoW difficulty requires C zero consequential the probability becomes (1/1024)^c

Do you think it is correct ?

Thanks in advance
pooya87
Legendary
*
Offline Offline

Activity: 3458
Merit: 10604



View Profile
August 20, 2020, 04:53:06 AM
Last edit: September 06, 2020, 06:12:35 AM by pooya87
 #2

Proof of Work and its difficulty don't work based on number of zeros. instead it is defined as integers and a value comparison. we have a "target" value that we need the hash result to be smaller than or equal to and the probability of that happening is a simple matter of computing how probable it is to find a number below that target.
since this target is smaller than 2256 and goes down as difficulty grows and also since we show hashes as full 256-bit results you end up seeing zeros as padding to make it 256-bit.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
odolvlobo
Legendary
*
Offline Offline

Activity: 4326
Merit: 3247



View Profile
August 20, 2020, 01:24:28 PM
 #3

Your post is not clear, but I think this is what you  are looking for:

The probability of N chosen bits all being 0 is 2-N.
The probability of N chosen hexadecimal digits all being 0 is 16-N.

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
dansus021
Copper Member
Hero Member
*****
Offline Offline

Activity: 2016
Merit: 937


Part of AOBT - English Translator to Indonesia


View Profile WWW
August 21, 2020, 11:37:00 AM
 #4

i think you can ask on Mining Section

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits.
..........UNLEASH..........
THE ULTIMATE
GAMING EXPERIENCE
DUELBITS
FANTASY
SPORTS
████▄▄█████▄▄
░▄████
███████████▄
▐███
███████████████▄
███
████████████████
███
████████████████▌
███
██████████████████
████████████████▀▀▀
███████████████▌
███████████████▌
████████████████
████████████████
████████████████
████▀▀███████▀▀
.
▬▬
VS
▬▬
████▄▄▄█████▄▄▄
░▄████████████████▄
▐██████████████████▄
████████████████████
████████████████████▌
█████████████████████
███████████████████
███████████████▌
███████████████▌
████████████████
████████████████
████████████████
████▀▀███████▀▀
/// PLAY FOR  FREE  ///
WIN FOR REAL
..PLAY NOW..
webtricks
Legendary
*
Offline Offline

Activity: 1918
Merit: 1728


View Profile
August 21, 2020, 06:35:48 PM
 #5



I would like to get your opinion on the following reasoning to define the number of tries needed to find the solution to a PoW problem at 95%.

    Consider a function SHA(256), the probability that this function contains just one zero is (1/16). Since the latter must be at the hash goal, the probability that it is at the very beginning is 1/64.
    In conclusion the probability that function SHA(256) returns a hash containing a zero at the very beginning is (1/64*16)=1/1024
    If the PoW difficulty requires C zero consequential the probability becomes (1/1024)^c

Do you think it is correct ?

Nope! Your assumption about Block Hash is wrong. Let me give you a detailed view on how it is really calculated:

Your current assumption is this (correct me if I am wrong): In order to block the mine, miner needs to find a hash having 'n' number of preceding zeros. Since the probability of finding a hash starting with '0' is 1 in 1024, the probability to find a block having 'n' preceding zeroes is 1 in (1/1024)n, right?

However, this is not how block hash is found by the miners. Finding block hash is nothing but finding a value which is less than the target value. Target value is adjusted after every 2,016 blocks. Current difficulty is:

0x000000000000000000109bac0000000000000000000000000000000000000000 (hexadecimal form)
or
1590739304116800001454600275103718494518067345886281728 (decimal/integer number)



Now in order to find the block hash, you need to find an integer value less than the above number. But this is not very simple because you need to include 6 values in your computation:
> Version
> Hash of previous block
> Merkle Root
> Time of mining
> Bits (difficulty/current target in compact form)
> Nonce (an incrementing number)

Now let's take an example, say Block: 644,731



For block 644,731, we have:
Version = 20400000 (hexadecimal)
Hash of Previous Block = 000000000000000000083d157a8a2a589a74fc2f7b91245cb3a415c23d7cc79a
Merkle Root = 9453cfc708a1cc84f3f36c2bae68202b03ad2866bb02da511d7e603a4e9d1fd1
Time = 16:42:15 as per GMT
Bits = 386,964,396 (decimal)
Nonce = 2035916310 (decimal)



Converting everything in hexadecimal form (little-endian), we will have following value,
(version+previousHash+merkleRoot+Time+Bits+Nonce):

0x000040209ac77c3dc215a4b35c24917b2ffc749a582a8a7a153d08000000000000000000d11f9 d4e3a607e1d51da02bb6628ad032b2068ae2b6cf3f384cca108c7cf539467f93f5fac9b1017169e 5979



The final step involves performing SHA-256 hashing twice on the above value and the result will be:
811802676f41d6aff67ad767517c466c4c8d3b87c81009000000000000000000



Converting it in little-endian, we have:
0000000000000000000910c8873b8d4c6c467c5167d77af6afd6416f67021881 which will become block hash of the block.



Now you can compare,
Target Value = 0x000000000000000000109bac0000000000000000000000000000000000000000 or 1590739304116800001454600275103718494518067345886281728

Block Hash (644,731) = 0000000000000000000910c8873b8d4c6c467c5167d77af6afd6416f67021881 or 868308124812842907393685749016650546999869456114653313



Since 868308124812842907393685749016650546999869456114653313 is smaller than 1590739304116800001454600275103718494518067345886281728, it is accepted block hash.

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!