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
OpenTDFKit should adopt post-quantum (PQ) cryptography to protect against future quantum computing threats. This issue proposes an incremental migration strategy using a hybrid classical + PQ approach for the Swift implementation of OpenTDF.
Current Cryptographic Architecture
OpenTDFKit currently uses (via CryptoKit and CryptoSwift):
publicstructHeader{
// Existing fields
publicvarkas:KasMetadatapublicvarephemeralKey:Data // Now can be classical OR hybrid
// New fields for hybrid mode
publicvarpqEphemeralKey:Data? // ML-KEM public key
publicvarpqPolicyBinding:Data? // ML-DSA signature
// Version negotiation
publicstaticletversionV12:UInt8=0x4C // "L1L" - classical
publicstaticletversion:UInt8=0x4D // "L1M" - classical
publicstaticletversionV14Hybrid:UInt8=0x4E // "L1N" - hybrid PQ
}
Swift Ecosystem Challenges
Challenge 1: Limited PQ Libraries
Issue: Swift lacks mature PQ crypto libraries compared to Rust
Mitigation:
Use C/C++ PQ libraries with Swift bridging (e.g., liboqs via C interop)
Contribute to Swift crypto ecosystem
Consider wrapping Rust libcrux via Swift/Rust FFI
Challenge 2: CryptoKit API Constraints
Issue: Apple's CryptoKit doesn't support PQ algorithms yet
Mitigation:
Use CryptoSwift or custom implementations for PQ
Monitor Apple's roadmap for CryptoKit PQ support
Abstract crypto operations behind protocol for easy swapping
Challenge 3: Performance on Mobile
Issue: PQ operations are more expensive than ECC
ML-KEM-768: ~1200 byte public key vs ~33 byte P-256 key
Slower key generation and encapsulation
Mitigation:
KAS operations are already network-bound
Implement async/await efficiently
Cache PQ keys where appropriate
Optimize hot paths with profiling
Recommended Approach
Option A: C Library Bridging (Fastest Path)
// Use liboqs via C interop
import liboqs
publicclassPQCrypto{staticfunc mlKemKeypair()throws->(publicKey:Data, privateKey:Data){
// Call liboqs C functions via Swift C interop
}}
Overview
OpenTDFKit should adopt post-quantum (PQ) cryptography to protect against future quantum computing threats. This issue proposes an incremental migration strategy using a hybrid classical + PQ approach for the Swift implementation of OpenTDF.
Current Cryptographic Architecture
OpenTDFKit currently uses (via CryptoKit and CryptoSwift):
Key Components Using ECC
NanoTDF Header (
NanoTDF.swift):Key Agreement (
CryptoHelper.swift):customECDH()methods for P-256, P-384, P-521KAS Rewrap (
KASRewrapClient.swift):Signatures (
CryptoHelper.swift):Quantum Threat Assessment
Vulnerable to quantum attacks (Shor's algorithm):
Already quantum-resistant:
Why OpenTDFKit Needs PQ Crypto
Proposed Timeline
Near-term (6-12 months): Research & Planning
Medium-term (1-2 years): Hybrid Implementation
Long-term (2+ years): PQ-Only Mode
Implementation Strategy
Phase 1: Hybrid Key Encapsulation
Replace ECDH with ML-KEM-768 + ECDH(P-256)
Phase 2: Hybrid Signatures
Replace ECDSA with ML-DSA-65 + ECDSA-P256 for policy binding
Phase 3: NanoTDF Format Extension
Extend NanoTDF header to support hybrid keys:
Swift Ecosystem Challenges
Challenge 1: Limited PQ Libraries
Challenge 2: CryptoKit API Constraints
Challenge 3: Performance on Mobile
Recommended Approach
Option A: C Library Bridging (Fastest Path)
Pros: Proven library, well-tested
Cons: C bridging complexity, potential safety issues
Option B: Pure Swift Implementation (Long-term)
Pros: Type-safe, no FFI overhead
Cons: Requires extensive crypto expertise, slower initial development
Option C: Rust FFI via swift-bridge (Hybrid)
Pros: Leverage proven libcrux, good performance
Cons: Complex build setup, two language toolchains
Recommendation: Start with Option A (liboqs) for prototyping, migrate to Option B or C for production.
Action Items
Performance Targets
Based on current OpenTDFKit benchmarks:
References
Related Work
Cross-Platform Considerations
OpenTDFKit targets iOS, macOS, tvOS, watchOS - ensure PQ implementation works across:
Priority: Medium-High
Complexity: High
Timeline: 12-24 months for full hybrid implementation