Skip to content

Commit

Permalink
chore: simplify requests hasher
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Kindi-0 committed Oct 2, 2024
1 parent 5085999 commit b4b9c63
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions processor/src/chiplets/aux_trace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ fn build_control_block_request<E: FieldElement<BaseField = Felt>>(
) -> E {
let op_label = LINEAR_HASH_LABEL;
let addr_nxt = main_trace.addr(row + 1);
let first_cycle_row = addr_to_row_index(addr_nxt) % HASH_CYCLE_LEN == 0;
let transition_label = if first_cycle_row { op_label + 16 } else { op_label + 32 };
let transition_label = op_label + 16;

let header =
alphas[0] + alphas[1].mul_base(Felt::from(transition_label)) + alphas[2].mul_base(addr_nxt);
Expand Down Expand Up @@ -335,8 +334,7 @@ fn build_span_block_request<E: FieldElement<BaseField = Felt>>(
) -> E {
let op_label = LINEAR_HASH_LABEL;
let addr_nxt = main_trace.addr(row + 1);
let first_cycle_row = addr_to_row_index(addr_nxt) % HASH_CYCLE_LEN == 0;
let transition_label = if first_cycle_row { op_label + 16 } else { op_label + 32 };
let transition_label = op_label + 16;

let header =
alphas[0] + alphas[1].mul_base(Felt::from(transition_label)) + alphas[2].mul_base(addr_nxt);
Expand All @@ -353,9 +351,7 @@ fn build_respan_block_request<E: FieldElement<BaseField = Felt>>(
) -> E {
let op_label = LINEAR_HASH_LABEL;
let addr_nxt = main_trace.addr(row + 1);

let first_cycle_row = addr_to_row_index(addr_nxt - ONE) % HASH_CYCLE_LEN == 0;
let transition_label = if first_cycle_row { op_label + 16 } else { op_label + 32 };
let transition_label = op_label + 32;

let header = alphas[0]
+ alphas[1].mul_base(Felt::from(transition_label))
Expand All @@ -375,9 +371,7 @@ fn build_end_block_request<E: FieldElement<BaseField = Felt>>(
) -> E {
let op_label = RETURN_HASH_LABEL;
let addr = main_trace.addr(row) + Felt::from(NUM_ROUNDS as u8);

let first_cycle_row = addr_to_row_index(addr) % HASH_CYCLE_LEN == 0;
let transition_label = if first_cycle_row { op_label + 16 } else { op_label + 32 };
let transition_label = op_label + 32;

let header =
alphas[0] + alphas[1].mul_base(Felt::from(transition_label)) + alphas[2].mul_base(addr);
Expand Down Expand Up @@ -967,11 +961,6 @@ fn addr_to_hash_cycle(addr: Felt) -> usize {
cycle_row
}

/// Convenience method to convert from addresses to rows.
fn addr_to_row_index(addr: Felt) -> usize {
(addr.as_int() - 1) as usize
}

/// Computes a memory read or write request at `row` given randomness `alphas`, memory address
/// `addr` and value `value`.
fn compute_memory_request<E: FieldElement<BaseField = Felt>>(
Expand Down

0 comments on commit b4b9c63

Please sign in to comment.