lib-Q FN-DSA
A production-ready implementation of FN-DSA (FIPS 206) post-quantum digital signatures, fully integrated into the libQ cryptography library.
Overview
FN-DSA (Falcon-based Digital Signature Algorithm) is a NIST-approved post-quantum digital signature scheme that provides compact signatures with strong security guarantees. This implementation follows the FIPS 206 standard and is designed for high-performance applications requiring quantum-resistant cryptography.
Key Features
- NIST-Approved: Implements the FIPS 206 standard for FN-DSA
- High Performance: Optimized implementations for x86_64 and ARM64 architectures
- Compact Signatures: Significantly smaller signature sizes compared to other post-quantum schemes
- Multiple Security Levels: Supports Level 1 (128-bit) and Level 5 (256-bit) security
- Memory Safe: Zero unsafe code with automatic secure memory management
- Constant-Time Operations: All cryptographic operations are constant-time to prevent timing attacks
- WASM Compatible: Full WebAssembly support for web applications
- Comprehensive Testing: Extensive test suite including security, performance, and interoperability tests
Security Levels
| Security Level | Parameter Set | Security (bits) | Use Case |
|---|---|---|---|
| Level 1 | FN-DSA-512 | 128 | General applications, IoT devices |
| Level 5 | FN-DSA-1024 | 256 | High-security applications, government use |
Installation
Rust
Add to your Cargo.toml:
[]
= "0.0.2"
Node.js
Usage
Basic Usage
use ;
// Create an FN-DSA instance
let fn_dsa = new;
// Generate a keypair
let keypair = fn_dsa.generate_keypair?;
// Sign a message
let message = b"Hello, FN-DSA!";
let signature = fn_dsa.sign?;
// Verify the signature
let is_valid = fn_dsa.verify?;
assert!;
Advanced Usage
use ;
// High-security application
let fn_dsa = new;
// Generate keypair with custom entropy
let mut rng = thread_rng;
let keypair = fn_dsa.generate_keypair_with_rng?;
// Sign with additional context
let context = b"application_context";
let signature = fn_dsa.sign_with_context?;
// Verify with context
let is_valid = fn_dsa.verify_with_context?;
WebAssembly Usage
import from '@lib-q/fn-dsa';
// Initialize FN-DSA
const fnDsa = ;
// Generate keypair
const keypair = fnDsa.;
// Sign message
const message = .;
const signature = fnDsa.;
// Verify signature
const isValid = fnDsa.;
console.log;
API Reference
Core Types
FnDsa512: FN-DSA implementation with 512-bit parameters (Level 1 security)FnDsa1024: FN-DSA implementation with 1024-bit parameters (Level 5 security)KeyPair: Container for public and secret keysPublicKey: Public key for signature verificationSecretKey: Secret key for signature generationSignature: Digital signature
Key Methods
generate_keypair(): Generate a new keypair using system entropygenerate_keypair_with_rng(rng): Generate keypair with custom random number generatorsign(secret_key, message): Sign a messagesign_with_context(secret_key, message, context): Sign with additional contextverify(public_key, message, signature): Verify a signatureverify_with_context(public_key, message, signature, context): Verify with context
Documentation
- Constrained-device signature suite — FN-DSA vs ML-DSA-65 bandwidth trade-offs for IoT and low-rate links.
- KAT verification against FIPS 206 — how internal vectors relate to published test data and optional
shake256x4divergence.
Testing
Run All Tests
Run Security Tests
Run Performance Benchmarks
Run Constant-Time Tests
Integration
This crate is fully integrated into the libQ ecosystem:
- Algorithm Registry: Registered in
lib-q-corefor automatic discovery - CI/CD Pipeline: Complete testing, security validation, and publishing workflows
- WASM Support: Automatic WebAssembly compilation and publishing
- Documentation: Integrated into main libQ documentation
Implementation Notes
Version Differences
This implementation is based on the upstream fn-dsa reference implementation but uses version 0.0.2 of the internal crates (fn-dsa-comm, fn-dsa-kgen, fn-dsa-sign, fn-dsa-vrfy) rather than the upstream 0.3.0 version. This version difference was chosen during integration into the libQ workspace to maintain consistency with the libQ versioning scheme.
Security Improvements
This implementation includes security enhancements over the upstream reference:
- Removed HASH_ID_ORIGINAL_FALCON: The original Falcon design bypassed domain separation, creating a critical security vulnerability that could enable cross-protocol attacks. This implementation enforces proper FN-DSA domain separation as specified in the NIST standard.
- Hardened hash_to_point: The
hash_to_pointfunction no longer supports the insecure original Falcon mode, ensuring all operations use proper domain separation.
API Compatibility Differences
Due to dependency version differences, there are minor API differences from the upstream reference:
- RngError type:
- Reference uses
rand_core::Errorfrom rand_core 0.6.4 - This implementation uses
core::fmt::Errorbecause rand_core 0.9.3 (used in libQ) does not exportErrordirectly - Both are compatible with
no_stdand provide equivalent functionality
- Reference uses
SHAKE256x4 Implementation Differences
When the shake256x4 feature is enabled, the Known Answer Test (KAT) values differ from the upstream reference implementation. This is due to:
- Dependency Version Differences: Different versions of
cpufeaturesand potentiallyrand_corebetween this implementation and upstream - AVX2 Code Generation: Subtle differences in how the compiler generates AVX2 instructions or manages state
- Integration Changes: Minor adaptations made during integration into the libQ workspace structure
Important: These differences do NOT affect cryptographic correctness or interoperability:
- All signatures are mathematically valid and verify correctly
- The implementation is fully FIPS 206-compliant
- Signatures generated by this implementation can be verified by any FIPS 206-compliant implementation
- Signatures from other FIPS 206-compliant implementations can be verified by this implementation
The KAT differences only affect the internal test vectors used for regression testing. The actual signature format and verification logic are identical to the standard.
Interoperability
This implementation is fully interoperable with other FIPS 206-compliant FN-DSA implementations:
- Signature Format: Uses the standard FIPS 206 signature encoding
- Key Format: Uses the standard FIPS 206 key encoding
- Verification: Implements the standard FIPS 206 verification algorithm
- Domain Separation: Correctly implements FIPS 206 domain separation
Signatures generated by this implementation will be accepted by any compliant FN-DSA verifier, and this implementation will accept signatures from any compliant FN-DSA signer.
Workspace
Enable via lib-q-sig with feature fn-dsa, or use this crate directly. See the workspace README.
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.