iden3 / go-iden3-crypto

Go implementation of some cryptographic primitives (that fit inside the SNARK field) and compatible with circomlib
Apache License 2.0
119 stars 41 forks source link

Optimize Poseidon #12

Closed ed255 closed 4 years ago

ed255 commented 4 years ago

This PR optimizes Poseidon mainly by removing all the allocations that were happening before due to the use of the fields module functions (which made every arithmetic operation require one or two allocations).

Tested on an Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz

Before:

BenchmarkPoseidon-8          550           2014834 ns/op         1373210 B/op      20650 allocs/op

After:

BenchmarkPoseidon-8          801           1289262 ns/op          253414 B/op       3553 allocs/op