semaphore-mtb icon indicating copy to clipboard operation
semaphore-mtb copied to clipboard

prover: use Keccak256 implementation form Gnark

Open wzmuda opened this issue 1 year ago • 1 comments

In keccak package add a wrapper converting []frontend.Variable to []uints.U8 expected by NewLegacykeccak256. Use the wrapper in insertion and deletion circuits instead of our Keccak256 implementation.

Remove the existing Keccak implementation. Add tests of the new implementation.

wzmuda avatar Mar 27 '24 22:03 wzmuda

Updated according to our conversation:

  • old impl removed
  • tests refactored. You may notice now that the current Keccak256 is just regular Keccak256 with fancy input format. I.e. it returns well-known hashes for well-known inputs.

Also Keccak256 API has slightly changed since the draft. Previously it was defined as func Keccak256(api frontend.API, int inputSize, data ...frontend.Variable) (hash []frontend.Variable, err error) to keep compatibility with the old implementation. Since the old implementation is gone, I see no reason to keep that compatibility, given that accepting just api and slice of frontend.Variable is simpler and works the same. Let me know if the previous API made sense for some specific use case.

wzmuda avatar Mar 29 '24 00:03 wzmuda