Path: blob/main/frontier/07-pairings/sage/07e-identity-based-encryption.ipynb
483 views
Notebook 07e: Identity-Based Encryption
Module 07. Bilinear Pairings
Motivating Question. To send Alice an encrypted email, you first need her public key. But how do you get it? You look it up in a directory, verify a certificate, check a chain of trust... What if you could just encrypt directly to [email protected], no certificate needed? Identity-based encryption (IBE) makes this possible, and bilinear pairings are the key ingredient.
Prerequisites. You should be comfortable with:
Bilinear maps: (Notebook 07a)
Pairing-friendly curves (Notebook 07c)
BLS signatures (Notebook 07d), IBE uses the same pairing machinery
Learning objectives. By the end of this notebook you will be able to:
Explain why IBE is useful and how it differs from traditional public-key encryption.
Implement the Boneh-Franklin IBE scheme step by step.
Verify correctness using bilinearity.
Identify the key escrow problem and understand mitigation strategies.
1. The Certificate Problem
In traditional public-key encryption (RSA, ElGamal, ECIES):
Bob generates a key pair .
Bob registers with a Certificate Authority (CA).
The CA issues a certificate binding Bob's identity to .
Alice fetches Bob's certificate, verifies the CA's signature, extracts .
Then Alice can encrypt.
This infrastructure (PKI) is complex, expensive, and fragile. Certificate revocation is notoriously hard.
Shamir's 1984 vision: What if Bob's identity string (email, phone number, employee ID) is his public key? Then Alice doesn't need certificates at all, she just encrypts to [email protected].
| Traditional PKE | Identity-Based Encryption |
|---|---|
| Bob generates | Trusted authority generates master params |
| CA certifies to Bob's identity | Bob's identity is his public key |
| Alice needs Bob's certificate | Alice needs only Bob's identity string |
| Revocation via CRL/OCSP | Revocation via key epochs (e.g., [email protected]‖2026) |
2. IBE Architecture
An IBE scheme has four algorithms:
| Algorithm | Who runs it | What it does |
|---|---|---|
| Setup | Private Key Generator (PKG) | Generates master secret and public parameters |
| Extract | PKG | Derives a private key from the master secret and identity string |
| Encrypt | Anyone (sender) | Encrypts a message to an identity string using only public params |
| Decrypt | Key holder | Decrypts using the extracted private key |
The PKG (Private Key Generator) is a trusted authority, like a CA, but it issues private keys rather than certificates.
Crypto foreshadowing. The PKG knows everyone's private key, this is the key escrow problem. We'll discuss mitigations at the end. In Module 09, we'll see how threshold secret sharing can distribute the PKG's trust across multiple parties.
3. Boneh-Franklin IBE: Setup
Boneh and Franklin (2001) gave the first practical IBE scheme, using bilinear pairings. Let's build it step by step on our toy curve.
Setup: The PKG:
Chooses a pairing-friendly curve with groups of prime order .
Picks generators , .
Picks a random master secret .
Computes the master public key .
Publishes as public parameters.
Here maps identity strings to curve points, and extracts a key from a pairing output.
4. Hash Functions
We need two hash functions:
, maps an identity string to a point in .
, derives a symmetric key from a pairing output.
In practice, is a hash-to-curve function and is a key derivation function (KDF). For our toy example, we'll use simplified versions.
5. Key Extraction
When Bob wants his private key, he authenticates to the PKG (shows his passport, proves he owns [email protected], etc.). The PKG then computes:
This is Bob's private key, a point in . The PKG sends it to Bob over a secure channel.
Misconception alert. "The PKG is like a CA." Not quite, a CA never sees your private key. The PKG computes your private key. This is a fundamental difference and the source of the key escrow problem.
Checkpoint 1. Key extraction is just scalar multiplication, exactly like BLS signing! In BLS, the signer computes . In IBE, the PKG computes . The mathematical structure is identical; the meaning is different (signature vs. private key).
6. Encryption
Alice wants to send a secret message to Bob. She knows only:
Bob's identity string
[email protected]The public parameters
Encrypt(ID, ):
Compute .
Pick a random .
Compute .
Compute the shared key: .
Compute .
The ciphertext is .
The crucial observation: Alice computes using only public information, she never needs Bob's private key or even a certificate.
7. Decryption
Bob receives ciphertext and uses his private key .
Decrypt(, ):
Compute the shared key: .
Recover the message: .
Why does this work? Let's trace the math:
Both equal ! Bilinearity lets the decryptor's secret (inside ) and the encryptor's randomness (inside ) combine, even though neither party knows the other's secret value.
8. Correctness Verification
Let's explicitly verify that the pairing values match, this is the heart of why IBE works.
Checkpoint 2. The correctness of IBE rests on the same bilinearity property as BLS verification:
BLS: , the signer's secret moves from one argument to the other.
IBE: , the PKG's secret and the encryptor's randomness combine.
In both cases, bilinearity is the "bridge" that connects values computed by different parties.
9. Wrong Identity Cannot Decrypt
What if Eve (with identity [email protected]) tries to decrypt a message encrypted for Bob?
10. Multiple Recipients Demo
Let's show the complete flow with multiple users.
11. The Key Escrow Problem
The elephant in the room: the PKG knows everyone's private key. It can decrypt any message in the system.
| Issue | Explanation |
|---|---|
| Eavesdropping | PKG can decrypt all ciphertexts |
| Impersonation | PKG can forge decryption keys for any identity |
| Single point of failure | Compromise of breaks everything |
| Legal compulsion | Government can force PKG to reveal keys |
Mitigations
| Strategy | How It Helps |
|---|---|
| Threshold PKG | Master secret is shared among -of- servers; no single server knows |
| Certificateless PKE | User combines PKG-derived key with self-generated key; PKG alone can't decrypt |
| Key epochs | Use identity "[email protected]‖2026-Q1", keys expire naturally, limiting damage window |
| Audit logging | PKG logs all key extractions; anomalous requests are flagged |
Checkpoint 3. Key escrow is not a bug, it's inherent to IBE's design. If the identity string alone determines the public key, then whoever can compute can decrypt. The question is whether the trade-off (no certificates) is worth the trust assumption (honest PKG). For enterprise email encryption within a company, it often is. For end-to-end encryption between strangers, it's not.
12. Key Revocation via Time Periods
An elegant feature of IBE: natural key revocation. Instead of complex certificate revocation lists (CRLs), encode a time period into the identity:
Bob gets a new private key each quarter. Old keys automatically stop working for new ciphertexts.
13. IBE vs. Traditional PKE
| Feature | Traditional PKE (RSA/EC) | IBE (Boneh-Franklin) |
|---|---|---|
| Public key | Random (must be looked up) | Identity string (known a priori) |
| Certificates needed? | Yes (PKI infrastructure) | No |
| Private key generation | User generates own | PKG derives from master secret |
| Key escrow | No (user controls key) | Yes (PKG knows all keys) |
| Revocation | CRLs, OCSP (complex) | Time-based identities (elegant) |
| Encryption offline? | Need certificate first | Yes, only need identity string |
| Mathematical basis | Integer factoring / ECDLP | Bilinear pairings (BDHP) |
| Key size overhead | None | Pairing parameters must be published |
Crypto foreshadowing. The Boneh-Franklin IBE can be extended to Hierarchical IBE (HIBE) where key extraction is delegated down an organizational tree. For instance, a company PKG derives a department key, and the department derives employee keys, without the root PKG being involved in every extraction. HIBE connects to the lattice-based constructions in Module 08, where Gentry, Peikert, and Vaikuntanathan showed how to build IBE from lattice assumptions, achieving post-quantum security.
14. Exercises
Exercise 1 (Worked): Full IBE Round Trip
Problem. Set up a fresh IBE system. Extract private keys for [email protected] and [email protected]. Have Alice encrypt the message to Bob. Have Bob decrypt. Verify correctness.
Solution:
Exercise 2 (Guided): Broadcast Encryption to a Mailing List
Problem. You want to encrypt a message so that anyone on [email protected] can decrypt. With IBE, simply encrypt to that identity string. The PKG extracts one shared private key for the mailing list and distributes it to all team members.
Implement this:
Extract a private key for
"[email protected]".Encrypt to
"[email protected]".Show that each team member (who has the shared key) can decrypt.
Show that an outsider cannot.
Fill in the TODOs:
Exercise 3 (Independent): Attribute-Based Identity
Problem.
Instead of email addresses, use attribute strings as identities. Define three roles:
"role:admin","role:engineer","role:intern".Extract private keys for each role.
Encrypt a confidential message () to
"role:admin".Show that only the admin key can decrypt.
Discuss: how could you encrypt to "admin OR engineer" using IBE? What are the limitations compared to full attribute-based encryption (ABE)?
Summary
| Concept | Key Fact |
|---|---|
| IBE Setup | PKG generates master secret , publishes |
| Key Extraction | , PKG derives private key from identity |
| Encryption | , key , uses only public info |
| Decryption | key , bilinearity ensures same key |
| Key escrow | PKG knows all private keys, mitigate with threshold PKG or certificateless PKE |
| Revocation | Encode time periods in identity: "[email protected]‖2026-Q1" |
This concludes Module 07 on bilinear pairings. We've gone from the abstract definition of bilinear maps, through the Weil pairing and pairing-friendly curves, to two major applications: BLS signatures and identity-based encryption. The common thread is bilinearity, the ability to "move" scalars between pairing arguments, connecting values computed by different parties.
Module complete! Next: Module 08: Lattices and Post-Quantum Cryptography