Skip to content

Commit

Permalink
Remove InteractionElements and LookupValues
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmilson committed Sep 9, 2024
1 parent 1ee6a70 commit 8a565ba
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 60 deletions.
5 changes: 1 addition & 4 deletions crates/prover/src/constraint_framework/logup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ impl LogupTraceGenerator {
.into_iter()
.flat_map(|eval| {
eval.columns.map(|c| {
CircleEvaluation::<SimdBackend, _, BitReversedOrder>::new(
CanonicCoset::new(self.log_size).circle_domain(),
c,
)
CircleEvaluation::new(CanonicCoset::new(self.log_size).circle_domain(), c)
})
})
.collect_vec();
Expand Down
9 changes: 2 additions & 7 deletions crates/prover/src/core/backend/simd/quotients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,8 @@ mod tests {
}];
let cpu_columns = columns
.iter()
.map(|c| {
CircleEvaluation::<CpuBackend, _, BitReversedOrder>::new(
c.domain,
c.values.to_cpu(),
)
})
.collect::<Vec<_>>();
.map(|c| CircleEvaluation::new(c.domain, c.values.to_cpu()))
.collect_vec();
let cpu_result = CpuBackend::accumulate_quotients(
domain,
&cpu_columns.iter().collect_vec(),
Expand Down
20 changes: 9 additions & 11 deletions crates/prover/src/core/pcs/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,30 +167,28 @@ pub struct TreeBuilder<'a, 'b, B: BackendForChannel<MC>, MC: MerkleChannel> {
impl<'a, 'b, B: BackendForChannel<MC>, MC: MerkleChannel> TreeBuilder<'a, 'b, B, MC> {
pub fn extend_evals(
&mut self,
columns: ColumnVec<CircleEvaluation<B, BaseField, BitReversedOrder>>,
columns: impl IntoIterator<Item = CircleEvaluation<B, BaseField, BitReversedOrder>>,
) -> TreeSubspan {
let span = span!(Level::INFO, "Interpolation for commitment").entered();
let col_start = self.polys.len();
let polys = columns
.into_iter()
.map(|eval| eval.interpolate_with_twiddles(self.commitment_scheme.twiddles))
.collect_vec();
span.exit();
self.polys.extend(polys);
TreeSubspan {
tree_index: self.tree_index,
col_start,
col_end: self.polys.len(),
}
self.extend_polys(polys)
}

pub fn extend_polys(&mut self, polys: ColumnVec<CirclePoly<B>>) -> TreeSubspan {
pub fn extend_polys(
&mut self,
columns: impl IntoIterator<Item = CirclePoly<B>>,
) -> TreeSubspan {
let col_start = self.polys.len();
self.polys.extend(polys);
self.polys.extend(columns);
let col_end = self.polys.len();
TreeSubspan {
tree_index: self.tree_index,
col_start,
col_end: self.polys.len(),
col_end,
}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/prover/src/core/poly/circle/secure_poly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ impl<B: PolyOps> SecureCirclePoly<B> {
let columns = polys.map(|poly| poly.evaluate_with_twiddles(domain, twiddles).values);
SecureEvaluation::new(domain, SecureColumnByCoords { columns })
}

pub fn into_coordinate_polys(self) -> [CirclePoly<B>; SECURE_EXTENSION_DEGREE] {
self.0
}
}

impl<B: FieldOps<BaseField>> Deref for SecureCirclePoly<B> {
Expand Down
16 changes: 2 additions & 14 deletions crates/prover/src/core/prover/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ use super::fields::secure_column::SECURE_EXTENSION_DEGREE;
use super::fri::FriVerificationError;
use super::pcs::{CommitmentSchemeProof, TreeVec};
use super::vcs::ops::MerkleHasher;
use crate::core::backend::CpuBackend;
use crate::core::channel::Channel;
use crate::core::circle::CirclePoint;
use crate::core::fields::qm31::SecureField;
use crate::core::pcs::{CommitmentSchemeProver, CommitmentSchemeVerifier};
use crate::core::poly::circle::CircleEvaluation;
use crate::core::poly::BitReversedOrder;
use crate::core::vcs::verifier::MerkleVerificationError;

#[derive(Debug, Serialize, Deserialize)]
Expand All @@ -26,14 +23,6 @@ pub struct StarkProof<H: MerkleHasher> {
pub commitment_scheme_proof: CommitmentSchemeProof<H>,
}

#[derive(Debug)]
pub struct AdditionalProofData {
pub composition_polynomial_oods_value: SecureField,
pub composition_polynomial_random_coeff: SecureField,
pub oods_point: CirclePoint<SecureField>,
pub oods_quotients: Vec<CircleEvaluation<CpuBackend, SecureField, BitReversedOrder>>,
}

pub fn prove<B: BackendForChannel<MC>, MC: MerkleChannel>(
components: &[&dyn ComponentProver<B>],
channel: &mut MC::C,
Expand All @@ -47,12 +36,11 @@ pub fn prove<B: BackendForChannel<MC>, MC: MerkleChannel>(

let span = span!(Level::INFO, "Composition").entered();
let span1 = span!(Level::INFO, "Generation").entered();
let composition_polynomial_poly =
component_provers.compute_composition_polynomial(random_coeff, &trace);
let composition_poly = component_provers.compute_composition_polynomial(random_coeff, &trace);
span1.exit();

let mut tree_builder = commitment_scheme.tree_builder();
tree_builder.extend_polys(composition_polynomial_poly.to_vec());
tree_builder.extend_polys(composition_poly.into_coordinate_polys());
tree_builder.commit(channel);
span.exit();

Expand Down
4 changes: 1 addition & 3 deletions crates/prover/src/examples/blake/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,7 @@ where

// Prove constraints.
let components = BlakeComponents::new(&stmt0, &all_elements, &stmt1);
let stark_proof =
prove::<SimdBackend, _>(&components.component_provers(), channel, commitment_scheme)
.unwrap();
let stark_proof = prove(&components.component_provers(), channel, commitment_scheme).unwrap();

BlakeProof {
stmt0,
Expand Down
4 changes: 2 additions & 2 deletions crates/prover/src/examples/blake/round/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ pub fn generate_trace(
generator
.trace
.into_iter()
.map(|eval| CircleEvaluation::<SimdBackend, _, BitReversedOrder>::new(domain, eval))
.collect_vec(),
.map(|eval| CircleEvaluation::new(domain, eval))
.collect(),
BlakeRoundLookupData {
xor_lookups: generator.xor_lookups,
round_lookup: generator.round_lookup,
Expand Down
4 changes: 2 additions & 2 deletions crates/prover/src/examples/blake/scheduler/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ pub fn gen_trace(
let domain = CanonicCoset::new(log_size).circle_domain();
let trace = trace
.into_iter()
.map(|eval| CircleEvaluation::<SimdBackend, _, BitReversedOrder>::new(domain, eval))
.collect_vec();
.map(|eval| CircleEvaluation::new(domain, eval))
.collect();

(trace, lookup_data, round_inputs)
}
Expand Down
25 changes: 11 additions & 14 deletions crates/prover/src/examples/plonk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ pub fn gen_trace(
&circuit.c_val,
]
.into_iter()
.map(|eval| CircleEvaluation::<SimdBackend, _, BitReversedOrder>::new(domain, eval.clone()))
.collect_vec()
.map(|eval| CircleEvaluation::new(domain, eval.clone()))
.collect()
}

pub fn gen_interaction_trace(
Expand Down Expand Up @@ -207,17 +207,14 @@ pub fn prove_fibonacci_plonk(
// Constant trace.
let span = span!(Level::INFO, "Constant").entered();
let mut tree_builder = commitment_scheme.tree_builder();
let constants_trace_location = tree_builder.extend_evals(
chain!([circuit.a_wire, circuit.b_wire, circuit.c_wire, circuit.op]
.into_iter()
.map(|col| {
CircleEvaluation::<SimdBackend, _, BitReversedOrder>::new(
CanonicCoset::new(log_n_rows).circle_domain(),
col,
)
}))
.collect_vec(),
);
let constants_trace_location = tree_builder.extend_evals(chain!([
circuit.a_wire,
circuit.b_wire,
circuit.c_wire,
circuit.op
]
.into_iter()
.map(|col| CircleEvaluation::new(CanonicCoset::new(log_n_rows).circle_domain(), col))));
tree_builder.commit(channel);
span.exit();

Expand All @@ -243,7 +240,7 @@ pub fn prove_fibonacci_plonk(
component.evaluate(eval);
});

let proof = prove::<SimdBackend, _>(&[&component], channel, commitment_scheme).unwrap();
let proof = prove(&[&component], channel, commitment_scheme).unwrap();

(component, proof)
}
Expand Down
7 changes: 4 additions & 3 deletions crates/prover/src/examples/poseidon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ pub fn gen_trace(
let domain = CanonicCoset::new(log_size).circle_domain();
let trace = trace
.into_iter()
.map(|eval| CircleEvaluation::<SimdBackend, _, BitReversedOrder>::new(domain, eval))
.collect_vec();
.map(|eval| CircleEvaluation::new(domain, eval))
.collect();
(trace, lookup_data)
}

Expand Down Expand Up @@ -367,7 +367,8 @@ pub fn prove_poseidon(
claimed_sum,
},
);
let proof = prove::<SimdBackend, _>(&[&component], channel, commitment_scheme).unwrap();
let proof = prove(&[&component], channel, commitment_scheme).unwrap();

(component, proof)
}

Expand Down

0 comments on commit 8a565ba

Please sign in to comment.