Struct tfhe::FheBool

source ·
pub struct FheBool { /* private fields */ }
Available on crate feature integer only.
Expand description

The FHE boolean data type.

§Example

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

let config = ConfigBuilder::default().build();

let (client_key, server_key) = generate_keys(config);

let ttrue = FheBool::encrypt(true, &client_key);
let ffalse = FheBool::encrypt(false, &client_key);

// Do not forget to set the server key before doing any computation
set_server_key(server_key);

let fhe_result = ttrue & ffalse;

let clear_result = fhe_result.decrypt(&client_key);
assert_eq!(clear_result, false);

Implementations§

source§

impl FheBool

source

pub fn current_device(&self) -> Device

source

pub fn move_to_device(&mut self, device: Device)

Moves (in-place) the ciphertext to the desired device.

Does nothing if the ciphertext is already in the desired device

source

pub fn try_decrypt_trivial(&self) -> Result<bool, NotTrivialCiphertextError>

Tries to decrypt a trivial ciphertext

Trivial ciphertexts are ciphertexts which are not encrypted meaning they can be decrypted by any key, or even without a key.

For debugging, it can be useful to use trivial ciphertext to speed up execution, and use Self::try_decrypt_trivial to decrypt temporary values and debug.

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

// This is not a trivial ciphertext as we use a client key to encrypt.
let non_trivial = FheBool::encrypt(false, &client_key);
// This is a trivial ciphertext
let trivial = FheBool::encrypt_trivial(true);

// We can trivial decrypt
let result: Result<bool, _> = trivial.try_decrypt_trivial();
assert_eq!(result, Ok(true));

// We cannot trivial decrypt
let result: Result<bool, _> = non_trivial.try_decrypt_trivial();
matches!(result, Err(_));
source

pub fn is_trivial(&self) -> bool

Returns true if the ciphertext is a trivial encryption

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let non_trivial = FheBool::encrypt(false, &client_key);
assert!(!non_trivial.is_trivial());

let trivial = FheBool::encrypt_trivial(true);
assert!(trivial.is_trivial());
source§

impl FheBool

Trait Implementations§

source§

impl BitAnd<&FheBool> for bool

source§

fn bitand(self, rhs: &FheBool) -> Self::Output

Performs a bitwise ‘and’ between a bool and a FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = false & &a;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, false & true);
§

type Output = FheBool

The resulting type after applying the & operator.
source§

impl<B> BitAnd<B> for &FheBool
where B: Borrow<FheBool>,

source§

fn bitand(self, rhs: B) -> Self::Output

Performs a bitwise ‘and’ between two FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);
let b = FheBool::encrypt(true, &client_key);

let result = &a & &b;
let result = result.decrypt(&client_key);
assert_eq!(result, true & true);
§

type Output = FheBool

The resulting type after applying the & operator.
source§

impl<B> BitAnd<B> for FheBool
where B: Borrow<Self>,

source§

fn bitand(self, rhs: B) -> Self::Output

Performs a bitwise ‘and’ between two FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);
let b = FheBool::encrypt(true, &client_key);

let result = a & &b;
let result = result.decrypt(&client_key);
assert_eq!(result, true & true);
§

type Output = FheBool

The resulting type after applying the & operator.
source§

impl BitAnd<FheBool> for bool

source§

fn bitand(self, rhs: FheBool) -> Self::Output

Performs a bitwise ‘and’ between a bool and a FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = false & a;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, false & true);
§

type Output = FheBool

The resulting type after applying the & operator.
source§

impl BitAnd<bool> for &FheBool

source§

fn bitand(self, rhs: bool) -> Self::Output

Performs a bitwise ‘and’ between FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = &a & false;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, true & false);
§

type Output = FheBool

The resulting type after applying the & operator.
source§

impl BitAnd<bool> for FheBool

source§

fn bitand(self, rhs: bool) -> Self::Output

Performs a bitwise ‘and’ between FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = a & false;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, true & false);
§

type Output = FheBool

The resulting type after applying the & operator.
source§

impl<B> BitAndAssign<B> for FheBool
where B: Borrow<Self>,

source§

fn bitand_assign(&mut self, rhs: B)

Performs a bitwise ‘and’ between FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let mut a = FheBool::encrypt(true, &client_key);
let b = true;

a &= b;
let result = a.decrypt(&client_key);
assert_eq!(result, true & true);
source§

impl BitAndAssign<bool> for FheBool

source§

fn bitand_assign(&mut self, rhs: bool)

Performs a bitwise ‘and’ between FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let mut a = FheBool::encrypt(true, &client_key);

a &= false;
let result = a.decrypt(&client_key);
assert_eq!(result, true & false);
source§

impl BitOr<&FheBool> for bool

source§

fn bitor(self, rhs: &FheBool) -> Self::Output

Performs a bitwise ‘or’ between a bool and a FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = false | &a;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, false | true);
§

type Output = FheBool

The resulting type after applying the | operator.
source§

impl<B> BitOr<B> for &FheBool
where B: Borrow<FheBool>,

source§

fn bitor(self, rhs: B) -> Self::Output

Performs a bitwise ‘or’ between two FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);
let b = FheBool::encrypt(false, &client_key);

let result = &a | &b;
let result = result.decrypt(&client_key);
assert_eq!(result, true | false);
§

type Output = FheBool

The resulting type after applying the | operator.
source§

impl<B> BitOr<B> for FheBool
where B: Borrow<Self>,

source§

fn bitor(self, rhs: B) -> Self::Output

Performs a bitwise ‘or’ between two FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);
let b = FheBool::encrypt(false, &client_key);

let result = a | &b;
let result = result.decrypt(&client_key);
assert_eq!(result, true | false);
§

type Output = FheBool

The resulting type after applying the | operator.
source§

impl BitOr<FheBool> for bool

source§

fn bitor(self, rhs: FheBool) -> Self::Output

Performs a bitwise ‘or’ between a bool and a FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = false | a;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, false | true);
§

type Output = FheBool

The resulting type after applying the | operator.
source§

impl BitOr<bool> for &FheBool

source§

fn bitor(self, rhs: bool) -> Self::Output

Performs a bitwise ‘or’ between FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = a | false;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, true | false);
§

type Output = FheBool

The resulting type after applying the | operator.
source§

impl BitOr<bool> for FheBool

source§

fn bitor(self, rhs: bool) -> Self::Output

Performs a bitwise ‘or’ between FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = a | false;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, true | false);
§

type Output = FheBool

The resulting type after applying the | operator.
source§

impl<B> BitOrAssign<B> for FheBool
where B: Borrow<Self>,

source§

fn bitor_assign(&mut self, rhs: B)

Performs a bitwise ‘or’ between two FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let mut a = FheBool::encrypt(true, &client_key);
let b = FheBool::encrypt(true, &client_key);

a |= &b;
let result = a.decrypt(&client_key);
assert_eq!(result, true | true);
source§

impl BitOrAssign<bool> for FheBool

source§

fn bitor_assign(&mut self, rhs: bool)

Performs a bitwise ‘or’ between FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let mut a = FheBool::encrypt(true, &client_key);

a |= false;
let result = a.decrypt(&client_key);
assert_eq!(result, true | false);
source§

impl BitXor<&FheBool> for bool

source§

fn bitxor(self, rhs: &FheBool) -> Self::Output

Performs a bitwise ‘xor’ between a bool and a FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = false ^ &a;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, false ^ true);
§

type Output = FheBool

The resulting type after applying the ^ operator.
source§

impl<B> BitXor<B> for &FheBool
where B: Borrow<FheBool>,

source§

fn bitxor(self, rhs: B) -> Self::Output

Performs a bitwise ‘xor’ between two FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);
let b = FheBool::encrypt(true, &client_key);

let result = &a ^ &b;
let result = result.decrypt(&client_key);
assert_eq!(result, true ^ true);
§

type Output = FheBool

The resulting type after applying the ^ operator.
source§

impl<B> BitXor<B> for FheBool
where B: Borrow<Self>,

source§

fn bitxor(self, rhs: B) -> Self::Output

Performs a bitwise ‘xor’ between two FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);
let b = FheBool::encrypt(true, &client_key);

let result = a ^ &b;
let result = result.decrypt(&client_key);
assert_eq!(result, true ^ true);
§

type Output = FheBool

The resulting type after applying the ^ operator.
source§

impl BitXor<FheBool> for bool

source§

fn bitxor(self, rhs: FheBool) -> Self::Output

Performs a bitwise ‘xor’ between a bool and a FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = false ^ a;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, false ^ true);
§

type Output = FheBool

The resulting type after applying the ^ operator.
source§

impl BitXor<bool> for &FheBool

source§

fn bitxor(self, rhs: bool) -> Self::Output

Performs a bitwise ‘xor’ between FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = a ^ false;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, true ^ false);
§

type Output = FheBool

The resulting type after applying the ^ operator.
source§

impl BitXor<bool> for FheBool

source§

fn bitxor(self, rhs: bool) -> Self::Output

Performs a bitwise ‘xor’ between FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = a ^ false;
let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, true ^ false);
§

type Output = FheBool

The resulting type after applying the ^ operator.
source§

impl<B> BitXorAssign<B> for FheBool
where B: Borrow<Self>,

source§

fn bitxor_assign(&mut self, rhs: B)

Performs a bitwise ‘xor’ between two FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let mut a = FheBool::encrypt(true, &client_key);
let b = FheBool::encrypt(true, &client_key);

a ^= &b;
let result = a.decrypt(&client_key);
assert_eq!(result, true ^ true);
source§

impl BitXorAssign<bool> for FheBool

source§

fn bitxor_assign(&mut self, rhs: bool)

Performs a bitwise ‘xor’ between FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let mut a = FheBool::encrypt(true, &client_key);

a ^= false;
let result = a.decrypt(&client_key);
assert_eq!(result, true ^ false);
source§

impl<Id> CastFrom<FheBool> for FheInt<Id>
where Id: FheIntId,

source§

fn cast_from(input: FheBool) -> Self

Cast a FheBool to a FheInt

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool, FheInt16};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);
let b = FheInt16::cast_from(a);

let decrypted: i16 = b.decrypt(&client_key);
assert_eq!(decrypted, i16::from(true));
source§

impl<Id> CastFrom<FheBool> for FheUint<Id>
where Id: FheUintId,

source§

fn cast_from(input: FheBool) -> Self

Cast a boolean ciphertext to an unsigned ciphertext

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool, FheUint16};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);
let b = FheUint16::cast_from(a);

let decrypted: u16 = b.decrypt(&client_key);
assert_eq!(decrypted, u16::from(true));
source§

impl Clone for FheBool

source§

fn clone(&self) -> FheBool

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'de> Deserialize<'de> for FheBool

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl FheDecrypt<bool> for FheBool

source§

fn decrypt(&self, key: &ClientKey) -> bool

Decrypts the value

source§

impl<B> FheEq<B> for FheBool
where B: Borrow<Self>,

source§

fn eq(&self, other: B) -> Self

Test for equality between two FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);
let b = FheBool::encrypt(false, &client_key);

let result = a.eq(&b);

let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, true == false);
source§

fn ne(&self, other: B) -> Self

Test for difference between two FheBool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);
let b = FheBool::encrypt(false, &client_key);

let result = a.ne(&b);

let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, true != false);
source§

impl FheEq<bool> for FheBool

source§

fn eq(&self, other: bool) -> FheBool

Test for equality between a FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = a.eq(false);

let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, true == false);
source§

fn ne(&self, other: bool) -> FheBool

Test for equality between a FheBool and a bool

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = a.ne(false);

let decrypted = result.decrypt(&client_key);
assert_eq!(decrypted, true != false);
source§

impl FheKeyswitch<FheBool> for KeySwitchingKey

source§

fn keyswitch(&self, input: &FheBool) -> FheBool

source§

impl FheTrivialEncrypt<bool> for FheBool

source§

fn encrypt_trivial(value: bool) -> Self

Creates a trivial encryption of a bool.

§Warning

Trivial encryptions are not real encryptions, as a trivially encrypted ciphertext can be decrypted by any key (in fact, no key is actually needed).

Trivial encryptions become real encrypted data once used in an operation that involves a real ciphertext

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt_trivial(true);

let decrypted: bool = a.decrypt(&client_key);
assert_eq!(decrypted, true);
source§

impl FheTryEncrypt<bool, ClientKey> for FheBool

§

type Error = Error

source§

fn try_encrypt(value: bool, key: &ClientKey) -> Result<Self, Self::Error>

source§

impl FheTryEncrypt<bool, CompactPublicKey> for FheBool

§

type Error = Error

source§

fn try_encrypt(value: bool, key: &CompactPublicKey) -> Result<Self, Self::Error>

source§

impl FheTryEncrypt<bool, CompressedPublicKey> for FheBool

§

type Error = Error

source§

fn try_encrypt( value: bool, key: &CompressedPublicKey ) -> Result<Self, Self::Error>

source§

impl FheTryEncrypt<bool, PublicKey> for FheBool

§

type Error = Error

source§

fn try_encrypt(value: bool, key: &PublicKey) -> Result<Self, Self::Error>

source§

impl FheTryTrivialEncrypt<bool> for FheBool

§

type Error = Error

source§

fn try_encrypt_trivial(value: bool) -> Result<Self, Self::Error>

source§

impl<Id: FheIntId> IfThenElse<FheInt<Id>> for FheBool

source§

fn if_then_else(&self, ct_then: &FheInt<Id>, ct_else: &FheInt<Id>) -> FheInt<Id>

Conditional selection.

The output value returned depends on the value of self.

  • if self is true, the output will have the value of ct_then
  • if self is false, the output will have the value of ct_else
source§

fn cmux(&self, ct_then: &Ciphertext, ct_else: &Ciphertext) -> Ciphertext

source§

impl<Id> IfThenElse<FheUint<Id>> for FheBool
where Id: FheUintId,

source§

fn if_then_else( &self, ct_then: &FheUint<Id>, ct_else: &FheUint<Id> ) -> FheUint<Id>

Conditional selection.

The output value returned depends on the value of self.

  • if self is true, the output will have the value of ct_then
  • if self is false, the output will have the value of ct_else
source§

fn cmux(&self, ct_then: &Ciphertext, ct_else: &Ciphertext) -> Ciphertext

source§

impl Named for FheBool

source§

const NAME: &'static str = "high_level_api::FheBool"

source§

impl Not for &FheBool

source§

fn not(self) -> Self::Output

Performs a bitwise ‘not’

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = !&a;
let result = result.decrypt(&client_key);
assert_eq!(result, false);
§

type Output = FheBool

The resulting type after applying the ! operator.
source§

impl Not for FheBool

source§

fn not(self) -> Self::Output

Performs a bitwise ‘not’

§Example
use tfhe::prelude::*;
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheBool};

let (client_key, server_key) = generate_keys(ConfigBuilder::default());
set_server_key(server_key);

let a = FheBool::encrypt(true, &client_key);

let result = !a;
let result = result.decrypt(&client_key);
assert_eq!(result, false);
§

type Output = FheBool

The resulting type after applying the ! operator.
source§

impl ParameterSetConformant for FheBool

source§

impl Serialize for FheBool

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Input, Output> CastInto<Output> for Input
where Output: CastFrom<Input>,

source§

fn cast_into(self) -> Output

source§

impl<Clear, Key, T> FheEncrypt<Clear, Key> for T
where T: FheTryEncrypt<Clear, Key>,

source§

fn encrypt(value: Clear, key: &Key) -> T

Available on crate feature integer only.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,