HEaaN
Crypto Lab's great homomorphic encryption library
|
Namespaces | |
CudaTools | |
Classes | |
class | Bootstrapper |
A class consisting of bootstrap and its related functions. More... | |
class | Ciphertext |
A class of ciphertexts each of which contains a vector of polynomials of length > 1. More... | |
struct | CollectiveKeyGenConfig |
Configuration for collective key generation on which key to generate. More... | |
class | CollectiveKeyGenData |
A class to describe data being transfered between parties on the process of generating public keys from secret keys provided by multiple parties. More... | |
class | CollectiveKeyGenerator |
A class generating public keys from secret keys provided by multiple parties. More... | |
class | Decryptor |
Abstract entity for decrypting ciphertexts. More... | |
class | Device |
class | Encryptor |
Abstract entity for encrypting messages into ciphertexts. More... | |
class | EnDecoder |
Class containing functions dealing with message/plaintext encoding and decoding. More... | |
class | HomEvaluator |
A class consisting of basic operation of Ciphertext and Message. More... | |
class | KeyGenerator |
A class generating public (encryption/evaluation) keys from a secret key. More... | |
class | KeyPack |
Class managing public keys. More... | |
class | Message |
class | Plaintext |
A class of plaintexts each of which is simply a polynomial. More... | |
class | Pointer |
A class holding unique_ptr but is copied with deepcopy. More... | |
class | RuntimeException |
class | ScopedCudaDeviceSelector |
class | SecretKey |
Secret key class. More... | |
Typedefs | |
using | Context = std::shared_ptr< ContextContent > |
using | u64 = std::uint64_t |
using | i64 = std::int64_t |
using | u32 = std::uint32_t |
using | i32 = std::int32_t |
using | SeedType = std::array< u64, SEED_SIZE_IN_BYTES/8 > |
using | Real = double |
Default type for representing a real number. More... | |
using | Complex = std::complex< Real > |
Default type for representing a complex number. More... | |
using | DeviceSet = std::set< Device > |
using | CudaDeviceIds = std::set< int > |
Enumerations | |
enum | DeviceType { DeviceType::CPU, DeviceType::GPU, DeviceType::UNDEFINED, DeviceType::CPU_PINNED } |
Functions | |
HEAAN_API Context | makeContext (const ParameterPreset &preset, const CudaDeviceIds &cuda_device_ids={}) |
Make a context object based on a given parameter preset. More... | |
HEAAN_API Context | makeContext (const u64 log_dimension, const u64 chain_length, const u64 bpsize, const u64 qpsize, const u64 tpsize, const u64 gadget_rank, const CudaDeviceIds &cuda_device_ids={}) |
Make a context based on custom parameters. More... | |
HEAAN_API Context | makeContextFromFile (const std::string &filename, const CudaDeviceIds &cuda_device_ids={}) |
Make a context object from a "context file". More... | |
HEAAN_API void | saveContextToFile (const Context &context, const std::string &filename) |
Save a context object into a file. More... | |
HEAAN_API u64 | getLogFullSlots (const Context &context) |
Get the maximal logarithmic (base of 2) number of slots for the given context object. More... | |
HEAAN_API u64 | getEncryptionLevel (const Context &context) |
Get the level of a fresh ciphertext, which is the maximum level that users can encrypt a ciphertext to. More... | |
HEAAN_API std::vector< Real > | getDefaultScaleFactorList (const Context &context) |
Get the default list of scale factors. More... | |
HEAAN_API std::vector< u64 > | getPrimeList (const Context &context) |
Get the list of primes. More... | |
HEAAN_API bool | isBootstrappableParameter (const Context &context) |
Get whether the bootstrapping is supported. More... | |
HEAAN_API bool | isSparseSecretEncapsulationSupported (const Context &context) |
Get whether the given context supports sparse secret encapsulation or not. More... | |
HEAAN_API bool | isExtendedBootstrapSupported (const Context &context) |
Get whether the bootstrapping for extended range supported. More... | |
HEAAN_API std::set< i64 > | getRotIndicesForBootstrap (const Context &context, u64 log_slots) |
Get the list of rotation key index for the bootstrapping process. More... | |
HEAAN_API SecurityLevel | getSecurityLevel (const Context &context) |
Get the security level of the given context. More... | |
HEAAN_API void | save (const EvaluationKey &key, std::ostream &stream) |
Save key to a given stream . More... | |
HEAAN_API void | save (const EncryptionKey &key, std::ostream &stream) |
HEAAN_API void | save (const SparseSecretEncapsulationKey &key, std::ostream &stream) |
HEAAN_API void | load (EvaluationKey &key, std::istream &stream) |
Load key from a given stream . More... | |
HEAAN_API void | load (EncryptionKey &key, std::istream &stream) |
HEAAN_API void | load (SparseSecretEncapsulationKey &key, std::istream &stream) |
HEAAN_API ParameterPreset | getSparseParameterPresetFor (ParameterPreset preset) |
Returns the parameter preset which is required to perform sparse secret encapsulation on bootstrapping for certain parameters. More... | |
HEAAN_API SeedType | getSeed () |
Get the random seed of the current HEaaN instance. More... | |
HEAAN_API void | setSeed (const SeedType &new_global_seed) |
Set the random seed. More... | |
constexpr HEAAN_API Device | getDefaultDevice () |
HEAAN_API Device | getCurrentCudaDevice () |
HEAAN_API void | setCurrentCudaDevice (int device_id) |
Variables | |
constexpr u64 | U64ZERO = UINT64_C(0) |
constexpr u64 | U64ONE = UINT64_C(1) |
enum HEAAN_API | ParameterPreset |
Class of Parameter presets. More... | |
enum HEAAN_API | FVb |
enum HEAAN_API | FGa |
enum HEAAN_API | FGb |
enum HEAAN_API | FTa |
enum HEAAN_API | FTb |
enum HEAAN_API | ST19 |
enum HEAAN_API | ST14 |
enum HEAAN_API | ST11 |
enum HEAAN_API | ST8 |
enum HEAAN_API | ST7 |
enum HEAAN_API | SS7 |
enum HEAAN_API | SD3 |
enum HEAAN_API | CUSTOM |
enum HEAAN_API | FVc |
enum HEAAN_API | FX |
enum HEAAN_API | FGd |
enum HEAAN_API | SGd0 |
template class HEAAN_API | Pointer< PlaintextImpl > |
template class HEAAN_API | Pointer< CiphertextImpl > |
template class HEAAN_API | Pointer< MessageImpl > |
template class HEAAN_API | Pointer< SecretKeyImpl > |
template class HEAAN_API | Pointer< CollectiveKeyGenDataImpl > |
constexpr const u64 | SEED_SIZE_IN_BYTES {32} |
constexpr Real | REAL_ZERO = 0.0 |
Real number 0. More... | |
constexpr Real | REAL_ONE = 1.0 |
Real number 1. More... | |
constexpr Real | REAL_PI = 3.14159265358979323846 |
Real number pi. More... | |
constexpr Complex | COMPLEX_ZERO = Complex(REAL_ZERO, REAL_ZERO) |
Complex number 0. More... | |
constexpr Complex | COMPLEX_IMAG_UNIT = Complex(REAL_ZERO, REAL_ONE) |
Complex number i. More... | |
enum HEAAN_API | SecurityLevel |
Enum class for security levels. More... | |
enum HEAAN_API | Classical128 = 128 |
at least 128-bit security level classically. More... | |
enum HEAAN_API | Classical192 = 192 |
at least 192-bit security level classically. More... | |
enum HEAAN_API | Classical256 = 256 |
at least 256-bit security level classically. More... | |
using HEaaN::Complex = typedef std::complex<Real> |
Default type for representing a complex number.
using HEaaN::Context = typedef std::shared_ptr<ContextContent> |
using HEaaN::CudaDeviceIds = typedef std::set<int> |
using HEaaN::DeviceSet = typedef std::set<Device> |
using HEaaN::i32 = typedef std::int32_t |
using HEaaN::i64 = typedef std::int64_t |
using HEaaN::Real = typedef double |
Default type for representing a real number.
using HEaaN::SeedType = typedef std::array<u64, SEED_SIZE_IN_BYTES / 8> |
using HEaaN::u32 = typedef std::uint32_t |
using HEaaN::u64 = typedef std::uint64_t |
|
strong |
Get the default list of scale factors.
[in] | context |
The i-th element corresponds to level i. HEaaN uses fixed scale factor system, which fixes the scale factor with respect to each level. It helps managing scale factor properly, and saves some level.
Get the level of a fresh ciphertext, which is the maximum level that users can encrypt a ciphertext to.
[in] | context |
For somewhat homomorphic encryption parameters, it is equal to the maximum level of Q part. For some full homomorphic encryption parameters, however, some levels are reserved for bootstrapping and encrypting a ciphertext over this level is not allowed.
Get the maximal logarithmic (base of 2) number of slots for the given context object.
[in] | context |
The maximal number of slots is equal to N / 2 if N is the dimension of the context. The basic intention is to use this function with the constructor of the Message
class, which takes the logarithmic number of slots in order to allocate sufficient memory.
Get the list of primes.
[in] | context |
The i-th element corresponds to level i
Get the list of rotation key index for the bootstrapping process.
[in] | context | |
[in] | log_slots |
HEAAN_API SecurityLevel HEaaN::getSecurityLevel | ( | const Context & | context | ) |
Get the security level of the given context.
[in] | context | Context object |
The security level is chosen according to the homomorphic encryption standard documentation, Table 1, distribution (-1,1) (ternary uniform with elements -1, 0 and 1) and CryptoLab's own experimental results.
Get the random seed of the current HEaaN instance.
HEAAN_API ParameterPreset HEaaN::getSparseParameterPresetFor | ( | ParameterPreset | preset | ) |
Returns the parameter preset which is required to perform sparse secret encapsulation on bootstrapping for certain parameters.
The context of the sparse parameter should be constructed and provided to construct modules for the parameters. Sparse Secret Encapsulation is a technique to ease bootstrapping complexity while maintaing homomorphic capacity. For more details, please refer to the paper : Bootstrapping for Approximate Homomorphic Encryption with Negligible Failure-Probability by Using Sparse-Secret Encapsulation
Get whether the bootstrapping is supported.
[in] | context |
Get whether the bootstrapping for extended range supported.
[in] | context |
Get whether the given context supports sparse secret encapsulation or not.
[in] | context |
Returns true for the context using a parameter with dense hamming weight on secret key, which can be key-switched to a corresponding parameter with a sparse secret key during bootstrapping.
HEAAN_API void HEaaN::load | ( | EncryptionKey & | key, |
std::istream & | stream | ||
) |
HEAAN_API void HEaaN::load | ( | EvaluationKey & | key, |
std::istream & | stream | ||
) |
Load key
from a given stream
.
HEAAN_API void HEaaN::load | ( | SparseSecretEncapsulationKey & | key, |
std::istream & | stream | ||
) |
HEAAN_API Context HEaaN::makeContext | ( | const ParameterPreset & | preset, |
const CudaDeviceIds & | cuda_device_ids = {} |
||
) |
Make a context object based on a given parameter preset.
[in] | preset | Parameter preset |
[in] | cuda_device_ids | Optional CUDA device IDs to be used. You can use only the specified cuda devices with this Context. |
RuntimeException | if one calls this function with preset == ParameterPreset::CUSTOM. In order to make sense, one must use the other overloaded makeContext() function to specify custom parameters explicitly. |
HEAAN_API Context HEaaN::makeContext | ( | const u64 | log_dimension, |
const u64 | chain_length, | ||
const u64 | bpsize, | ||
const u64 | qpsize, | ||
const u64 | tpsize, | ||
const u64 | gadget_rank, | ||
const CudaDeviceIds & | cuda_device_ids = {} |
||
) |
Make a context based on custom parameters.
[in] | log_dimension | Logarithmic (with base 2) dimension of the ciphertexts and the keys. This means that in this homomorphic encryption context, the polynomials constituting the ciphertexts and the public/secret keys must be elements of the ring R[X] / (X^N + 1), where N is called the dimension of the polynomial (or of the ciphertexts). The value must be >= 10 and <= 20. |
[in] | chain_length | This is the number of primes in the RNS decomposition of each polynomial constituting the ciphertexts or the keys in the current homomorphic encryption context. There are the base prime (the prime at level 0) and the quantization primes at the higher levels, so chain_length is equal to the sum of the number of base primes (usually this number is 1) and the number of quantization primes. The value must be <= 50. |
[in] | bpsize | The size of the base prime in bits. The value must be greater than or equal to qpsize, less than or equal to 61. |
[in] | qpsize | The size of the quantization primes in bits. The value must be greater than or equal to 36, less than or equal to bpsize. |
[in] | tpsize | The size of the temporary primes in bits. The value must be greater than qpsize + (bpsize - qpsize) / numTP, less than or equal to
|
[in] | gadget_rank | This is the number of decomposed polynomials when one does the "modup" process in the middle of keyswitching process. More precisely, in the modup process, the maximal ciphertext modulus Q which is also a product of word-sized primes, is divided into gadget_rank number of pieces and the modup process is to be applied to each of these pieces. This also means that the size of the evaluation keys is roughly gadget_rank times of the fresh ciphertexts. Using smaller or bigger number of gadget_rank has its advantages and disadvantages: using bigger number means that the polynomial is divided more finely, and this causes bigger total size for the evaluation keys, meanwhile smaller gadget_rank makes the size of the evaluation keys smaller. However, since the security level of the parameter is determined by the size of each modup polynomial, so in order to retain the same security level, using smaller gadget_rank causes smaller ciphertext modulus size, i.e., less multiplication depth is allowed. Microsoft SEAL uses the maximum gadget_rank, i.e. equal to chain_length, while HEaaN allows smaller gadget_rank in order to accelerate homomorphic operations and reduce switching key size. |
[in] | cuda_device_ids | Optional CUDA device IDs to be used. You can use only the specified cuda devices with this Context. |
One must use this function to create a custom "somewhat" parameters, meaning ones with a fixed multiplication depth and without bootstrapping.
HEAAN_API Context HEaaN::makeContextFromFile | ( | const std::string & | filename, |
const CudaDeviceIds & | cuda_device_ids = {} |
||
) |
Make a context object from a "context file".
[in] | filename | It designates the path of the file to be read inside this function. |
[in] | cuda_device_ids | Optional CUDA device IDs to be used. You can use only the specified cuda devices with this Context. |
A context file is one created by saveContextToFile
.
RuntimeException | if it fails to open filename in read mode. |
HEAAN_API void HEaaN::save | ( | const EncryptionKey & | key, |
std::ostream & | stream | ||
) |
HEAAN_API void HEaaN::save | ( | const EvaluationKey & | key, |
std::ostream & | stream | ||
) |
Save key
to a given stream
.
HEAAN_API void HEaaN::save | ( | const SparseSecretEncapsulationKey & | key, |
std::ostream & | stream | ||
) |
Save a context object into a file.
[in] | context | A context object to be saved. |
[in] | filename | File path to be written. |
RuntimeException | if it fails to open filename in write mode. |
HEAAN_API void HEaaN::setCurrentCudaDevice | ( | int | device_id | ) |
Set the random seed.
[in] | new_global_seed | The internal random seed is to be set with this parameter. |
enum HEAAN_API HEaaN::Classical128 = 128 |
at least 128-bit security level classically.
enum HEAAN_API HEaaN::Classical192 = 192 |
at least 192-bit security level classically.
enum HEAAN_API HEaaN::Classical256 = 256 |
at least 256-bit security level classically.
Complex number i.
enum HEAAN_API HEaaN::CUSTOM |
enum HEAAN_API HEaaN::FGa |
enum HEAAN_API HEaaN::FGb |
enum HEAAN_API HEaaN::FGd |
enum HEAAN_API HEaaN::FTa |
enum HEAAN_API HEaaN::FTb |
enum HEAAN_API HEaaN::FVb |
enum HEAAN_API HEaaN::FVc |
enum HEAAN_API HEaaN::FX |
|
strong |
Class of Parameter presets.
The first alphabet denotes whether a parameter is full or somewhat homomorphic encryption. Somewhat homomorphic encryption parameters can use only a finite number of multiplications while full homomorphic encryption parameters can use infinitely many multiplications via bootstrapping. The second alphabet denotes the size of log2(N), where N denotes the dimension of the base ring. V(Venti), G(Grande), T(Tall), S(Short), D(Demi) represent log2(N) = 17, 16, 15, 14, 13, respectively. For somewhat parameters, a number that comes after these alphabets indicates total available multiplication number.
template class HEAAN_API HEaaN::Pointer< CiphertextImpl > |
template class HEAAN_API HEaaN::Pointer< CollectiveKeyGenDataImpl > |
template class HEAAN_API HEaaN::Pointer< MessageImpl > |
template class HEAAN_API HEaaN::Pointer< PlaintextImpl > |
template class HEAAN_API HEaaN::Pointer< SecretKeyImpl > |
|
constexpr |
Real number 1.
|
constexpr |
Real number pi.
|
constexpr |
Real number 0.
enum HEAAN_API HEaaN::SD3 |
|
strong |
Enum class for security levels.
This enum class represents the security level of the homomorphic encryption parameters. The prefix Classical
in the enum value names denotes that the security level in question is measured assuming classical computers, not quantum ones. signifies that no security level assumptions are imposed, suitable for parameters for experimental purposes.
|
constexpr |
enum HEAAN_API HEaaN::SGd0 |
enum HEAAN_API HEaaN::SS7 |
enum HEAAN_API HEaaN::ST11 |
enum HEAAN_API HEaaN::ST14 |
enum HEAAN_API HEaaN::ST19 |
enum HEAAN_API HEaaN::ST7 |
enum HEAAN_API HEaaN::ST8 |
|
constexpr |
|
constexpr |