2024-02-01 07:16:28 -05:00
|
|
|
use core::mem::size_of;
|
2022-12-02 13:56:52 -08:00
|
|
|
|
|
|
|
|
use itertools::Itertools;
|
2022-11-30 12:55:41 -08:00
|
|
|
use plonky2::field::extension::Extendable;
|
|
|
|
|
use plonky2::field::polynomial::PolynomialValues;
|
|
|
|
|
use plonky2::hash::hash_types::RichField;
|
2022-12-09 12:51:42 -08:00
|
|
|
use plonky2::timed;
|
2022-11-30 12:55:41 -08:00
|
|
|
use plonky2::util::timing::TimingTree;
|
|
|
|
|
|
|
|
|
|
use crate::all_stark::{AllStark, NUM_TABLES};
|
2023-09-06 12:31:17 -04:00
|
|
|
use crate::arithmetic::{BinaryOperator, Operation};
|
2023-09-12 14:45:37 -04:00
|
|
|
use crate::byte_packing::byte_packing_stark::BytePackingOp;
|
2022-11-30 12:55:41 -08:00
|
|
|
use crate::config::StarkConfig;
|
2022-11-15 09:26:54 -08:00
|
|
|
use crate::cpu::columns::CpuColumnsView;
|
2022-12-03 11:21:31 -08:00
|
|
|
use crate::keccak_sponge::columns::KECCAK_WIDTH_BYTES;
|
2022-11-30 12:55:41 -08:00
|
|
|
use crate::keccak_sponge::keccak_sponge_stark::KeccakSpongeOp;
|
|
|
|
|
use crate::util::trace_rows_to_poly_values;
|
2022-11-15 09:26:54 -08:00
|
|
|
use crate::witness::memory::MemoryOp;
|
2023-09-06 12:31:17 -04:00
|
|
|
use crate::{arithmetic, keccak, keccak_sponge, logic};
|
2022-11-15 09:26:54 -08:00
|
|
|
|
2022-11-28 13:19:40 -08:00
|
|
|
#[derive(Clone, Copy, Debug)]
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) struct TraceCheckpoint {
|
Cross-table lookup for arithmetic stark (#905)
* First draft of linking arithmetic Stark into the CTL mechanism.
* Handle {ADD,SUB,MUL}FP254 operations explicitly in `modular.rs`.
* Adjust argument order; add tests.
* Add CTLs for ADD, MUL, SUB, LT and GT.
* Add CTLs for {ADD,MUL,SUB}MOD, DIV and MOD.
* Add CTLs for {ADD,MUL,SUB}FP254 operations.
* Refactor the CPU/arithmetic CTL mapping; add some documentation.
* Minor comment fixes.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Merge `*FP254` CTL into main CTL; rename some registers.
* Connect extra argument from CPU in binary ops to facilitate combining with ternary ops.
* Merge modular ops CTL into main CTL.
* Refactor DIV and MOD code into its own module.
* Merge DIV and MOD into arithmetic CTL.
* Clippy.
* Fixes related to merge.
* Simplify register naming.
* Generate u16 BN254 modulus limbs at compile time.
* Clippy.
* Add degree bits ranges for Arithmetic table.
2023-05-11 03:29:06 +10:00
|
|
|
pub(self) arithmetic_len: usize,
|
2023-09-12 14:45:37 -04:00
|
|
|
pub(self) byte_packing_len: usize,
|
2022-11-28 13:19:40 -08:00
|
|
|
pub(self) cpu_len: usize,
|
2022-12-03 22:44:54 -08:00
|
|
|
pub(self) keccak_len: usize,
|
|
|
|
|
pub(self) keccak_sponge_len: usize,
|
2022-11-28 13:19:40 -08:00
|
|
|
pub(self) logic_len: usize,
|
|
|
|
|
pub(self) memory_len: usize,
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:55:41 -08:00
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub(crate) struct Traces<T: Copy> {
|
Cross-table lookup for arithmetic stark (#905)
* First draft of linking arithmetic Stark into the CTL mechanism.
* Handle {ADD,SUB,MUL}FP254 operations explicitly in `modular.rs`.
* Adjust argument order; add tests.
* Add CTLs for ADD, MUL, SUB, LT and GT.
* Add CTLs for {ADD,MUL,SUB}MOD, DIV and MOD.
* Add CTLs for {ADD,MUL,SUB}FP254 operations.
* Refactor the CPU/arithmetic CTL mapping; add some documentation.
* Minor comment fixes.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Merge `*FP254` CTL into main CTL; rename some registers.
* Connect extra argument from CPU in binary ops to facilitate combining with ternary ops.
* Merge modular ops CTL into main CTL.
* Refactor DIV and MOD code into its own module.
* Merge DIV and MOD into arithmetic CTL.
* Clippy.
* Fixes related to merge.
* Simplify register naming.
* Generate u16 BN254 modulus limbs at compile time.
* Clippy.
* Add degree bits ranges for Arithmetic table.
2023-05-11 03:29:06 +10:00
|
|
|
pub(crate) arithmetic_ops: Vec<arithmetic::Operation>,
|
2023-09-12 14:45:37 -04:00
|
|
|
pub(crate) byte_packing_ops: Vec<BytePackingOp>,
|
2022-11-30 12:55:41 -08:00
|
|
|
pub(crate) cpu: Vec<CpuColumnsView<T>>,
|
|
|
|
|
pub(crate) logic_ops: Vec<logic::Operation>,
|
|
|
|
|
pub(crate) memory_ops: Vec<MemoryOp>,
|
2023-10-06 15:49:57 -04:00
|
|
|
pub(crate) keccak_inputs: Vec<([u64; keccak::keccak_stark::NUM_INPUTS], usize)>,
|
2022-11-30 12:55:41 -08:00
|
|
|
pub(crate) keccak_sponge_ops: Vec<KeccakSpongeOp>,
|
2022-11-15 09:26:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T: Copy> Traces<T> {
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn new() -> Self {
|
2022-11-15 09:26:54 -08:00
|
|
|
Traces {
|
Cross-table lookup for arithmetic stark (#905)
* First draft of linking arithmetic Stark into the CTL mechanism.
* Handle {ADD,SUB,MUL}FP254 operations explicitly in `modular.rs`.
* Adjust argument order; add tests.
* Add CTLs for ADD, MUL, SUB, LT and GT.
* Add CTLs for {ADD,MUL,SUB}MOD, DIV and MOD.
* Add CTLs for {ADD,MUL,SUB}FP254 operations.
* Refactor the CPU/arithmetic CTL mapping; add some documentation.
* Minor comment fixes.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Merge `*FP254` CTL into main CTL; rename some registers.
* Connect extra argument from CPU in binary ops to facilitate combining with ternary ops.
* Merge modular ops CTL into main CTL.
* Refactor DIV and MOD code into its own module.
* Merge DIV and MOD into arithmetic CTL.
* Clippy.
* Fixes related to merge.
* Simplify register naming.
* Generate u16 BN254 modulus limbs at compile time.
* Clippy.
* Add degree bits ranges for Arithmetic table.
2023-05-11 03:29:06 +10:00
|
|
|
arithmetic_ops: vec![],
|
2023-09-12 14:45:37 -04:00
|
|
|
byte_packing_ops: vec![],
|
2022-11-15 09:26:54 -08:00
|
|
|
cpu: vec![],
|
2022-11-30 12:55:41 -08:00
|
|
|
logic_ops: vec![],
|
|
|
|
|
memory_ops: vec![],
|
|
|
|
|
keccak_inputs: vec![],
|
|
|
|
|
keccak_sponge_ops: vec![],
|
2022-11-15 09:26:54 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-06 12:31:17 -04:00
|
|
|
/// Returns the actual trace lengths for each STARK module.
|
|
|
|
|
// Uses a `TraceCheckPoint` as return object for convenience.
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn get_lengths(&self) -> TraceCheckpoint {
|
2023-09-06 12:31:17 -04:00
|
|
|
TraceCheckpoint {
|
|
|
|
|
arithmetic_len: self
|
|
|
|
|
.arithmetic_ops
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|op| match op {
|
2023-09-07 15:35:34 -04:00
|
|
|
Operation::TernaryOperation { .. } => 2,
|
|
|
|
|
Operation::BinaryOperation { operator, .. } => match operator {
|
2023-09-06 12:31:17 -04:00
|
|
|
BinaryOperator::Div | BinaryOperator::Mod => 2,
|
|
|
|
|
_ => 1,
|
|
|
|
|
},
|
2023-11-07 15:52:00 -05:00
|
|
|
Operation::RangeCheckOperation { .. } => 1,
|
2023-09-06 12:31:17 -04:00
|
|
|
})
|
|
|
|
|
.sum(),
|
2023-11-28 10:25:03 -05:00
|
|
|
byte_packing_len: self
|
|
|
|
|
.byte_packing_ops
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|op| usize::from(!op.bytes.is_empty()))
|
|
|
|
|
.sum(),
|
2023-09-06 12:31:17 -04:00
|
|
|
cpu_len: self.cpu.len(),
|
|
|
|
|
keccak_len: self.keccak_inputs.len() * keccak::keccak_stark::NUM_ROUNDS,
|
|
|
|
|
keccak_sponge_len: self
|
|
|
|
|
.keccak_sponge_ops
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|op| op.input.len() / keccak_sponge::columns::KECCAK_RATE_BYTES + 1)
|
|
|
|
|
.sum(),
|
|
|
|
|
logic_len: self.logic_ops.len(),
|
|
|
|
|
// This is technically a lower-bound, as we may fill gaps,
|
|
|
|
|
// but this gives a relatively good estimate.
|
|
|
|
|
memory_len: self.memory_ops.len(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns the number of operations for each STARK module.
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn checkpoint(&self) -> TraceCheckpoint {
|
2022-11-28 13:19:40 -08:00
|
|
|
TraceCheckpoint {
|
Cross-table lookup for arithmetic stark (#905)
* First draft of linking arithmetic Stark into the CTL mechanism.
* Handle {ADD,SUB,MUL}FP254 operations explicitly in `modular.rs`.
* Adjust argument order; add tests.
* Add CTLs for ADD, MUL, SUB, LT and GT.
* Add CTLs for {ADD,MUL,SUB}MOD, DIV and MOD.
* Add CTLs for {ADD,MUL,SUB}FP254 operations.
* Refactor the CPU/arithmetic CTL mapping; add some documentation.
* Minor comment fixes.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Merge `*FP254` CTL into main CTL; rename some registers.
* Connect extra argument from CPU in binary ops to facilitate combining with ternary ops.
* Merge modular ops CTL into main CTL.
* Refactor DIV and MOD code into its own module.
* Merge DIV and MOD into arithmetic CTL.
* Clippy.
* Fixes related to merge.
* Simplify register naming.
* Generate u16 BN254 modulus limbs at compile time.
* Clippy.
* Add degree bits ranges for Arithmetic table.
2023-05-11 03:29:06 +10:00
|
|
|
arithmetic_len: self.arithmetic_ops.len(),
|
2023-09-12 14:45:37 -04:00
|
|
|
byte_packing_len: self.byte_packing_ops.len(),
|
2022-11-28 13:19:40 -08:00
|
|
|
cpu_len: self.cpu.len(),
|
2022-12-03 22:44:54 -08:00
|
|
|
keccak_len: self.keccak_inputs.len(),
|
|
|
|
|
keccak_sponge_len: self.keccak_sponge_ops.len(),
|
2022-11-30 12:55:41 -08:00
|
|
|
logic_len: self.logic_ops.len(),
|
|
|
|
|
memory_len: self.memory_ops.len(),
|
2022-11-28 13:19:40 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn rollback(&mut self, checkpoint: TraceCheckpoint) {
|
Cross-table lookup for arithmetic stark (#905)
* First draft of linking arithmetic Stark into the CTL mechanism.
* Handle {ADD,SUB,MUL}FP254 operations explicitly in `modular.rs`.
* Adjust argument order; add tests.
* Add CTLs for ADD, MUL, SUB, LT and GT.
* Add CTLs for {ADD,MUL,SUB}MOD, DIV and MOD.
* Add CTLs for {ADD,MUL,SUB}FP254 operations.
* Refactor the CPU/arithmetic CTL mapping; add some documentation.
* Minor comment fixes.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Merge `*FP254` CTL into main CTL; rename some registers.
* Connect extra argument from CPU in binary ops to facilitate combining with ternary ops.
* Merge modular ops CTL into main CTL.
* Refactor DIV and MOD code into its own module.
* Merge DIV and MOD into arithmetic CTL.
* Clippy.
* Fixes related to merge.
* Simplify register naming.
* Generate u16 BN254 modulus limbs at compile time.
* Clippy.
* Add degree bits ranges for Arithmetic table.
2023-05-11 03:29:06 +10:00
|
|
|
self.arithmetic_ops.truncate(checkpoint.arithmetic_len);
|
2023-09-12 14:45:37 -04:00
|
|
|
self.byte_packing_ops.truncate(checkpoint.byte_packing_len);
|
2022-11-28 13:19:40 -08:00
|
|
|
self.cpu.truncate(checkpoint.cpu_len);
|
2022-12-03 22:44:54 -08:00
|
|
|
self.keccak_inputs.truncate(checkpoint.keccak_len);
|
|
|
|
|
self.keccak_sponge_ops
|
|
|
|
|
.truncate(checkpoint.keccak_sponge_len);
|
2022-11-30 12:55:41 -08:00
|
|
|
self.logic_ops.truncate(checkpoint.logic_len);
|
|
|
|
|
self.memory_ops.truncate(checkpoint.memory_len);
|
2022-11-28 13:19:40 -08:00
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn mem_ops_since(&self, checkpoint: TraceCheckpoint) -> &[MemoryOp] {
|
2022-11-30 18:12:31 -08:00
|
|
|
&self.memory_ops[checkpoint.memory_len..]
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn push_cpu(&mut self, val: CpuColumnsView<T>) {
|
2022-11-28 13:19:40 -08:00
|
|
|
self.cpu.push(val);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn push_logic(&mut self, op: logic::Operation) {
|
2022-11-30 15:25:07 -08:00
|
|
|
self.logic_ops.push(op);
|
2022-11-28 13:19:40 -08:00
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn push_arithmetic(&mut self, op: arithmetic::Operation) {
|
Cross-table lookup for arithmetic stark (#905)
* First draft of linking arithmetic Stark into the CTL mechanism.
* Handle {ADD,SUB,MUL}FP254 operations explicitly in `modular.rs`.
* Adjust argument order; add tests.
* Add CTLs for ADD, MUL, SUB, LT and GT.
* Add CTLs for {ADD,MUL,SUB}MOD, DIV and MOD.
* Add CTLs for {ADD,MUL,SUB}FP254 operations.
* Refactor the CPU/arithmetic CTL mapping; add some documentation.
* Minor comment fixes.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Merge `*FP254` CTL into main CTL; rename some registers.
* Connect extra argument from CPU in binary ops to facilitate combining with ternary ops.
* Merge modular ops CTL into main CTL.
* Refactor DIV and MOD code into its own module.
* Merge DIV and MOD into arithmetic CTL.
* Clippy.
* Fixes related to merge.
* Simplify register naming.
* Generate u16 BN254 modulus limbs at compile time.
* Clippy.
* Add degree bits ranges for Arithmetic table.
2023-05-11 03:29:06 +10:00
|
|
|
self.arithmetic_ops.push(op);
|
2022-11-28 13:19:40 -08:00
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn push_memory(&mut self, op: MemoryOp) {
|
2022-12-01 12:06:29 -08:00
|
|
|
self.memory_ops.push(op);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn push_byte_packing(&mut self, op: BytePackingOp) {
|
2023-09-12 14:45:37 -04:00
|
|
|
self.byte_packing_ops.push(op);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn push_keccak(
|
|
|
|
|
&mut self,
|
|
|
|
|
input: [u64; keccak::keccak_stark::NUM_INPUTS],
|
|
|
|
|
clock: usize,
|
|
|
|
|
) {
|
2023-10-06 15:49:57 -04:00
|
|
|
self.keccak_inputs.push((input, clock));
|
2022-12-02 13:56:52 -08:00
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn push_keccak_bytes(&mut self, input: [u8; KECCAK_WIDTH_BYTES], clock: usize) {
|
2022-12-02 13:56:52 -08:00
|
|
|
let chunks = input
|
|
|
|
|
.chunks(size_of::<u64>())
|
|
|
|
|
.map(|chunk| u64::from_le_bytes(chunk.try_into().unwrap()))
|
|
|
|
|
.collect_vec()
|
|
|
|
|
.try_into()
|
|
|
|
|
.unwrap();
|
2023-10-06 15:49:57 -04:00
|
|
|
self.push_keccak(chunks, clock);
|
2022-12-02 13:56:52 -08:00
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn push_keccak_sponge(&mut self, op: KeccakSpongeOp) {
|
2022-12-01 12:06:29 -08:00
|
|
|
self.keccak_sponge_ops.push(op);
|
2022-11-28 13:19:40 -08:00
|
|
|
}
|
|
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn clock(&self) -> usize {
|
2022-11-28 13:19:40 -08:00
|
|
|
self.cpu.len()
|
|
|
|
|
}
|
2022-11-30 12:55:41 -08:00
|
|
|
|
2023-11-13 09:26:56 -05:00
|
|
|
pub(crate) fn into_tables<const D: usize>(
|
2022-11-30 12:55:41 -08:00
|
|
|
self,
|
|
|
|
|
all_stark: &AllStark<T, D>,
|
|
|
|
|
config: &StarkConfig,
|
|
|
|
|
timing: &mut TimingTree,
|
|
|
|
|
) -> [Vec<PolynomialValues<T>>; NUM_TABLES]
|
|
|
|
|
where
|
|
|
|
|
T: RichField + Extendable<D>,
|
|
|
|
|
{
|
2022-12-01 16:23:39 -08:00
|
|
|
let cap_elements = config.fri_config.num_cap_elements();
|
2022-11-30 12:55:41 -08:00
|
|
|
let Traces {
|
Cross-table lookup for arithmetic stark (#905)
* First draft of linking arithmetic Stark into the CTL mechanism.
* Handle {ADD,SUB,MUL}FP254 operations explicitly in `modular.rs`.
* Adjust argument order; add tests.
* Add CTLs for ADD, MUL, SUB, LT and GT.
* Add CTLs for {ADD,MUL,SUB}MOD, DIV and MOD.
* Add CTLs for {ADD,MUL,SUB}FP254 operations.
* Refactor the CPU/arithmetic CTL mapping; add some documentation.
* Minor comment fixes.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Merge `*FP254` CTL into main CTL; rename some registers.
* Connect extra argument from CPU in binary ops to facilitate combining with ternary ops.
* Merge modular ops CTL into main CTL.
* Refactor DIV and MOD code into its own module.
* Merge DIV and MOD into arithmetic CTL.
* Clippy.
* Fixes related to merge.
* Simplify register naming.
* Generate u16 BN254 modulus limbs at compile time.
* Clippy.
* Add degree bits ranges for Arithmetic table.
2023-05-11 03:29:06 +10:00
|
|
|
arithmetic_ops,
|
2023-09-12 14:45:37 -04:00
|
|
|
byte_packing_ops,
|
2022-11-30 12:55:41 -08:00
|
|
|
cpu,
|
|
|
|
|
logic_ops,
|
|
|
|
|
memory_ops,
|
|
|
|
|
keccak_inputs,
|
2022-12-03 11:21:31 -08:00
|
|
|
keccak_sponge_ops,
|
2022-11-30 12:55:41 -08:00
|
|
|
} = self;
|
|
|
|
|
|
Cross-table lookup for arithmetic stark (#905)
* First draft of linking arithmetic Stark into the CTL mechanism.
* Handle {ADD,SUB,MUL}FP254 operations explicitly in `modular.rs`.
* Adjust argument order; add tests.
* Add CTLs for ADD, MUL, SUB, LT and GT.
* Add CTLs for {ADD,MUL,SUB}MOD, DIV and MOD.
* Add CTLs for {ADD,MUL,SUB}FP254 operations.
* Refactor the CPU/arithmetic CTL mapping; add some documentation.
* Minor comment fixes.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Merge `*FP254` CTL into main CTL; rename some registers.
* Connect extra argument from CPU in binary ops to facilitate combining with ternary ops.
* Merge modular ops CTL into main CTL.
* Refactor DIV and MOD code into its own module.
* Merge DIV and MOD into arithmetic CTL.
* Clippy.
* Fixes related to merge.
* Simplify register naming.
* Generate u16 BN254 modulus limbs at compile time.
* Clippy.
* Add degree bits ranges for Arithmetic table.
2023-05-11 03:29:06 +10:00
|
|
|
let arithmetic_trace = timed!(
|
|
|
|
|
timing,
|
|
|
|
|
"generate arithmetic trace",
|
|
|
|
|
all_stark.arithmetic_stark.generate_trace(arithmetic_ops)
|
|
|
|
|
);
|
2023-09-12 14:45:37 -04:00
|
|
|
let byte_packing_trace = timed!(
|
|
|
|
|
timing,
|
|
|
|
|
"generate byte packing trace",
|
|
|
|
|
all_stark
|
|
|
|
|
.byte_packing_stark
|
|
|
|
|
.generate_trace(byte_packing_ops, cap_elements, timing)
|
|
|
|
|
);
|
2022-11-30 12:55:41 -08:00
|
|
|
let cpu_rows = cpu.into_iter().map(|x| x.into()).collect();
|
|
|
|
|
let cpu_trace = trace_rows_to_poly_values(cpu_rows);
|
2022-12-09 12:51:42 -08:00
|
|
|
let keccak_trace = timed!(
|
|
|
|
|
timing,
|
|
|
|
|
"generate Keccak trace",
|
2022-12-01 17:14:40 -08:00
|
|
|
all_stark
|
|
|
|
|
.keccak_stark
|
2022-12-09 12:51:42 -08:00
|
|
|
.generate_trace(keccak_inputs, cap_elements, timing)
|
|
|
|
|
);
|
|
|
|
|
let keccak_sponge_trace = timed!(
|
|
|
|
|
timing,
|
|
|
|
|
"generate Keccak sponge trace",
|
2022-12-03 11:21:31 -08:00
|
|
|
all_stark
|
|
|
|
|
.keccak_sponge_stark
|
2022-12-09 12:51:42 -08:00
|
|
|
.generate_trace(keccak_sponge_ops, cap_elements, timing)
|
|
|
|
|
);
|
|
|
|
|
let logic_trace = timed!(
|
|
|
|
|
timing,
|
|
|
|
|
"generate logic trace",
|
|
|
|
|
all_stark
|
|
|
|
|
.logic_stark
|
|
|
|
|
.generate_trace(logic_ops, cap_elements, timing)
|
|
|
|
|
);
|
|
|
|
|
let memory_trace = timed!(
|
|
|
|
|
timing,
|
|
|
|
|
"generate memory trace",
|
|
|
|
|
all_stark.memory_stark.generate_trace(memory_ops, timing)
|
|
|
|
|
);
|
2022-11-30 12:55:41 -08:00
|
|
|
|
|
|
|
|
[
|
Cross-table lookup for arithmetic stark (#905)
* First draft of linking arithmetic Stark into the CTL mechanism.
* Handle {ADD,SUB,MUL}FP254 operations explicitly in `modular.rs`.
* Adjust argument order; add tests.
* Add CTLs for ADD, MUL, SUB, LT and GT.
* Add CTLs for {ADD,MUL,SUB}MOD, DIV and MOD.
* Add CTLs for {ADD,MUL,SUB}FP254 operations.
* Refactor the CPU/arithmetic CTL mapping; add some documentation.
* Minor comment fixes.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Combine addcy CTLs at the expense of repeated constraint evaluation.
* Merge `*FP254` CTL into main CTL; rename some registers.
* Connect extra argument from CPU in binary ops to facilitate combining with ternary ops.
* Merge modular ops CTL into main CTL.
* Refactor DIV and MOD code into its own module.
* Merge DIV and MOD into arithmetic CTL.
* Clippy.
* Fixes related to merge.
* Simplify register naming.
* Generate u16 BN254 modulus limbs at compile time.
* Clippy.
* Add degree bits ranges for Arithmetic table.
2023-05-11 03:29:06 +10:00
|
|
|
arithmetic_trace,
|
2023-09-12 14:45:37 -04:00
|
|
|
byte_packing_trace,
|
2022-11-30 12:55:41 -08:00
|
|
|
cpu_trace,
|
|
|
|
|
keccak_trace,
|
2022-12-03 11:21:31 -08:00
|
|
|
keccak_sponge_trace,
|
2022-11-30 12:55:41 -08:00
|
|
|
logic_trace,
|
|
|
|
|
memory_trace,
|
|
|
|
|
]
|
|
|
|
|
}
|
2022-11-28 13:19:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T: Copy> Default for Traces<T> {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self::new()
|
2022-11-15 09:26:54 -08:00
|
|
|
}
|
|
|
|
|
}
|