spec: fix keccak's addr handling#674
Conversation
Codex Code ReviewNo issues found in the PR diff. The changes are limited to Keccak spec metadata/constraints and documentation. The new |
Review: spec: fix
|
|
|
||
| The address containing the state to be permuted is passed in as argument `A0 = x10`. | ||
| The following constraints describe that this address is read into `addr` (@keccak:c:read_addr), from which `state_ptr` --- the collection of pointers to all lanes of the state --- is derived (@keccak:c:state_ptr). | ||
| The following constraints describe that this address is read into `addr` (@keccak:c:read_addr), from which `state_ptr` --- the collection of pointers to all lanes of the state --- is derived (@keccak:c:state_ptr); @keccak:c:range_state_ptr is included to satisfy @add:a:sum. |
There was a problem hiding this comment.
The text explains that @keccak:c:range_state_ptr satisfies @add:a:sum, but the new @keccak:c:range_addr constraint's purpose (satisfying @add:a:lhs for the ADD chip used in @keccak:c:state_ptr) isn't mentioned. Consider adding something like: @keccak:c:range_addr is included to satisfy @add:a:lhs.
| name = "addr" | ||
| type = "DWordBL" | ||
| desc = "memory address storing the first bit of the state" | ||
| type = "DWordHL" |
There was a problem hiding this comment.
I think technically we can do a DWordWL here?
We're not using addr anywhere else other than computing state_ptr, so we can get WL range check from the memory and not need the IS_HALF checks.
This does imply a change to the first bullet point in "Notes/potential optimizations" too.
There was a problem hiding this comment.
I mean, while we're at it, we might as well drop addrand just load the first address in state_ptr[0][0]? That would still leave the optimization that state_ptr[0][0] could be a DWordWL (while the others have to be HLs), which I think we should forego in favor of a more readable spec. Wdyt?
There was a problem hiding this comment.
Sure.
I think the only reason we didn't do that in the first place was to keep the range_ptr ADD iter clean, but we can even keep it as-is, given that ADD<x; x, 0> works just fine
No description provided.