-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicole
authored and
Nicole
committed
Oct 31, 2024
1 parent
e9f6078
commit d66d52d
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod config; | ||
pub mod constraints; | ||
pub mod prover; |