diff --git a/src/data_structures/eth_mpt.cairo b/src/data_structures/eth_mpt.cairo index 730e908..6f3f791 100644 --- a/src/data_structures/eth_mpt.cairo +++ b/src/data_structures/eth_mpt.cairo @@ -265,12 +265,16 @@ impl MPTImpl of MPTTrait { if prefix == 0 { match second.try_into() { - Option::Some(n) => Result::Ok(MPTNode::Extension((first, n, 2, n_nibbles - 1))), + Option::Some(n) => Result::Ok( + MPTNode::Extension((first, n, 2, n_nibbles - 1)) + ), Option::None(_) => Result::Err('Invalid next node') } } else if prefix == 1 { match second.try_into() { - Option::Some(n) => Result::Ok(MPTNode::Extension((first, n, 1, n_nibbles))), + Option::Some(n) => Result::Ok( + MPTNode::Extension((first, n, 1, n_nibbles)) + ), Option::None(_) => Result::Err('Invalid next node') } } else if prefix == 2 { diff --git a/src/hashing/keccak.cairo b/src/hashing/keccak.cairo index 424cea1..4742181 100644 --- a/src/hashing/keccak.cairo +++ b/src/hashing/keccak.cairo @@ -1,10 +1,16 @@ 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 // @return The keccak hash of the input, matching the output of the EVM's keccak256 opcode fn keccak_cairo_words64(words: Words64) -> u256 { + if words.is_empty() { + return EMPTY_KECCAK; + } + let n = words.len(); let mut keccak_input = ArrayTrait::new();