Bitcoin Forum
May 23, 2024, 07:58:02 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Testing my own hashing code  (Read 176 times)
Michael Rolle (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
May 22, 2019, 02:20:13 AM
 #1

I'm writing my own software to do the double SHA-256 hashing on my Windows 10 system.
I want to test it on real data, i.e., testnet.

My code can be called from C++, Python, or run as an executable from a command line.
It will take a message header as an input, and try to find a hash that satisfies the level of difficulty.

I expect that my code will be invoked with many such headers before it succeeds, even on testnet.  If I understand it correctly, the nodes on the network each receive different versions of the current block (with the extra nonce varying).

So I'm looking for a program that will get current data from the network, feed the message header to my program, try again if not successful, and post the success when successful.  I'd like to see that eventually, I will have successfully mined something.

Alternatively, I'd like to access an older block on the network to see if I can duplicate the successful hashing of that block, using the version of the message that was actually solved by the miner.  That way, I know that my program should succeed.

Can I get access to test cases which have a known result?

Is there a way I can estimate how many hashing attempt it would take, on average, to solve a hashing problem?  I know this will vary over time because of the adjustments to the level of difficulty, but I'd be interested in a ball-park answer for the testnet.  If the answer is in days (given the hashing speed of my software), then I might want to abandon attempts to successfully mine with live data and try some other approach.
Jean_Luc
Sr. Member
****
Offline Offline

Activity: 462
Merit: 696


View Profile
May 22, 2019, 08:24:44 AM
 #2

Is there a way I can estimate how many hashing attempt it would take, on average, to solve a hashing problem?

A hash function can be seen as a pseudo number generator. In the case of a 256 bit hash, the hash will produce a random number uniformly distributed in the range [0,2^256-1].
So depending on the minimum hash value you want you can compute the actual difficulty (from the number of acceptable hash) and deduce the probabilty to find a match after n tries using Bernouilli.  1-(1-number of acceptable hash/2^256)^n

The BTC difficulty (displayed on www.blockchain.com) is computed as (actual difficulty/2^32).
DaCryptoRaccoon
Hero Member
*****
Offline Offline

Activity: 1214
Merit: 591


OGRaccoon


View Profile
May 22, 2019, 11:08:06 AM
 #3

I'm writing my own software to do the double SHA-256 hashing on my Windows 10 system.
I want to test it on real data, i.e., testnet.

My code can be called from C++, Python, or run as an executable from a command line.
It will take a message header as an input, and try to find a hash that satisfies the level of difficulty.

I expect that my code will be invoked with many such headers before it succeeds, even on testnet.  If I understand it correctly, the nodes on the network each receive different versions of the current block (with the extra nonce varying).

So I'm looking for a program that will get current data from the network, feed the message header to my program, try again if not successful, and post the success when successful.  I'd like to see that eventually, I will have successfully mined something.

Alternatively, I'd like to access an older block on the network to see if I can duplicate the successful hashing of that block, using the version of the message that was actually solved by the miner.  That way, I know that my program should succeed.

Can I get access to test cases which have a known result?

Is there a way I can estimate how many hashing attempt it would take, on average, to solve a hashing problem?  I know this will vary over time because of the adjustments to the level of difficulty, but I'd be interested in a ball-park answer for the testnet.  If the answer is in days (given the hashing speed of my software), then I might want to abandon attempts to successfully mine with live data and try some other approach.

Here are the first 50 nonce values for bitcoin.
There is no way to know exactly how long hashing would take it's all down to the numbers.

Code:
1639830024
2573394689
1844305925
2850094635
2011431709
2538380312
2258412857
1716931356
1397702696
1709518110
4161222679
208296255
2259603767
615369513
2566641720
3591544324
2474926087
4064360242
766824726
1901123894
3592540203
1645155368
1437882917
2969614887
837891875
1555516980
3012316214
2396281646
2688142130
3893691144
716922133
230744328
1076005922
616579874
3890072084
797229870
2244623873
3941073664
1610743848
1902584070
3522947079
3600650283
2093702200
429798192
2771238433
1626117377
2957174816
3759171867
3014810412
1028409902

┏━━━━━━━━━━━━━━━━━┓
┃   💎 Mine Solo with CKPool 💎    ┃
┃    ➤ Hit Blocks on Your Own!      ┃
┃ ███▓▓  ███▓▓  ███▓▓  ███▓▓┃
Michael Rolle (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
May 25, 2019, 09:05:59 PM
 #4

A program like Bitcoin Core assumes there's an external rig somewhere, and so there must be some sort of communications protocol, by which the app (Bitcoin Core) sends blocks and receives hash results.
I haven't been able to find any reference online about any protocols for this, but I'm sure there must be a standard that the rig manufacturers follow.

Can someone please point me to this standard.

This way, I can write some software that will follow this standard and then employ my own hashing code.
odolvlobo
Legendary
*
Offline Offline

Activity: 4326
Merit: 3235



View Profile
May 25, 2019, 11:14:10 PM
 #5

A program like Bitcoin Core assumes there's an external rig somewhere, and so there must be some sort of communications protocol, by which the app (Bitcoin Core) sends blocks and receives hash results.
I haven't been able to find any reference online about any protocols for this, but I'm sure there must be a standard that the rig manufacturers follow.

I don't understand what you wrote. I think your understanding and assumptions may be off.

Here is the code in Bitcoin Core that computes a SHA-256 hash: https://github.com/bitcoin/bitcoin/blob/master/src/crypto/sha256.cpp

Here is the SHA-256 standard:
https://csrc.nist.gov/publications/detail/fips/180/4/final

Here is some documentation on the Bitcoin message protocol:
https://en.bitcoin.it/wiki/Protocol_documentation

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
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!