# Zcash mining proof of concept in FPGA

**URL:** <https://forum.zcashcommunity.com/t/zcash-mining-proof-of-concept-in-fpga/36385>\
**Category:** Mining\
**Created:** [April 26, 2020, 6:51pm UTC](https://forum.zcashcommunity.com/t/zcash-mining-proof-of-concept-in-fpga/36385 "2020-04-26T18:51:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hpbhat](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hpbhat/32/16039_2.png) [@hpbhat](https://forum.zcashcommunity.com/u/hpbhat)\
**Post date:** [April 26, 2020, 6:51pm UTC](https://forum.zcashcommunity.com/t/zcash-mining-proof-of-concept-in-fpga/36385/1 "2020-04-26T18:51:54Z")

</div>

I am trying to build some proof of concept in FPGA for zcash mining.

I have gone through following discussions and understood the algorithm flow upto some extent.

> [@Easy to follow description of the equihash algorithm](https://forum.zcashcommunity.com/t/easy-to-follow-description-of-the-equihash-algorithm/12689/23):
>
> I can edit my post I post wrong value the correct is index 0 ====\> f4ad238782320cc409c974795a1e117df01149a1f1068b0bd9863bb88e67f276f41c83e358d1d92842978fb53cc3eab0d184 index 1 ===\> 5ce08e3f788e241fa87d2be5618c09538f7815fe1137b1d05c3a5da1957254b1e302291025c0011246ed923024b784d1c9e3 index 2 ===\> 24fb72d01d3e1bd4cc69cd1ef3783b285159fb8a036b0e0fd8bdfbb062bd6e3f3add331bb474eccfd999188a20408d88a23d

> <https://gist.github.com/mtve/f35c090f4d93e4e71b74a6544fa5255f>

My current confusion is regarding the blake2b input

block header:  
040000007003225F30E1015EE14609B222E6036B7572963E18355688A966BB0E00000000E53B8DC142BBF69584F26B5F1D2125B79F238E77D04A37CDFAE64D3CFE9B2E730000000000000000000000000000000000000000000000000000000000000000C85BDA595DB6121C4FFFFFFF05000000000000000000000000000000000000000000000000000000 + 4 byte Index  
If I consider the above block header of 140 byte, then I have some question regarding how I can feed the block header to blake2b input

Blake2b-512 can accept 128byte of message block. So, I need to break 140 byte + 4 byte index = 144byte header to 2 message blocks. Then calculate the hash of first 128byte block data and then calculate the final hash by considering the hash of 1st block and remaining message block.

So, In my view the fist message block should be 22E6036B7572963E18355688A966BB0E00000000E53B8DC142BBF69584F26B5F1D2125B79F238E77D04A37CDFAE64D3CFE9B2E730000000000000000000000000000000000000000000000000000000000000000C85BDA595DB6121C4FFFFFFF050000000000000000000000000000000000000000000000 + 00000000 (index, will increment 10000000, 20000000, 30000000 …)  
and 2nd message block should be remaining 16 bytes of header and appended with zero in the left side {(112 byte appended zero) || 040000007003225F30E1015EE14609B2 (16 byte).}

Also, as per wiki

> **[BLAKE (hash function)](https://en.wikipedia.org/wiki/BLAKE_(hash_function))**
>
> BLAKE is a cryptographic hash function based on Daniel J. Bernstein's ChaCha stream cipher, but a permuted copy of the input block, XORed with round constants, is added before each ChaCha round. Like SHA-2, there are two variants differing in the word size. ChaCha operates on a 4×4 array of words. BLAKE repeatedly combines an 8-word hash value with 16 message words, truncating the ChaCha result to obtain the next hash value. BLAKE-256 and BLAKE-224 use 32-bit words and produce digest sizes of 256...

**Function** Compress  
we need to feed input t  
t: Number, 0…2128 Count of bytes that have been fed into the Compression  
for first block it must be 128byte and for 2nd block whether it must be 144 byte of 256byte (as we are padding 112bytes with zero) ?

Please confirm whether the block1 & block2 data arrangement to blake2b input is correct or any rearrangement should be done.

---

<div class="post-metadata">

**Author:** ![hpbhat](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hpbhat/32/16039_2.png) [@hpbhat](https://forum.zcashcommunity.com/u/hpbhat)\
**Post date:** [April 30, 2020, 12:30pm UTC](https://forum.zcashcommunity.com/t/zcash-mining-proof-of-concept-in-fpga/36385/3 "2020-04-30T12:30:01Z")

</div>

Hi,

Any thought on above query ?

Thanks,  
HP Bhat
