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

Jubjub EdDSA + Tests + solidity cleanups #60

Closed HarryR closed 5 years ago

HarryR commented 5 years ago

This implements EdDSA in Solidity and Python, it doesn't yet match the libsnark implementation of JubJub's DSA, however there are some crucial takeaways for this:

  1. The s value from the signature may be the twist point on the curve
  2. The right hand side, for verification, uses the value t to multiply the public key by
  3. The public key is malleable, it must be on the twisted Edwards curve, but it is selectable by the user

Secondly, I'm truncating the output of the hash function to 250 bits, this ensures that it will be clamped to the point of the twist (JUBJUB_L). This is easy to do in EVM and Python, but requires a conversion to bits in the snark circuit. This adds an extra 250 constraints for bitness checks of the input to the scalarMult function.