HarryR / ethsnarks

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

is there poseidon solidity contract? #164

Open yanyanho opened 4 years ago

yanyanho commented 4 years ago

I find that : inputs = [3, 0] python_result = poseidon(inputs) print(python_result)

the result is 254bit? is it a bug?

HarryR commented 4 years ago

Hi.

the code to generate Poseidon EVM contract is at: https://github.com/HarryR/ethsnarks/blob/master/ethsnarks/poseidon/contract.py - it emits raw EVM bytecode rather than Solidity, but could be modified to emit Solidity with mostly inline assembly like the MiMC contract generator does.

The Poseidon hash inputs and outputs are in the zkSNARK scalar field, so not 256bit integers, or the altbn curve field, but the order of the curve (L, which is a ~254 bit prime).