mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-10 09:43:09 +00:00
Fix indices in CTL functions
This commit is contained in:
parent
f97deab8a7
commit
1590c1d0be
@ -537,16 +537,12 @@ pub(crate) fn verify_cross_table_lookups<F: RichField + Extendable<D>, const D:
|
||||
config: &StarkConfig,
|
||||
) -> Result<()> {
|
||||
let mut ctl_zs_openings = ctl_zs_lasts.iter().map(|v| v.iter()).collect::<Vec<_>>();
|
||||
for (
|
||||
CrossTableLookup {
|
||||
looking_tables,
|
||||
looked_table,
|
||||
},
|
||||
extra_product_vec,
|
||||
) in cross_table_lookups
|
||||
.iter()
|
||||
.zip(ctl_extra_looking_products.iter())
|
||||
for CrossTableLookup {
|
||||
looking_tables,
|
||||
looked_table,
|
||||
} in cross_table_lookups.iter()
|
||||
{
|
||||
let extra_product_vec = &ctl_extra_looking_products[looked_table.table as usize];
|
||||
for c in 0..config.num_challenges {
|
||||
let mut looking_zs_prod = looking_tables
|
||||
.iter()
|
||||
@ -575,16 +571,12 @@ pub(crate) fn verify_cross_table_lookups_circuit<F: RichField + Extendable<D>, c
|
||||
inner_config: &StarkConfig,
|
||||
) {
|
||||
let mut ctl_zs_openings = ctl_zs_lasts.iter().map(|v| v.iter()).collect::<Vec<_>>();
|
||||
for (
|
||||
CrossTableLookup {
|
||||
looking_tables,
|
||||
looked_table,
|
||||
},
|
||||
extra_product_vec,
|
||||
) in cross_table_lookups
|
||||
.into_iter()
|
||||
.zip(ctl_extra_looking_products.iter())
|
||||
for CrossTableLookup {
|
||||
looking_tables,
|
||||
looked_table,
|
||||
} in cross_table_lookups.into_iter()
|
||||
{
|
||||
let extra_product_vec = &ctl_extra_looking_products[looked_table.table as usize];
|
||||
for c in 0..inner_config.num_challenges {
|
||||
let mut looking_zs_prod = builder.mul_many(
|
||||
looking_tables
|
||||
|
||||
@ -467,40 +467,40 @@ where
|
||||
|
||||
// Extra products to add to the looked last value
|
||||
let mut extra_looking_products = Vec::new();
|
||||
for _ in 0..NUM_TABLES {
|
||||
extra_looking_products.push(Vec::new());
|
||||
}
|
||||
|
||||
// Arithmetic
|
||||
extra_looking_products.push(Vec::new());
|
||||
for _ in 0..stark_config.num_challenges {
|
||||
extra_looking_products[0].push(builder.constant(F::ONE));
|
||||
extra_looking_products[Table::Arithmetic as usize].push(builder.constant(F::ONE));
|
||||
}
|
||||
|
||||
// KeccakSponge
|
||||
extra_looking_products.push(Vec::new());
|
||||
for _ in 0..stark_config.num_challenges {
|
||||
extra_looking_products[1].push(builder.constant(F::ONE));
|
||||
extra_looking_products[Table::KeccakSponge as usize].push(builder.constant(F::ONE));
|
||||
}
|
||||
|
||||
// Keccak
|
||||
extra_looking_products.push(Vec::new());
|
||||
for _ in 0..stark_config.num_challenges {
|
||||
extra_looking_products[2].push(builder.constant(F::ONE));
|
||||
extra_looking_products[Table::Keccak as usize].push(builder.constant(F::ONE));
|
||||
}
|
||||
|
||||
// Logic
|
||||
extra_looking_products.push(Vec::new());
|
||||
for _ in 0..stark_config.num_challenges {
|
||||
extra_looking_products[3].push(builder.constant(F::ONE));
|
||||
extra_looking_products[Table::Logic as usize].push(builder.constant(F::ONE));
|
||||
}
|
||||
|
||||
// Memory
|
||||
extra_looking_products.push(Vec::new());
|
||||
for c in 0..stark_config.num_challenges {
|
||||
extra_looking_products[4].push(Self::get_memory_extra_looking_products_circuit(
|
||||
&mut builder,
|
||||
public_values,
|
||||
cpu_trace_len,
|
||||
ctl_challenges.challenges[c],
|
||||
));
|
||||
extra_looking_products[Table::Memory as usize].push(
|
||||
Self::get_memory_extra_looking_products_circuit(
|
||||
&mut builder,
|
||||
public_values,
|
||||
cpu_trace_len,
|
||||
ctl_challenges.challenges[c],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Verify the CTL checks.
|
||||
|
||||
@ -9,7 +9,7 @@ use plonky2::hash::hash_types::RichField;
|
||||
use plonky2::plonk::config::GenericConfig;
|
||||
use plonky2::plonk::plonk_common::reduce_with_powers;
|
||||
|
||||
use crate::all_stark::{AllStark, Table};
|
||||
use crate::all_stark::{AllStark, Table, NUM_TABLES};
|
||||
use crate::arithmetic::arithmetic_stark::ArithmeticStark;
|
||||
use crate::config::StarkConfig;
|
||||
use crate::constraint_consumer::ConstraintConsumer;
|
||||
@ -114,30 +114,34 @@ where
|
||||
|
||||
// Extra products to add to the looked last value.
|
||||
let mut extra_looking_products = Vec::new();
|
||||
for _ in 0..NUM_TABLES {
|
||||
extra_looking_products.push(Vec::new());
|
||||
}
|
||||
|
||||
// Arithmetic
|
||||
for _ in 0..config.num_challenges {
|
||||
extra_looking_products[Table::Arithmetic as usize].push(F::ONE);
|
||||
}
|
||||
|
||||
// KeccakSponge
|
||||
extra_looking_products.push(Vec::new());
|
||||
for _ in 0..config.num_challenges {
|
||||
extra_looking_products[0].push(F::ONE);
|
||||
extra_looking_products[Table::KeccakSponge as usize].push(F::ONE);
|
||||
}
|
||||
|
||||
// Keccak
|
||||
extra_looking_products.push(Vec::new());
|
||||
for _ in 0..config.num_challenges {
|
||||
extra_looking_products[1].push(F::ONE);
|
||||
extra_looking_products[Table::Keccak as usize].push(F::ONE);
|
||||
}
|
||||
|
||||
// Logic
|
||||
extra_looking_products.push(Vec::new());
|
||||
for _ in 0..config.num_challenges {
|
||||
extra_looking_products[2].push(F::ONE);
|
||||
extra_looking_products[Table::Logic as usize].push(F::ONE);
|
||||
}
|
||||
|
||||
// Memory
|
||||
extra_looking_products.push(Vec::new());
|
||||
let cpu_trace_len = 1 << all_proof.stark_proofs[0].proof.recover_degree_bits(config);
|
||||
let cpu_trace_len = 1 << all_proof.stark_proofs[1].proof.recover_degree_bits(config);
|
||||
for c in 0..config.num_challenges {
|
||||
extra_looking_products[3].push(get_memory_extra_looking_products(
|
||||
extra_looking_products[Table::Memory as usize].push(get_memory_extra_looking_products(
|
||||
&public_values,
|
||||
cpu_trace_len,
|
||||
ctl_challenges.challenges[c],
|
||||
|
||||
@ -95,7 +95,7 @@ fn test_empty_txn_list() -> anyhow::Result<()> {
|
||||
|
||||
verify_proof(&all_stark, proof.clone(), &config)?;
|
||||
|
||||
let cpu_trace_len = 1 << proof.stark_proofs[0].proof.recover_degree_bits(&config);
|
||||
let cpu_trace_len = 1 << proof.stark_proofs[1].proof.recover_degree_bits(&config);
|
||||
let all_circuits = AllRecursiveCircuits::<F, C, D>::new(
|
||||
&all_stark,
|
||||
&[16..17, 14..15, 14..15, 9..10, 12..13, 18..19], // Minimal ranges to prove an empty list
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user