pub type RadixCiphertext = BaseRadixCiphertext<Ciphertext>;Aliased Type§
pub struct RadixCiphertext { /* private fields */ }Implementations§
Source§impl RadixCiphertext
impl RadixCiphertext
pub fn block_carries_are_empty(&self) -> bool
pub fn is_trivial(&self) -> bool
Sourcepub fn decrypt_trivial<Clear>(&self) -> Result<Clear, NotTrivialCiphertextError>
pub fn decrypt_trivial<Clear>(&self) -> Result<Clear, NotTrivialCiphertextError>
Decrypts 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::decrypt_trivial to decrypt temporary values and debug.
§Example
use tfhe::integer::{gen_keys_radix, RadixCiphertext};
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
// 8 bits
let (cks, sks) = gen_keys_radix(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128, 4);
let msg = 124u8;
let msg2 = 17u8;
// Trivial encryption
let trivial_ct: RadixCiphertext = sks.create_trivial_radix(msg, 4);
let non_trivial_ct = cks.encrypt(msg2);
let res = trivial_ct.decrypt_trivial();
assert_eq!(Ok(msg), res);
let res = non_trivial_ct.decrypt_trivial::<u8>();
assert!(res.is_err());
// Doing operations that mixes trivial and non trivial
// will always return a non trivial
let ct_res = sks.add_parallelized(&trivial_ct, &non_trivial_ct);
let res = ct_res.decrypt_trivial::<u8>();
assert!(res.is_err());
// Doing operations using only trivial ciphertexts
// will return a trivial
let ct_res = sks.add_parallelized(&trivial_ct, &trivial_ct);
let res = ct_res.decrypt_trivial::<u8>();
assert_eq!(Ok(msg + msg), res);pub fn re_randomize( &mut self, re_randomization_key: ReRandomizationKey<'_>, seed: ReRandomizationSeed, ) -> Result<()>
Trait Implementations§
Source§impl Compressible for RadixCiphertext
impl Compressible for RadixCiphertext
fn compress_into(self, messages: &mut Vec<Ciphertext>) -> Option<DataKind>
Source§impl IntegerCiphertext for RadixCiphertext
impl IntegerCiphertext for RadixCiphertext
fn blocks(&self) -> &[Ciphertext]
fn from_blocks(blocks: Vec<Ciphertext>) -> Self
fn blocks_mut(&mut self) -> &mut [Ciphertext]
fn moduli(&self) -> Vec<u64>
Source§impl IntegerRadixCiphertext for RadixCiphertext
impl IntegerRadixCiphertext for RadixCiphertext
const IS_SIGNED: bool = false
fn into_blocks(self) -> Vec<Ciphertext>
fn block_carries_are_empty(&self) -> bool
Source§fn holds_boolean_value(&self) -> bool
fn holds_boolean_value(&self) -> bool
Returns whether the ciphertext seems like it holds/encrypts
a boolean (0 or 1) value. Read more