SHA3 opcode | Keccak support in copy circuit#235
Conversation
This is interesting. While working on the Super Circuit I noticed that for RLC with dynamic-length inputs, it's easier (or I should say, more convenient) to calculate the The bytecode circuit already does the lookups to keccak like this (using the reverse of the input). Maybe we can agree to always use |
I did know about this definition from the bytecode circuit. I made a mistake by only adding up every Based on what I've pushed in the recent fix, it turns out to be this, which is in fact the |
d2390a4 to
23b79fd
Compare
|
Before this feature, a copy_table lookup looked like this:
|
|
@ed255 I've handled the above points in this PR: scroll-tech#46 I haven't opened it yet against upstream because I was waiting for this PR to be merged first. Do you prefer if I opened a single PR for this change as well as implementing the SHA3 opcode?
Defined here: https://github.com/scroll-tech/zkevm-specs/blob/feat/sha3/src/zkevm_specs/evm/table.py#L411-L423
Handled here: https://github.com/scroll-tech/zkevm-specs/blob/feat/sha3/src/zkevm_specs/evm/table.py#L467-L496 In the PR: scroll-tech#46 I already have a basic test case for |
Ah I see. Considering that this PR is quite small I would say that I'd prefer if the SHA3 opcode spec was added to this PR as well :) That is, merging scroll-tech#46 into this PR. I think this way the review will be more clear, because the same PR will contain the new copy circuit functionality, and the SHA3 opcode using such functionality, with the corresponding tests.
Thanks for the pointers! |
* feat: initial changes * fix: rebase and fix return_ opcode as per new copy lookup api * feat: add copy and keccak lookup * tests: WIP test for sha3 * fix: sha3 tests for root tx
|
@ed255 Merged! So this PR now is a full implementation of the SHA3 opcode. |
ed255
left a comment
There was a problem hiding this comment.
I've left comments to discuss some stuff.
ChihChengLiang
left a comment
There was a problem hiding this comment.
I added some questions
Co-authored-by: Chih Cheng Liang <chihchengliang@gmail.com>
ChihChengLiang
left a comment
There was a problem hiding this comment.
LGTM now. Great PR. Thank you for the contribution!
This PR adds a
RlcAcctype in theCopyDataTypeTagenum.This tag is reserved for copy destination where instead of copying byte to byte (read to write), we're accumulating an RLC value in the destination. That is:
This variant of the copy circuit will be used for
SHA3opcode execution gadget, where the goal is to find a final accumulator value over each byte from the input. The final RLC accumulator will be used to lookup to the Keccak table and find theSHA3of the input bytes.The PR also implements the
SHA3opcode.Closes #228
Closes #223