pub struct FheProgramNode<T: NumCiphertexts> {
pub ids: &'static [NodeIndex],
/* private fields */
}Expand description
A type that wraps an FheType during graph construction. It is an implementation detail and you should not construct these directly. Outside of very specific semantics, use-after-free and other undefined behaviors may occur.
Remarks
This type serves as an anchor so users can apply +, *, -, /, <<, and >> operators
on types inside an FHE program function. If the underlying type T implements the
GraphCipherAdd, GraphCipherMul, etc trait, then FheProgramNode<T> implements
std::ops::Add, std::ops::Mul, etc and proxies to T’s underlying
implementation.
This type impls the Copy trait so users don’t have to call .clone() all the time.
Unfortunately, this rules out the clean implementation of using a Vec<NodeIndex>
to store the graph nodes T represents; Vec does not impl Copy, and thus it
cannot exist in this type. To circumvent this limitation, we use a threadlocal
arena of NodeIndex to allocate and copy
slices. This requires we lie about the lifetime of ids, which isn’t actually ’static,
but rather until we clear the arena. We clean the arena in the FHE program macro after
FHE program construction and thus after all FheProgramNodes have gone out of scope.
You should never explicitly construct these outside of e.g. FHE type GraphCipherPlainAdd traits, which run during graph construction.
Undefined behavior
These types must be constructed while a crate::CURRENT_CTX refers to a valid
crate::Context. Furthermore, no FheProgramNode should outlive the said context.
Violating any of these conditions may result in memory corruption or
use-after-free.
Fields
ids: &'static [NodeIndex]The ids on this node. The ’static lifetime on this slice is a lie. The sunscreen compiler must ensure that no FheProgramNode exists after FHE program construction.
Implementations
sourceimpl<T: NumCiphertexts> FheProgramNode<T>
impl<T: NumCiphertexts> FheProgramNode<T>
sourcepub fn new(ids: &[NodeIndex]) -> Self
pub fn new(ids: &[NodeIndex]) -> Self
Creates a new FHE program node with the given node index.
These are an implementation detail needed while constructing the
FHE program graph
and should not be constructed at any other time. You should never
need to directly create a FheProgramNode.
Remarks
This type internally captures a slice rather than directly storing its own Vec. We do this so the type can impl Copy and composing FHE programs is natural without the user needing to call clone() all the time.
Undefined behavior
This type references memory in a bump allocator. Failing to ensure FheProgramNodes never outlive the backing context, will result in use-after-free.
sourcepub fn get_plain_modulus() -> u64
pub fn get_plain_modulus() -> u64
Returns the plain modulus parameter for the given BFV scheme
Trait Implementations
sourceimpl<T> Add<FheProgramNode<Cipher<T>>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherAdd<Left = T, Right = T>,
impl<T> Add<FheProgramNode<Cipher<T>>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherAdd<Left = T, Right = T>,
sourceimpl<T> Add<FheProgramNode<Cipher<T>>> for FheProgramNode<T> where
T: FheType + GraphCipherPlainAdd<Left = T, Right = T>,
impl<T> Add<FheProgramNode<Cipher<T>>> for FheProgramNode<T> where
T: FheType + GraphCipherPlainAdd<Left = T, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the + operator.
sourceimpl<T> Add<FheProgramNode<Cipher<T>>> for f64 where
T: FheType + GraphCipherConstAdd<Left = T, Right = f64> + TryFrom<f64>,
impl<T> Add<FheProgramNode<Cipher<T>>> for f64 where
T: FheType + GraphCipherConstAdd<Left = T, Right = f64> + TryFrom<f64>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the + operator.
sourceimpl<T> Add<FheProgramNode<Cipher<T>>> for i64 where
T: FheType + GraphCipherConstAdd<Left = T, Right = i64> + TryFrom<i64>,
impl<T> Add<FheProgramNode<Cipher<T>>> for i64 where
T: FheType + GraphCipherConstAdd<Left = T, Right = i64> + TryFrom<i64>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the + operator.
sourceimpl<T> Add<FheProgramNode<Cipher<T>>> for u64 where
T: FheType + GraphCipherConstAdd<Left = T, Right = u64> + TryFrom<u64>,
impl<T> Add<FheProgramNode<Cipher<T>>> for u64 where
T: FheType + GraphCipherConstAdd<Left = T, Right = u64> + TryFrom<u64>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the + operator.
sourceimpl<T> Add<FheProgramNode<T>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherPlainAdd<Left = T, Right = T>,
impl<T> Add<FheProgramNode<T>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherPlainAdd<Left = T, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the + operator.
sourcefn add(self, rhs: FheProgramNode<T>) -> Self::Output
fn add(self, rhs: FheProgramNode<T>) -> Self::Output
Performs the + operation. Read more
sourceimpl<T, U> Add<T> for FheProgramNode<Cipher<U>> where
U: FheType + GraphCipherConstAdd<Left = U, Right = T>,
T: FheLiteral,
impl<T, U> Add<T> for FheProgramNode<Cipher<U>> where
U: FheType + GraphCipherConstAdd<Left = U, Right = T>,
T: FheLiteral,
sourceimpl<T: Clone + NumCiphertexts> Clone for FheProgramNode<T>
impl<T: Clone + NumCiphertexts> Clone for FheProgramNode<T>
sourcefn clone(&self) -> FheProgramNode<T>
fn clone(&self) -> FheProgramNode<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<T: Debug + NumCiphertexts> Debug for FheProgramNode<T>
impl<T: Debug + NumCiphertexts> Debug for FheProgramNode<T>
sourceimpl<T> Div<FheProgramNode<Cipher<T>>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherDiv<Left = T, Right = T>,
impl<T> Div<FheProgramNode<Cipher<T>>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherDiv<Left = T, Right = T>,
sourceimpl<T> Div<FheProgramNode<Cipher<T>>> for FheProgramNode<T> where
T: FheType + GraphPlainCipherDiv<Left = T, Right = T>,
impl<T> Div<FheProgramNode<Cipher<T>>> for FheProgramNode<T> where
T: FheType + GraphPlainCipherDiv<Left = T, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the / operator.
sourceimpl<T> Div<FheProgramNode<Cipher<T>>> for f64 where
T: FheType + GraphConstCipherDiv<Left = f64, Right = T> + TryFrom<f64>,
impl<T> Div<FheProgramNode<Cipher<T>>> for f64 where
T: FheType + GraphConstCipherDiv<Left = f64, Right = T> + TryFrom<f64>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the / operator.
sourceimpl<T> Div<FheProgramNode<Cipher<T>>> for i64 where
T: FheType + GraphConstCipherDiv<Left = i64, Right = T> + TryFrom<f64>,
impl<T> Div<FheProgramNode<Cipher<T>>> for i64 where
T: FheType + GraphConstCipherDiv<Left = i64, Right = T> + TryFrom<f64>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the / operator.
sourceimpl<T> Div<FheProgramNode<Cipher<T>>> for u64 where
T: FheType + GraphConstCipherDiv<Left = u64, Right = T> + TryFrom<f64>,
impl<T> Div<FheProgramNode<Cipher<T>>> for u64 where
T: FheType + GraphConstCipherDiv<Left = u64, Right = T> + TryFrom<f64>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the / operator.
sourceimpl<T> Div<FheProgramNode<T>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherPlainDiv<Left = T, Right = T>,
impl<T> Div<FheProgramNode<T>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherPlainDiv<Left = T, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the / operator.
sourcefn div(self, rhs: FheProgramNode<T>) -> Self::Output
fn div(self, rhs: FheProgramNode<T>) -> Self::Output
Performs the / operation. Read more
sourceimpl<T, U> Div<U> for FheProgramNode<Cipher<T>> where
U: FheLiteral,
T: FheType + GraphCipherConstDiv<Left = T, Right = U>,
impl<T, U> Div<U> for FheProgramNode<Cipher<T>> where
U: FheLiteral,
T: FheType + GraphCipherConstDiv<Left = T, Right = U>,
sourceimpl<T> Input for FheProgramNode<T> where
T: NumCiphertexts + TypeName,
impl<T> Input for FheProgramNode<T> where
T: NumCiphertexts + TypeName,
type Output = FheProgramNode<T>
type Output = FheProgramNode<T>
The type returned by the input fn`.
sourceimpl<T> LaneCount for FheProgramNode<Cipher<T>> where
T: FheType + LaneCount,
impl<T> LaneCount for FheProgramNode<Cipher<T>> where
T: FheType + LaneCount,
sourcefn lane_count() -> usize
fn lane_count() -> usize
The number of lanes.
sourceimpl<T> Mul<FheProgramNode<Cipher<T>>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherMul<Left = T, Right = T>,
impl<T> Mul<FheProgramNode<Cipher<T>>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherMul<Left = T, Right = T>,
sourceimpl<T> Mul<FheProgramNode<Cipher<T>>> for FheProgramNode<T> where
T: FheType + GraphCipherPlainMul<Left = T, Right = T>,
impl<T> Mul<FheProgramNode<Cipher<T>>> for FheProgramNode<T> where
T: FheType + GraphCipherPlainMul<Left = T, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the * operator.
sourceimpl<T> Mul<FheProgramNode<Cipher<T>>> for f64 where
T: FheType + GraphCipherConstMul<Left = T, Right = f64> + TryFrom<f64>,
impl<T> Mul<FheProgramNode<Cipher<T>>> for f64 where
T: FheType + GraphCipherConstMul<Left = T, Right = f64> + TryFrom<f64>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the * operator.
sourceimpl<T> Mul<FheProgramNode<Cipher<T>>> for i64 where
T: FheType + GraphCipherConstMul<Left = T, Right = i64> + TryFrom<i64>,
impl<T> Mul<FheProgramNode<Cipher<T>>> for i64 where
T: FheType + GraphCipherConstMul<Left = T, Right = i64> + TryFrom<i64>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the * operator.
sourceimpl<T> Mul<FheProgramNode<Cipher<T>>> for u64 where
T: FheType + GraphCipherConstMul<Left = T, Right = u64> + TryFrom<u64>,
impl<T> Mul<FheProgramNode<Cipher<T>>> for u64 where
T: FheType + GraphCipherConstMul<Left = T, Right = u64> + TryFrom<u64>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the * operator.
sourceimpl<T> Mul<FheProgramNode<T>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherPlainMul<Left = T, Right = T>,
impl<T> Mul<FheProgramNode<T>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherPlainMul<Left = T, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the * operator.
sourcefn mul(self, rhs: FheProgramNode<T>) -> Self::Output
fn mul(self, rhs: FheProgramNode<T>) -> Self::Output
Performs the * operation. Read more
sourceimpl<T, U> Mul<T> for FheProgramNode<Cipher<U>> where
U: FheType + GraphCipherConstMul<Left = U, Right = T> + TryFrom<T>,
T: FheLiteral,
impl<T, U> Mul<T> for FheProgramNode<Cipher<U>> where
U: FheType + GraphCipherConstMul<Left = U, Right = T> + TryFrom<T>,
T: FheLiteral,
sourceimpl<T> Neg for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherNeg<Val = T>,
impl<T> Neg for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherNeg<Val = T>,
sourceimpl<T> NumCiphertexts for FheProgramNode<T> where
T: NumCiphertexts,
impl<T> NumCiphertexts for FheProgramNode<T> where
T: NumCiphertexts,
sourceconst NUM_CIPHERTEXTS: usize = T::NUM_CIPHERTEXTS
const NUM_CIPHERTEXTS: usize = T::NUM_CIPHERTEXTS
The number of ciphertexts this type decomposes into.
sourceimpl<T> Output for FheProgramNode<T> where
T: NumCiphertexts,
impl<T> Output for FheProgramNode<T> where
T: NumCiphertexts,
sourceimpl<T: PartialEq + NumCiphertexts> PartialEq<FheProgramNode<T>> for FheProgramNode<T>
impl<T: PartialEq + NumCiphertexts> PartialEq<FheProgramNode<T>> for FheProgramNode<T>
sourcefn eq(&self, other: &FheProgramNode<T>) -> bool
fn eq(&self, other: &FheProgramNode<T>) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &FheProgramNode<T>) -> bool
fn ne(&self, other: &FheProgramNode<T>) -> bool
This method tests for !=.
sourceimpl<T> Sub<FheProgramNode<Cipher<T>>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherSub<Left = T, Right = T>,
impl<T> Sub<FheProgramNode<Cipher<T>>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherSub<Left = T, Right = T>,
sourceimpl<T> Sub<FheProgramNode<Cipher<T>>> for FheProgramNode<T> where
T: FheType + GraphPlainCipherSub<Left = T, Right = T>,
impl<T> Sub<FheProgramNode<Cipher<T>>> for FheProgramNode<T> where
T: FheType + GraphPlainCipherSub<Left = T, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the - operator.
sourceimpl<T> Sub<FheProgramNode<Cipher<T>>> for f64 where
T: FheType + GraphConstCipherSub<Left = f64, Right = T>,
impl<T> Sub<FheProgramNode<Cipher<T>>> for f64 where
T: FheType + GraphConstCipherSub<Left = f64, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the - operator.
sourceimpl<T> Sub<FheProgramNode<Cipher<T>>> for i64 where
T: FheType + GraphConstCipherSub<Left = i64, Right = T>,
impl<T> Sub<FheProgramNode<Cipher<T>>> for i64 where
T: FheType + GraphConstCipherSub<Left = i64, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the - operator.
sourceimpl<T> Sub<FheProgramNode<Cipher<T>>> for u64 where
T: FheType + GraphConstCipherSub<Left = u64, Right = T>,
impl<T> Sub<FheProgramNode<Cipher<T>>> for u64 where
T: FheType + GraphConstCipherSub<Left = u64, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the - operator.
sourceimpl<T> Sub<FheProgramNode<T>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherPlainSub<Left = T, Right = T>,
impl<T> Sub<FheProgramNode<T>> for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherPlainSub<Left = T, Right = T>,
type Output = FheProgramNode<Cipher<T>>
type Output = FheProgramNode<Cipher<T>>
The resulting type after applying the - operator.
sourcefn sub(self, rhs: FheProgramNode<T>) -> Self::Output
fn sub(self, rhs: FheProgramNode<T>) -> Self::Output
Performs the - operation. Read more
sourceimpl<T, U> Sub<T> for FheProgramNode<Cipher<U>> where
U: FheType + GraphCipherConstSub<Left = U, Right = T>,
T: FheLiteral,
impl<T, U> Sub<T> for FheProgramNode<Cipher<U>> where
U: FheType + GraphCipherConstSub<Left = U, Right = T>,
T: FheLiteral,
sourceimpl<T> SwapRows for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherSwapRows,
impl<T> SwapRows for FheProgramNode<Cipher<T>> where
T: FheType + GraphCipherSwapRows,
sourceimpl<T> TypeName for FheProgramNode<T> where
T: TypeName + NumCiphertexts,
impl<T> TypeName for FheProgramNode<T> where
T: TypeName + NumCiphertexts,
impl<T: Copy + NumCiphertexts> Copy for FheProgramNode<T>
impl<T: Eq + NumCiphertexts> Eq for FheProgramNode<T>
impl<T: NumCiphertexts> StructuralEq for FheProgramNode<T>
impl<T: NumCiphertexts> StructuralPartialEq for FheProgramNode<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for FheProgramNode<T> where
T: RefUnwindSafe,
impl<T> Send for FheProgramNode<T> where
T: Send,
impl<T> Sync for FheProgramNode<T> where
T: Sync,
impl<T> Unpin for FheProgramNode<T> where
T: Unpin,
impl<T> UnwindSafe for FheProgramNode<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.