Path: blob/main/frontier/07-pairings/sage/07c-pairing-friendly-curves.ipynb
483 views
Notebook 07c: Pairing-Friendly Curves
Module 07. Bilinear Pairings
Motivating Question. Not every elliptic curve supports efficient pairings. For a random curve over a 256-bit prime, the embedding degree is astronomically large, making the pairing target field computationally infeasible. How do we find curves where is small enough to compute with, yet large enough for security? This is the art of pairing-friendly curve construction.
Prerequisites. You should be comfortable with:
The Weil pairing and its properties (Notebook 07b)
Embedding degree : smallest integer with (07a, 07b)
Extension fields (Module 02/03)
Learning objectives. By the end of this notebook you will be able to:
Compute the embedding degree for a given curve and subgroup.
Understand why most curves are not pairing-friendly.
Know the key families of pairing-friendly curves (supersingular, MNT, BN, BLS).
Appreciate the security implications of the embedding degree.
1. The Embedding Degree
Bridge from Notebook 07b. In the previous notebooks, we saw that the pairing maps into where is the embedding degree, the smallest positive integer such that the subgroup order divides .
The embedding degree determines:
Efficiency: Arithmetic in costs roughly times as much as in . Smaller = faster pairing.
Security: The DLP in can be attacked by index-calculus methods. Larger = harder DLP in .
We need in a "Goldilocks zone": small enough for efficiency, large enough for security.
Checkpoint 1. For our supersingular curve over , the embedding degree is for all prime-order subgroups. This is typical of supersingular curves, they always have small embedding degree (). This makes them natural candidates for pairing-based crypto.
2. Why Most Curves Are NOT Pairing-Friendly
For a "random" elliptic curve, the embedding degree is essentially , which is for a 256-bit curve. Computing in is utterly impossible.
Let's verify this empirically:
3. Families of Pairing-Friendly Curves
Since random curves don't work, cryptographers have identified specific families of curves with small, controlled embedding degrees:
| Family | Embedding degree | Typical use | Key feature |
|---|---|---|---|
| Supersingular | Teaching, simple constructions | $ | |
| MNT | Early pairing crypto | Found by CM method | |
| Barreto-Naehrig (BN) | SNARKs (Groth16), Ethereum | Parameterized by a single integer | |
| BLS (Barreto-Lynn-Scott) | Ethereum 2.0 (BLS12-381) | Better security margin than BN |
4. Supersingular Curves
We've been using supersingular curves () throughout this module. They are the simplest pairing-friendly curves.
Key properties:
Trace of Frobenius (i.e., ).
Embedding degree (for -invariant : ).
Easy to construct: over with is always supersingular.
Downside: The small embedding degree means lives in a relatively small extension field, which limits security. For 128-bit security, you need (since for the DLP in ).
5. BN Curves (Barreto-Naehrig)
BN curves are a family of pairing-friendly curves with embedding degree . They are parameterized by a single integer :
The curve is over for a suitable .
Properties:
always.
and are both prime (for suitable ).
where (trace of Frobenius).
Used in SNARKs (Groth16) and was the curve of choice for Ethereum's pairing precompile (alt_bn128).
Misconception alert. "BN curves always have (prime order)." Yes, this is by design. The BN family is constructed so that is prime, meaning there's no cofactor (). This simplifies the protocol (no cofactor clearing needed) and ensures every non-identity point is a generator.
6. BLS Curves (Barreto-Lynn-Scott)
After advances in the Number Field Sieve (NFS) for extension fields, BN curves at 128-bit security required larger parameters. The BLS family provides a better security margin.
The most famous: BLS12-381, used in Ethereum 2.0, Zcash, and many other systems.
| Parameter | BLS12-381 |
|---|---|
| Embedding degree | |
| Field size () | 381 bits |
| Subgroup order () | 255 bits |
| Security level | bits |
| field size | bits |
7. Security: Balancing the Two DLPs
A pairing-based system has two discrete log problems:
ECDLP in (or ): best attack is Pollard's rho, operations.
DLP in : best attack is the Number Field Sieve, roughly .
The security level is the minimum of these two. We want them to be roughly balanced:
| Security level | needs | needs | |----------------|-----------------|---------------------------| | 128-bit | | or more | | 192-bit | | | | 256-bit | | |
Checkpoint 2. The takeaway: embedding degree determines the tradeoff.
Too small (): DLP in is easy → insecure (this is the MOV attack).
Too large (): Can't compute in → pairing is useless.
Just right ( for BN/BLS at 128-bit security): Efficient and secure.
The MOV (Menezes-Okamoto-Vanstone) attack uses the pairing itself to reduce the ECDLP to a DLP in . This is why non-pairing curves must avoid having small embedding degree.
8. The MOV Attack: When Pairings Work Against You
If a curve has a small embedding degree but you're trying to use it for non-pairing crypto (like ECDH), the pairing becomes an attack:
Attacker wants to solve ECDLP: given , find .
Compute and for some auxiliary point .
Now solve the DLP in , where and .
If is small enough, index calculus solves this quickly.
This is why secp256k1 and P-256 have enormous embedding degrees, they must be immune to MOV.
Crypto foreshadowing. Pairing-friendly curves are the foundation of:
BLS signatures (next notebook): sign = hash to curve + scalar mul; verify = one pairing check.
Groth16 SNARKs (Module 10): trusted setup on a pairing curve; verification = 3 pairings.
KZG commitments (Module 10): polynomial commitment scheme using a single pairing check.
The choice of curve (BN254 vs BLS12-381) affects both performance and security of these systems.
9. Exercises
Exercise 1 (Worked): Computing Embedding Degree
Problem. For the curve over , find , its largest prime factor , and the embedding degree .
Solution:
Exercise 2 (Guided): BN Curve Construction
Problem. Find the smallest such that BN parameters and are both prime. Construct the curve and verify that and the embedding degree is 12.
Fill in the TODOs:
Exercise 3 (Independent): MOV on a Larger Curve
Problem.
Use the supersingular curve over (embedding degree ).
Choose a prime-order subgroup. Create an ECDLP instance with a random secret .
Implement the MOV attack: use the Weil pairing to reduce to a DLP in .
Solve the DLP in using SageMath's
discrete_logfunction.Verify you recovered the correct secret.
Summary
| Concept | Key Fact |
|---|---|
| Embedding degree | Smallest with ; determines |
| Random curves | Have (huge) → pairing is infeasible |
| Supersingular | Always have ; simplest pairing-friendly curves |
| BN curves | , parameterized by ; used in SNARKs |
| BLS curves | ; BLS12-381 is the standard for 128-bit security |
| MOV attack | Pairing reduces ECDLP to DLP in , small is dangerous for non-pairing curves |
| Security balance | Must balance ECDLP security () with DLP security () |
Now that we know which curves to use, we're ready to build real protocols. Next: BLS signatures, arguably the most elegant signature scheme.
Next: 07d: BLS Signatures