Circuit#
Currently, this API is unsupported in Python
-
class Circuit#
A class that keeps the directed acyclic graph (DAG) that is the circuit.
Public Functions
-
inline Circuit()#
Constructs an empty circuit.
-
~Circuit()#
Destructs a circuit.
-
Circuit(Circuit &&c) noexcept#
Move constructor.
- Parameters:
c – the circuit to move into this instance.
-
PNode addNode(PNode n)#
Add a node to the circuit.
- Parameters:
n – the node to add.
-
PNode addInputNode(const CircuitCiphertext &c)#
Add an input node (a ctxt input) to the DAG.
The ciphertext is added with no label. A label can be added later.
- Parameters:
c – The ciphertext to add.
-
void buildEdges() const#
Finish the construction of the DAG after all nodes have been added.
-
inline bool areEdgesBuilt() const#
Return whether the edges have been built.
-
void setLabelCtxt(const CtxtLabel &label, const CtxtId &id)#
Give a node a human-meaningful label.
- Parameters:
label – The human meaningful label.
id – The node id to label.
-
void setTensorMetadata(const CtxtLabel &label, const TTShape &s)#
Store a TTShape with the circuit and give it a label.
- Parameters:
label – The label of the TTShape.
s – The shape to be stored.
-
const TTShape &getTensorMetadataShape(const CtxtLabel &label) const#
Get a TTShape from the circuit using the label it was given.
- Parameters:
label – The label of the TTShape.
-
void addPlaintextNode(const PtxtId &id, int chainIndex, const RawValues &p)#
Add a plaintext to the circuit.
The plaintext is added once and any references to this plaintex is done by its label.
- Parameters:
id – The id of the plaintext.
chainIndex – the chain index to encode the plaintext in
p – The raw values of the plaintext.
-
void addEncryptedParameters(const CtxtId &id, const LeveledRawValues &p)#
Add ciphertext values to the circuit.
Any inputs that are not labeled are considered as parameters and therefore a part of the circuit.
- Parameters:
id – The id of the plaintext.
p – The raw values of the plaintext.
-
inline const std::map<CtxtLabel, CtxtId> &getLabelToIdMap() const#
Get the map translating from a label to a ctxt id.
-
PNode getNodeByOutputId(const CtxtId &id) const#
Get a node by its id.
- Parameters:
id – The id of the node to retrieve.
-
bool hasNodeWithOutputId(const CtxtId &id) const#
Query whether a node with a given id exists in the circuit.
- Parameters:
id – The id of the node to query.
-
std::vector<PNode> getNodes() const#
Get the vector of nodes in the circuit.
-
const RawValues &getRawValues(const PtxtId &id) const#
Get the raw values of a plaintext of a certain id.
- Parameters:
id – The id of the plaintext to retrieve.
-
void writeGateList(std::ostream &o) const#
Write the circuit into a GateList file.
- Parameters:
o – The stream to write the file into.
-
void saveUnlabeledInputs(circuit::CtxtCacheMem &m, bool deleteValues = true)#
Record all unlabeled ctxt the circuit encountered.
Since ctxt that were not labeled are not input it must mean they are encrypted parameters of the circuit. With this function these ctxts can be saved to cache to be later encrypted and be used when running the circuit.
- Parameters:
m – A cache mem to write the unlabeled ctxts to.
deleteValues – Determines whether the values should be deleted from the circuit.
-
inline Circuit()#