Skip to content

Commit 08be71c

Browse files
authored
Make Prover generic over the ConstraintCommitment type (#343)
1 parent ee2089a commit 08be71c

File tree

22 files changed

+559
-186
lines changed

22 files changed

+559
-186
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ impl Prover for WorkProver {
270270
type TraceLde<E: FieldElement<BaseField = BaseElement>> = DefaultTraceLde<E, Blake3>;
271271
type ConstraintEvaluator<'a, E: FieldElement<BaseField = BaseElement>> =
272272
DefaultConstraintEvaluator<'a, WorkAir, E>;
273+
type ConstraintCommitment<E: FieldElement<BaseField = Self::BaseField>> =
274+
DefaultConstraintCommitment<E, H, Self::VC>;
273275

274276
// Our public inputs consist of the first and last value in the execution trace.
275277
fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs {
@@ -300,6 +302,22 @@ impl Prover for WorkProver {
300302
DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients)
301303
}
302304

305+
// We'll use the default constraint commitment.
306+
fn build_constraint_commitment<E: FieldElement<BaseField = Self::BaseField>>(
307+
&self,
308+
composition_poly_trace: CompositionPolyTrace<E>,
309+
num_constraint_composition_columns: usize,
310+
domain: &StarkDomain<Self::BaseField>,
311+
partition_options: PartitionOptions,
312+
) -> (Self::ConstraintCommitment<E>, CompositionPoly<E>) {
313+
DefaultConstraintCommitment::new(
314+
composition_poly_trace,
315+
num_constraint_composition_columns,
316+
domain,
317+
partition_options,
318+
)
319+
}
320+
303321
fn options(&self) -> &ProofOptions {
304322
&self.options
305323
}

examples/src/fibonacci/fib2/prover.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// LICENSE file in the root directory of this source tree.
55

66
use winterfell::{
7-
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, ConstraintCompositionCoefficients,
8-
DefaultConstraintEvaluator, DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo,
9-
TracePolyTable, TraceTable,
7+
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, CompositionPoly, CompositionPolyTrace,
8+
ConstraintCompositionCoefficients, DefaultConstraintCommitment, DefaultConstraintEvaluator,
9+
DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo, TracePolyTable, TraceTable,
1010
};
1111

1212
use super::{
@@ -60,6 +60,8 @@ where
6060
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
6161
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> =
6262
DefaultTraceLde<E, Self::HashFn, Self::VC>;
63+
type ConstraintCommitment<E: FieldElement<BaseField = Self::BaseField>> =
64+
DefaultConstraintCommitment<E, H, Self::VC>;
6365
type ConstraintEvaluator<'a, E: FieldElement<BaseField = Self::BaseField>> =
6466
DefaultConstraintEvaluator<'a, Self::Air, E>;
6567

@@ -90,4 +92,19 @@ where
9092
) -> Self::ConstraintEvaluator<'a, E> {
9193
DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients)
9294
}
95+
96+
fn build_constraint_commitment<E: FieldElement<BaseField = Self::BaseField>>(
97+
&self,
98+
composition_poly_trace: CompositionPolyTrace<E>,
99+
num_constraint_composition_columns: usize,
100+
domain: &StarkDomain<Self::BaseField>,
101+
partition_options: PartitionOptions,
102+
) -> (Self::ConstraintCommitment<E>, CompositionPoly<E>) {
103+
DefaultConstraintCommitment::new(
104+
composition_poly_trace,
105+
num_constraint_composition_columns,
106+
domain,
107+
partition_options,
108+
)
109+
}
93110
}

examples/src/fibonacci/fib8/prover.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// LICENSE file in the root directory of this source tree.
55

66
use winterfell::{
7-
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, ConstraintCompositionCoefficients,
8-
DefaultConstraintEvaluator, DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo,
9-
TracePolyTable, TraceTable,
7+
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, CompositionPoly, CompositionPolyTrace,
8+
ConstraintCompositionCoefficients, DefaultConstraintCommitment, DefaultConstraintEvaluator,
9+
DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo, TracePolyTable, TraceTable,
1010
};
1111

1212
use super::{
@@ -75,6 +75,8 @@ where
7575
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
7676
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> =
7777
DefaultTraceLde<E, Self::HashFn, Self::VC>;
78+
type ConstraintCommitment<E: FieldElement<BaseField = Self::BaseField>> =
79+
DefaultConstraintCommitment<E, H, Self::VC>;
7880
type ConstraintEvaluator<'a, E: FieldElement<BaseField = Self::BaseField>> =
7981
DefaultConstraintEvaluator<'a, Self::Air, E>;
8082

@@ -105,4 +107,19 @@ where
105107
) -> Self::ConstraintEvaluator<'a, E> {
106108
DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients)
107109
}
110+
111+
fn build_constraint_commitment<E: FieldElement<BaseField = Self::BaseField>>(
112+
&self,
113+
composition_poly_trace: CompositionPolyTrace<E>,
114+
num_constraint_composition_columns: usize,
115+
domain: &StarkDomain<Self::BaseField>,
116+
partition_options: PartitionOptions,
117+
) -> (Self::ConstraintCommitment<E>, CompositionPoly<E>) {
118+
DefaultConstraintCommitment::new(
119+
composition_poly_trace,
120+
num_constraint_composition_columns,
121+
domain,
122+
partition_options,
123+
)
124+
}
108125
}

examples/src/fibonacci/fib_small/prover.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// This source code is licensed under the MIT license found in the
44
// LICENSE file in the root directory of this source tree.
55
use winterfell::{
6-
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, ConstraintCompositionCoefficients,
7-
DefaultConstraintEvaluator, DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo,
8-
TracePolyTable, TraceTable,
6+
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, CompositionPoly, CompositionPolyTrace,
7+
ConstraintCompositionCoefficients, DefaultConstraintCommitment, DefaultConstraintEvaluator,
8+
DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo, TracePolyTable, TraceTable,
99
};
1010

1111
use super::{
@@ -65,6 +65,8 @@ where
6565
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
6666
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> =
6767
DefaultTraceLde<E, Self::HashFn, Self::VC>;
68+
type ConstraintCommitment<E: FieldElement<BaseField = Self::BaseField>> =
69+
DefaultConstraintCommitment<E, H, Self::VC>;
6870
type ConstraintEvaluator<'a, E: FieldElement<BaseField = Self::BaseField>> =
6971
DefaultConstraintEvaluator<'a, Self::Air, E>;
7072

@@ -95,4 +97,19 @@ where
9597
) -> Self::ConstraintEvaluator<'a, E> {
9698
DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients)
9799
}
100+
101+
fn build_constraint_commitment<E: FieldElement<BaseField = Self::BaseField>>(
102+
&self,
103+
composition_poly_trace: CompositionPolyTrace<E>,
104+
num_constraint_composition_columns: usize,
105+
domain: &StarkDomain<Self::BaseField>,
106+
partition_options: PartitionOptions,
107+
) -> (Self::ConstraintCommitment<E>, CompositionPoly<E>) {
108+
DefaultConstraintCommitment::new(
109+
composition_poly_trace,
110+
num_constraint_composition_columns,
111+
domain,
112+
partition_options,
113+
)
114+
}
98115
}

examples/src/fibonacci/mulfib2/prover.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// LICENSE file in the root directory of this source tree.
55

66
use winterfell::{
7-
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, ConstraintCompositionCoefficients,
8-
DefaultConstraintEvaluator, DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo,
9-
TracePolyTable, TraceTable,
7+
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, CompositionPoly, CompositionPolyTrace,
8+
ConstraintCompositionCoefficients, DefaultConstraintCommitment, DefaultConstraintEvaluator,
9+
DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo, TracePolyTable, TraceTable,
1010
};
1111

1212
use super::{
@@ -56,6 +56,8 @@ where
5656
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
5757
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> =
5858
DefaultTraceLde<E, Self::HashFn, Self::VC>;
59+
type ConstraintCommitment<E: FieldElement<BaseField = Self::BaseField>> =
60+
DefaultConstraintCommitment<E, H, Self::VC>;
5961
type ConstraintEvaluator<'a, E: FieldElement<BaseField = Self::BaseField>> =
6062
DefaultConstraintEvaluator<'a, Self::Air, E>;
6163

@@ -86,4 +88,19 @@ where
8688
) -> Self::ConstraintEvaluator<'a, E> {
8789
DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients)
8890
}
91+
92+
fn build_constraint_commitment<E: FieldElement<BaseField = Self::BaseField>>(
93+
&self,
94+
composition_poly_trace: CompositionPolyTrace<E>,
95+
num_constraint_composition_columns: usize,
96+
domain: &StarkDomain<Self::BaseField>,
97+
partition_options: PartitionOptions,
98+
) -> (Self::ConstraintCommitment<E>, CompositionPoly<E>) {
99+
DefaultConstraintCommitment::new(
100+
composition_poly_trace,
101+
num_constraint_composition_columns,
102+
domain,
103+
partition_options,
104+
)
105+
}
89106
}

examples/src/fibonacci/mulfib8/prover.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// LICENSE file in the root directory of this source tree.
55

66
use winterfell::{
7-
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, ConstraintCompositionCoefficients,
8-
DefaultConstraintEvaluator, DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo,
9-
TracePolyTable, TraceTable,
7+
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, CompositionPoly, CompositionPolyTrace,
8+
ConstraintCompositionCoefficients, DefaultConstraintCommitment, DefaultConstraintEvaluator,
9+
DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo, TracePolyTable, TraceTable,
1010
};
1111

1212
use super::{
@@ -68,6 +68,8 @@ where
6868
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
6969
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> =
7070
DefaultTraceLde<E, Self::HashFn, Self::VC>;
71+
type ConstraintCommitment<E: FieldElement<BaseField = Self::BaseField>> =
72+
DefaultConstraintCommitment<E, H, Self::VC>;
7173
type ConstraintEvaluator<'a, E: FieldElement<BaseField = Self::BaseField>> =
7274
DefaultConstraintEvaluator<'a, Self::Air, E>;
7375

@@ -98,4 +100,19 @@ where
98100
) -> Self::ConstraintEvaluator<'a, E> {
99101
DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients)
100102
}
103+
104+
fn build_constraint_commitment<E: FieldElement<BaseField = Self::BaseField>>(
105+
&self,
106+
composition_poly_trace: CompositionPolyTrace<E>,
107+
num_constraint_composition_columns: usize,
108+
domain: &StarkDomain<Self::BaseField>,
109+
partition_options: PartitionOptions,
110+
) -> (Self::ConstraintCommitment<E>, CompositionPoly<E>) {
111+
DefaultConstraintCommitment::new(
112+
composition_poly_trace,
113+
num_constraint_composition_columns,
114+
domain,
115+
partition_options,
116+
)
117+
}
101118
}

examples/src/lamport/aggregate/prover.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#[cfg(feature = "concurrent")]
77
use winterfell::iterators::*;
88
use winterfell::{
9-
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, ConstraintCompositionCoefficients,
10-
DefaultConstraintEvaluator, DefaultTraceLde, PartitionOptions, StarkDomain, TraceInfo,
11-
TracePolyTable, TraceTable,
9+
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, CompositionPoly, CompositionPolyTrace,
10+
ConstraintCompositionCoefficients, DefaultConstraintCommitment, DefaultConstraintEvaluator,
11+
DefaultTraceLde, PartitionOptions, StarkDomain, TraceInfo, TracePolyTable, TraceTable,
1212
};
1313

1414
use super::{
@@ -105,6 +105,8 @@ where
105105
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
106106
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> =
107107
DefaultTraceLde<E, Self::HashFn, Self::VC>;
108+
type ConstraintCommitment<E: FieldElement<BaseField = Self::BaseField>> =
109+
DefaultConstraintCommitment<E, H, Self::VC>;
108110
type ConstraintEvaluator<'a, E: FieldElement<BaseField = Self::BaseField>> =
109111
DefaultConstraintEvaluator<'a, Self::Air, E>;
110112

@@ -134,6 +136,21 @@ where
134136
) -> Self::ConstraintEvaluator<'a, E> {
135137
DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients)
136138
}
139+
140+
fn build_constraint_commitment<E: FieldElement<BaseField = Self::BaseField>>(
141+
&self,
142+
composition_poly_trace: CompositionPolyTrace<E>,
143+
num_constraint_composition_columns: usize,
144+
domain: &StarkDomain<Self::BaseField>,
145+
partition_options: PartitionOptions,
146+
) -> (Self::ConstraintCommitment<E>, CompositionPoly<E>) {
147+
DefaultConstraintCommitment::new(
148+
composition_poly_trace,
149+
num_constraint_composition_columns,
150+
domain,
151+
partition_options,
152+
)
153+
}
137154
}
138155

139156
// TRACE INITIALIZATION

examples/src/lamport/threshold/prover.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use std::collections::HashMap;
88
#[cfg(feature = "concurrent")]
99
use winterfell::iterators::*;
1010
use winterfell::{
11-
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, ConstraintCompositionCoefficients,
12-
DefaultConstraintEvaluator, DefaultTraceLde, PartitionOptions, StarkDomain, TraceInfo,
13-
TracePolyTable, TraceTable,
11+
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, CompositionPoly, CompositionPolyTrace,
12+
ConstraintCompositionCoefficients, DefaultConstraintCommitment, DefaultConstraintEvaluator,
13+
DefaultTraceLde, PartitionOptions, StarkDomain, TraceInfo, TracePolyTable, TraceTable,
1414
};
1515

1616
use super::{
@@ -147,6 +147,8 @@ where
147147
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
148148
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> =
149149
DefaultTraceLde<E, Self::HashFn, Self::VC>;
150+
type ConstraintCommitment<E: FieldElement<BaseField = Self::BaseField>> =
151+
DefaultConstraintCommitment<E, H, Self::VC>;
150152
type ConstraintEvaluator<'a, E: FieldElement<BaseField = Self::BaseField>> =
151153
DefaultConstraintEvaluator<'a, Self::Air, E>;
152154

@@ -176,6 +178,21 @@ where
176178
) -> Self::ConstraintEvaluator<'a, E> {
177179
DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients)
178180
}
181+
182+
fn build_constraint_commitment<E: FieldElement<BaseField = Self::BaseField>>(
183+
&self,
184+
composition_poly_trace: CompositionPolyTrace<E>,
185+
num_constraint_composition_columns: usize,
186+
domain: &StarkDomain<Self::BaseField>,
187+
partition_options: PartitionOptions,
188+
) -> (Self::ConstraintCommitment<E>, CompositionPoly<E>) {
189+
DefaultConstraintCommitment::new(
190+
composition_poly_trace,
191+
num_constraint_composition_columns,
192+
domain,
193+
partition_options,
194+
)
195+
}
179196
}
180197

181198
// TRACE INITIALIZATION

examples/src/merkle/prover.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// LICENSE file in the root directory of this source tree.
55

66
use winterfell::{
7-
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, ConstraintCompositionCoefficients,
8-
DefaultConstraintEvaluator, DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo,
9-
TracePolyTable, TraceTable,
7+
crypto::MerkleTree, matrix::ColMatrix, AuxRandElements, CompositionPoly, CompositionPolyTrace,
8+
ConstraintCompositionCoefficients, DefaultConstraintCommitment, DefaultConstraintEvaluator,
9+
DefaultTraceLde, PartitionOptions, StarkDomain, Trace, TraceInfo, TracePolyTable, TraceTable,
1010
};
1111

1212
use super::{
@@ -109,6 +109,8 @@ where
109109
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
110110
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> =
111111
DefaultTraceLde<E, Self::HashFn, Self::VC>;
112+
type ConstraintCommitment<E: FieldElement<BaseField = Self::BaseField>> =
113+
DefaultConstraintCommitment<E, H, Self::VC>;
112114
type ConstraintEvaluator<'a, E: FieldElement<BaseField = Self::BaseField>> =
113115
DefaultConstraintEvaluator<'a, Self::Air, E>;
114116

@@ -141,4 +143,19 @@ where
141143
) -> Self::ConstraintEvaluator<'a, E> {
142144
DefaultConstraintEvaluator::new(air, aux_rand_elements, composition_coefficients)
143145
}
146+
147+
fn build_constraint_commitment<E: FieldElement<BaseField = Self::BaseField>>(
148+
&self,
149+
composition_poly_trace: CompositionPolyTrace<E>,
150+
num_constraint_composition_columns: usize,
151+
domain: &StarkDomain<Self::BaseField>,
152+
partition_options: PartitionOptions,
153+
) -> (Self::ConstraintCommitment<E>, CompositionPoly<E>) {
154+
DefaultConstraintCommitment::new(
155+
composition_poly_trace,
156+
num_constraint_composition_columns,
157+
domain,
158+
partition_options,
159+
)
160+
}
144161
}

0 commit comments

Comments
 (0)