Skip to content

Commit

Permalink
chore(hlapi): remove Wop
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeul-zama committed Jul 22, 2024
1 parent bdc3216 commit e626957
Show file tree
Hide file tree
Showing 28 changed files with 42 additions and 322 deletions.
3 changes: 1 addition & 2 deletions tfhe/benches/high_level_api/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ bench_type!(FheUint64);
bench_type!(FheUint128);

fn main() {
let config =
ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS, None).build();
let config = ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS).build();
let cks = ClientKey::generate(config);
let compressed_sks = CompressedServerKey::new(&cks);

Expand Down
3 changes: 1 addition & 2 deletions tfhe/docs/fundamentals/compress.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use tfhe::{
};

fn main() {
let config = tfhe::ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2, None)
let config = tfhe::ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2)
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2)
.build();

Expand Down Expand Up @@ -212,7 +212,6 @@ fn main() {
let config = ConfigBuilder::default()
.use_custom_parameters(
tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS,
None,
)
.build();
let (client_key, _) = generate_keys(config);
Expand Down
2 changes: 1 addition & 1 deletion tfhe/docs/fundamentals/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn main() {
let params_2 = PARAM_MESSAGE_2_CARRY_2_PBS_KS;

let (client_key, server_key) = generate_keys(
ConfigBuilder::with_custom_parameters(params_1, None).build()
ConfigBuilder::with_custom_parameters(params_1).build()
);

let conformance_params_1 = FheUint8ConformanceParams::from(params_1);
Expand Down
2 changes: 0 additions & 2 deletions tfhe/docs/guides/parallelized_pbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = ConfigBuilder::default()
.use_custom_parameters(
tfhe::shortint::parameters::PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
None,
)
.build();

Expand Down Expand Up @@ -52,7 +51,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = ConfigBuilder::default()
.use_custom_parameters(
tfhe::shortint::parameters::PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS.with_deterministic_execution(),
None,
)
.build();

Expand Down
1 change: 0 additions & 1 deletion tfhe/docs/guides/public_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ fn main() {
let config = ConfigBuilder::default()
.use_custom_parameters(
tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS,
None,
)
.build();
let (client_key, _) = generate_keys(config);
Expand Down
4 changes: 2 additions & 2 deletions tfhe/docs/guides/run_on_gpu.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Finally, the client decrypts the results using:
**TFHE-rs** allows to leverage the high number of threads given by a GPU. To maximize the number of GPU threads, update your configuration accordingly:

```Rust
let config = ConfigBuilder::with_custom_parameters(PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS, None).build();
let config = ConfigBuilder::with_custom_parameters(PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS).build();
```

Here's the complete example:
Expand All @@ -145,7 +145,7 @@ use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS

fn main() {

let config = ConfigBuilder::with_custom_parameters(PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS, None).build();
let config = ConfigBuilder::with_custom_parameters(PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS).build();

let client_key= ClientKey::generate(config);
let compressed_server_key = CompressedServerKey::new(&client_key);
Expand Down
4 changes: 2 additions & 2 deletions tfhe/docs/guides/zk-pok.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {

let params =
tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
let config = tfhe::ConfigBuilder::with_custom_parameters(params, None);
let config = tfhe::ConfigBuilder::with_custom_parameters(params);

let client_key = tfhe::ClientKey::generate(config.clone());
// This is done in an offline phase and the CRS is shared to all clients and the server
Expand Down Expand Up @@ -91,7 +91,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
// And parameters allowing to keyswitch/cast to the computation parameters.
let casting_params = tfhe::shortint::parameters::key_switching::PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
// Enable the dedicated parameters on the config
let config = tfhe::ConfigBuilder::with_custom_parameters(params, None)
let config = tfhe::ConfigBuilder::with_custom_parameters(params)
.use_dedicated_compact_public_key_parameters((cpk_params, casting_params));

// Then use TFHE-rs as usual
Expand Down
2 changes: 1 addition & 1 deletion tfhe/examples/dist_tuniform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
my_params.glwe_noise_distribution = DynamicDistribution::new_t_uniform(10);

let config = ConfigBuilder::default()
.use_custom_parameters(my_params, None)
.use_custom_parameters(my_params)
.build();

let (keys, server_keys) = generate_keys(config);
Expand Down
14 changes: 6 additions & 8 deletions tfhe/examples/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,12 @@ fn main() -> Result<(), std::io::Error> {
println!("key gen start");
let config = match args.multibit {
None => ConfigBuilder::default(),
Some(2) => ConfigBuilder::with_custom_parameters(
PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
None,
),
Some(3) => ConfigBuilder::with_custom_parameters(
PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
None,
),
Some(2) => {
ConfigBuilder::with_custom_parameters(PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS)
}
Some(3) => {
ConfigBuilder::with_custom_parameters(PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS)
}
Some(v) => {
panic!("Invalid multibit setting {v}");
}
Expand Down
8 changes: 4 additions & 4 deletions tfhe/examples/utilities/hlapi_compact_pk_ct_sizes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
{
let params = PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS;
let config = ConfigBuilder::default()
.use_custom_parameters(params, None)
.use_custom_parameters(params)
.build();
let (client_key, _) = generate_keys(config);
let test_name = format!("hlapi_sizes_{}_cpk", params.name());
Expand Down Expand Up @@ -99,7 +99,7 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
{
let params = PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS;
let config = ConfigBuilder::default()
.use_custom_parameters(params, None)
.use_custom_parameters(params)
.build();
let (client_key, _) = generate_keys(config);
let test_name = format!("hlapi_sizes_{}_cpk", params.name());
Expand Down Expand Up @@ -158,7 +158,7 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
{
let params = PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS;
let config = ConfigBuilder::default()
.use_custom_parameters(params, None)
.use_custom_parameters(params)
.build();
let (client_key, _) = generate_keys(config);

Expand Down Expand Up @@ -206,7 +206,7 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
{
let params = PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS;
let config = ConfigBuilder::default()
.use_custom_parameters(params, None)
.use_custom_parameters(params)
.build();
let (client_key, _) = generate_keys(config);

Expand Down
4 changes: 1 addition & 3 deletions tfhe/src/c_api/high_level_api/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ pub unsafe extern "C" fn config_builder_use_custom_parameters(
let params: crate::shortint::ClassicPBSParameters =
shortint_block_parameters.try_into().unwrap();

let inner = Box::from_raw(*builder)
.0
.use_custom_parameters(params, None);
let inner = Box::from_raw(*builder).0.use_custom_parameters(params);
*builder = Box::into_raw(Box::new(ConfigBuilder(inner)));
})
}
Expand Down
2 changes: 0 additions & 2 deletions tfhe/src/high_level_api/backward_compatibility/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ impl Upgrade<IntegerClientKey> for IntegerClientKeyV0 {
fn upgrade(self) -> Result<IntegerClientKey, Self::Error> {
Ok(IntegerClientKey {
key: self.key,
wopbs_block_parameters: self.wopbs_block_parameters,
dedicated_compact_private_key: None,
compression_key: None,
})
Expand All @@ -102,7 +101,6 @@ impl Upgrade<IntegerServerKey> for IntegerServerKeyV0 {
fn upgrade(self) -> Result<IntegerServerKey, Self::Error> {
Ok(IntegerServerKey {
key: self.key,
wopbs_key: self.wopbs_key,
cpk_key_switching_key_material: None,
compression_key: None,
decompression_key: None,
Expand Down
4 changes: 2 additions & 2 deletions tfhe/src/high_level_api/booleans/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ mod cpu {
fn test_safe_deserialize_conformant_fhe_bool() {
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS;
let (client_key, server_key) =
generate_keys(ConfigBuilder::with_custom_parameters(block_params, None));
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
set_server_key(server_key.clone());

let clear_a = random::<bool>();
Expand All @@ -698,7 +698,7 @@ mod cpu {
fn test_safe_deserialize_conformant_compressed_fhe_bool() {
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS;
let (client_key, server_key) =
generate_keys(ConfigBuilder::with_custom_parameters(block_params, None));
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
set_server_key(server_key.clone());
let clear_a = random::<bool>();
let a = CompressedFheBool::encrypt(clear_a, &client_key);
Expand Down
2 changes: 0 additions & 2 deletions tfhe/src/high_level_api/compact_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ mod tests {

let config = crate::ConfigBuilder::with_custom_parameters(
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
None,
)
.build();

Expand Down Expand Up @@ -446,7 +445,6 @@ mod tests {

let config = crate::ConfigBuilder::with_custom_parameters(
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
None,
)
.use_dedicated_compact_public_key_parameters((
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
Expand Down
1 change: 0 additions & 1 deletion tfhe/src/high_level_api/compressed_ciphertext_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ mod tests {
fn test_compressed_ct_list() {
let config = crate::ConfigBuilder::with_custom_parameters(
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
None,
)
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
.build();
Expand Down
22 changes: 4 additions & 18 deletions tfhe/src/high_level_api/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ impl Default for ConfigBuilder {
}

impl ConfigBuilder {
#[doc(hidden)]
pub fn enable_function_evaluation(mut self) -> Self {
self.config.inner.enable_wopbs();
self
}

pub fn enable_compression(mut self, compression_parameters: CompressionParameters) -> Self {
self.config.inner.enable_compression(compression_parameters);

Expand Down Expand Up @@ -70,16 +64,13 @@ impl ConfigBuilder {
}
}

pub fn with_custom_parameters<P>(
block_parameters: P,
wopbs_block_parameters: Option<crate::shortint::WopbsParameters>,
) -> Self
pub fn with_custom_parameters<P>(block_parameters: P) -> Self
where
P: Into<crate::shortint::PBSParameters>,
{
Self {
config: Config {
inner: IntegerConfig::new(block_parameters.into(), wopbs_block_parameters, None),
inner: IntegerConfig::new(block_parameters.into(), None),
},
}
}
Expand All @@ -96,16 +87,11 @@ impl ConfigBuilder {
self
}

pub fn use_custom_parameters<P>(
mut self,
block_parameters: P,
wopbs_block_parameters: Option<crate::shortint::WopbsParameters>,
) -> Self
pub fn use_custom_parameters<P>(mut self, block_parameters: P) -> Self
where
P: Into<crate::shortint::PBSParameters>,
{
self.config.inner =
IntegerConfig::new(block_parameters.into(), wopbs_block_parameters, None);
self.config.inner = IntegerConfig::new(block_parameters.into(), None);
self
}

Expand Down
8 changes: 2 additions & 6 deletions tfhe/src/high_level_api/integers/signed/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ fn test_multi_bit_rotate() {
let config = ConfigBuilder::default()
.use_custom_parameters(
crate::shortint::parameters::PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
None,
)
.build();
fhe_int64_rotate(config);
Expand Down Expand Up @@ -368,7 +367,6 @@ fn test_multi_div_rem() {
let config = ConfigBuilder::default()
.use_custom_parameters(
crate::shortint::parameters::PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
None,
)
.build();
fhe_int32_div_rem(config);
Expand Down Expand Up @@ -546,7 +544,6 @@ fn test_compact_public_key_big() {
let config = ConfigBuilder::default()
.use_custom_parameters(
crate::shortint::parameters::classic::compact_pk::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS,
None,
)
.build();
let (client_key, _) = generate_keys(config);
Expand All @@ -567,7 +564,6 @@ fn test_compact_public_key_small() {
let config = ConfigBuilder::default()
.use_custom_parameters(
crate::shortint::parameters::classic::compact_pk::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS,
None,
)
.build();
let (client_key, _) = generate_keys(config);
Expand Down Expand Up @@ -646,7 +642,7 @@ fn test_leading_trailing_zeros_ones() {
fn test_safe_deserialize_conformant_fhe_int32() {
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS;
let (client_key, server_key) =
generate_keys(ConfigBuilder::with_custom_parameters(block_params, None));
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
set_server_key(server_key.clone());

let clear_a = random::<i32>();
Expand All @@ -668,7 +664,7 @@ fn test_safe_deserialize_conformant_fhe_int32() {
fn test_safe_deserialize_conformant_compressed_fhe_int32() {
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS;
let (client_key, server_key) =
generate_keys(ConfigBuilder::with_custom_parameters(block_params, None));
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
set_server_key(server_key.clone());

let clear_a = random::<i32>();
Expand Down
1 change: 0 additions & 1 deletion tfhe/src/high_level_api/integers/unsigned/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub(in crate::high_level_api) use inner::RadixCiphertextVersionOwned;
mod base;
mod compressed;
mod static_;
mod wopbs;

mod encrypt;
mod inner;
Expand Down
Loading

0 comments on commit e626957

Please sign in to comment.