Template Class Publickey< Scheme::CKKS >

Inheritance Relationships

Derived Type

Class Documentation

template<>
class Publickey<Scheme::CKKS>

Publickey represents a public key used for encrypting data in homomorphic encryption schemes.

The Publickey class is initialized with encryption parameters and provides a method to access the underlying public key data. This key is used in conjunction with the HEEncryptor class to encrypt plaintexts, making them suitable for homomorphic operations.

Subclassed by heongpu::MultipartyPublickey< Scheme::CKKS >

Public Functions

Publickey(HEContext<Scheme::CKKS> &context)

Constructs a new Publickey object with specified parameters.

Parameters:

context – Reference to the Parameters object that sets the encryption parameters.

Data64 *data()

Returns a pointer to the underlying public key data.

Returns:

Data64* Pointer to the public key data.

inline void switch_stream(cudaStream_t stream)

Switches the publickey CUDA stream.

Parameters:

stream – The new CUDA stream to be used.

inline cudaStream_t stream() const

Retrieves the CUDA stream associated with the publickey.

This function returns the CUDA stream that was used to create or last modify the publickey.

Returns:

The CUDA stream associated with the publickey.

inline int ring_size() const noexcept

Returns the size of the polynomial ring used in the homomorphic encryption scheme.

Returns:

int Size of the polynomial ring.

inline int coeff_modulus_count() const noexcept

Returns the number of coefficient modulus primes used in the encryption parameters.

Returns:

int Number of coefficient modulus primes.

void store_in_device(cudaStream_t stream = cudaStreamDefault)

Stores the ciphertext in the device (GPU) memory.

void store_in_host(cudaStream_t stream = cudaStreamDefault)

Stores the ciphertext in the host (CPU) memory.

inline bool is_on_device() const noexcept

Checks whether the data is stored on the device (GPU) memory.

Publickey() = default

Default constructor for Publickey.

Initializes an empty Publickey object. All members will have their default values.

inline Publickey(const Publickey &copy)

Copy constructor for creating a new Publickey object by copying an existing one.

This constructor performs a deep copy of the public key data, ensuring that the new object has its own independent copy of the data. GPU memory operations are handled using cudaMemcpyAsync for asynchronous data transfer.

Parameters:

copy – The source Publickey object to copy from.

inline Publickey(Publickey &&assign) noexcept

Move constructor for transferring ownership of a Publickey object.

Transfers all resources, including GPU memory, from the source object to the newly constructed object. The source object is left in a valid but undefined state.

Parameters:

assign – The source Publickey object to move from.

inline Publickey &operator=(const Publickey &copy)

Copy assignment operator for assigning one Publickey object to another.

Performs a deep copy of the public key data, ensuring that the target object has its own independent copy. GPU memory is copied using cudaMemcpyAsync.

Parameters:

copy – The source Publickey object to copy from.

Returns:

Reference to the assigned object.

inline Publickey &operator=(Publickey &&assign) noexcept

Move assignment operator for transferring ownership of a Publickey object.

Transfers all resources, including GPU memory, from the source object to the target object. The source object is left in a valid but undefined state.

Parameters:

assign – The source Publickey object to move from.

Returns:

Reference to the assigned object.

void save(std::ostream &os) const
void load(std::istream &is)