I recently presented the paper Chaghri which is a joint work with Tomer Ashur and Mohammad Mahzoun at ACM CCS. The paper introduces a new algebraic cipher that outperforms AES when implemented as a circuit in fully homomorphic encryption.
Algebraic Ciphers
Traditional block ciphers are designed to be efficient in their software and hardware implementations. Depending on where they are implemented, their design optimizes the running time, gate count, and memory/power consumption. For example, an IoT device having limited resources would call for low gate count and memory/power consumption. Similarly, a high-speed router would require a low running time. However, when we talk about different target application domains, i.e. secure computation protocols, the efficiency metrics we consider are also different. Multi-Party Computation (MPC), Zero-Knowledge (ZK) proofs, and Fully Homomorphic Encryption (FHE) are examples of secure computation protocols that are described via algebraic operations. In secure computation protocols, we convert arithmetic computations into a sequence of algebraic operations over a finite field which is called arithmetization, and we call the block ciphers employed in these protocols algebraic ciphers. Therefore, these protocols would call for low arithmetic complexity as an efficiency metric, in other words, a basic multiplicative layout. In the later sections of this blog post, we will see the design considerations for an algebraic cipher to have a basic multiplicative layout. Before describing Chaghri, I will explain the motivation behind designing an FHE-friendly block cipher.
Transciphering
Transciphering is a technique to improve the communication rate between the client and the cloud when the size of the freshly encrypted (under an FHE scheme) ciphertexts becomes too large. Let’s see it in an example:

The client sends their encrypted data to the cloud, and the cloud performs operations on the encrypted data. However, depending on the complexity of the performed operations, the parameters of the FHE scheme might result in larger sizes of freshly encrypted ciphertexts on the client side. As a result, this harms the communication rate from the client to the cloud. Rather than encrypting under the FHE scheme, by using a block cipher to encrypt the data, one can obtain drastically reduced sizes of the ciphertexts. Then, to be able to perform operations on the encrypted data, all the cloud needs to do is to homomorphically decrypt the encrypted data.
Motivation of Chaghri
In the paper “How Not To Design an Efficient FHE-friendly Block Cipher: Seljuk”, we have shown that AES performs 88% faster than Vision which is designed to be efficient in MPC and ZK proof. As AES is a traditional block cipher, and Vision is tailored to be an efficient algebraic cipher, we investigated the reasons for this behavior. The first one is the dense affine polynomial in Vision that has \(m+1\) monomials where \(m\) is the degree of the field extension. The second one is the inversion that is repeated 20 times (10 rounds, and each round has two inversions). Here, the question, “How can we describe operations in an efficient way?”, naturally pops up. We will find the answer in the next section.
Non-procedural Computation
In procedural computation, we can describe the system’s state as a function of the system’s state at a previous point in time. However, when it comes to the secure computation protocols, we have a better way of interpreting the system’s state: non-procedural computation. In non-procedural computation, the system’s state is interpreted with respect to a different timeline. What is very useful in non-procedural computation is we can do constant time executions when the size of the native field changes. To make it more clear, let’s consider inversion. To compute the inversion of an input without masking, we raise the input to the power of \(n-2\) where \(n\) is the field size. The execution time of the inversion being dependent on the field size, using non-procedural computation we can mask the input and delegate the computation to the offline phase in MPC. By doing so, we can obtain a constant execution time rather than a variable execution time dependent on the field size. Therefore, exploiting non-procedural computation allows us to design efficient algebraic ciphers. Moreover, we can gain security by efficiently computing without the need to increase the number of rounds. In the design of Chaghri, we also exploit non-procedural computation by using Frobenius automorphism (\(x\mapsto x^{k^i}, k\) is the characteristic of the field).
Description of Chaghri
Chaghri state consists of three field elements (\( x_i \in \mathbb{F}_2^{63}\)) and is of size 189 bits. It is a substitution permutation network (SPN) which means it has a series of operations in rounds. AES and PRESENT are other well-known examples of SPNs. Chaghri has 8 rounds and each round consists of two identical steps. Each step consists of S-box and linear layers, and is followed by subkey injection.
S-box Layer
Power maps are widely used in S-box layers as they have good cryptanalytic properties. Our choice of power function in Chaghri is the Gold exponent (\( x \mapsto x^{{2^k}+1}\)). Referring to the Frobenius automorphism, the reasoning is quite clear. Computing a Gold exponent requires one Frobenius automorphism and one multiplication. Moreover, it is a non-procedural computation as we can compute it in a constant time independent of the choice of \(k\). In Chaghri, we chose \(k = 32\) which makes the Gold exponent a permutation and also provides good cryptanalytic properties. However, even though the power maps have good cryptanalytic properties, the polynomial description of the cipher might not be complex enough to resist algebraic attacks. \( \mathbb{F}_2\)-linearized affine polynomials \( (A(X)=a_0 + \sum_{i=0}^{n-1}a_iX^{2^i}\) over \(\mathbb{F}_{2^n})\) are used to increase the complexity of the polynomial description as they are efficient to compute with respect to the normal basis. In FHE, as \( x^{2^k}\) can be computed by a Frobenius automorphism, we can efficiently increase the complexity of the polynomial description. Our initial choice of the affine polynomial was of the form \( a(x) = a_1x^8+a_2\). However, Liu et al. showed that this affine polynomial results in a linear increase of the algebraic degree rather than an exponential increase which makes it possible to apply a higher order differential attack. As they show that the affine polynomial \( a'(x) = c_1x^{256}+c_2x^4+c_3x+c_4\) results in exponential increase, the affine polynomial of Chaghri is set to \( a’\).
Linear Layer
Linear layer is used to diffuse the local properties to the entire state. A distinguished way to do so is multiplying the state with an MDS (maximum distance separable) matrix. MDS matrices are natural choices for linear layers as they have good diffusion properties, and are used in well-known ciphers such as AES, Twofish and Camellia.
Subkey Injection
Subkey injection is the XOR of the subkey to the state.
Decryption Algorithm of Chaghri
Recalling the transciphering example, encryption happens at the client side, and decryption is homomorphically happening at the cloud side. Therefore, in Chaghri, we focus on the decryption algorithm for efficiency. Following image shows a decryption round that consists of two identical steps.

Each step first applies the Gold exponent followed by the affine polynomial. Then, it applies the linear layer for the diffusion purposes. Each step is followed by a subkey injection. Subkeys are obtained by key scheduling which is the exact same algorithm as the decryption. It is fed with the master key, and instead of the subkeys, round constants are XORed after each step.
Cost of a Round
The Gold exponent requires one Frobenius automorphism and one multiplication. The affine polynomial requires two Frobenius automorphisms, and the linear layer requires two rotations. In total, the Chaghri decryption requires 48 Frobenius automorphisms, 16 multiplications and 32 rotations.
Benchmark
To evaluate the behavior of Chaghri in FHE, we compared AES and Chaghri implemented in BGV. Following table compares the running times for both ciphers.

As they have different throughputs, we compare them using “seconds per bit” metric. As it can be seen in the table, Chaghri achieves a more compact algebraic description outperforming AES by 63%!


