aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2025-08-01Use Projective Coordinatesfeat/projective-coordinatesNicholas Rodrigues Lordello
I modified the curve implementation to use projective coordinates, but there wasn't a material speedup of the BLS12-381 pairing implementation. I suspect it is related to the fact that I am not implementing the Miller Loop in a way that takes advantage of the coordinate projection, which makes things take more time in the end.
2025-08-01Batched Pairing ComputationNicholas Rodrigues Lordello
We batch pairing computations for efficient checking. This allows to more efficiently implement things like BLS signatures (where we check that some pairing dot another is equal to 1). This is because the exponentiation in Fp12 is a _huge_ computational effort (and what takes the most time in the pairing computation). It looks like `@noble/curves` implements a pairing to another `Gt` that is much more efficient to compute (as we do not need to untwist coordinates at all, meaning no field inversion, and no computations in Fp12), but I will hold off on implementing this until there is an actual need for it (in case the current pairing implementation is too slow).
2025-08-01Add Generator TestNicholas Rodrigues Lordello
We use the `py_ecc` generator, and the generator test now passes as expected. Note that we still haven't gotten to the bottom of why `py_ecc` and `@noble/curves` have different `Gt` groups.
2025-08-01Pairings With `py_ecc` ImplementationNicholas Rodrigues Lordello
We now have pairings working with the `py_ecc` implementation, but it looks like different pairing implementations (such as `@noble/curves`) map to different `Gt` groups. I don't think it matters much (as long as we map to _some_ valid group `GT`, and have bilinear properties), but I want to understand _why_ this is the case.
2025-07-30Refactor Curve Into FunctorNicholas Rodrigues Lordello
Curves can now be generically instantiated with a functor, depending on its parameterization (underlying field, Weirstrass `b` value, generator point and order). This makes things very nice! We also now define `E12` explicitely, with a test that `twist E2.g = E12.g`.
2025-07-29Refactor Fields to be Functor BasedNicholas Rodrigues Lordello
Prime fields and polynomial extension fields are now functor based. That is, you define field parameters and a functor will produce a field module. This is the first step to moving all BLS12-381 pairing definitions to a single module, instead of splitting them. This makes the "this is the curve and its pairing" very central, with the field and curve modules being generic over their respective parameterization. Added field exponentiation - and found out that Zarith supports negative exponents, and `powm x ~-1 p` is a much more efficient way of computing a field inverse (tests run ~5 times quicker).
2025-07-29Prepare for CodebergNicholas Rodrigues Lordello
Add license, and fix dune project.
2025-07-28Add Journal Entry for PairingsNicholas Rodrigues Lordello
Explaining the motivation for them, and how they are magic.
2025-07-28Compute `w^2` and `w^3` Only OnceNicholas Rodrigues Lordello
When twisting from E2 to E12, we need to compute `w` coefficients for the twisted coordinates. We now compute this only once, and resuse the value on every `twist` call.
2025-07-28Pairing Tests and RefactorNicholas Rodrigues Lordello
We refactored the extension field types to use an array for coefficients instead of a tuple. Tests were modified to only have string literals for numerical literals (istead of previously encoding a whole `Fp12` in a single string for example). As a result, we get better formatting and more line breaks instead of super dense and long lines. Unfortunately, this makes a very big PR instead. The pairing development will continue in the next one to not overgrow this too much.
2024-10-06Fully Test EC ImplementationNicholas Rodrigues Lordello
Fully test the elliptic curve implementations, including the curve over Fp2 and Fp12, as well as twisting points from E2 to E12.
2024-10-01Added More Tests for BLS12-381 CurvesNicholas Rodrigues Lordello
2024-09-29Implemented Elliptic Curve OperationsNicholas Rodrigues Lordello
This includes operations for all 3 curves relevant to PLONK.
2024-08-16Implemented Point Addition (untested)Nicholas Rodrigues Lordello
2024-08-15Started Implementing Elliptic CurvesNicholas Rodrigues Lordello
Mostly implemented, but notably missing string conversion methods as well as point addition and scalar multiplication.
2024-07-27Collected some resources on EC torsion, formattingNicholas Rodrigues Lordello
2024-07-25Switch to BLS12-381Nicholas Rodrigues Lordello
2024-07-25Notes on elliptic curvesNicholas Rodrigues Lordello
2024-07-25Cleaned Up TestsNicholas Rodrigues Lordello
2024-06-24Add Fp12 TestsNicholas Rodrigues Lordello
Additionally, slight refactor to make the `field.ml` module **ONLY** include the module type signature definition.
2024-06-24Implement Polynomial Extension FieldsNicholas Rodrigues Lordello
Notably, only `Fp[X]/1+x^2`, or `Fp2` is tested at the moment. More tests for `Fp12` coming right up!
2024-06-18Journal and next stepsNicholas Rodrigues Lordello
In this commit, we refactor the module to contain all the fields that we need: namely the prime field for the BN254 curve, but also the extension fields (polynomial rings) needed for the elliptic curve pairings used by PLONK. In addition, I added a "journal" for documenting findings as I go as well as useful resources I used when implementing this from scratch.
2024-06-17Implement Finite Prime FieldNicholas Rodrigues Lordello
Adds a finite prime field implementation that is used by the BN254 curve and pairings. Extended finite fields will be coming next.