TFHE Library
The TFHE functions can be used on encrypted data inside fhEVM. For instance, you could add 2 encrypted states together with TFHE.add(encryptedValue1, encryptedValue2)
.
To access all the TFHE functions, you can just import the library at the beginning of your solidity code:
You need to strictly use Solidity version 0.8.24 in your contracts.
Here's the list of operations:
Name | Function | Operator | Type |
---|---|---|---|
Addition |
| + | Binary |
Subtraction |
| - | Binary |
Multiplication |
| * | Binary |
Division (over plaintext denominator) |
| NA | Binary |
Remainder (over plaintext denominator) |
| NA | Binary |
BitAnd |
| & | Binary |
BitOr |
| | | Binary |
BitXor |
| ^ | Binary |
Shift Right |
| NA | Binary |
Shift Left |
| NA | Binary |
Rotate Right |
| NA | Binary |
Rotate Left |
| NA | Binary |
Supported Comparison Operations:
Name | Function | Operator | Type |
---|---|---|---|
Equal |
| NA | Binary |
Not equal |
| NA | Binary |
Greater than or equal |
| NA | Binary |
Greater than |
| NA | Binary |
Less than or equal |
| NA | Binary |
Less than |
| NA | Binary |
Min |
| NA | Binary |
Max |
| NA | Binary |
Neg |
| - | Unary |
Not |
| ~ | Unary |
The library has limited support for operator overloading; so far only +, *, &, |, ^, -, ~ are supported for all encrypted types.
More information about the supported operations can be found on the Rust FHE library from Zama: TFHE-rs
Last updated