Skip to content
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

Closed
wants to merge 4 commits into from
Closed

[WIP] Add Legendre trait #79

wants to merge 4 commits into from

Conversation

davidnevadoc
Copy link
Contributor

Add trait for computing Legendre symbol and field element norm.

 - 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);
Copy link
Contributor Author

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

@davidnevadoc davidnevadoc marked this pull request as ready for review August 11, 2023 20:14
@davidnevadoc davidnevadoc requested a review from han0110 August 11, 2023 20:15
// 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;
Copy link
Contributor

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>;
Copy link
Contributor

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.

@davidnevadoc
Copy link
Contributor Author

Changes moved to #77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants