lib-q-saturnin
Rust implementation of the Saturnin post-quantum symmetric algorithm suite.
Saturnin is the primary symmetric suite for HPKE/AEAD tiers in this workspace (see lib-q-hpke, lib-q-aead).
Overview
Saturnin is a lightweight block cipher designed for post-quantum security. This implementation provides AEAD, block cipher, hash, and stream cipher modes.
Usage
Add to Cargo.toml:
[]
= "0.0.2"
AEAD
use ;
Hash
use ;
Block Cipher
use ;
Stream Cipher
use ;
Features
aead- Authenticated encryption (default)aead-short— Saturnin-Short (spec section 2.3): singleSaturnin^6block overpad(nonce ‖ plaintext); fixed 32-byte ciphertext, no associated data, plaintext strictly under 128 bits. This is not CTR-Cascade (aead).block-cipher- Block cipher operationshash- Hash functionstream- Stream cipherzeroize- Secure memory zeroization
Performance features
simdenables runtime SIMD dispatch.simd-avx2enables AVX2 backend support onx86_64(runtime detected).simd-neonenables NEON backend support onaarch64(runtime detected).parallelenables multi-block parallel helpers on non-WASM targets.
Scalar core and bs32_core remain the audited reference implementations. SIMD paths are optimized implementations that must remain byte-for-byte equivalent to scalar outputs.
WebAssembly
The crate builds for wasm32-unknown-unknown. Enable the wasm feature so that the getrandom dependency (via lib-q-core) compiles with wasm_js; otherwise the build will fail on that target. The parallel feature is not available on wasm32 (the module is omitted on that target).
Example: cargo build --target wasm32-unknown-unknown --features wasm
Security
- 256-bit post-quantum security
- Constant-time operations; AEAD tag verification uses constant-time comparison (see SECURITY.md).
- No side channels
- Validated against reference implementation
Performance
Typical throughput on modern hardware:
- AEAD: ~200-400 MB/s
- Hash: ~400-600 MB/s
- Block cipher: ~150-300 MB/s
- Stream cipher: ~250-450 MB/s
Testing
SIMD validation matrix
# Scalar reference path
# AVX2-enabled path (x86_64)
# NEON-enabled path (aarch64)
Benchmark protocol
- Run on an otherwise idle machine with fixed CPU frequency governor when possible.
- Collect scalar baseline first, then collect SIMD-enabled results on the same machine.
- Use identical workload sizes and warmup/sample settings for all runs.
- Report bytes/second and relative speedup (
simd / scalar) for each workload.
Recommended commands:
# Scalar baseline
# AVX2 benchmark run
Performance acceptance gates
When evaluating SIMD changes, use these minimum expected speedups against scalar baseline on the same host:
- Hash throughput:
>= 1.30x - Stream throughput:
>= 1.25x - Block single-block encryption:
>= 1.05x
If a change does not meet these thresholds, keep it behind feature gates until further optimization or analysis is completed.
License
See the main lib-q license.
Contributing
See the main lib-q contributing guide.