Skip to content

Commit

Permalink
prover: use Keccak256 implementation from Gnark
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Wojciech Zmuda <[email protected]>
  • Loading branch information
wzmuda committed Mar 29, 2024
1 parent 5374181 commit 64aeeeb
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 477 deletions.
5 changes: 4 additions & 1 deletion prover/deletion_circuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ func (circuit *DeletionMbuCircuit) Define(api frontend.API) error {
bits_post := abstractor.Call1(api, ToReducedBigEndian{Variable: circuit.PostRoot, Size: 256})
bits = append(bits, bits_post...)

hash := keccak.NewKeccak256(api, circuit.BatchSize*32+2*256, bits...)
hash, err := keccak.Keccak256(api, bits)
if err != nil {
return err
}
sum := abstractor.Call(api, FromBinaryBigEndian{Variable: hash})

// The same endianness conversion has been performed in the hash generation
Expand Down
5 changes: 4 additions & 1 deletion prover/insertion_circuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ func (circuit *InsertionMbuCircuit) Define(api frontend.API) error {
bits = append(bits, bits_id...)
}

hash := keccak.NewKeccak256(api, (circuit.BatchSize+2)*256+32, bits...)
hash, err := keccak.Keccak256(api, bits)
if err != nil {
return err
}
sum := abstractor.Call(api, FromBinaryBigEndian{Variable: hash})

// The same endianness conversion has been performed in the hash generation
Expand Down
48 changes: 0 additions & 48 deletions prover/keccak/constants.go

This file was deleted.

Loading

0 comments on commit 64aeeeb

Please sign in to comment.