TFHE-rs v0.4.0: Signed Integers and Encrypted Conditionals
This new version of TFHE-rs introduces support for signed integers, conditional instructions and significant performance improvements.
New type: FheInt
The new version of TFHE-rs now supports signed integers. Similarly to what is proposed with the [.c-inline-code]FheUint[.c-inline-code] type, the API now includes the signed integer type [.c-inline-code]FheInt[.c-inline-code]. This mimics the behavior of the classical [.c-inline-code]int[.c-inline-code] from many programming languages. In general, an unsigned integer encoded over 32-bits, like a [.c-inline-code]uint32[.c-inline-code], allows representing values between 0 and 232-1. That is, it represents integers modulo 232. When working with 32-bit signed integers, the domain becomes [-231, 231-1]. All operations available in TFHE-rs for unsigned integers are now also available for signed integers, with similar timings. Note that this is also true for operations between a ciphertext and a cleartext. Finally, casting from an [.c-inline-code]FheUint[.c-inline-code] to an [.c-inline-code]FheInt[.c-inline-code] is supported (and vice versa). By default, all precisions up to 256-bits are available. In Table 1, timings of signed operations between two ciphertexts are given:
Below we outline a small code example on how to use signed integers in the latest version of TFHE-rs:
Beyond the update of the default API (the one described in the previous example), all of the underlying APIs have been updated with this new type.
Support of conditional instructions
It is now possible to compute simple ternary homomorphic conditional instructions of the form [.c-inline-code]If...Then...Else[.c-inline-code]. The evaluated condition should be an encrypted boolean value represented as a classical [.c-inline-code]FheUint[.c-inline-code] or [.c-inline-code]FheInt[.c-inline-code]. This allows a ciphertext, or an expression, to be chosen depending on the value of the condition. The example below shows how to use this feature:
This latest release of TFHE-rs includes many performance improvements. On the low-level primitives, the programmable bootstrapping is now slightly faster. As a result, the latency of all integer operations has been reduced by approximately 8%. The practical gain depends on the operation and precision, ranging from 3 to 20%.
Some specific operations have undergone significant optimizations, such as the multiplication between a clear value and a ciphertext, which is now 30 to 50% faster.
Additionally, the division between two ciphertexts is almost twice as fast in comparison to the previous version.
- Star the TFHE-rs Github repository to endorse our work.
- Review the TFHE-rs documentation.
- Get support on our community channels.
- Help advance the FHE space with the Zama Bounty Program: Create a string library that works on encrypted data using TFHE-rs (€15,000 in prize💰)