Path: blob/main/frontier/07-pairings/sage/07d-bls-signatures.ipynb
483 views
Notebook 07d: BLS Signatures
Module 07. Bilinear Pairings
Motivating Question. ECDSA (Module 06) produces a signature , two scalars, each the size of the group order. Can we do better? BLS signatures produce a single curve point as the signature, cutting the size in half. Even more remarkably, multiple BLS signatures can be aggregated into a single signature that verifies all at once. This is why Ethereum 2.0 uses BLS, thousands of validator signatures compress into one. How does bilinearity make this possible?
Prerequisites. You should be comfortable with:
Bilinear maps: (Notebook 07a)
Pairing-friendly curves and embedding degree (07c)
Digital signatures: sign/verify paradigm (Module 06, ECDSA)
Learning objectives. By the end of this notebook you will be able to:
Implement BLS key generation, signing, and verification from scratch.
Understand why the verification equation works (using bilinearity).
Aggregate multiple signatures and verify the aggregate.
Identify the rogue key attack and understand proof-of-possession as a defense.
1. BLS Signature Scheme Overview
Bridge from Module 06. In ECDSA, verification requires computing and checking an x-coordinate. BLS verification is simpler: a single pairing equation. The trade-off: BLS needs a pairing-friendly curve (more expensive arithmetic), but the signature is shorter and aggregation is trivial.
Setup: A pairing-friendly curve with groups of prime order , generators and , and pairing .
Hash-to-curve: A function that maps messages to curve points.
| Algorithm | Operation | Result |
|---|---|---|
| KeyGen | Pick random , compute | |
| Sign | Compute | |
| Verify | Check | True/False |
2. Key Generation
3. Signing
To sign message :
Hash the message to a curve point: .
Multiply by the secret key: .
That's it! The signature is a single point in .
4. Verification
To verify signature on message with public key , check:
Why does this work? If and :
Both sides equal . Bilinearity does all the work!
Checkpoint 1. BLS verification requires computing two pairings and comparing them. In practice, this is optimized to a single "pairing product" check: . Pairing computation is more expensive than scalar multiplication, but the simplicity of the scheme makes up for it.
5. Comparison: BLS vs ECDSA
| Feature | ECDSA | BLS |
|---|---|---|
| Signature size | 2 scalars (64 bytes at 256-bit) | 1 curve point (48 bytes compressed) |
| Verification | 1 scalar mul + 1 multi-scalar mul | 2 pairings |
| Nonce required? | Yes (catastrophic if reused!) | No (deterministic) |
| Aggregation | Not possible | Yes, key advantage |
| Curve type | Any EC group | Pairing-friendly only |
| Speed (sign) | Fast | Slightly slower (hash-to-curve) |
| Speed (verify) | Fast | Slower (pairings expensive) |
6. Signature Aggregation
The killer feature of BLS: aggregation. Given signatures from different signers on different messages, we can combine them into a single signature that can be verified with a single (multi-)pairing check.
Aggregation:
Verification: Check
Why? By bilinearity:
Checkpoint 2. Aggregation saves space and verification time:
Space: signatures compress to 1 point (48 bytes for BLS12-381, regardless of ).
Verification: Instead of pairings, we need pairings (one per message + one for the aggregate). For same-message aggregation, it's just 2 pairings total.
In Ethereum 2.0, thousands of validator signatures on the same block attestation are aggregated into one.
7. Same-Message Aggregation
When all signers sign the same message (common in consensus protocols), aggregation is even simpler:
Only 2 pairings regardless of how many signers!
8. The Rogue Key Attack
There's a subtle vulnerability in naive same-message aggregation. An attacker Mallory can choose her "public key" as:
Then the aggregated public key becomes just , and Mallory can forge an aggregate signature for any message without the other signers' participation!
Defense: Proof of Possession (PoP). Each signer must prove they know the secret key corresponding to their public key by signing the public key itself: .
Checkpoint 3. The rogue key attack is prevented by requiring each signer to provide a proof of possession (PoP), a BLS signature on their own public key using a separate hash function. This proves they know the secret key and can't construct a rogue key that cancels others. Ethereum 2.0 validators must submit a PoP when registering.
Misconception alert. "BLS aggregation is always safe." No, naive aggregation is vulnerable to the rogue key attack. You need either (a) proof of possession for same-message aggregation, or (b) distinct-message aggregation (where each signer uses a unique message), or (c) the "message augmentation" scheme where each message is prepended with the signer's public key.
9. Exercises
Exercise 1 (Worked): BLS Round Trip
Problem. Generate a BLS key pair. Sign the message "Consensus reached". Verify the signature. Then change one character in the message and show verification fails.
Solution:
Exercise 2 (Guided): Five-Signer Aggregation
Problem. Create 5 signers, each signing the same message "Block 500 is valid". Aggregate all 5 signatures and verify the aggregate with just 2 pairings.
Fill in the TODOs:
Exercise 3 (Independent): Rogue Key Defense
Problem.
Implement a
proof_of_possession(sk, pk)function that returns (use a different hash-to-curve for PoP).Implement
verify_pop(pk, pop)that checks .Show that a legitimate signer can produce a valid PoP, but Mallory's rogue key cannot (because Mallory doesn't know the discrete log of her rogue key).
Modify the aggregation scheme to require a valid PoP from each signer before accepting their public key.
Summary
| Concept | Key Fact |
|---|---|
| BLS KeyGen | , |
| BLS Sign | , one point, no nonce needed |
| BLS Verify | , one pairing equation |
| Aggregation | ; verify with product of pairings |
| Same-message | Only 2 pairings: |
| Rogue key attack | Attacker crafts to cancel others; prevented by proof of possession |
BLS signatures are the most elegant pairing-based protocol: short, deterministic, and aggregatable. In the final notebook, we'll see how pairings enable something even more surprising: identity-based encryption.