Compare commits

...

14 Commits

Author SHA1 Message Date
Tore Frederiksen
c62f2c6bea added visibility 2023-07-02 18:07:54 +02:00
Tore Frederiksen
18c22f2ee7 added visibility 2023-07-02 18:07:46 +02:00
Tore Frederiksen
bd8ab6a888 made method public 2023-06-30 13:52:02 +02:00
Tore Frederiksen
2fe7a17224 more access 2023-06-28 15:54:23 +02:00
Tore Frederiksen
9f5a5bb0b3 more access 2023-06-28 15:51:12 +02:00
Tore Frederiksen
c7d7ba0f7a More access 2023-06-28 14:04:49 +02:00
Tore Frederiksen
09c0206950 Added more key access 2023-06-28 13:26:03 +02:00
Tore Frederiksen
30a7554dc4 Fixed accidential change 2023-06-28 10:45:05 +02:00
Tore Frederiksen
7f96bae099 Access to lwe key 2023-06-28 10:14:20 +02:00
Tore Frederiksen
ee4c0ac041 access to small lwe key 2023-06-28 10:13:54 +02:00
Tore Frederiksen
c891148984 access to ciphertext 2023-06-26 13:36:10 +02:00
Tore Frederiksen
792b5dac42 refactor: trying to get key vector access working 2023-06-21 17:01:49 +02:00
Tore Frederiksen
376de492da refactor: trying to get key vector access working 2023-06-21 16:49:12 +02:00
Tore Frederiksen
f4ffa4d3f1 feat: initial access to private key material 2023-06-21 10:15:58 +02:00
9 changed files with 21 additions and 10 deletions

View File

@@ -20,7 +20,7 @@ use std::fmt::{Debug, Formatter};
/// * `parameters` - the cryptographic parameter set.
#[derive(Clone, Serialize, Deserialize)]
pub struct ClientKey {
pub(crate) lwe_secret_key: LweSecretKeyOwned<u32>,
pub lwe_secret_key: LweSecretKeyOwned<u32>,
pub(crate) glwe_secret_key: GlweSecretKeyOwned<u32>,
pub(crate) parameters: BooleanParameters,
}

View File

@@ -18,9 +18,9 @@ use rayon::prelude::*;
/// A random number generator which can be used to encrypt messages.
pub struct EncryptionRandomGenerator<G: ByteRandomGenerator> {
// A separate mask generator, only used to generate the mask elements.
mask: RandomGenerator<G>,
pub mask: RandomGenerator<G>,
// A separate noise generator, only used to generate the noise elements.
noise: RandomGenerator<G>,
pub noise: RandomGenerator<G>,
}
impl<G: ByteRandomGenerator> EncryptionRandomGenerator<G> {

View File

@@ -19,7 +19,7 @@ impl<G: ByteRandomGenerator> SecretRandomGenerator<G> {
self.0.remaining_bytes()
}
pub(crate) fn fill_slice_with_random_uniform_binary<Scalar>(&mut self, slice: &mut [Scalar])
pub fn fill_slice_with_random_uniform_binary<Scalar>(&mut self, slice: &mut [Scalar])
where
Scalar: RandomGenerable<UniformBinary>,
{

View File

@@ -636,6 +636,10 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> LweCiphertext<C> {
pub fn ciphertext_modulus(&self) -> CiphertextModulus<C::Element> {
self.ciphertext_modulus
}
pub fn data(&self) -> &C {
&self.data
}
}
impl<Scalar: UnsignedInteger, C: ContainerMut<Element = Scalar>> LweCiphertext<C> {

View File

@@ -7,6 +7,7 @@ mod crt;
mod radix;
pub(crate) mod utils;
use crate::core_crypto::prelude::LweSecretKeyOwned;
use crate::integer::block_decomposition::BlockRecomposer;
use crate::integer::ciphertext::{CompressedCrtCiphertext, CrtCiphertext};
use crate::integer::client_key::utils::i_crt;
@@ -33,7 +34,7 @@ use super::ciphertext::{CompressedRadixCiphertext, RadixCiphertext};
/// use the same crypto parameters.
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub struct ClientKey {
pub(crate) key: ShortintClientKey,
pub key: ShortintClientKey,
}
impl From<ShortintClientKey> for ClientKey {
@@ -463,4 +464,9 @@ impl ClientKey {
{
encrypt_crt(&self.key, message, base_vec, encrypt_block)
}
pub fn get_small_secret_vec(&self) -> Vec<u64> {
let container = LweSecretKeyOwned::into_container(self.key.small_lwe_secret_key.clone());
container
}
}

View File

@@ -11,7 +11,7 @@ use crate::shortint::{
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CompactPublicKey {
pub(crate) key: ShortintCompactPublicKey,
pub key: ShortintCompactPublicKey,
}
impl CompactPublicKey {

View File

@@ -4,6 +4,7 @@ use crate::core_crypto::entities::*;
use crate::shortint::ciphertext::{Ciphertext, CompressedCiphertext};
use crate::shortint::engine::ShortintEngine;
use crate::shortint::parameters::{MessageModulus, ShortintParameterSet};
use pulp::Scalar;
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
@@ -21,7 +22,7 @@ pub struct ClientKey {
pub(crate) large_lwe_secret_key: LweSecretKeyOwned<u64>,
pub(crate) glwe_secret_key: GlweSecretKeyOwned<u64>,
/// Key used as the output of the keyswitch operation
pub(crate) small_lwe_secret_key: LweSecretKeyOwned<u64>,
pub small_lwe_secret_key: LweSecretKeyOwned<u64>,
pub parameters: ShortintParameterSet,
}
@@ -511,7 +512,7 @@ impl ClientKey {
/// assert_eq!(msg, dec % modulus as u64);
/// ```
pub fn decrypt_message_native_crt(&self, ct: &Ciphertext, message_modulus: u8) -> u64 {
ShortintEngine::with_thread_local_mut(|engine| {
ShortintEngine::with_thread_local_mut(|engine: &mut ShortintEngine| {
engine
.decrypt_message_native_crt(self, ct, message_modulus as u64)
.unwrap()

View File

@@ -21,7 +21,7 @@ pub fn shortint_public_key_zero_encryption_count(
impl ShortintEngine {
pub(crate) fn new_public_key(&mut self, client_key: &ClientKey) -> EngineResult<PublicKey> {
let client_parameters = client_key.parameters;
let client_parameters: crate::shortint::ShortintParameterSet = client_key.parameters;
let (secret_encryption_key, encryption_noise) =
match client_parameters.encryption_key_choice().into() {

View File

@@ -15,7 +15,7 @@ use crate::shortint::engine::ShortintEngine;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CompactPublicKey {
pub(crate) key: LweCompactPublicKeyOwned<u64>,
pub key: LweCompactPublicKeyOwned<u64>,
pub parameters: ShortintParameterSet,
pub pbs_order: PBSOrder,
}