Key generation is the foundation of PVAC-HFHE. This guide explains the cryptographic parameters, key structures, and security considerations.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/octra-labs/pvac_hfhe_cpp/llms.txt
Use this file to discover all available pages before exploring further.
Quick start
Parameters structure
TheParams struct controls security and performance trade-offs. From include/pvac/core/types.hpp:36-70:
Default parameters provide 128-bit security (estimated). Security is based on the Learning Parity with Noise (LPN) assumption.
Key parameter meanings
| Parameter | Value | Purpose |
|---|---|---|
B | 337 | Multiplicative group order (prime) |
m_bits | 8192 | LPN matrix rows |
n_bits | 16384 | LPN matrix columns |
lpn_n | 4096 | LPN secret dimension |
lpn_t | 16384 | LPN sample count |
edge_budget | 1,200,000 | Maximum edges before compaction |
Public key structure
Frominclude/pvac/core/types.hpp:123-131:
Key components
Params prmCopy of the parameter set used for key generation.
uint64_t canon_tagRandom tag for domain separation in PRFs.
std::vector<BitVec> HLPN matrix H used in encryption.
Fp omega_BPrimitive B-th root of unity in the field.
std::vector<Fp> powg_BPrecomputed powers g^0, g^1, …, g^(B-1) where g generates the multiplicative subgroup of order B.
std::array<uint8_t, 32> H_digestSHA-256 hash of the matrix H for verification.
Secret key structure
Frominclude/pvac/core/types.hpp:133-136:
Key components
std::array<uint64_t, 4> prf_k256-bit PRF key (4 × 64-bit words) for generating randomness.
std::vector<uint64_t> lpn_s_bitsLPN secret vector s packed as 64-bit words. Size is
(lpn_n + 63) / 64 words.
Key generation algorithm
Frominclude/pvac/crypto/keygen.hpp:35-136, the keygen function:
Find generator g
Find a generator of the multiplicative subgroup of order B using exponentiation by (p-1)/B
Generator finding (excerpt)
Frominclude/pvac/crypto/keygen.hpp:67-88:
LPN secret generation (excerpt)
Frominclude/pvac/crypto/keygen.hpp:124-135:
Inspecting generated keys
Fromexamples/basic_usage.cpp:51-56:
Key sizes
Based on benchmark data:| Key | Size | Notes |
|---|---|---|
| Public key | 8 MB | Includes H matrix and precomputed powers |
| Secret key | ~512 bytes | PRF key (32B) + LPN secret (~512 bits packed) |
Security considerations
LPN hardness
Security is based on the decisional LPN problem:include/pvac/core/types.hpp:53-56):
- Information-theoretic bound: 2226 bits
- Classical security: 200+ bits
- Quantum security: 100+ bits
These estimates assume τ = 1/8 (12.5% error rate) with the default parameters.
Performance
From benchmark data (benchmarks/README.md:198):
- Key generation time: 858.95 ms (mean)
- Comparison: 22x slower than BFV (38ms), but this is a one-time cost
Next steps
Encryption and decryption
Learn how to use the generated keys
Performance tuning
Optimize key generation and usage