Expand description
B4AE (Beyond For All Encryption) Protocol
Implements B4AE Protocol Specification v1.0. Quantum-resistant secure communication protocol.
Β§B4AE (Beyond For All Encryption)
Research-Grade Post-Quantum Metadata-Hardened Secure Messaging Protocol
B4AE v2.1 β A formally verified, quantum-resistant protocol with authentication mode separation, stateless DoS protection, and global traffic scheduling for metadata protection.
Β§Overview
B4AE v2.0 is a research-grade protocol architecture designed for high-assurance deployments requiring formal verification, post-quantum security, and strong metadata protection. It transforms B4AE from βstrong engineeringβ (v1.0) to βresearch-grade protocolβ suitable for academic scrutiny and formal analysis.
Current Version: v2.1.1 (production-ready β 0 warnings, 0 errors, NIST PQC standards)
Previous Version: v2.0.0 (see CHANGELOG)
Β§Key Features (v2.0)
- π Authentication Mode Separation: Choose Mode A (deniable, XEdDSA) or Mode B (post-quantum, Dilithium5) - no contradictory hybrid
- π‘οΈ Stateless Cookie Challenge: 360x DoS protection reduction (~0.01ms verification before expensive crypto)
- π Global Traffic Scheduler: Cross-session metadata protection with constant-rate output (100-1000 msg/s)
- π Session Key Binding: Cryptographic binding to session ID prevents key transplant attacks
- π Protocol ID Derivation: SHA3-256 of canonical spec for automatic version enforcement
- π Security-by-Default: No optional security features - all protections always enabled
- π Formal Verification: Tamarin + ProVerif models with machine-checked security proofs
- π Formal Threat Model: Single source of truth defining 6 adversary types
- β‘ High Performance: Mode A ~150ms handshake, Mode B ~155ms handshake
- π Open Source: Fully auditable and transparent implementation
Β§Why B4AE v2.0?
Β§8 Architectural Improvements Over v1.0
B4AE v2.0 addresses critical architectural flaws identified in v1.0 audit:
| Issue (v1.0) | Solution (v2.0) | Benefit |
|---|---|---|
| β XEdDSA + Dilithium5 hybrid destroys deniability | β Mode A (XEdDSA only) vs Mode B (Dilithium5 only) | Clear security properties, no contradictions |
| β No DoS protection before expensive crypto | β Stateless cookie challenge (~0.01ms) | 360x DoS reduction |
| β Per-session metadata protection | β Global unified traffic scheduler | Cross-session indistinguishability |
| β Feature-driven design, no formal threat model | β Single formal threat model (6 adversary types) | Consistent security properties |
| β Optional security features | β Security-by-default (no opt-out) | No insecure configurations |
| β No formal verification | β Tamarin + ProVerif models | Machine-checked security proofs |
| β Session keys not bound to session ID | β Cryptographic session binding | Prevents key transplant attacks |
| β Hardcoded version strings | β Protocol ID = SHA3-256(spec) | Automatic version enforcement |
Β§Design Philosophy
- Model-driven (not feature-driven): All features derived from formal threat model
- Security-by-default (not optional): All protections always enabled
- Formally verified (not just tested): Machine-checked security proofs
Β§Technical Architecture (v2.0)
Β§Authentication Mode System
B4AE v2.0 separates authentication into distinct modes with clear security properties:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AUTHENTICATION MODES β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Mode A: Deniable Authentication (XEdDSA only) β
β β
Deniable (verifier can forge) β
β β
Fast (~0.3ms signatures) β
β β Not post-quantum secure β
β Use: Private messaging, whistleblowing β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Mode B: Post-Quantum Non-Repudiable (Dilithium5 only) β
β β
Post-quantum secure (NIST Level 5) β
β β
Non-repudiable signatures β
β β Not deniable β
β Use: Legal contracts, audit trails, compliance β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Mode C: Future Hybrid (Research placeholder) β
β β οΈ Not production-ready β
β Future: Deniable + post-quantum β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββΒ§Protocol Flow (v2.0)
Client Server
| |
|--- ModeNegotiation --------------->| (Mode selection)
|<-- ModeSelection -------------------|
| |
|--- ClientHello (minimal) --------->| (No expensive crypto)
|<-- CookieChallenge (stateless) ----| (~0.01ms HMAC)
| |
|--- ClientHelloWithCookie --------->| (Cookie verified)
| + HandshakeInit | (Then expensive crypto)
|<-- HandshakeResponse ---------------|
| |
|--- HandshakeComplete -------------->|
| |
[Session established with keys bound to session_id]
| |
|--- Encrypted Messages ------------->| (Via global scheduler)
|<-- Encrypted Messages --------------| (Constant-rate output)Β§Global Traffic Scheduler
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GLOBAL UNIFIED TRAFFIC SCHEDULER β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Session 1 βββ β
β Session 2 βββΌββ> Unified Queue ββ> Constant-Rate Output β
β Session 3 βββ€ + (100 msg/s) β
β Session N βββ Dummy Messages β
β β
β Security: Cross-session indistinguishability β
β Trade-off: ~5ms avg latency for metadata protection β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββΒ§Quick Start (v2.0)
Β§Installation
Add B4AE v2.0 to your Cargo.toml:
[dependencies]
b4ae = { version = "2.1", features = ["v2_protocol"] } # Enable v2 protocol + B4aeClientV2
# Optional features:
# b4ae = { version = "2.1", features = ["v2_protocol", "elara"] } # + ELARA UDP transportFeatures: v2_protocol (v2.0 protocol), elara (UDP transport), proxy (SOCKS5, requires elara)
Β§Basic Usage (v2.0)
use b4ae::B4aeClientV2;
use b4ae::protocol::v2::AuthenticationMode;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Gunakan B4aeClientV2 β high-level API untuk v2 protocol
let mut alice = B4aeClientV2::new(AuthenticationMode::ModeA)?;
let mut bob = B4aeClientV2::new(AuthenticationMode::ModeA)?;
let alice_id = b"alice".to_vec();
let bob_id = b"bob".to_vec();
// Mode negotiation (automatic)
let negotiation = alice.initiate_mode_negotiation(&bob_id)?;
let selection = bob.respond_mode_negotiation(&alice_id, negotiation)?;
alice.complete_mode_negotiation(&bob_id, selection)?;
// Cookie challenge (automatic DoS protection)
let client_hello = alice.send_client_hello(&bob_id)?;
let cookie_challenge = bob.respond_cookie_challenge(&alice_id, client_hello)?;
// Handshake with mode-specific signatures
let init = alice.initiate_handshake_v2(&bob_id, cookie_challenge)?;
let response = bob.respond_to_handshake_v2(&alice_id, init)?;
let complete = alice.process_response_v2(&bob_id, response)?;
bob.complete_handshake_v2(&alice_id, complete)?;
alice.finalize_initiator_v2(&bob_id)?;
// Messages go through global traffic scheduler
let encrypted = alice.encrypt_message_v2(&bob_id, b"Hello, B4AE v2.0!")?;
let decrypted = bob.decrypt_message_v2(&alice_id, &encrypted)?;
println!("Received: {}", String::from_utf8_lossy(&decrypted));
Ok(())
}Β§Mode Selection Guide
Choose Mode A (Deniable) when:
- β You need plausible deniability (whistleblowing, anonymous communication)
- β You want fast handshakes (~150ms)
- β Classical 128-bit security is sufficient
- β You donβt need post-quantum security
- β You donβt need non-repudiation
Choose Mode B (Post-Quantum) when:
- β You need post-quantum security (NIST Level 5)
- β You need non-repudiable signatures (legal contracts, audit trails)
- β You can accept slightly slower handshakes (~155ms)
- β You donβt need deniability
See Mode Selection Guide for detailed comparison.
Β§Building from Source
Β§Prerequisites
- Rust 1.75 or later (edition 2021)
- OpenSSL development libraries (optional; ring uses system crypto)
Β§Build
# Clone repository (--recursive untuk ELARA submodule)
git clone --recursive https://github.com/rafaelsistems/B4AE-Beyond-For-All-Encryption-.git
cd B4AE-Beyond-For-All-Encryption-
# Build default (tanpa ELARA)
cargo build --release
# Build dengan ELARA transport
cargo build --release --features elara
# Run tests
cargo test --all-features
# Run benchmarks
cargo bench
# Demos (dengan ELARA)
cargo run --example b4ae_elara_demo --features elara
cargo run --example b4ae_chat_demo --features elara -- server 9000 # terminal 1
cargo run --example b4ae_chat_demo --features elara -- client 127.0.0.1:9000 # terminal 2
cargo run --example b4ae_file_transfer_demo --features elara -- recv output.bin 9001 # receiver first
cargo run --example b4ae_file_transfer_demo --features elara -- send file.txt 127.0.0.1:9001 # senderΒ§Platform SDKs
B4AE provides bindings for mobile and web:
| Platform | Crate/Binding | API |
|---|---|---|
| Web | b4ae-wasm | generate_key, encrypt, decrypt |
| Android | b4ae-android | B4AE.generateKey(), encrypt(), decrypt() |
| iOS | b4ae-ffi + Swift | B4AE.generateKey(), encrypt(), decrypt() |
| Full Protocol | b4ae-ffi --features full-protocol | handshake + encrypt/decrypt (quantum-resistant) |
See docs/PLATFORM_SDK.md for build and usage.
Β§Documentation
- Platform SDK β iOS, Android, WASM bindings
- ROADMAP β development roadmap
- Formal Verification β TLA+, Coq, proptest
- Plugin Architecture β Signal, Matrix integration
- Gateway/Proxy β B4AE β legacy protocol
- Enterprise Deployment β enterprise guide
- Specifications β protocol, API, performance
Β§Research
Comprehensive research documentation:
- Quantum Cryptography Analysis
- Post-Quantum Algorithm Evaluation
- Metadata Protection Techniques
- Performance Benchmarking
- Competitive Analysis
Β§Comparison with E2EE
| Feature | E2EE (Signal) | B4AE |
|---|---|---|
| Quantum Resistance | β | β |
| Metadata Protection | β | β |
| Forward Secrecy | β | β Enhanced |
| Multi-Device Sync | β οΈ Limited | β Seamless |
| Enterprise Features | β | β |
| Performance | ββββ | ββββ |
| Open Source | β | β |
Β§Roadmap
Β§Phase 1: Foundation (Months 1-6) β
- Research & Specification
- Cryptographic Core Implementation
- Performance Benchmarking Framework
Β§Phase 2: Core Development (Months 7-12) β
- Cryptographic Core (Kyber, Dilithium, Hybrid)
- Protocol Implementation
- Network Layer (ELARA transport integration)
- Platform SDKs (Swift, Kotlin, WASM)
Β§Phase 3: Integration & Testing (Months 13-18) β
- Security Testing & Audits (scripts/security_audit, cargo audit CI)
- Performance Optimization (docs/PERFORMANCE.md, release profile)
- Integration Testing (elara_integration_test expanded)
Β§Phase 4: Production & Deployment (Months 19-24) β
- Production Infrastructure (Dockerfile, docker-compose)
- Pilot Deployment (docs/PILOT_DEPLOYMENT_GUIDE.md)
- General Availability (docs/RELEASE_CHECKLIST.md)
Β§Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Β§Areas for Contribution
- π Cryptographic implementations
- π§ͺ Testing and security audits
- π Documentation improvements
- π Platform-specific optimizations
- π Bug reports and fixes
Β§Security
Β§Reporting Security Issues
Please report security vulnerabilities to: rafaelsistems@gmail.com
Do not open public issues for security vulnerabilities.
Β§Security Audits
B4AE undergoes regular security audits by independent third parties. Audit reports will be published here.
Β§License
B4AE is dual-licensed under:
- MIT License (LICENSE-MIT)
- Apache License 2.0 (LICENSE-APACHE)
You may choose either license for your use.
Β§Citation
If you use B4AE in your research, please cite:
@software{b4ae2026,
title = {B4AE: Beyond For All Encryption},
author = {B4AE Team},
year = {2026},
url = {https://github.com/rafaelsistems/B4AE-Beyond-For-All-Encryption-}
}Β§Acknowledgments
- NIST for post-quantum cryptography standardization
- Open Quantum Safe project for liboqs
- ELARA Protocol for transport substrate integration
- Signal Foundation for pioneering E2EE
- The Rust community for excellent cryptographic libraries
Β§Contact
- Website: GitHub Repository
- Email: rafaelsistems@gmail.com
- Security: rafaelsistems@gmail.com
B4AE: Securing Communication for the Quantum Era ππ
Β§π Project Status (Phases 1β4 Complete)
Β§Completed β
-
Phase 1: Foundation (100%)
- Comprehensive research (5 documents, 200+ pages)
- Technical specifications (5 documents, 150+ pages)
- Development infrastructure setup
-
Phase 2: Core Development (100%)
- Cryptographic core - Kyber, Dilithium, Hybrid, PFS+, ZKAuth
- Protocol implementation - Handshake, Message, Session
- Metadata protection - Padding, Timing, Obfuscation
- Platform SDKs (100%) - iOS Swift, Android Kotlin, Web WASM + demo apps
Β§ELARA Integration β
- Transport Layer: ElaraTransport (UDP dengan chunking)
- B4aeElaraNode: Full handshake & messaging via ELARA
- Example:
b4ae_elara_demo
Β§Performance Metrics β‘
- Handshake: <150ms (target: <200ms) β
- Message latency: <0.6ms (target: <1.0ms) β
- Throughput: >1000 msg/s β
- Test coverage: 85%
Status: Ahead of schedule, under budget
See docs/ROADMAP.md for detailed progress.
Β§ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββ
β Application Layer β
βββββββββββββββββββββββββββββββββββββββββββ€
β Protocol Layer β
β ββββββββββββ¬βββββββββββ¬βββββββββββ β
β βHandshake β Message β Session β β
β ββββββββββββ΄βββββββββββ΄βββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ€
β Metadata Protection Layer β
β ββββββββββββ¬βββββββββββ¬βββββββββββ β
β β Padding β Timing βObfuscate β β
β ββββββββββββ΄βββββββββββ΄βββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ€
β Cryptographic Core β
β ββββββββββββ¬βββββββββββ¬βββββββββββ β
β β Kyber βDilithium β Hybrid β β
β ββββββββββββΌβββββββββββΌβββββββββββ€ β
β β AES-GCM β HKDF β PFS+ β β
β ββββββββββββΌβββββββββββΌβββββββββββ€ β
β β Random β ZKAuth β β β
β ββββββββββββ΄βββββββββββ΄βββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββΒ§Module Overview
| Modul | Deskripsi | Feature |
|---|---|---|
src/crypto/ | Kyber, Dilithium, Hybrid, PFS+, ZKAuth, AES-GCM, HKDF | β |
src/protocol/ | Handshake, Message, Session | β |
src/metadata/ | Padding, Timing, Obfuscation β terintegrasi di B4aeClient | β |
src/key_hierarchy.rs | MIK, DMK, STK, BKS (Spec Β§4); BKS 2-of-2 dengan HMAC | β |
src/transport/ | ElaraTransport (UDP, chunking), ProxyElaraTransport (SOCKS5) | elara, proxy |
src/elara_node.rs | B4aeElaraNode: handshake + messaging via ELARA | elara |
src/client.rs | B4aeClient: cleanup_inactive_sessions(), cleanup_old_state() | β |
src/storage.rs | EncryptedStorage (STK + AES-GCM) | β |
src/audit.rs | AuditSink, AuditEvent untuk compliance | β |
src/lib.rs | MAX_MESSAGE_SIZE = 1 MiB (DoS mitigation) | β |
Β§π Documentation
Β§Specifications
Β§Guides
- Platform SDK β iOS, Android, WASM
- ELARA Integration
- Formal Verification
Β§Research
- Quantum Cryptography Analysis
- Post-Quantum Algorithm Evaluation
- Metadata Protection Techniques
- Performance Benchmarking Framework
- Competitive Analysis
Β§Status & Audit
- ROADMAP β development roadmap
- AUDIT_FEATURES_ANALYSIS β fitur vs implementasi
Β§β‘ Performance
Β§Benchmarks (Intel i7-12700K)
| Operation | Time | Target | Status |
|---|---|---|---|
| Kyber-1024 KeyGen | 0.12ms | <0.15ms | β |
| Dilithium5 Sign | 0.95ms | <1.00ms | β |
| Hybrid KeyExchange | 1.75ms | <2.00ms | β |
| Message Encrypt | 0.5ms | <1.0ms | β |
| Handshake Complete | <150ms | <200ms | β |
All performance targets exceeded β
Β§π Security
Β§Cryptographic Algorithms
- Key Exchange: Kyber-1024 (NIST FIPS 203) + X25519
- Signatures: Dilithium5 (NIST FIPS 204) + Ed25519
- Encryption: AES-256-GCM
- Key Derivation: HKDF-SHA3-256
Β§Security Features
β
Quantum resistance (NIST-standardized PQC)
β
Hybrid cryptography (defense in depth)
β
Perfect Forward Secrecy Plus
β
Zero-knowledge authentication
β
Metadata protection (padding, timing obfuscation, dummy traffic β terintegrasi di client)
β
Audit logging (B4aeConfig.audit_sink untuk compliance)
β
Memory security (zeroization)
β
Replay attack prevention
Β§Audits
- Internal review: Ongoing β
- External audit: Scheduled Q2 2026
Β§π€ Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Β§Development
# Run tests
cargo test
# Run benchmarks
cargo bench
# Generate documentation
cargo doc --no-deps --open
# Format code
cargo fmt
# Lint
cargo clippyΒ§π License
Dual-licensed under MIT or Apache 2.0.
Β§π Contact
- Website: GitHub Repository
- Email: rafaelsistems@gmail.com
- Security: rafaelsistems@gmail.com
B4AE - Beyond For All Encryption
Quantum-resistant security for the future π
Re-exportsΒ§
pub use error::B4aeError;pub use error::B4aeResult;pub use crypto::CryptoConfig;pub use crypto::SecurityLevel;pub use client::B4aeClient;pub use client::B4aeConfig;pub use protocol::SecurityProfile;
ModulesΒ§
- audit
- Audit logging for compliance. Audit logging untuk production compliance
- client
- High-level client API.
- crypto
- Cryptographic primitives (Kyber, Dilithium, hybrid, AES-GCM, HKDF, PFS+, ZKAuth). B4AE Cryptographic Core Module
- error
- Error types for B4AE.
- key_
hierarchy - Key hierarchy (MIK, DMK, STK, BKS). B4AE Key Hierarchy (Protocol Spec v1.0 Β§4)
- key_
store - Key persistence (passphrase-protected MIK storage). B4AE Key Store
- metadata
- Metadata protection (padding, timing, obfuscation). B4AE Metadata Protection Module
- performance
- Performance monitoring and profiling. B4AE Performance Monitoring and Profiling Tools
- prelude
- Re-exports for common usage.
- protocol
- Protocol layer (handshake, message, session). B4AE Protocol Implementation
- security
- Security-hardened core module with panic-free production paths Security-hardened modules for B4AE
- storage
- Encrypted storage using STK. B4AE Encrypted Storage
- time
- Safe time utilities (panic-free). B4AE Safe Time Utilities
ConstantsΒ§
- MAX_
MESSAGE_ SIZE - Maximum message size (plaintext or ciphertext) β DoS mitigation.
- PROTOCOL_
FULL_ NAME - B4AE Protocol Full Name
- PROTOCOL_
NAME - B4AE Protocol Name
- PROTOCOL_
VERSION - B4AE wire protocol version (Protocol Specification v1.0). Used in handshake and message headers. Value 1 = spec v1.0.
- VERSION
- B4AE crate version (Cargo.toml)