Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
This document details the min/max operations supported by TFHE-rs.
Homomorphic integers support the min/max operations:
Min
min
Binary
Max
max
Binary
The following example shows how to perform min/max operations:
This document details the ternary operations supported by TFHE-rs.
The ternary conditional operator execute conditional instructions in the form if cond { choice_if_true } else { choice_if_false }
.
Ternary operator
select
Ternary
The syntax is encrypted_condition.select(encrypted_choice_if_true, encrypted_choice_if_false)
. The valid encrypted_condition
must be an encryption of 0 or 1.
The following example shows how to perform ternary conditional operations:
This document details the bitwise operations supported by TFHE-rs.
Homomorphic integer types support the following bitwise operations:
The following example shows how to perform bitwise operations:
!
Unary
&
Binary
|
Binary
^
Binary
>>
Binary
<<
Binary
rotate_right
Binary
rotate_left
Binary
This document details the casting operations supported by TFHE-rs.
You can cast between integer types using either the cast_from
associated function or the cast_into
method.
The following example shows how to perform casting operations:
This document details the comparison operations supported by TFHE-rs.
Homomorphic integers support comparison operations. However, due to Rust's limitations, you cannot overload comparison symbols. This is because Rust requires Boolean outputs from such operations, but homomorphic types return ciphertexts. Therefore, you should use the following methods, which conform to the naming conventions of Rust’s standard traits:
Supported operations:
eq
Binary
ne
Binary
gt
Binary
ge
Binary
lt
Binary
le
Binary
The following example shows how to perform comparison operations:
This document gives a high-level overview of various operations on encrypted integers supported by TFHE-rs.
TFHE-rs supports various operations on encrypted integers (Enc
) of any size between 1 and 256 bits. These operations can also work between encrypted integers and clear integers (Int
).
name
symbol
Enc
/Enc
Enc
/ Int
Neg
-
Add
+
Sub
-
Mul
*
Div
/
Rem
%
Not
!
BitAnd
&
BitOr
|
BitXor
^
Shr
>>
Shl
<<
Min
min
Max
max
Greater than
gt
Greater or equal than
ge
Less than
lt
Less or equal than
le
Equal
eq
Cast (into dest type)
cast_into
Cast (from src type)
cast_from
Ternary operator
select
This document details the string operations supported by TFHE-rs.
eq
FheAsciiString
FheAsciiString or ClearString
ne
FheAsciiString
FheAsciiString or ClearString
le
FheAsciiString
FheAsciiString or ClearString
ge
FheAsciiString
FheAsciiString or ClearString
lt
FheAsciiString
FheAsciiString or ClearString
gt
FheAsciiString
FheAsciiString or ClearString
len
FheAsciiString
is_empty
FheAsciiString
eq_ignore_case
FheAsciiString
FheAsciiString or ClearString
to_lowercase
FheAsciiString
to_uppercase
FheAsciiString
contains
FheAsciiString
FheAsciiString or ClearString
ends_with
FheAsciiString
FheAsciiString or ClearString
starts_with
FheAsciiString
FheAsciiString or ClearString
find
FheAsciiString
FheAsciiString or ClearString
rfind
FheAsciiString
FheAsciiString or ClearString
strip_prefix
FheAsciiString
FheAsciiString or ClearString
strip_suffix
FheAsciiString
FheAsci---iString or ClearString
concat
FheAsciiString
FheAsciiString
repeat
FheAsciiString
u16 or u32 or i32 or usize or (FheUint16, u16)
trim_end
FheAsciiString
trim_start
FheAsciiString
trim
FheAsciiString
replace
FheAsciiString
FheAsciiString
replacen
FheAsciiString
FheAsciiString or ClearString
u16 or u32 or i32 or usize or (FheUint16, u16)
The following example shows how to perform string operations:
This document details the Booleans operations supported by TFHE-rs.
Native homomorphic Booleans support the following common Boolean operations:
&
Binary
|
Binary
^
Binary
!
Unary
This document details the arithmetic operations supported by TFHE-rs.
Homomorphic integer types (FheUint
and FheInt
) support the following arithmetic operations:
-
Unary
+
Binary
-
Binary
*
Binary
/
Binary
%
Binary
Specifications for operations with zero:
Division by zero: returns modulus - 1.
Example: for FheUint8 (modulus = ), dividing by zero returns an ecryption of 255.
Remainder operator: returns the first input unchanged.
Example: if ct1 = FheUint8(63)
and ct2 = FheUint8(0)
, then ct1 % ct2 returns FheUint8(63).
The following example shows how to perform arithmetic operations:
*
*