The key generation module provides functionality to create cryptographic key pairs for the PVAC-HFHE scheme.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.
Functions
keygen()
Generates a public-secret key pair for PVAC-HFHE encryption.System parameters defining security and performance characteristics
Output parameter for the generated public key
Output parameter for the generated secret key
Key generation process
Thekeygen() function performs the following steps:
- Parameter validation - Verifies that
Bdivides(p-1)wherep = 2^127 - 1 - Canonical tag generation - Creates a random
canon_tagfor public key identification - Parity check matrix - Generates the sparse parity check matrix
Husinggen_H() - Permutation generation - Creates the public permutation
ubkfromcanon_tag - PRF key setup - Generates 4 random 64-bit PRF keys for the secret key
- Subgroup generator - Finds a generator
gof orderBin the multiplicative group - Power table - Precomputes
powg_B[i] = g^ifori = 0toB-1 - Primitive root - Finds a primitive
B-th root of unityomega_B - LPN secret - Generates random secret bits
lpn_s_bitsof lengthlpn_n
The function will abort if the parameter
B does not divide (p-1), ensuring the multiplicative group structure is valid.factor_small()
Factors a small integer into its prime divisors.The integer to factor
Vector of unique prime divisors of
nGenerated key structures
Public key (PubKey)
The public key contains:prm- Copy of system parameterscanon_tag- Random tag for key identificationH- Sparse parity check matrix (n × m)ubk- Public permutation and its inverseH_digest- SHA-256 digest of matrix H for verificationomega_B- Primitive B-th root of unitypowg_B- Precomputed powers of subgroup generator
Secret key (SecKey)
The secret key contains:prf_k- Array of 4 pseudorandom function keys (64-bit each)lpn_s_bits- LPN secret bit vector of lengthlpn_n
Security considerations
The security of the scheme depends on:- LPN hardness - The Learning Parity with Noise problem with parameters
(lpn_n, lpn_t, tau) - Sparse code syndrome - The difficulty of decoding the sparse parity check matrix
H - PRF security - The pseudorandom properties of the key derivation functions
Example usage
Performance notes
Key generation involves:- Finding a subgroup generator (requires exponentiation in the finite field)
- Finding a primitive root of unity (requires primality testing)
- Generating the sparse matrix H (deterministic from
canon_tag) - Generating random LPN secrets (fast)
Related functions
gen_H()- Generates the parity check matrixgen_ubk_public()- Creates the public permutation