Conceptio › Archive › arXiv CS
arXiv CS open access

Free-XOR TFHE via Lazy Bootstrapping

Ali Ajorian et al. · arxiv_cs
arXiv CS · Papers
Open Source ↗Direct PDF ↓
cryptographycybersecurityprivacysecurity
Gate bootstrapping (GB) is a widely used technique in FHEW-like fully homomorphic encryption schemes, such as TFHE, for evaluating Boolean gates while simultaneously reducing the noise of the resulting ciphertext. However, the computational cost of GB is typically dominated by an expensive blind rot
Conceptio Open Archive

Analyze & explore related research in Conceptio

Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.

Free-XOR TFHE via Lazy Bootstrapping Ali Ajorian

University of Basel Switzerland ali.ajorian@unibas.ch

arXiv:2610.29983v1 [cs.CR] 21 Oct 2026

Abstract Gate bootstrapping (GB) is a widely used technique in FHEWlike fully homomorphic encryption schemes, such as TFHE, for evaluating Boolean gates while simultaneously reducing the noise of the resulting ciphertext. However, the computational cost of GB is typically dominated by an expensive blind rotation (BR). [7] proposed a gate bootstrapping framework in which XOR gates can be evaluated simply by adding the two input ciphertexts, resulting in what they call freeXOR. To obtain a functionally complete set of operations, they further designed a GB procedure for evaluating AND gates using two lightweight blind rotations. In this work, we propose a similar gate bootstrapping framework that supports free evaluation of XOR gates while evaluating all symmetric binary Boolean gates, i.e., the 8 gates whose output is identical for the inputs (0, 1) and (1, 0), using two blind rotations. In addition to providing broader gate support, our construction is substantially simpler than that of [7], both conceptually and in terms of implementation. CCS Concepts: • Software and its engineering → Software organization and properties. Keywords: Fully Homomorphic Encryption, Gate Bootstrapping, Free-XOR, TFHE

1

Introduction

Fully homomorphic encryption (FHE) allows computation directly on encrypted data without decrypting it. Among FHE schemes, TFHE [11] is widely used for Boolean circuits. In the conventional TFHE approach, each bit is encrypted independently as an LWE ciphertext, and each gate is evaluated through programmable bootstrapping (PBS), which computes a function on the encrypted value while refreshing the ciphertext to control noise accumulation. PBS is one of the most expensive operations in TFHE, so the cost of evaluating a circuit is strongly influenced by the number of bootstrappings it requires. In conventional TFHE, every gate, including XOR gates, is evaluated via PBS. Chen et al. [7] proposed an approach called free-XOR, which allows XOR gates to be evaluated without PBS. This is possible because XOR corresponds to addition modulo 2, which can be implemented directly using lightweight homomorphic addition. Therefore, circuits containing many XOR gates, such as those arising in symmetric cryptography and arithmetic, can benefit significantly from this technique.

Osman Biçer

University of Basel Switzerland osman.bicer@unibas.ch Although achieving free-XOR for circuits consisting only of XOR gates is straightforward, extending the approach to support a complete set of Boolean gates is considerably more challenging. To obtain a functionally complete gate set, Chen et al. [7] proposed an algorithm for evaluating AND gates based on the NTRU hardness assumption, at the cost of two blind rotations. Our contribution. In this work, we propose a similar gate bootstrapping framework that supports free evaluation of XOR gates while evaluating all symmetric binary Boolean gates, i.e., the 8 gates whose output is identical for the inputs (0, 1) and (1, 0), using two blind rotations. Our construction is conceptually simpler than that of [7], only based on learning with error (LWE) hardness assumption, making it easier to implement. Our main ideas are as follows. • Two-bit encoding with the Free-XOR property. We encode each bit as an element of Z4 , with the least significant bit representing the encoded Boolean value. Addition modulo 4 therefore computes the XOR of the underlying bits without requiring a programmable bootstrapping (PBS). The most significant bit acts as a redundant component that can be eliminated through bootstrapping when necessary. As in conventional TFHE constructions, we also reserve a padding bit to support non-negacyclic functions during programmable bootstrapping. Additionally, we introduce headroom into the encoding to accommodate multiple consecutive XOR additions over the integers without carrying into the padding bit. Since the available headroom is bounded and the noise accumulates across successive additions, we periodically estimate headroom consumption and refresh the ciphertext when necessary. We refer to this strategy as lazy bootstrapping. • Symmetric gate evaluation with two PBS. For two input bits 𝑏 0, 𝑏 1 ∈ {0, 1} of a symmetric gate, the corresponding truth-table row can be indexed by 𝑖 = 2𝑏 0 + 𝑏 1 ∈ {0, 1, 2, 3}. Given their two-bit encoded values 𝑚 0 and 𝑚 1 , we obtain this index as 𝑖 = 2𝑚 0 + 𝜋 (𝑚 1 ) (mod 4), where 𝜋 (𝑥) = 𝑥 mod 2. The function 𝜋 is evaluated homomorphically using one PBS, yielding an encryption of the truth-table index. A second PBS then applies a lookup table representing the gate’s truth table to obtain an encryption

Ali Ajorian and Osman Biçer

of the gate output. Thus, any two-input symmetric Boolean gate can be evaluated using two PBSs. • Headroom analysis and failure probability. We analyze the constraints on the headroom, deriving a lower bound determined by the number of consecutive additions between bootstrappings and an upper bound imposed by modulus-switching noise. We also analyze the resulting failure probability to guide the selection of suitable parameters. We implemented our approach in Rust using the low-level API of TFHE-rs [21]. As expected, our experimental results show that our framework reduces circuit evaluation time compared with standard TFHE gate bootstrapping when the number of XOR gates significantly exceeds the number of symmetric gates. This improvement stems from evaluating XOR gates without programmable bootstrapping (PBS), whereas each symmetric gate requires two PBS operations. Consequently, our approach is particularly beneficial for circuits in which XOR gates dominate the gate composition. Organization. Section 2 reviews the necessary background, including LWE and GLWE encryption, programmable bootstrapping, and TFHE for Boolean circuits. Section 3 presents our free-XOR framework, including the noise analysis. Section 4 describes our implementation and experimental results. Finally, Section 5 summarizes our work.

2

Background

In this section, we introduce the fundamental concepts used throughout the rest of the paper. In particular, we describe the Learning With Errors (LWE) problem and the LWE and GLWE encryption schemes employed by TFHE. Notations. When an integer 𝑥 encodes the Boolean value false, we denote it by 𝑥. Similarly, when 𝑥 encodes true, we denote it by 𝑥. We denote polynomials by uppercase letters, whereas 𝑋 represents the indeterminate in polynomial expressions. Given a polynomial 𝑃, we denote by [𝑃] 𝑖 its coefficient of the monomial 𝑋 𝑖 . Vectors are denoted by bold characters, whereas scalars are written in non-bold characters. We use 𝑎 ← 𝐴 to denote sampling 𝑎 from a distribution or a set 𝐴. When 𝐴 is a set, the sampling is assumed to be uniform. We denote the polynomial ring Z𝑞 /(𝑋 𝑁 + 1) by R𝑞 . The expectation of a random variable 𝑋 is denoted by E[𝑋 ]. A random variable 𝑋 following a Gaussian distribution with mean 𝜇 and variance 𝜎 2 is denoted by 𝑋 ∼ N (𝜇, 𝜎 2 ). For a standard Gaussian random variable 𝑍 , we have √ Pr(|𝑍 | ≥ 𝑙) = erfc(𝑙/ 2) where, erfc stands for complementary error function, defined as erfc(𝑥) = 1 − erf (𝑥), and erf is the error function defined by ∫ 𝑥 2 2 erf (𝑥) = √ 𝑒 −𝑡 𝑑𝑡 . 𝜋 0

We use ⌊·⌉ to denote rounding to the nearest integer. The inner (dot) product of two vectors a and b is denoted by ⟨a, b⟩. 2.1

FHE

Fully homomorphic encryption (FHE), often regarded as a long-standing goal of modern cryptography, is a framework in which a function 𝑓 can be evaluated directly on a ciphertext 𝑐 encrypting a message 𝑥, producing a ciphertext that decrypts to 𝑓 (𝑥). The notion of computing on encrypted data was originally introduced as privacy homomorphism by Rivest, Adleman, and Dertouzos in 1978 [18], while the first construction supporting arbitrary-depth computation was given by Gentry nearly three decades later [14]. Before Gentry’s construction, several homomorphic encryption schemes supported restricted classes of computations. For example, RSA [19] and ElGamal [13] support a single homomorphic operation and are therefore referred to as partially homomorphic encryption (PHE). Other schemes, such as BGN [4], support both addition and multiplication, but only for circuits with a bounded multiplicative depth; these are commonly referred to as somewhat homomorphic encryption (SHE). Surveys of homomorphic encryption and its different categories can be found in [1, 16]. A fundamental limitation of early SHE schemes is that homomorphic operations, particularly multiplication, introduce noise into ciphertexts. As this noise accumulates, it eventually exceeds the decryption tolerance, causing decryption to fail. Gentry addressed this limitation by introducing bootstrapping, in which a noisy ciphertext is homomorphically decrypted using an encryption of the secret key, producing a new ciphertext encrypting the same plaintext with reduced noise. By periodically bootstrapping a ciphertext before its noise becomes too large, an encryption scheme can support arbitrarily deep computations and thereby achieve FHE. An FHE scheme only needs to support a functionally complete set of operations to evaluate arbitrary functions. Based on the type of computation they natively support, FHE schemes can be broadly divided into three categories. First, Boolean FHE schemes, such as TFHE [10] and FHEW [12], operate on Boolean values and evaluate Boolean circuits composed of functionally complete sets of gates, such as NAND alone or the combination of AND and XOR. Second, arithmetic FHE schemes, such as BGV [5] and BFV [6], support modular addition and multiplication over finite rings and are particularly well suited to arithmetic circuits and SIMDstyle batched computation. Third, approximate-arithmetic FHE schemes, such as CKKS [8], support arithmetic over approximate representations of real or complex numbers and are designed for applications in which numerical approximation is acceptable, such as statistical and machine-learning computations.

Free-XOR TFHE via Lazy Bootstrapping

FHE schemes can also be classified according to their key structure as either symmetric-key or public-key schemes. In particular, a symmetric-key FHE scheme can, under suitable constructions, be transformed into a public-key scheme [20]. 2.2

TFHE

Fast Fully Homomorphic Encryption over the Torus (TFHE) is a fully homomorphic encryption scheme known for its efficient and fast evaluation of Boolean circuits over encrypted data [11]. Its security is based on the Learning With Errors (LWE) problem, introduced by Regev [17]. 2.2.1 LWE Hardness Asuumptions. In its standard form, an LWE sample is generated as 𝑏 = ⟨a, s⟩ + 𝑒

(mod 𝑞),

where a ← Z𝑞𝑛 is sampled uniformly at random, s ← Z𝑞𝑛 is the secret vector1 , and 𝑒 ← 𝜒 is sampled from an error distri-

bution 𝜒, typically a discrete Gaussian distribution N (0, 𝜎𝑒 ). The hardness of LWE is commonly formulated in two variants: • Decision-LWE: Given samples (a, 𝑏) generated according to the LWE distribution and samples (a, 𝑢), where 𝑢 ← Z𝑞 is uniformly random, no PPT adversary can distinguish between the two distributions with more than a negligible advantage. • Search-LWE: Given polynomially many LWE samples (a𝑖 , 𝑏𝑖 ) satisfying 𝑏𝑖 = ⟨a, s⟩ + 𝑒𝑖 (mod 𝑞), recovering the secret vector s is assumed to be computationally hard.

2.2.2 LWE Encryption Scheme. To encrypt a message 𝑚 ∈ Z𝑝 , where 𝑝 ≪ 𝑞, the plaintext must first be encoded into Z𝑞 using a scaling-based encoding: 𝑞 Encode(𝑚) = Δ𝑚 + 𝑒, Δ=⌊ ⌉ 𝑝 where typically 𝑝 |𝑞 and 𝑒 ← 𝜒 is an error. This encoding maps consecutive plaintext values in Z𝑝 to points in Z𝑞 separated by approximately Δ. The resulting spacing provides room to place the error 𝑒 introduced by LWE2 . This noisy encoding Δ𝑚 + 𝑒 (mod 𝑞) is known as ciphertext phase. Decoding this value gives Δ𝑚 + 𝑒 𝑒 ⌉ = 𝑚 + ⌊ ⌉. Decode(Δ𝑚 + 𝑒) = ⌊ Δ Δ Since the error distribution 𝜒 has unbounded support, correct decoding is not guaranteed for every sample. Instead, 𝜎𝑒 is chosen such that the probability of |𝑒 | ≥ Δ/2 is negligible. Consequently, ⌊𝑒/Δ⌉ = 0 with overwhelming probability, and the decoding correctly recovers 𝑚. Assuming 1 Usually, the secret vector is sampled as a binary vector s ← {0, 1} 𝑛 .

2 Each element of Z can be represented using log (𝑞) bits, whereas a 𝑞 2 message in Z𝑝 requires log2 (𝑝 ) bits. The scaling effectively places the message in the most significant bits of the representation in Z𝑞 , leaving the remaining lower bits to accommodate the noise.

𝑒 ∼ N (0, 𝜎𝑒2 ) and letting 𝑍 ∼ N (0, 1),    Δ 𝑃fail = Pr |𝑒 | ≥ Δ/2 = Pr |𝑍 | ≥ =𝑙 2𝜎𝑒 √ and therefore 𝑃fail = erfc(𝑙/ 2). This gives the decoding failure probability for the parameters 𝑞, 𝑝 and 𝜎𝑒 . The noisy-encoded plaintext is incorporated into an LWE ciphertext by adding the inner product of a uniformly random vector and a secret key:   Enc(s, 𝑚) = (a, 𝑏) = a ← Z𝑞𝑛 , ⟨a, s⟩ + Δ𝑚 + 𝑒 (mod 𝑞) where s is a secret key sampled uniformly at random from Z𝑞𝑛 . The vector a and the scalar 𝑏 are referred to as the mask and body, respectively. In the rest of the paper, we denote Enc(s, 𝑚) by LWE(Δ𝑚) interchangeably. Given a ciphertext LWE(Δ𝑚) = (a, 𝑏), decryption first removes the contribution of the secret key: Dec(s, a, 𝑏) = 𝑏 − ⟨a, s⟩ = Δ𝑚 + 𝑒

(mod 𝑞)

The plaintext is then recovered by applying the decoding function: 𝑚 = Decode(Δ𝑚 + 𝑒) which correctly recovers 𝑚 with overwhelming probability. Homomorphic Operations. To add two messages homomorphically in the ciphertext space, it is sufficient to add their corresponding ciphertexts component-wise. Similarly, multiplying a plaintext scalar 𝛼 by all components of a ciphertext corresponding to a message 𝑚 results in a ciphertext corresponding to 𝛼𝑚. Homomorphic multiplication of two ciphertexts, however, is not simply performed by componentwise multiplication of two LWE ciphertexts and requires additional techniques. We refer to [15] for a detailed treatment of homomorphic operations. A sequence of homomorphic operations causes the noise in a ciphertext to accumulate. As the noise increases, the resulting ciphertext may eventually violate the condition |𝑒 | < Δ/2, making correct decryption impossible. To prevent this, a bootstrapping operation can be performed before the noise becomes too large. Bootstrapping reduces the noise in a ciphertext and produces a refreshed ciphertext that can be used for further homomorphic computation. In TFHE, bootstrapping can additionally evaluate a function on the encoded plaintext while simultaneously reducing the ciphertext noise. This technique, known as programmable bootstrapping, allows a single bootstrapping operation to perform both noise reduction and function evaluation. Programmable bootstrapping is discussed in Section 2.3. 2.2.3 GLWE Encryption Scheme. The LWE encryption scheme can be generalized to the General Learning With Errors (GLWE) scheme by replacing the underlying space Z𝑞 with a polynomial ring R𝑞 = Z𝑞 [𝑋 ]/(𝑋 𝑁 + 1). In GLWE, the secret key S and the mask A are vectors of polynomials in R𝑞𝑛 , while the message 𝑀 and the error 𝐸 are polynomials

Ali Ajorian and Osman Biçer

in the same ring. Specifically, for a message 𝑀 ∈ R𝑝 , where 𝑝 ≪ 𝑞, the encryption is defined as   Enc(S, 𝑀) = (A, 𝐵) = A ← R𝑞𝑘 , ⟨A, S⟩ + Δ𝑀 + 𝐸 , where S ∈ R𝑞𝑘 is the secret key, Δ = ⌊𝑞/𝑝⌉ is the scaling factor, and 𝐸 ∈ R𝑞 is an error polynomial whose coefficients are sampled from an error distribution 𝜒. In the rest of the paper, Enc(S, 𝑀) is denoted by GLWE(Δ𝑀) interchangeably. Given a ciphertext GLWE(Δ𝑀) = (A, 𝐵), decryption first removes the contribution of the secret key: Dec(S, A, 𝐵) = 𝐵 − ⟨A, S⟩ = Δ𝑀 + 𝐸

(mod 𝑞, 𝑋 𝑁 + 1).

The resulting noisy encoded message is then decoded coefficientwise by Δ𝑀 + 𝐸 Decode(Δ𝑀 + 𝐸) = ⌊ ⌉. Δ In some applications, a polynomial 𝑀 needs to be represented in the form of a GLWE ciphertext without introducing encryption noise or hiding the polynomial. In this case, the mask is set to zero, i.e., A = 0, and the body is set to 𝐵 = Δ𝑀. This representation is called a trivial encryption of 𝑀 and is denoted by(0, Δ𝑀). Sample Extraction. Given a GLWE ciphertext C ∈ R𝑞𝑘+1 encrypting a polynomial 𝑀=

𝑁 −1 ∑︁

𝑚𝑖 𝑋 𝑖 ∈ Z𝑞 /(𝑋 𝑁 + 1),

𝑖=0

one can homomorphically construct an LWE ciphertext c ∈ Z𝑞𝑛+1 , where 𝑛 = 𝑘𝑁 , encrypting a selected coefficient 𝑚𝑖 of 𝑀. This can be achieved by appropriately selecting and rearranging coefficients of the GLWE ciphertext C to form the LWE ciphertext c. Consequently, the secret key of c, known as the extracted secret key, is obtained by flattening the coefficients of the GLWE secret key: s = (𝑠 0,0, . . . , 𝑠 0,𝑁 −1, . . . , 𝑠𝑘 −1,0, . . . , 𝑠𝑘 −1,𝑁 −1 ) ∈ Z𝑞𝑘𝑁 . This operation is called sample extraction [11] and is denoted by Ext(C, 𝑖) = LWE(Δ𝑚𝑖 ) ∈ Z𝑞𝑘𝑁 +1 . Key Switching. A key-switching operation is a homomorphic operation that takes as input a ciphertext c𝑘1 , encrypted under a key 𝑘 1 , together with an encryption of every component of 𝑘 1 under a (possibly different) key 𝑘 2 , and produces a ciphertext c𝑘2 encrypting the same underlying message under 𝑘 2 . The set of ciphertexts encrypting the elements of 𝑘 1 under 𝑘 2 is called the key-switching key (KSK). The operation is denoted by: KSw(c𝑘1 , KSK) = c𝑘2 . The general idea is to homomorphically cancel 𝑘 1 out of the ciphertext using the encryption of 𝑘 1 under 𝑘 2 , yielding a ciphertext under 𝑘 2 . Several types of key switching are used in practice, including LWE-to-LWE, GLWE-to-GLWE, LWE-to-GLWE, and many-LWE-to-one-GLWE [9].

Blind Rotation. Homomorphic polynomial rotation has several applications, particularly in programmable bootstrapping. In the plaintext domain, rotating the coefficients of a polynomial 𝑀 by 𝑡 positions corresponds to multiplying 𝑀 by 𝑋 −𝑡 . When 𝑀 belongs to the polynomial ring R𝑞 = Z𝑞 /(𝑋 𝑁 + 1), this operation has two important properties: 1. Periodicity modulo 2𝑁 . Since 𝑋 𝑁 = −1, we have 𝑋 2𝑁 = 1. Therefore, the rotation exponent is interpreted modulo 2𝑁 , and we can restrict the rotation position to 0 ≤ 𝑡 < 2𝑁 . 2. Negacyclicity.3 Since 𝑋 𝑁 = −1, 𝑋 −𝑁 = −1 as well4 . Consequently, 𝑋 − (𝑡 +𝑁 ) 𝑀 (𝑋 ) = 𝑋 −𝑁 𝑋 −𝑡 𝑀 (𝑋 ) = −𝑋 −𝑡 𝑀 (𝑋 )

(mod 𝑋 𝑁 + 1).

Thus, rotating by an additional 𝑁 positions negates the resulting polynomial. Given a GLWE ciphertext C encrypting a polynomial 𝑀 ∈ R𝑞 and an LWE ciphertext c = (a, 𝑏) encrypting a rotation position 𝑡 ∈ {0, . . . , 2𝑁 −1} under the secret key s, TFHE homomorphically computes a GLWE ciphertext C′ ∈ R𝑞𝑘+1 encrypting the rotated polynomial. This operation is called blind rotation because the rotation is performed without revealing the encrypted position 𝑡. It relies on GLWE encryptions of the individual secret-key components 𝑠𝑖 , which collectively form the blind rotation key (BRK). The operation is denoted by BRot(BRK, C, c) = C′ ∈ R𝑞𝑘+1 . To understand how blind rotation is performed, recall that the LWE ciphertext satisfies 𝑏−

𝑛−1 ∑︁

𝑎𝑖 𝑠𝑖 = Δ𝑡 + 𝑒

(mod 𝑞),

𝑖=0

The rotation position is therefore represented by a noisy encoding in Z𝑞 , rather than being available directly as a plaintext integer. TFHE uses modulus switching to map the ciphertext components from Z𝑞 to the rotation-exponent domain modulo 2𝑁 . At the algebraic level, the underlying decomposition is Í𝑛−1

𝑋 𝑖=0 𝑎𝑖 𝑠𝑖 −𝑏 𝑀 = 𝑋 −𝑏 𝑀

𝑛−1 Ö

𝑋 𝑎𝑖 𝑠𝑖 .

𝑖=0

This decomposition consists of an initial rotation determined by −𝑏, followed by conditional rotations: for each 𝑖, the polynomial is rotated by 𝑎𝑖 when 𝑠𝑖 = 1 and remains unchanged when 𝑠𝑖 = 0. The BRK enables these conditional rotations to 3 A function 𝑓 is called negacyclic when for all 𝑥 ∈ 𝐷

𝑓 it satisfies 𝑓 (𝑥 +𝑁 ) = −𝑓 (𝑥 ). 4 Since 𝑋 𝑁 = −1, we have 1 = 𝑋 0 = 𝑋 𝑁 −𝑁 = 𝑋 𝑁 · 𝑋 −𝑁 = −1 · 𝑋 −𝑁 = −𝑋 −𝑁 , and hence 𝑋 −𝑁 = −1.

Free-XOR TFHE via Lazy Bootstrapping

be evaluated homomorphically without revealing the secretkey bits. Blind rotation is therefore a central and computationally expensive operation in TFHE. 2.3

Programmable Bootstrapping (PBS)

Introduced by Gentry [14], bootstrapping reduces the noise accumulated in a ciphertext through a sequence of homomorphic operations by homomorphically evaluating its decryption function, using a homomorphic encryption of the secret key. The resulting ciphertext encrypts the same underlying plaintext, while its noise is essentially independent of the noise in the input ciphertext. TFHE further allows a target function ℎ to be evaluated during bootstrapping, i.e., PBS(LWE(Δ𝑚)) = LWE(Δℎ(𝑚)), by encoding ℎ into a polynomial called a test polynomial. We first elaborate on test polynomials in Section 2.3.1 and then provide further details on the operation of PBS in Section 2.3.2. 2.3.1 Test Polynomial and Lookup Table (LUT). Consider a polynomial 𝑉 ∈ Z𝑞 /(𝑋 𝑁 + 1) as 𝑉 (𝑥) =

𝑁 −1 ∑︁

𝑣𝑖 𝑋 𝑖 ,

𝑣𝑖 ∈ Z𝑞

𝑖=0

and define the following function for each 𝑡 ∈ Z2𝑁   𝜓𝑉 (𝑡) ≜ 𝑋 −𝑡 𝑉 (𝑋 ) 0 (mod 𝑋 𝑁 + 1) That is, 𝜓𝑉 (𝑡) rotates 𝑉 by 𝑡 positions via multiplying it by the monomial 𝑋 −𝑡 and extracts the constant coefficient of the result. In the ciphertext domain, 𝑉 is represented as a GLWE trivial encryption, the multiplication is performed via a blind rotation, and the constant coefficient is extracted via sample extraction. As discussed in the context of blind rotation, the operation 𝑋 −𝑡 𝑉 (𝑋 ) in R𝑞 is negacyclic, therefore 𝜓𝑉 (𝑡) for 𝑡 < 𝑁 samples the 𝑡-th coefficient of 𝑉 , while for 𝑡 ≥ 𝑁 it samples the negative of the coefficient at position 𝑡 − 𝑁 , namely: ( 𝑣𝑡 0≤𝑡 <𝑁 𝜓𝑉 (𝑡) = −𝑣𝑡 −𝑁 𝑁 ≤ 𝑡 < 2𝑁 Note that the coefficients 𝑣 0, . . . , 𝑣 𝑁 −1 of 𝑉 remain free and unconstrained, while the generated length-2𝑁 sequence 𝜓𝑉 (0),𝜓𝑉 (1), . . . ,𝜓𝑉 (2𝑁 − 1) is negacyclic, with its second half equal to the negation of its first half. A negacyclic function 𝑓 : Z2𝑁 → Z𝑞 can be encoded by 𝜓𝑉 using the polynomial 𝑉 (𝑋 ) =

𝑁 −1 ∑︁

𝑓 (𝑖)𝑋 𝑖

(1)

𝑖=0

which satisfies 𝑓 (𝑚) = 𝜓𝑉 (𝑚) and can be computed homomorphically via a blind rotation followed by a sample extraction. Such a polynomial is called a test polynomial and can be represented as a lookup table containing 𝑁 entries,

each corresponding to one of its coefficients. We refer to such a function 𝑓 as LUT function. Negacyclicity is a structural property of 𝑓 and cannot be circumvented: a non-negacyclic function on domain Z2𝑁 has no test-polynomial encoding. However, any function 𝑔 : 𝐷 → Z𝑞 with 𝐷 ⊆ Z𝑁 can still be encoded, by defining a negacyclic 𝑓 : Z2𝑁 → Z𝑞 as   𝑔(𝑖) 𝑖∈𝐷    𝑓 (𝑖) ≜ −𝑔(𝑖 −𝑁 ) 𝑖 − 𝑁 ∈ 𝐷 (2)   0 o.w.  This works precisely because the target domain 𝐷 ⊆ Z𝑁 never reaches the second half of Z2𝑁 . Consequently, under this construction every valid input 𝑚 to 𝑓 has its most significant bit equal to zero — so at the design level, one padding bit must be reserved for the input 𝑚, and no sequence of operations may ever carry into it. Recoding Input via Modulo Switching. To evaluate𝜓𝑉 (𝑡) on an LWE ciphertext encoding Δ𝑚 + 𝑒 ∈ Z𝑞 , its value must be recoded into the index range [0, 2𝑁 ). Direct reduction modulo 2𝑁 is unsuitable because it retains low-order bits, which primarily contain noise, while discarding the highorder bits encoding the message. Instead, we use modulus switching [6, 9] to change the modulus from 𝑞 to 2𝑁 . Given an LWE ciphertext (𝑎 1, . . . , 𝑎𝑛 , 𝑏), modulus switching scales and rounds each component:   2𝑁 2𝑁 2𝑁 ˜ (𝑎˜1, . . . , 𝑎˜𝑛 , 𝑏) = ⌊𝑎 1 ⌉, . . . , ⌊𝑎𝑛 ⌉, ⌊𝑏 ⌉ 𝑞 𝑞 𝑞 Consequently, the encoded message is rescaled from Δ = 𝑞/𝑝 to Δ̃ = 2𝑁 /𝑝:   𝑞 2𝑁 2𝑁 2𝑁 2𝑁 (Δ𝑚 + 𝑒) = 𝑚 +𝑒 = 𝑚+ 𝑒 = Δ̃𝑚 + 𝑒 ′, 𝑞 𝑝 𝑞 𝑝 𝑞 where 𝑒 ′ = (2𝑁 /𝑞)𝑒 is the scaled noise, ignoring rounding errors. Thus, modulus switching preserves the message encoding while mapping it to the desired index range. Denoting rounding errors by 𝜀𝑖 = 𝑎˜𝑖 − 2𝑁 𝑞 𝑎𝑖 and 𝜀𝑏 = 2𝑁 ˜ 𝑏 − 𝑏, the phase of the switched ciphertext is 𝑞

𝑏˜ −

𝑛 ∑︁

𝑠𝑖 𝑎˜𝑖 = Δ̃𝑚 + 𝑒 ′ + 𝑒 ms,

𝑒 ms = 𝜀𝑏 −

𝑛 ∑︁

𝑠𝑖 𝜀𝑖 .

𝑖=1

𝑖=1

Each rounding error is modeled as independent and uniform on [−1/2, 1/2], so it has mean 0 and variance 1/12. Hence, ! 𝑛 ∑︁ ∑︁ Var(𝑒 ms ) = Var 𝜀𝑏 − 𝑠𝑖 𝜀𝑖 = Var(𝜀𝑏 ) + Var(𝜀𝑖 ) 𝑖=1

𝑖: 𝑠𝑖 =1

1 +𝑢 = 12 where 𝑢 denotes the number of elements in the secret key for which 𝑠𝑖 = 1. For a uniformly random binary key, E[𝑢] = 𝑛/2,

Ali Ajorian and Osman Biçer

hence

𝑛+2 2 𝜎ms ≈ .

24 The error 𝑒 ′ already present before the rounding has standard deviation 2𝑁 𝑞 𝜎𝑒 , where 𝜎𝑒 is the standard deviation of 𝑒. Since 𝑒 ′ and 𝑒 ms are independent, the total error 𝐸 = 𝑒 ′ + 𝑒 ms seen by 𝜓𝑉 has standard deviation √︂  2 𝑛 + 2 2𝑁 𝜎𝐸 = 𝜎 + . (3) 𝑒 𝑞 24 Consecutive messages are Δ̃ = 2𝑁 /𝑝 positions apart, so decoding is correct if and only if |𝐸| < Δ̃/2 = 𝑁 /𝑝. Modeling the total error as Gaussian distribution 𝐸 ∼ N (0, 𝜎𝐸2 ) 5 and denoting 𝑍 = 𝜎𝐸𝐸 ∼ N (0, 1), the failure probability is   𝑁 𝑁 𝑃 fail = Pr |𝐸| ≥ = Pr (|𝑍 | ≥ 𝑙) , 𝑙= 𝑝 𝑝𝜎𝐸 √ Since 𝑃fail = erfc(𝑙/ 2), a target negligible failure probability determines 𝑙. For given 𝑁 , 𝑛, and 𝜎𝑒 , the plaintext modulus must therefore satisfy 𝑁 𝑁 ≥ 𝑙 =⇒ 𝑝 ≤ . (4) 𝑝𝜎𝐸 𝑙𝜎𝐸 Designing Test Polynomials. At the design level, we aim to evaluate ℎ : Z𝑝 → Z𝑝 , whereas 𝜓𝑉 implements 𝑓 : Z2𝑁 → Z𝑞 . This mismatch is addressed by adjusting the input and output encodings. Since 𝑝 ≪ 𝑁 , each plaintext 𝑚 ∈ Z𝑝 corresponds to a block of Δ̃ = 2𝑁 /𝑝 consecutive indices in Z2𝑁 . The input message associated with an index 𝑡 is therefore 𝑡 𝑡 𝑚=⌊ ⌉=⌊ ⌉. 2𝑁 /𝑝 Δ̃ To ensure valid ciphertext encoding, each output ℎ(𝑚) is scaled by Δ. Accordingly, the 2𝑁 indices are partitioned into 2𝑝 blocks of Δ̃ = 𝑁 /𝑝 elements each, with every index in a block assigned the same scaled output. For a function compatible with negacyclic evaluation, the corresponding test polynomial is   𝑁 −1 ∑︁ 𝑖 𝑉 (𝑋 ) = Δℎ ⌊ ⌉ 𝑋𝑖. (5) 𝑁 /𝑝 𝑖=0 Non-negacyclic functions can be handled using the technique described in Equation 2. 2.3.2 How PBS Works. To bootstrap a ciphertext c = LWE(Δ𝑚) encrypted under a secret key s = (𝑠 1, . . . , 𝑠𝑛 ) and containing accumulated error 𝑒, TFHE requires a bootstrapping key (BSK). The BSK is actually a blind rotation key consists of a collection of GLWE ciphertexts under an encryption key S′ , with one ciphertext associated with each 5 By the central limit theorem, since 𝐸 is a sum of several independent

random variables, namely 𝐸 = 𝑒 ′ + 𝜀𝑏 − by a Gaussian distribution.

𝑖=1 𝑠𝑖 𝜀𝑖 , it can be approximated

Í𝑛

component of the input LWE secret key. These ciphertexts enable the components 𝑠𝑖 of the input secret key to be used homomorphically during the blind rotation. We refer to [9] for details on the construction of the BSK. Given c, the BSK, and a trivial GLWE encryption of a test polynomial 𝑉 corresponding to a target negacyclic function ℎ 6 , TFHE homomorphically evaluates 𝜓𝑉 (𝑡), where 𝑡 = (2𝑁 /𝑞) · (Δ𝑚 + 𝑒), to obtain a ciphertext LWE(Δℎ(𝑚)). This proceeds as follows: 1. Obtain LWE(Δ𝑡) via modulus switching, i.e., by scaling all components of c by 2𝑁 /𝑞 and rounding the results. 2. Compute 𝑋 −𝑡 𝑉 (𝑋 ) homomorphically via a blind rotation, which takes GLWE(Δ𝑉 ), LWE(Δ𝑡), and the BSK as input and outputs a GLWE encryption of 𝑋 −𝑡 𝑉 (𝑋 ), denoted by C′ . In otherwords, C′ = BRot(BSK, C, c) This ciphertext is encrypted under the key S′ by which BSK is generated. 3. Extract the constant coefficient of C′ as an LWE ciphertext, yielding an LWE encryption of ℎ(𝑚), via sample extraction operator Ext(C′, 0) = c′ ∈ Z𝑞𝑘𝑁 +1 . As discussed in Section 2.2.3, this extracted ciphertext is under a key s′ ∈ Z𝑞𝑘𝑁 obtained by flattening of S′ . 4. Having an appropriate LWE to LWE key-switching key 𝐾𝑆𝐾 from s′ to s, switch the encryption key of c′ from s′ back to s via a key-switching operation as KSw(c′, 𝐾𝑆𝐾) = c′′ ∈ Z𝑞𝑛+1 c′′ will be LWE(Δℎ(𝑚)). Note that no modulus switching from 2𝑁 back to 𝑞 is needed. Although the input to the blind rotation is represented modulo 2𝑁 , the test polynomial GLWE(Δ𝑉 ) itself lives in Z𝑞 [𝑋 ]/(𝑋 𝑁 + 1) throughout the computation. Consequently, the sample-extracted LWE ciphertext is already defined modulo 𝑞 and is therefore a valid LWE ciphertext. 2.3.3 TFHE Boolean Circuits. In TFHE, Boolean values are encrypted as LWE ciphertexts, and binary gates can be evaluated homomorphically by applying a programmable bootstrapping (PBS) to an appropriate linear combination of the input ciphertexts. The linear combination depends on the Boolean function to be evaluated, while the PBS evaluates a corresponding look-up table (LUT) and simultaneously reduces the ciphertext noise. This process is commonly referred to as gate bootstrapping. In particular, all standard binary Boolean gates, such as AND, OR, XOR, NAND, and NOR, can be evaluated in this way [11]. A natural starting point for Boolean values is to set 𝑝 = 2 for a chosen ciphertext modulus 𝑞. According to the encoding introduced in Section 2.2.2, this gives Δ = 𝑞/𝑝 = 𝑞/2 and the two Boolean messages are encoded as Encode(𝑚) = Δ𝑚, 6 One can instead hide 𝑉 by encrypting it as a non-trivial GLWE ciphertext.

Free-XOR TFHE via Lazy Bootstrapping

that is, Encode(0) = 0 and Encode(1) = 𝑞/2. However, the linear combination of two such encoded values needs at least two bits of precision to remain distinguishable, so a larger 𝑝 must be chosen. Moreover, the underlying function ℎ : Z𝑝 → Z𝑝 whose test polynomial realizes a given gate type is not negacyclic, so, as stated in Section 2.3, padding bits are needed. An alternative, the shifted encoding [9–11], is defined as 𝑞 Δ Encode(𝑚) = − + 𝑚, Δ = 𝑞/2, 8 2 which gives Encode(0) = −𝑞/8 and Encode(1) = 𝑞/8. Under this encoding, boolean values take the form of a negative/positive sign representation, which makes gate bootstrapping more convenient. Here the LUT function is a sign function on the rotation index, 𝑞   𝑥<0 −  8 sgn(𝑥) = 𝑞  + 𝑥 ≥ 0,  8 Í𝑁 −1 𝑞 𝑖 whose corresponding test polynomial is 𝑉 (𝑋 ) = 𝑖=0 8𝑋 . Since sgn is negacyclic, no padding bit is required. It is then sufficient to define, for each gate type, a linear combination of the encoded inputs that sgn maps to the correct output. For example, as shown in Table 1, the combination Encode(𝑢) + Encode(𝑣) + 𝑞/8 evaluates the OR gate: sgn(−𝑞/8) = −𝑞/8 encodes 0, while sgn(𝑞/8) = sgn(3𝑞/8) = 𝑞/8 encodes 1. 𝑢 𝑣 𝑈 =Encode(𝑢) 𝑉 =Encode(𝑣) 𝑈 +𝑉 +𝑞/8 false false −𝑞/8 −𝑞/8 −𝑞/8 false true −𝑞/8 +𝑞/8 +𝑞/8 true false +𝑞/8 −𝑞/8 +𝑞/8 true true +𝑞/8 +𝑞/8 +3𝑞/8 Table 1. Linear combination used for OR gate bootstrapping with the shifted Boolean encoding. Similarly, the combination Encode(𝑢) + Encode(𝑣) − 𝑞/8 is the right choice for AND gates, as shown in Table 2. 𝑢 𝑣 𝑈 =Encode(𝑢) 𝑉 =Encode(𝑣) 𝑈 +𝑉 −𝑞/8 false false −𝑞/8 −𝑞/8 −3𝑞/8 false true −𝑞/8 +𝑞/8 −𝑞/8 true false +𝑞/8 −𝑞/8 −𝑞/8 true true +𝑞/8 +𝑞/8 +𝑞/8 Table 2. Linear combination used for AND gate bootstrapping with the shifted Boolean encoding.

3 Free-XOR Gate Bootstrapping Framework For a circuit consisting only of XOR gates, an encoding with 𝑝 = 2 is sufficient, as XOR can be obtained simply by homomorphically adding the two input ciphertexts. This works

because XOR is equivalent to addition modulo 2, which the encoding preserves automatically, without requiring bootstrapping to evaluate nonlinear operations. Moreover, the noise grows relatively slowly, so many common circuits can be evaluated without bootstrapping for noise reduction. Specifically, after 𝑘 XORs the ciphertext contains 𝑘 + 1 independent encryption noises, each with standard deviation 𝜎𝑒√, so the total noise 𝐸 is approximately Gaussian with 𝜎𝐸 = 𝑘 + 1 𝜎𝑒 . Decryption fails when 𝐸 is at least half a step, Δ/2 = 𝑞/(2𝑝) = 𝑞/4, hence 𝑃fail = Pr(|𝐸| ≥ Δ/2) = Pr(|𝑍 | ≥ 𝑞/4𝜎𝐸 ) 𝑞 = Pr(|𝑍 | ≥ 𝑙) , 𝑙= √ 4 𝑘 + 1 𝜎𝑒 where 𝑍 ∼ N (0, 1). For a target failure probability 2−𝛼 , let 𝑧𝛼 be the value satisfying Pr(|𝑍 | ≥ 𝑧𝛼 ) = 2−𝛼 . Requiring 𝑙 ≥ 𝑧𝛼 gives the maximal number of XORs, 2  𝑞 (6) 𝑙 ≥ 𝑧𝛼 =⇒ 𝑘 + 1 ≤ 4 𝑧𝛼 𝜎𝑒 Example. Take the modulus 𝑞 = 264 and a noise standard deviation 𝜎𝑒 = 247 , which is of the order commonly used for LWE ciphertexts with a dimension of a few hundred7 . Then 𝑞/(4𝜎𝑒 ) = 264 /(22 · 247 ) = 215 and the bound becomes  15  2 2 1.07 × 109 . 𝑘 +1≤ ≈ 𝑧𝛼 𝑧𝛼2 For 𝛼 = 40 we have 𝑧𝛼 ≈ 7.2, which gives 1.07 × 109 ≈ 2 × 107 . 7.22 Thus about twenty million XORs can be chained while keeping the failure probability below 2−40 . For 𝛼 = 64 (𝑧𝛼 ≈ 9.1) the bound is about 1.3 × 107 . 𝑘 +1≤

3.1

Supporting Other Boolean Gate Types

For circuits with other types of binary gates the situation is different. A linear combination of two input ciphertexts, which TFHE handles very efficiently, cannot implement a non-linear gate such as AND or OR. Instead, the gate is implemented by a programmable bootstrapping applied to an appropriate linear combination of the inputs. For bits 𝑏 0, 𝑏 1 ∈ {0, 1}, the linear combination 𝑖 (𝑏 0, 𝑏 1 ) = 2𝑏 1 + 𝑏 0 ∈ {0, 1, 2, 3}

(7)

uniquely identifies the input pair, as shown in Table 3. Thus, the index 𝑖 identifies the corresponding row in the truth table of the target gate. This design supports only eight of the sixteen possible binary Boolean gates: AND, NAND, OR, NOR, XOR, XNOR, FALSE, and TRUE. These gates produce the same output for the input pairs (0, 1) and (1, 0). Consequently, their outputs can be determined from either index convention, 𝑖 = 2𝑏 1 + 𝑏 0 or 𝑖 = 2𝑏 0 + 𝑏 1 . The remaining eight 7 It is common to give 𝜎 as a fraction of the modulus 𝑞; here 𝜎 /𝑞 = 2 −17 . 𝑒 𝑒

Ali Ajorian and Osman Biçer

gates distinguish these two input pairs and are therefore not supported by our design. For a gate type T, we define a function gT : Z4 → Z2 whose output matches the truth table of that gate, i.e., 𝑇 (𝑏 0, 𝑏 1 ) = gT (𝑖 (𝑏 0, 𝑏 1 )). Homomorphically evaluating 𝑖 and then applying programmable bootstrapping with a lookup table (LUT) representing gT yields the correct gate output. We call gT the gate characteristic function for a gate T. 𝑏 1 𝑏 0 𝑖 = 2𝑏 1 + 𝑏 0 gAND gOR 0 0 0 0 0 0 1 1 0 1 1 0 2 0 1 1 1 3 1 1 Table 3. Truth-table indices and corresponding output functions for AND and OR gates. 3.1.1 Encoding. We need a mapping8 for each bit 𝑏 that supports Free-XOR while also allowing the index 𝑖 in Equation 7 to be computed efficiently. A two-bit mapping whose least significant bit equals 𝑏 achieves the Free-XOR property and, with programmable bootstrapping, also supports the computation of 𝑖. Specifically, 𝑏 = 0 is mapped to the bit patterns 00 and 10, denoted by 0 and 2, respectively, whereas 𝑏 = 1 is mapped to 01 and 11, denoted by 1 and 3, respectively. Formally, the mapping is given by 𝜋 : Z4 → Z2 , where 𝜋 (𝑚) = 𝑚 mod 2 is the parity of 𝑚, i.e., whether 𝑚 is even or odd. With a slight abuse of notation, we denote the canonical representatives 0 and 1 by 𝜋 −1 (0) and 𝜋 −1 (1) respectively. We define a function 𝐼 : Z24 → Z4 that computes the index 𝑖 from Equation 7 for any pair of mapped inputs: 𝐼 (𝑚 0, 𝑚 1 ) ≜ 2𝑚 0 + 𝜋 (𝑚 1 )

(mod 4),

(8)

where 𝜋 (𝑥) = 𝑥 mod 2. Thus, for a gate type T with characteristic function gT , the output for encoded inputs 𝑚 0, 𝑚 1 ∈ Z4 is given by T(𝜋 (𝑚 0 ), 𝜋 (𝑚 1 )) = gT (𝐼 (𝑚 0, 𝑚 1 )).

(9)

To demonstrate the Free-XOR property and compatibility with Equation 7, we introduce a table over the mapping space that we call the modulo table. It contains 16 rows, one for each pair of values 𝑚 0, 𝑚 1 ∈ Z4 . Each input pair in the Boolean truth table corresponds to four rows in the modulo table, since each bit has two possible representations. We call these four rows an equivalent chunk. For example, the input pair (1, 0) corresponds to the four pairs (1, 0),

(1, 2),

(3, 0),

(3, 2).

Accordingly, the modulo table is partitioned into four equivalent chunks, denoted by 𝑄 0, 𝑄 1, 𝑄 2, 𝑄 3 , corresponding to the Boolean input pairs (0, 0), (0, 1), (1, 0), (1, 1), respectively. 8We avoid the term encoding here because TFHE uses it to refer to the

scaling-by-Δ operation.

Table 4. The mapping 𝜋 achieves free-XOR by addition modulo 4. The index 𝑖 is obtained as 𝐼 (𝑚 0, 𝑚 1 ) = 2𝑚 0 + 𝜋 (𝑚 1 ), where 𝜋 (𝑚) = 𝑚 mod 2. 𝑚 0 𝑚 1 𝑚 0 +𝑚 1 𝜋 (𝑚 0 ) 𝜋 (𝑚 1 ) 𝜋 (𝑚 0 +𝑚 1 ) 2𝑚 0 +𝜋 (𝑚 1 ) 0 0 0 0 0 0 0 0 2 2 0 0 0 0 2 0 0 0 0 0 0 2 2 0 0 0 0 0 0 1 1 0 1 1 1 3 0 1 1 1 0 3 2 1 3 0 1 1 1 2 3 1 0 1 1 1 1 0 1 1 0 1 2 1 2 3 1 0 1 2 3 0 3 1 0 1 2 3 2 1 1 0 1 2 1 1 2 1 1 0 3 1 3 0 1 1 0 3 3 1 0 1 1 0 3 3 3 2 1 1 0 3

Table 4 shows that addition modulo 4 preserves the FreeXOR property for all 16 pairs of mapped values 𝑚 0, 𝑚 1 ∈ Z4 . It also shows that the function 𝐼 computes the index 𝑖 from Equation 7. Padding Bit and Headroom. The difficulty in our approach is that for the gate types AND, NAND, OR, and NOR the corresponding function gT is not negacyclic. In particular, as shown in Table 3, gAND (3) = 1 ≠ −gAND (1) = 0 and gOR (0) = 0 ≠ −gOR (2) = 1, whereas negacyclicity requires gT (𝑖 + 2) = −gT (𝑖). Therefore, as discussed in Section 2.3.1, a padding bit must be reserved. This bit, however, breaks the mod 4 arithmetic that our encoding previously provided automatically. To address this problem, in addition to the padding bit, we reserve a headroom in our encoding to keep the intermediate values obtained from a sequence of additions (XOR gates) away from the padding bit. For a headroom 𝐻 > 4, each intermediate value 𝑣 ∈ Z𝐻 is encoded as Δ𝑣 with Δ = 𝑞/(2𝐻 ). The factor of 2 accounts for the reserved padding bit: the lower half of Z𝑞 holds 𝐻 distinct values and the upper half is the padding. Additions are then performed over the integers instead of modulo 4, and no wrap-around occurs as long as the value stays below 𝐻 . Whenever a gate requires the non-linear function gT , programmable bootstrapping is applied using the LUT 𝑥 → gT (𝑥 mod 4), defined over the entire range [0, 𝐻 ). Similarly, when the value approaches 𝐻 , programmable bootstrapping is applied using the LUT 𝑥 → 𝜋 (𝑥 mod 4) to obtain a fresh ciphertext.

Free-XOR TFHE via Lazy Bootstrapping

Choosing Headroom. A larger headroom allows more XORs between bootstrappings, but it is limited by the modulus switching error 𝜎𝐸 of Equation (3). With the padding bit the plaintext modulus is 𝑝 = 2𝐻 , so the condition 𝑝 ≤ 𝑁 /(𝑙𝜎𝐸 ) of Equation 4 gives 𝐻≤

𝑁 , 2 𝑙 𝜎𝐸

(10)

where 𝑙 is chosen based on the target failure probability. Thus 𝐻 must be larger than the biggest value reached between two bootstrappings, and, at the same time, small enough for this bound to hold. 3.2

Gate Bootstrapping for Supported Non-linear Boolean Gates

To evaluate a gate T with characteristic function gT on two input ciphertexts, it suffices to homomorphically evaluate gT as in Equation 9. Let Π and G denote programmable bootstrapping operations implementing the functions 𝜋 (𝑥) = 𝑥 mod 2 and 𝑥 ↦→ gT (𝑥 mod 4), respectively. Given 𝑐 0 = LWE(Δ𝑚 0 ) and 𝑐 1 = LWE(Δ𝑚 1 ), with Δ = 𝑞/2𝐻 , where 𝐻 is the headroom and 𝑚 0, 𝑚 1 ∈ Z4 are mapped inputs, the homomorphic addition and scalar multiplication properties of TFHE yield

  G 2𝑐 0 + Π(𝑐 1 ) = G 2 LWE(Δ𝑚 0 ) + Π(LWE(Δ𝑚 1 ))  = G LWE(Δ2𝑚 0 ) + LWE(Δ𝜋 (𝑚 1 ))  = G LWE(Δ(2𝑚 0 + 𝜋 (𝑚 1 )))  = G LWE(Δ𝐼 (𝑚 0, 𝑚 1 )) = LWE(ΔgT (𝑚 0, 𝑚 1 )) = LWE(ΔT(𝜋 (𝑚 0 ), 𝜋 (𝑚 1 ))). The LUT of G is defined on the whole range [0, 𝐻 ) and reduces its input modulo 4 before applying the indexed truth table. This is what makes the third line valid: the sum 2𝑚 0 + 𝜋 (𝑚 1 ) is computed over the integers and may exceed 3, but 2𝑚 0 mod 4 depends only on the parity of 𝑚 0 . It must stay below 𝐻 , i.e., 𝑚 0 < (𝐻 − 1)/2, otherwise it spills into the padding bit. Figure 1 shows the resulting circuit for the supported non-free gates AND, NAND, OR and NOR (XOR and XNOR are handled by the free-XOR property, XNOR with an additional plaintext addition of 1). Each such gate costs two bootstrappings, one for Π and one for G. The unary NOT gate is free in the same way: it is the XOR with the constant 1, i.e., a single plaintext addition of Δ that needs no bootstrapping and adds no noise. The constant gates FALSE and TRUE need no bootstrapping either, since their output is a trivial encryption of 0 or 1 that is independent of the inputs.

𝑐0

×2

𝑐1

Π

+

G

Figure 1. Gate bootstrapping for the supported non-free binary gates. The input 𝑐 0 is multiplied by 2, and 𝑐 1 is passed through the bootstrapping Π that computes 𝑥 mod 2. Their sum encrypts the index 𝐼 (𝑚 0, 𝑚 1 ), and the bootstrapping G applies the indexed truth table of the gate T to it.

4

Implementations and Proof of Work

We implemented our proposed approach in Rust and made the source code publicly available in [2]. Our implementation uses the open-source TFHE-rs library [21], which provides high-level APIs for manipulating TFHE ciphertexts. To evaluate Boolean circuits, we developed a compiler that translates circuits represented in the Bristol Fashion (BF) format into equivalent circuits operating over TFHE ciphertexts. An interpreter then evaluates the resulting circuits using a valid set of ciphertexts as inputs. 4.1

Bristol Fashion (BF)

We use the Bristol Fashion (BF) syntax [3] to represent Boolean circuits within our framework. BF provides a textual representation of a circuit in which all gates are listed in topological order. Each gate is specified by its type together with the indices of its input and output wires. For a circuit with 𝑛 input wires and 𝑚 output wires, the first 𝑛 wire indices are reserved for the input wires, while the final 𝑚 wire indices are reserved for the output wires. 4.2

Parameters

As described in Section 3.1.1, our encoding uses two bits to represent the plaintext modulus, i.e., 𝑝 = 4. To satisfy Equation 10 under the other chosen parameters, including 𝑁 and 𝜎𝑒 , we allocate additional two bits for carry values arising during homomorphic computations. Accordingly, we set the headroom to four bits, i.e., 𝐻 = 16. A larger value of 𝐻 allows more homomorphic operations to be performed between bootstrapping operations, thereby reducing the frequency of bootstrapping. However, increasing 𝐻 may require adjusting other parameters to maintain the desired security level and may increase the dimensions of the underlying polynomials and vectors, potentially increasing computational costs. Optimizing these parameters jointly to balance security, computational efficiency, and bootstrapping frequency remains an open engineering problem for our approach. 4.3

Lazy Bootstrapping

As explained in Section 3.1.1, we reserve a headroom that allows us to postpone the bootstrapping of XOR, XNOR, and NOT gates, while guaranteeing that intermediate values never overwrite the padding bit, which must remain zero for the trick that enables the evaluation of non-negacyclic

Ali Ajorian and Osman Biçer

Table 5. Lazy bootstrapping conditions and estimated maximum possible value (MPV) of the output wire for each gate type, where mpv𝑖 is the MPV of input wire 𝑖 and 𝐻 is the headroom. Gate Bootstrapping condition Output wire MPV XOR mpv0 + mpv1 > 𝐻 − 1 mpv0 + mpv1 XNOR mpv0 + mpv1 + 1 > 𝐻 − 1 mpv0 + mpv1 + 1 NOT mpv0 + 1 > 𝐻 − 1 mpv0 + 1 Others 2 mpv0 > 𝐻 − 1 2 mpv0 + 1 functions. If a value exceeds the maximum value that fits in the headroom, the padding bit is overwritten and the result is no longer valid. One way to satisfy this requirement is to write a compiler that, given the input values, finds the optimal places to insert bootstrapping operations. However, this approach has two drawbacks: first, it may leak information about the input values, and second, it requires a new configuration for every evaluation. Our approach instead estimates the maximum possible value (MPV) of each wire during homomorphic evaluation and applies a bootstrapping when this value approaches the headroom. To this end, we maintain a hashmap from wire indices to MPVs, which is filled and updated during the evaluation. For each gate, we look up the MPVs of its input wires and estimate the MPV of its output wire. If the estimate would overflow the headroom, we bootstrap one or two of the input wires. The overflow condition depends on the gate type. For XOR, the evaluation is an addition of the two input ciphertexts, so an overflow occurs when the sum of the input MPVs is greater than 𝐻 − 1. For NOT, the evaluation adds 1 to the ciphertext, so an overflow occurs when the input MPV plus 1 is greater than 𝐻 − 1. For XNOR, we add the two input ciphertexts and 1, so an overflow occurs when the sum of the input MPVs plus 1 is greater than 𝐻 − 1. For the other supported symmetric gates, which apply the index function 𝐼 = 2𝑚 0 + 𝜋 (𝑚 1 ), an overflow occurs when twice the MPV of the first input is greater than 𝐻 − 1. Since 𝜋 is applied via a PBS, there is no need to check the sum 2 MPV0 + MPV1 . Table 5 summarizes all cases. For XOR and XNOR, we bootstrap the input with the larger MPV first, and then the other input only if the condition still holds. 4.4

Experimental Results

We evaluated our approach on toy circuits with varying combinations of free-XOR gates and symmetric gates requiring two PBS operations. Each experiment was repeated 10 times on an Apple M2 MacBook Pro with 24 GB of RAM. Table 6 presents a subset of the results, comparing the evaluation time of our approach with that of the standard approach, which performs bootstrapping after evaluating each gate.

Our approach achieves an approximately 88% speedup on XOR-only circuits, with diminishing gains as the proportion of symmetric gates relative to FreeXOR gates increases. Table 6. Our experimental results. All the elapsed times are reported in seconds. Circuit Gates Standard FreeXOR XOR-tree 63 XOR 0.975 0.114 Toy1 150 XOR, 15 INV, 20 AND, 15 OR 2.866 1.422 Toy2 100 XOR, 30 INV, 40 AND, 30 OR 2.608 2.481 Toy3 80 XOR, 20 INV, 50 AND, 50 OR 2.682 3.711

5

Conclusion and Discussion

We proposed an encoding that enables XOR evaluation without immediate programmable bootstrapping (PBS), using homomorphic addition instead. To support other symmetric gates, such as AND, NAND, OR, and NOR, we introduced an indexing function that homomorphically identifies the corresponding row of a gate’s truth table. Evaluating a symmetric gate requires two PBS operations: one to compute the index and another to evaluate the gate’s functionality based on that index. In contrast, XOR gates can be evaluated without immediate bootstrapping. Our approach reserves headroom for intermediate results produced by operations performed without bootstrapping, allowing bootstrapping to be deferred until this headroom is about to overflow. Consequently, our approach is most efficient for circuits in which XOR gates significantly outnumber symmetric gates.

References [1] Abbas Acar, Hidayet Aksu, A Selcuk Uluagac, and Mauro Conti. 2018. A survey on homomorphic encryption schemes: Theory and implementation. ACM Computing Surveys (Csur) 51, 4 (2018), 1–35. [2] Ali Ajorian. 2026. FreeXOR-FHE. https://github.com/Ajorian/freexorfhe Source code repository. [3] David Archer, Victor Arribas Abril, Steve Lu, Pieter Maene, Nele Mertens, Danilo Sijacic, and Nigel Smart. 2019. Bristol Fashion MPC Circuits. https://nigelsmart.github.io/MPC-Circuits/. Accessed: 202609-10. [4] Dan Boneh, Eu-Jin Goh, and Kobbi Nissim. 2005. Evaluating 2-DNF formulas on ciphertexts. In Theory of cryptography conference. Springer, 325–341. [5] Zvika Brakerski, Craig Gentry, and Vinod Vaikuntanathan. 2014. (Leveled) fully homomorphic encryption without bootstrapping. ACM Transactions on Computation Theory (TOCT) 6, 3 (2014), 1–36. [6] Zvika Brakerski and Vinod Vaikuntanathan. 2014. Efficient fully homomorphic encryption from (standard) LWE. SIAM Journal on computing 43, 2 (2014), 831–871. [7] Chunling Chen, Xianhui Lu, Ruida Wang, Zhihao Li, Xuan Shen, and Benqiang Wei. 2024. Free-xor gate bootstrapping. Cryptology ePrint Archive (2024). [8] Jung Hee Cheon, Andrey Kim, Miran Kim, and Yongsoo Song. 2017. Homomorphic encryption for arithmetic of approximate numbers. In International conference on the theory and application of cryptology and information security. Springer, 409–437.

Free-XOR TFHE via Lazy Bootstrapping [9] Ilaria Chillotti. 2022. TFHE Deep Dive - Part IV - Programmable Bootstrapping. https://www.zama.org/post/tfhe-deep-dive-part-4. Zama Blog. [10] Ilaria Chillotti, Nicolas Gama, Mariya Georgieva, and Malika Izabachène. 2016. Faster Fully Homomorphic Encryption: Bootstrapping in Less Than 0.1 Seconds. In Advances in Cryptology – ASIACRYPT 2016. Springer, 3–33. doi:10.1007/978-3-662-53887-6_1 [11] Ilaria Chillotti, Nicolas Gama, Mariya Georgieva, and Malika Izabachène. 2020. TFHE: Fast Fully Homomorphic Encryption Over the Torus: I. Chillotti et al. Journal of Cryptology 33, 1 (2020), 34–91. [12] Léo Ducas and Daniele Micciancio. 2015. FHEW: bootstrapping homomorphic encryption in less than a second. In Annual international conference on the theory and applications of cryptographic techniques. Springer, 617–640. [13] Taher ElGamal. 1985. A public key cryptosystem and a signature scheme based on discrete logarithms. IEEE transactions on information theory 31, 4 (1985), 469–472. [14] Craig Gentry. 2009. A fully homomorphic encryption scheme. Ph. D. Dissertation. Stanford University.

[15] Marc Joye. 2021. Guide to fully homomorphic encryption over the [discretized] torus. Cryptology ePrint Archive (2021). [16] Chiara Marcolla, Victor Sucasas, Marc Manzano, Riccardo Bassoli, Frank HP Fitzek, and Najwa Aaraj. 2022. Survey on fully homomorphic encryption, theory, and applications. Proc. IEEE 110, 10 (2022), 1572– 1609. [17] Oded Regev. 2009. On lattices, learning with errors, random linear codes, and cryptography. Journal of the ACM (JACM) 56, 6 (2009), 1–40. [18] Ronald L Rivest, Len Adleman, Michael L Dertouzos, et al. 1978. On data banks and privacy homomorphisms. Foundations of secure computation 4, 11 (1978), 169–180. [19] Ronald L Rivest, Adi Shamir, and Len Adleman. 1978. A method for obtaining digital signatures and public-key cryptosystems. Commun. ACM 21, 2 (1978), 120–126. [20] Ron Rothblum. 2011. Homomorphic encryption: From private-key to public-key. In Theory of cryptography conference. Springer, 219–234. [21] Zama. 2022. TFHE-rs: A Pure Rust Implementation of the TFHE Scheme for Boolean and Integer Arithmetics Over Encrypted Data. https://github.com/zama-ai/tfhe-rs.

Related documents

Record · ID 1406377 · SHA-256 a71e90ae840313c9
Retrieved via Conceptio: every document is proof-bundled with source, license, and retrieval metadata.
Bring this data into your agent: Connect via MCP or API · 20 free credits to start · no card required
Read the Docs → · View CLI source on GitHub · Conceptio Open Knowledge Archive