Skip to content

Commit

Permalink
Offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Aug 27, 2024
1 parent 7d617e0 commit 7ab9eb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions evm_arithmetization/src/fixed_recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2393,6 +2393,7 @@ where
/// This method outputs a tuple of [`ProofWithPublicInputs<F, C, D>`] and
/// associated [`FinalPublicValues`]. Only the proof with public inputs is
/// necessary for a verifier to assert correctness of the computation.
#[allow(clippy::type_complexity)]
pub fn prove_block_wrapper(
&self,
block_proof: &ProofWithPublicInputs<F, C, D>,
Expand Down
17 changes: 10 additions & 7 deletions evm_arithmetization/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,14 @@ impl<F: RichField, H: Hasher<F>> FinalPublicValues<F, H> {

impl<H: Hasher<F>, F: RichField> From<PublicValues<F>> for FinalPublicValues<F, H> {
fn from(value: PublicValues<F>) -> Self {
let mut hash_payload = value.block_hashes.prev_hashes[1..].to_vec();
hash_payload.push(value.block_hashes.cur_hash);

Self {
checkpoint_state_trie_root: value.trie_roots_before.state_root,
new_state_trie_root: value.trie_roots_after.state_root,
checkpoint_consolidated_hash: value.extra_block_data.checkpoint_consolidated_hash,
new_consolidated_hash: consolidate_hashes::<H, F>(
&value.block_hashes.prev_hashes.try_into().unwrap(),
),
new_consolidated_hash: consolidate_hashes::<H, F>(&hash_payload),
_phantom: PhantomData,
}
}
Expand Down Expand Up @@ -255,8 +256,10 @@ impl FinalPublicValuesTarget {
);
}

let mut hash_payload = pv.block_hashes.prev_hashes[TARGET_HASH_SIZE..].to_vec();
hash_payload.extend_from_slice(&pv.block_hashes.cur_hash);
let consolidated_hash = builder
.hash_n_to_hash_no_pad::<C::InnerHasher>(pv.block_hashes.prev_hashes.to_vec())
.hash_n_to_hash_no_pad::<C::InnerHasher>(hash_payload)
.elements;

for i in 0..NUM_HASH_OUT_ELTS {
Expand Down Expand Up @@ -338,9 +341,9 @@ impl BlockHashes {
/// Generates the consolidated hash for a sequence of block hashes.
///
/// It will pack 256 contiguous block hashes and hash them out.
pub fn consolidate_hashes<H: Hasher<F>, F: RichField>(
hashes: &[H256; 256],
) -> [F; NUM_HASH_OUT_ELTS] {
pub fn consolidate_hashes<H: Hasher<F>, F: RichField>(hashes: &[H256]) -> [F; NUM_HASH_OUT_ELTS] {
debug_assert!(hashes.len() == 256);

let payload = hashes.iter().flat_map(|&h| h256_limbs(h)).collect_vec();
H::hash_no_pad(&payload)
.to_vec()
Expand Down

0 comments on commit 7ab9eb9

Please sign in to comment.