halo2curves/pasta/
fq.rs
1use std::convert::TryInto;
2
3use halo2derive::impl_field;
4use rand::RngCore;
5use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
6
7use crate::{
8 extend_field_legendre, field_bits, impl_binops_additive, impl_binops_calls,
9 impl_binops_multiplicative, impl_from_bool, impl_from_u64, serialize_deserialize_primefield,
10};
11
12impl_field!(
14 vesta_base,
15 Fq,
16 modulus = "40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001",
17 mul_gen = "5",
18 zeta = "06819a58283e528e511db4d81cf70f5a0fed467d47c033af2aa9d2e050aa0e4f",
19 from_uniform = [48, 64],
20 endian = "little",
21);
22
23extend_field_legendre!(Fq);
24impl_binops_calls!(Fq);
25impl_binops_additive!(Fq, Fq);
26impl_binops_multiplicative!(Fq, Fq);
27impl_from_u64!(Fq);
28impl_from_bool!(Fq);
29field_bits!(Fq);
30serialize_deserialize_primefield!(Fq);
31
32#[cfg(test)]
33mod test {
34 use super::Fq;
35 use crate::{
36 arith_test, constants_test, from_uniform_bytes_test, legendre_test, serde_test, test,
37 };
38
39 constants_test!(Fq);
40 arith_test!(Fq);
41 legendre_test!(Fq);
42 test!(arith, Fq, sqrt_test, 1000);
43 serde_test!(Fq PrimeFieldBits);
44 from_uniform_bytes_test!(Fq, 1000, L 64, L 48);
45}