@ -1,3 +1,24 @@
///! Bls12-377 scalar field.
///
/// Roots of unity computed from modulus and R using this sage code:
///
/// ```ignore
/// q = 8444461749428370424248824938781546531375899335154063827935233455917409239041
/// R = 6014086494747379908336260804527802945383293308637734276299549080986809532403 # Montgomery R
/// s = 47
/// o = q - 1
/// F = GF(q)
/// g = F.multiplicative_generator()
/// g = F.multiplicative_generator()
/// assert g.multiplicative_order() == o
/// g2 = g ** (o/2**s)
/// assert g2.multiplicative_order() == 2**s
/// def into_chunks(val, width, n):
/// return [int(int(val) // (2 ** (width * i)) % 2 ** width) for i in range(n)]
/// print("Gen: ", g * R % q)
/// print("Gen: ", into_chunks(g * R % q, 64, 4))
/// print("2-adic gen: ", into_chunks(g2 * R % q, 64, 4))
/// ```
use ark_ff ::{ biginteger ::BigInteger256 as BigInteger , fields ::* } ;
use ark_ff ::{ biginteger ::BigInteger256 as BigInteger , fields ::* } ;
pub type Fr = Fp256 < FrParameters > ;
pub type Fr = Fp256 < FrParameters > ;
@ -12,10 +33,10 @@ impl FftParameters for FrParameters {
#[ rustfmt::skip ]
#[ rustfmt::skip ]
const TWO_ADIC_ROOT_OF_UNITY : BigInteger = BigInteger ( [
const TWO_ADIC_ROOT_OF_UNITY : BigInteger = BigInteger ( [
0x3c3d3ca739381fb2 ,
0x9a14cda3ec99772b ,
0xd7aacc7c59724826 ,
0xd1ba211c5cc349c ,
12646347781564978760 u64 ,
6783048705277173164 u64 ,
268534165941069093 u64 ,
1121515446318641358 u64 ,
] ) ;
] ) ;
}
}
impl FpParameters for FrParameters {
impl FpParameters for FrParameters {
@ -53,15 +74,15 @@ impl FpParameters for FrParameters {
const INV : u64 = 725501752471715839 u64 ;
const INV : u64 = 725501752471715839 u64 ;
/// GENERATOR = 11
/// GENERATOR = 22
/// Encoded in Montgomery form, so the value is
/// Encoded in Montgomery form, so the value is
/// (11 * R) % q = 7043719196222586021957094278335006679584931048936630243748405699433040183146
/// (22 * R) % q = 5642976643016801619665363617888466827793962762719196659561577942948671127251
#[ rustfmt::skip ]
#[ rustfmt::skip ]
const GENERATOR : BigInteger = BigInteger ( [
const GENERATOR : BigInteger = BigInteger ( [
1855201571499933546 u64 ,
8511318076631809892 u64 ,
6222 51 476536 7795 509u64 ,
1122129207579058019 u64 ,
2984901390528151251 u64 ,
10561528701063790279 u64 ,
54767502144 95080041 u64 ,
898978044469942640 u64 ,
] ) ;
] ) ;
/// (r - 1)/2 =
/// (r - 1)/2 =