Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
icemelon committed Mar 31, 2022
1 parent 5da447c commit e25799a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/zkevm_specs/evm/execution/extcodehash.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def extcodehash(instruction: Instruction):
is_empty = (
instruction.is_zero(nonce)
* instruction.is_zero(balance)
* instruction.is_equal(code_hash, instruction.rlc_encode(EMPTY_CODE_HASH))
* instruction.is_equal(code_hash, instruction.rlc_encode(EMPTY_CODE_HASH, 32))
)

instruction.constrain_equal(
Expand Down
7 changes: 6 additions & 1 deletion src/zkevm_specs/evm/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,15 @@ def compare(self, lhs: Expression, rhs: Expression, n_bytes: int) -> Tuple[FQ, F
return FQ(lhs.expr().n < rhs.expr().n), FQ(lhs.expr().n == rhs.expr().n)

def compare_word(self, lhs: RLC, rhs: RLC) -> Tuple[FQ, FQ]:
"""
Compare the value of two 256-bit words, and return two outputs.
The first output value is 1 if the left-hand side is strictly smaller, 0 otherwise.
The second output value is 1 if the left-hand side is equal to the right-hand side, 0 otherwise.
"""
assert len(lhs.le_bytes) == 32, "Expected word to contain 32 bytes"
assert len(rhs.le_bytes) == 32, "Expected word to contain 32 bytes"
lhs_hi, lhs_lo = self.word_to_lo_hi(lhs)
rhs_hi, rhs_lo = self.word_to_lo_hi(lhs)
rhs_hi, rhs_lo = self.word_to_lo_hi(rhs)
hi_lt, hi_eq = self.compare(lhs_hi, rhs_hi, 16)
lo_lt, lo_eq = self.compare(lhs_lo, rhs_lo, 16)
return FQ(hi_lt + hi_eq * lo_lt), FQ(hi_eq * lo_eq)
Expand Down

0 comments on commit e25799a

Please sign in to comment.