Skip to content

Commit

Permalink
Merge pull request #207 from grjte/grjte-custom-lde
Browse files Browse the repository at this point in the history
Support custom implementations of Trace LDE
  • Loading branch information
irakliyk authored Jul 24, 2023
2 parents 526ae17 + 3eb276f commit e9ee070
Show file tree
Hide file tree
Showing 35 changed files with 588 additions and 498 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.7.0 (TBD)
* [BREAKING] replaced the `TraceLde` struct with a trait (#207).

## 0.6.4 (2023-05-26)
* Simplified construction of constraint composition polynomial (#198).
* Refactored serialization of OOD frame in STARK proofs (#199).
Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/fib2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

mod air;
Expand Down
5 changes: 3 additions & 2 deletions examples/src/fibonacci/fib2/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// LICENSE file in the root directory of this source tree.

use super::{
BaseElement, DefaultRandomCoin, ElementHasher, FibAir, FieldElement, PhantomData, ProofOptions,
Prover, Trace, TraceTable, TRACE_WIDTH,
BaseElement, DefaultRandomCoin, DefaultTraceLde, ElementHasher, FibAir, FieldElement,
PhantomData, ProofOptions, Prover, Trace, TraceTable, TRACE_WIDTH,
};

// FIBONACCI PROVER
Expand Down Expand Up @@ -57,6 +57,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> BaseElement {
let last_step = trace.length() - 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/fib8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

mod air;
Expand Down
5 changes: 3 additions & 2 deletions examples/src/fibonacci/fib8/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// LICENSE file in the root directory of this source tree.

use super::{
BaseElement, DefaultRandomCoin, ElementHasher, Fib8Air, FieldElement, PhantomData,
ProofOptions, Prover, Trace, TraceTable,
BaseElement, DefaultRandomCoin, DefaultTraceLde, ElementHasher, Fib8Air, FieldElement,
PhantomData, ProofOptions, Prover, Trace, TraceTable,
};

// FIBONACCI PROVER
Expand Down Expand Up @@ -72,6 +72,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> BaseElement {
let last_step = trace.length() - 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/fib_small/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f64::BaseElement, FieldElement},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

mod air;
Expand Down
6 changes: 3 additions & 3 deletions examples/src/fibonacci/fib_small/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.

use super::{
air::FibSmall, BaseElement, DefaultRandomCoin, ElementHasher, FieldElement, PhantomData,
ProofOptions, Prover, Trace, TraceTable, TRACE_WIDTH,
air::FibSmall, BaseElement, DefaultRandomCoin, DefaultTraceLde, ElementHasher, FieldElement,
PhantomData, ProofOptions, Prover, Trace, TraceTable, TRACE_WIDTH,
};

// FIBONACCI PROVER
Expand Down Expand Up @@ -57,6 +56,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> BaseElement {
let last_step = trace.length() - 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/mulfib2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

mod air;
Expand Down
5 changes: 3 additions & 2 deletions examples/src/fibonacci/mulfib2/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// LICENSE file in the root directory of this source tree.

use super::{
BaseElement, DefaultRandomCoin, ElementHasher, MulFib2Air, PhantomData, ProofOptions, Prover,
Trace, TraceTable,
BaseElement, DefaultRandomCoin, DefaultTraceLde, ElementHasher, FieldElement, MulFib2Air,
PhantomData, ProofOptions, Prover, Trace, TraceTable,
};

// FIBONACCI PROVER
Expand Down Expand Up @@ -53,6 +53,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> BaseElement {
let last_step = trace.length() - 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/fibonacci/mulfib8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

mod air;
Expand Down
5 changes: 3 additions & 2 deletions examples/src/fibonacci/mulfib8/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// LICENSE file in the root directory of this source tree.

use super::{
BaseElement, DefaultRandomCoin, ElementHasher, MulFib8Air, PhantomData, ProofOptions, Prover,
Trace, TraceTable,
BaseElement, DefaultRandomCoin, DefaultTraceLde, ElementHasher, FieldElement, MulFib8Air,
PhantomData, ProofOptions, Prover, Trace, TraceTable,
};

// FIBONACCI PROVER
Expand Down Expand Up @@ -65,6 +65,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> BaseElement {
let last_step = trace.length() - 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/lamport/aggregate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, get_power_series, FieldElement, StarkField},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

mod air;
Expand Down
7 changes: 4 additions & 3 deletions examples/src/lamport/aggregate/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// LICENSE file in the root directory of this source tree.

use super::{
get_power_series, rescue, BaseElement, DefaultRandomCoin, ElementHasher, FieldElement,
LamportAggregateAir, PhantomData, ProofOptions, Prover, PublicInputs, Signature, StarkField,
TraceTable, CYCLE_LENGTH, NUM_HASH_ROUNDS, SIG_CYCLE_LENGTH, TRACE_WIDTH,
get_power_series, rescue, BaseElement, DefaultRandomCoin, DefaultTraceLde, ElementHasher,
FieldElement, LamportAggregateAir, PhantomData, ProofOptions, Prover, PublicInputs, Signature,
StarkField, TraceTable, CYCLE_LENGTH, NUM_HASH_ROUNDS, SIG_CYCLE_LENGTH, TRACE_WIDTH,
};

#[cfg(feature = "concurrent")]
Expand Down Expand Up @@ -97,6 +97,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, _trace: &Self::Trace) -> PublicInputs {
self.pub_inputs.clone()
Expand Down
2 changes: 1 addition & 1 deletion examples/src/lamport/threshold/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, get_power_series, FieldElement, StarkField},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

mod signature;
Expand Down
8 changes: 5 additions & 3 deletions examples/src/lamport/threshold/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
// LICENSE file in the root directory of this source tree.

use super::{
get_power_series, rescue, AggPublicKey, BaseElement, DefaultRandomCoin, ElementHasher,
FieldElement, LamportThresholdAir, PhantomData, ProofOptions, Prover, PublicInputs, Signature,
StarkField, TraceTable, HASH_CYCLE_LENGTH, NUM_HASH_ROUNDS, SIG_CYCLE_LENGTH, TRACE_WIDTH,
get_power_series, rescue, AggPublicKey, BaseElement, DefaultRandomCoin, DefaultTraceLde,
ElementHasher, FieldElement, LamportThresholdAir, PhantomData, ProofOptions, Prover,
PublicInputs, Signature, StarkField, TraceTable, HASH_CYCLE_LENGTH, NUM_HASH_ROUNDS,
SIG_CYCLE_LENGTH, TRACE_WIDTH,
};
use std::collections::HashMap;

Expand Down Expand Up @@ -138,6 +139,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, _trace: &Self::Trace) -> PublicInputs {
self.pub_inputs.clone()
Expand Down
2 changes: 1 addition & 1 deletion examples/src/merkle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, Digest, ElementHasher, MerkleTree},
math::{fields::f128::BaseElement, FieldElement, StarkField},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

mod air;
Expand Down
7 changes: 4 additions & 3 deletions examples/src/merkle/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// LICENSE file in the root directory of this source tree.

use super::{
rescue, BaseElement, DefaultRandomCoin, ElementHasher, FieldElement, MerkleAir, PhantomData,
ProofOptions, Prover, PublicInputs, Trace, TraceTable, HASH_CYCLE_LEN, HASH_STATE_WIDTH,
NUM_HASH_ROUNDS, TRACE_WIDTH,
rescue, BaseElement, DefaultRandomCoin, DefaultTraceLde, ElementHasher, FieldElement,
MerkleAir, PhantomData, ProofOptions, Prover, PublicInputs, Trace, TraceTable, HASH_CYCLE_LEN,
HASH_STATE_WIDTH, NUM_HASH_ROUNDS, TRACE_WIDTH,
};

// MERKLE PROVER
Expand Down Expand Up @@ -103,6 +103,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs {
let last_step = trace.length() - 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/rescue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

#[allow(clippy::module_inception)]
Expand Down
6 changes: 4 additions & 2 deletions examples/src/rescue/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
// LICENSE file in the root directory of this source tree.

use super::{
rescue, BaseElement, DefaultRandomCoin, ElementHasher, FieldElement, PhantomData, ProofOptions,
Prover, PublicInputs, RescueAir, Trace, TraceTable, CYCLE_LENGTH, NUM_HASH_ROUNDS,
rescue, BaseElement, DefaultRandomCoin, DefaultTraceLde, ElementHasher, FieldElement,
PhantomData, ProofOptions, Prover, PublicInputs, RescueAir, Trace, TraceTable, CYCLE_LENGTH,
NUM_HASH_ROUNDS,
};

// RESCUE PROVER
Expand Down Expand Up @@ -69,6 +70,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs {
let last_step = trace.length() - 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/rescue_raps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, ExtensionOf, FieldElement},
ProofOptions, Prover, StarkProof, Trace, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, VerifierError,
};

mod custom_trace_table;
Expand Down
5 changes: 3 additions & 2 deletions examples/src/rescue_raps/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

use super::{
apply_rescue_round_parallel, rescue::STATE_WIDTH, BaseElement, DefaultRandomCoin,
ElementHasher, FieldElement, PhantomData, ProofOptions, Prover, PublicInputs, RapTraceTable,
RescueRapsAir, Trace, CYCLE_LENGTH, NUM_HASH_ROUNDS,
DefaultTraceLde, ElementHasher, FieldElement, PhantomData, ProofOptions, Prover, PublicInputs,
RapTraceTable, RescueRapsAir, Trace, CYCLE_LENGTH, NUM_HASH_ROUNDS,
};

// RESCUE PROVER
Expand Down Expand Up @@ -98,6 +98,7 @@ where
type Trace = RapTraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> PublicInputs {
let last_step = trace.length() - 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/vdf/exempt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

mod air;
Expand Down
5 changes: 3 additions & 2 deletions examples/src/vdf/exempt/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// LICENSE file in the root directory of this source tree.

use super::{
BaseElement, DefaultRandomCoin, ElementHasher, FieldElement, PhantomData, ProofOptions, Prover,
Trace, TraceTable, VdfAir, VdfInputs, FORTY_TWO, INV_ALPHA,
BaseElement, DefaultRandomCoin, DefaultTraceLde, ElementHasher, FieldElement, PhantomData,
ProofOptions, Prover, Trace, TraceTable, VdfAir, VdfInputs, FORTY_TWO, INV_ALPHA,
};

// VDF PROVER
Expand Down Expand Up @@ -50,6 +50,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> VdfInputs {
// the result is read from the second to last step because the last last step contains
Expand Down
2 changes: 1 addition & 1 deletion examples/src/vdf/regular/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::time::Instant;
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
DefaultTraceLde, ProofOptions, Prover, StarkProof, Trace, TraceTable, VerifierError,
};

mod air;
Expand Down
5 changes: 3 additions & 2 deletions examples/src/vdf/regular/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// LICENSE file in the root directory of this source tree.

use super::{
BaseElement, DefaultRandomCoin, ElementHasher, FieldElement, PhantomData, ProofOptions, Prover,
Trace, TraceTable, VdfAir, VdfInputs, FORTY_TWO, INV_ALPHA,
BaseElement, DefaultRandomCoin, DefaultTraceLde, ElementHasher, FieldElement, PhantomData,
ProofOptions, Prover, Trace, TraceTable, VdfAir, VdfInputs, FORTY_TWO, INV_ALPHA,
};

// VDF PROVER
Expand Down Expand Up @@ -47,6 +47,7 @@ where
type Trace = TraceTable<BaseElement>;
type HashFn = H;
type RandomCoin = DefaultRandomCoin<Self::HashFn>;
type TraceLde<E: FieldElement<BaseField = Self::BaseField>> = DefaultTraceLde<E, Self::HashFn>;

fn get_pub_inputs(&self, trace: &Self::Trace) -> VdfInputs {
let last_step = trace.length() - 1;
Expand Down
Loading

0 comments on commit e9ee070

Please sign in to comment.