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:
We recommend to use the same solidity version (for example v0.8.24) throughout your whole project, unless you are using Foundry that can work with multiple solidity versions. In Remix you might want to stick to v0.8.24.
Here's the list of operations:
Name | Function | Operator | Type |
---|---|---|---|
Addition |
| + | Binary |
Subtraction |
| - | Binary |
Multiplication |
| * | Binary |
Division |
| NA | Binary |
Remainder |
| NA | Binary |
BitAnd |
| & | Binary |
BitOr |
| | | Binary |
BitXor |
| ^ | Binary |
Shift Right |
| NA | Binary |
Shift Left |
| NA | Binary |
And the list of comparisons:
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 a 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