pub struct DynamicGenericInt<T: CiphertextOps, U: Sign> {
pub bits: Vec<Arc<AtomicRefCell<T>>>,
/* private fields */
}Expand description
A dynamic generic integer stored in unpacked form. A dynamic generic integer encrypts its bits in
a few different ciphertexts of type T where the number of bits also represent the bit width
Fields§
§bits: Vec<Arc<AtomicRefCell<T>>>The ciphertexts encrypting this dynamic generic integer’s bits in least-to-most significant order.
Implementations§
Source§impl<T, U> DynamicGenericInt<T, U>where
T: CiphertextOps,
U: Sign,
impl<T, U> DynamicGenericInt<T, U>where
T: CiphertextOps,
U: Sign,
Sourcepub fn new(enc: &Encryption, n: usize) -> Self
pub fn new(enc: &Encryption, n: usize) -> Self
Allocate a new DynamicGenericInt using trivial or precomputed (if T is L1GgswCiphertext) encryptions
of zero.
Sourcepub fn from_bits_deep(bits: Vec<T>) -> Self
pub fn from_bits_deep(bits: Vec<T>) -> Self
Create a DynamicGenericInt from a previously encrypted set of type T ciphertexts.
§Remarks
bits are ordered from least to most significant.
This performs a deep copy of the underlying data.
Sourcepub fn from_bits_shallow(bits: Vec<Arc<AtomicRefCell<T>>>) -> Self
pub fn from_bits_shallow(bits: Vec<Arc<AtomicRefCell<T>>>) -> Self
Create a DynamicGenericInt from The inner ref-counted set of T ciphertexts.
§Remarks
bits are ordered from least to most significant.
This performs a shallow copy of the underlying data.
Sourcepub fn encrypt_secret(
val: U::PlaintextType,
enc: &Encryption,
sk: &SecretKey,
n: usize,
) -> Self
pub fn encrypt_secret( val: U::PlaintextType, enc: &Encryption, sk: &SecretKey, n: usize, ) -> Self
Sourcepub fn decrypt(&self, enc: &Encryption, sk: &SecretKey) -> U::PlaintextType
pub fn decrypt(&self, enc: &Encryption, sk: &SecretKey) -> U::PlaintextType
Decrypts this encrypted integer and returns the contained integer message.
Sourcepub fn graph_inputs<'a>(
&self,
ctx: &'a FheCircuitCtx,
) -> DynamicGenericIntGraphNodes<'a, T, U>
pub fn graph_inputs<'a>( &self, ctx: &'a FheCircuitCtx, ) -> DynamicGenericIntGraphNodes<'a, T, U>
Add input nodes to the given FheCircuitCtx.
Sourcepub fn with_decryption_fn<F>(&self, f: F) -> U::PlaintextType
pub fn with_decryption_fn<F>(&self, f: F) -> U::PlaintextType
Run a custom (e.g. threshold) decryption algorithm and return the result.
Sourcepub fn trivial(
val: U::PlaintextType,
enc: &Encryption,
eval: &Evaluation,
n: usize,
) -> Self
pub fn trivial( val: U::PlaintextType, enc: &Encryption, eval: &Evaluation, n: usize, ) -> Self
Create a trivial encryption of val.
§Remarks
If T is L1GgswCiphertext, then the result
will contain precomputed rather than trivial ciphertexts.
§Panics
If val >= 2**n or val < -(2**n)
Source§impl<U> DynamicGenericInt<L1GlweCiphertext, U>where
U: Sign,
impl<U> DynamicGenericInt<L1GlweCiphertext, U>where
U: Sign,
Sourcepub fn encrypt(
val: U::PlaintextType,
enc: &Encryption,
pk: &PublicKey,
n: usize,
) -> Self
pub fn encrypt( val: U::PlaintextType, enc: &Encryption, pk: &PublicKey, n: usize, ) -> Self
Encrypt val using PublicKey.
§Remarks
Requires the encryption parameters support RLWE encryption. crate::DEFAULT_128
have this property.
It’s generally recommended to encrypt a crate::fluent::PackedDynamicGenericInt
and unpack the result, as they’re significantly smaller.
Trait Implementations§
Source§impl<T: Clone + CiphertextOps, U: Clone + Sign> Clone for DynamicGenericInt<T, U>
impl<T: Clone + CiphertextOps, U: Clone + Sign> Clone for DynamicGenericInt<T, U>
Source§fn clone(&self) -> DynamicGenericInt<T, U>
fn clone(&self) -> DynamicGenericInt<T, U>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de, T, U: Sign> Deserialize<'de> for DynamicGenericInt<T, U>where
T: Deserialize<'de> + CiphertextOps,
impl<'de, T, U: Sign> Deserialize<'de> for DynamicGenericInt<T, U>where
T: Deserialize<'de> + CiphertextOps,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<const N: usize, T: CiphertextOps, U: Sign> From<DynamicGenericInt<T, U>> for GenericInt<N, T, U>
impl<const N: usize, T: CiphertextOps, U: Sign> From<DynamicGenericInt<T, U>> for GenericInt<N, T, U>
Source§fn from(value: DynamicGenericInt<T, U>) -> Self
fn from(value: DynamicGenericInt<T, U>) -> Self
Source§impl<const N: usize, T: CiphertextOps, U: Sign> From<GenericInt<N, T, U>> for DynamicGenericInt<T, U>
impl<const N: usize, T: CiphertextOps, U: Sign> From<GenericInt<N, T, U>> for DynamicGenericInt<T, U>
Source§fn from(value: GenericInt<N, T, U>) -> DynamicGenericInt<T, U>
fn from(value: GenericInt<N, T, U>) -> DynamicGenericInt<T, U>
Source§impl<T, U: Sign> Serialize for DynamicGenericInt<T, U>where
T: Serialize + CiphertextOps,
impl<T, U: Sign> Serialize for DynamicGenericInt<T, U>where
T: Serialize + CiphertextOps,
Auto Trait Implementations§
impl<T, U> Freeze for DynamicGenericInt<T, U>
impl<T, U> !RefUnwindSafe for DynamicGenericInt<T, U>
impl<T, U> Send for DynamicGenericInt<T, U>
impl<T, U> Sync for DynamicGenericInt<T, U>
impl<T, U> Unpin for DynamicGenericInt<T, U>where
U: Unpin,
impl<T, U> UnsafeUnpin for DynamicGenericInt<T, U>
impl<T, U> !UnwindSafe for DynamicGenericInt<T, U>
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<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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.