Linear Approximating to Integer Addition
Li An-Ping
Beijing 100085, P.R. China [email protected]
Abstract
The integer addition is often applied in ciphers as a cryptographic means. In this paper we will present some results about the linear approximating for the integer addition.
1. Preliminary
For the undecided effect of carry operations in the integer addition, it is often used as a cryptographic means in some ciphers, for instance, in the candidate ciphers of eSTREAM (The ECRYPT Stream Cipher Project) some of them employed the combination of the integer addition, XOR and rotations as main cryptographic transformation. Therefore, it is significant to know the effect of the integer addition in cryptography. J. Wallen [3] provided an algorithm for computing the correlation of linear approximation of addition modulo
2
n. In this paper, we will show some explicit results about the linear approximating to the integer addition.2. Some basic results
In this paper, the symbol
⊕
as usually stands for XOR operation. Supposez
is a binary segment of lengthn
, denoted byz i
[ ]
the i-th bit, and let 1( )
[ ]
i
s z
=
∑
z i
,s z
0( )
= −
n
s z
1( )
,and
d z
( )
=
s z
0( )
−
s z
1( )
, that is,s z
0( )
ands z
1( )
are the numbers of the bit “0” and bit “1” inz
respectively, andd z
( )
is the bias of them. Letx
andy
be two integers of lengthn
bits,denoted by
L x y
( , )
=
(
x
+
y
)
⊕ ⊕
(
x
y
)
,L x y
( , )
= + +
(1
x
y
)
⊕ ⊕
(
x
y
)
, and define2 2
,
2 2
,
2
,
(2
2
( , )[ ]) / 2 ,
(2
2
( , )[ ]) / 2 ,
( ( , )) /
2 .
n n
i
x y
n n
i
x y
n x y
D
L x y i
D
L x y i
D
d L x y
n
=
−
=
−
=
⋅
∑
∑
∑
(2.1)
We have the following result
Proposition 1
1/ 2 ,
i0
,
i
D
=
≤ <
i
n
(2.2)1/ 2 ,
i0
,
i
D
= −
≤ <
i
n
(2.3)2
1
1
2
nD
n
⎛
⎞
= ⋅ −
⎜
⎟
⎝
⎠
. (2.4)Proof. It is easy to check directly
D
0=
1
, so we assume thati
>
0
. For an integerz
,denoted by
z
i the integer formed by the segment ofz
from bit 0 to biti
. Letw
=
L x y
( , )
,only if
x
i−1+
y
i−1<
2
i, so( ) 2 2
1 2
(
) 2
(2
2
) / 2
i
n i n n i
i k
N
k
− −≤ <
=
∑
⋅
=
−
. (2.5)Hence,
2 2
(2
n2
) / 2
n1/ 2
ii i
D
=
− ⋅
N
=
.The proof of (1.3) is similar to the above, so omitted. It is easy to know that
0
(
i) /
i n
D
D
n
≤ <
=
∑
, (2.6)so,
0
2
1
(
2 ) /
1
2
i
n i n
D
n
n
−
≤ <
⎛
⎞
=
= ⋅ −
⎜
⎟
⎝
⎠
∑
.From Proposition 1, we have seen that
x
+
y
is still some likex
⊕
y
on the bits in statistics, especially for the first bits, though there are undecided carry operations in the addition. In other words, the probability(
x
+
y i
)[ ]
= ⊕
(
x
y i
)[ ]
has notable advantage wheni
is small, e.g.0,1, 2,
,
i
=
etc
. In the following, we will show a more general result on the linear approximating to the integer addition.Suppose that
z
is a integer variable over the domainΩ
, denoted by( )
[ ]
i
z
z i
δ
=
⊕
and define(|
| 2
( )) / |
|
z
z
z
δ
∈ΩΔ = Ω −
∑
Ω
. (2.7)Moreover, for a constant integer
c
, denoted byC
=
{
i c i
| [ ] 1
=
}
. Suppose theC
=
{
i
k}
1s,1 2 s
i
> >
i
>
i
, as usual,|
C
|
represents the cardinality of setC
, i.e.|
C
|
=
s
, and define1
1
( 1)
k ki s
C
−i
≤ ≤
=
∑
−
.Proposition 2 Suppose that
c
is a constant integer, denoted byL
c=
L x y
( , ) &
c
and( , ) &
c
L
=
L x y
c
, we have| |
1/ 2 ,
( 1) / 2 ,
c
c
C L
C C L
Δ =
Δ = −
(2.8)known the formula (2.8) is true when
s
=
1
. Now assume it is true in the cases
. We consider the firsti
s+1bits, denoted byN
0 andN
1 the numbers of the pairs( , )
x y
ofi
s+1-bits integerssuch that
x
+ <
y
2
is+1 andx
+ ≥
y
2
is+1, we have known that which are equal the numbers ofthe pairs
( , )
x y
with thatL x y i
( , )[
s+1]
=
0
and1 respectively and1 1 1 1 1 1
0
(2
1)2
,
1(2
1)2
.
s s s s
i i i i
N
=
++
+−N
=
+−
+−(2.9)
Denote
j
k= −
i
ki
s+1, 1
≤ ≤
k
s
, andC
′ =
{
j
k}
1s, then we apply the induction on the setC
′
,that is, on the segments of integers beginning the
i
s+1-th bit, we have1/ 2
,
( 1) / 2
,
c c C L C s L ′ ′ ′ ′
Δ =
Δ = −
So, 1 1 1 1 1 2 1 0 1 2 1 0 1 2 1 0 1 1(1 ( 1) ) / 2
( ( 1) (
2
{
(1
/ 2)
(1 ( 1)
/ 2)}
2
{
(1
/ 2)
(1 ( 1)
/ 2)}
2
(
( 1)
)
((1 ( 1)
) / 2 2
(1 ( 1) ) / 2)
2
2
s
c c c
s c c s c s c s s c k k i s
L L L
i s L L i s L i s s L i L j
N
N
N
N
N
N
+ ′ ′ + ′ ′ + ′ + ′ + ′ − ⋅ − − ⋅ − − ⋅ − − − − + − − − +Δ =
⋅
⋅ + Δ
+
⋅ + −
Δ
−
⋅
⋅ − Δ
+
⋅ − −
Δ
=
⋅
+ −
⋅ Δ
=
+ −
+
⋅ + −
⋅ Δ
=
⋅ Δ
=
1 1 1 1 1 1 1 1 1 1 1 1 11 ( 1) ) / 2)
( 1) (1 ( 1) ) / 2 (1 ( 1) ) / 2
( 1) (1 ( 1) ) / 2 (1 ( 1) ) / 2
( 1)
2
2
2
.
s s k sk s s
k s s
k s
k s s
k s s
k s
k k k s
i
i i i
i i i
i + ≤ ≤ − + + ≤ ≤ − + + ≤ ≤ − ≤ ≤ + + − − − + − − − + − − − + − − − + − − −
∑
∑
=
∑
=
∑
=
The proof for the second formula of (2.8) is similar to the above, so omitted.
In the some real cases, it is possible to come into the partial cases, that is, in
L x y
( , )
=
(
x
+
y
)
⊕ ⊕
(
x
y
)
the variabley
=
a
is a constant. Letc
be a constant, denotedby
L
c=
L x a
( , ) &
c
, we define1 0 1
0 2
( , )
(
),
( , )
2
( , ).
n
n c
x
a c
L
a c
a c
φ
δ
φ
φ
≤ <
=
∑
=
−
(2.10)if the parameters are clear from the context, In the following we will mainly calculate the
( , )
a c
Φ
.Suppose that
A
=
{ | [ ] 1}
i a i
=
andC
=
{ | [ ] 1}
i c i
=
, that is,A
andC
are the sets of the positions of bits “1” of the constantsa
andc
respectively. Without loss the generality, we assume that1 1 2 2 s s
,
A
∪ =
C
A C A C
A C
(2.11) which is the arrangement ofA
andC
in the order from small to large, where1 1
,
i i
i s i s
A
A C
C
≤ ≤ ≤ ≤
=
∪
=
∪
. In this paper we restrict the caseA
∩ = ∅
C
. Denoted bya
kthesegment of the integer
a
formed byA
1toA
k. Letα
ibe the smallest element ofA
ibut1
0,
α
=
α
s+1=
n
, andn
i=
α
i+1−
α
i,
1
≤ ≤
i
s
,(
)
2
2
i
i
t i
t A
A
αχ
−∈
=
∑
. Suppose{ } ,
0ki i
C
=
x
0 1 k
,
x
< <
x
<
x
we define0
(
)
( 1) 2
j xji
j k
C
−≤ ≤
∂
=
∑
−
,(
)
2
i1(
)
i i
C
αC
τ
=
+⋅∂
. (2.12)Lemma 1 If
s
=
1,
then1
( , )
a c
a
( )
C
φ
= ⋅
τ
. (2.13)Proof. It is clear that the number
φ
1( , )
a c
is the number ofL x a
( , )
with odd carries in thepositions of constant
c
. Suppose thatC
=
{ } ,
x
i 0kx
0< <
x
1<
x
k,
denoted byN
r thenumber of
L x a
( , )
withr
carries in the positions of constantc
. It is not difficult to know thatthe
r
carries must appear in the firstr
positions ofC
, i.e.x
0< <
x
1<
x
r−1,
hence it is easy to have1
1
( )
(2
1) 2
(2
2
).
r r r
r r
x x n x
r
n x n x
N
a
a
− −
− −
− −
= ⋅
− ⋅
= ⋅
−
(2 .14)Therefore,
2 2 1
1 1 2
0 2
( , )
(2
n xi2
n xi)
( )
i
i i k
a c
N
a
a
C
φ
− − +τ
+
≤ ≤
=
∑
= ⋅
∑
−
= ⋅
. (2.15)
1 2
(
,
)
v
∗ =
v
xu
+
yw xw
+
yu
. (2.16) and for 2-vector( , )
x y
, we defineT x y
( , )
=
( , )
y x
. Let2 2
( , )
(
),
n n
c a x
p a c
δ
L
− ≤ <
=
∑
( , )
( , ),
q a c
= −
a
p a c
andΓ
( , )
a c
=
( ( , ), ( , )).
q a c p a c
Denoted byI
=
2
n−
1
, and for theintegers
k
, 0
≤ <
k
s
, let2
k11
k
I
=
α+−
,& ,
k k
a
=
I
a
2
k1,
k k
a
=
α+−
a
and&
k k
c
=
I
c
.Moreover, denoted by
1
|
i|
i s
C
λ
≤ ≤=
∑
.Lemma 2
1 1
( , )
(
(
s k)
(
s k,
s k))
k s
a c
T
λχ
A
− +a
−c
−≤ ≤
Γ
=
∑
⋅Φ
, (2.17)where it is assumed that
Φ
(
a c
0,
0)
=
(1, 0)
.Proof. Let
z
be the integer of lengthn
such thatz
≡ +
x
a
mod(2 )
n , anda
=
2
n−
a
,hence it has
x
= +
z
a
mod(2 )
n , so( , )
(
)
(
)
(
)
( , )
(
)
L a x
= ⊕
z
a
+ ⊕ = ⊕
z
a
z
a
+ ⊕ ⊕ ⊕
z
a
a
a
=
L z a
⊕ ⊕
a
a
,Denoted by
I
′ = ⊕
a
a
, suppose thatα
=
min{ |
t t
∈
A
}
, then it is easy to know1
2
n2
I
′ =
−
α + . Thus it has,( , ) &
( ( , )
) &
( ( , ) & )
L a x
c
=
L z a
⊕
I
′
c
=
L z a
c
⊕
c
.Hence,
0
( , )
( ( , ) & )
( )
z a
p a c
δ
L z a
c
δ
c
≤ <
=
∑
⊕
. (2.18)Denoted by
0
[ ]
( ( , ) & ), [ ]
[ ]
z a
p s
δ
L z a
c q s
a
p s
≤ <
=
∑
= −
andΓ
[ ]
s
=
( [ ], [ ])
q s p s
, from(2.18) we know that in order to prove (2.17) it suffice to prove
1 1
( , )
(
s k)
(
s k,
s k)
k s
a c
χ
A
− +a
−c
−≤ <
Γ
=
∑
⋅Φ
. (2.19)It is easy to know that the bits of
L z a
( , )
excel overA
s will be “0” for the bits ofa
anda
+
z
afterA
sall are “1” , so it follows that1
( , ) &
( , ) &
sL z a
c
=
L z a
c
−integer
z
belongs toS
i iffz
>>
α
s=
χ
(
A
s)
−
i
. It is clear that for1, 2,
, (
), |
| 2
ss i
i
=
χ
A
S
=
α , and|
S
0|
=
a
s−1. Hence we have0 1
1 1 1 1
1 1
0
( ( , ) & )
( ( , ) &
)
(
,
),
0,
( ( , ) & )
( ( ,
) &
)
[
1]
i i
s
s s s
z S z S
s s
z S z a
L z a
c
L z a
c
a
c
for i
L z a
c
L z a
c
p s
δ
δ
φ
δ
δ
−
− − −
∈ ∈
− −
∈ ≤ <
=
=
>
=
=
−
∑
∑
∑
∑
.The equation above can be written as
1 1
[ ]
s
χ
(
A
s) (
a
s−,
c
s−)
[
s
1]
Γ
=
Φ
+ Γ −
(2.20) So, the equation (2.19) will be followed by the induction.
For each integer
k
,1
≤ ≤
k
s
, denoted byd
k=
χ
(
A
k)
⋅
τ
(
C
k)
,(2
nk,
)
k
d d
k kζ
=
−
,Moreover, let
p a
(
k)
andq a
(
k)
be defined as in the Lemma 2 and denoted by1 1
(
) ( (
)
(
)),
k k k k
e
=
τ
C
⋅
q a
−−
p a
−σ
k= −
(
e e
k,
k)
, and assuming thatσ
0=
(1, 0),
σ
1=
(0, 0)
,and
ζ
s+1=
(1, 0)
, then we haveProposition 3 If
A
∩ = ∅
C
,
0 1
( , )
(
k i)
k s k i s
a c
σ
ζ
≤ ≤ < ≤ +
Φ
=
∑
∏
, (2.21)Proof. We will apply the induction on
s
. From Lemma 1, we can know that the Proposition 3 is true fors
=
1.
Consider the integers of lengthα
s, by the induction we have0 1
0 1
( [
1], [
1])
(
k i).
k s k i s
s
s
φ
φ
σ
ζ
≤ ≤ − < ≤
−
−
=
∑
∏
In the case
s
, it is clear that there area
s−1 integers that will carry in the positionα
s, which are1 1
2
s, 2
s1,
, 2
s1
s s
a
a
α α α
− −
−
−
+
−
. Suppose that in thesea
s−1 integers there are[
1]
p s
−
ones inφ
1[
s
−
1]
andq s
[
−
1]
ones inφ
0[
s
−
1]
respectively. Consider the lastsegments of integers from the
α
s-bit to the end, leta
kandc
kbe defined as the above andk k
a
= −
a
a
,c
k= −
c c
k , and denoted byN
0 andN
1 the numbers of the segments1 1
( ,
s) &
s1
(
)
(
)
,
02
s
n
s s s s
N
=
χ
A
⋅
τ
C
=
d
N
=
−
d
.Let 1
( (
) 1)
(
),
02
ns 1s s
N
′
=
χ
A
+ ⋅
τ
C
N
′
=
−
N
′
, it has,1 0 1 1 0 1 0
0 1 1 0
0 1
[ ]
( [
1]
[
1])
( [
1]
[
1])
[
1]
[
1]
[
1]
[
1]
( [
1]
[
1]) (
)
Im(
(
)).
s
k i
k s k i s
s
s
q s
N
s
p s
N
N q s
N p s
s
N
s
N
q s
p s
C
φ
φ
φ
φ
φ
τ
σ
ζ
≤ ≤ < ≤ +
′
′
=
− −
−
⋅
+
− −
−
⋅
+
− +
−
=
− ⋅
+
− ⋅
+
− −
−
=
∑
∏
Where
Im( , )
x y
=
y
.
As a example, the case
s
=
2
,2 1 | 1|
1
( , )
12
22
2
1 2( 1)
1(
2)
n n C
a c
d
d
d d
a
C
φ
= ⋅
+
⋅
−
⋅ + −
⋅
τ
.The case
A
∩ ≠ ∅
C
may be treated in a similar way but will require a little more consideration to setA
i∩
C
i=
B
iand as the first step to calculate in the case of a blockABC
, the detail discussion is omitted.3. Conclusion
We hope that these results presented here will be useful in the designs and cryptanalysis of ciphers in the future, the results of Proposition 1 were once appeared in the paper [1] and [2].
Reference
[1] Li An-Ping, Linear approximating for the cipher Salsa20, available at
http://www.ecrypt.eu.org/stream/papersdir/056.pdf
[2] Li An-Ping, Linear approximating for the cipher Salsa20 (II), available at
http://www.ecrypt.eu.org/stream/papersdir/067.pdf