Skip to content

Commit

Permalink
style(all): regroup uses
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeul-zama committed Mar 21, 2024
1 parent 2bf23ae commit 31e2949
Show file tree
Hide file tree
Showing 125 changed files with 158 additions and 329 deletions.
3 changes: 0 additions & 3 deletions apps/trivium/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Example of a Rust main below:
```rust
use tfhe::{ConfigBuilder, generate_keys, FheBool};
use tfhe::prelude::*;

use tfhe_trivium::TriviumStream;

fn get_hexadecimal_string_from_lsb_first_stream(a: Vec<bool>) -> String {
Expand Down Expand Up @@ -139,10 +138,8 @@ Example code:
```rust
use tfhe::shortint::prelude::*;
use tfhe::shortint::CastingKey;

use tfhe::{ConfigBuilder, generate_keys, FheUint64};
use tfhe::prelude::*;

use tfhe_trivium::TriviumStreamShortint;

fn test_shortint() {
Expand Down
4 changes: 1 addition & 3 deletions apps/trivium/benches/kreyvium_bool.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use criterion::Criterion;
use tfhe::prelude::*;
use tfhe::{generate_keys, ConfigBuilder, FheBool};

use tfhe_trivium::KreyviumStream;

use criterion::Criterion;

pub fn kreyvium_bool_gen(c: &mut Criterion) {
let config = ConfigBuilder::default().build();
let (client_key, server_key) = generate_keys(config);
Expand Down
4 changes: 1 addition & 3 deletions apps/trivium/benches/kreyvium_byte.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use criterion::Criterion;
use tfhe::prelude::*;
use tfhe::{generate_keys, ConfigBuilder, FheUint64, FheUint8};

use tfhe_trivium::{KreyviumStreamByte, TransCiphering};

use criterion::Criterion;

pub fn kreyvium_byte_gen(c: &mut Criterion) {
let config = ConfigBuilder::default()
.enable_function_evaluation()
Expand Down
4 changes: 1 addition & 3 deletions apps/trivium/benches/trivium_bool.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use criterion::Criterion;
use tfhe::prelude::*;
use tfhe::{generate_keys, ConfigBuilder, FheBool};

use tfhe_trivium::TriviumStream;

use criterion::Criterion;

pub fn trivium_bool_gen(c: &mut Criterion) {
let config = ConfigBuilder::default().build();
let (client_key, server_key) = generate_keys(config);
Expand Down
4 changes: 1 addition & 3 deletions apps/trivium/benches/trivium_byte.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use criterion::Criterion;
use tfhe::prelude::*;
use tfhe::{generate_keys, ConfigBuilder, FheUint64, FheUint8};

use tfhe_trivium::{TransCiphering, TriviumStreamByte};

use criterion::Criterion;

pub fn trivium_byte_gen(c: &mut Criterion) {
let config = ConfigBuilder::default().build();
let (client_key, server_key) = generate_keys(config);
Expand Down
4 changes: 1 addition & 3 deletions apps/trivium/src/kreyvium/kreyvium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
//! for the representation of the inner bits.
use crate::static_deque::StaticDeque;

use rayon::prelude::*;
use tfhe::prelude::*;
use tfhe::{set_server_key, unset_server_key, FheBool, ServerKey};

use rayon::prelude::*;

/// Internal trait specifying which operations are necessary for KreyviumStream generic type
pub trait KreyviumBoolInput<OpOutput>:
Sized
Expand Down
4 changes: 1 addition & 3 deletions apps/trivium/src/kreyvium/kreyvium_byte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
//! for the representation of the inner bits.
use crate::static_deque::{StaticByteDeque, StaticByteDequeInput};

use rayon::prelude::*;
use tfhe::prelude::*;
use tfhe::{set_server_key, unset_server_key, FheUint8, ServerKey};

use rayon::prelude::*;

/// Internal trait specifying which operations are necessary for KreyviumStreamByte generic type
pub trait KreyviumByteInput<OpOutput>:
Sized
Expand Down
4 changes: 1 addition & 3 deletions apps/trivium/src/kreyvium/kreyvium_shortint.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::static_deque::StaticDeque;

use tfhe::shortint::prelude::*;

use rayon::prelude::*;
use tfhe::shortint::prelude::*;

/// KreyviumStreamShortint: a struct implementing the Kreyvium stream cipher, using a generic
/// Ciphertext for the internal representation of bits (intended to represent a single bit). To be
Expand Down
3 changes: 1 addition & 2 deletions apps/trivium/src/kreyvium/test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::{KreyviumStream, KreyviumStreamByte, KreyviumStreamShortint, TransCiphering};
use tfhe::prelude::*;
use tfhe::{generate_keys, ConfigBuilder, FheBool, FheUint64, FheUint8};

use crate::{KreyviumStream, KreyviumStreamByte, KreyviumStreamShortint, TransCiphering};

// Values for these tests come from the github repo renaud1239/Kreyvium,
// commit fd6828f68711276c25f55e605935028f5e843f43

Expand Down
1 change: 1 addition & 0 deletions apps/trivium/src/static_deque/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[allow(clippy::module_inception)]
mod static_deque;
pub use static_deque::StaticDeque;

mod static_byte_deque;
pub use static_byte_deque::{StaticByteDeque, StaticByteDequeInput};
1 change: 0 additions & 1 deletion apps/trivium/src/static_deque/static_byte_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! This is pretending to store bits, and allows accessing bits in chunks of 8 consecutive.
use crate::static_deque::StaticDeque;

use tfhe::FheUint8;

/// Internal trait specifying which operations are needed by StaticByteDeque
Expand Down
6 changes: 2 additions & 4 deletions apps/trivium/src/trans_ciphering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
//! when trans ciphering is available to them.
use crate::{KreyviumStreamByte, KreyviumStreamShortint, TriviumStreamByte, TriviumStreamShortint};
use tfhe::shortint::Ciphertext;

use rayon::prelude::*;
use tfhe::prelude::*;
use tfhe::shortint::Ciphertext;
use tfhe::{set_server_key, unset_server_key, FheUint64, FheUint8, ServerKey};

use rayon::prelude::*;

/// Triat specifying the interface for trans ciphering a FheUint64 object. Since it is meant
/// to be used with stream ciphers, encryption and decryption are by default the same.
pub trait TransCiphering {
Expand Down
3 changes: 1 addition & 2 deletions apps/trivium/src/trivium/test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::{TransCiphering, TriviumStream, TriviumStreamByte, TriviumStreamShortint};
use tfhe::prelude::*;
use tfhe::{generate_keys, ConfigBuilder, FheBool, FheUint64, FheUint8};

use crate::{TransCiphering, TriviumStream, TriviumStreamByte, TriviumStreamShortint};

// Values for these tests come from the github repo cantora/avr-crypto-lib, commit 2a5b018,
// file testvectors/trivium-80.80.test-vectors

Expand Down
4 changes: 1 addition & 3 deletions apps/trivium/src/trivium/trivium_bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
//! for the representation of the inner bits.
use crate::static_deque::StaticDeque;

use rayon::prelude::*;
use tfhe::prelude::*;
use tfhe::{set_server_key, unset_server_key, FheBool, ServerKey};

use rayon::prelude::*;

/// Internal trait specifying which operations are necessary for TriviumStream generic type
pub trait TriviumBoolInput<OpOutput>:
Sized
Expand Down
4 changes: 1 addition & 3 deletions apps/trivium/src/trivium/trivium_byte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
//! for the representation of the inner bits.
use crate::static_deque::{StaticByteDeque, StaticByteDequeInput};

use rayon::prelude::*;
use tfhe::prelude::*;
use tfhe::{set_server_key, unset_server_key, FheUint8, ServerKey};

use rayon::prelude::*;

/// Internal trait specifying which operations are necessary for TriviumStreamByte generic type
pub trait TriviumByteInput<OpOutput>:
Sized
Expand Down
4 changes: 1 addition & 3 deletions apps/trivium/src/trivium/trivium_shortint.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::static_deque::StaticDeque;

use tfhe::shortint::prelude::*;

use rayon::prelude::*;
use tfhe::shortint::prelude::*;

/// TriviumStreamShortint: a struct implementing the Trivium stream cipher, using a generic
/// Ciphertext for the internal representation of bits (intended to represent a single bit). To be
Expand Down
7 changes: 2 additions & 5 deletions concrete-csprng/examples/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,25 @@ use clap::{value_parser, Arg, Command};
use concrete_csprng::generators::AesniRandomGenerator as ActivatedRandomGenerator;
#[cfg(feature = "generator_aarch64_aes")]
use concrete_csprng::generators::NeonAesRandomGenerator as ActivatedRandomGenerator;
use concrete_csprng::generators::RandomGenerator;
#[cfg(all(
not(feature = "generator_x86_64_aesni"),
not(feature = "generator_aarch64_aes"),
feature = "generator_fallback"
))]
use concrete_csprng::generators::SoftwareRandomGenerator as ActivatedRandomGenerator;

use concrete_csprng::generators::RandomGenerator;

#[cfg(target_os = "macos")]
use concrete_csprng::seeders::AppleSecureEnclaveSeeder as ActivatedSeeder;
#[cfg(all(not(target_os = "macos"), feature = "seeder_x86_64_rdseed"))]
use concrete_csprng::seeders::RdseedSeeder as ActivatedSeeder;
use concrete_csprng::seeders::Seeder;
#[cfg(all(
not(target_os = "macos"),
not(feature = "seeder_x86_64_rdseed"),
feature = "seeder_unix"
))]
use concrete_csprng::seeders::UnixSeeder as ActivatedSeeder;

use concrete_csprng::seeders::Seeder;

use std::io::prelude::*;
use std::io::{stdout, StdoutLock};

Expand Down
2 changes: 1 addition & 1 deletion tfhe/benches/boolean/bench.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[path = "../utilities.rs"]
mod utilities;
use crate::utilities::{write_to_json, CryptoParametersRecord, OperatorType};

use crate::utilities::{write_to_json, CryptoParametersRecord, OperatorType};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use tfhe::boolean::client_key::ClientKey;
use tfhe::boolean::parameters::{
Expand Down
1 change: 1 addition & 0 deletions tfhe/benches/core_crypto/ks_bench.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[path = "../utilities.rs"]
mod utilities;

use crate::utilities::{write_to_json, CryptoParametersRecord, OperatorType};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use serde::Serialize;
Expand Down
5 changes: 2 additions & 3 deletions tfhe/benches/core_crypto/pbs_bench.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#[path = "../utilities.rs"]
mod utilities;
use crate::utilities::{write_to_json, CryptoParametersRecord, OperatorType};
use rayon::prelude::*;

use crate::utilities::{write_to_json, CryptoParametersRecord, OperatorType};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rayon::prelude::*;
use serde::Serialize;
use tfhe::boolean::parameters::{
BooleanParameters, DEFAULT_PARAMETERS, PARAMETERS_ERROR_PROB_2_POW_MINUS_165,
};

use tfhe::core_crypto::prelude::*;
use tfhe::keycache::NamedParam;
use tfhe::shortint::parameters::*;
Expand Down
4 changes: 1 addition & 3 deletions tfhe/benches/high_level_api/bench.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::ops::*;

use criterion::{black_box, Criterion};

use rand::prelude::*;
use std::fmt::Write;
use std::ops::*;
use tfhe::prelude::*;
use tfhe::shortint::parameters::*;
use tfhe::{
Expand Down
15 changes: 3 additions & 12 deletions tfhe/benches/integer/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,15 @@
mod utilities;

use crate::utilities::{write_to_json, EnvConfig, OperatorType};
use std::env;

use criterion::{criterion_group, Criterion};
use itertools::iproduct;
use rand::prelude::*;
use std::env;
use std::vec::IntoIter;
use tfhe::integer::keycache::KEY_CACHE;
use tfhe::integer::{IntegerKeyKind, RadixCiphertext, RadixClientKey, ServerKey};
use tfhe::integer::{IntegerKeyKind, RadixCiphertext, RadixClientKey, ServerKey, U256};
use tfhe::keycache::NamedParam;

use tfhe::integer::U256;

#[allow(unused_imports)]
use tfhe::shortint::parameters::{
PARAM_MESSAGE_1_CARRY_1_KS_PBS, PARAM_MESSAGE_2_CARRY_2_KS_PBS, PARAM_MESSAGE_3_CARRY_3_KS_PBS,
PARAM_MESSAGE_4_CARRY_4_KS_PBS, PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
};
use tfhe::shortint::parameters::*;

/// The type used to hold scalar values
/// It must be as big as the largest bit size tested
Expand Down
4 changes: 1 addition & 3 deletions tfhe/benches/integer/signed_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
mod utilities;

use crate::utilities::{write_to_json, EnvConfig, OperatorType};
use std::env;

use criterion::{criterion_group, Criterion};
use itertools::iproduct;
use rand::prelude::*;
use std::env;
use std::vec::IntoIter;
use tfhe::integer::keycache::KEY_CACHE;
use tfhe::integer::{IntegerKeyKind, RadixCiphertext, ServerKey, SignedRadixCiphertext, I256};
use tfhe::keycache::NamedParam;

use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
#[cfg(not(feature = "gpu"))]
use tfhe::shortint::parameters::PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS;
Expand Down
11 changes: 4 additions & 7 deletions tfhe/benches/shortint/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
mod utilities;

use crate::utilities::{write_to_json, OperatorType};
use std::env;

use criterion::{criterion_group, Criterion};
use tfhe::keycache::NamedParam;
use tfhe::shortint::parameters::*;
use tfhe::shortint::{Ciphertext, CompressedServerKey, ServerKey};

use rand::Rng;
use std::env;
use tfhe::keycache::NamedParam;
use tfhe::shortint::keycache::{KEY_CACHE, KEY_CACHE_WOPBS};

use tfhe::shortint::parameters::parameters_wopbs::WOPBS_PARAM_MESSAGE_4_NORM2_6_KS_PBS;
use tfhe::shortint::parameters::*;
use tfhe::shortint::{Ciphertext, CompressedServerKey, ServerKey};

const SERVER_KEY_BENCH_PARAMS: [ClassicPBSParameters; 4] = [
PARAM_MESSAGE_1_CARRY_1_KS_PBS,
Expand Down
7 changes: 2 additions & 5 deletions tfhe/benches/shortint/casting.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use crate::utilities::{write_to_json, OperatorType};

use tfhe::shortint::prelude::*;

use rayon::prelude::*;

use criterion::Criterion;
use rayon::prelude::*;
use tfhe::shortint::prelude::*;

pub fn pack_cast_64(c: &mut Criterion) {
let bench_name = "pack_cast_64";
Expand Down
1 change: 0 additions & 1 deletion tfhe/docs/fine_grained_api/integer/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ bincode = "1.3.3"
// main.rs

use bincode;

use std::io::Cursor;
use tfhe::integer::{gen_keys_radix, ServerKey, RadixCiphertext};
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
Expand Down
1 change: 0 additions & 1 deletion tfhe/docs/fine_grained_api/shortint/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ If we redo this same circuit with the `checked` flavor, a panic will occur:

```rust
use tfhe::shortint::prelude::*;

use std::error::Error;

fn main() {
Expand Down
2 changes: 0 additions & 2 deletions tfhe/docs/how_to/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ bincode = "1.3.3"
// main.rs

use bincode;

use std::io::Cursor;

use tfhe::{ConfigBuilder, ServerKey, generate_keys, set_server_key, FheUint8};
use tfhe::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion tfhe/docs/how_to/trait_bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ only allowing easier debugging.

```rust
use std::ops::{Add, Mul};

use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint32, FheUint64};

Expand Down
1 change: 0 additions & 1 deletion tfhe/docs/tutorials/parity_bit.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ Here is a complete example that uses this function for both clear and FHE values
```rust
use tfhe::{FheBool, ConfigBuilder, generate_keys, set_server_key};
use tfhe::prelude::*;

use std::ops::{Not, BitXor};

#[derive(Copy, Clone, Debug)]
Expand Down
Loading

0 comments on commit 31e2949

Please sign in to comment.