Skip to main content

DynamicGenericInt

Struct DynamicGenericInt 

Source
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,

Source

pub fn new(enc: &Encryption, n: usize) -> Self

Allocate a new DynamicGenericInt using trivial or precomputed (if T is L1GgswCiphertext) encryptions of zero.

Source

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.

Source

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.

Source

pub fn encrypt_secret( val: U::PlaintextType, enc: &Encryption, sk: &SecretKey, n: usize, ) -> Self

Encrypts the given integer.

§Panics

If the given value is out of bounds.

Source

pub fn decrypt(&self, enc: &Encryption, sk: &SecretKey) -> U::PlaintextType

Decrypts this encrypted integer and returns the contained integer message.

Source

pub fn graph_inputs<'a>( &self, ctx: &'a FheCircuitCtx, ) -> DynamicGenericIntGraphNodes<'a, T, U>

Add input nodes to the given FheCircuitCtx.

Source

pub fn with_decryption_fn<F>(&self, f: F) -> U::PlaintextType
where F: Fn(&T) -> bool,

Run a custom (e.g. threshold) decryption algorithm and return the result.

Source

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,

Source

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>

Source§

fn clone(&self) -> DynamicGenericInt<T, U>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

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

Converts to this type from the input type.
Source§

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>

Converts to this type from the input type.
Source§

impl<T, U: Sign> Serialize for DynamicGenericInt<T, U>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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>
where U: Send, T: Sync + Send,

§

impl<T, U> Sync for DynamicGenericInt<T, U>
where U: Sync, T: Sync + Send,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,