Skip to content

Commit

Permalink
add vanishing polynomial of a coset
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole authored and Nicole committed Oct 31, 2024
1 parent e9f6078 commit d66d52d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions provers/circle_stark/src/constraints.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use lambdaworks_math::{
circle::point::CirclePoint,
field::{element::FieldElement, fields::mersenne31::field::Mersenne31Field},
};

pub fn evaluate_vanishing_poly(
log_2_size: u32,
point: CirclePoint<Mersenne31Field>,
) -> FieldElement<Mersenne31Field> {
let mut x = point.x;
for _ in 1..log_2_size {
x = x.square().double() - FieldElement::one();
}
x
}

#[cfg(test)]
mod tests {
use super::*;
use lambdaworks_math::circle::cosets::Coset;

type FE = FieldElement<Mersenne31Field>;

#[test]
fn vanishing_poly_vanishes_in_coset() {
let log_2_size = 3;
let coset = Coset::new_standard(log_2_size);
let points = Coset::get_coset_points(&coset);
for point in points {
assert_eq!(evaluate_vanishing_poly(log_2_size, point), FE::zero());
}
}
#[test]
fn vanishing_poly_doesnt_vanishe_outside_coset() {
let log_2_size = 3;
let coset = Coset::new_standard(log_2_size + 1);
let points = Coset::get_coset_points(&coset);
for point in points {
assert_ne!(evaluate_vanishing_poly(log_2_size, point), FE::zero());
}
}
}
1 change: 1 addition & 0 deletions provers/circle_stark/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod config;
pub mod constraints;
pub mod prover;

0 comments on commit d66d52d

Please sign in to comment.