HEaaN
Crypto Lab's great homomorphic encryption library
|
Class managing public keys. More...
#include <KeyPack.hpp>
Public Member Functions | |
KeyPack (const Context &context) | |
Create a KeyPack object. More... | |
KeyPack (const Context &context, const Context &context_sparse) | |
Create a KeyPack object which is capable of holding key for sparse secret encapsulation. More... | |
KeyPack (const Context &context, const std::string &key_dir_path) | |
Create a KeyPack object with a designated directory for saved keys. More... | |
KeyPack (const Context &context, const Context &context_sparse, const std::string &key_dir_path) | |
Create a KeyPack object with a designated directory for saved keys, for parameter supporting sparse secret encapsulation. More... | |
void | loadEncKey (void) |
Load encryption key from a file to the memory. More... | |
void | loadEncKey (std::istream &stream) |
void | loadMultKey (void) |
Load multiplication key from a file to the memory. More... | |
void | loadMultKey (std::istream &stream) |
void | loadConjKey (void) |
Load conjugation key from file to memory. More... | |
void | loadConjKey (std::istream &stream) |
void | loadLeftRotKey (const u64 rot) |
Load left rotation key (by rot) from file to memory. More... | |
void | loadLeftRotKey (const u64 rot, std::istream &stream) |
void | loadRightRotKey (const u64 rot) |
Load right rotation key (by rot) from file to memory. More... | |
void | loadRightRotKey (const u64 rot, std::istream &stream) |
void | loadSparseSecretEncapsulationKey (void) |
Load key for sparse secret encapsulation from file to memory. More... | |
void | loadSparseSecretEncapsulationKey (std::istream &stream) |
bool | isEncKeyLoaded (void) const |
Check whether the Encryption Key is loaded in memory. More... | |
bool | isMultKeyLoaded (void) const |
Check whether the Multiplication Key is loaded in memory. More... | |
bool | isLeftRotKeyLoaded (const u64 rot) const |
Check whether the Left Rotation Key is loaded in memory. More... | |
bool | isRightRotKeyLoaded (const u64 rot) const |
Check whether the Right Rotation Key is loaded in memory. More... | |
bool | isConjKeyLoaded (void) const |
Check whether the Conjugation Key is loaded in memory. More... | |
bool | isLeftRotKeyFileAvailable (const u64 rot) const |
Check whether the Left Rotation Key file is accessible. More... | |
bool | isSparseSecretEncapsulationKeyLoaded () const |
Check whether the sparse secret encapsulation key is loaded in memory. More... | |
std::shared_ptr< EncryptionKey > | getEncKey (void) const |
Get a pointer to the encryption key. More... | |
std::shared_ptr< EvaluationKey > | getMultKey (void) const |
Get a pointer to the multiplication key. More... | |
std::shared_ptr< EvaluationKey > | getLeftRotKey (const u64 rot) const |
Get a pointer to the left rotation key. More... | |
std::shared_ptr< EvaluationKey > | getRightRotKey (const u64 rot) const |
Get a pointer to the right roation key. More... | |
std::shared_ptr< EvaluationKey > | getConjKey (void) const |
Get a pointer to the conjugation key. More... | |
std::shared_ptr< SparseSecretEncapsulationKey > | getSparseSecretEncapsulationKey (void) const |
Get a pointer to the key for sparse secret encapsulation. More... | |
void | setKeyDirPath (const std::string &key_dir_path) |
Set the key directory for the keys in the current object. More... | |
void | to (const Device &device) |
Make all the keys only usable at device . This can be useful in memory-constrained environment since it frees the spaces allocated for keys in other devices. More... | |
void | save (std::ostream &stream) const |
Save multiplication, conjugation, encryption, sparse secret encapsulation, and all rotation keys to stream . More... | |
void | load (std::istream &stream) |
Load multiplication, conjugation, encryption, sparse secret encapsulation, and all rotation keys from stream . The context used to construct this KeyPack should match that of the keys in the stream; otherwise, it is undefined behavior. More... | |
void | save (const std::string &dir_path) const |
Save multiplication, conjugation, encryption, sparse secret encapsulation, and all rotation keys under a directory. More... | |
Private Attributes | |
std::shared_ptr< KeyPackImpl > | impl_ |
Pointer to the implementation class. More... | |
u64 | num_max_slots_ |
Maximal number of slots for the current context object. More... | |
Friends | |
class | KeyGenerator |
Class managing public keys.
Create a KeyPack object which is capable of holding key for sparse secret encapsulation.
|
explicit |
Create a KeyPack object with a designated directory for saved keys.
RuntimeException | if either keyDirPath or keyDirPath + "/PK" (the designated location for public keys) is not a valid directory |
|
explicit |
Create a KeyPack object with a designated directory for saved keys, for parameter supporting sparse secret encapsulation.
RuntimeException | if either keyDirPath or keyDirPath + "/PK" (the designated location for public keys) is not a valid directory |
RuntimeException | if context_sparse is not a context constructed with the corresponding sparse parameter of which constructed context. Please refer to SparseParameterPresetFor() on ParameterPreset.hpp for the sparse parameters. |
std::shared_ptr<EvaluationKey> HEaaN::KeyPack::getConjKey | ( | void | ) | const |
Get a pointer to the conjugation key.
This function first checks if the Conjugation Key is loaded in the memory (isConjKeyLoaded()). If it fails, then it tries to load the key from the file in the path, and if it fails again, then this function finally returns nullptr.
std::shared_ptr<EncryptionKey> HEaaN::KeyPack::getEncKey | ( | void | ) | const |
Get a pointer to the encryption key.
This function first checks if the Encryption Key is loaded in the memory (isEncKeyLoaded()). If it fails, then it tries to load the key from the file in the path, and if it fails again, then this function finally returns nullptr.
std::shared_ptr<EvaluationKey> HEaaN::KeyPack::getLeftRotKey | ( | const u64 | rot | ) | const |
Get a pointer to the left rotation key.
[in] | rot | The rotation index |
This function first checks if the Rotation Key is loaded in the memory (isLeftRotKeyLoaded()). If it fails, then it tries to load the key from the file in the path, and if it fails again, then this function finally returns nullptr.
std::shared_ptr<EvaluationKey> HEaaN::KeyPack::getMultKey | ( | void | ) | const |
Get a pointer to the multiplication key.
This function first checks if the Multiplication Key is loaded in the memory (isMultKeyLoaded()). If it fails, then it tries to load the key from the file in the path, and if it fails again, then this function finally returns nullptr.
std::shared_ptr<EvaluationKey> HEaaN::KeyPack::getRightRotKey | ( | const u64 | rot | ) | const |
Get a pointer to the right roation key.
[in] | rot | Thhe rotation index |
This function first checks if the Rotation Key is loaded in the memory (isRightRotKeyLoaded()). If it fails, then it tries to load the key from the file in the path, and if it fails again, then this function finally returns nullptr.
std::shared_ptr<SparseSecretEncapsulationKey> HEaaN::KeyPack::getSparseSecretEncapsulationKey | ( | void | ) | const |
Get a pointer to the key for sparse secret encapsulation.
This function first checks if sparse secret encryption keys are loaded in the memory (isSparseSecretEncapsulationKeyLoaded()). If it fails, then it tries to load the keys from the file in the path, and if it fails again, then this function finally returns nullptr.
bool HEaaN::KeyPack::isConjKeyLoaded | ( | void | ) | const |
Check whether the Conjugation Key is loaded in memory.
bool HEaaN::KeyPack::isEncKeyLoaded | ( | void | ) | const |
Check whether the Encryption Key is loaded in memory.
bool HEaaN::KeyPack::isLeftRotKeyFileAvailable | ( | const u64 | rot | ) | const |
Check whether the Left Rotation Key file is accessible.
bool HEaaN::KeyPack::isLeftRotKeyLoaded | ( | const u64 | rot | ) | const |
Check whether the Left Rotation Key is loaded in memory.
[in] | rot | Rotation Key index. |
bool HEaaN::KeyPack::isMultKeyLoaded | ( | void | ) | const |
Check whether the Multiplication Key is loaded in memory.
bool HEaaN::KeyPack::isRightRotKeyLoaded | ( | const u64 | rot | ) | const |
Check whether the Right Rotation Key is loaded in memory.
[in] | rot | Rotation Key index. |
bool HEaaN::KeyPack::isSparseSecretEncapsulationKeyLoaded | ( | ) | const |
Check whether the sparse secret encapsulation key is loaded in memory.
void HEaaN::KeyPack::load | ( | std::istream & | stream | ) |
Load multiplication, conjugation, encryption, sparse secret encapsulation, and all rotation keys from stream
. The context used to construct this KeyPack
should match that of the keys in the stream; otherwise, it is undefined behavior.
void HEaaN::KeyPack::loadConjKey | ( | std::istream & | stream | ) |
void HEaaN::KeyPack::loadConjKey | ( | void | ) |
Load conjugation key from file to memory.
If the key is already loaded in the memory or it cannot find the key file, this function does nothing. If stream is specified, load from the stream.
void HEaaN::KeyPack::loadEncKey | ( | std::istream & | stream | ) |
void HEaaN::KeyPack::loadEncKey | ( | void | ) |
Load encryption key from a file to the memory.
If the key is already loaded in the memory or it cannot find the key file, this function does nothing. If a stream is specified, load from the stream.
void HEaaN::KeyPack::loadLeftRotKey | ( | const u64 | rot | ) |
Load left rotation key (by rot) from file to memory.
[in] | rot | Rotation index (left rotation) |
If the key is already loaded in the memory or it cannot find the key file, this function does nothing. If stream is specified, load from the stream.
void HEaaN::KeyPack::loadLeftRotKey | ( | const u64 | rot, |
std::istream & | stream | ||
) |
void HEaaN::KeyPack::loadMultKey | ( | std::istream & | stream | ) |
void HEaaN::KeyPack::loadMultKey | ( | void | ) |
Load multiplication key from a file to the memory.
If the key is already loaded in the memory or it cannot find the key file, this function does nothing. If stream is specified, load from the stream.
void HEaaN::KeyPack::loadRightRotKey | ( | const u64 | rot | ) |
Load right rotation key (by rot) from file to memory.
[in] | rot | Rotation index (right rotation) |
If the key is already loaded in the memory or it cannot find the key file, this function does nothing. If stream is specified, load from the stream.
void HEaaN::KeyPack::loadRightRotKey | ( | const u64 | rot, |
std::istream & | stream | ||
) |
void HEaaN::KeyPack::loadSparseSecretEncapsulationKey | ( | std::istream & | stream | ) |
void HEaaN::KeyPack::loadSparseSecretEncapsulationKey | ( | void | ) |
Load key for sparse secret encapsulation from file to memory.
If the key is already loaded in the memory or it cannot find the key file, this function does nothing. If stream is specified, load from the stream.
void HEaaN::KeyPack::save | ( | const std::string & | dir_path | ) | const |
Save multiplication, conjugation, encryption, sparse secret encapsulation, and all rotation keys under a directory.
void HEaaN::KeyPack::save | ( | std::ostream & | stream | ) | const |
Save multiplication, conjugation, encryption, sparse secret encapsulation, and all rotation keys to stream
.
void HEaaN::KeyPack::setKeyDirPath | ( | const std::string & | key_dir_path | ) |
Set the key directory for the keys in the current object.
void HEaaN::KeyPack::to | ( | const Device & | device | ) |
Make all the keys only usable at device
. This can be useful in memory-constrained environment since it frees the spaces allocated for keys in other devices.
|
friend |
|
private |
Pointer to the implementation class.
|
private |
Maximal number of slots for the current context object.