2020-11-12 20:13:13 +00:00
|
|
|
//! This module contains implementations for the two finite fields of the
|
|
|
|
|
//! Tweedledum and Tweedledee curves.
|
|
|
|
|
|
|
|
|
|
mod fp;
|
|
|
|
|
mod fq;
|
|
|
|
|
|
|
|
|
|
pub use fp::*;
|
|
|
|
|
pub use fq::*;
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
2020-11-13 00:08:08 +00:00
|
|
|
use ff::{Field, PrimeField};
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
use crate::arithmetic::FieldExt;
|
2020-11-12 20:13:13 +00:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_extract() {
|
2020-11-13 00:08:08 +00:00
|
|
|
let a = Fq::rand();
|
2020-11-12 20:13:13 +00:00
|
|
|
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);
|
|
|
|
|
}
|