cpuminer icon indicating copy to clipboard operation
cpuminer copied to clipboard

How can we be certain that the hashing is correct?

Open IvanVnucec opened this issue 4 years ago • 9 comments

The problem is that we are mining cryptos rather slowly compared to the ASICs machines. Because of that, how can we be assured that the hashing algorithms works correctly other than watching our wallet getting money (which could take a while).

IvanVnucec avatar Aug 25 '21 11:08 IvanVnucec

All the algorithm implementations in cpuminer have been tested.

If one has the time, it would also be quite easy to write a simple getwork server that serves mock low-difficulty jobs and checks that submitted solutions meet the target.

pooler avatar Aug 25 '21 11:08 pooler

How did you test the algorithm implementations?

IvanVnucec avatar Aug 25 '21 12:08 IvanVnucec

The implementations were tested both manually (using known block headers) and by mining. Keep in mind that this was quite a few years ago, when CPU mining was still practically possible.

pooler avatar Aug 25 '21 12:08 pooler

Could you provide me with some known block headers and their correct hashes? I'm willing to make test cases because I did a few code changes, and now I'm in dilemma if the code (still) works or not.

Also, do you have some documentation regarding algorithm implementation, specifically sha256? I'm finding it hard to track current code with the strange function names and lack of comments.

IvanVnucec avatar Aug 25 '21 12:08 IvanVnucec

Could you provide me with some known block headers and their correct hashes?

You should use a block explorer or a coin daemon to fetch this kind of data.

Also, do you have some documentation regarding algorithm implementation, specifically sha256? I'm finding it hard to track current code with the strange function names and lack of comments.

Sorry, I never wrote any documentation about the implementation details.

pooler avatar Aug 25 '21 12:08 pooler

Sorry, I never wrote any documentation about the implementation details.

Do you have documentation from which you've written those hashing functions?

IvanVnucec avatar Aug 25 '21 13:08 IvanVnucec

For SHA-256 there is plenty of documentation available online. When I first started I think I simply used ArtForz's code (see sha256_transform()) as a base, and went from there.

pooler avatar Aug 25 '21 13:08 pooler

Ok thanks.

IvanVnucec avatar Aug 25 '21 13:08 IvanVnucec

I'm going to reopen it because someone might want to write a solution to the problem of validating the hashing algorithm.

IvanVnucec avatar Aug 26 '21 05:08 IvanVnucec