-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Many refactors #983
Many refactors #983
Conversation
d6e4ac3
to
af86fd7
Compare
d687fa6
to
7951e25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several comments, see with David and Thomas if need be for coverage and function executor patterns for tests
I think the shortint compression would not work as expected as it would worsen the degree of the ciphertexts as it's currently written
I would therefore require a test checking for an identity decompression that the degree is conserved
fn modulus_switch_compression<P>(param: P) | ||
where | ||
P: Into<PBSParameters>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not use the Function executor pattern ?
if need be ask Thomas how to use the executor stuff
eee4ddb
to
35b2ee0
Compare
let ct2 = cks.encrypt_with_message_modulus(clear2, MessageModulus(modulus as usize)); | ||
|
||
println!("MUL SMALL CARRY:: clear1 = {clear1}, clear2 = {clear2}, mod = {modulus}"); | ||
let ct_res = sks.unchecked_mul_lsb_small_carry(&ct1, &ct2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this uses the bivariate PBS, I think I would go for an integer like rework, where each op gets its file, so you would export the macro in the shortint module that would get moved to e.g.
tests/mod.rs
and then crate a file for the operation you are currently working on ?
so
tests/modulus_switch_compression.rs
does that make sense ?
tfhe/src/shortint/ciphertext/mod.rs
Outdated
} | ||
} | ||
} | ||
#[allow(clippy::module_inception)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsure for the naming below
also, let's keep the modules public for now, more often than not having private stuff ends being more problems than it's worth at the moment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By reexporting everything publicly, the interface of this module remains unchanged I believe
I don't see what problem this could cause
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll see but from experience on TFHE-rs as soon as something is not public, then it gets annoying/someone needs access for fairly good reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe everything is accessible through the pub use
, the only difference being that it appears one module higher (as before this refactor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I said, we will see :)
35b2ee0
to
f2abd31
Compare
pub mod shortint; | ||
pub mod parametrized_test; | ||
pub mod parametrized_test_bivariate_pbs_compliant; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the split does not make sense I believe as we discussed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if eventually, we'd like to have many more files, I think, it's better to have two files rather than one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes but the split does not make sense as some tests are not bivar PBS compliant in the corresponding file :/
tfhe/examples/sha256.rs
Outdated
@@ -37,7 +35,9 @@ macro_rules! __join_implementation { | |||
}; | |||
} | |||
|
|||
#[macro_export] | |||
#[doc(hidden)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc(hidden) on the re export ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was already hidden, but I can remove it if you think it makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean does a doc hidden make sense on a pub use ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a pub(crate) use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry
I mean
doc(hidden) on a use statement does nothing ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
@@ -1,490 +1,11 @@ | |||
//! This module implements the ciphertext structures. | |||
mod base; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's keep things public, as you can see the boolean_value one was public, same thing for shortint please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tfhe/src/integer/ciphertext/utils.rs
Outdated
use super::{CrtCiphertext, RadixCiphertext, SignedRadixCiphertext}; | ||
use crate::shortint::Ciphertext; | ||
|
||
pub trait IntegerCiphertext: Clone { | ||
fn blocks(&self) -> &[Ciphertext]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be in the mod.rs itself ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's clearer to have the mod only containing other modules (and possibly reexports)
Renamed module integer_ciphertext
tfhe/src/integer/client_key/radix.rs
Outdated
@@ -27,8 +27,7 @@ use serde::{Deserialize, Serialize}; | |||
/// | |||
/// let ct = cks.encrypt(msg); | |||
/// | |||
/// // Decryption | |||
/// let dec = cks.decrypt(&ct); | |||
/// /// let dec = cks.decrypt(&ct); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
use super::super::CheckError; | ||
pub use crate::core_crypto::commons::parameters::PBSOrder; | ||
use crate::shortint::parameters::{CarryModulus, MessageModulus}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::cmp; | ||
use std::fmt::Debug; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be in the mod.rs itself ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer it this way
I think it's clearer to have the mod only containing other modules (and possibly reexports)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
pub use common::*; | ||
pub use compact_list::*; | ||
pub use compressed::*; | ||
pub use standard::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's not have pub use of everything, it was a bad pattern/practice in core_crypto, Thomas said it was not the best way of making things available where required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
mod common; | ||
mod compact_list; | ||
mod compressed; | ||
mod standard; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub mod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
tfhe/src/integer/ciphertext/mod.rs
Outdated
pub use base::*; | ||
pub use boolean_value::*; | ||
pub use compact_list::*; | ||
pub use compressed::*; | ||
pub use utils::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub use the minimum required/which makes sense to compile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
2fae26a
to
acba6ca
Compare
@@ -617,6 +656,9 @@ macro_rules! impl_scalar_binary_assign_fn_on_type { | |||
}; | |||
} | |||
|
|||
#[cfg(feature = "integer")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feature gate required ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No
Removing
cuda test red @mayeul-zama |
acba6ca
to
0bcfc17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the preliminary refactor and most notably for the shortint test fixes !
0bcfc17
to
c2f3c2c
Compare
c2f3c2c
to
53df75b
Compare
No description provided.