pub struct FheProgram {
    pub scheme: SchemeType,
    pub graph: StableGraph<NodeInfo, EdgeInfo>,
}
Expand description

The intermediate representation for an FHE program used in the compiler back-end.

Other modules may transform these using the forward_traverse and reverse_traverse methods, or iterate over the graph member for analysis or execution.

The graph construction methods append_* take NodeIndex types as arguments. These indices must refer to other nodes in the graph.

Fields

scheme: SchemeType

The scheme type this FHE program will run under.

graph: StableGraph<NodeInfo, EdgeInfo>

The underlying dependency graph.

Implementations

Create a new new empty intermediate representation.

Write this graph into graphviz dot format. The returned string contains the file’s contents.

Appends a negate operation that depends on operand x.

Appends a multiply operation that depends on the operands x and y.

Appends a multiply operation that depends on the operands x and y.

Appends an add operation that depends on the operands x and y.

Appends a subtract operation that depends on the operands x and y.

Appends an input ciphertext with the given name.

Appends an input plaintext with the given name.

Appends a constant literal unencrypted.

  • value: The integer or floating-point value in the literal.

Sppends a node designating x as an output of the FHE program.

Appends an operation that relinearizes x.

Appends an operation that rotates ciphertext x left by the literal node at y places.

Remarks

Recall that BFV has 2 rows in a Batched vector. This rotates each row. CKKS has one large vector.

Appends an operation that rotates ciphertext x right by the literal node at y places.

Remarks

Recall that BFV has 2 rows in a Batched vector. This rotates each row. CKKS has one large vector.

A specialized topological DAG traversal that allows the following graph mutations during traversal:

  • Delete the current node
  • Insert nodoes after current node
  • Add new nodes with no dependencies

Any other graph mutation will likely result in unvisited nodes.

  • callback: A closure that receives the current node index and an object allowing you to make graph queryes. This closure returns a transform list. forward_traverse will apply these transformations before continuing the traversal.

A specialized reverse topological DAG traversal that allows the following graph mutations during traversal:

  • Delete the current node
  • Insert nodoes after current node
  • Add new nodes with no dependencies

Any other graph mutation will likely result in unvisited nodes.

  • callback: A closure that receives the current node index and an object allowing you to make graph queryes. This closure returns a transform list. reverse_traverse will apply these transformations before continuing the traversal.

Remove the given node.

Returns the node indices of output ciphertexts

Returns the number of inputs ciphertexts this FHE program takes.

Runs tree shaking and returns a derived FheProgram with only dependencies required to run the requested nodes.

  • nodes: indices specifying a set of nodes in the graph. Prune return a new FheProgram containing nodes in the transitive closure of this set.

Validates this FheProgram for correctness.

Whether or not this FHE program needs relin keys to run. Needed for relinearization.

Whether or not this FHE program requires Galois keys to run. Needed for rotation and row swap operations.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.