CircuitContext#
Currently, this API is unsupported in Python
-
class CircuitContext : public helayers::HeContext#
Public Functions
-
CircuitContext()#
-
~CircuitContext()#
-
void imitate(const HeContext &he)#
Initializes a circuit context with the same parameters and traits as given he.
- Parameters:
he – The HeContext to imitate.
-
virtual void init(const HeConfigRequirement &req) override#
Internal use.
-
inline circuit::NodeId createNodeId()#
Allocate a new NodeId.
-
inline int createTensorId()#
Allocate a new tensor ID.
-
void labelCtxt(const CTileTensor &c, const std::string &label)#
Associate a CTileTensor with a label.
This actually assigns a unique label to each CTile in the tile tensor.
- Parameters:
c – The tile tensor to associate with a label.
label – The label to associate to a CTile.
-
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<AbstractEncoder> getEncoder() const override#
Do not use. Should be made private.
-
inline virtual int slotCount() const override#
The number of slots in each CTile (ciphertext) or PTile (plaintext) created over this context.
-
inline virtual int getTopChainIndex() const override#
Returns the highest available chain index (for schemes where it is applicable).
-
virtual std::shared_ptr<std::vector<uint64_t>> getModulusChain() const override#
Returns the modulus chain: the value of each prime in the chain (where applicable).
Sets the modulus chain: the value of each prime in the chain (where applicable).
-
inline 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).
-
inline virtual int getSecurityLevel() const override#
Returns the security level supplied by this context.
-
virtual std::shared_ptr<AbstractBootstrapEvaluator> createAbstractBootstrapEvaluator(const BootstrapConfig &bsConfig) const override#
Do not use. Should be made private.
-
virtual void printSignature(std::ostream &out = std::cout) const override#
Prints a summary of library details and configuration params.
- Parameters:
out – [in] output stream to write to
-
inline 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.
-
inline virtual void loadSecretKey(std::istream &out, 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.
-
inline virtual std::string getSchemeName() const override#
Returns the name of the underlying scheme.
-
virtual std::string getSignature() const override#
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<HeContext> clone() const override#
Returns an uninitialized context of the same type.
Used for dynamic type loading among others.
-
inline virtual double getAccurateScale(int) const override#
Returns the accurate scale to be used for a given chain index.
Only supported when accurate scaling mode is enabled. Cannot be called before the context is initialized.
- Parameters:
chainIndex – the chain index to get the scale of.
- Throws:
runtime_error – If this SealCkksContext is not initialized.
runtime_error – If accurate scaling is not enabled.
-
virtual bool isConfigRequirementFeasible(const HeConfigRequirement &req) const override#
Internal use.
-
void logInputNode(const CircuitCiphertext &out)#
Log a new ciphertext.
- Parameters:
out – Id of ciphertext
-
void logOperator(circuit::PNode n)#
Log an operation that does not involve plaintext as a node in the circuit.
- Parameters:
n – The node to be added to the circuit.
-
void logMultiOutputsOperator(circuit::PNode n, const std::vector<circuit::NodeId> &outputIds)#
Log an operation that does not involve plaintext and has multiple outputs as a node in the circuit.
- Parameters:
n – The node to be added to the circuit.
outputIds – The nodes IDs of the outputs of this node.
Log an operation that involves a plaintext as a node in the circuit.
- Parameters:
n – The node to be added to the circuit.
p – The plaintext that is involved in the operation.
-
void flush()#
Finalize writing to the output.
-
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 int getChainIndexAfterBootstrapping() const override#
Assuming this HeContext is bootstrappable, returns the level of ciphertexts after bootstrapping.
-
virtual int getMinChainIndexForBootstrapping() const override#
Assuming this HeContext is bootstrappable, returns the minimum level in which ciphertexts can be bootstrapped.
-
inline void startGroup(const std::string &g, bool makeUnique = false)#
Start a new group.
Every node logged from now until the group closes will be a part of the group.
- Parameters:
g – The group name.
makeUnique – Add a prefix to make the group name unique. If there can be multiple groups with the same name they can be made unique by setting this parameter to true. A unique suffix of ” #<id>” will be added to the name.
-
inline void endGroup(const std::string &g)#
Close a group.
Every node logged since the creation of the group until now was a part of the group.
- Parameters:
g – The group name.
-
inline void startEra(const circuit::EraInfo &e)#
Start a new era.
Every node logged from now will belong to the new era.
- Parameters:
e – The info of the new era.
-
void addToTensorRepository(int tensorId, const DoubleTensor &tensor, const TTShape &shape)#
Adds a new tensor to the tensor repository of the circuit associated with this context, if not exist already (if exists, does nothing).
- Parameters:
tensorId – The ID of the tensor to add.
tensor – The tensor to add.
shape – The tile tensor shape associated with the tensor.
-
void addToTensorRepository(int tensorId, const ComplexTensor &tensor, const TTShape &shape)#
Adds a new complex tensor to the tensor repository of the circuit associated with this context, if not exist already (if exists, does nothing).
- Parameters:
tensorId – The ID of the tensor to add.
tensor – The complex tensor to add.
shape – The tile tensor shape associated with the tensor.
Public Static Functions
-
static void imitate(CTileTensor &dest, const CTileTensor &src)#
Create an imitating TileTensor with the same shape.
The new CTileTensor may have a different HeContext. This function can be used to generate a CTileTensor of CircuitContext that is imitating a CTileTensor of another context.
- Parameters:
src – The CTileTensor to imitate.
circ – The new imitating CTileTensor.
-
CircuitContext()#