Help - Trying to figure out the algorithm

I am trying to figure out how blocks are generated from a developer view of perspective. I am not interested in pool mining etc. Just learning how different blockchains work. So, I know how BTC and XMR blockchains work when creating blocks. But, I couldn’t figure out Equihash coins generation.

For example, high level abstraction for Bitcoin mining (solo + local node) process could be :

GetBlockTemplate from node
Header_Array = CreateYourHeader (combine all these block version, prev hash, merkle root, current time, block bits, zero nonce)
While (target_not_met)

  • nonce ++
  • place nonce in the Header_Array
  • hash = SHA256(SHA256(Header_Array)) then reverse
  • If (hash < target) target_not_met=false

SubmitBlock with nonce

So, how equihash + blake2b are used in BTG, ZEC, etc… ?

Let’s say I started with GetBlockTemplate like BTC…
Then ? Can anyone give me a high level algorithm like I mentioned above please?

The block header is slightly modified; it conforms to the ZCash block header.

Details here:

image

As far as Equihash and Blake2b…

This is basic Equihash:

  1. Take block header and perform blake2 many times to create large pool of random-looking working data (several GB for BTG). This means performing many hashes just to create the data.
  2. Look for matched strings in that data of a mininum length. This is called the “Generalized Birthday Problem.” If you find a match, you have a solution.

You can find info about the Equihash parameters BTG is using here. That page also includes links out to references like the original Equihash paper by Biryukov and Khovratovich.

Lastly, you can see a reference client which can perform Equihash mining for BTG here:

Note: this is a reference implementation that runs on CPU and is known to be non-optimal, but will help you understand how the hashing is performed at the code level.

1 Like