HarryR / ethsnarks

A toolkit for viable zk-SNARKS on Ethereum, Web, Mobile and Desktop
GNU Lesser General Public License v3.0
240 stars 57 forks source link

LongsightF Merkle Tree #14

Closed HarryR closed 6 years ago

HarryR commented 6 years ago

This implements an incremental merkle tree class in Python and the necessary backend SNARK circuits to verify the proofs.

The hash used for the merkle tree is LongsightF5p5, where 5 rounds with exponent of 5.

This is because 152 rounds are needed to meet the difficulty level outline in the MiMC paper, and 29*5 is... nearly there. This means that hashing the leaf, then proving a merkle path 29 entries long is about the same cost as two full hashes at 152 rounds each, rather than 30 hashes at 152 rounds each.