Part 5 - Mathematical Foundation (Bilinear Pairing)
Part 5: Mathematical Foundation
5.1 Symbol Definitions
| Symbol | Description |
|---|---|
| Cyclic groups of prime order | |
| Bilinear pairing function | |
| Generator of | |
| Attribute Universe (ขนาด ) | |
| Hash function mapping attributes to group elements | |
| (MSK) | Master key |
| Public key | |
| User's secret key (based on attributes) |
5.2 Background - Bilinear Pairing
Properties:
|G| = |G_T| = p
g ∈ G, ⟨g⟩ = G (g generates G)
e : G × G → G_T (pairing function)
Bilinearity Property (สำคัญมาก!):
Why important? คุณสมบัตินี้ทำให้เรา "ย้าย" exponents ได้ใน pairings ซึ่งสำคัญมากสำหรับกระบวนการถอดรหัส
Example:
ถ้ามี: g^a และ g^b
Pairing: e(g^a, g^b) = e(g,g)^(ab)
สามารถ "คูณ exponents" ได้!
5.3 Pairing Operation Example
Given:
Prime order p = 101
Generator g = 2
Random exponents a = 5, b = 7
Step 1: คำนวณค่าใน G₁
A = g^a mod p = 2^5 mod 101 = 32
B = g^b mod p = 2^7 mod 101 = 128 mod 101 = 27
Step 2: คำนวณ Pairing
e(A, B) = e(g^a, g^b) = e(g,g)^(ab)
ab = 5 × 7 = 35
e(g,g)^35 = 2^35 mod 101 = 97
Result: e(32, 27) = 97
Summary Table:
| Step | Computation | Result |
|---|---|---|
| Compute | 32 | |
| Compute | 27 | |
| Compute Pairing | 97 |
5.4 Why Pairing is Important
ใน CP-ABE Pairing ช่วย:
1. Verification
ตรวจสอบว่า user's attributes satisfy policy
2. Decryption
อนุญาตให้เฉพาะ authorized users
คำนวณ correct decryption key ได้
At Leaf Node:
DecryptNode(x) = e(D_i, C_x) / e(D'_i, C'_x)
= e(g,g)^(r·q_x(0))
สำเร็จก็ต่อเมื่อ:
✅ User มี attribute i
✅ Secret key มี matching components (D_i, D'_i)
ถ้า i ∉ S:
❌ DecryptNode(x) = ⊥ (fail)
Pairings รับประกันว่า: เฉพาะ valid attributes เท่านั้นที่สร้าง valid shares!
5.5 Computational Cost
สำคัญมาก! จำให้ได้:
| Operation | Computational Cost |
|---|---|
| Pairing | High ⚠️ |
| Exponentiation | Moderate |
| Multiplication in | Low |
Pairing > Exponentiation > Multiplication
Impact:
Decryption ใน CP-ABE ต้องทำ multiple pairings
↓
Computationally expensive!
↓
⚠️ ต้อง optimize operations
Part 6: CP-ABE Scheme Details
6.1 Setup Phase
Attribute Authority (AA) สร้าง:
1. เลือก random values:
α, β ← Zₚ (random)
2. Public Key:
PK = (g, g^β, e(g,g)^α)
3. Master Secret Key:
MSK = (β, g^α)
จุดประสงค์:
- PK - เผยแพร่ให้ทุกคน (สำหรับ encrypt)
- MSK - เก็บลับ (สำหรับสร้าง user keys)
6.2 KeyGen (การสร้าง User Key)
Input:
- Master Key (MK)
- Set of attributes
Output:
- User's secret key
Algorithm:
1. เลือก random r ∈ Zₚ
2. เลือก random rⱼ ∈ Zₚ สำหรับแต่ละ attribute j ∈ S
3. คำนวณ key:
Key Insight: Random value "ผูก" key components ทั้งหมดเข้าด้วยกัน / แต่ละ user ได้ ต่างกัน ทำให้ keys จาก users ต่างกัน incompatible สำหรับการรวมกัน
Example:
Sarah's key: r_Sarah = 123
Kevin's key: r_Kevin = 456
Because r_Sarah ≠ r_Kevin:
→ Key components ใช้ร่วมกันไม่ได้
→ ✅ Collusion resistant!
6.3 Encrypt (การเข้ารหัส)
Input:
- Public Key (PK)
- Message (M)
- Access Tree (T)
Output:
- Ciphertext (CT)
Algorithm:
Step 1: Secret Sharing
สำหรับแต่ละ node x ใน tree:
เลือก polynomial qₓ โดยที่:
- degree dₓ = kₓ - 1
- kₓ = threshold value ของ node นั้น
Step 2: Root Node
1. เลือก random s ∈ Zₚ
2. ตั้ง q_R(0) = s
3. เลือก d_R points อื่นแบบ random เพื่อกำหนด q_R
Step 3: Other Nodes
สำหรับ node x อื่นๆ:
1. ตั้ง qₓ(0) = q_parent(x)(index(x))
2. เลือก dₓ points อื่นแบบ random
Step 4: Ciphertext
ให้ Y = leaf nodes ใน T
Ciphertext:
How it works: Secret ถูก "แบ่ง" ข้าม access tree โดยใช้ polynomial secret sharing / ถอดรหัสได้ก็ต่อเมื่อมี attributes เพียงพอที่จะ satisfy policy และ reconstruct
6.4 Decrypt (การถอดรหัส)
Recursive Algorithm: DecryptNode(CT, SK, x)
Case 1: Leaf Node
ถ้า x เป็น leaf node:
ให้ i = att(x)
If i ∈ S (user มี attribute นี้):
If i ∉ S (user ไม่มี attribute นี้):
DecryptNode(CT, SK, x) = ⊥ (fail)
No pairing → no reconstruction: ถ้าไม่มี matching attribute, user ไม่สามารถคำนวณ pairing value ที่จำเป็นได้
Case 2: Internal Node
ใช้ Lagrange interpolation "in the exponents"
รวม values จาก child nodes
Final Step: Recover Message
1. User คำนวณ pairing:
e(C, g^α) = e(g^s, g^α) = e(g,g)^(αs)
2. Reconstruct หลังจาก traverse access tree
3. คำนวณ Message:
Why "in the exponents"? เราทำงานกับค่าที่เข้ารหัสเช่น ไม่ใช่ โดยตรง / Lagrange interpolation ทำให้เราสามารถ reconstruct secret จาก shares แม้ว่า shares เหล่านั้นจะ "ซ่อน" อยู่ใน exponents
Part 7: Policy Features
7.1 Leaf Nodes (Attributes)
String Attributes:
- department
- role
- location
Numerical Attributes with Comparisons:
- hire_date < 2002
- exec_level >= 5
- age > 21
- salary >= 50000
7.2 Internal Nodes (Logical Operators)
Basic Gates:
- AND gates
- OR gates
Advanced Gates:
- k of n threshold gates
- Example: "2 of 3" = ต้องมีอย่างน้อย 2 ใน 3 attributes
7.3 Example Policy Tree
ACP1
│
OR
/ \
2 of 3 AND
/ | \ / \
exec≥5 sales IT mgr OR
/ \
mktg hire<2002
Policy ในภาษาคน:
สามารถถอดรหัสได้ถ้า:
(มี 2 ใน 3 อย่างนี้:
- executive level >= 5
- ใน sales
- ใน IT dept.)
OR
(เป็น manager AND (ใน marketing OR จ้างก่อน 2002))
Reading the policy: "คุณถอดรหัสได้ถ้า (exec level 5+ OR ใน sales OR ใน IT dept - อย่างน้อย 2 ใน 3) OR (เป็น manager AND (ใน marketing OR จ้างก่อน 2002))"
Part 8: CP-ABE in Practice
8.1 What is CP-ABE?
Summary:
- Cryptographic-based Access Control
- Fine-grained AC - Enforce through user attributes
- Combines AC policy + Encryption - ใช้ policy เพื่อ encrypt!
- One-to-many encryption
Key Points:
✅ Enforce AC policy บน traditional encryption
✅ Works with AES, RSA, ECC
✅ Encryption + Access policy in one
Cost Hierarchy:
Pairing > Exponentiation > Multiplication
8.2 Real-World Usage: Hybrid Encryption
Problem:
CP-ABE ช้า (pairing-based crypto)
↓
ไม่เหมาะกับไฟล์ใหญ่
Solution: Hybrid Encryption
Step 1: เข้ารหัสไฟล์ด้วย AES (เร็ว!)
File → AES encrypt with SymKey → CT_M
Step 2: เข้ารหัส SymKey ด้วย CP-ABE (ใส่ policy!)
SymKey → CP-ABE encrypt with Policy T → CT_Key
Step 3: เก็บทั้งสอง
- Encrypted file (AES)
- Encrypted key (CP-ABE with policy)
Formula:
Enc_AES(M, SymKey) = CT_M
Enc_CP-ABE(SymKey, Policy T) = CT_Key
Send: (CT_M, CT_Key)
Why This Works:
✅ Fast (AES เร็ว)
✅ Secure (CP-ABE ปลอดภัย)
✅ Fine-grained (Policy ใน CP-ABE)
เปรียบเทียบ: เหมือนใส่เงินในกล่องนิรภัย (AES encrypts file) แล้วใช้กุญแจพิเศษที่มีแค่คนที่มี attributes ถูกต้องถึงจะใช้ได้ (CP-ABE encrypts key)
8.3 Revocation in CP-ABE
8.3.1 User Revocation
Question: ถ้ามี user ถูก revoke ล่ะ?
Answer: ได้ แต่ not for free! 😅
Problem:
CP-ABE แบบพื้นฐานไม่มี revocation ในตัว
Solution (Straightforward):
Step 1: Re-encrypt data
- สร้าง SymKey ใหม่
- Encrypt file ใหม่ด้วย AES
Step 2: Update policy
- เปลี่ยน policy T → T'
- ตัด user ที่โดน revoke ออก
Step 3: Re-encrypt key
- Encrypt SymKey ใหม่ด้วย CP-ABE policy T'
Step 4: Update user keys
- AA updates secret keys (SKs) ของ active users ทั้งหมด
- Redistribute keys ใหม่
Cost:
❌ Re-encryption cost
❌ Re-key generation cost
❌ Key redistribution cost
สรุป: If a user is revoked, the data owner needs to re-encrypt the data (or at least the key).
8.3.2 Attribute Revocation
Scenario:
ใน CP-ABE:
- Policy อยู่ใน ciphertext
- User ถือ SK ที่ผูกกับ attributes
ถ้า revoke แค่ attribute เดียว (เช่น studentNumber):
- ผู้ใช้หลายคนอาจมี attribute นี้
- แต่เราไม่อยาก revoke ทุกคน แค่บางคน
Problem:
❌ ลบ attribute ออกจากระบบเฉยๆ ไม่พอ!
Solution (Attribute Versioning):
Step 1: นิยาม attribute ใหม่
เดิม: studentNumber
ใหม่: studentID_v2
Step 2: Update policy
จาก T → T'
เปลี่ยนให้ใช้ studentID_v2 แทน studentNumber
Step 3: Re-encrypt
- สร้าง SymKey ใหม่
- Encrypt file ใหม่ด้วย AES
- Encrypt SymKey ใหม่ด้วย CP-ABE ภายใต้ policy T'
Step 4: AA redistributes keys
- แจก secret keys ใหม่ให้เฉพาะผู้ใช้ที่ยัง valid
- คนที่โดน revoke ไม่ได้ attribute เวอร์ชันใหม่
→ ถอดรหัสไม่ได้
สรุป: Attribute revocation in basic CP-ABE requires re-keying, policy update, and re-encryption.
Alternative Approaches:
- Attribute expiration (time-based attributes)
- Proxy re-encryption
- Advanced CP-ABE schemes with revocation
Part 9: Performance & Implementation
9.1 Encryption & Decryption Details
Encryption:
- ใช้ general secret sharing techniques เพื่อ model policy
- One ciphertext component per leaf node
- Size of CT ∝ number of leaf nodes (attributes) ใน Policy
Decryption:
- ใช้ Lagrange interpolation "in the exponents"
9.2 Private Key Generation - Binding Mechanism
The Secret:
Desired attributes: x₁, x₂, ..., xₙ
Random values: r, r_x₁, r_x₂, ..., r_xₙ ← Zₚ
SK = (g^((α+r)/β),
g^r · H(x₁)^(r_x₁), g^(r_x₁),
...
g^r · H(xₙ)^(r_xₙ), g^(r_xₙ))
Key Points:
- ✅ "Binds" key components เข้าด้วยกัน (ผ่าน shared random )
- ✅ Components จาก keys ต่างกัน incompatible
- ✅ Key to preventing collusion attacks
Why this works: ทุก key component มี secret random value / เนื่องจาก Sarah's ≠ Kevin's → key components ของพวกเขาใช้ร่วมกันไม่ได้
9.3 Performance Benchmarks
Test Environment:
- 64-bit AMD 3.7 GHz workstation
Results:
| Operation | Approximate Time |
|---|---|
| Private key gen. | 35 ms per attribute |
| Encryption | 27 ms per leaf node |
| Decryption | 0.5–0.8 ms per leaf node |
Observations:
✅ Essentially no overhead นอกจาก group operations
⚠️ เวลาขึ้นอยู่กับจำนวน attributes/leaf nodes
9.4 Implementation: cp-abe Toolkit
Command Examples:
# Setup: สร้าง PK และ MSK
$ cpabe-setup
# KeyGen: สร้าง user's private key
$ cpabe-keygen -o sarah_priv_key pub_key master_key \
sysadmin it_dept 'office = 1431' 'hire_date = 2002'
# Encrypt: เข้ารหัสไฟล์ด้วย policy
$ cpabe-enc pub_key security_report.pdf \
"(sysadmin and (hire_date < 2005 or security_team)) or \
2 of (executive_level >= 5, audit_group, strategy_team))"Availability:
- GPL source ที่ ACSC (Advanced Crypto Software Collection)
- http://acsc.csl.sri.com
Part 10: Advantages, Disadvantages & Security
10.1 Advantages ✅
- Support fine-grained Access Control
- ควบคุมได้ถึงระดับ individual user
- Flexible and Scalable key management
- แต่ละ user มีแค่ one key
- ไม่ว่าจะ share กับกี่คน
- Multiple user access
- ไม่ต้องมี 3rd party online mechanism
- Data owner defines policy
- เจ้าของข้อมูลกำหนด policy เองได้
10.2 Disadvantages ❌
-
Public key encryption (kind of) - slow performance
- Pairing operations แพง
-
Not suitable for encrypting big files directly
- ต้องใช้ Hybrid encryption
-
Revocation is costly
- ต้อง re-encrypt
- ต้อง re-key generation
-
Dynamic environments
- Users บ่อย join/leave = ปัญหา
Solution: ใช้ CP-ABE encrypt symmetric key แล้วใช้ symmetric encryption สำหรับไฟล์ใหญ่ = Hybrid approach = flexibility ของ CP-ABE + efficiency ของ symmetric encryption
10.3 Security
Proven Secure:
✅ Collusion resistance
✅ Assumes random oracle model
✅ Assumes generic group model
Assumptions:
"Black box" heuristic
= "วิธีเดียวที่จะทำลายได้คือ brute force"
= Computationally infeasible สำหรับ parameters ที่เลือกอย่างถูกต้อง
Future Work:
- Scheme without generic group model assumption
- Better revocation mechanisms
- Improved efficiency
Part 11: Summary & Comparison
11.1 What CP-ABE Solves
✅ Solutions:
- Flexible, expressive access policies
- One key per user (scalable)
- Offline key setup
- No trusted online mediator
- Collusion resistance
- Fine-grained access control
⚠️ Limitations:
- Slower than symmetric encryption
- Revocation is costly
- Not ideal for very large files directly
11.2 Best Use Cases
✅ เหมาะสำหรับ:
- Cloud storage with complex access requirements
- Healthcare records (HIPAA compliance)
- Government classified documents
- Corporate confidential files
- Multi-user collaborative environments
- Untrusted cloud environments
❌ ไม่เหมาะสำหรับ:
- Real-time streaming
- Very large files (use hybrid)
- High-frequency updates
- Simple 1-to-1 encryption
11.3 Comparison with Traditional Methods
| Feature | Traditional Symmetric | Traditional Asymmetric | CP-ABE |
|---|---|---|---|
| Key per user | ❌ Multiple or shared | ❌ One per recipient | ✅ One per user |
| Fine-grained AC | ❌ No | ❌ No | ✅ Yes |
| Expressive policies | ❌ No | ❌ No | ✅ Yes |
| Performance | ✅ Fast | ⚠️ Slow | ❌ Slower |
| Scalability | ❌ Poor | ❌ Poor | ✅ Good |
| Collusion resistance | ❌ No | ❌ No | ✅ Yes |
| Revocation cost | ❌ High | ❌ High | ⚠️ Very high |
11.4 Related Work Comparison
| Scheme | Collusion Resistant | Policies | Attributes in | Policy in |
|---|---|---|---|---|
| [1,2] | Yes | Single threshold | Ciphertext | Key |
| [3] | Yes | Monotone formulas | Ciphertext | Key |
| CP-ABE (This) | Yes | Monotone formulas | Key | Ciphertext |
| [4]* | No | All boolean | Key | Ciphertext |
*มี policy hiding property แต่ต้องการ online semi-trusted server
สรุปท้ายบท
Key Takeaways:
1. Problem:
Traditional crypto ไม่เหมาะกับ cloud
- Symmetric: Key distribution & revocation ยาก
- Asymmetric: Multiple copies, ช้า
2. Solution:
CP-ABE = Attribute-Based Encryption
- Bind keys กับ attributes แทน persons
- Encrypt ด้วย policies over attributes
- Decrypt ได้ถ้า attributes satisfy policy
3. Core Concepts:
- Attributes: คุณสมบัติของ user
- Policy: เงื่อนไขการถอดรหัส (AND, OR, threshold)
- Collusion resistance: ป้องกันการรวม keys
- Pairing: Mathematical foundation
4. Practical Usage:
✅ Hybrid: AES encrypts file, CP-ABE encrypts key
✅ Fine-grained access control
✅ One key per user
❌ Revocation costly
❌ Slow for big files
5. Real-world:
Best for: Cloud storage, healthcare, government
Use with: Hybrid encryption approach
Watch out for: Revocation overhead
Final Quote
"CP-ABE provides a powerful solution for fine-grained access control in cloud storage environments where traditional encryption methods fall short."
สรุปสั้นๆ:
CP-ABE = Encryption + Fine-grained Access Control
= Attributes + Policies + Collusion Resistance
= Perfect for Cloud + Complex Access Requirements