Sqrt fq2 bls12 381 regression (#89) Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
Marcin marcin.gorny.94@protonmail.com
Tue, 11 Jan 2022 18:28:17 +0100
1 files changed,
13 insertions(+),
0 deletions(-)
jump to
M
bls12_381/src/fields/tests.rs
→
bls12_381/src/fields/tests.rs
@@ -1118,6 +1118,19 @@ assert!(x.is_zero());
} #[test] +fn test_fq2_sqrt() { + // 1 has a sqrt in the base field + let fq2_sqrt = Fq2::new(Fq::one(), Fq::zero()).sqrt().unwrap(); + assert_eq!(fq2_sqrt.c0, Fq::one()); + assert_eq!(fq2_sqrt.c1, Fq::zero()); + + // -1 has no sqrt in the base field, but should be valid in Fq2 + let fq2_sqrt = Fq2::new(-Fq::one(), Fq::zero()).sqrt().unwrap(); + assert_eq!(fq2_sqrt.c0, Fq::zero()); + assert_eq!(fq2_sqrt.c1, Fq::one()); +} + +#[test] fn test_fq_num_bits() { assert_eq!(FqParameters::MODULUS_BITS, 381); assert_eq!(FqParameters::CAPACITY, 380);