Next Article in Journal
Characteristic Analysis of the Outer Sheath Circulating Current in a Single-Core AC Submarine Cable System
Next Article in Special Issue
Security Enhanced Symmetric Key Encryption Employing an Integer Code for the Erasure Channel
Previous Article in Journal
Viable Requirements of Curvature Coupling Helical Magnetogenesis Scenario
Previous Article in Special Issue
Nonlinearity of Boolean Functions: An Algorithmic Approach Based on Multivariate Polynomials
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Rotational Cryptanalysis on ChaCha Stream Cipher

by
Stefano Barbero
1,*,
Danilo Bazzanella
1 and
Emanuele Bellini
2
1
Department of Mathematical Sciences “Giuseppe Luigi Lagrange”, Politecnico di Torino, 10129 Torino, Italy
2
Cryptography Research Centre, Technology Innovation Institute, Abu Dhabi P.O. Box 9639, United Arab Emirates
*
Author to whom correspondence should be addressed.
Submission received: 17 March 2022 / Revised: 13 May 2022 / Accepted: 20 May 2022 / Published: 25 May 2022
(This article belongs to the Special Issue The Advances in Algebraic Coding Theory)

Abstract

:
In this paper we consider the ChaCha20 stream cipher in the related-key scenario and we study how to obtain rotational-XOR pairs with nonzero probability after the application of the first quarter round. The ChaCha20 input can be viewed as a 4 × 4 matrix of 32-bit words, where the first row of the matrix is fixed to a constant value, the second two rows represent the key, and the fourth some initialization values. Under some reasonable independence assumptions and a suitable selection of the input, we show that the aforementioned probability is about 2 251.7857 , a value greater than 2 256 , which is the one expected from a random permutation. We also investigate the existence of constants, different from the ones used in the first row of the ChaCha20 input, for which the rotational-XOR probability increases, representing a potential weakness in variants of the ChaCha20 stream cipher. So far, to our knowledge, this is the first analysis of the ChaCha20 stream cipher from a rotational-XOR perspective.
MSC:
Primary: 94A60; 11T71; Secondary: 11T06; 94D10

1. Introduction

The ChaCha20 stream cypher, published in 2008 [1], was developed by Daniel J. Bernstein as a modification of Salsa20 [2], another stream cypher designed in 2005 by the same author and then later submitted to the eSTREAM project. The aim of ChaCha20 is to increase diffusion and performance on some architectures with respect to Salsa20. Google has selected ChaCha20 along with Bernstein’s Poly1305 message authentication code as a replacement for RC4 in TLS, and its specifications can be found in [3]. Both ciphers are ARX (Add-Rotate-XOR) ciphers, i.e., built on a pseudorandom function based only on the following three 32-bit word operations: modular addition, circular rotation, and bitwise exclusive or (XOR). This pseudorandom function is itself built upon a 512 bit permutation. According to [4], both permutations are not designed to simulate ideal permutations: they are designed to simulate ideal permutations with certain symmetries, i.e., ideal permutations of the orbits of the state space under these symmetries. The input of the ChaCha20 function is partially fixed to specific asymmetric constants, ensuring that different inputs lie in different orbits. As a consequence of the ChaCha20 design, some cryptanalytic techniques, such as rotational cryptanalysis, seem hard to apply.
Related works. Rotational cryptanalysis studies the propagation of rotational pairs ( x , x r ) throughout the encryption steps of an ARX scheme. It is a probabilistic chosen-plaintext attack that turns to be an effective cryptanalytical tool against ciphers and hash functions that are based on the three ARX operations.
A rotational pair of keys was considered for the first time in the pioneering work on related keys by Biham [5]. This approach was extended by Kelsey et al. in several related-key attacks on block ciphers [6]. A rotational pair of inputs was later adopted in the cryptanalysis of the compression function of Shabal [7] (the term “rotational input” was not used yet), but it was traced only through bitwise operations and not through additions. Bernstein [8] explicitly prevented using rotational pairs in Salsa20 (and ChaCha20) by fixing non-symmetric constants in the input of the permutation. However, he did not provide any complexity or probability estimates for this kind of attack. The designers of the block cipher SEA [9] described the technique of rotational cryptanalysis in 2006 and defended against it with non-linear key-schedule and pseudorandom constants. In his Ph.D. thesis, Daum [10] described the links between modular addition and bit rotations. In 2010, the term “rotational cryptanalysis” appeared for the first time in the papers of Khovratovich and Nikolić [11,12], were they cryptanalyzed the reduced-round Threefish cipher, which is part of the Skein hash function, a SHA-3 competition candidate [13]. Their attack covered 53 rounds of Skein-256 and 57 rounds of Skein-512. In the aforementioned paper [11], the authors proved that for ARX primitives, under the assumption that the cipher can be modeled as a Markov chain, the probability to have a rotational pair of inputs which will produce a rotational pair at the output depends on the number of additions only. This claim was corrected in [14], where the authors showed that chained modular additions used in ARX ciphers do not always form a Markov chain with regards to rotational analysis. They provided a precise value of the probability of such chains and they gave a new algorithm for computing the rotational probability of ARX ciphers. Then, they used the algorithm to correct (from 12 to 7 rounds) the rotational attacks on BLAKE2 [15] and to provide valid rotational attacks against the simplified version of Skein. In 2013, rotational cryptanalysis was also applied to distinguish four rounds of KECCAK permutation [16] in time 2 221 . A crucial requirement for rotational cryptanalysis to work effectively is that all constants used in the ARX primitive must preserve their values when rotated. This requirement can be relaxed to some extent and instead of assuming completely rotational constants, one can work with constants that are almost rotational, i.e., the XOR difference between the initial constants and the rotated ones gives words of small Hamming weight. A different approach was taken by Ashur and Liu in 2016 [17]. They presented a way to compute the rotational probability when constants are injected into the state and applied their approach to Speck. In particular, they exposed, in the related-key scenario, a trail suggesting that a weak key class of size 2 39 exists, leading to a 7-round distinguisher for Speck64/32. The technique was later automated in [18], through the use of SAT solvers. In [19], a rotational cryptanalysis of the Salsa core function was presented, also finding rotational distinguishers for the Salsa and Chacha permutations: the rotational distinguisher for the ChaCha permutation performs properly only up to 8 rounds with a probability of approximately 2 489.6 , while the rotational distinguisher for the Salsa permutation performs properly up to 32 rounds with a probability of approximately 2 506.752 , clarifying the weakness of the Salsa core function with respect to rotational cryptanalysis. Finally, in [20] the authors applied rotational cryptanalysis to Chacha20 permutation without considering the injected constants in the state of the permutation, showing that it does not behave as a random permutation for up to 17 rounds, since the related probability is less than 2 505 for 17 rounds of ChaCha permutation, while, for a random permutation of the same input size, this probability is 2 511 .
Our contribution. In this paper we study the applicability to the ChaCha20 stream cipher quarter round function of the techniques due to Ashur and Liu [17], used for the rotational cryptanalysis of Speck in the presence of constants. In order to do this, we first consider the quarter round function Q of Chacha20, described in Section 2, determining the conditions which guarantee that, starting from randomly and independently chosen w -bit words, inputs x 1 , x 2 , x 3 and a w -bit constant c 0 giving the w –bit words y 0 , y 1 , y 2 , y 3 as output, i.e.,
( y 0 , y 1 , y 2 , y 3 ) = Q ( c 0 , x 1 , x 2 , x 3 ) ,
we can find a characteristics of the type
( ( y 0 r ) a , ( y 1 r ) b , ( y 2 r ) c , ( y 3 r ) d ) = Q ( c 0 , f 1 , f 2 , f 3 ) ,
for some input relations  f i = f i ( r , c 0 , x 1 , x 2 , x 3 ) , i = 1 , 2 , 3 , where r is an integer less than the word size w and a , b , c , d are w -bit strings. Then, we search for a suitable selection of a , b , c , d , and key/nonce/counter relations, the above mentioned input relations f i , i = 1 , 2 , 3 , such that, fixing the rotational amount r = 1 , we can precisely determine which input constants c 0 yield rotational-XOR pairs with high or low probability, in a related-key scenario. We determine a formula to compute this probability as a function of c 0 and we show that in the case of the constants commonly used in ChaCha20 it is greater than 2 256 , revealing the non-randomness of the quarter round permutation. Moreover we investigate the value of this probability for different constants than the ones injected in the ChaCha20 initial state, determining for which of them it increases. While in [19,20] it was only considered the core of ChaCha/Salsa, not the full stream cipher construction, to our knowledge, this is the first attempt to apply rotational analysis to the Chacha20 stream cipher in order to distinguish the behavior of the Chacha20 quarter round from a random permutation and to relate this behaviour to the values of the constants used in Chacha20.
Outline of the paper. In Section 2, we introduce the notation and the essential preliminaries, describing the ChaCha20 stream cipher and the fundamentals of rotational and rotational-XOR cryptanalysis.
In Section 3 we present our analysis. In particular, in Section 3.1, we derive a set of necessary and sufficient conditions which need to be satisfied for a rotational-XOR pair to appear in the output of ChaCha20 quarter round, given that the first word of the input is fixed to a constant value. In Section 3.2, we discuss a suitable choice of the input relations f i , i = 1 , 2 , 3 , and of the parameters a , b , c , d , allowing them to meet the above conditions.In Section 3.3, under the previous choice we compute the probability that these conditions are satisfied by a randomly and independently chosen set of inputs x i , i = 1 , 2 , 3 , as a function of the constant c 0 , i.e., the probability that rotational-XOR pairs (with rotational amount r = 1 ) ( y , ( y 1 ) δ ) appear as outputs of the quarter round. In Section 4 we discuss and resume our results. In particular, in Section 4.1 we evaluate this probability for the special constants commonly used in the ChaCha20 stream cipher. We show that, in our scenario, rotational-XOR pairs can appear in ChaCha20 after one round with probability around 2 251.7857 against the value of 2 256 for a random permutation. In Section 4.2 we describe the form of some initial constants for which these pairs are very likely. Finally, in Section 5 we give our conclusions.

2. Notation and ChaCha20 Stream Cipher Description

In this section, we first define our notation, then we describe the specifications of the ChaCha20 stream cipher and we provide the basics of rotational and rotational-XOR cryptanalysis.

2.1. Notation

Let 𝔽 2 be the binary field with two elements, and M n × n ( 𝔽 2 w ) be the set of all n × n matrices with elements in 𝔽 2 w . Depending on the context, lowercase letters stand for w -bit words or for the corresponding non-negative integers they represent, i.e.,
x = x [ w 1 ] , x [ w 2 ] , , x [ 1 ] , x [ 0 ] 𝔽 2 w , x = i = 0 w 1 x [ i ] 2 i
where x [ i ] 𝔽 2 for all i = 0 , , w 1 . In the case of ChaCha20, we have n = 4 and w = 32 . With uppercase letters we indicate a n × n matrix of n 2 words, i.e., X M n × n ( 𝔽 2 w ) .
We also use the following notation:
  • ⊕ for the bitwise exclusive or (XOR), i.e., the addition in 𝔽 2 w ;
  • ⊞ for the w -bit addition mod 2 w ;
  • ⊟ for the w -bit subtraction mod 2 w , i.e., the sum mod 2 w with the opposite of an element in 𝔽 2 w ;
  • i = 1 k x i for the w -bit addition mod 2 w of k words x 1 , , x k ;
  • x | y for the vector bitwise OR operation between x and y;
  • x | | y for the concatenation of x and y;
  • S H L ( x ) for a non–cyclic left shift by one bit of x;
  • ( I S H L ) ( x ) = x S H L ( x ) ;
  • r and r respectively for constant-distance left and right circular rotation of r bits of a w -bit word with 1 r w 1 ;
  • | | x | | for the Hamming weight of x;
  • | I | for the cardinality of a set I;
  • 1 Z for the characteristic function of a condition Z, which is equal to 1 when Z is satisfied and equal to 0 otherwise;
  • 1 ̲ = ( 0 , 0 , , 0 , 1 ) 𝔽 2 w ;
  • x y if and only if we have x [ i ] y [ i ] for all i = 0 , , w 1 ;
  • x = L h ( x ) | | R h ( x ) , where, for 1 h w 1 ,
    L h ( x ) = ( x [ w 1 ] , x [ w 2 ] , , x [ w h ] ) R h ( x ) = ( x [ w h 1 ] , x [ w h 2 ] , , x [ 1 ] , x [ 0 ] )
    and, considering x ,
    x = l h ( x ) 2 w h + r h ( x ) , where l h ( x ) = i = 0 h 1 x [ w h + i ] 2 i and r h ( x ) = i = 0 w h 1 x [ i ] 2 i
    with 0 l h ( x ) 2 h 1 and 0 r h ( x ) 2 w h 1 ;
  • · h for the operator which gives for any x N the integer x h satisfying
    0 x h 2 h 1 and x h x mod 2 h .

2.2. ChaCha20 Specification

The ChaCha20 permutation has a state of 512 bits, which can be seen as a 4 × 4 matrix whose elements are binary vectors of w = 32 bits, i.e.,
X = { x i , j } i = 0 , , 3 j = 0 , , 3 = x 0 , 0 x 0 , 1 x 0 , 2 x 0 , 3 x 1 , 0 x 1 , 1 x 1 , 2 x 1 , 3 x 2 , 0 x 2 , 1 x 2 , 2 x 2 , 3 x 3 , 0 x 3 , 1 x 3 , 2 x 3 , 3 M n × n ( 𝔽 2 w ) .
The initial state of ChaCha20 is initialized by setting the first row to a 128-bit constant value, the second and third row are used to store a 256-bit key, and the fourth row contains a 64-bit nonce and a 64-bit counter.
Definition 1
(ChaCha20 quarter round). Let x i , y i , i = 0 , 1 , 2 , 3 be w -bit words, and let ( y 0 , y 1 , y 2 , y 3 ) = Q ( x 0 , x 1 , x 2 , x 3 ) , where Q is the ChaCha20 quarter round, defined as follows:
b 0 = x 0 x 1 ( 1 ) y 0 = b 0 b 1 b 3 = b 0 x 3 r 1 y 3 = y 0 b 3 r 3 b 2 = b 3 x 2 ( 2 ) y 2 = y 3 b 2 b 1 = b 2 x 1 r 2 y 1 = y 2 b 1 r 4 .
We show in Figure 1 a schematic drawing of the ChaCha20 quarter round. The permutation used in the ChaCha20 stream cipher performs 20 rounds or, equivalently, 10 double rounds. Two consecutive rounds (or a double round) of the ChaCha20 permutation consist in applying the quarter round four times in parallel to the columns of the state (first round), and then four times in parallel to the diagonals of the state (second round). More formally:
Definition 2
(ChaCha20 column/diagonal round). Let X = { x i , j } i = 0 , , 3 j = 0 , , 3 , Y = { y i , j } i = 0 , , 3 j = 0 , , 3 be two matrices in M n × n ( 𝔽 2 w ) .
A column round Y = R C ( X ) is defined as follows, with i = 0 , 1 , 2 , 3 :
( y 0 , i , y 1 , i , y 2 , i , y 3 , i ) = Q ( x 0 , i , x 1 , i , x 2 , i , x 3 , i ) .
A diagonal round Y = R D ( X ) is defined as follows, for i = 0 , 1 , 2 , 3 and where each subscript is computed modulo n = 4 :
( y 0 , i , y 1 , i + 1 , y 2 , i + 2 , y 3 , i + 3 ) = Q ( x 0 , i , x 1 , i + 1 , x 2 , i + 2 , x 3 , i + 3 ) .

2.3. Rotational and Rotational-XOR (RX) Cryptanalysis

Rotational cryptanalysis is essentially a distinguishing attack that exploits rotational offsets with probability higher than the one for a random permutation. If we consider a w –bit word x and a rotational offset r , we call ( x , x r ) a rotational pair and we define the rotational property as the property that an operation with the input of a rotational pair gives, as output, another rotational pair. Let us denote with S an ARX scheme with q modular additions. Rotational cryptanalysis is based on the following facts:
  • The rotational property is preserved through the XOR of rotational pairs and after a rotation by a constant value r :
    ( x y ) r = ( x r ) ( y r ) , ( x r ) r = ( x r ) r ;
  • The rotational property is preserved through a modular addition of two w –bit words with a probability given by
    D r : = Pr ( x y ) r = ( x r ) ( y r ) = 1 4 ( 1 + 2 r w + 2 r + 2 w ) ,
    and computed in Corollary 4.12 of [10], this probability is a decreasing function of r , thus it is maximized when r = 1 ;
  • In the case of chained modular additions of more than two w –bit strings, D r must be evaluated using Lemma 2 in [14];
  • S ( x r ) = S ( x ) r with probability ( D r ) q
  • Given a random function P : 𝔽 2 w 𝔽 2 w , P ( x r ) = P ( x ) r with probability 2 w
Thus, we can detect non-randomness in the ARX scheme S if ( D r ) q > 2 w . For example, when r = 1 , an ARX scheme implemented with q not chained additions is vulnerable to rotational cryptanalysis if q < w / 1.415 .
Rotational-XOR cryptanalysis is also a distinguishing attack, firstly introduced in [17] where it was applied to SPECK. This attack studies the propagation of a rotational-XOR pair (RX–pair), i.e., a couple ( x , ( x r ) α ) having RX–difference α . Clearly RX cryptanalysis is a generalization of rotational cryptanalysis, since they coincide when α = 0 . Moreover for RX–pairs ( x , ( x r ) α ) and ( y , ( y r ) β ) we have
  • ( ( x y ) r ) ( α β ) = ( ( x r ) α ) ( ( y r ) β ) ;
  • ( ( x r ) α ) r = ( ( x r ) r ) ( α r ) for a fixed rotational amount r .
The propagation of RX–differences through modular addition when r = 1 can be computed using the following theorem proved in [17], whose statement has been adapted to our notation
Theorem 1
(Ashur-Liu [17]). Let x , y F 2 w be independent random variables. Let the following a 1 , b 1 , a 2 , b 2 , Δ 1 , Δ 2 be constants in F 2 w . Then the probability
Pr ( ( ( x a 1 ) ( y b 1 ) ) Δ 1 ) r = ( ( ( x r ) a 2 ) ( ( y r ) b 2 ) ) Δ 2
when r = 1 and w is sufficiently large is equal to
𝟙 { ( a 1 ̲ ) b } 2 | | b | | · p 1 + 𝟙 { a b } · 2 | | b | | · p 2 ,
where
a = ( I S H L ) ( δ 1 δ 2 δ 3 ) , b = S H L ( ( δ 1 δ 3 ) | ( δ 2 δ 3 ) ) ,
δ 1 = R 1 ( a 1 ) L w 1 ( a 2 ) , δ 2 = R 1 ( b 1 ) L w 1 ( b 2 ) , δ 3 = R 1 ( Δ 1 ) L w 1 ( Δ 2 ) ,
and p 1 = 2 3 , p 2 = 3 · 2 3 2 1.415 .

3. Searching for Rotational/RX Pairs in ChaCha20

The aim of this section is to consider the ChaCha20 stream cipher, in which the first row in its initial state has constant entries, giving general conditions on the propagation of rotational/RX–pairs that we simply call rotational propagation. Moreover, by a suitable choice of inputs and parameters, we find a special case in which the rotational propagation can have a non-negligible probability depending on a certain family of these constants.

3.1. Conditions for the Rotational Propagation

Recalling that the first row of the ChaCha20 4 × 4 matrix has constant entries, the following proposition holds
Proposition 1.
Let us consider the ChaCha20 quarter round Q , c 0 a constant w –bit string and the rotational amount r with 1 r w 1 . If we have
Q ( c 0 , x 1 , x 2 , x 3 ) = ( y 0 , y 1 , y 2 , y 3 )
and we consider the w –bit strings a , b , c , d and the entries f i = f i ( r , c 0 , x 1 , x 2 , x 3 ) , i = 1 , 2 , 3 , then
( ( y 0 r ) a , ( y 1 r ) b , ( y 2 r ) c , ( y 3 r ) d ) = Q ( c 0 , f 1 , f 2 , f 3 ) ( c 0 x 1 r ) ( x 3 r ) ( a r 1 ) ( d ( r 1 + r 3 ) ) = ( c 0 f 1 ) f 3 ( b 3 x 2 r ) ( x 1 r ) ( c r 2 ) ( b ( r 2 + r 4 ) ) = ( b 3 r a ( d r 3 ) ) f 2 f 1 ( c 0 f 1 ) ( b 1 r ) c ( b r 4 ) = ( c 0 x 1 b 1 r ) a ( y 3 r d ) ( ( b 3 r ) a ( d r 3 ) ) f 2 = ( y 3 b 3 x 2 r ) c .
We call input relations the functions f i = f i ( r , c 0 , x 1 , x 2 , x 3 ) , i = 1 , 2 , 3 .
Proof. 
If we use the input ( c 0 , f 1 , f 2 , f 3 ) instead of the input ( c 0 , x 1 , x 2 , x 3 ) , we find
b 0 ˜ = c 0 f 1 ( 6 ) y 0 ˜ = b 0 ˜ b 1 ˜
b 3 ˜ = b 0 ˜ f 3 r 1 ( 7 ) y 3 ˜ = y 0 ˜ b 3 ˜ r 3
b 2 ˜ = b 3 ˜ f 2 ( 8 ) y 2 ˜ = y 3 ˜ b 2 ˜
b 1 ˜ = b 2 ˜ f 1 r 2 ( 9 ) y 1 ˜ = y 2 ˜ b 1 ˜ r 4 .
We have to satisfy the following conditions
y 0 ˜ = ( y 0 r ) a b 0 ˜ b 1 ˜ = ( b 0 b 1 r ) a
y 3 ˜ = ( y 3 r ) d y 0 ˜ b 3 ˜ r 3 = ( y 0 b 3 r 3 r ) d
y 2 ˜ = ( y 2 r ) c y 3 ˜ b 2 ˜ = ( y 3 b 2 r ) c
y 1 ˜ = ( y 1 r ) b y 2 ˜ b 1 ˜ r 4 = ( y 2 b 1 r 4 r ) b
where (11) and (13) easily give
b 3 ˜ = ( b 3 r ) a ( d r 3 )
from conditions y 0 ˜ = ( y 0 r ) a and
b 1 ˜ = ( b 1 r ) c ( b r 4 ) ,
since we have the condition y 2 ˜ = ( y 2 r ) c . Now from (14) and (7) we find
b 0 ˜ f 3 = ( b 0 r ) ( x 3 r ) ( a r 1 ) ( d ( r 1 + r 3 ) )
and from (15) and (9) we have
b 2 ˜ f 1 = b 2 r x 1 r ( c r 2 ) ( b ( r 2 + r 4 ) )
Thus, the four conditions we need to satisfy are (16), (17), (10) and (12). If in (16) we substitute (6) and we take in account (1) in Definition 1, we find the first condition of our thesis
( c 0 x 1 r ) ( x 3 r ) ( a r 1 ) ( d ( r 1 + r 3 ) ) = ( c 0 f 1 ) f 3 .
If we substitute (8), (14) and (2) in (17) we find the second condition of our thesis
( b 3 x 2 r ) ( x 1 r ) ( c r 2 ) ( b ( r 2 + r 4 ) ) = = ( b 3 r a ( d r 3 ) ) f 2 f 1 .
Moreover, if we substitute (6), (15) and (1) in (10), we obtain the third condition of our thesis
( c 0 f 1 ) ( b 1 r ) c ( b r 4 ) = ( c 0 x 1 b 1 r ) a .
Finally if we substitute (11), (8), (14) and (2) in (12) we have the last condition of our thesis
( y 3 r d ) ( ( b 3 r ) a ( d r 3 ) ) f 2 = ( y 3 b 3 x 2 r ) c .
 □

3.2. On the Choices of the Input Relations and of a, b, c, d

One can consider many different choices for the values of f i and a , b , c , d in order to satisfy the conditions of Proposition 1. Our intention is to set these values in order to obtain simplified conditions which can be satisfied with a non-negligible probability depending on the values given to c 0 . Considering Equations (14) and (15), a first simplification we apply is to choose a, b, c and d such that
a ( d r 3 ) = 0 , c ( b r 4 ) = 0 .
With this setting the conditions of Proposition 1 become
( c 0 f 1 ) f 3 = ( c 0 x 1 r ) ( x 3 r )
b 3 r f 2 f 1 = ( b 3 x 2 r ) ( x 1 r )
( c 0 f 1 ) ( b 1 r ) = ( c 0 x 1 b 1 r ) a
( ( y 3 r ) d ) ( b 3 r ) f 2 = ( y 3 b 3 x 2 r ) c ,
and we have (21) and (22) satisfied when
a = [ ( c 0 f 1 ) ( b 1 r ) ] [ c 0 x 1 b 1 r ] c = [ ( ( y 3 r ) d ) ( b 3 r ) f 2 ] [ y 3 b 3 x 2 r ] .
Regarding the input relations, we consider expressions of the kind f i = f i ( x i , c 0 , r ) , which seem reasonable choices once we look to the remaining conditions (19) and (20). Indeed we may select f 3 and f 2 as
f 3 = x 3 r , f 2 = x 2 r ,
in order to simplify (19) and to give an expression for (20) very similar to the condition of rotational propagation through modular addition, obtaining
( c 0 f 1 ) = c 0 x 1 r
b 3 r ( x 2 r ) f 1 = ( b 3 x 2 r ) ( x 1 r ) .
Now we have to think about f 1 and, consequently, about how to manage conditions (25) and (26). Clearly a possibility is to choose f 1 = x 1 r in order to reduce (26) exactly to the condition for the rotational propagation through modular addition
b 3 r ( x 2 r ) = b 3 x 2 r .
In this case (25) becomes
c 0 x 1 r = c 0 ( x 1 r ) ,
which holds for some x 1 only under particular conditions on c 0 . These conditions turn out to be too restrictive for our purposes. At the end of this subsection, we will prove them in Proposition 2, explaining why they give rise to a small number of possible choices for c 0 in order to obtain nonzero probability for (25). This part can be skipped over by the reader without problems. Therefore we may choose f 1 as something different from x 1 r and consequently we may consider (26) as a condition of the form
b 3 r ( x 2 r ) = ( b 3 x 2 σ ( x 1 , c 0 , r ) ) r
where σ in general is not a constant, since it depends on x 1 . But we may combine the law of total probability with the Ashur-Liu Theorem 1 in [17] in order to find a probability estimate for (29) in the case r = 1 . So a good choice is to consider the case r = 1 and use (25) in order to define f 1 as we will do in the next subsection.
Proposition 2.
If we consider
c 0 = l r ( c 0 ) 2 w r + r r ( c 0 ) , c 0 r = l r ( c 0 r ) 2 w r + r r ( c 0 r ) , x 1 = l r ( x 1 ) 2 w r + r r ( x 1 ) ,
and
γ L = 𝟙 { l r ( c 0 r ) + l r ( x 1 ) 2 r } , γ R = 𝟙 { r r ( c 0 ) + r r ( x 1 ) 2 w r }
then condition (28) holds if and only if we have
r r ( c 0 ) = r r ( c 0 r ) + γ L w r , l r ( c 0 r ) = l r ( c 0 ) + γ R r
or, in other words, if and only if
c 0 ( c 0 r ) = ( γ R ) 2 w r + γ L w .
Proof. 
The proof is quite straightforward, since from (30) we have
c 0 = ( c 0 r ) r = r r ( c 0 r ) 2 r + l r ( c 0 r ) , x 1 r = r r ( x 1 ) 2 r + l r ( x 1 )
thus
c 0 ( x 1 r ) = r r ( c 0 r ) + r r ( x 1 ) + γ L w r 2 r + l r ( c 0 r ) + l r ( x 1 ) r
and, since
c 0 x 1 = l r ( c 0 ) + l r ( x 1 ) + γ R r 2 w r + r r ( x 1 ) + r r ( c 0 ) w r ,
we obtain
( c 0 x 1 ) r = r r ( x 1 ) + r r ( c 0 ) w r 2 r + l r ( c 0 ) + l r ( x 1 ) + γ R r .
Therefore comparing (32) and (33) we find (31). □
Following this choice, with arguments similar to the ones used by Daum in [10], we may evaluate some probability different from zero for condition (28) only when one of the following conditions is satisfied
  • c 0 ( c 0 r ) = 2 w 2 w r + 1 , i.e., γ L = γ R = 1 , which is equivalent to the equation
    ( l r ( c 0 r ) 1 ) ( 2 w r 1 ) = r r ( c 0 r ) ( 2 r 1 )
    and it gives 2 gcd ( w , r ) 1 possible values for c 0 ;
  • c 0 ( c 0 r ) = 1 , i.e., γ L = 1 , γ R = 0 , which is equivalent to the equation
    r r ( c 0 r ) ( 2 r 1 ) l r ( c 0 r ) ( 2 w r 1 ) = 1
    and it gives one value for c 0 only when gcd ( w , r ) = 1 and otherwise it is impossible;
  • c 0 ( c 0 r ) = 0 , i.e., γ L = γ R = 0 , which is equivalent to the equation
    l r ( c 0 r ) ( 2 w r 1 ) = r r ( c 0 r ) ( 2 r 1 )
    and it gives 2 gcd ( w , r ) possible values for c 0 ;
  • c 0 ( c 0 r ) = 2 w 2 w r , i.e., γ L = 0 , γ R = 1 , which is equivalent to the equation
    ( l r ( c 0 r ) 1 ) ( 2 w r 1 ) r r ( c 0 ) ( 2 r 1 ) = 1
    and it gives one value for c 0 only when gcd ( w , r ) = 1 and otherwise it is impossible.
The strong dependence from gcd ( w , r ) of the possible values of c 0 for which (25) holds for some x 1 seems too limiting for our purposes. For example, when gcd ( w , r ) = 1 we have only two suitable values for c 0 from the third case and only a single value from the remaining ones.

3.3. Probability of Rotational Propagation for 1 Bit Rotations

From what we have previously pointed out, we will consider from now on r = 1 with the choices (24), (35) and (29), where
σ ( x 1 , c 0 , 1 ) = ( f 1 1 ) x 1 .
and we use condition (25) in order to define f 1
c 0 f 1 = ( c 0 x 1 ) 1 f 1 ( x 1 , c 0 , 1 ) = ( ( c 0 x 1 ) 1 ) c 0
This definition of f 1 seems reasonable since we can simultaneously have (25) automatically satisfied and a better range of possible values for σ ( x 1 , c 0 , 1 ) that may give a non-negligible probability for condition (26).
We will follow this path: first we will prove the following Corollary 1 of Theorem 1, then we will use it together with the law of total probability in order to find a formula for the probability of (29) depending on c 0 and in particular on the cardinalities of some sets related to c 0 . Finally, we will evaluate these cardinalities in Lemma 1 and we will give in Theorem 2 the value of this probability making explicit its dependence on c 0 .
Corollary 1.
Let x , y F 2 w be independent random variables, r = 1 and
σ = L 1 ( σ ) | | R 1 ( σ ) = σ [ w 1 ] | | σ [ w 2 ] , σ [ w 3 ] , , σ [ 1 ] , σ [ 0 ]
a constant word in F 2 w . If j, 0 j w 1 , is the index of the first bit equal to 0 in R 1 ( σ ) starting from the right to the left, with the convention that j = w 1 only when R 1 ( σ ) has all the entries equal to 1, then
Pr ( ( x y ) σ ) 1 = ( x 1 ) ( y 1 ) = P ( σ ) ,
where
P ( σ ) = p 2 if j = 0 and σ [ i ] = 0 for all i = 0 , w 2 2 j p 1 if j = w 1 or , if j 1 , σ [ i ] = 0 for all i = j + 1 , , w 2 0 otherwise .
Proof. 
We observe that (36) is a special case of (3) when a 1 = a 2 = b 1 = b 2 = Δ 2 = 0 , σ = Δ 1 . Thus from (5) we find δ 1 = δ 2 = 0 and δ 3 = R 1 ( σ ) . Therefore
δ 1 δ 2 δ 3 = R 1 ( σ ) ( δ 1 δ 3 ) | ( δ 2 δ 3 ) = ( δ 3 | δ 3 ) = δ 3 = R 1 ( σ )
b = S H L ( R 1 ( σ ) ) = σ [ w 3 ] , σ [ w 4 ] , , σ [ 1 ] , σ [ 0 ] , 0
and
a = ( I S H L ) ( δ 1 δ 2 δ 3 ) = ( I S H L ) ( R 1 ( σ ) ) = R 1 ( σ ) S H L ( R 1 ( σ ) ) = = ( σ [ w 2 ] σ [ w 3 ] , , σ [ h + 1 ] σ [ h ] , , σ [ 1 ] σ [ 0 ] , σ [ 0 ] )
a 1 ̲ = ( σ [ w 2 ] σ [ w 3 ] , , σ [ h + 1 ] σ [ h ] , , σ [ 1 ] σ [ 0 ] , σ [ 0 ] 1 ) .
We obtain 𝟙 { ( a 1 ̲ ) b } = 1 if and only if we have
σ [ 0 ] 1 0 σ [ 0 ] = 1
and, for all 0 h w 3 ,
σ [ h + 1 ] σ [ h ] σ [ h ] .
Clearly, condition (41) holds when all the bits σ [ h ] are equal to 1 for any σ [ h + 1 ] 𝔽 2 , while, if σ [ j ] , j 1 , is the first bit equal to 0 in R 1 ( σ ) starting from the right to the left, condition (41) holds for h j if and only if σ [ h + 1 ] = 0 . Thus in order to have 𝟙 { ( a 1 ̲ ) b } = 1 , we need R 1 ( σ ) such that | | R 1 ( σ ) | | = j w 2 , where all the first j bits from σ [ 0 ] to σ [ j 1 ] are equal to 1 and the remaining ones from σ [ j ] to σ [ w 2 ] are equal to 0, or | | R 1 ( σ ) | | = w 1 , i.e., all the bits of R 1 ( σ ) are equal to 1. In these cases we find from Theorem 1 that P ( σ ) = 2 j p 1 . On the other hand 𝟙 { a b } is equal to 1 if and only if we have
σ [ 0 ] 0 σ [ 0 ] = 0
and for all 0 h w 3 condition (41) holds. Since σ [ h ] = 0 in (41) implies σ [ h + 1 ] = 0 and we have σ [ 0 ] = 0 , an easy inductive argument shows that all the bits of R 1 ( σ ) must be equal to 0 in order to have 𝟙 { a b } = 1 . Thus | | R 1 ( σ ) | | = 0 and we find from Theorem 1 P ( σ ) = p 2 . We finally observe that the two characteristic functions 𝟙 { ( a 1 ̲ ) b } and 𝟙 { a b } can not be contemporarily equal to 1, and they are contemporarily equal to 0, with P ( σ ) = 0 , for any other value of R 1 ( σ ) different from the ones we have pointed out. □
Thanks to the law of total probability, since for a fixed v we may assume σ ( v , c 0 , 1 ) as a constant while b 3 and x 2 are independent variables, we find
Pr ( b 3 x 2 σ ( x 1 , c 0 , 1 ) ) 1 = b 3 1 ( x 2 1 ) = = v F 2 w Pr x 1 = v · Pr ( b 3 x 2 σ ( x 1 , c 0 , 1 ) ) 1 = b 3 1 ( x 2 1 ) | x 1 = v = = 1 2 w v F 2 w Pr ( b 3 x 2 σ ( v , c 0 , 1 ) ) 1 = b 3 1 ( x 2 1 ) = = 1 2 w v F 2 w P ( σ ( v , c 0 , 1 ) ) = P ( c 0 ) ,
where we used the fact that x 1 is uniformly distributed, so Pr x 1 = v = 1 2 w . In order to explicitly evaluate P ( c 0 ) applying the results of Corollary 1, we now define sets of w –bit words having a special form and, in the next Lemma 1, we will find their cardinalities, depending on c 0 .
Definition 3.
Let us consider the vectors u ( δ , h ) F 2 w such that
u ( δ , h ) = ( δ , 0 , 0 , 0 , , 0 w 1 h - zeros , 1 , 1 , 1 , , 1 ) h - ones where h = 0 , 1 , w 1 , δ 𝔽 2
We define the sets I h as
I h = { v F 2 w : σ ( v , c 0 , 1 ) = u ( δ , h ) , δ 2 } .
Therefore, from Corollary 1 we have the following explicit expression for P ( c 0 )
P ( c 0 ) = 1 2 w v F 2 w P ( σ ( v , c 0 , 1 ) ) = 1 2 w | I 0 | p 2 + p 1 h = 1 w 1 | I h | · 2 h = = 1 2 w + 3 3 | I 0 | + h = 1 w 1 | I h | · 2 h ,
where, for h = 0 , , w 1 , we evaluate the cardinalities | I h | in the following lemma.
Lemma 1.
Let us consider σ and f 1 respectively defined as in (34) and (35). Then we have
| I 0 | = 2 w 1 if c 0 = ( 0 , 0 , 0 , , 0 w 1 - zeros , 1 )   or   c 0 = ( 1 , 1 , 1 , 1 , , 1 ) w - ones 2 w if c 0 = ( 0 , 0 , 0 , 0 , , 0 ) w - zeros 0 otherwise
and
| I h | = 2 if h = w 1 , w 2 and c 0 [ 0 ] = 1 2 w 1 h if 1 h w 3 , c 0 [ 0 ] = 1 and c 0 [ i ] = j 2 for all i = h + 1 , , w 1 4 if h = w 1 , w 2 and c 0 [ 0 ] = 0 , c 0 [ 1 ] = 1 2 w h if 1 h w 3 , c 0 [ 0 ] = 0 , c 0 [ 1 ] = 1 and c 0 [ i ] = j 𝔽 2 for all i = h + 1 , , w 1 0 otherwise .
Proof. 
First of all, we recall that v I h if and only if
σ ( v , c 0 , 1 ) = ( f 1 ( v , c 0 , 1 ) 1 ) v = u ( δ , h )
or, equivalently, if and only if
f 1 ( v , c 0 , 1 ) = ( u ( δ , h ) v ) 1
and if we use (35) we finally have the condition
v I h ( c 0 v ) 1 = ( ( u ( δ , h ) v ) 1 ) c 0 .
If we consider
c 0 = l 1 ( c 0 ) 2 w 1 + r 1 ( c 0 ) = c 0 [ w 1 ] 2 w 1 + i = 0 w 2 c 0 [ i ] 2 i , v = l 1 ( v ) 2 w 1 + r 1 ( v ) = v [ w 1 ] 2 w 1 + i = 0 w 2 v [ i ] 2 i ,
we find
( c 0 v ) 1 = r 1 ( c 0 ) + r 1 ( v ) w 1 · 2 + c 0 [ w 1 ] + v [ w 1 ] + γ R 1 ,
where γ R = 𝟙 { r 1 ( c 0 ) + r 1 ( v ) 2 w 1 } . On the other hand, we have
( u ( δ , h ) v ) 1 = v [ w 2 ] u [ w 2 ] , v [ w 3 ] u [ w 3 ] , , v [ 0 ] u [ 0 ] , v [ w 1 ] δ
and, since
c 0 = 2 c 0 [ w 1 ] 2 w 2 + 1 2 i = 1 w 2 c 0 [ i ] 2 i + c 0 [ 0 ] = 2 c 0 [ w 1 ] 2 w 2 + r 1 ( c 0 ) c 0 [ 0 ] 2 + c 0 [ 0 ] ,
u ( δ , h ) v = l 1 ( ( u ( δ , h ) v ) ) 2 w 1 + r 1 ( ( u ( δ , h ) v ) ,
where l 1 ( ( u ( δ , h ) v ) = v [ w 1 ] δ , and by Definition 3
v ¯ = r 1 ( ( u ( δ , h ) v ) = i = 0 w 2 ( v [ i ] u [ i ] ) 2 i = = i = h w 2 ( v [ i ] u [ i ] ) 2 i + i = 0 h 1 ( v [ i ] u [ i ] ) 2 i = = i = h w 2 v [ i ] 2 i + i = 0 h 1 ( v [ i ] 1 ) 2 i ,
we obtain
( ( u ( δ , h ) v ) 1 ) c 0 = = c 0 [ w 1 ] 2 w 2 + r 1 ( c 0 ) c 0 [ 0 ] 2 + v ¯ + γ L w 1 · 2 + c 0 [ 0 ] + v [ w 1 ] δ 1 ,
where γ L = 𝟙 { c 0 [ 0 ] + v [ w 1 ] δ 2 } .
Therefore, comparing (48) and (50), we find that condition (46) is equivalent to the system of congruences
r 1 ( c 0 ) + r 1 ( v ) c 0 [ w 1 ] 2 w 2 + r 1 ( c 0 ) c 0 [ 0 ] 2 + v ¯ + γ L mod 2 w 1 c 0 [ w 1 ] + v [ w 1 ] + γ R c 0 [ 0 ] + v [ w 1 ] δ mod 2 ,
where, using (47) and (49), and observing that
i = 0 h 1 ( v [ i ] + ( v [ i ] 1 ) ) 2 i = i = 0 h 1 2 i = 2 h 1 , r 1 ( c 0 ) + c 0 [ 0 ] 2 = i = 0 w 3 c 0 [ i + 1 ] 2 i + c 0 [ 0 ] ,
we can rewrite the first congruence of (51) as
i = 0 w 3 c 0 [ i + 1 ] 2 i + c 0 [ 0 ] + 2 h 1 c 0 [ w 1 ] 2 w 2 + 2 i = 0 h 1 ( v [ i ] 1 ) 2 i + γ L mod 2 w 1 .
Now, in solving (52) we have to consider the following cases.
  • c 0 [ 0 ] = 1 , h 1 : in this case when h = w 1 congruence (52) becomes
    i = 1 w 3 c 0 [ i + 1 ] 2 i + c 0 [ 1 ] c 0 [ w 1 ] 2 w 2 + i = 1 w 3 ( v [ i 1 ] 1 ) 2 i + ( v [ w 3 ] 1 ) 2 w 2 + γ L mod 2 w 1 .
    Comparing the two members it clearly holds if and only if
    v [ i 1 ] = c 0 [ i + 1 ] 1 , i = 1 , , w 2 , and c 0 [ 1 ] = γ L
    and, by definition of γ L , the second congruence in (51) holds if
    v [ w 1 ] c 0 [ w 1 ] + γ R mod 2 and , if γ L = 1 δ = v [ w 1 ] 1 v [ w 1 ] c 0 [ w 1 ] + γ R + 1 mod 2 and , if γ L = 0 δ = v [ w 1 ]
    where γ R is fixed by (53) and by the free choice of v [ w 2 ] . Therefore we always have only 2 solutions when h = w 1 . When h = w 2 congruence (52) becomes
    i = 1 w 3 c 0 [ i + 1 ] 2 i + c 0 [ 1 ] + 2 w 2 c 0 [ w 1 ] 2 w 2 + i = 1 w 3 ( v [ i 1 ] 1 ) 2 i + v [ w 3 ] 1 2 w 2 + γ L mod 2 w 1
    giving v [ w 3 ] = [ ( 1 + c 0 [ w 1 ] ) mod 2 ] 1 and conditions similar to (53)
    v [ i 1 ] = c 0 [ i + 1 ] 1 , i = 1 , , w 3 , and c 0 [ 1 ] = γ L
    and the same conditions (54) for congruence (51). Thus also when h = w 2 we find that we do not have conditions on v [ w 2 ] and we always have only 2 solutions. Finally if 1 h w 3 both members of the congruence (52) are less than 2 w 1 and they have the same parity if and only if c 0 [ 1 ] = γ L . Moreover, we have
    2 w 2 2 h + 1 = i = h + 1 w 3 2 i i = h + 1 w 3 c 0 [ i + 1 ] 2 i ,
    where the equality holds if and only if c 0 [ i + 1 ] = 1 for all i = h + 1 , , w 3 , and
    i = 1 h 1 c 0 [ i + 1 ] 2 i 2 h 2 , i = 1 h 1 ( v [ i 1 ] 1 ) 2 i 2 h 2 ,
    where the equalities hold if c 0 [ i + 1 ] = ( v [ h 1 ] 1 ) = 1 for all i = 1 , , h 1 . Thus we find
    i = h + 1 w 3 c 0 [ i + 1 ] 2 i + ( c 0 [ h + 1 ] + 1 ) 2 h + i = 1 h 1 c 0 [ i + 1 ] 2 i = = c 0 [ w 1 ] 2 w 2 + ( v [ h 1 ] 1 ) 2 h + i = 1 h 1 ( v [ i 1 ] 1 ) 2 i ,
    which gives v [ i 1 ] = c 0 [ i + 1 ] 1 for all i = 1 , , h 1 and, if c 0 [ w 1 ] = j 2 , we need c 0 [ i + 1 ] = j for all i = h + 1 , , w 3 and v [ h 1 ] = j . Therefore we have solutions only when the constant c 0 is such that c 0 [ i ] = j 𝔽 2 for all i = h + 1 , , w 1 and, since also in these cases the same conditions (54) for congruence (51) hold, we have v [ i ] free for all i = h , h + 1 , , w 2 and 2 w 1 h possible solutions.
  • c 0 [ 0 ] = 0 , h 1 : in this case we necessarily have γ L = 0 and v [ w 1 ] δ 𝔽 2 since γ L = 1 only when c 0 [ 0 ] = v [ w 1 ] δ = 1 , thus (52) becomes
    i = 1 w 3 c 0 [ i + 1 ] 2 i + c 0 [ 1 ] + 2 h 1 c 0 [ w 1 ] 2 w 2 + 2 i = 0 h 1 ( v [ i ] 1 ) 2 i mod 2 w 1
    and we have solutions only when c 0 [ 1 ] = 1 , in order to preserve the same parity for both members. Under this supplementary condition, congruence (55) is equivalent to
    i = 1 w 3 c 0 [ i + 1 ] 2 i + 2 h c 0 [ w 1 ] 2 w 2 + 2 i = 0 h 1 ( v [ i ] 1 ) 2 i mod 2 w 1 ,
    moreover in this case the second congruence in (51) gives
    v [ w 1 ] c 0 [ w 1 ] + γ R mod 2 and δ = v [ w 1 ]
    or
    v [ w 1 ] c 0 [ w 1 ] + γ R + 1 mod 2 and δ = v [ w 1 ] 1 ,
    i.e., for every solution of (56) we have also two possibilities for v [ w 1 ] . Thus, since (56) can be solved as in the previous case distinguishing between h = w 1 , h = w 2 , and 1 h w 3 , the number of solutions is doubled. So, if c 0 [ 1 ] = 1 and h = w 1 , w 2 , we find 4 solutions, while, if 1 h w 3 and c 0 [ i ] = j 2 for all i = h + 1 , , w 1 , we have 2 w h solutions.
  • h = 0 : in this last case we have v ¯ = r 1 ( v ) in the first congruence in (51) so this congruence becomes the equality
    i = 0 w 3 c 0 [ i + 1 ] 2 i + c 0 [ 0 ] = c 0 [ w 1 ] 2 w 2 + γ L .
    Since
    i = 0 w 3 c 0 [ i + 1 ] 2 i 2 w 2 1 ,
    if c 0 [ 0 ] = 0 we have solutions only when c 0 [ i ] = 0 for all i = 1 , , w 1 and γ L = 0 , with the two possibilities for v [ w 1 ] given by
    v [ w 1 ] γ R mod 2 and δ = v [ w 1 ]
    or
    v [ w 1 ] γ R + 1 mod 2 and δ = v [ w 1 ] 1 ,
    so all v F 2 w are solutions. On the other hand, if c 0 [ 0 ] = 1 and c 0 [ w 1 ] = 1 , from (57) we also need c 0 [ i ] = 1 for all i = 1 , , w 2 and γ L = 0 , therefore δ = v [ w 1 ] and v [ w 1 ] γ R mod 2 . Thus only v [ w 1 ] is fixed and we have 2 w 1 solutions. Finally, when c 0 [ 0 ] = 1 and c 0 [ w 1 ] = 0 we also need c 0 [ i ] = 0 for all i = 1 , , w 2 and γ L = 1 . Therefore δ = v [ w 1 ] 1 and v [ w 1 ] γ R mod 2 , thus also in this case we have only v [ w 1 ] fixed and, consequently, there are 2 w 1 solutions.
 □
Thanks to Lemma 1 and to (44), we have nonzero probabilities only if c 0 satisfies one of the following conditions
  • c 0 [ 0 ] = 1 ,
  • c 0 [ 0 ] = 0 and c 0 [ 1 ] = 1 ,
  • c 0 [ i ] = 0 , i = 0 , , w 1 , i.e., c 0 is the zero vector in F 2 w ,
or, in other words, there are 3 · 2 w 2 + 1 possible choices of c 0 which are about 3 4 of all the possible constants.
In the following theorem we give the exact values of P ( c 0 ) excluding the only three trivial values of c 0 for which | I 0 | 0 .
Theorem 2.
Let us consider c 0 such that c 0 [ i ] = j F 2 for all i = t + 1 , , w 2 with 1 t w 3 and c 0 different from ( 0 , 0 , 0 , , 0 w 1 zeros , 1 ) , ( 1 , 1 , 1 , 1 , , 1 ) w ones , ( 0 , 0 , 0 , 0 , , 0 ) w zeros . Then we have
P ( c 0 ) = 9 + 8 · δ c 0 [ w 1 ] , c 0 [ w 2 ] · 2 2 ( w 2 t ) 1 3 · 2 2 w + 1 if c 0 [ 0 ] = 1 9 + 8 · δ c 0 [ w 1 ] , c 0 [ w 2 ] · 2 2 ( w 2 t ) 1 3 · 2 2 w if c 0 [ 0 ] = 0 , c 0 [ 1 ] = 1 ,
where
δ c 0 [ w 1 ] , c 0 [ w 2 ] = 1 if c 0 [ w 1 ] = c 0 [ w 2 ] 0 if c 0 [ w 1 ] c 0 [ w 2 ] .
Proof. 
With our choices of c 0 and from the results of Lemma 1, we have | I h | = 0 for h = 0 , 1 , , t 1 , | I h | 0 for h = t , , w 3 if c 0 [ w 1 ] = c 0 [ w 2 ] , and | I h | 0 if h = w 1 , w 2 . Thus, from (44) we obtain
P ( c 0 ) = 1 2 w + 3 | I w 1 | 2 ( w 1 ) + | I w 2 | 2 ( w 2 ) + δ c 0 [ w 1 ] , c 0 [ w 2 ] h = t w 3 | I h | · 2 h .
If c 0 [ 0 ] = 1 from the results of Lemma 1 we find
P ( c 0 ) = 1 2 w + 3 2 ( w 2 ) + 2 ( w 3 ) + δ c 0 [ w 1 ] , c 0 [ w 2 ] 2 w 1 h = t w 3 2 2 h
and, since
2 w 1 h = t w 3 2 2 h = 4 · 2 2 ( w 2 t ) 1 3 · 2 w 3 ,
an easy calculation gives
P ( c 0 ) = 9 + 8 · δ c 0 [ w 1 ] , c 0 [ w 2 ] · 2 2 ( w 2 t ) 1 3 · 2 2 w + 1 .
The case c 0 [ 0 ] = 0 and c 0 [ 1 ] = 1 is straightforward, since all the non-zero cardinalities of the sets | I h | are doubled. □

4. Discussion

We first resume our results: with the choices (18), (23), (24) and (35)
  • conditions (21) and (22) hold automatically from (23);
  • condition (25) holds automatically from (35);
  • condition (26), for w sufficiently large, holds with probability P ( c 0 ) given by (44) and explicitly by (58), under the assumption of independence and uniform distribution for x 1 , x 2 and b 3 .
Therefore when r = 1 and w is sufficiently large, if c 0 satisfies the hypotheses of Theorem 2 and following our choices for f 1 , f 2 , f 3 , a, b, c and d, with the aforementioned assumptions of independence and uniform distribution for x 1 , x 2 and b 3 , the equality
( ( y 0 1 ) a , ( y 1 1 ) b , ( y 2 1 ) c , ( y 3 1 ) d ) = Q ( c 0 , f 1 , f 2 , f 3 )
holds with probability P ( c 0 ) given by (58).

4.1. Propagation Probability of Rotational-XOR Pairs through ChaCha20 Quarter Round

If we consider the four constants used in the ChaCha20 definition, they all satisfy c 0 [ 0 ] = 1 , thus we have
  • [ expa ] = 01100101011110000111000001100001 and δ c 0 [ w 1 ] , c 0 [ w 2 ] = 0 , so P ( c 0 ) = 3 2 2 w + 1 , which gives P ( c 0 ) = 3 · 2 65 when w = 32 ;
  • [ nd 3 ] = 01101110011001000010000000110011 and δ c 0 [ w 1 ] , c 0 [ w 2 ] = 0 with P ( c 0 ) as before;
  • [ 2 - by ] = 00110010001011010110001001111001 and δ c 0 [ w 1 ] , c 0 [ w 2 ] = 1 , t = w 3 , so P ( c 0 ) = 11 2 2 w + 1 , which gives P ( c 0 ) = 11 · 2 65 when w = 32 ;
  • [ te k ] = 01110100011001010010000001101011 and δ c 0 [ w 1 ] , c 0 [ w 2 ] = 0 with P ( c 0 ) as for the first two constants.
A simple calculation shows that the probability of rotational propagation related to the 4 columns of the initial state of ChaCha20 is 297 · 2 260 2 251.7857 which is greater than 2 32 · 8 = 2 256 .

4.2. ChaCha20 Alternative Constants Giving Non-Negligible Probability

In our scenario, this probability increases for some selections of alternative constants and may represent a weakness for variants of ChaCha20 against rotational attacks. From Theorem 2 we observe that P ( c 0 ) has always a higher value when c 0 [ w 1 ] = c 0 [ w 2 ] . In this case we find
P ( c 0 ) = 2 2 w 2 t 1 + 1 3 · 2 2 w + 1 if c 0 [ 0 ] = 1 2 2 w 2 t 1 + 1 3 · 2 2 w if c 0 [ 0 ] = 0 , c 0 [ 1 ] = 1 ,
both of them are greater than 2 2 w for all the possible values of t 1 , 2 , , w 3 and increase their value when t decreases. Thus, constants c 0 satisfying the hypotheses of Theorem 2 and giving a rotational propagation probability for the quarter round greater than 2 64 when w = 32 have one of the two following forms
c 0 = ( j , j , , j , 2 equal bits c 0 [ t ] , c 0 [ t 1 ] , , c 0 [ 2 ] , c 0 [ 1 ] , 1 ) ( j , j , , j , 2 equal bits c 0 [ t ] , c 0 [ t 1 ] , , c 0 [ 2 ] , 1 , 0 ) .
Finally, we consider the following special values of c 0 :
  • c 0 = ( 0 , 0 , 0 , , 0 w 1 zeros , 1 ) and c 0 = ( 1 , 1 , 1 , 1 , , 1 ) w ones using the results from (44) and Lemma 1 we have P ( c 0 ) = 3 16 for w sufficiently large;
  • c 0 = ( 0 , 0 , 0 , 0 , , 0 ) w zeros again, from (44) and Lemma 1, we obtain P ( c 0 ) = 3 8 for w sufficiently large.

5. Conclusions

We considered the ChaCha20 stream cipher and we studied the propagation of rotational-XOR pairs in the quarter round function. Under suitable choices of the inputs and assumptions of independence and uniform distribution, setting the rotational amount r to 1, we established a formula for the probability of the propagation of rotational-XOR pairs depending on the selected constants. For the standard constants in ChaCha20 we find a probability around 2 251.7857 against the probability of 2 256 of a random permutation. Moreover, we were able to find a family of constants which in our scenario potentially facilitate rotational propagation with non-negligible probability.

Author Contributions

Conceptualization, S.B., D.B. and E.B.; methodology, S.B. and E.B.; validation, S.B. and E.B.; formal analysis, S.B. and E.B.; investigation, S.B., D.B. and E.B.; resources, D.B. and E.B.; data curation, S.B. and E.B.; writing—original draft preparation, S.B.; writing—review and editing, S.B. and E.B.; visualization, S.B. and E.B.; supervision D.B. and E.B.; project administration, D.B. and E.B.; funding acquisition, D.B. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by Politecnico di Torino (Funding for basic research).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Not applicable.

Acknowledgments

The authors would like to thank the anonymous referees for their valuable suggestions and corrections which surely improved the paper.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Bernstein, D.J. ChaCha, a Variant of Salsa20. In Workshop Record of SASC; 2008; Volume 8, pp. 3–5. Available online: https://cr.yp.to/chacha/chacha-20080120.pdf (accessed on 23 May 2022).
  2. Bernstein, D.J. Salsa20 Specification. In Technical Report, eSTREAM Project; 2005; Available online: http://www.ecrypt.eu.org/stream/salsa20pf.html (accessed on 23 May 2022).
  3. Nir, Y.; Langley, A. Chacha20 and poly1305 for IETF protocols. RFC 2018, 8439, 1–46. [Google Scholar] [CrossRef]
  4. Bernstein, D.J.; Hopwood, D.; Hülsing, A.; Lange, T.; Niederhagen, R.; Papachristodoulou, L.; Schneider, M.; Schwabe, P.; Wilcox-O’Hearn, Z. SPHINCS: Practical Stateless Hash–Based Signatures. In Advances in Cryptology—EUROCRYPT 2015; LNCS; Springer: Berlin/Heidelberg, Germany, 2015; Volume 9056, pp. 368–397. [Google Scholar] [CrossRef] [Green Version]
  5. Biham, E. New Types of Cryptanalytic Attacks Using Related Keys. J. Cryptol. 1994, 7, 229–246. [Google Scholar] [CrossRef]
  6. Kelsey, J.; Schneier, B.; Wagner, D. Related-key cryptanalysis of 3-way, biham-DES, CAST, DES-X, newDES, RC2, and TEA. In Information and Communications Security. ICICS 1997; LNCS; Springer: Berlin/Heidelberg, Germany, 1997; Volume 1334, pp. 233–246. [Google Scholar] [CrossRef]
  7. Knudsen, L.R.; Matusiewicz, K.; Thomsen, S.S. Observations on the Shabal Keyed Permutation. In Official Comment. 2009. Available online: http://www2.mat.dtu.dk/people/oldusers/S.Thomsen/shabal/shabal.pdf (accessed on 23 May 2022).
  8. Bernstein, D.J. Salsa20 Security. In Technical Report, eSTREAM Project; 2005; Available online: http://cr.yp.to/snuffle/security.pdf (accessed on 23 May 2022).
  9. Standaert, F.-X.; Piret, G.; Gershenfeld, N.; Quisquater, J.-J. Sea: A Scalable Encryption Algorithm for Small Embedded Applications. In Smart Card Research and Advanced Applications. CARDIS 2006; LNCS; Springer: Berlin/Heidelberg, Germany, 2006; Volume 3928, pp. 222–236. [Google Scholar] [CrossRef] [Green Version]
  10. Daum, M. Cryptanalysis of Hash Functions of the MD4-Family. Ph.D. Thesis, Ruhr University Bochum, Bochum, Germany, 2005. Available online: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.7847&rep=rep1&type=pdf (accessed on 23 May 2022).
  11. Khovratovich, D.; Nikolić, I. Rotational cryptanalysis of ARX. In Fast Software Encryption. FSE 2010; LNCS; Springer: Berlin/Heidelberg, Germany, 2010; Volume 6147, pp. 333–346. [Google Scholar] [CrossRef] [Green Version]
  12. Khovratovich, D.; Nikolić, I.; Rechberger, C. Rotational Rebound Attacks on Reduced Skein. In Advances in Cryptology—ASIACRYPT 2010; LNCS; Springer: Berlin/Heidelberg, Germany, 2010; Volume 6477, pp. 1–19. [Google Scholar] [CrossRef] [Green Version]
  13. Ferguson, N.; Lucks, S.; Schneier, B.; Whiting, D.; Bellare, M.; Kohno, T.; Callas, J.; Walker, J. The Skein Hash Function Family. Submiss. NIST (Round 3) 2010, 7, 3. [Google Scholar]
  14. Khovratovich, D.; Nikolić, I.; Pieprzyk, J.; Sokolowski, P.; Steinfeld, R. Rotational Cryptanalysis of ARX Revisited. In Fast Software Encryption. FSE 2015; LNCS; Springer: Berlin/Heidelberg, Germany, 2015; Volume 9054, pp. 519–536. [Google Scholar] [CrossRef] [Green Version]
  15. Guo, J.; Karpman, P.; Nikolić, I.; Wang, L.; Wu, S. Analysis of BLAKE2. In Topics in Cryptology—CT-RSA 2014; LNCS; Springer: Cham, Switzerland, 2014; Volume 8366, pp. 402–423. [Google Scholar] [CrossRef]
  16. Morawiecki, P.; Pieprzyk, J.; Srebrny, M. Rotational Cryptanalysis of Round-reduced Keccak. In Fast Software Encryption: 20th International Workshop; LNCS; Springer: Berlin/Heidelberg, Germany, 2013; Volume 8424, pp. 241–262. [Google Scholar] [CrossRef] [Green Version]
  17. Ashur, T.; Liu, Y. Rotational Cryptanalysis in the Presence of Constants. IACR Trans. Symmetric Cryptol. 2016, 2016, 57–70. [Google Scholar] [CrossRef]
  18. Ashur, T.; De Witte, G.; Liu, Y. An Automated Tool for Rotational-XOR Cryptanalysis of ARX-based Primitives. In Proceedings of the 2017 Symposium on Information Theory and Signal Processing in the Benelux (SITB 2017), Delft, The Netherlands, 11–12 May 2017. [Google Scholar]
  19. Ito, R. Rotational Cryptanalysis of Salsa Core Function. In Information Security. ISC 2020; LNCS; Springer: Cham, Switzerland, 2020; Volume 12472, pp. 129–145. [Google Scholar] [CrossRef]
  20. Barbero, S.; Bellini, E.; Makarim, R. Rotational Analysis of ChaCha Permutation. Adv. Math. Commun. 2021. [Google Scholar] [CrossRef]
Figure 1. The ChaCha20 quarter round scheme.
Figure 1. The ChaCha20 quarter round scheme.
Symmetry 14 01087 g001
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Barbero, S.; Bazzanella, D.; Bellini, E. Rotational Cryptanalysis on ChaCha Stream Cipher. Symmetry 2022, 14, 1087. https://0-doi-org.brum.beds.ac.uk/10.3390/sym14061087

AMA Style

Barbero S, Bazzanella D, Bellini E. Rotational Cryptanalysis on ChaCha Stream Cipher. Symmetry. 2022; 14(6):1087. https://0-doi-org.brum.beds.ac.uk/10.3390/sym14061087

Chicago/Turabian Style

Barbero, Stefano, Danilo Bazzanella, and Emanuele Bellini. 2022. "Rotational Cryptanalysis on ChaCha Stream Cipher" Symmetry 14, no. 6: 1087. https://0-doi-org.brum.beds.ac.uk/10.3390/sym14061087

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop