pub struct LweCiphertextVectorView64<'a>(/* private fields */);Expand description
A structure representing a vector of LWE ciphertext views, with 64 bits of precision.
By view here, we mean that the entity does not own the data, but immutably borrows it.
§Notes:
This view is not Clone as Clone for a slice is not defined. It is not Deserialize either, as Deserialize of a slice is not defined. Immutable variant.
Trait Implementations§
Source§impl AbstractEntity for LweCiphertextVectorView64<'_>
 
impl AbstractEntity for LweCiphertextVectorView64<'_>
Source§type Kind = LweCiphertextVectorKind
 
type Kind = LweCiphertextVectorKind
Source§impl<'a> Debug for LweCiphertextVectorView64<'a>
 
impl<'a> Debug for LweCiphertextVectorView64<'a>
Source§impl<'b> EntitySerializationEngine<LweCiphertextVectorView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext vector view entity. Immutable variant.
 
impl<'b> EntitySerializationEngine<LweCiphertextVectorView64<'b>, Vec<u8>> for DefaultSerializationEngine
§Description:
Implementation of EntitySerializationEngine for DefaultSerializationEngine that operates
on 64 bits integers. It serializes a LWE ciphertext vector view entity. Immutable variant.
Source§fn serialize(
    &mut self,
    entity: &LweCiphertextVectorView64<'b>,
) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
 
fn serialize( &mut self, entity: &LweCiphertextVectorView64<'b>, ) -> Result<Vec<u8>, EntitySerializationError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweCiphertextCount, LweDimension, Variance, *};
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(3);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; lwe_count.0];
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector64 = engine.create_plaintext_vector_from(&input)?;
let mut ciphertext_vector: LweCiphertextVector64 =
    engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let raw_buffer = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector)?;
let view: LweCiphertextVectorView64 = engine
    .create_lwe_ciphertext_vector_from(raw_buffer.as_slice(), lwe_dimension.to_lwe_size())?;
let mut serialization_engine = DefaultSerializationEngine::new(())?;
let serialized = serialization_engine.serialize(&view)?;
let recovered: LweCiphertextVector64 =
    serialization_engine.deserialize(serialized.as_slice())?;
let recovered_buffer = engine.consume_retrieve_lwe_ciphertext_vector(recovered)?;
assert_eq!(raw_buffer, recovered_buffer);
Source§unsafe fn serialize_unchecked(
    &mut self,
    entity: &LweCiphertextVectorView64<'b>,
) -> Vec<u8> ⓘ
 
unsafe fn serialize_unchecked( &mut self, entity: &LweCiphertextVectorView64<'b>, ) -> Vec<u8> ⓘ
Source§impl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorView64<'data>, &'data [u64]> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that
returns the underlying slice of a LweCiphertextVectorView64 consuming it in the process
 
impl<'data> LweCiphertextVectorConsumingRetrievalEngine<LweCiphertextVectorView64<'data>, &'data [u64]> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorConsumingRetrievalEngine for DefaultEngine that
returns the underlying slice of a LweCiphertextVectorView64 consuming it in the process
Source§fn consume_retrieve_lwe_ciphertext_vector(
    &mut self,
    ciphertext: LweCiphertextVectorView64<'data>,
) -> Result<&'data [u64], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
 
fn consume_retrieve_lwe_ciphertext_vector( &mut self, ciphertext: LweCiphertextVectorView64<'data>, ) -> Result<&'data [u64], LweCiphertextVectorConsumingRetrievalError<Self::EngineError>>
§Example:
use concrete_core::prelude::{LweSize, *};
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_ciphertext_count = LweCiphertextCount(8);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_ciphertext_count.0];
let slice = &owned_container[..];
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: LweCiphertextVectorView64 =
    engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
assert_eq!(slice, retrieved_slice);Source§unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked(
    &mut self,
    ciphertext: LweCiphertextVectorView64<'data>,
) -> &'data [u64]
 
unsafe fn consume_retrieve_lwe_ciphertext_vector_unchecked( &mut self, ciphertext: LweCiphertextVectorView64<'data>, ) -> &'data [u64]
Source§impl<'data> LweCiphertextVectorCreationEngine<&'data [u64], LweCiphertextVectorView64<'data>> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns an
immutable LweCiphertextVectorView64 that does not own its memory.
 
impl<'data> LweCiphertextVectorCreationEngine<&'data [u64], LweCiphertextVectorView64<'data>> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorCreationEngine for DefaultEngine which returns an
immutable LweCiphertextVectorView64 that does not own its memory.
Source§fn create_lwe_ciphertext_vector_from(
    &mut self,
    container: &'data [u64],
    lwe_size: LweSize,
) -> Result<LweCiphertextVectorView64<'data>, LweCiphertextVectorCreationError<Self::EngineError>>
 
fn create_lwe_ciphertext_vector_from( &mut self, container: &'data [u64], lwe_size: LweSize, ) -> Result<LweCiphertextVectorView64<'data>, LweCiphertextVectorCreationError<Self::EngineError>>
§Example:
use concrete_core::prelude::*;
// Here we create a container outside of the engine
// Note that the size here is just for demonstration purposes and should not be chosen
// without proper security analysis for production
let lwe_size = LweSize(16);
let lwe_count = LweCiphertextCount(3);
let mut owned_container = vec![0_u64; lwe_size.0 * lwe_count.0];
let slice = &owned_container[..];
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let ciphertext_vector_view: LweCiphertextVectorView64 =
    engine.create_lwe_ciphertext_vector_from(slice, lwe_size)?;Source§unsafe fn create_lwe_ciphertext_vector_from_unchecked(
    &mut self,
    container: &'data [u64],
    lwe_size: LweSize,
) -> LweCiphertextVectorView64<'data>
 
unsafe fn create_lwe_ciphertext_vector_from_unchecked( &mut self, container: &'data [u64], lwe_size: LweSize, ) -> LweCiphertextVectorView64<'data>
Source§impl LweCiphertextVectorDecryptionEngine<LweSecretKey64, LweCiphertextVectorView64<'_>, PlaintextVector64> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDecryptionEngine for DefaultEngine that
operates on 64 bits integers.
 
impl LweCiphertextVectorDecryptionEngine<LweSecretKey64, LweCiphertextVectorView64<'_>, PlaintextVector64> for DefaultEngine
§Description:
Implementation of LweCiphertextVectorDecryptionEngine for DefaultEngine that
operates on 64 bits integers.
Source§fn decrypt_lwe_ciphertext_vector(
    &mut self,
    key: &LweSecretKey64,
    input: &LweCiphertextVectorView64<'_>,
) -> Result<PlaintextVector64, LweCiphertextVectorDecryptionError<Self::EngineError>>
 
fn decrypt_lwe_ciphertext_vector( &mut self, key: &LweSecretKey64, input: &LweCiphertextVectorView64<'_>, ) -> Result<PlaintextVector64, LweCiphertextVectorDecryptionError<Self::EngineError>>
§Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
let lwe_count = LweCiphertextCount(18);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = vec![3_u64 << 50; lwe_count.0];
let noise = Variance(2_f64.powf(-50.));
// Unix seeder must be given a secret input.
// Here we just give it 0, which is totally unsafe.
const UNSAFE_SECRET: u128 = 0;
let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let key: LweSecretKey64 = engine.generate_new_lwe_secret_key(lwe_dimension)?;
let plaintext_vector = engine.create_plaintext_vector_from(&input)?;
let mut raw_ciphertext_vector = vec![0_u64; key.lwe_dimension().to_lwe_size().0 * lwe_count.0];
let mut ciphertext_vector_view: LweCiphertextVectorMutView64 = engine
    .create_lwe_ciphertext_vector_from(
        &mut raw_ciphertext_vector[..],
        lwe_dimension.to_lwe_size(),
    )?;
engine.discard_encrypt_lwe_ciphertext_vector(
    &key,
    &mut ciphertext_vector_view,
    &plaintext_vector,
    noise,
)?;
// Convert MutView to View
let raw_ciphertext_vector =
    engine.consume_retrieve_lwe_ciphertext_vector(ciphertext_vector_view)?;
let ciphertext_vector_view: LweCiphertextVectorView64 = engine
    .create_lwe_ciphertext_vector_from(
        &raw_ciphertext_vector[..],
        lwe_dimension.to_lwe_size(),
    )?;
let decrypted_plaintext_vector =
    engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector_view)?;
assert_eq!(
    decrypted_plaintext_vector.plaintext_count(),
    PlaintextCount(lwe_count.0)
);
Source§unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
    &mut self,
    key: &LweSecretKey64,
    input: &LweCiphertextVectorView64<'_>,
) -> PlaintextVector64
 
unsafe fn decrypt_lwe_ciphertext_vector_unchecked( &mut self, key: &LweSecretKey64, input: &LweCiphertextVectorView64<'_>, ) -> PlaintextVector64
Source§impl LweCiphertextVectorDiscardingCircuitBootstrapBooleanVerticalPackingEngine<LweCiphertextVectorView64<'_>, LweCiphertextVectorMutView64<'_>, FftFourierLweBootstrapKey64, PlaintextVector64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for FftEngine
 
impl LweCiphertextVectorDiscardingCircuitBootstrapBooleanVerticalPackingEngine<LweCiphertextVectorView64<'_>, LweCiphertextVectorMutView64<'_>, FftFourierLweBootstrapKey64, PlaintextVector64, LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64> for FftEngine
Source§fn discard_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_vector(
    &mut self,
    output: &mut LweCiphertextVectorMutView64<'_>,
    input: &LweCiphertextVectorView64<'_>,
    bsk: &FftFourierLweBootstrapKey64,
    luts: &PlaintextVector64,
    cbs_level_count: DecompositionLevelCount,
    cbs_base_log: DecompositionBaseLog,
    cbs_pfpksk: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64,
) -> Result<(), LweCiphertextVectorDiscardingCircuitBootstrapBooleanVerticalPackingError<Self::EngineError>>
 
fn discard_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_vector( &mut self, output: &mut LweCiphertextVectorMutView64<'_>, input: &LweCiphertextVectorView64<'_>, bsk: &FftFourierLweBootstrapKey64, luts: &PlaintextVector64, cbs_level_count: DecompositionLevelCount, cbs_base_log: DecompositionBaseLog, cbs_pfpksk: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, ) -> Result<(), LweCiphertextVectorDiscardingCircuitBootstrapBooleanVerticalPackingError<Self::EngineError>>
§Example:
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let polynomial_size = PolynomialSize(1024);
let glwe_dimension = GlweDimension(1);
let lwe_dimension = LweDimension(481);
let var_small = Variance::from_variance(2f64.powf(-80.0));
let var_big = Variance::from_variance(2f64.powf(-70.0));
const UNSAFE_SECRET: u128 = 0;
let mut default_engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut default_parallel_engine =
    DefaultParallelEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;
let mut fft_engine = FftEngine::new(())?;
let glwe_sk: GlweSecretKey64 =
    default_engine.generate_new_glwe_secret_key(glwe_dimension, polynomial_size)?;
let lwe_small_sk: LweSecretKey64 = default_engine.generate_new_lwe_secret_key(lwe_dimension)?;
let lwe_big_sk: LweSecretKey64 =
    default_engine.transform_glwe_secret_key_to_lwe_secret_key(glwe_sk.clone())?;
let bsk_level_count = DecompositionLevelCount(9);
let bsk_base_log = DecompositionBaseLog(4);
let std_bsk: LweBootstrapKey64 = default_parallel_engine.generate_new_lwe_bootstrap_key(
    &lwe_small_sk,
    &glwe_sk,
    bsk_base_log,
    bsk_level_count,
    var_small,
)?;
let fourier_bsk: FftFourierLweBootstrapKey64 =
    fft_engine.convert_lwe_bootstrap_key(&std_bsk)?;
let ksk_level_count = DecompositionLevelCount(9);
let ksk_base_log = DecompositionBaseLog(1);
let ksk_big_to_small: LweKeyswitchKey64 = default_engine.generate_new_lwe_keyswitch_key(
    &lwe_big_sk,
    &lwe_small_sk,
    ksk_level_count,
    ksk_base_log,
    var_big,
)?;
let pfpksk_level_count = DecompositionLevelCount(9);
let pfpksk_base_log = DecompositionBaseLog(4);
let cbs_pfpksk: LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64 = default_engine
    .generate_new_lwe_circuit_bootstrap_private_functional_packing_keyswitch_keys(
        &lwe_big_sk,
        &glwe_sk,
        pfpksk_base_log,
        pfpksk_level_count,
        var_small,
    )?;
// We will have a message with 10 bits of information
let message_bits = 10;
let bits_to_extract = ExtractedBitsCount(message_bits);
// The value we encrypt is 42, we will extract the bits of this value and apply the
// circuit bootstrapping followed by the vertical packing on the extracted bits.
let cleartext = 42;
let delta_log_msg = DeltaLog(64 - message_bits);
let encoded_message = default_engine.create_plaintext_from(&(cleartext << delta_log_msg.0))?;
let lwe_in = default_engine.encrypt_lwe_ciphertext(&lwe_big_sk, &encoded_message, var_big)?;
// Bit extraction output, use the zero_encrypt engine to allocate a ciphertext vector
let mut bit_extraction_output = default_engine.zero_encrypt_lwe_ciphertext_vector(
    &lwe_small_sk,
    var_small,
    LweCiphertextCount(bits_to_extract.0),
)?;
fft_engine.discard_extract_bits_lwe_ciphertext(
    &mut bit_extraction_output,
    &lwe_in,
    &fourier_bsk,
    &ksk_big_to_small,
    bits_to_extract,
    delta_log_msg,
)?;
// Though the delta log here is the same as the message delta log, in the general case they
// are different, so we create two DeltaLog parameters
let delta_log_lut = DeltaLog(64 - message_bits);
// Create a look-up table we want to apply during vertical packing, here just the identity
// with the proper encoding.
// Note that this particular table will not trigger the cmux tree from the vertical packing,
// adapt the LUT generation to your usage.
// Here we apply a single look-up table as we output a single ciphertext.
let number_of_luts_and_output_vp_ciphertexts = 1;
let lut_size = 1 << bits_to_extract.0;
let mut lut: Vec<u64> = Vec::with_capacity(lut_size);
for i in 0..lut_size {
    lut.push((i as u64 % (1 << message_bits)) << delta_log_lut.0);
}
let lut_as_plaintext_vector = default_engine.create_plaintext_vector_from(lut.as_slice())?;
// We run on views, so we need a container for the output
let mut output_cbs_vp_ct_container = vec![
    0u64;
    lwe_big_sk.lwe_dimension().to_lwe_size().0
        * number_of_luts_and_output_vp_ciphertexts
];
let mut output_cbs_vp_ct_mut_view: LweCiphertextVectorMutView64 = default_engine
    .create_lwe_ciphertext_vector_from(
        output_cbs_vp_ct_container.as_mut_slice(),
        lwe_big_sk.lwe_dimension().to_lwe_size(),
    )?;
// And we need to get a view on the bits extracted earlier that serve as inputs to the
// circuit bootstrap + vertical packing
let extracted_bits_lwe_size = bit_extraction_output.lwe_dimension().to_lwe_size();
let extracted_bits_container =
    default_engine.consume_retrieve_lwe_ciphertext_vector(bit_extraction_output)?;
let cbs_vp_input_vector_view: LweCiphertextVectorView64 = default_engine
    .create_lwe_ciphertext_vector_from(
        extracted_bits_container.as_slice(),
        extracted_bits_lwe_size,
    )?;
let cbs_level_count = DecompositionLevelCount(4);
let cbs_base_log = DecompositionBaseLog(6);
fft_engine.discard_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_vector(
    &mut output_cbs_vp_ct_mut_view,
    &cbs_vp_input_vector_view,
    &fourier_bsk,
    &lut_as_plaintext_vector,
    cbs_level_count,
    cbs_base_log,
    &cbs_pfpksk,
)?;
assert_eq!(output_cbs_vp_ct_mut_view.lwe_ciphertext_count().0, 1);
assert_eq!(
    output_cbs_vp_ct_mut_view.lwe_dimension(),
    LweDimension(glwe_dimension.0 * polynomial_size.0)
);
Source§unsafe fn discard_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_vector_unchecked(
    &mut self,
    output: &mut LweCiphertextVectorMutView64<'_>,
    input: &LweCiphertextVectorView64<'_>,
    bsk: &FftFourierLweBootstrapKey64,
    luts: &PlaintextVector64,
    cbs_level_count: DecompositionLevelCount,
    cbs_base_log: DecompositionBaseLog,
    cbs_pfpksk: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64,
)
 
unsafe fn discard_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_vector_unchecked( &mut self, output: &mut LweCiphertextVectorMutView64<'_>, input: &LweCiphertextVectorView64<'_>, bsk: &FftFourierLweBootstrapKey64, luts: &PlaintextVector64, cbs_level_count: DecompositionLevelCount, cbs_base_log: DecompositionBaseLog, cbs_pfpksk: &LweCircuitBootstrapPrivateFunctionalPackingKeyswitchKeys64, )
Source§impl LweCiphertextVectorEntity for LweCiphertextVectorView64<'_>
 
impl LweCiphertextVectorEntity for LweCiphertextVectorView64<'_>
Source§fn lwe_dimension(&self) -> LweDimension
 
fn lwe_dimension(&self) -> LweDimension
Source§fn lwe_ciphertext_count(&self) -> LweCiphertextCount
 
fn lwe_ciphertext_count(&self) -> LweCiphertextCount
Source§impl<'a> PartialEq for LweCiphertextVectorView64<'a>
 
impl<'a> PartialEq for LweCiphertextVectorView64<'a>
Source§fn eq(&self, other: &LweCiphertextVectorView64<'a>) -> bool
 
fn eq(&self, other: &LweCiphertextVectorView64<'a>) -> bool
self and other values to be equal, and is used by ==.impl<'a> Eq for LweCiphertextVectorView64<'a>
impl<'a> StructuralPartialEq for LweCiphertextVectorView64<'a>
Auto Trait Implementations§
impl<'a> Freeze for LweCiphertextVectorView64<'a>
impl<'a> RefUnwindSafe for LweCiphertextVectorView64<'a>
impl<'a> Send for LweCiphertextVectorView64<'a>
impl<'a> Sync for LweCiphertextVectorView64<'a>
impl<'a> Unpin for LweCiphertextVectorView64<'a>
impl<'a> UnwindSafe for LweCiphertextVectorView64<'a>
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> 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