Struct concrete_core::backends::core::entities::LweCiphertextVector32
source · [−]pub struct LweCiphertextVector32(_);
Expand description
A structure representing a vector of LWE ciphertexts with 32 bits of precision.
Trait Implementations
type Kind = LweCiphertextVectorKind
type Kind = LweCiphertextVectorKind
The kind of the entity.
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
fn destroy(
&mut self,
entity: LweCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
fn destroy(
&mut self,
entity: LweCiphertextVector32
) -> Result<(), DestructionError<Self::EngineError>>
Destroys an entity.
Unsafely destroys an entity. Read more
Description:
Implementation of LweCiphertextVectorDecryptionEngine
for CoreEngine
that operates on
32 bits integers.
fn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> Result<PlaintextVector32, LweCiphertextVectorDecryptionError<Self::EngineError>>
fn decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> Result<PlaintextVector32, LweCiphertextVectorDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension, PlaintextCount};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 18];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let decrypted_plaintext_vector =
engine.decrypt_lwe_ciphertext_vector(&key, &ciphertext_vector)?;
assert_eq!(
decrypted_plaintext_vector.plaintext_count(),
PlaintextCount(18)
);
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(decrypted_plaintext_vector)?;
unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> PlaintextVector32
unsafe fn decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &LweCiphertextVector32
) -> PlaintextVector32
Unsafely decrypts an LWE ciphertext vector. Read more
Description:
Implementation of LweCiphertextVectorDiscardingAffineTransformationEngine
for CoreEngine
that operates on 32 bits integers.
fn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<Self::EngineError>>
fn discard_affine_transform_lwe_ciphertext_vector(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
) -> Result<(), LweCiphertextVectorDiscardingAffineTransformationError<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 20 bits)
let input_vector = vec![3_u32 << 20; 8];
let weights_input = vec![2_u32; 8];
let bias_input = 8_u32 << 20;
let noise = Variance::from_variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let weights: CleartextVector32 = engine.create_cleartext_vector(&input_vector)?;
let bias: Plaintext32 = engine.create_plaintext(&bias_input)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input_vector)?;
let ciphertext_vector = engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
let mut output_ciphertext = engine.zero_encrypt_lwe_ciphertext(&key, noise)?;
engine.discard_affine_transform_lwe_ciphertext_vector(
&mut output_ciphertext,
&ciphertext_vector,
&weights,
&bias,
)?;
assert_eq!(output_ciphertext.lwe_dimension(), lwe_dimension);
engine.destroy(key)?;
engine.destroy(weights)?;
engine.destroy(bias)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
engine.destroy(output_ciphertext)?;
unsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
)
unsafe fn discard_affine_transform_lwe_ciphertext_vector_unchecked(
&mut self,
output: &mut LweCiphertext32,
inputs: &LweCiphertextVector32,
weights: &CleartextVector32,
bias: &Plaintext32
)
Unsafely performs the affine transform of an LWE ciphertext vector. Read more
Description:
Implementation of LweCiphertextVectorDiscardingDecryptionEngine
for CoreEngine
that
operates on 32 bits integers.
fn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
fn discard_decrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
) -> Result<(), LweCiphertextVectorDiscardingDecryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension, PlaintextCount};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 18];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let mut plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
engine.discard_decrypt_lwe_ciphertext_vector(
&key,
&mut plaintext_vector,
&ciphertext_vector,
)?;
assert_eq!(plaintext_vector.plaintext_count(), PlaintextCount(18));
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
)
unsafe fn discard_decrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut PlaintextVector32,
input: &LweCiphertextVector32
)
Unsafely decrypts an LWE ciphertext vector. Read more
Description:
Implementation of LweCiphertextVectorDiscardingEncryptionEngine
for CoreEngine
that
operates on 32 bits integers.
fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
fn discard_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
) -> Result<(), LweCiphertextVectorDiscardingEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, LweCiphertextCount(3))?;
engine.discard_encrypt_lwe_ciphertext_vector(
&key,
&mut ciphertext_vector,
&plaintext_vector,
noise,
)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
)
unsafe fn discard_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
output: &mut LweCiphertextVector32,
input: &PlaintextVector32,
noise: Variance
)
Unsafely encryprs an LWE ciphertext vector. Read more
Description:
Implementation of LweCiphertextVectorEncryptionEngine
for CoreEngine
that operates on
32 bits integers.
fn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<LweCiphertextVector32, LweCiphertextVectorEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> Result<LweCiphertextVector32, LweCiphertextVectorEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(6);
// Here a hard-set encoding is applied (shift by 20 bits)
let input = vec![3_u32 << 20; 3];
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let mut ciphertext_vector: LweCiphertextVector32 =
engine.encrypt_lwe_ciphertext_vector(&key, &plaintext_vector, noise)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(
engine.destroy(key)?;
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
unsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> LweCiphertextVector32
unsafe fn encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
input: &PlaintextVector32,
noise: Variance
) -> LweCiphertextVector32
Unsafely encrypts an LWE ciphertext vector. Read more
The distribution of key the ciphertext was encrypted with.
Returns the LWE dimension of the ciphertexts.
Returns the number of ciphertexts contained in the vector.
fn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> Result<LweCiphertextVector32, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
fn trivially_encrypt_lwe_ciphertext_vector(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> Result<LweCiphertextVector32, LweCiphertextVectorTrivialEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweSize;
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_size = LweSize(10);
let input = vec![3_u32 << 20; 3];
let mut engine = CoreEngine::new()?;
let plaintext_vector: PlaintextVector32 = engine.create_plaintext_vector(&input)?;
let ciphertext_vector: LweCiphertextVector32 =
engine.trivially_encrypt_lwe_ciphertext_vector(lwe_size, &plaintext_vector)?;
assert_eq!(ciphertext_vector.lwe_dimension().to_lwe_size(), lwe_size);
assert_eq!(
ciphertext_vector.lwe_ciphertext_count().0,
plaintext_vector.plaintext_count().0
);
engine.destroy(plaintext_vector)?;
engine.destroy(ciphertext_vector)?;
unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> LweCiphertextVector32
unsafe fn trivially_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
lwe_size: LweSize,
input: &PlaintextVector32
) -> LweCiphertextVector32
Unsafely creates the trivial LWE encryption of the plaintext vector. Read more
Description:
Implementation of LweCiphertextVectorZeroEncryptionEngine
for CoreEngine
that
operates on 32 bits integers.
fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
fn zero_encrypt_lwe_ciphertext_vector(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> Result<LweCiphertextVector32, LweCiphertextVectorZeroEncryptionError<Self::EngineError>>
Example:
use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::{LweCiphertextCount, LweDimension};
use concrete_core::prelude::*;
// DISCLAIMER: the parameters used here are only for test purpose, and are not secure.
let lwe_dimension = LweDimension(2);
let ciphertext_count = LweCiphertextCount(3);
let noise = Variance(2_f64.powf(-25.));
let mut engine = CoreEngine::new()?;
let key: LweSecretKey32 = engine.create_lwe_secret_key(lwe_dimension)?;
let ciphertext_vector =
engine.zero_encrypt_lwe_ciphertext_vector(&key, noise, ciphertext_count)?;
assert_eq!(ciphertext_vector.lwe_dimension(), lwe_dimension);
assert_eq!(ciphertext_vector.lwe_ciphertext_count(), ciphertext_count);
engine.destroy(key)?;
engine.destroy(ciphertext_vector)?;
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector32
unsafe fn zero_encrypt_lwe_ciphertext_vector_unchecked(
&mut self,
key: &LweSecretKey32,
noise: Variance,
count: LweCiphertextCount
) -> LweCiphertextVector32
Unsafely encrypts zeros in an LWE ciphertext vector. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for LweCiphertextVector32
impl Send for LweCiphertextVector32
impl Sync for LweCiphertextVector32
impl Unpin for LweCiphertextVector32
impl UnwindSafe for LweCiphertextVector32
Blanket Implementations
Mutably borrows from an owned value. Read more