HelibContext#
- class HelibContext#
An implementation of HeContext API with concrete subclasses for HElib scheme.
- static create(preset: pyhelayers.HelibPreset) pyhelayers.HelibContext #
Creates a new HelibContext for either CKKS or BGV, based on a preset configuration. See list of presets in HelibConfig.h
- Parameters:
preset – Preset configuration
- static set_ntl_num_threads(arg0: int) None #
Prints the HelibContext’s content.
-
class HelibContext : public helayers::HeContext#
An implementation of HeContext API with concrete subclasses for HElib scheme.
Subclassed by helayers::HelibBgvContext, helayers::HelibBitwiseContext, helayers::HelibCkksContext
Public Functions
-
HelibContext()#
A constructor.
-
virtual ~HelibContext()#
-
virtual void init(const HeConfigRequirement &req) override#
Not yet implemented.
- Throws:
runtime_error – When called.
-
void initPreset(HelibPreset preset)#
Initalizes with a given preset.
See list of presets in HelibConfig.h
- Parameters:
preset – Preset configuration name
-
virtual void init(const HelibConfig &conf)#
Initialize context with given configuration.
- Parameters:
conf – Configuration details
-
virtual int getTopChainIndex() const override#
Returns -1.
-
inline virtual int slotCount() const override#
returns the number of slots in plaintexts and ciphertexts created by this HelibContext.
-
inline virtual int getSecurityLevel() const override#
Returns the security level.
-
inline virtual bool hasSecretKey() const override#
Returns true if this HelibContext has a secret key and false otherwise.
-
inline const helib::PubKey &getPublicKey() const#
Returns the public key.
-
inline const helib::SecKey &getSecretKey() const#
Returns the secret key.
- Throws:
runtime_error – If this HelibContext does not have a secret key.
-
inline const helib::Context &getContext() const#
Returns the Context object of the underlying helib library.
-
inline bool getMirrored() const#
Returns true if the slots of plaintexts encoded with this helibContext will be mirrored and false otherwise.
-
inline void setMirrored(bool v)#
Sets or unsets the option of mirroring plaintext slot values before encoding.
-
virtual void printSignature(std::ostream &out = std::cout) const override#
Prints the signature of this helibContext.
- Parameters:
out – The ostream to print the signature to.
-
virtual void saveSecretKey(std::ostream &out, bool seedOnly = false) 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 = false) 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.
-
inline virtual std::string getLibraryName() const override#
Returns the name of the underlying library.
-
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.
Public Static Functions
-
static std::shared_ptr<HelibContext> create(HelibPreset preset)#
Creates a new HelibContext for either CKKS or BGV, based on a preset configuration.
See list of presets in HelibConfig.h
- Parameters:
preset – Preset configuration
-
HelibContext()#