Struct tfhe::CompactFheIntList

source ·
pub struct CompactFheIntList<Id: FheIntId> { /* private fields */ }
Available on crate feature integer only.
Expand description

Compact list of FheInt

Meant to save in storage space / transfer.

  • A Compact type must be expanded using expand before it can be used.
  • It is not possible to ‘compact’ an existing FheInt. Compacting can only be achieved at encryption time by a CompactPublicKey

§Example

use tfhe::prelude::*;
use tfhe::{generate_keys, CompactFheInt32List, CompactPublicKey, ConfigBuilder, FheInt32};

let (client_key, _) = generate_keys(ConfigBuilder::default());
let compact_public_key = CompactPublicKey::try_new(&client_key).unwrap();

let clears = vec![i32::MAX, i32::MIN, 0, 1];
let compact = CompactFheInt32List::encrypt(&clears, &compact_public_key);
assert_eq!(compact.len(), clears.len());

let ciphertexts = compact.expand();
let decrypted: Vec<i32> = ciphertexts
    .into_iter()
    .map(|ciphertext| ciphertext.decrypt(&client_key))
    .collect();
assert_eq!(decrypted, clears);

Implementations§

source§

impl<Id> CompactFheIntList<Id>
where Id: FheIntId,

source

pub fn len(&self) -> usize

Returns the number of element in the compact list

source

pub fn is_empty(&self) -> bool

source

pub fn into_raw_parts(self) -> (CompactCiphertextList, Id)

source

pub fn from_raw_parts(list: CompactCiphertextList, id: Id) -> Self

source

pub fn expand(&self) -> Vec<FheInt<Id>>

Expand to a Vec<FheInt>

See CompactFheIntList example.

Trait Implementations§

source§

impl<Id: Clone + FheIntId> Clone for CompactFheIntList<Id>

source§

fn clone(&self) -> CompactFheIntList<Id>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'de, Id> Deserialize<'de> for CompactFheIntList<Id>
where Id: Deserialize<'de> + FheIntId,

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<'a, Id, T> FheTryEncrypt<&'a [T], CompactPublicKey> for CompactFheIntList<Id>
where T: DecomposableInto<u64>, Id: FheIntId,

§

type Error = Error

source§

fn try_encrypt( values: &'a [T], key: &CompactPublicKey ) -> Result<Self, Self::Error>

source§

impl<Id: FheIntId> Named for CompactFheIntList<Id>

source§

const NAME: &'static str = "high_level_api::CompactFheIntList"

source§

impl<Id: FheIntId> ParameterSetConformant for CompactFheIntList<Id>

§

type ParameterSet = CompactFheIntListConformanceParams<Id>

source§

fn is_conformant(&self, params: &CompactFheIntListConformanceParams<Id>) -> bool

source§

impl<Id> Serialize for CompactFheIntList<Id>
where Id: Serialize + FheIntId,

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<Id> Freeze for CompactFheIntList<Id>
where Id: Freeze,

§

impl<Id> RefUnwindSafe for CompactFheIntList<Id>
where Id: RefUnwindSafe,

§

impl<Id> Send for CompactFheIntList<Id>
where Id: Send,

§

impl<Id> Sync for CompactFheIntList<Id>
where Id: Sync,

§

impl<Id> Unpin for CompactFheIntList<Id>
where Id: Unpin,

§

impl<Id> UnwindSafe for CompactFheIntList<Id>
where Id: UnwindSafe,

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<Input, Output> CastInto<Output> for Input
where Output: CastFrom<Input>,

source§

fn cast_into(self) -> Output

source§

impl<Clear, Key, T> FheEncrypt<Clear, Key> for T
where T: FheTryEncrypt<Clear, Key>,

source§

fn encrypt(value: Clear, key: &Key) -> T

Available on crate feature integer only.
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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

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

§

type Output = T

Should always be Self
source§

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

§

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

§

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

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,