You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request integrates field specifications from Arklib into the library, focusing on non-binary prime fields. It introduces both the infrastructure for formal primality proofs and the definitions for several widely used elliptic curve scalar fields.
Features
New Finite Field Implementations: Added definitions and formal primality proofs for several industry-standard prime fields:
Elliptic Curve Fields: BLS12-377, BLS12-381, BN254, and Secp256k1 (base and scalar).
STARK-friendly Fields: BabyBear, Goldilocks, and KoalaBear (including precomputed 2-adic roots of unity).
Mersenne Fields: Mersenne-31 ($2^{31} - 1$).
Pratt Primality Certificates: Implemented a pratt tactic and supporting infrastructure to automate formal proofs of primality using the Lucas test.
Non-Binary Field Abstraction: Introduced the NonBinaryField type class to provide a unified interface for non-binary field operations.
Refactoring
Library Reorganization: Centralized finite field imports in the main CompPoly.lean entry point.
Identity Logic: Established coefficient identities for polynomial compositions (specifically for $-X$ and $X^2$) within CompPoly/Fields/Basic.lean to support broader polynomial arithmetic.
Documentation
Fields Documentation: Added a new README.md in the CompPoly/Fields/ directory explaining the included scalar prime fields and the methodology for their formal primality proofs.
Analysis of Changes
Metric
Count
📝 Files Changed
12
✅ Lines Added
1219
❌ Lines Removed
0
sorry Tracking
❌ **Added:** 9 `sorry`(s)
lemma cube_map_bijective : in CompPoly/Fields/KoalaBear.lean
def twoAdicGenerators : List Field in CompPoly/Fields/KoalaBear.lean
lemma isPrimitiveRoot_twoAdicGenerator (bits : Fin (twoAdicity + 1)) : in CompPoly/Fields/KoalaBear.lean
lemma twoAdicGenerators_order (bits : Fin (twoAdicity + 1)) : in CompPoly/Fields/KoalaBear.lean
lemma coprime_three_fieldSize_sub_one : Nat.Coprime 3 (fieldSize - 1) in CompPoly/Fields/KoalaBear.lean
lemma twoAdicGenerators_pow_twoPow_eq_one (bits : Fin (twoAdicity + 1)) : in CompPoly/Fields/KoalaBear.lean
lemma twoAdicGenerator_unit_mem_rootsOfUnity in CompPoly/Fields/KoalaBear.lean
lemma twoAdicGenerators_pow_twoPow_ne_one_of_lt in CompPoly/Fields/KoalaBear.lean
lemma inv_eq_pow (a : Field) (ha : a ≠ 0) : a⁻¹ = a ^ (fieldSize - 2) in CompPoly/Fields/KoalaBear.lean
🎨 **Style Guide Adherence**
Based on the provided style guide, here are the lines that violate the guidelines:
CompPoly/Fields/Secp256k1.lean:139:theorem ScalarField_is_prime : Nat.Prime SCALAR_FIELD_CARD := by
Violation: "Theorems and Proofs: snake_case" (Capitalization of ScalarField).
CompPoly/Fields/BLS12_377.lean:33:theorem ScalarField_is_prime : Nat.Prime scalarFieldSize := by
Violation: "Theorems and Proofs: snake_case" (Capitalization of ScalarField).
CompPoly/Fields/BN254.lean:21:theorem ScalarField_is_prime : Nat.Prime scalarFieldSize := by
Violation: "Theorems and Proofs: snake_case" (Capitalization of ScalarField).
📄 **Per-File Summaries**
CompPoly.lean: Added imports for various finite field implementations and Pratt certificates to the library.
CompPoly/Fields/BLS12_377.lean: Defines the BLS12-377 scalar prime field and establishes its primality using a Pratt certificate.
CompPoly/Fields/BLS12_381.lean: Defines the BLS12-381 scalar field and proves its primality using a Pratt certificate.
CompPoly/Fields/BN254.lean: Defines the BN254 scalar prime field and provides a formal proof of its primality using Pratt certificates.
CompPoly/Fields/BabyBear.lean: This file defines the BabyBear field and provides a proof of its primality using the Pratt certificate tactic.
CompPoly/Fields/Basic.lean: Defines the NonBinaryField type class and establishes coefficient identities for polynomial compositions with $-X$ and $X^2$.
CompPoly/Fields/Goldilocks.lean: Defines the Goldilocks prime field and proves its characteristic is prime using a Pratt certificate.
CompPoly/Fields/KoalaBear.lean: Defines the KoalaBear finite field ($2^{31} - 2^{24} + 1$), including its primality proof and precomputed 2-adic roots of unity.
CompPoly/Fields/Mersenne.lean: Defines the Mersenne-31 prime field ($2^{31} - 1$) and provides a proof of its primality using a Pratt certificate.
CompPoly/Fields/PrattCertificate.lean: Implements Pratt primality certificates and an automated pratt tactic for proving primality using the Lucas test.
CompPoly/Fields/README.md: Added a README documenting the scalar prime fields for common elliptic curves and their associated formal primality proofs.
CompPoly/Fields/Secp256k1.lean: Defines the Secp256k1 base and scalar prime fields and provides their primality proofs using Pratt certificates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request imports field specs from Arklib, starting with nonbinary fields.
Corresponds to a sister pull request: Verified-zkEVM/ArkLib#309