tfhe::integer::gpu::ciphertext

Struct CudaUnsignedRadixCiphertext

Source
pub struct CudaUnsignedRadixCiphertext {
    pub ciphertext: CudaRadixCiphertext,
}
Available on crate features integer and gpu only.

Fields§

§ciphertext: CudaRadixCiphertext

Implementations§

Source§

impl CudaUnsignedRadixCiphertext

Source

pub fn new( d_blocks: CudaLweCiphertextList<u64>, info: CudaRadixCiphertextInfo, ) -> Self

Source

pub fn from_radix_ciphertext( radix: &RadixCiphertext, streams: &CudaStreams, ) -> Self

Copies a RadixCiphertext to the GPU memory

§Example
use tfhe::core_crypto::gpu::vec::GpuIndex;
use tfhe::core_crypto::gpu::CudaStreams;
use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
use tfhe::integer::gpu::gen_keys_radix_gpu;
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
let size = 4;

let gpu_index = 0;
let mut streams = CudaStreams::new_single_gpu(GpuIndex(gpu_index));

// Generate the client key and the server key:
let (cks, sks) = gen_keys_radix_gpu(
    PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
    size,
    &mut streams,
);

let clear: u64 = 255;

// Encrypt two messages
let ctxt = cks.encrypt(clear);

let mut d_ctxt = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt, &mut streams);
let mut h_ctxt = d_ctxt.to_radix_ciphertext(&mut streams);

assert_eq!(h_ctxt, ctxt);
Source

pub fn copy_from_radix_ciphertext( &mut self, radix: &RadixCiphertext, streams: &CudaStreams, )

Source

pub fn to_radix_ciphertext(&self, streams: &CudaStreams) -> RadixCiphertext

use tfhe::core_crypto::gpu::vec::GpuIndex;
use tfhe::core_crypto::gpu::CudaStreams;
use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
use tfhe::integer::gpu::gen_keys_radix_gpu;
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;

let gpu_index = 0;
let mut streams = CudaStreams::new_single_gpu(GpuIndex(gpu_index));

// Generate the client key and the server key:
let num_blocks = 4;
let (cks, sks) = gen_keys_radix_gpu(
    PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
    num_blocks,
    &mut streams,
);

let msg1 = 10u32;
let ct1 = cks.encrypt(msg1);

// Copy to GPU
let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &mut streams);
let ct2 = d_ct1.to_radix_ciphertext(&mut streams);
let msg2 = cks.decrypt(&ct2);

assert_eq!(msg1, msg2);

Trait Implementations§

Source§

impl AsMut<CudaUnsignedRadixCiphertext> for CudaBooleanBlock

Source§

fn as_mut(&mut self) -> &mut CudaUnsignedRadixCiphertext

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<CudaUnsignedRadixCiphertext> for CudaBooleanBlock

Source§

fn as_ref(&self) -> &CudaUnsignedRadixCiphertext

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl CudaCompressible for CudaUnsignedRadixCiphertext

Source§

fn compress_into( self, messages: &mut Vec<CudaRadixCiphertext>, streams: &CudaStreams, ) -> DataKind

Source§

impl CudaIntegerRadixCiphertext for CudaUnsignedRadixCiphertext

Source§

const IS_SIGNED: bool = false

Source§

fn as_ref(&self) -> &CudaRadixCiphertext

Source§

fn as_mut(&mut self) -> &mut CudaRadixCiphertext

Source§

fn from(ct: CudaRadixCiphertext) -> Self

Source§

fn into_inner(self) -> CudaRadixCiphertext

Source§

fn duplicate(&self, streams: &CudaStreams) -> Self

Source§

unsafe fn duplicate_async(&self, streams: &CudaStreams) -> Self

Safety Read more
Source§

fn block_carries_are_empty(&self) -> bool

Source§

fn holds_boolean_value(&self) -> bool

Source§

fn is_equal(&self, other: &Self, streams: &CudaStreams) -> bool

Auto Trait Implementations§

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<T> CudaExpandable for T

Source§

fn from_expanded_blocks( blocks: CudaRadixCiphertext, kind: DataKind, ) -> Result<T, Error>

Available on crate features integer and gpu 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> 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> Iota32 for T

Source§

impl<T> Iota64 for T

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