Template Class HEOperator< Scheme::BFV >
Defined in File operator.cuh
Inheritance Relationships
Derived Types
public heongpu::HEArithmeticOperator< Scheme::BFV >(Template Class HEArithmeticOperator< Scheme::BFV >)private heongpu::HELogicOperator< Scheme::BFV >(Template Class HELogicOperator< Scheme::BFV >)
Class Documentation
-
template<>
class HEOperator<Scheme::BFV> HEOperator is responsible for performing homomorphic operations on encrypted data, such as addition, subtraction, multiplication, and other functions.
The HEOperator class is initialized with encryption parameters and provides various functions for performing operations on ciphertexts, including BFV scheme. It supports both in-place and out-of-place operations, as well as asynchronous processing using CUDA streams.
Subclassed by heongpu::HEArithmeticOperator< Scheme::BFV >, heongpu::HELogicOperator< Scheme::BFV >
Public Functions
-
void add(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())
Adds two ciphertexts and stores the result in the output.
- Parameters:
input1 – First input ciphertext to be added.
input2 – Second input ciphertext to be added.
output – Ciphertext where the result of the addition is stored.
-
inline void add_inplace(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &input2, const ExecutionOptions &options = ExecutionOptions())
Adds the second ciphertext to the first ciphertext, modifying the first ciphertext with the result.
- Parameters:
input1 – The ciphertext to which the value of input2 will be added.
input2 – The ciphertext to be added to input1.
-
void sub(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())
Subtracts the second ciphertext from the first and stores the result in the output.
- Parameters:
input1 – First input ciphertext (minuend).
input2 – Second input ciphertext (subtrahend).
output – Ciphertext where the result of the subtraction is stored.
-
inline void sub_inplace(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &input2, const ExecutionOptions &options = ExecutionOptions())
Subtracts the second ciphertext from the first, modifying the first ciphertext with the result.
- Parameters:
input1 – The ciphertext from which input2 will be subtracted.
input2 – The ciphertext to subtract from input1.
-
void negate(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())
Negates a ciphertext and stores the result in the output.
- Parameters:
input1 – Input ciphertext to be negated.
output – Ciphertext where the result of the negation is stored.
-
inline void negate_inplace(Ciphertext<Scheme::BFV> &input1, const ExecutionOptions &options = ExecutionOptions())
Negates a ciphertext in-place, modifying the input ciphertext.
- Parameters:
input1 – Ciphertext to be negated.
-
inline void add_plain(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())
Adds a ciphertext and a plaintext and stores the result in the output.
- Parameters:
input1 – Input ciphertext to be added.
input2 – Input plaintext to be added.
output – Ciphertext where the result of the addition is stored.
-
inline void add_plain_inplace(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, const ExecutionOptions &options = ExecutionOptions())
Adds a plaintext to a ciphertext in-place, modifying the input ciphertext.
- Parameters:
input1 – Ciphertext to which the plaintext will be added.
input2 – Plaintext to be added to the ciphertext.
-
inline void sub_plain(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())
Subtracts a plaintext from a ciphertext and stores the result in the output.
- Parameters:
input1 – Input ciphertext (minuend).
input2 – Input plaintext (subtrahend).
output – Ciphertext where the result of the subtraction is stored.
-
inline void sub_plain_inplace(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, const ExecutionOptions &options = ExecutionOptions())
Subtracts a plaintext from a ciphertext in-place, modifying the input ciphertext.
- Parameters:
input1 – Ciphertext from which the plaintext will be subtracted.
input2 – Plaintext to be subtracted from the ciphertext.
-
inline void multiply(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())
Multiplies two ciphertexts and stores the result in the output.
- Parameters:
input1 – First input ciphertext to be multiplied.
input2 – Second input ciphertext to be multiplied.
output – Ciphertext where the result of the multiplication is stored.
-
inline void multiply_inplace(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &input2, const ExecutionOptions &options = ExecutionOptions())
Multiplies two ciphertexts in-place, modifying the first ciphertext.
- Parameters:
input1 – Ciphertext to be multiplied, and where the result will be stored.
input2 – Second input ciphertext to be multiplied.
-
inline void multiply_plain(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())
Multiplies a ciphertext and a plaintext and stores the result in the output.
- Parameters:
input1 – Input ciphertext to be multiplied.
input2 – Input plaintext to be multiplied.
output – Ciphertext where the result of the multiplication is stored.
-
inline void multiply_plain_inplace(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, const ExecutionOptions &options = ExecutionOptions())
Multiplies a plaintext with a ciphertext in-place, modifying the input ciphertext.
- Parameters:
input1 – Ciphertext to be multiplied by the plaintext, and where the result will be stored.
input2 – Plaintext to be multiplied with the ciphertext.
-
inline void relinearize_inplace(Ciphertext<Scheme::BFV> &input1, Relinkey<Scheme::BFV> &relin_key, const ExecutionOptions &options = ExecutionOptions())
Performs in-place relinearization of the given ciphertext using the provided relin key.
- Parameters:
input1 – Ciphertext to be relinearized.
relin_key – The Relinkey object used for relinearization.
-
inline void rotate_rows(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Galoiskey<Scheme::BFV> &galois_key, int shift, const ExecutionOptions &options = ExecutionOptions())
Rotates the rows of a ciphertext by a given shift value and stores the result in the output.
- Parameters:
input1 – Input ciphertext to be rotated.
output – Ciphertext where the result of the rotation is stored.
galois_key – Galois key used for the rotation operation.
shift – Number of positions to shift the rows.
-
inline void rotate_rows_inplace(Ciphertext<Scheme::BFV> &input1, Galoiskey<Scheme::BFV> &galois_key, int shift, const ExecutionOptions &options = ExecutionOptions())
Rotates the rows of a ciphertext in-place by a given shift value, modifying the input ciphertext.
- Parameters:
input1 – Ciphertext to be rotated.
galois_key – Galois key used for the rotation operation.
shift – Number of positions to shift the rows.
-
inline void rotate_columns(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Galoiskey<Scheme::BFV> &galois_key, const ExecutionOptions &options = ExecutionOptions())
Rotates the columns of a ciphertext and stores the result in the output.
- Parameters:
input1 – Input ciphertext to be rotated.
output – Ciphertext where the result of the rotation is stored.
galois_key – Galois key used for the rotation operation.
-
inline void apply_galois(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Galoiskey<Scheme::BFV> &galois_key, int galois_elt, const ExecutionOptions &options = ExecutionOptions())
Applies a Galois automorphism to the ciphertext and stores the result in the output.
- Parameters:
input1 – Input ciphertext to which the Galois operation will be applied.
output – Ciphertext where the result of the Galois operation is stored.
galois_key – Galois key used for the operation.
galois_elt – The Galois element to apply.
-
inline void apply_galois_inplace(Ciphertext<Scheme::BFV> &input1, Galoiskey<Scheme::BFV> &galois_key, int galois_elt, const ExecutionOptions &options = ExecutionOptions())
Applies a Galois automorphism to the ciphertext in-place, modifying the input ciphertext.
- Parameters:
input1 – Ciphertext to which the Galois operation will be applied.
galois_key – Galois key used for the operation.
galois_elt – The Galois element to apply.
-
inline void keyswitch(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Switchkey<Scheme::BFV> &switch_key, const ExecutionOptions &options = ExecutionOptions())
Performs key switching on the ciphertext and stores the result in the output.
- Parameters:
input1 – Input ciphertext to be key-switched.
output – Ciphertext where the result of the key switching is stored.
switch_key – Switch key used for the key switching operation.
-
inline void multiply_power_of_X(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, int index, const ExecutionOptions &options = ExecutionOptions())
-
inline void transform_to_ntt(Plaintext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())
Transforms a plaintext to the NTT domain and stores the result in the output.
- Parameters:
input1 – Input plaintext to be transformed.
output – Plaintext where the result of the transformation is stored.
-
inline void transform_to_ntt_inplace(Plaintext<Scheme::BFV> &input1, const ExecutionOptions &options = ExecutionOptions())
Transforms a plaintext to the NTT domain in-place, modifying the input plaintext.
- Parameters:
input1 – Plaintext to be transformed.
-
inline void transform_to_ntt(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())
Transforms a ciphertext to the NTT domain and stores the result in the output.
- Parameters:
input1 – Input ciphertext to be transformed.
output – Ciphertext where the result of the transformation is stored.
-
inline void transform_to_ntt_inplace(Ciphertext<Scheme::BFV> &input1, const ExecutionOptions &options = ExecutionOptions())
Transforms a ciphertext to the NTT domain in-place, modifying the input ciphertext.
- Parameters:
input1 – Ciphertext to be transformed.
-
inline void transform_from_ntt(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())
Transforms a ciphertext from the NTT domain and stores the result in the output.
- Parameters:
input1 – Input ciphertext to be transformed from the NTT domain.
output – Ciphertext where the result of the transformation is stored.
-
inline void transform_from_ntt_inplace(Ciphertext<Scheme::BFV> &input1, const ExecutionOptions &options = ExecutionOptions())
Transforms a ciphertext from the NTT domain in-place, modifying the input ciphertext.
- Parameters:
input1 – Ciphertext to be transformed from the NTT domain.
-
HEOperator() = default
-
HEOperator(const HEOperator ©) = default
-
HEOperator(HEOperator &&source) = default
-
HEOperator &operator=(const HEOperator &assign) = default
-
HEOperator &operator=(HEOperator &&assign) = default
Protected Functions
-
HEOperator(HEContext<Scheme::BFV> &context, HEEncoder<Scheme::BFV> &encoder)
Construct a new HEOperator object with the given parameters.
- Parameters:
context – Reference to the Parameters object that sets the encryption parameters for the operator.
-
void add_plain_bfv(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const cudaStream_t stream)
-
void add_plain_bfv_inplace(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, const cudaStream_t stream)
-
void sub_plain_bfv(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const cudaStream_t stream)
-
void sub_plain_bfv_inplace(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, const cudaStream_t stream)
-
void multiply_bfv(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const cudaStream_t stream)
-
void multiply_plain_bfv(Ciphertext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const cudaStream_t stream)
-
void relinearize_seal_method_inplace(Ciphertext<Scheme::BFV> &input1, Relinkey<Scheme::BFV> &relin_key, const cudaStream_t stream)
-
void relinearize_external_product_method_inplace(Ciphertext<Scheme::BFV> &input1, Relinkey<Scheme::BFV> &relin_key, const cudaStream_t stream)
-
void relinearize_external_product_method2_inplace(Ciphertext<Scheme::BFV> &input1, Relinkey<Scheme::BFV> &relin_key, const cudaStream_t stream)
-
void rotate_method_I(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Galoiskey<Scheme::BFV> &galois_key, int shift, const cudaStream_t stream)
-
void rotate_method_II(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Galoiskey<Scheme::BFV> &galois_key, int shift, const cudaStream_t stream)
-
void apply_galois_method_I(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Galoiskey<Scheme::BFV> &galois_key, int galois_elt, const cudaStream_t stream)
-
void apply_galois_method_II(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Galoiskey<Scheme::BFV> &galois_key, int galois_elt, const cudaStream_t stream)
-
void rotate_columns_method_I(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Galoiskey<Scheme::BFV> &galois_key, const cudaStream_t stream)
-
void rotate_columns_method_II(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Galoiskey<Scheme::BFV> &galois_key, const cudaStream_t stream)
-
void switchkey_method_I(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Switchkey<Scheme::BFV> &switch_key, const cudaStream_t stream)
-
void switchkey_method_II(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, Switchkey<Scheme::BFV> &switch_key, const cudaStream_t stream)
-
void negacyclic_shift_poly_coeffmod(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, int index, const cudaStream_t stream)
-
void transform_to_ntt_bfv_plain(Plaintext<Scheme::BFV> &input1, Plaintext<Scheme::BFV> &output, const cudaStream_t stream)
-
void transform_to_ntt_bfv_cipher(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, const cudaStream_t stream)
-
void transform_from_ntt_bfv_cipher(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &output, const cudaStream_t stream)
-
Ciphertext<Scheme::BFV> operator_from_ciphertext(Ciphertext<Scheme::BFV> &input, cudaStream_t stream = cudaStreamDefault)
Protected Attributes
-
scheme_type scheme_
-
int n
-
int n_power
-
int bsk_mod_count_
-
int Q_prime_size_
-
int Q_size_
-
int P_size_
-
std::shared_ptr<DeviceVector<Modulus64>> modulus_
-
std::shared_ptr<DeviceVector<Root64>> ntt_table_
-
std::shared_ptr<DeviceVector<Root64>> intt_table_
-
std::shared_ptr<DeviceVector<Ninverse64>> n_inverse_
-
std::shared_ptr<DeviceVector<Data64>> last_q_modinv_
-
std::shared_ptr<DeviceVector<Modulus64>> base_Bsk_
-
std::shared_ptr<DeviceVector<Root64>> bsk_ntt_tables_
-
std::shared_ptr<DeviceVector<Root64>> bsk_intt_tables_
-
std::shared_ptr<DeviceVector<Ninverse64>> bsk_n_inverse_
-
Modulus64 m_tilde_
-
std::shared_ptr<DeviceVector<Data64>> base_change_matrix_Bsk_
-
std::shared_ptr<DeviceVector<Data64>> inv_punctured_prod_mod_base_array_
-
std::shared_ptr<DeviceVector<Data64>> base_change_matrix_m_tilde_
-
Data64 inv_prod_q_mod_m_tilde_
-
std::shared_ptr<DeviceVector<Data64>> inv_m_tilde_mod_Bsk_
-
std::shared_ptr<DeviceVector<Data64>> prod_q_mod_Bsk_
-
std::shared_ptr<DeviceVector<Data64>> inv_prod_q_mod_Bsk_
-
Modulus64 plain_modulus_
-
std::shared_ptr<DeviceVector<Data64>> base_change_matrix_q_
-
std::shared_ptr<DeviceVector<Data64>> base_change_matrix_msk_
-
std::shared_ptr<DeviceVector<Data64>> inv_punctured_prod_mod_B_array_
-
Data64 inv_prod_B_mod_m_sk_
-
std::shared_ptr<DeviceVector<Data64>> prod_B_mod_q_
-
std::shared_ptr<DeviceVector<Modulus64>> q_Bsk_merge_modulus_
-
std::shared_ptr<DeviceVector<Root64>> q_Bsk_merge_ntt_tables_
-
std::shared_ptr<DeviceVector<Root64>> q_Bsk_merge_intt_tables_
-
std::shared_ptr<DeviceVector<Ninverse64>> q_Bsk_n_inverse_
-
std::shared_ptr<DeviceVector<Data64>> half_p_
-
std::shared_ptr<DeviceVector<Data64>> half_mod_
-
Data64 upper_threshold_
-
std::shared_ptr<DeviceVector<Data64>> upper_halfincrement_
-
Data64 Q_mod_t_
-
std::shared_ptr<DeviceVector<Data64>> coeeff_div_plainmod_
-
int d
-
int d_tilda
-
int r_prime
-
std::shared_ptr<DeviceVector<Modulus64>> B_prime_
-
std::shared_ptr<DeviceVector<Root64>> B_prime_ntt_tables_
-
std::shared_ptr<DeviceVector<Root64>> B_prime_intt_tables_
-
std::shared_ptr<DeviceVector<Ninverse64>> B_prime_n_inverse_
-
std::shared_ptr<DeviceVector<Data64>> base_change_matrix_D_to_B_
-
std::shared_ptr<DeviceVector<Data64>> base_change_matrix_B_to_D_
-
std::shared_ptr<DeviceVector<Data64>> Mi_inv_D_to_B_
-
std::shared_ptr<DeviceVector<Data64>> Mi_inv_B_to_D_
-
std::shared_ptr<DeviceVector<Data64>> prod_D_to_B_
-
std::shared_ptr<DeviceVector<Data64>> prod_B_to_D_
-
std::shared_ptr<DeviceVector<Data64>> base_change_matrix_D_to_Q_tilda_
-
std::shared_ptr<DeviceVector<Data64>> Mi_inv_D_to_Q_tilda_
-
std::shared_ptr<DeviceVector<Data64>> prod_D_to_Q_tilda_
-
std::shared_ptr<DeviceVector<int>> I_j_
-
std::shared_ptr<DeviceVector<int>> I_location_
-
std::shared_ptr<DeviceVector<int>> Sk_pair_
-
std::vector<Modulus64> prime_vector_
-
DeviceVector<int> new_prime_locations_
-
DeviceVector<int> new_input_locations_
-
int *new_prime_locations
-
int *new_input_locations
-
int slot_count_
-
std::shared_ptr<DeviceVector<Modulus64>> plain_modulus_pointer_
-
std::shared_ptr<DeviceVector<Ninverse64>> n_plain_inverse_
-
std::shared_ptr<DeviceVector<Root64>> plain_intt_tables_
-
std::shared_ptr<DeviceVector<Data64>> encoding_location_
-
void add(Ciphertext<Scheme::BFV> &input1, Ciphertext<Scheme::BFV> &input2, Ciphertext<Scheme::BFV> &output, const ExecutionOptions &options = ExecutionOptions())