Skip to main content

Crate hqc_kem

Crate hqc_kem 

Source
Expand description

Pure Rust implementation of HQC-KEM (NIST FIPS 207).

HQC is a code-based Key Encapsulation Mechanism using quasi-cyclic codes over the ring Z_2[X]/(X^n-1). Uses concatenated Reed-Solomon + Reed-Muller error correction with Fujisaki-Okamoto transform for IND-CCA2 security.

§Usage

use hqc_kem::{Hqc128, HqcKem};

let mut rng = rand::rng();
let (ek, dk) = Hqc128::generate_key(&mut rng);
let (ct, ss1) = ek.encapsulate(&mut rng);
let ss2 = dk.decapsulate(&ct);
assert_eq!(ss1, ss2);

§Security Levels

§Features

  • kgen: Key generation (default)
  • ecap: Encapsulation (default)
  • dcap: Decapsulation (default)
  • kem: RustCrypto kem 0.3 trait implementations
  • pkcs8: PKCS#8 key encoding/decoding (requires alloc)
  • pem: PEM encoding (enables pkcs8/pem)
  • alloc: Vec/Box conversions and PKCS#8 encoding
  • serde: Serde serialization support
  • std: Standard library (default; enables runtime CPU feature detection)

The core KEM (kgen/ecap/dcap) is no_std and performs no heap allocation.

Modules§

hqc128
HQC-128: NIST Level 1 security (128-bit).
hqc192
HQC-192: NIST Level 3 security (192-bit).
hqc256
HQC-256: NIST Level 5 security (256-bit).

Structs§

Ciphertext
HQC ciphertext.
DecapsulationKey
HQC decapsulation key (secret key).
EncapsulationKey
HQC encapsulation key (public key).
Hqc128Params
HQC-128 parameter marker (NIST Level 1, 128-bit security).
Hqc192Params
HQC-192 parameter marker (NIST Level 3, 192-bit security).
Hqc256Params
HQC-256 parameter marker (NIST Level 5, 256-bit security).
HqcKem
HQC Key Encapsulation Mechanism parameterized by security level.
SharedSecret
HQC shared secret.

Enums§

Error
Errors that can occur during HQC operations.

Traits§

HqcParams
Trait defining an HQC parameter set.

Type Aliases§

Hqc128
HQC-128 KEM (NIST Level 1).
Hqc192
HQC-192 KEM (NIST Level 3).
Hqc256
HQC-256 KEM (NIST Level 5).