mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-11 07:38:08 -05:00
Compare commits
14 Commits
main
...
tore/inter
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c62f2c6bea | ||
|
|
18c22f2ee7 | ||
|
|
bd8ab6a888 | ||
|
|
2fe7a17224 | ||
|
|
9f5a5bb0b3 | ||
|
|
c7d7ba0f7a | ||
|
|
09c0206950 | ||
|
|
30a7554dc4 | ||
|
|
7f96bae099 | ||
|
|
ee4c0ac041 | ||
|
|
c891148984 | ||
|
|
792b5dac42 | ||
|
|
376de492da | ||
|
|
f4ffa4d3f1 |
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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>,
|
||||
{
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user