Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions stwo_cairo_prover/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions stwo_cairo_prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ cairo-air = { path = "crates/cairo-air" }
stwo-cairo-serialize = { path = "crates/cairo-serialize", version = "~0.1.0" }
# TODO(Ohad): re export stwo from constraint-framework.
# TODO(Ohad): separate cairo-air from prover code and use prover features only in the prover crate.
stwo = { git = "https://github.com/starkware-libs/stwo", rev = "5f177b2fe", features = [
stwo = { git = "https://github.com/starkware-libs/stwo", rev = "699ae6e", features = [
"parallel",
"prover",
], default-features = false }
stwo-constraint-framework = { git = "https://github.com/starkware-libs/stwo", rev = "5f177b2fe", features = [
stwo-constraint-framework = { git = "https://github.com/starkware-libs/stwo", rev = "699ae6e", features = [
"parallel",
"prover",
] }
stwo-air-utils-derive = { git = "https://github.com/starkware-libs/stwo", rev = "5f177b2fe" }
stwo-air-utils = { git = "https://github.com/starkware-libs/stwo", rev = "5f177b2fe" }
stwo-air-utils-derive = { git = "https://github.com/starkware-libs/stwo", rev = "699ae6e" }
stwo-air-utils = { git = "https://github.com/starkware-libs/stwo", rev = "699ae6e" }
test-case = "3.3.1"
thiserror = { version = "2.0.12", default-features = false }
tracing = "0.1.40"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ use cairo_air::builtins_air::BuiltinComponents;
use cairo_air::opcodes_air::OpcodeComponents;
use cairo_air::range_checks_air::RangeChecksComponents;
use itertools::{chain, Itertools};
use num_traits::One;
use num_traits::{One, Zero};
use stwo::core::channel::MerkleChannel;
use stwo::core::fields::m31::M31;
use stwo::core::fields::m31::{BaseField, M31};
use stwo::core::pcs::TreeVec;
use stwo::core::poly::circle::CanonicCoset;
use stwo::prover::backend::simd::SimdBackend;
use stwo::prover::backend::{BackendForChannel, Column};
use stwo::prover::backend::{BackendForChannel, Col, Column};
use stwo::prover::poly::circle::CircleCoefficients;
use stwo::prover::CommitmentSchemeProver;
use stwo_cairo_common::prover_types::felt::split_f252;
use stwo_constraint_framework::relation_tracker::{
Expand Down Expand Up @@ -44,7 +45,9 @@ where
interaction_tree
.iter()
.map(|poly| {
poly.evaluate(CanonicCoset::new(poly.log_size()).circle_domain())
let coeffs = reduce_degree(poly.evals.clone().interpolate());
coeffs
.evaluate(CanonicCoset::new(coeffs.log_size()).circle_domain())
.values
.to_cpu()
})
Expand Down Expand Up @@ -318,3 +321,19 @@ fn add_to_relation_entries_many<E: FrameworkEval>(
.flat_map(|x| add_to_relation_entries(x, trace))
.collect()
}

/// Reduces the polynomial to a minimal degree polynomial that evaluates to the same values.
pub fn reduce_degree(coeffs: CircleCoefficients<SimdBackend>) -> CircleCoefficients<SimdBackend> {
let mut new_log_size = coeffs.log_size();
while new_log_size > 1 {
if ((1 << (new_log_size - 1))..(1 << new_log_size))
.any(|i| coeffs.coeffs.at(i) != BaseField::zero())
{
break;
}
new_log_size -= 1;
}
CircleCoefficients::new(Col::<SimdBackend, BaseField>::from_iter(
coeffs.coeffs.to_cpu()[..1 << new_log_size].iter().copied(),
))
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ mod tests {
&mut CommitmentSchemeProver::<SimdBackend, Blake2sMerkleChannel>::new(
config, &twiddles,
);
commitment_scheme.set_store_polynomials_coefficients();

// Preprocessed trace.
let preproceseed_column_0 = RangeCheck::new(log_ranges, 0).gen_column_simd();
Expand Down Expand Up @@ -278,10 +279,12 @@ mod tests {
interaction_claim.claimed_sum,
);

let trace_polys = commitment_scheme
.trees
.as_ref()
.map(|t| t.polynomials.iter().cloned().collect_vec());
let trace_polys = commitment_scheme.trees.as_ref().map(|t| {
t.polynomials
.iter()
.map(|poly| poly.coeffs.clone().unwrap())
.collect_vec()
});

let component_eval = component.deref();
stwo_constraint_framework::assert_constraints_on_polys(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ where
log_blowup_factor,
&mut MC::C::default(),
&twiddles,
false,
);

commitment_scheme.commitment.root()
Expand Down
Loading