Linear Approximations of Addition Modulo
Linear Approximations of Addition Modulo
Johan Wallén
1 Introduction
Linear cryptanalysis [8] is one of the most powerful general cryptanalytic meth-
ods for block ciphers proposed by date. Since its introduction, resistance against
this attack has been a standard design goal for block ciphers. Although some
design methodologies to achieve this goal have been proposed—for example [12,
10, 4, 13]—many block ciphers are still designed in a rather ad hoc manner, or
dictated by other primary design goals. For these ciphers, it it important to have
efficient methods for evaluating their resistance against linear cryptanalysis.
At the heart of linear cryptanalysis lies the study of the correlation of linear
approximate relations between the input and output of functions. Good linear
approximations of ciphers are usually found heuristically by forming trails con-
sisting of linear approximations of the components of the cipher. In order to
search the space of linear trails, e.g. using a Branch-and-bound algorithm (see
e.g. [5, 9, 1]), we need efficient methods for computing the correlation of linear
approximations of the simplest components of the cipher, as well as methods for
generating the relevant approximations of the components. Towards this goal,
we study a few basic functions often used in block ciphers.
Currently, block ciphers are usually build from local nonlinear mappings,
global linear mappings, and arithmetic operations. The mixture of linear map-
pings and arithmetic operations seems fruitful, since they are suitable for soft-
ware implementation, and their mixture is difficult to analyse mathematically.
While the latter property intuitively should make standard cryptanalysis in-
tractable , it also makes it difficult to say something concrete about the security
of the cipher.
Perhaps the simplest arithmetic operations in wide use are addition and sub-
traction modulo 2n . Interestingly, good tools for studying linear approximations
of even these simple mappings have not appeared in the literature to date. In this
paper, we consider algorithms for two important problems for linear approxima-
tions of these operations: for computing the correlation of any given linear ap-
proximation and for generating all approximations with a correlation coefficient
of a given absolute value. Our results are based on a fairly simple classification
of the linear approximations of the carry function. Using this classification, we
derive Θ(log n)-time algorithms for computing the correlation of of linear ap-
proximations of addition and subtraction modulo 2n in a standard RAM model
of computation. The classification also gives optimal (that is, linear in the size
of the output) algorithms for generating all linear approximations of addition or
subtraction with a given non-zero correlation. In the generation algorithms, one
or two of the selection vectors may optionally be fixed. As a simple corollary, we
determine closed-form expressions for the distribution of the correlation coeffi-
cients. We hope that our result will facilitate advanced linear cryptanalysis of
ciphers using modular arithmetic.
Similar results with respect to differential cryptanalysis [2] are discussed in [7,
6]. The simpler case with one addend fixed is considered in [11] with respect to
both linear and differential cryptanalysis.
In the next section, we discuss linear approximations and some preliminary
results. In Sect. 3, we derive our classification of linear approximations of the
carry function, and the corresponding results for addition and subtraction. Using
this classification, we then present the Θ(log n)-time algorithm for computing
the correlation of linear approximations in Sect. 4, and the generation algorithms
in Sect. 5.
2 Preliminaries
2.1 Linear Approximations
Linear cryptanalysis [8] views (a part of) the cipher as a relation between the
plaintext, the ciphertext and the key, and tries to approximate this relation using
linear relations. The following standard terminology is convenient for discussing
these linear approximations.
Let f, g : IFn2 → IF2 be Boolean functions. The correlation between f and g
is defined by
c(f, g) = 21−n {x ∈ IFn2 | f (x) = g(x)} − 1 .
This is simply the probability taken over x that f (x) = g(x) scaled to a value in
[−1, 1]. Let u = (um−1 , . . . , u0 )t ∈ IFm t n
2 and w = (wn−1 , . . . , w0 ) ∈ IF2 be binary
n m
column vectors, and let h : IF2 → IF2 . Let w · x = wn−1 xn−1 + · · · + w1 x1 + w0 x0
denote the standard dot product. Define the linear function lw : IFn2 → IF2 by
lw (x) = w · x for all w ∈ IFn2 . A linear approximation of h is an approximate
Linear Approximations of Addition Modulo 2n 263
Here, u and w are the output and input selection vectors, respectively.
Definition 1. Let Bn = fˆ | f : IFn2 → IF2 be the real algebra generated by the
n-variable Boolean functions. As usual, the addition, multiplication, and multi-
plication by scalars are given by (ξ + η)(x) = ξ(x) + η(x), (ξη)(x) = ξ(x)η(x)
and (aξ)(x) = a(ξ(x)) for all ξ, η ∈ Bn and a ∈ IR.
For Boolean functions, f, g : IFn2 → IF2 , fˆ, ĝ = c(f, g). Since the set of linear
functions {ˆlw | w ∈ IFn2 } forms an orthonormal basis for Bn , every ξ ∈ Bn has a
unique representation as
ξ= αw ˆlw , where αw = ξ, ˆlw ∈ IR .
w∈IFn
2
that at most one of the terms in the expression for Ri+1 is non-zero, and that
we can determine which of the four terms might be non-zero by looking only
at xi+k and yi+k . The four terms consider the cases (xi+k , yi+k ) = (1, 0), (0, 1),
(0, 0), and (1, 1), respectively. This observation yields the following lemma.
Definition 3. The common prefix mask cpmki : IFn2 → IFn2 is for all j defined
by cpmki (x)j = 1 if and only if k ≤ j < k + i and xℓ = 1 for all j < ℓ < k + i.
Let wH (x) = {i | xi = 0} denote the Hamming weight of x ∈ IFn2 .
Note that α(i) and the values of β used in the algorithm only depend on n. For
convenience, we introduce the following notation. Let β (i) ∈ IFn2 be such that
(i)
βℓ = 1 iff ℓ−2i is a non-negative multiple of 2i+1 (e.g. β (1) = 0100 · · · 01000100).
For b ∈ {0, 1}, let
i i
z (i) (b, x, y) = (cpm2i (b, x(n/2 −1)
, y (n/2 −1)
), . . . , cpm2i (b, x(0) , y (0) ))t ,
i i
where x = (x(n/2 −1) , . . . , x(0) )t and y = (y (n/2 −1) , . . . , y (0) )t . We also let x →
y, z denote the function “if x then y else z”. That is, x → y, z = (x ∧ y) ∨ (x ∧ z).
Proof (of Theorem 2). The algorithm clearly terminates in time Θ(log n) and
uses constant space in addition to the masks α(i) . The initial value of β can also
be constructed in logarithmic time. We show by induction on i that β = β (i)
and zb = z (i) (b, x, y) at the start of the ith iteration of the for-loop. For i = 0,
this clearly holds, so let i ≥ 0. Consider the vectors x, y and zb split into
2i+1 -bit blocks, and let x′ , y ′ , and zb′ denote one of these blocks. After step 2a,
γb,ℓ = (yℓ ∧ zb,ℓ ) → xℓ , xℓ when ℓ − 2i is a multiple of 2i+1 , and γb,ℓ = 0
otherwise. Let ξ denote the bit of γb corresponding to the middle bit of the
block under consideration. By induction and the splitting lemma, cpm(b, x′ , y ′ ) =
L L R R
(cpm(b, x′ , y ′ ), cpm(ξ, x′ , y ′ ))t . After step 2b, a block of the form χ00 · · · 0
in γb has been transformed to a block of the form 0χχ · · · χ. In step 2c, the upper
half of each block zb′ is combined with the corresponding lower half of the block
zξ′ to give t′b = cpm(b, x′ , y ′ ). That is, tb = z (i+1) (b, x, y). Finally, β = β (i+1)
after step 2e. ⊓
⊔
Since the Hamming weight can be computed in time O(log n), we have the
following corollary.
⊞
Corollary 1. Let u, v, w ∈ IFn2 . The correlation coefficients C(u ←
− v, w) and
⊟
C(u ←− v, w) can be computed in time Θ(log n) (using the algorithm in Theorem 2
and the expressions in Theorem 1 and Lemma 7).
270 Johan Wallén
5 Generating Approximations
In this section, we derive a recursive description of the linear approximations
carry
u ←−−− v, w with a given non-zero correlation coefficient. For simplicity, we
only consider the absolute values of the correlation coefficients. The recursive
description immediately gives optimal generation algorithms for the linear ap-
carry
proximations. By Theorem 1, the magnitude of C(u ←−−− v, w) is either zero or
a power of 2 . Thus, we start by considering the set of vectors (u, v, w) ∈ (IFn2 )3
1
carry
such that C(u ←−−− v, w) = ±2−k .
carry
We will use the splitting lemma to determine the approximations u ←−−− v, w
with non-zero correlation and wH (cpmn (u, eq(v, w))) = k. Note that
where b = xL L L L
0 iff (y0 , cpmn−1 (x , y )0 ) = (1, 1). Now, cpm1 (b, x0 , y0 ) = 1 iff
L
b = 1 iff either x0 = 1 and (y0L , cpmn−1 (xL , y L )0 ) = (1, 1) or xL 0 = 0 and
(y0L , cpmn−1 (xL , y L )0 ) = (1, 1). Let the {0, 1}-valued bn (x, y) = 1 iff x0 = 1
and (y0 , cpmn (x, y)0 ) = (1, 1) or x0 = 0 and (y0 , cpmn (x, y)0 ) = (1, 1), let
F (n, k) = {(u, v, w) ∈ (IFn2 )3 | C(u ← − v, w) = ±2−k , bn (u, eq(v, w)) = 1}, and
n 3
let G(n, k) = {(u, v, w) ∈ (IF2 ) | C(u ← − v, w) = ±2−k , bn (u, eq(v, w)) = 0}.
Let A(n, k) = {(u, v, w) ∈ (IFn2 )3 | C(u ← − v, w) = ±2−k }. Then A(n, k) is
formed from F (n − 1, k − 1) and G(n − 1, k) by appending any three bits to
the approximations in F (n − 1, k − 1) (since u0 and eq(v, w)0 are arbitrary, and
cpmn (u, eq(v, w))0 = 1) and by appending {(0, 0, 0), (1, 0, 0)} to the approxima-
tions in G(n − 1, k) (since u0 is arbitrary and cpmn (u, eq(v, w))0 = 0). Let S =
{(0, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0)}, T = {(0, 0, 1), (0, 1, 0), (1, 0, 0), (1, 1, 1)}, and
denote y = eq(v, w). We denote concatenation simply by juxtaposition.
The set F (n, k) can be divided into two cases.
1. The vectors with wH (cpmn−1 (uL , y L )) = k, bn−1 (uL , y L ) = 0, and bn (u, y) =
1. Since (u0 , y0 ) ∈ {(1, 0), (1, 1)} and cpmn (u, y)0 = 0, this set equals G(n −
1, k)(1, 0, 0).
2. The vectors with wH (cpmn−1 (uL , y L )) = k − 1, bn−1 (uL , y L ) = 1 and
bn (x, y) = 1. Since (u0 , y0 ) ∈ {(0, 1), (1, 0)} and cpmn (u, y)0 = 1, this set
equals F (n − 1, k − 1)S.
That is,
F (n, k) = G(n − 1, k)(1, 0, 0) ∪ F (n − 1, k − 1)S .
Clearly, F (1, 0) = {(1, 0, 0)} and F (n, k) = ∅ when k < 0 or k ≥ n.
Similarly, G(n, k) can be divided into two cases:
1. The vectors with wH (cpmn−1 (uL , y L )) = k, bn−1 (uL , y L ) = 0, and bn (u, y) =
0. Since (u0 , y0 ) ∈ {(0, 0), (0, 1)} and cpmn (u, y)0 = 0, this set equals G(n −
1, k)(0, 0, 0).
2. The vectors with wH (cpmn−1 (uL , y L )) = k − 1, bn−1 (uL , y L ) = 1 and
bn (u, y) = 0. Since (u0 , y0 ) ∈ {(0, 0), (1, 1)} and cpmn (u, y)0 = 1, this set
equals F (n − 1, k − 1)T .
Linear Approximations of Addition Modulo 2n 271
That is,
G(n, k) = G(n − 1, k)(0, 0, 0) ∪ F (n − 1, k − 1)T .
Clearly, G(1, 0) = {(0, 0, 0)} and G(n, k) = ∅ when k < 0 or k ≥ n.
carry
Theorem 3. Let A(n, k) = {(u, v, w) ∈ (IFn2 )3 | C(u ←−−− v, w) = ±2−k }.
Then
where F and G are as follows. Let S = {(0, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0)} and
T = {(0, 0, 1), (0, 1, 0), (1, 0, 0), (1, 1, 1)}. First, F (1, 0) = {(1, 0, 0)}, G(1, 0) =
{(0, 0, 0)}, and F (n, k) = G(n, k) = ∅ when k < 0 or k ≥ n. Second, when
0 ≤ k < n,
From this theorem, it can be seen that there are 8(n − 1) linear approximations
carry
u ←−−− v, w with correlation ± 21 . In the notation of formal languages, these are
the 8 approximations of the form
carry
0n−2 1a ←−−− 0n−2 0b, 0n−2 0c
for arbritrary a, b, c ∈ {0, 1}, and the 8(n − 2) approximations of the form
carry
0n−i−3 1d0i g ←−−− 0n−i−3 0e0i 0, 0n−i−3 0f 0i 0
for (d, e, f ) ∈ {(0, 0, 1), (0, 1, 0), (1, 0, 0), (1, 1, 1)}, g ∈ {0, 1} and i ∈ {0, . . . , n −
3}.
The recursive description in Theorem 3 can easily be used to generate all
linear approximations with a given correlation. The straightforward algorithm
uses O(n) space and is linear-time in the number of generated approximations.
Clearly, this immediately generalise to the case where one or two of the selection
vectors are fixed. By Lemma 7, this also generalise to addition and subtraction
modulo 2n .
Corollary 2. The set of linear approximations with correlation ±2−k of the
carry function, addition, or subtraction modulo 2n can be generated in optimal
time (that is, linear in the size of the output) and O(n) space in the RAM
model (by straightforward application of the recurrence in Theorem 3 and the
expressions in Lemma 7). Moreover, one or two of the selection vectors can be
optionally fixed.
Theorem 3 can also be used to determine the distribution of the correlation
coefficients.
272 Johan Wallén
Corollary 3. Let N (n, k) = {(u, v, w) ∈ (IFn2 )3 | C(u ←
− v, w) = ±2−k }. Then
n−1
N (n, k) = 22k+1
k
for all 0 ≤ k < n and N (n, k) = 0 otherwise. Thus, the number of linear
approximations with non-zero correlation is 2 · 5n−1 .
we see that
k n−1−k
n−1 4 1
Pr[X = k] =
k 5 5
k n−1−k
for all 0 ≤ k < n, since 2 · 5n−1 n−1
k
4
5
1
5 = 22k+1 n−1k . Thus, X is
4 4
binomially distributed with mean 5 (n − 1) and variance 25 (n − 1).
6 Conclusions
Acknowledgements
This work was supported by the Finnish Defence Forces Research Institute of
Technology.
Linear Approximations of Addition Modulo 2n 273
References
1. Kazumaro Aoki, Kunio Kobayashi, and Shiho Moriai. Best differential character-
istic search for FEAL. In Fast Software Encryption 1997, volume 1267 of LNCS,
pages 41–53. Springer-Verlag, 1997.
2. Eli Biham and Adi Shamir. Differential Cryptanalysis of the Data Encryption
Standard. Springer-Verlag, 1993.
3. Florent Chabaud and Serge Vaudenay. Links between differential and linear crypt-
analysis. In Advances in Cryptology–Eurocrypt 1994, volume 950 of LNCS, pages
356–365. Springer-Verlag, 1995.
4. Joan Daemen. Cipher and Hash Function Design: Methods Based on Linear and
Differential Cryptanalysis. PhD thesis, Katholieke Universiteit Leuven, March
1995.
5. E.L. Lawler and D.E. Wood. Branch-and-bound methods: a survey. Operations
Research, 14(4):699–719, 1966.
6. Helger Lipmaa. On differential properties of Pseudo-Hadamard transform and
related mappings. In Progress in Cryptology–Indocrypt 2002, volume 2551 of LNCS,
pages 48–61. Springer-Verlag, 2002.
7. Helger Lipmaa and Shiho Moriai. Efficient algorithms for computing differential
properties of addition. In Fast Software Encryption 2001, volume 2355 of LNCS,
pages 336–350. Springer-Verlag, 2002.
8. Mitsuru Matsui. Linear cryptanalysis method for DES cipher. In Advances in
Cryptology–Eurocrypt 1993, volume 765 of LNCS, pages 386–397. Springer-Verlag,
1993.
9. Mitsuru Matsui. On correlation between the order of S-boxes and the strength
of DES. In Advances in Cryptology–Eurocrypt 1994, volume 950 of LNCS, pages
366–375. Springer-Verlag, 1995.
10. Mitsuru Matsui. New structure of block ciphers with provable security against
differential and linear cryptanalysis. In Fast Software Encryption 1996, volume
1039 of LNCS, pages 205–218. Springer-Verlag, 1996.
11. Hiroshi Miyano. Addend dependency of differential/linear probability of addition.
IEICE Trans. Fundamentals, E81-A(1):106–109, 1998.
12. Kaisa Nyberg. Linear approximations of block ciphers. In Advances in Cryptology–
Eurocrypt 1994, volume 950 of LNCS, pages 439–444. Springer-Verlag, 1995.
13. Serge Vaudenay. Provable security for block ciphers by decorrelation. In STACS
1998, volume 1373 of LNCS, pages 249–275. Springer-Verlag, 1998.