PQC Binary Format v1.0.9
A standardized, self-describing binary format for post-quantum cryptography encrypted data interchange.
๐ The Problem
Post-quantum cryptography (PQC) implementations suffer from the "Babel Tower problem": different implementations cannot interoperate because there is no standardized format for encrypted data. Each library uses its own proprietary format, making cross-platform and cross-language encryption impossible.
๐ก The Solution
PQC Binary Format provides a universal, algorithm-agnostic format that:
- โ Works across 28+ cryptographic algorithms
- โ Self-describing metadata enables seamless decryption
- โ Integrity verification with SHA-256 checksums
- โ Cross-platform compatible (Rust, Python, JavaScript, Go, etc.)
- โ Future-proof design allows algorithm migration
- โ Zero dependencies except serde and sha2
๐ Quick Start
Rust
Add to your Cargo.toml:
[]
= "1.0"
Basic Usage (Rust)
use ;
use HashMap;
// Create metadata with encryption parameters
let metadata = PqcMetadata ;
// Create encrypted data container
let encrypted_data = vec!; // Your encrypted bytes
let format = new;
// Serialize to bytes (for transmission or storage)
let bytes = format.to_bytes.unwrap;
// Deserialize from bytes (includes automatic checksum verification)
let recovered = from_bytes.unwrap;
assert_eq!;
println!;
Python
Install the Python bindings:
# Create algorithm and metadata
=
=
=
# Create and serialize format
=
=
# Deserialize and verify
=
# Verify checksum integrity
JavaScript/TypeScript
Build the WebAssembly bindings:
import init from './pqc_binary_format.js';
await ;
const algorithm = ;
const encParams = ;
const metadata = ;
const pqcFormat = ;
const serialized = pqcFormat.;
const deserialized = ;
console.log;
Go
Build the Rust library first, then use the Go bindings:
package main
import (
"fmt"
"log"
pqc "github.com/PQCrypta/pqcrypta-community/bindings/go"
)
func main()
C/C++
Build the Rust library and generate the C header:
int
๐ Language Bindings
PQC Binary Format provides production-ready, fully tested bindings for multiple programming languages. All bindings support the complete API and produce cross-compatible binary formats.
Available Bindings (v1.0.9)
| Language | Status | Package | Documentation | Examples |
|---|---|---|---|---|
| Rust | โ Native | pqc-binary-format |
docs.rs | 3 examples |
| Python | โ Tested | pqc_binary_format |
Python README | 2 examples |
| JavaScript/WASM | โ Tested | pqc_binary_format (npm) |
JS README | 1 example |
| Go | โ Tested | github.com/PQCrypta/pqcrypta-community/bindings/go |
Go README | 1 example |
| C | โ Tested | FFI via Rust | C/C++ README | 1 example |
| C++ | โ Tested | FFI via Rust | C/C++ README | 1 example |
Installation Quick Reference
# Rust
# Python (via maturin)
&&
# JavaScript/WASM (via wasm-pack)
# Go
# C/C++ (build from source)
# Link against target/release/libpqc_binary_format.so
Cross-Language Compatibility
All language bindings are fully interoperable! You can:
- โ Encrypt data in Python, decrypt in Rust
- โ Serialize in Go, deserialize in JavaScript
- โ Create format in C++, validate in Python
- โ Mix any combination across platforms
Example workflow:
# Create encrypted data with Python
# Verify with C++
LD_LIBRARY_PATH=target/release
# Process with Go
&&
Binding Features
All bindings support:
- โ Full algorithm suite (28 algorithms)
- โ Metadata serialization/deserialization
- โ SHA-256 integrity verification
- โ Feature flags (compression, streaming, etc.)
- โ Error handling with detailed messages
- โ Memory safety (Rust-backed)
Package Distribution Status
| Platform | Status | Notes |
|---|---|---|
| crates.io (Rust) | โ Published | v1.0.9 live! |
| PyPI (Python) | โณ Ready | Maturin build tested, ready for maturin publish |
| npm (JavaScript) | โณ Ready | WASM package built with wasm-pack |
| pkg.go.dev (Go) | โณ Ready | Will auto-index on tag push |
๐ฆ Binary Format Specification
+-------------------+
| Magic (4 bytes) | "PQC\x01" - Format identifier
+-------------------+
| Version (1 byte) | 0x01 - Format version
+-------------------+
| Algorithm (2 bytes)| Algorithm identifier (0x0050 - 0x0506)
+-------------------+
| Flags (1 byte) | Feature flags (compression, streaming, etc.)
+-------------------+
| Metadata Len (4) | Length of metadata section
+-------------------+
| Data Len (8) | Length of encrypted payload
+-------------------+
| Metadata (var) | Algorithm-specific parameters
+-------------------+
| Data (var) | Encrypted data
+-------------------+
| Checksum (32) | SHA-256 integrity checksum
+-------------------+
๐ Supported Algorithms
The format supports 28 cryptographic algorithm identifiers:
Classical Algorithms
- Classical (0x0050): X25519 + Ed25519 + AES-256-GCM
- Password Classical (0x0051): Password-based encryption
Hybrid Algorithms
- Hybrid (0x0100): ML-KEM-1024 + X25519 + ML-DSA-87 + Ed25519
Post-Quantum Algorithms
- Post-Quantum (0x0200): ML-KEM-1024 + ML-DSA-87
- ML-KEM-1024 (0x0202): Pure ML-KEM with AES-256-GCM
- Multi-KEM (0x0203): Dual-layer KEM
- Multi-KEM Triple (0x0204): Triple-layer KEM
- Quad-Layer (0x0205): Four independent layers
- PQ3-Stack (0x0207): Forward secrecy stack
Max Secure Series (0x0300-0x0306)
High-security configurations for enterprise use
FN-DSA Series (0x0400-0x0407)
Falcon-based signature algorithms
Experimental (0x0500-0x0506)
Research and next-generation algorithms
๐ฏ Features
Feature Flags
Control optional behavior with feature flags:
use ;
use HashMap;
let flags = new
.with_compression // Data was compressed before encryption
.with_streaming // Streaming encryption mode
.with_additional_auth; // Additional authentication layer
let metadata = PqcMetadata ;
let format = with_flags;
assert!;
assert!;
Metadata Structure
The format includes rich metadata for decryption:
use ;
use HashMap;
let metadata = PqcMetadata ;
Custom Parameters
Add your own metadata:
use PqcMetadata;
let mut metadata = new;
metadata.add_custom;
// Later...
if let Some = metadata.get_custom
๐ Integrity Verification
Every format includes a SHA-256 checksum calculated over all fields:
use PqcBinaryFormat;
let bytes = format.to_bytes.unwrap;
// Tamper with the data
// let mut corrupted = bytes.clone();
// corrupted[50] ^= 0xFF;
// Deserialization automatically verifies checksum
match from_bytes
๐ Examples
Example 1: Basic Encryption Format
use ;
use HashMap;
Example 2: Cross-Language Interoperability
Rust (Encryption)
let format = new;
let bytes = format.to_bytes.unwrap;
// Send bytes to Python/JavaScript/Go/C++
Python (Decryption)
=
JavaScript (Decryption)
const format = ;
console.log;
console.log;
Go (Decryption)
format, _ := pqc.FromBytes(bytes)
defer format.Free()
fmt.Printf("Algorithm: %s\n", format.GetAlgorithmName())
fmt.Printf("Data: %d bytes\n", len(format.GetData()))
Example 3: Algorithm Migration
// Old data encrypted with Classical algorithm
let old_format = from_bytes?;
assert_eq!;
// Re-encrypt with Post-Quantum algorithm
let plaintext = decrypt_with_classical?;
let new_metadata = create_pq_metadata?;
let new_format = new;
// Same format, different algorithm!
๐ Use Cases
1. Cross-Platform Encryption
Encrypt in Rust, decrypt in Python, JavaScript, or Go using the same format.
2. Long-Term Archival
Self-describing format ensures data can be decrypted decades later even as algorithms evolve.
3. Algorithm Agility
Switch between algorithms without changing application code.
4. Compliance & Audit
Embedded metadata provides audit trail for regulatory compliance (GDPR, HIPAA, etc.).
5. Research & Benchmarking
Standardized format enables fair comparison of PQC algorithm performance.
๐งช Testing
# Run tests
# Run tests with output
# Run specific test
๐ Benchmarks
# Run benchmarks
# View benchmark results
Performance characteristics:
- Serialization: ~50 MB/s for typical payloads
- Deserialization: ~45 MB/s (includes checksum verification)
- Overhead: ~100 bytes + metadata size
๐ง Development
Building from Source
Running Examples
๐ค Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
Current Status
- Language Bindings: โ Rust (native), โ Python (tested v1.0.9), โ JavaScript/WASM (tested v1.0.9), โ Go (tested v1.0.9), โ C/C++ (tested v1.0.9)
- Examples: โ 9 validated examples across 6 languages
- Package Distribution: โ crates.io published! | โณ PyPI, npm, pkg.go.dev ready
Areas for Contribution
- Additional Language Bindings: Java, C#, Ruby, Swift, Kotlin - help us expand!
- Documentation: Tutorials, integration guides, video walkthroughs
- Testing: Additional test cases, fuzzing, property-based testing
- Performance: SIMD optimizations, benchmark improvements
- Standards: Help draft RFC for IETF standardization submission
- Package Publishing: Help publish to PyPI, npm, and other package registries
๐ License
Licensed under either of:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.
๐ Acknowledgments
This format was developed as part of the PQCrypta enterprise post-quantum cryptography platform. Special thanks to:
- NIST Post-Quantum Cryptography Project
- The Rust cryptography community
- Contributors to pqcrypto, ring, and other foundational crates
๐ References
- NIST Post-Quantum Cryptography
- ML-KEM (Kyber) Specification
- ML-DSA (Dilithium) Specification
- PQCrypta Documentation
๐ Related Projects
- pqcrypto - Rust PQC implementations
- Open Quantum Safe - PQC library collection
- CIRCL - Cloudflare's crypto library
๐ฌ Community & Support
- GitHub Issues: Report bugs
- Discussions: Ask questions
- Website: pqcrypta.com
- Documentation: docs.rs/pqc-binary-format
Made with โค๏ธ by the PQCrypta Community
Securing the future, one byte at a time.