zkBob / fawkes-crypto

Fawkes-Crypto - zkSNARKs framework
https://github.com/zeropoolnetwork/fawkes-crypto
Apache License 2.0
2 stars 1 forks source link

Optimize poseidon implementation #10

Closed AllFi closed 1 year ago

AllFi commented 1 year ago

An efficient implementation of the poseidon is presented in Supplementary Material B of https://eprint.iacr.org/2019/458.pdf. This optimization can't be applied to circuit and works only for native implementation.

Implementation of matrix operations has been copied from https://github.com/filecoin-project/neptune/blob/master/src/matrix.rs. Neptune's implementation of poseidon requires mds to be a symmetric matrix that doesn't hold in our case. So the rest of poseidon algorithm has been implemented based on reference implementation from the original paper: https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/poseidonperm_x3_64_24_optimized.sage.

New PoseidonParams can be deserialized from the current format. Additional fields will be precomputed during deserialization.

These updates don't change the crate interface so it is not necessary to modify other repositories (except for version updating).