HEaaN
Crypto Lab's great homomorphic encryption library
Public Types | Public Member Functions | Private Attributes | List of all members
HEaaN::SecretKey Class Reference

Secret key class. More...

#include <SecretKey.hpp>

Public Types

using Coefficients = int *
 

Public Member Functions

 SecretKey (const Context &context)
 Generate random secret key. More...
 
 SecretKey (const Context &context, std::istream &stream)
 Load secret key from stream. More...
 
 SecretKey (const Context &context, const std::string &key_dir_path)
 Load secret key from file. More...
 
 SecretKey (const Context &context, const Coefficients &coefficients)
 Generate a secret key whose coefficients are copied from coefficients and fits context. More...
 
void save (const std::string &path) const
 Save a secret key to file. More...
 
void save (std::ostream &stream) const
 Save a secret key to stream. More...
 
void saveSeedOnly (const std::string &path) const
 Save the seed of a secret key to file. More...
 
void saveSeedOnly (std::ostream &stream) const
 Save the seed of a secret key to stream. More...
 
const ContextgetContext () const
 Get Context context. More...
 
Polynomial & getSx ()
 Get sx part of secret key. More...
 
const Polynomial & getSx () const
 Get const sx part of secret key. More...
 
Coefficients getCoefficients () const
 Get integer representation of coefficients. More...
 
const DevicegetDevice () const
 Get device a secret key reside in. More...
 
void to (const Device &device)
 Send a secret key to given device. More...
 

Private Attributes

Pointer< SecretKeyImpl > impl_
 

Detailed Description

Secret key class.

Member Typedef Documentation

◆ Coefficients

Constructor & Destructor Documentation

◆ SecretKey() [1/4]

HEaaN::SecretKey::SecretKey ( const Context context)
explicit

Generate random secret key.

◆ SecretKey() [2/4]

HEaaN::SecretKey::SecretKey ( const Context context,
std::istream &  stream 
)
explicit

Load secret key from stream.

The key can be loaded regardless of whether the stream is saving the full key or its seed only.

◆ SecretKey() [3/4]

HEaaN::SecretKey::SecretKey ( const Context context,
const std::string &  key_dir_path 
)
explicit

Load secret key from file.

The key can be loaded regardless of whether the stream is saving the full key or its seed only.

◆ SecretKey() [4/4]

HEaaN::SecretKey::SecretKey ( const Context context,
const Coefficients coefficients 
)
explicit

Generate a secret key whose coefficients are copied from coefficients and fits context.

The key cannot be save or loaded by its seed. Instead of using a uniform random bit generator, it fills the secret key's coefficients with integers from coefficients[0] to coefficients[context->getDimension() - 1].

Member Function Documentation

◆ getCoefficients()

Coefficients HEaaN::SecretKey::getCoefficients ( ) const

Get integer representation of coefficients.

◆ getContext()

const Context& HEaaN::SecretKey::getContext ( ) const

Get Context context.

◆ getDevice()

const Device& HEaaN::SecretKey::getDevice ( ) const

Get device a secret key reside in.

Returns
The device in which the secret key resides

◆ getSx() [1/2]

Polynomial& HEaaN::SecretKey::getSx ( )

Get sx part of secret key.

◆ getSx() [2/2]

const Polynomial& HEaaN::SecretKey::getSx ( ) const

Get const sx part of secret key.

◆ save() [1/2]

void HEaaN::SecretKey::save ( const std::string &  path) const

Save a secret key to file.

◆ save() [2/2]

void HEaaN::SecretKey::save ( std::ostream &  stream) const

Save a secret key to stream.

◆ saveSeedOnly() [1/2]

void HEaaN::SecretKey::saveSeedOnly ( const std::string &  path) const

Save the seed of a secret key to file.

The seed can reproduce the key under different parameter (Context) too.

◆ saveSeedOnly() [2/2]

void HEaaN::SecretKey::saveSeedOnly ( std::ostream &  stream) const

Save the seed of a secret key to stream.

The seed can reproduce the key under different parameter (Context) too.

◆ to()

void HEaaN::SecretKey::to ( const Device device)

Send a secret key to given device.

Parameters
[in]device

Member Data Documentation

◆ impl_

Pointer<SecretKeyImpl> HEaaN::SecretKey::impl_
private

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