Operations on encrypted types
Last updated
Last updated
The TFHE
library defines the following operations with FHE ciphertexts:
name | function name | symbol | type |
---|
NOTE 1: Random encrypted integers that are generated fully on-chain. Currently, implemented as a mockup by using a PRNG in the plain. Not for use in production!
NOTE 2: The shift operators
TFHE.shr
andTFHE.shl
can take any encrypted typeeuintX
as a first operand and either auint8
or aeuint8
as a second operand, however the second operand will always be computed modulo the number of bits of the first operand. For example,TFHE.shr(euint64 x, 70)
will actually be equal toTFHE.shr(euint64 x, 6)
because70 % 64 = 6
. This is in contrast to the classical shift operators in Solidity where there is no intermediate modulo operation, so for instance anyuint64
shifted right via>>
would give a null result.
Overloaded operators +
, -
, *
, &
, ... on encrypted integers are supported (). As of now, overloaded operators will call the versions without an overflow check.
More information about the supported operations can be found in the page or in the .
If you find yourself in search of a missing feature, we encourage you to for upcoming developments. Alternatively, don't hesitate to reach out to us on Discord or visit our community forum.
Add |
|
| Binary |
Sub |
|
| Binary |
Mul |
|
| Binary |
Div (plaintext divisor) |
| Binary |
Rem (plaintext divisor) |
| Binary |
BitAnd |
|
| Binary |
BitOr |
|
| Binary |
BitXor |
|
| Binary |
Shift Right |
| Binary |
Shift Left |
| Binary |
Rotate Right |
| Binary |
Rotate Left |
| Binary |
Equal |
| Binary |
Not equal |
| Binary |
Greater than or equal |
| Binary |
Greater than |
| Binary |
Less than or equal |
| Binary |
Less than |
| Binary |
Min |
| Binary |
Max |
| Binary |
Neg |
|
| Unary |
Not |
|
| Unary |
Select |
| Ternary |
Decrypt |
| Decryption |
Reencrypt |
| Reencryption |
Random unsigned int (mockup) |
| Random |