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.
Overview
The decryption module provides functions for decrypting PVAC-HFHE ciphertexts back to plaintext values. Decryption requires both the public key and secret key.Core decryption functions
dec_value
Decrypts a single-slot ciphertext to a field element.
Public key used during encryption
Secret key used during encryption
Ciphertext to decrypt
The decrypted field element from the first slot
Description
Decrypts a ciphertext and returns the field element in the first slot. For single-value ciphertexts created withenc_value, this returns the encrypted integer modulo the field prime.
This function is equivalent to
dec_values(pk, sk, C)[0].dec_values
Decrypts a multi-slot ciphertext to a vector of field elements.
Public key used during encryption
Secret key used during encryption
Ciphertext to decrypt
Vector of decrypted field elements, one per slot
Description
Decrypts all slots of a ciphertext. The function:- Recursively evaluates the PRF
Rfor each layer using the secret key - Accumulates the contributions from all edges:
sum of ±g^B[i] * w[j] / R[layer][j] - Adds the constant term
c0
C.slots field elements.
See: decrypt.hpp:46
Implementation details
Layer PRF evaluation
The decryption algorithm uses a recursive PRF evaluation with caching:Public key
Secret key
Ciphertext being decrypted
Layer ID to evaluate
State vector for cycle detection
Cache for memoization
Vector of R values for the layer, one per slot
Description
Evaluates the PRF for a layer recursively:- BASE layers: Evaluates
prf_R_slots(pk, sk, L.seed, C.slots) - PROD layers: Computes
R[pa] * R[pb]element-wise
This is an internal function used by
dec_values. Users typically don’t call it directly.Decryption formula
For a ciphertextC, the decryption computes:
jranges over slots0..C.slots-1sign(SGN_P) = +1,sign(SGN_M) = -1g^B[i]is the public key’s generator power tableR[layer][j]is the PRF output for that layer and slot
Example usage
Performance notes
- Decryption time is proportional to the number of layers and edges
- Layer R values are cached, so shared layers are only evaluated once
- Multi-slot ciphertexts decrypt all slots in a single pass
- Large ciphertexts (many edges) take longer to decrypt
Consider using
compact_edges and compact_layers before decryption to improve performance on large ciphertexts.