This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 854
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'word-lo-hi' into leo/word-lo-hi
- Loading branch information
Showing
103 changed files
with
2,327 additions
and
2,849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,12 @@ | ||
use crate::evm_circuit::util::rlc; | ||
use crate::util::word::Word; | ||
use bus_mapping::circuit_input_builder::NumberOrHash; | ||
use eth_types::Field; | ||
use halo2_proofs::circuit::Value; | ||
|
||
/// Encode the type `NumberOrHash` into a field element | ||
pub fn number_or_hash_to_field<F: Field>(v: &NumberOrHash, challenge: Value<F>) -> Value<F> { | ||
pub fn number_or_hash_to_word<F: Field>(v: &NumberOrHash) -> Word<Value<F>> { | ||
match v { | ||
NumberOrHash::Number(n) => Value::known(F::from(*n as u64)), | ||
NumberOrHash::Hash(h) => { | ||
// since code hash in the bytecode table is represented in | ||
// the little-endian form, we reverse the big-endian bytes | ||
// of H256. | ||
let le_bytes = { | ||
let mut b = h.to_fixed_bytes(); | ||
b.reverse(); | ||
b | ||
}; | ||
challenge.map(|challenge| rlc::value(&le_bytes, challenge)) | ||
} | ||
NumberOrHash::Number(n) => Word::from(*n as u64).into_value(), | ||
NumberOrHash::Hash(h) => Word::from(*h).into_value(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.