Struct concrete_core::backends::default::entities::LweCiphertextMutView64
source · [−]pub struct LweCiphertextMutView64<'a>(_);
Expand description
A structure representing an LWE ciphertext view, with 64 bits of precision.
By view here, we mean that the entity does not own the data, but mutably 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. Mutable variant.
Trait Implementations
sourceimpl AbstractEntity for LweCiphertextMutView64<'_>
impl AbstractEntity for LweCiphertextMutView64<'_>
type Kind = LweCiphertextKind
type Kind = LweCiphertextKind
The kind of the entity.
sourceimpl<'a> Debug for LweCiphertextMutView64<'a>
impl<'a> Debug for LweCiphertextMutView64<'a>
sourceimpl DestructionEngine<LweCiphertextMutView64<'_>> for DefaultEngine
impl DestructionEngine<LweCiphertextMutView64<'_>> for DefaultEngine
sourcefn destroy(
&mut self,
entity: LweCiphertextMutView64<'_>
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertextMutView64<'_>
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
sourceunsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextMutView64<'_>)
unsafe fn destroy_unchecked(&mut self, _entity: &mut LweCiphertextMutView64<'_>)
Unsafely destroys an entity. Read more
sourceimpl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertextView64<'_>, Cleartext64, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextCleartextDiscardingMultiplicationEngine<LweCiphertextView64<'_>, Cleartext64, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextCleartextDiscardingMultiplicationEngine
for DefaultEngine
that operates on views containing 64 bits integers.
sourcefn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Cleartext64
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
fn discard_mul_lwe_ciphertext_cleartext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Cleartext64
) -> Result<(), LweCiphertextCleartextDiscardingMultiplicationError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let cleartext_input = 12_u64;
let noise = Variance(2_f64.powf(-25.));
// 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 cleartext: Cleartext64 = engine.create_cleartext(&cleartext_input)?;
let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_mul_lwe_ciphertext_cleartext(&mut ciphertext_2, &ciphertext_1, &cleartext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(cleartext)?;
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Cleartext64
)
unsafe fn discard_mul_lwe_ciphertext_cleartext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Cleartext64
)
Unsafely multiply an LWE ciphertext with a cleartext. Read more
sourceimpl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextMutView64<'data>, &'data mut [u64]> for DefaultEngine
impl<'data> LweCiphertextConsumingRetrievalEngine<LweCiphertextMutView64<'data>, &'data mut [u64]> for DefaultEngine
Description:
Implementation of LweCiphertextConsumingRetrievalEngine
for DefaultEngine
that returns
the underlying slice of a LweCiphertextMutView64
consuming it in the process
sourcefn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextMutView64<'data>
) -> Result<&'data mut [u64], LweCiphertextConsumingRetrievalError<Self::EngineError>>
fn consume_retrieve_lwe_ciphertext(
&mut self,
ciphertext: LweCiphertextMutView64<'data>
) -> Result<&'data mut [u64], LweCiphertextConsumingRetrievalError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
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(128);
let mut owned_container = vec![0_u64; lwe_size.0];
let slice = &mut owned_container[..];
// Required as we can't borrow a mut slice more than once
let underlying_ptr = slice.as_ptr();
// 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_view: LweCiphertextMutView64 = engine.create_lwe_ciphertext(slice)?;
let retrieved_slice = engine.consume_retrieve_lwe_ciphertext(ciphertext_view)?;
assert_eq!(underlying_ptr, retrieved_slice.as_ptr());
sourceunsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextMutView64<'data>
) -> &'data mut [u64]
unsafe fn consume_retrieve_lwe_ciphertext_unchecked(
&mut self,
ciphertext: LweCiphertextMutView64<'data>
) -> &'data mut [u64]
Unsafely retrieves the content of the container from an LWE ciphertext, consuming it in the process. Read more
sourceimpl<'data> LweCiphertextCreationEngine<&'data mut [u64], LweCiphertextMutView64<'data>> for DefaultEngine
impl<'data> LweCiphertextCreationEngine<&'data mut [u64], LweCiphertextMutView64<'data>> for DefaultEngine
Description:
Implementation of LweCiphertextCreationEngine
for DefaultEngine
which returns a mutable
LweCiphertextMutView64
that does not own its memory.
sourcefn create_lwe_ciphertext(
&mut self,
container: &'data mut [u64]
) -> Result<LweCiphertextMutView64<'data>, LweCiphertextCreationError<Self::EngineError>>
fn create_lwe_ciphertext(
&mut self,
container: &'data mut [u64]
) -> Result<LweCiphertextMutView64<'data>, LweCiphertextCreationError<Self::EngineError>>
Example:
use concrete_commons::parameters::LweSize;
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(128);
let mut owned_container = vec![0_u64; lwe_size.0];
let slice = &mut 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_view: LweCiphertextMutView64 = engine.create_lwe_ciphertext(slice)?;
engine.destroy(ciphertext_view)?;
sourceunsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: &'data mut [u64]
) -> LweCiphertextMutView64<'data>
unsafe fn create_lwe_ciphertext_unchecked(
&mut self,
container: &'data mut [u64]
) -> LweCiphertextMutView64<'data>
Unsafely creates an LWE ciphertext from an arbitrary container. Read more
sourceimpl LweCiphertextDiscardingAdditionEngine<LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextDiscardingAdditionEngine<LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingAdditionEngine
for DefaultEngine
that operates
on on views containing 64 bits integers.
sourcefn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &LweCiphertextView64<'_>
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &LweCiphertextView64<'_>
) -> Result<(), LweCiphertextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input_1 = 3_u64 << 50;
let input_2 = 7_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext_1 = engine.create_plaintext(&input_1)?;
let plaintext_2 = engine.create_plaintext(&input_2)?;
let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext_1, noise)?;
let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_2, &plaintext_2, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let raw_ciphertext_2 = engine.consume_retrieve_lwe_ciphertext(ciphertext_2)?;
let ciphertext_2: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_2[..])?;
let mut ciphertext_3_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_3: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_3_container[..])?;
engine.discard_add_lwe_ciphertext(&mut ciphertext_3, &ciphertext_1, &ciphertext_2)?;
assert_eq!(ciphertext_3.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext_1)?;
engine.destroy(plaintext_2)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
engine.destroy(ciphertext_3)?;
sourceunsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &LweCiphertextView64<'_>
)
unsafe fn discard_add_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &LweCiphertextView64<'_>
)
Unsafely adds two LWE ciphertexts. Read more
sourceimpl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextDiscardingEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingEncryptionEngine
for DefaultEngine
that
operates on 64 bits integers.
sourcefn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
) -> Result<(), LweCiphertextDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut output_cipertext_container = vec![0_64; lwe_dimension.to_lwe_size().0];
let mut output_ciphertext: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut output_cipertext_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut output_ciphertext, &plaintext, noise)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(output_ciphertext)?;
sourceunsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &LweSecretKey64,
output: &mut LweCiphertextMutView64<'_>,
input: &Plaintext64,
noise: Variance
)
Unsafely encrypts an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey64, LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextDiscardingKeyswitchEngine<LweKeyswitchKey64, LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingKeyswitchEngine
for DefaultEngine
that operates
on views containing 64 bits integers.
sourcefn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>,
ksk: &LweKeyswitchKey64
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
fn discard_keyswitch_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>,
ksk: &LweKeyswitchKey64
) -> Result<(), LweCiphertextDiscardingKeyswitchError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{
DecompositionBaseLog, DecompositionLevelCount, LweDimension,
};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let input_lwe_dimension = LweDimension(6);
let output_lwe_dimension = LweDimension(3);
let decomposition_level_count = DecompositionLevelCount(2);
let decomposition_base_log = DecompositionBaseLog(8);
let noise = Variance(2_f64.powf(-25.));
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 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 input_key: LweSecretKey64 = engine.create_lwe_secret_key(input_lwe_dimension)?;
let output_key: LweSecretKey64 = engine.create_lwe_secret_key(output_lwe_dimension)?;
let keyswitch_key = engine.create_lwe_keyswitch_key(
&input_key,
&output_key,
decomposition_level_count,
decomposition_base_log,
noise,
)?;
let plaintext = engine.create_plaintext(&input)?;
let mut raw_ciphertext_1_container = vec![0_u64; input_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut raw_ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&input_key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut raw_ciphertext_2_container = vec![0_u64; output_key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut raw_ciphertext_2_container[..])?;
engine.discard_keyswitch_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1, &keyswitch_key)?;
assert_eq!(ciphertext_2.lwe_dimension(), output_lwe_dimension);
engine.destroy(input_key)?;
engine.destroy(output_key)?;
engine.destroy(keyswitch_key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>,
ksk: &LweKeyswitchKey64
)
unsafe fn discard_keyswitch_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>,
ksk: &LweKeyswitchKey64
)
Unsafely keyswitch an LWE ciphertext. Read more
sourceimpl LweCiphertextDiscardingOppositeEngine<LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextDiscardingOppositeEngine<LweCiphertextView64<'_>, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextDiscardingOppositeEngine
for DefaultEngine
that operates
on views containing 64 bits integers.
sourcefn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
fn discard_opp_lwe_ciphertext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>
) -> Result<(), LweCiphertextDiscardingOppositeError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_opp_lwe_ciphertext(&mut ciphertext_2, &ciphertext_1)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>
)
unsafe fn discard_opp_lwe_ciphertext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input: &LweCiphertextView64<'_>
)
Unsafely computes the opposite of an LWE ciphertext. Read more
sourceimpl LweCiphertextEntity for LweCiphertextMutView64<'_>
impl LweCiphertextEntity for LweCiphertextMutView64<'_>
type KeyDistribution = BinaryKeyDistribution
type KeyDistribution = BinaryKeyDistribution
The distribution of the key the ciphertext was encrypted with.
sourcefn lwe_dimension(&self) -> LweDimension
fn lwe_dimension(&self) -> LweDimension
Returns the LWE dimension of the ciphertext.
sourceimpl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertextView64<'_>, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine
impl LweCiphertextPlaintextDiscardingAdditionEngine<LweCiphertextView64<'_>, Plaintext64, LweCiphertextMutView64<'_>> for DefaultEngine
Description:
Implementation of LweCiphertextPlaintextDiscardingAdditionEngine
for DefaultEngine
that
operates on views containing 64 bits integers.
sourcefn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Plaintext64
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
fn discard_add_lwe_ciphertext_plaintext(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Plaintext64
) -> Result<(), LweCiphertextPlaintextDiscardingAdditionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
// Here a hard-set encoding is applied (shift by 50 bits)
let input = 3_u64 << 50;
let noise = Variance(2_f64.powf(-25.));
// 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.create_lwe_secret_key(lwe_dimension)?;
let plaintext = engine.create_plaintext(&input)?;
let mut ciphertext_1_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_1: LweCiphertextMutView64 =
engine.create_lwe_ciphertext(&mut ciphertext_1_container[..])?;
engine.discard_encrypt_lwe_ciphertext(&key, &mut ciphertext_1, &plaintext, noise)?;
// Convert MutView to View
let raw_ciphertext_1 = engine.consume_retrieve_lwe_ciphertext(ciphertext_1)?;
let ciphertext_1: LweCiphertextView64 = engine.create_lwe_ciphertext(&raw_ciphertext_1[..])?;
let mut ciphertext_2_container = vec![0_u64; key.lwe_dimension().to_lwe_size().0];
let mut ciphertext_2 = engine.create_lwe_ciphertext(&mut ciphertext_2_container[..])?;
engine.discard_add_lwe_ciphertext_plaintext(&mut ciphertext_2, &ciphertext_1, &plaintext)?;
assert_eq!(ciphertext_2.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(plaintext)?;
engine.destroy(ciphertext_1)?;
engine.destroy(ciphertext_2)?;
sourceunsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Plaintext64
)
unsafe fn discard_add_lwe_ciphertext_plaintext_unchecked(
&mut self,
output: &mut LweCiphertextMutView64<'_>,
input_1: &LweCiphertextView64<'_>,
input_2: &Plaintext64
)
Unsafely adds a plaintext to an LWE ciphertext. Read more
sourceimpl<'a> PartialEq<LweCiphertextMutView64<'a>> for LweCiphertextMutView64<'a>
impl<'a> PartialEq<LweCiphertextMutView64<'a>> for LweCiphertextMutView64<'a>
sourcefn eq(&self, other: &LweCiphertextMutView64<'a>) -> bool
fn eq(&self, other: &LweCiphertextMutView64<'a>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &LweCiphertextMutView64<'a>) -> bool
fn ne(&self, other: &LweCiphertextMutView64<'a>) -> bool
This method tests for !=
.
impl<'a> Eq for LweCiphertextMutView64<'a>
impl<'a> StructuralEq for LweCiphertextMutView64<'a>
impl<'a> StructuralPartialEq for LweCiphertextMutView64<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for LweCiphertextMutView64<'a>
impl<'a> Send for LweCiphertextMutView64<'a>
impl<'a> Sync for LweCiphertextMutView64<'a>
impl<'a> Unpin for LweCiphertextMutView64<'a>
impl<'a> !UnwindSafe for LweCiphertextMutView64<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more