LattigoContext#
- class LattigoContext#
An implementation of HeContext using the Lattigo backend.
- init(self: pyhelayers.LattigoContext, req: pyhelayers.HeConfigRequirement) None #
Initializes this LattigoContext according the given requirement.
- Parameters:
req – an HeConfigRequirement object, indicating the required configuration parameters (e.g. securityLevel, numSlots).
- Raises:
RuntimeError – if it is not possible to fulfill the given requirement.
-
class LattigoContext : public helayers::HeContext#
An implementation of HeContext for Lattigo.
Public Functions
-
LattigoContext()#
-
inline ~LattigoContext()#
-
virtual std::shared_ptr<AbstractCiphertext> createAbstractCipher() const override#
Do not use. Should be made private.
-
virtual std::shared_ptr<AbstractPlaintext> createAbstractPlain() const override#
Do not use. Should be made private.
-
virtual std::shared_ptr<AbstractBootstrapEvaluator> createAbstractBootstrapEvaluator(const BootstrapConfig &bsConfig) const override#
Do not use. Should be made private.
-
virtual std::shared_ptr<AbstractEncoder> getEncoder() const override#
Do not use. Should be made private.
-
virtual void printSignature(std::ostream &out) const override#
Prints a summary of library details and configuration params.
- Parameters:
out – [in] output stream to write to
-
virtual int getTopChainIndex() const override#
Returns the highest available chain index (for schemes where it is applicable).
-
virtual int getMinChainIndexForBootstrapping() const override#
Assuming this HeContext is bootstrappable, returns the minimum level in which ciphertexts can be bootstrapped.
-
virtual int slotCount() const override#
The number of slots in each CTile (ciphertext) or PTile (plaintext) created over this context.
-
virtual int getSecurityLevel() const override#
Returns the security level supplied by this context.
-
virtual bool hasSecretKey() const override#
Returns whether this context contains a secret key.
If not, decryption and other operations relying on decryption will not be available (will throw an exception).
-
virtual std::string getLibraryName() const override#
Returns the name of the underlying library.
-
virtual std::string getSchemeName() const override#
Returns the name of the underlying scheme.
-
virtual void saveSecretKey(std::ostream &out, bool seedOnly) override#
Save secret key to the given ostream.
- Parameters:
out – The binary stream to save to.
seedOnly – If true, only the seed used to control the secret key’s randomness will be saved, rather than the whole secret key.
- Throws:
runtime_error – If this HeContext doesn’t have a secret key. i.e. hasSecretKey() is false.
runtime_error – If seedOnly is true but the underlying HeContext does not support secret key I/O using seeds.
-
virtual void loadSecretKey(std::istream &in, bool seedOnly) override#
Load secret key from the given istream.
- Parameters:
in – The binary stream to load from.
seedOnly – If true, the seed of the secret key will be loaded from the given binary stream and the secret key will be generated using this seed.
- Throws:
runtime_error – If this HeContext already has a secret key. i.e. hasSecretKey() is true.
runtime_error – If seedOnly is true but the underlying HeContext does not support secret key I/O using seeds.
-
virtual std::shared_ptr<HeContext> clone() const override#
Returns an uninitialized context of the same type.
Used for dynamic type loading among others.
-
virtual int getBestFeasibleFractionalPartPrecision(const HeConfigRequirement &req) const override#
Returns the best feasible fractional part precision under the given configuration requirement.
If there is no such a fractional part precision, returns -1. All the fields of the given requirement other than req.fractionalPartPrecision are expected to be present, while any value in req.fractionalPartPrecision will be ignored.
- Parameters:
req – The requirement to get best fractional part precision for.
-
virtual void init(const HeConfigRequirement &req) override#
Internal use.
-
virtual bool isConfigRequirementFeasible(const HeConfigRequirement &req) const override#
Internal use.
-
virtual bool publicFunctionsSupported(const PublicFunctions &publicFunctions) const override#
Returns whether the given PublicFunctions object is supported by this HeContext.
The given PublicFunctions object is assumed to be valid (see also PublicFunctions::validate()).
- Parameters:
publicFunctions – The PublicFunctions object.
-
virtual HeConfigRequirement getActualConfigRequirement(const HeConfigRequirement &req) const override#
Returns the actual config requirement that will be enabled by the HE context when provided with the given config requirement.
Some parameters may differ from the original object and be “better”, e.g. higher multiplication depth.
- Parameters:
req – The given config requirement.
-
virtual int getBestFeasibleMulDepth(const HeConfigRequirement &req) const override#
Returns the best feasible multiplication depth under the given configuration requirement.
If there is no such a multiplication depth, returns -1. All the fields of the given requirement other than req.multiplicationDepth are expected to be present, while any value in req.multiplicationDepth will be ignored.
- Parameters:
req – The requirement to get best multiplication depth for.
-
virtual BootstrapConfig getBootstrapChainIndexes(const HeConfigRequirement &req) const override#
Returns a bootstrap config object with two chain index values: the minimum level in which ciphertexts can be bootstrapped and the level of ciphertexts after bootstrapping.
- Parameters:
req – The requirement, must indicate a bootstrappable object.
-
virtual int getChainIndexAfterBootstrapping() const override#
Assuming this HeContext is bootstrappable, returns the level of ciphertexts after bootstrapping.
-
virtual std::vector<double> getMaxAllowedValues() const override#
Returns the maximal absolute value allowed for each chain index.
Values lower than the threshold are guaranteed to not produce overflows. The value in position i corresponds to the limit for chain index i.
-
virtual std::map<std::string, int64_t> getEstimatedMeasures() const override#
For internal use.
-
virtual int getMinSupportedNumSlots() const override#
Returns the minimal number of slots supported by this HE context.
-
virtual int getMaxSupportedNumSlots() const override#
Returns the maximal number of slots supported by this HE context.
-
latticpp::Parameters getParameters() const#
Returns the scheme configured parameters object.
-
latticpp::PublicKey getPublicKey() const#
Returns the scheme’s public key.
-
latticpp::SecretKey getSecretKey() const#
Returns the scheme’s secret key.
-
latticpp::Evaluator *getEvaluator() const#
Returns an evaluator object. each thread has its own evaluator.
-
latticpp::KeyGenerator getKeyGenerator() const#
Returns the key generator object.
-
latticpp::RelinearizationKey getRelinearizationKey() const#
Returns the scheme’s relinearization key.
-
latticpp::RotationKeys getRotationKeys() const#
Returns the scheme’s rotation keys.
-
virtual bool isRotationExist(int rotateStep) const override#
Returns whether there exists a rotation key for the given rotation step.
- Parameters:
rotateStep – The rotation step.
-
latticpp::BootstrappingParameters getBootstrapParameters() const#
Returns the scheme’s bootstrapping preset parameters.
-
latticpp::Encoder getLattigoEncoder() const#
Returns the scheme encoder.
-
latticpp::Encryptor getLattigoEncryptor() const#
Returns the scheme encryptor.
-
latticpp::Decryptor getLattigoDecryptor() const#
Returns the scheme decryptor.
-
latticpp::BootstrappingKey getBootstrappingKey() const#
Returns the scheme’s bootstrapping keys.
-
virtual void genRotKeysFromHierarchicalKeys() override#
generate rotation keys from the hierarchical keys
-
LattigoContext()#