aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2025-08-11Remove the Test Vector from IETF DraftNicholas Rodrigues Lordello
I could not get the result to match it, or find an implementation that matched it either... I plan on modifying the pairing implementation to match what I consider is the "canonical" one, that is implemented over a Fp12-tower and used in most implementations used in the wild (including Ethereum's and ZCash's).
2025-08-11Experiment With Reference ImplementationNicholas Rodrigues Lordello
We experiment with the test vector from the IETF draft "Pairing-Friendly Curves", but the implementation does not yield the same test result (some coefficients are the same though)... I don't know why, and I cannot find a reference implementation that _does_ return the pairing value from the test vector.
2025-08-10Add Failing Pairing Test VectorNicholas Rodrigues Lordello
2025-08-01Refactor ProjectNicholas Rodrigues Lordello
We now put all field, curve, and pairing instantiations under `bls12_381` module. We no longer have an `E12` curve - since we don't use it.
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-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-07-25Switch to BLS12-381Nicholas 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.