Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plafer cleanup block hash table #1333

Merged
merged 14 commits into from
May 28, 2024
17 changes: 15 additions & 2 deletions air/src/trace/main_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::{
};
use alloc::vec::Vec;
use core::ops::{Deref, Range};
use vm_core::{utils::range, Felt, ONE, ZERO};
use vm_core::{utils::range, Felt, Word, ONE, ZERO};

// CONSTANTS
// ================================================================================================
Expand Down Expand Up @@ -107,14 +107,27 @@ impl MainTrace {
}

/// Returns the first half of the hasher state at row i.
pub fn decoder_hasher_state_first_half(&self, i: usize) -> [Felt; DIGEST_LEN] {
pub fn decoder_hasher_state_first_half(&self, i: usize) -> Word {
let mut state = [ZERO; DIGEST_LEN];
for (col, s) in state.iter_mut().enumerate() {
*s = self.columns.get_column(DECODER_TRACE_OFFSET + HASHER_STATE_OFFSET + col)[i];
}
state
}

/// Returns the second half of the hasher state at row i.
pub fn decoder_hasher_state_second_half(&self, i: usize) -> Word {
const SECOND_WORD_OFFSET: usize = 4;
let mut state = [ZERO; DIGEST_LEN];
for (col, s) in state.iter_mut().enumerate() {
*s = self
.columns
.get_column(DECODER_TRACE_OFFSET + HASHER_STATE_OFFSET + SECOND_WORD_OFFSET + col)
[i];
}
state
}

/// Returns a specific element from the hasher state at row i.
pub fn decoder_hasher_state_element(&self, element: usize, i: usize) -> Felt {
self.columns.get_column(DECODER_TRACE_OFFSET + HASHER_STATE_OFFSET + element)[i + 1]
Expand Down
Loading
Loading