mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-03-27 23:03:06 +00:00
NUM_REGISTERS -> NUM_COLUMNS
This commit is contained in:
parent
7812ad242c
commit
f30889b7d7
@ -119,4 +119,4 @@ pub(crate) const fn reg_a_prime_prime_prime(x: usize, y: usize) -> usize {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const NUM_REGISTERS: usize = REG_A_PRIME_PRIME_PRIME_0_0_HI + 1;
|
||||
pub(crate) const NUM_COLUMNS: usize = REG_A_PRIME_PRIME_PRIME_0_0_HI + 1;
|
||||
|
||||
@ -15,7 +15,7 @@ use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer
|
||||
use crate::cross_table_lookup::Column;
|
||||
use crate::keccak::columns::{
|
||||
reg_a, reg_a_prime, reg_a_prime_prime, reg_a_prime_prime_0_0_bit, reg_a_prime_prime_prime,
|
||||
reg_b, reg_c, reg_c_partial, reg_input_limb, reg_output_limb, reg_step, NUM_REGISTERS,
|
||||
reg_b, reg_c, reg_c_partial, reg_input_limb, reg_output_limb, reg_step, NUM_COLUMNS,
|
||||
};
|
||||
use crate::keccak::constants::{rc_value, rc_value_bit};
|
||||
use crate::keccak::logic::{
|
||||
@ -55,7 +55,7 @@ impl<F: RichField + Extendable<D>, const D: usize> KeccakStark<F, D> {
|
||||
pub(crate) fn generate_trace_rows(
|
||||
&self,
|
||||
inputs: Vec<[u64; NUM_INPUTS]>,
|
||||
) -> Vec<[F; NUM_REGISTERS]> {
|
||||
) -> Vec<[F; NUM_COLUMNS]> {
|
||||
let num_rows = (inputs.len() * NUM_ROUNDS).next_power_of_two();
|
||||
info!("{} rows", num_rows);
|
||||
let mut rows = Vec::with_capacity(num_rows);
|
||||
@ -71,8 +71,8 @@ impl<F: RichField + Extendable<D>, const D: usize> KeccakStark<F, D> {
|
||||
rows
|
||||
}
|
||||
|
||||
fn generate_trace_rows_for_perm(&self, input: [u64; NUM_INPUTS]) -> Vec<[F; NUM_REGISTERS]> {
|
||||
let mut rows = vec![[F::ZERO; NUM_REGISTERS]; NUM_ROUNDS];
|
||||
fn generate_trace_rows_for_perm(&self, input: [u64; NUM_INPUTS]) -> Vec<[F; NUM_COLUMNS]> {
|
||||
let mut rows = vec![[F::ZERO; NUM_COLUMNS]; NUM_ROUNDS];
|
||||
|
||||
for x in 0..5 {
|
||||
for y in 0..5 {
|
||||
@ -92,11 +92,7 @@ impl<F: RichField + Extendable<D>, const D: usize> KeccakStark<F, D> {
|
||||
rows
|
||||
}
|
||||
|
||||
fn copy_output_to_input(
|
||||
&self,
|
||||
prev_row: [F; NUM_REGISTERS],
|
||||
next_row: &mut [F; NUM_REGISTERS],
|
||||
) {
|
||||
fn copy_output_to_input(&self, prev_row: [F; NUM_COLUMNS], next_row: &mut [F; NUM_COLUMNS]) {
|
||||
for x in 0..5 {
|
||||
for y in 0..5 {
|
||||
let cur_lo = prev_row[reg_a_prime_prime_prime(x, y)];
|
||||
@ -117,7 +113,7 @@ impl<F: RichField + Extendable<D>, const D: usize> KeccakStark<F, D> {
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_trace_row_for_round(&self, row: &mut [F; NUM_REGISTERS], round: usize) {
|
||||
fn generate_trace_row_for_round(&self, row: &mut [F; NUM_COLUMNS], round: usize) {
|
||||
row[reg_step(round)] = F::ONE;
|
||||
|
||||
// Populate C partial and C.
|
||||
@ -219,7 +215,7 @@ impl<F: RichField + Extendable<D>, const D: usize> KeccakStark<F, D> {
|
||||
}
|
||||
|
||||
impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for KeccakStark<F, D> {
|
||||
const COLUMNS: usize = NUM_REGISTERS;
|
||||
const COLUMNS: usize = NUM_COLUMNS;
|
||||
const PUBLIC_INPUTS: usize = NUM_PUBLIC_INPUTS;
|
||||
|
||||
fn eval_packed_generic<FE, P, const D2: usize>(
|
||||
|
||||
@ -6,13 +6,13 @@ use plonky2::plonk::circuit_builder::CircuitBuilder;
|
||||
|
||||
use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer};
|
||||
use crate::keccak::columns::reg_step;
|
||||
use crate::keccak::columns::NUM_REGISTERS;
|
||||
use crate::keccak::columns::NUM_COLUMNS;
|
||||
use crate::keccak::keccak_stark::{NUM_PUBLIC_INPUTS, NUM_ROUNDS};
|
||||
use crate::vars::StarkEvaluationTargets;
|
||||
use crate::vars::StarkEvaluationVars;
|
||||
|
||||
pub(crate) fn eval_round_flags<F: Field, P: PackedField<Scalar = F>>(
|
||||
vars: StarkEvaluationVars<F, P, NUM_REGISTERS, NUM_PUBLIC_INPUTS>,
|
||||
vars: StarkEvaluationVars<F, P, NUM_COLUMNS, NUM_PUBLIC_INPUTS>,
|
||||
yield_constr: &mut ConstraintConsumer<P>,
|
||||
) {
|
||||
// Initially, the first step flag should be 1 while the others should be 0.
|
||||
@ -30,7 +30,7 @@ pub(crate) fn eval_round_flags<F: Field, P: PackedField<Scalar = F>>(
|
||||
|
||||
pub(crate) fn eval_round_flags_recursively<F: RichField + Extendable<D>, const D: usize>(
|
||||
builder: &mut CircuitBuilder<F, D>,
|
||||
vars: StarkEvaluationTargets<D, NUM_REGISTERS, NUM_PUBLIC_INPUTS>,
|
||||
vars: StarkEvaluationTargets<D, NUM_COLUMNS, NUM_PUBLIC_INPUTS>,
|
||||
yield_constr: &mut RecursiveConstraintConsumer<F, D>,
|
||||
) {
|
||||
let one = builder.one_extension();
|
||||
|
||||
@ -52,4 +52,4 @@ pub(crate) const fn is_channel(channel: usize) -> usize {
|
||||
IS_CHANNEL_START + channel
|
||||
}
|
||||
|
||||
pub(crate) const NUM_REGISTERS: usize = IS_CHANNEL_START + NUM_CHANNELS;
|
||||
pub(crate) const NUM_COLUMNS: usize = IS_CHANNEL_START + NUM_CHANNELS;
|
||||
|
||||
@ -17,7 +17,7 @@ use crate::cross_table_lookup::Column;
|
||||
use crate::lookup::{eval_lookups, eval_lookups_circuit, permuted_cols};
|
||||
use crate::memory::columns::{
|
||||
sorted_value_limb, value_limb, ADDR_CONTEXT, ADDR_SEGMENT, ADDR_VIRTUAL, CONTEXT_FIRST_CHANGE,
|
||||
COUNTER, COUNTER_PERMUTED, IS_READ, NUM_REGISTERS, RANGE_CHECK, RANGE_CHECK_PERMUTED,
|
||||
COUNTER, COUNTER_PERMUTED, IS_READ, NUM_COLUMNS, RANGE_CHECK, RANGE_CHECK_PERMUTED,
|
||||
SEGMENT_FIRST_CHANGE, SORTED_ADDR_CONTEXT, SORTED_ADDR_SEGMENT, SORTED_ADDR_VIRTUAL,
|
||||
SORTED_IS_READ, SORTED_TIMESTAMP, TIMESTAMP, VIRTUAL_FIRST_CHANGE,
|
||||
};
|
||||
@ -227,10 +227,10 @@ impl<F: RichField + Extendable<D>, const D: usize> MemoryStark<F, D> {
|
||||
pub(crate) fn generate_trace_rows(
|
||||
&self,
|
||||
memory_ops: Vec<MemoryOp<F>>,
|
||||
) -> Vec<[F; NUM_REGISTERS]> {
|
||||
) -> Vec<[F; NUM_COLUMNS]> {
|
||||
let num_ops = memory_ops.len();
|
||||
|
||||
let mut trace_cols = [(); NUM_REGISTERS].map(|_| vec![F::ZERO; num_ops]);
|
||||
let mut trace_cols = [(); NUM_COLUMNS].map(|_| vec![F::ZERO; num_ops]);
|
||||
for i in 0..num_ops {
|
||||
let MemoryOp {
|
||||
channel_index,
|
||||
@ -254,7 +254,7 @@ impl<F: RichField + Extendable<D>, const D: usize> MemoryStark<F, D> {
|
||||
|
||||
self.generate_memory(&mut trace_cols);
|
||||
|
||||
let mut trace_rows = vec![[F::ZERO; NUM_REGISTERS]; num_ops];
|
||||
let mut trace_rows = vec![[F::ZERO; NUM_COLUMNS]; num_ops];
|
||||
for (i, col) in trace_cols.iter().enumerate() {
|
||||
for (j, &val) in col.iter().enumerate() {
|
||||
trace_rows[j][i] = val;
|
||||
@ -353,7 +353,7 @@ impl<F: RichField + Extendable<D>, const D: usize> MemoryStark<F, D> {
|
||||
}
|
||||
|
||||
impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for MemoryStark<F, D> {
|
||||
const COLUMNS: usize = NUM_REGISTERS;
|
||||
const COLUMNS: usize = NUM_COLUMNS;
|
||||
const PUBLIC_INPUTS: usize = NUM_PUBLIC_INPUTS;
|
||||
|
||||
fn eval_packed_generic<FE, P, const D2: usize>(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user