helayers::HelibCkksContext Class Reference

An implementation of HeContext for Helib's CKKS scheme. More...

#include <HelibCkksContext.h>

Inheritance diagram for helayers::HelibCkksContext:
helayers::HelibContext helayers::HeContext

Public Member Functions

 HelibCkksContext ()
 Constructs an empty object.
 
void init (unsigned long m, unsigned long r, unsigned long L, unsigned long c=2, bool enableConjugate=true)
 Initializes context with given parameters.
 
void init (const HelibConfig &conf) override
 Initializes context with given configuration. More...
 
void init (const HelibConfig &conf, helib::Context *userContext, helib::SecKey *userSecretKey, helib::PubKey *userPublicKey)
 Initializes context with given context and keys. More...
 
std::shared_ptr< AbstractCiphertextcreateAbstractCipher () override
 Do not use. Should be made private.
 
std::shared_ptr< AbstractPlaintextcreateAbstractPlain () override
 Do not use. Should be made private.
 
std::shared_ptr< AbstractEncodergetEncoder () override
 Do not use. Should be made private.
 
const helib::EncryptedArrayCx & getEncryptedArray ()
 Returns encrypted array object.
 
bool getEnableConjugate () const
 
void load (std::istream &out) override
 Loads from binary stream.
 
std::string getSchemeName () const override
 Returns scheme name.
 
std::shared_ptr< HeContextclone () const override
 See parent method.
 
- Public Member Functions inherited from helayers::HelibContext
void init (const HeConfigRequirement &req) override
 Internal use.
 
void initPreset (HelibPreset preset)
 Initalizes with a given preset. More...
 
int getTopChainIndex () const override
 Returns the highest available chain index (for schemes where it is applicable).
 
int slotCount () const override
 The number of slots in each CTile (ciphertext) or PTile (plaintext) created over this context.
 
int getSecurityLevel () const override
 Returns the security level supplied by this context.
 
bool hasSecretKey () const override
 Returns whether this context contains a secret key. More...
 
const helib::PubKey & getPublicKey () const
 
const helib::SecKey & getSecretKey () const
 
const helib::Context & getContext () const
 
bool getMirrored () const
 
void setMirrored (bool v)
 
void printSignature (std::ostream &out=std::cout) const override
 Prints a summary of library details and configuration params. More...
 
void debugPrint (const std::string &title="", int verbose=0, std::ostream &out=std::cout) const override
 Prints detailed information for debug purposes. More...
 
void save (std::ostream &out, bool withSecretKey) override
 Saves this context to a stream in binary form. More...
 
void load (std::istream &in) override
 Loads context saved by the save() method. More...
 
void saveSecretKey (std::ostream &out) override
 Save secret key to the given ostream. More...
 
void loadSecretKey (std::istream &in) override
 Load secret key from the given istream. More...
 
std::string getLibraryName () const override
 Returns the name of the underlying library.
 
bool isConfigRequirementFeasible (const HeConfigRequirement &req) const override
 Internal use.
 
- Public Member Functions inherited from helayers::HeContext
 HeContext ()
 Constructs an empty object.
 
 HeContext (const HeContext &src)=delete
 Copy constructor. More...
 
HeContextoperator= (const HeContext &src)=delete
 Copy from another object. More...
 
virtual std::shared_ptr< AbstractFunctionEvaluatorgetFunctionEvaluator ()
 Do not use. Should be made private.
 
virtual std::shared_ptr< AbstractBitwiseEvaluatorgetBitwiseEvaluator ()
 Do not use. Should be made private.
 
const HeTraitsgetTraits ()
 Returns an HeTraits object containing various properties of the underlying scheme.
 
virtual std::shared_ptr< std::vector< uint64_t > > getModulusChain () const
 Returns the modulus chain bit length for each prime in the chain (where applicable).
 
void saveToFile (const std::string &fileName, bool withSecretKey)
 Saves this context to a file in binary form. More...
 
void loadFromFile (const std::string &fileName)
 Loads context saved by the saveToFile() method. More...
 
void saveSecretKeyToFile (const std::string &fileName)
 save secret key to the given file. More...
 
void loadSecretKeyFromFile (const std::string &fileName)
 load secret key from the given file. More...
 
virtual double getDefaultScale () const
 Returns default scale used in encoding (where applicable).
 
virtual void setDefaultScale (double v)
 Sets the default scale to be used in encoding (where applicable). More...
 
virtual std::string getSignature () const
 Returns a signature of the context that distinguishes it enough to be able to load previously stored contexts based on their signatures.
 
virtual std::shared_ptr< JsonWrappergetEstimatedLatencies () const
 For internal use.
 

Protected Member Functions

void initCommon (helib::Context *context)
 A helper function for init() method.
 

Additional Inherited Members

- Static Public Member Functions inherited from helayers::HelibContext
static std::shared_ptr< HelibContextcreate (HelibPreset preset)
 Creates a new HelibContext for either CKKS or BGV, based on a preset configuration. More...
 
- Static Public Member Functions inherited from helayers::HeContext
static std::shared_ptr< HeContextloadHeContextFromFile (const std::string &fileName)
 Returns a pointer to a context initialized from file. More...
 
static std::shared_ptr< HeContextloadHeContext (std::istream &in)
 Returns a pointer to a context initialized from stream. More...
 
static bool internalRegisterContext (const HeContext *context)
 Registers a context object for the purpose of dynamic loading. More...
 
- Protected Attributes inherited from helayers::HelibContext
HelibConfig config
 
helib::Context * context = NULL
 
helib::SecKey * secretKey = NULL
 
helib::PubKey * publicKey = NULL
 
long nslots = 0
 
bool mirrored = false
 
- Protected Attributes inherited from helayers::HeContext
HeTraits traits
 

Detailed Description

An implementation of HeContext for Helib's CKKS scheme.

It can be either initialized via parameters, via an HelibConfig, or loaded from a file. It is recommended not to use directly after initialization, but use an HeContext reference instead.

Member Function Documentation

◆ init() [1/2]

void helayers::HelibCkksContext::init ( const HelibConfig conf)
overridevirtual

Initializes context with given configuration.

Parameters
[in]confuser configuration

Reimplemented from helayers::HelibContext.

◆ init() [2/2]

void helayers::HelibCkksContext::init ( const HelibConfig conf,
helib::Context *  userContext,
helib::SecKey *  userSecretKey,
helib::PubKey *  userPublicKey 
)

Initializes context with given context and keys.

Parameters
[in]confuser configuration
[in]userContextuser context
[in]userSecretKeyuser secret key
[in]userPublicKeyuser public key

The documentation for this class was generated from the following files:
  • /opt/IBM/FHE-distro/ML-HElib/src/helayers/hebase/helib/HelibCkksContext.h
  • /opt/IBM/FHE-distro/ML-HElib/src/helayers/hebase/helib/HelibCkksContext.cpp