pub struct FheProgramNode<T: NumCiphertexts, S = ()> {
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 CURRENT_FHE_CTX refers to a valid
FheContext. 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§
Source§impl<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.
Source§impl<T: NumCiphertexts, S> FheProgramNode<T, S>
impl<T: NumCiphertexts, S> FheProgramNode<T, S>
Sourcepub fn get_plain_modulus() -> u64
pub fn get_plain_modulus() -> u64
Returns the plain modulus parameter for the given BFV scheme
Trait Implementations§
Source§impl<L, T> Add<FheProgramNode<Cipher<T>>> for FheProgramNode<Indeterminate<L, T>, Stage>where
T: FheType + GraphCipherPlainAdd<Left = T, Right = T> + GraphCipherAdd<Left = T, Right = T>,
L: FheLiteral,
impl<L, T> Add<FheProgramNode<Cipher<T>>> for FheProgramNode<Indeterminate<L, T>, Stage>where
T: FheType + GraphCipherPlainAdd<Left = T, Right = T> + GraphCipherAdd<Left = T, Right = T>,
L: FheLiteral,
Source§type Output = FheProgramNode<Indeterminate<L, T>, Stage>
type Output = FheProgramNode<Indeterminate<L, T>, Stage>
+ operator.Source§impl<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>,
Source§impl<L, T> Add<FheProgramNode<Indeterminate<L, T>, Stage>> for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherPlainAdd<Left = T, Right = T> + GraphCipherAdd<Left = T, Right = T>,
L: FheLiteral,
impl<L, T> Add<FheProgramNode<Indeterminate<L, T>, Stage>> for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherPlainAdd<Left = T, Right = T> + GraphCipherAdd<Left = T, Right = T>,
L: FheLiteral,
Source§type Output = FheProgramNode<Indeterminate<L, T>, Stage>
type Output = FheProgramNode<Indeterminate<L, T>, Stage>
+ operator.Source§fn add(self, rhs: FheProgramNode<Indeterminate<L, T>, Stage>) -> Self::Output
fn add(self, rhs: FheProgramNode<Indeterminate<L, T>, Stage>) -> Self::Output
+ operation. Read moreSource§impl<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>,
Source§impl<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,
Source§impl<T> Add for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherAdd<Left = T, Right = T>,
impl<T> Add for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherAdd<Left = T, Right = T>,
Source§impl<T: Clone + NumCiphertexts, S: Clone> Clone for FheProgramNode<T, S>
impl<T: Clone + NumCiphertexts, S: Clone> Clone for FheProgramNode<T, S>
Source§fn clone(&self) -> FheProgramNode<T, S>
fn clone(&self) -> FheProgramNode<T, S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<L, T> Coerce<FheProgramNode<Cipher<T>>> for FheProgramNode<Indeterminate<L, T>, Stage>where
L: FheLiteral,
T: FheType,
impl<L, T> Coerce<FheProgramNode<Cipher<T>>> for FheProgramNode<Indeterminate<L, T>, Stage>where
L: FheLiteral,
T: FheType,
Source§impl<T: NumCiphertexts, S> Coerce<FheProgramNode<T, S>> for FheProgramNode<T, S>
impl<T: NumCiphertexts, S> Coerce<FheProgramNode<T, S>> for FheProgramNode<T, S>
Source§impl<T: Debug + NumCiphertexts, S: Debug> Debug for FheProgramNode<T, S>
impl<T: Debug + NumCiphertexts, S: Debug> Debug for FheProgramNode<T, S>
Source§impl<L, T> Div<FheProgramNode<Cipher<T>>> for FheProgramNode<Indeterminate<L, T>, Stage>where
T: FheType + GraphCipherPlainDiv<Left = T, Right = T> + GraphCipherDiv<Left = T, Right = T>,
L: FheLiteral,
impl<L, T> Div<FheProgramNode<Cipher<T>>> for FheProgramNode<Indeterminate<L, T>, Stage>where
T: FheType + GraphCipherPlainDiv<Left = T, Right = T> + GraphCipherDiv<Left = T, Right = T>,
L: FheLiteral,
Source§type Output = FheProgramNode<Indeterminate<L, T>, Stage>
type Output = FheProgramNode<Indeterminate<L, T>, Stage>
/ operator.Source§impl<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>,
Source§impl<L, T> Div<FheProgramNode<Indeterminate<L, T>, Stage>> for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherPlainDiv<Left = T, Right = T> + GraphCipherDiv<Left = T, Right = T>,
L: FheLiteral,
impl<L, T> Div<FheProgramNode<Indeterminate<L, T>, Stage>> for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherPlainDiv<Left = T, Right = T> + GraphCipherDiv<Left = T, Right = T>,
L: FheLiteral,
Source§type Output = FheProgramNode<Indeterminate<L, T>, Stage>
type Output = FheProgramNode<Indeterminate<L, T>, Stage>
/ operator.Source§fn div(self, rhs: FheProgramNode<Indeterminate<L, T>, Stage>) -> Self::Output
fn div(self, rhs: FheProgramNode<Indeterminate<L, T>, Stage>) -> Self::Output
/ operation. Read moreSource§impl<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>,
Source§impl<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>,
Source§impl<T> Div for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherDiv<Left = T, Right = T>,
impl<T> Div for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherDiv<Left = T, Right = T>,
Source§impl<L, T> From<FheProgramNode<Indeterminate<L, T>, Stage>> for FheProgramNode<Cipher<T>>where
L: FheLiteral,
T: FheType,
impl<L, T> From<FheProgramNode<Indeterminate<L, T>, Stage>> for FheProgramNode<Cipher<T>>where
L: FheLiteral,
T: FheType,
Source§fn from(value: FheProgramNode<Indeterminate<L, T>, Stage>) -> Self
fn from(value: FheProgramNode<Indeterminate<L, T>, Stage>) -> Self
Source§impl<T> Input for FheProgramNode<T>where
T: NumCiphertexts + TypeName,
impl<T> Input for FheProgramNode<T>where
T: NumCiphertexts + TypeName,
Source§impl<T> LaneCount for FheProgramNode<Cipher<T>>
impl<T> LaneCount for FheProgramNode<Cipher<T>>
Source§fn lane_count() -> usize
fn lane_count() -> usize
Source§impl<L, T> Mul<FheProgramNode<Cipher<T>>> for FheProgramNode<Indeterminate<L, T>, Stage>where
T: FheType + GraphCipherPlainMul<Left = T, Right = T> + GraphCipherMul<Left = T, Right = T>,
L: FheLiteral,
impl<L, T> Mul<FheProgramNode<Cipher<T>>> for FheProgramNode<Indeterminate<L, T>, Stage>where
T: FheType + GraphCipherPlainMul<Left = T, Right = T> + GraphCipherMul<Left = T, Right = T>,
L: FheLiteral,
Source§type Output = FheProgramNode<Indeterminate<L, T>, Stage>
type Output = FheProgramNode<Indeterminate<L, T>, Stage>
* operator.Source§impl<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>,
Source§impl<L, T> Mul<FheProgramNode<Indeterminate<L, T>, Stage>> for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherPlainMul<Left = T, Right = T> + GraphCipherMul<Left = T, Right = T>,
L: FheLiteral,
impl<L, T> Mul<FheProgramNode<Indeterminate<L, T>, Stage>> for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherPlainMul<Left = T, Right = T> + GraphCipherMul<Left = T, Right = T>,
L: FheLiteral,
Source§type Output = FheProgramNode<Indeterminate<L, T>, Stage>
type Output = FheProgramNode<Indeterminate<L, T>, Stage>
* operator.Source§fn mul(self, rhs: FheProgramNode<Indeterminate<L, T>, Stage>) -> Self::Output
fn mul(self, rhs: FheProgramNode<Indeterminate<L, T>, Stage>) -> Self::Output
* operation. Read moreSource§impl<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>,
Source§impl<T, U> Mul<T> for FheProgramNode<Cipher<U>>
impl<T, U> Mul<T> for FheProgramNode<Cipher<U>>
Source§impl<T> Mul for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherMul<Left = T, Right = T>,
impl<T> Mul for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherMul<Left = T, Right = T>,
Source§impl<T, S> NumCiphertexts for FheProgramNode<T, S>where
T: NumCiphertexts,
impl<T, S> NumCiphertexts for FheProgramNode<T, S>where
T: NumCiphertexts,
Source§const NUM_CIPHERTEXTS: usize = T::NUM_CIPHERTEXTS
const NUM_CIPHERTEXTS: usize = T::NUM_CIPHERTEXTS
Source§impl<T> Output for FheProgramNode<T>where
T: NumCiphertexts,
impl<T> Output for FheProgramNode<T>where
T: NumCiphertexts,
Source§impl<T: PartialEq + NumCiphertexts, S: PartialEq> PartialEq for FheProgramNode<T, S>
impl<T: PartialEq + NumCiphertexts, S: PartialEq> PartialEq for FheProgramNode<T, S>
Source§impl<L, T> Sub<FheProgramNode<Cipher<T>>> for FheProgramNode<Indeterminate<L, T>, Stage>where
T: FheType + GraphCipherPlainSub<Left = T, Right = T> + GraphCipherSub<Left = T, Right = T>,
L: FheLiteral,
impl<L, T> Sub<FheProgramNode<Cipher<T>>> for FheProgramNode<Indeterminate<L, T>, Stage>where
T: FheType + GraphCipherPlainSub<Left = T, Right = T> + GraphCipherSub<Left = T, Right = T>,
L: FheLiteral,
Source§type Output = FheProgramNode<Indeterminate<L, T>, Stage>
type Output = FheProgramNode<Indeterminate<L, T>, Stage>
- operator.Source§impl<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>,
Source§impl<L, T> Sub<FheProgramNode<Indeterminate<L, T>, Stage>> for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherPlainSub<Left = T, Right = T> + GraphCipherSub<Left = T, Right = T>,
L: FheLiteral,
impl<L, T> Sub<FheProgramNode<Indeterminate<L, T>, Stage>> for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherPlainSub<Left = T, Right = T> + GraphCipherSub<Left = T, Right = T>,
L: FheLiteral,
Source§type Output = FheProgramNode<Indeterminate<L, T>, Stage>
type Output = FheProgramNode<Indeterminate<L, T>, Stage>
- operator.Source§fn sub(self, rhs: FheProgramNode<Indeterminate<L, T>, Stage>) -> Self::Output
fn sub(self, rhs: FheProgramNode<Indeterminate<L, T>, Stage>) -> Self::Output
- operation. Read moreSource§impl<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>,
Source§impl<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,
Source§impl<T> Sub for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherSub<Left = T, Right = T>,
impl<T> Sub for FheProgramNode<Cipher<T>>where
T: FheType + GraphCipherSub<Left = T, Right = T>,
Source§impl<T, S> TypeName for FheProgramNode<T, S>where
T: TypeName + NumCiphertexts,
impl<T, S> TypeName for FheProgramNode<T, S>where
T: TypeName + NumCiphertexts,
impl<T: Copy + NumCiphertexts, S: Copy> Copy for FheProgramNode<T, S>
impl<T: Eq + NumCiphertexts, S: Eq> Eq for FheProgramNode<T, S>
impl<T: NumCiphertexts, S> StructuralPartialEq for FheProgramNode<T, S>
Auto Trait Implementations§
impl<T, S> Freeze for FheProgramNode<T, S>where
S: Freeze,
impl<T, S> RefUnwindSafe for FheProgramNode<T, S>where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for FheProgramNode<T, S>
impl<T, S> Sync for FheProgramNode<T, S>
impl<T, S> Unpin for FheProgramNode<T, S>
impl<T, S> UnwindSafe for FheProgramNode<T, S>where
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more