-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add Legendre
trait
#79
Conversation
- Add Legendre macro with norm and legendre symbol computation - Add macro for automatic implementation in prime fields
@@ -38,6 +38,9 @@ const ENDO_PARAMS_EP: EndoParameters = EndoParameters { | |||
endo!(Eq, Fp, ENDO_PARAMS_EQ); | |||
endo!(Ep, Fq, ENDO_PARAMS_EP); | |||
|
|||
// prime_field_legendre!(Fp); | |||
// prime_field_legendre!(Fq); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.