pasta_curves-source/src/pasta/fields.rs
2020-12-03 13:47:47 -07:00

26 lines
562 B
Rust

//! This module contains implementations for the two finite fields of the Pallas
//! and Vesta curves.
mod fp;
mod fq;
pub use fp::*;
pub use fq::*;
#[cfg(test)]
use ff::{Field, PrimeField};
#[cfg(test)]
use crate::arithmetic::FieldExt;
#[test]
fn test_extract() {
let a = Fq::rand();
let a = a.square();
let (t, s) = a.extract_radix2_vartime().unwrap();
assert_eq!(
t.pow_vartime(&[1 << Fq::S, 0, 0, 0]) * Fq::ROOT_OF_UNITY.pow_vartime(&[s, 0, 0, 0]),
a
);
assert_eq!(a.deterministic_sqrt().unwrap().square(), a);
}