Remove is_keccak_sponge (#1410)

* Remove is_keccak_sponge

* Apply comment
This commit is contained in:
Hamy Ratoanina 2023-12-07 13:07:06 -05:00 committed by GitHub
parent 170ce5f27c
commit edfc86c393
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 6 deletions

View File

@ -31,7 +31,6 @@ but change the code context, which is where the instructions are read from.
\item \texttt{is\_kernel\_mode}: Boolean indicating whether we are in kernel (i.e. privileged) mode. This means we are executing kernel code, and we have access to \item \texttt{is\_kernel\_mode}: Boolean indicating whether we are in kernel (i.e. privileged) mode. This means we are executing kernel code, and we have access to
privileged instructions. privileged instructions.
\item \texttt{gas}: The current amount of gas used in the current context. It is eventually checked to be below the current gas limit. Must fit in 32 bits. \item \texttt{gas}: The current amount of gas used in the current context. It is eventually checked to be below the current gas limit. Must fit in 32 bits.
\item \texttt{is\_keccak\_sponge}: Boolean indicating whether we are executing a Keccak hash. Only used as a filter for CTLs.
\item \texttt{clock}: Monotonic counter which starts at 0 and is incremented by 1 at each row. Used to enforce correct ordering of memory accesses. \item \texttt{clock}: Monotonic counter which starts at 0 and is incremented by 1 at each row. Used to enforce correct ordering of memory accesses.
\item \texttt{opcode\_bits}: 8 boolean columns, which are the bit decomposition of the opcode being read at the current PC. \item \texttt{opcode\_bits}: 8 boolean columns, which are the bit decomposition of the opcode being read at the current PC.
\end{itemize} \end{itemize}

Binary file not shown.

View File

@ -78,9 +78,6 @@ pub(crate) struct CpuColumnsView<T: Copy> {
/// If CPU cycle: the opcode, broken up into bits in little-endian order. /// If CPU cycle: the opcode, broken up into bits in little-endian order.
pub opcode_bits: [T; 8], pub opcode_bits: [T; 8],
/// Filter. 1 iff a Keccak sponge lookup is performed on this row.
pub is_keccak_sponge: T,
/// Columns shared by various operations. /// Columns shared by various operations.
pub(crate) general: CpuGeneralColumnsView<T>, pub(crate) general: CpuGeneralColumnsView<T>,

View File

@ -48,8 +48,15 @@ pub(crate) fn ctl_data_keccak_sponge<F: Field>() -> Vec<Column<F>> {
} }
/// CTL filter for a call to the Keccak sponge. /// CTL filter for a call to the Keccak sponge.
// KECCAK_GENERAL is differentiated from JUMPDEST by its second bit set to 0.
pub(crate) fn ctl_filter_keccak_sponge<F: Field>() -> Filter<F> { pub(crate) fn ctl_filter_keccak_sponge<F: Field>() -> Filter<F> {
Filter::new_simple(Column::single(COL_MAP.is_keccak_sponge)) Filter::new(
vec![(
Column::single(COL_MAP.op.jumpdest_keccak_general),
Column::linear_combination_with_constant([(COL_MAP.opcode_bits[1], -F::ONE)], F::ONE),
)],
vec![],
)
} }
/// Creates the vector of `Columns` corresponding to the two inputs and /// Creates the vector of `Columns` corresponding to the two inputs and

View File

@ -129,7 +129,6 @@ pub(crate) fn generate_keccak_general<F: Field>(
state: &mut GenerationState<F>, state: &mut GenerationState<F>,
mut row: CpuColumnsView<F>, mut row: CpuColumnsView<F>,
) -> Result<(), ProgramError> { ) -> Result<(), ProgramError> {
row.is_keccak_sponge = F::ONE;
let [(context, _), (segment, log_in1), (base_virt, log_in2), (len, log_in3)] = let [(context, _), (segment, log_in1), (base_virt, log_in2), (len, log_in3)] =
stack_pop_with_log_and_fill::<4, _>(state, &mut row)?; stack_pop_with_log_and_fill::<4, _>(state, &mut row)?;
let len = u256_to_usize(len)?; let len = u256_to_usize(len)?;