[WIP] Add Legendre trait#79
Conversation
- Add Legendre macro with norm and legendre symbol computation - Add macro for automatic implementation in prime fields
| endo!(Ep, Fq, ENDO_PARAMS_EP); | ||
|
|
||
| // prime_field_legendre!(Fp); | ||
| // prime_field_legendre!(Fq); |
There was a problem hiding this comment.
Calling this macro here results in conflicting names for the values generated in the lazy_static!. I have tried the following:
static ref [< $field _LE_AS_BIGUINT >]: BigUint = BigUint::from_bytes_le((-<$field as ff::Field>::ONE).to_repr().as_ref())/2usize ;
static ref [< $field _LEGENDRE_EXP >]: Vec<u64> = [< $field _LE_AS_BIGUINT >].to_u64_digits();inside a paste!.
But I get some annoying warnings regarding non upper case globals that I haven't managed to remove
| // This is (p-1)/2 where p is the modulus of the base prime field | ||
| fn legendre_exp() -> &'static Vec<u64>; | ||
|
|
||
| fn norm(&self) -> &Self::BasePrimeField; |
There was a problem hiding this comment.
Is this added to cover the extension field? If so I think we couldn't return a reference since the norm of Fq2 is calculated on the fly, so here we'd have some lifetime issue.
| type BasePrimeField: PrimeField; | ||
|
|
||
| // This is (p-1)/2 where p is the modulus of the base prime field | ||
| fn legendre_exp() -> &'static Vec<u64>; |
There was a problem hiding this comment.
I think we could have this as some const 'static [u64] and we can print it out and pass it when calling prime_field_legendre, that might be an more direct approach? And we can avoid the naming conflict issue.
|
Changes moved to #77 |
Add trait for computing Legendre symbol and field element norm.