ComputeFHE 1.0
General-Purpose Privacy-Preserving Computation Library for TFHE
Loading...
Searching...
No Matches
Public Member Functions | List of all members
computefhe::ComputeFHE Class Reference

The core manager class for the ComputeFHE library. More...

#include <ComputeFHE.h>

Public Member Functions

 ComputeFHE (bool simulation_mode=false)
 Constructs a ComputeFHE instance.
 
 ComputeFHE (CryptoContextParam param, bool simulation_mode=false)
 Constructs a ComputeFHE instance with specific parameters.
 
 ComputeFHE (CryptoContextParam param, ALUType alu_type, bool simulation_mode=false)
 Constructs a ComputeFHE instance with specific parameters and ALU type.
 
 ComputeFHE (ALUType alu_type, bool simulation_mode=false)
 Constructs a ComputeFHE instance with a specific ALU type.
 
 ~ComputeFHE ()
 Destructor. Cleans up ALU and context resources.
 
BinFHEContextGetBinFHEContext ()
 Returns the underlying OpenFHE BinFHEContext.
 
BaseALUGetALU ()
 Returns the active ALU implementation.
 
BaseALUSimulatorGetSimulator ()
 Returns the simulator instance. Only valid in simulation mode. Returns nullptr if simulation mode is disabled.
 
CryptoContextParam GetCryptoContextParam ()
 Returns the current cryptographic context parameters.
 
ALUType GetALUType ()
 Returns the current ALU type (STANDARD or OPTIMIZED).
 
const LWEPrivateKeyGetLWEPrivateKey ()
 Returns the LWE Private Key. Requires CLIENT_MODE to be true.
 
void SetLWEPrivateKey (const LWEPrivateKey &sk)
 Sets the LWE Private Key.
 
void generateKeys ()
 Generates the secret key and switching keys for the context.
 
FixedPoint EncryptInt (uint64_t pt, size_t n_digits=8, bool fresh=true)
 Encrypts a 64-bit integer into a FixedPoint bit-vector.
 
uint64_t DecryptInt (const FixedPoint &ct, size_t n_digits=0)
 Decrypts a FixedPoint bit-vector back into a 64-bit integer.
 
BinaryDigit EncryptBool (bool pt, bool fresh=true)
 Encrypts a single boolean value.
 
bool DecryptBool (const BinaryDigit &ct)
 Decrypts a single BinaryDigit bit.
 
FixedPoint GetConstantInt (uint64_t pt, size_t n_digits=8)
 Creates an unencrypted FixedPoint representation of an integer.
 
uint64_t ConvertConstantInt (const FixedPoint &pt)
 Converts a constant (unencrypted) FixedPoint back to a 64-bit integer.
 
double extractNoise (ConstLWECiphertext &ct)
 Estimates the noise magnitude within a specific bit.
 
void PrintCryptoContextParams ()
 Prints the current cryptographic context settings to stdout.
 
void PrintLWECiphertextParams (ConstLWECiphertext &ct)
 Prints technical details about a specific LWE ciphertext to stdout.
 
bool isAutoEncryptMode ()
 Checks if Auto-Encrypt mode is enabled.
 
void setAutoEncryptMode (bool mode=true)
 Sets the Auto-Encrypt mode.
 

Detailed Description

The core manager class for the ComputeFHE library.

This class manages the OpenFHE BinFHEContext, private keys, and the active ALU implementation. It provides the primary API for encrypting/decrypting data and managing the global cryptographic state.

Constructor & Destructor Documentation

◆ ComputeFHE() [1/4]

computefhe::ComputeFHE::ComputeFHE ( bool  simulation_mode = false)

Constructs a ComputeFHE instance.

Parameters
simulation_modeIf true, initializes in simulation mode.

◆ ComputeFHE() [2/4]

computefhe::ComputeFHE::ComputeFHE ( CryptoContextParam  param,
bool  simulation_mode = false 
)

Constructs a ComputeFHE instance with specific parameters.

Parameters
paramThe cryptographic context parameters.
simulation_modeIf true, initializes in simulation mode.

◆ ComputeFHE() [3/4]

computefhe::ComputeFHE::ComputeFHE ( CryptoContextParam  param,
ALUType  alu_type,
bool  simulation_mode = false 
)

Constructs a ComputeFHE instance with specific parameters and ALU type.

Parameters
paramThe cryptographic context parameters.
alu_typeThe ALU implementation to use (Standard or Optimized).
simulation_modeIf true, initializes in simulation mode.

◆ ComputeFHE() [4/4]

computefhe::ComputeFHE::ComputeFHE ( ALUType  alu_type,
bool  simulation_mode = false 
)

Constructs a ComputeFHE instance with a specific ALU type.

Parameters
alu_typeThe ALU implementation to use.
simulation_modeIf true, initializes in simulation mode.

Member Function Documentation

◆ ConvertConstantInt()

uint64_t computefhe::ComputeFHE::ConvertConstantInt ( const FixedPoint pt)

Converts a constant (unencrypted) FixedPoint back to a 64-bit integer.

Parameters
ptThe unencrypted bit-vector.
Returns
The resulting 64-bit integer.

◆ DecryptBool()

bool computefhe::ComputeFHE::DecryptBool ( const BinaryDigit ct)

Decrypts a single BinaryDigit bit.

Parameters
ctThe encrypted bit.
Returns
The decrypted boolean value.

◆ DecryptInt()

uint64_t computefhe::ComputeFHE::DecryptInt ( const FixedPoint ct,
size_t  n_digits = 0 
)

Decrypts a FixedPoint bit-vector back into a 64-bit integer.

Parameters
ctThe encrypted bit-vector.
n_digitsThe number of bits to decrypt (0 defaults to vector size).
Returns
The decrypted 64-bit unsigned integer.

◆ EncryptBool()

BinaryDigit computefhe::ComputeFHE::EncryptBool ( bool  pt,
bool  fresh = true 
)

Encrypts a single boolean value.

Parameters
ptThe plaintext boolean.
freshIf true, performs fresh encryption.
Returns
A BinaryDigit proxy acting as a ciphertext.

◆ EncryptInt()

FixedPoint computefhe::ComputeFHE::EncryptInt ( uint64_t  pt,
size_t  n_digits = 8,
bool  fresh = true 
)

Encrypts a 64-bit integer into a FixedPoint bit-vector.

Parameters
ptThe plaintext integer value.
n_digitsThe bit-width of the resulting ciphertext.
freshIf true, performs fresh encryption; otherwise may use cached logic.
Returns
A FixedPoint object containing encrypted bits.

◆ extractNoise()

double computefhe::ComputeFHE::extractNoise ( ConstLWECiphertext ct)

Estimates the noise magnitude within a specific bit.

Parameters
ctThe ciphertext bit to analyze.
Returns
The noise level (useful for debugging bootstrapping thresholds).

◆ GetConstantInt()

FixedPoint computefhe::ComputeFHE::GetConstantInt ( uint64_t  pt,
size_t  n_digits = 8 
)

Creates an unencrypted FixedPoint representation of an integer.

This is used for creating "Constant" operands. These are not cryptographically secure but allow the ALU to perform faster Ciphertext-Plaintext operations.

Parameters
ptThe plaintext integer.
n_digitsThe bit-width.
Returns
A FixedPoint object where is_ct() is false.

◆ setAutoEncryptMode()

void computefhe::ComputeFHE::setAutoEncryptMode ( bool  mode = true)

Sets the Auto-Encrypt mode.

When enabled, plaintext literals used in operations with encrypted types are automatically passed through EncryptInt() in client mode. When disabled or in server mode, they are treated as plaintext constants via GetConstantInt().

Parameters
modeTrue to enable automatic encryption of plaintext literals.

The documentation for this class was generated from the following file: