Skip to content

Commit

Permalink
crate new methods for evaluation_context
Browse files Browse the repository at this point in the history
  • Loading branch information
ColoCarletti committed Dec 20, 2024
1 parent 4c73313 commit 605149d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
12 changes: 6 additions & 6 deletions provers/stark/src/constraints/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ impl<A: AIR> ConstraintEvaluator<A> {
.collect();

// Compute all the transition constraints at this point of the LDE domain.
let evaluations_transition =
air.compute_transition(&TransitionEvaluationContext::Prover {
frame: &frame,
periodic_values: &periodic_values,
rap_challenges,
});
let transition_evaluation_context = TransitionEvaluationContext::new_prover(
&frame,
&periodic_values,
rap_challenges,
);
let evaluations_transition = air.compute_transition(&transition_evaluation_context);

#[cfg(all(debug_assertions, not(feature = "parallel")))]
transition_evaluations.push(evaluations_transition.clone());
Expand Down
8 changes: 3 additions & 5 deletions provers/stark/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ pub fn validate_trace<A: AIR>(
.iter()
.map(|col| col[step].clone())
.collect();
let evaluations = air.compute_transition(&TransitionEvaluationContext::Prover {
frame: &frame,
periodic_values: &periodic_values,
rap_challenges,
});
let transition_evaluation_context =
TransitionEvaluationContext::new_prover(&frame, &periodic_values, rap_challenges);
let evaluations = air.compute_transition(&transition_evaluation_context);

// Iterate over each transition evaluation. When the evaluated step is not from
// the exemption steps corresponding to the transition, it should have zero as a
Expand Down
30 changes: 30 additions & 0 deletions provers/stark/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,36 @@ where
},
}

impl<'a, F, E> TransitionEvaluationContext<'a, F, E>
where
F: IsSubFieldOf<E>,
E: IsField,
{
pub fn new_prover(
frame: &'a Frame<'a, F, E>,
periodic_values: &'a [FieldElement<F>],
rap_challenges: &'a [FieldElement<E>],
) -> Self {
Self::Prover {
frame,
periodic_values,
rap_challenges,
}
}

pub fn new_verifier(
frame: &'a Frame<'a, E, E>,
periodic_values: &'a [FieldElement<E>],
rap_challenges: &'a [FieldElement<E>],
) -> Self {
Self::Verifier {
frame,
periodic_values,
rap_challenges,
}
}
}

/// AIR is a representation of the Constraints
pub trait AIR {
type Field: IsFFTField + IsSubFieldOf<Self::FieldExtension> + Send + Sync;
Expand Down
11 changes: 6 additions & 5 deletions provers/stark/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,13 @@ pub trait IsStarkVerifier<A: AIR> {

let ood_frame =
(proof.trace_ood_evaluations).into_frame(num_main_trace_columns, A::STEP_SIZE);
let transition_evaluation_context = TransitionEvaluationContext::new_verifier(
&ood_frame,
&periodic_values,
&challenges.rap_challenges,
);
let transition_ood_frame_evaluations =
air.compute_transition(&TransitionEvaluationContext::Verifier {
frame: &ood_frame,
periodic_values: &periodic_values,
rap_challenges: &challenges.rap_challenges,
});
air.compute_transition(&transition_evaluation_context);

let mut denominators =
vec![FieldElement::<A::FieldExtension>::zero(); air.num_transition_constraints()];
Expand Down

0 comments on commit 605149d

Please sign in to comment.