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

Sage constants & tests codegen #101

Merged
merged 14 commits into from
Oct 10, 2020
Merged

Sage constants & tests codegen #101

merged 14 commits into from
Oct 10, 2020

Conversation

mratsim
Copy link
Owner

@mratsim mratsim commented Oct 10, 2020

This PR overhauls curves constants generation and provides

  1. A sage script that generates frobenius maps and untwist-frobenius-twist endomorphisms constants. The sage script generates valid Nim code and should significantly help adding new curves as in Support proposed Ethereum curves in EIPs 1895, 1962, 2539, 3026 #93 and continue BW6-761 from BW6-761 part 1 #100.
  2. A sage script that generates lattice decomposition for endomorphism acceleration. Similarly the sage script generates valid Nim code. This should significantly help for BN254_Nogami (which was missing endomorphism aceleration), Secp256k1 and continuing work on BW6-761.
    Note: A bug was found in BLS12 G2 lattices that led to requiring:
    1. k0 being positive
    2. Always have an extra bit to handle scalar (the previous lattice didn't provide optimal basis / lowest possible infinity norm)
    3. This has been fixed. Also to handle negative miniscalars, the code now negate them and saves a bit in representation (= 1 EC add and 1 EC double)
  3. A sage script that generates naive pairing constants (ate parameter, final exponent) for quick prototyping of pairing via naive Miller loop and exponentiation by (p^k -1)/r
  4. JSON test vectors generators for scalar multiplication. This should help testing scalar multiplication on a wide range of test-case instead of being restricted by copy-paste tediousness. This also avoids circular dependencies for testing endomorphism acceleration as they required the cofactor to be cleared and so require (generic) scalar multiplication to be working.
  5. Old sage scripts were deleted besides the one for generating Tonelli Shanks precomputation.

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.

1 participant