Skip to main content

Crate lib_q_fn_dsa

Crate lib_q_fn_dsa 

Source
Expand description

lib-Q FN-DSA - Post-Quantum Digital Signatures

This crate provides a libQ-compatible wrapper around the FN-DSA (FIPS 206) post-quantum digital signature algorithm, which is based on FALCON with enhanced performance and compact signature sizes.

§Features

  • NIST-Approved: Implements NIST FIPS 206 (FN-DSA)
  • High Performance: Optimized for both x86_64 and ARM64 architectures
  • Compact Signatures: Smaller signature sizes compared to other post-quantum schemes
  • Security Levels: Supports Level 1 (128-bit) and Level 5 (256-bit) security
  • Memory Safe: Zero unsafe code, automatic memory zeroization
  • Constant-Time: Operations designed to prevent timing attacks

§Security Levels

FN-DSA provides two main security levels:

  • Level 1 (128-bit security): n=512, suitable for most applications
  • Level 5 (256-bit security): n=1024, for high-security applications

§Example Usage

use lib_q_core::{
    SigKeypair,
    SigPublicKey,
    SigSecretKey,
    Signature,
};
use lib_q_fn_dsa::{
    FnDsa,
    FnDsa512,
    FnDsa1024,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create an FN-DSA instance
    let fn_dsa = FnDsa512::new();

    // Generate a keypair
    let keypair = fn_dsa.generate_keypair()?;

    // Sign a message
    let message = b"Hello, FN-DSA!";
    let signature = fn_dsa.sign(&keypair.secret_key, message)?;

    // Verify the signature
    let is_valid =
        fn_dsa.verify(&keypair.public_key, message, &signature)?;
    assert!(is_valid);

    Ok(())
}

Modules§

utils
Utility functions for FN-DSA

Structs§

FnDsa
Generic FN-DSA implementation that can work with any security level
FnDsa512
FN-DSA Level 1 (128-bit security) implementation
FnDsa1024
FN-DSA Level 5 (256-bit security) implementation
KeyPairGeneratorStandard
Key pair generator for degrees (logn) 9 to 10 only.
SigKeypair
Signature keypair with automatic memory zeroization
SigPublicKey
Signature public key
SigSecretKey
Signature secret key with automatic memory zeroization
SigningKeyStandard
Signature generator for degrees (logn) 9 to 10 only.
VerifyingKeyStandard
Signature verifier for degrees (logn) 9 to 10 only.

Enums§

Error
The error type for lib-Q operations
FnDsaSecurityLevel
FN-DSA security level enumeration

Constants§

DOMAIN_NONE
Empty domain separation context.
FN_DSA_LOGN_512
Symbolic constant for FN-DSA with degree 512 (logn = 9).
FN_DSA_LOGN_1024
Symbolic constant for FN-DSA with degree 1024 (logn = 10).
HASH_ID_RAW
Hash function identifier: none.

Traits§

FnDsaImpl
Base FN-DSA implementation trait
KeyPairGenerator
Key pair generator and temporary buffers.
Signature
Trait for digital signatures
SigningKey
Signing key handler and temporary buffers.
VerifyingKey
Verifying key handler.

Functions§

sign_key_size
Get the size (in bytes) of a signing key for the provided degree (degree is n = 2^logn, with 2 <= logn <= 10).
signature_size
Get the size (in bytes) of a signature for the provided degree (degree is n = 2^logn, with 2 <= logn <= 10).
vrfy_key_size
Get the size (in bytes) of a verifying key for the provided degree (degree is n = 2^logn, with 2 <= logn <= 10).

Type Aliases§

Result
Result type for lib-Q operations