Skip to content

Commit

Permalink
chore(pr): comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontaigu committed Aug 27, 2024
1 parent ec7ea04 commit cf3c28b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
4 changes: 2 additions & 2 deletions tfhe/src/high_level_api/integers/signed/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ where
/// let (client_key, server_key) = generate_keys(ConfigBuilder::default());
/// set_server_key(server_key);
///
/// let a = FheInt16::encrypt(1i16, &client_key);
/// let a = FheInt16::encrypt(46i16, &client_key);
///
/// let result = a.is_even();
/// let decrypted = result.decrypt(&client_key);
/// assert!(!decrypted);
/// assert!(decrypted);
/// ```
pub fn is_even(&self) -> FheBool {
global_state::with_internal_keys(|key| match key {
Expand Down
4 changes: 2 additions & 2 deletions tfhe/src/high_level_api/integers/unsigned/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ where
/// let (client_key, server_key) = generate_keys(ConfigBuilder::default());
/// set_server_key(server_key);
///
/// let a = FheUint16::encrypt(32u16, &client_key);
/// let a = FheUint16::encrypt(4393u16, &client_key);
///
/// let result = a.is_odd();
/// let decrypted = result.decrypt(&client_key);
/// assert!(!decrypted);
/// assert!(decrypted);
/// ```
pub fn is_odd(&self) -> FheBool {
global_state::with_internal_keys(|key| match key {
Expand Down
14 changes: 2 additions & 12 deletions tfhe/src/integer/server_key/radix/even_odd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,20 @@ impl ServerKey {
}

/// Returns an encryption of true if the value is even
#[allow(unused_mut)]
pub fn smart_is_even_parallelized<T>(&self, ct: &mut T) -> BooleanBlock
where
T: IntegerRadixCiphertext,
{
// Even though we don't need to worry about carries,
// we still clean them
if !ct.block_carries_are_empty() {
self.full_propagate_parallelized(ct);
}

self.unchecked_is_even(ct)
}

/// Returns an encryption of true if the value is odd
#[allow(unused_mut)]
pub fn smart_is_odd_parallelized<T>(&self, ct: &mut T) -> BooleanBlock
where
T: IntegerRadixCiphertext,
{
// Even though we don't need to worry about carries,
// we still clean them
if !ct.block_carries_are_empty() {
self.full_propagate_parallelized(ct);
}

self.unchecked_is_odd(ct)
}

Expand Down

0 comments on commit cf3c28b

Please sign in to comment.