Skip to content

Commit

Permalink
5.4 Keccak: Unsupported Empty Bytes Input Breaks EVM Equivalence
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagofneto committed Oct 26, 2023
1 parent 35b363a commit fe92cfb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/hashing/keccak.cairo
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use cairo_lib::utils::types::words64::{Words64, bytes_used_u64};
use keccak::cairo_keccak;

const EMPTY_KECCAK: u256 = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;

// @notice Wrapper arround cairo_keccak that format the input for compatibility with EVM
// @param words The input data, as a list of 64-bit little-endian words
// @param last_word_bytes Number of bytes in the last word
// @return The keccak hash of the input, matching the output of the EVM's keccak256 opcode
fn keccak_cairo_words64(words: Words64, last_word_bytes: usize) -> u256 {
if words.is_empty() {
return EMPTY_KECCAK;
}

let n = words.len();
let mut keccak_input = ArrayTrait::new();
let mut i: usize = 0;
Expand Down

0 comments on commit fe92cfb

Please sign in to comment.