Message Boards Message Boards


Integer Differential Cryptanalisys of Kuznyechik cipher

Posted 5 years ago
4 Replies
14 Total Likes


Block cipher “Kuznyechik” (Grasshopper) is defined in the National Standard of the Russian Federation GOST R 34.12-2015 (effective date 01.01.2016). It has 128 bit block and 256 bit key. This code builds upper bound estimates of its practical resistance to integer differential cryptanalysis. This cryptanalytic method first appeared in works of Biham and Shamir: input and output differences were taken regarding XOR operation. Integer differentials modulo $2^{32}$ were first introduced by Thomas A. Berson. The “integer” modification is quite new, so when many ciphers were designed they were not tested for resistance to it.

This cipher is based on SPN (Substitution-permutation network). It has 10 rounds, of which first 9 rounds have round-function in the form: $F(x,k)=P(S(x*k))$, where $x$ is input block, $k$ is roundkey, $P$ is linear transformation (permutation), $S$ is nonlinear transfromation (substitution), * is the operation which combines input block and the roundkey. The last round is simply $(x*k)$. Worth mentioning, that exactly S-blocks are the targets of integer differential cryptanalysis.

btw, I don’t use parallelization because my laptop is unable to parallelize

P-layer: Linear Transfromation

The original linear transformation of the cipher creates problems for this cryptanalytic method. So we substitute the original P-layer by another linear operators, with the property: inversions of these operators in the ring $Z_{2^8}$ have only 0s and 1s in all rows (rationale is given in [2]). Usage of linear operator with these properties gives us the ability to build uppper-bound estimates of practical resistance of this cipher against integer differential cryptanalysis, similar to those, described by Biham, Shamir and Berson. This modification makes cryptanalysis focuse on S-block and its properties.

This code generates operators of that kind and deletes singular matrices among them (l is a maximum number of 1s that can occur in each row, size is the size of square matrix, quan is the number of matrices we want to generate).

MatrL[l_,size_]:= MatrL[l,size,1];
MatrL[l_,size_,quan_]:= Block[{rows,tabs={},t,d,tnew},
    rows = Table[PadLeft[ConstantArray[1,i],size],{i,1,l}];
    t = Partition[tabs,size];
   d = Det/@t;
   tnew = Delete[t,Position[d,0]]

This code builds inverse of a matrix in the ring $Z_{2^8}$.

Inv[matrix_,mod_]:= Map[Mod[#,mod]&,
    Table[(-1)^(i+j) Det[Delete[#,j]&/@Delete[matrix,i]],{j,16},{i,16}]*PowerMod[Det[matrix],-1,mod],{2}];

S - block: Nonlinear Transformation

This is the substitution layer specifed in the cipher [1]


It substitutes your bytes given in integer form by an integer, for which your byte is treated as index in this S-block. For example (I add 1, because bytes can be 0...255 and indices are 1...256):


gives {252,110,22,182}.As we can see 0 gives us the first element in S-block - 252, 5 gives the sixth element - 110, and so on.


Here I do evaluate the cipher’s resistance in two cases:

1. operation * is bitwise XOR and round differences are modulo $2^8=256$

$$\Delta = \max_{ \alpha , \gamma = 1,...,255}2^{-8} \sum_{k=0,...,255} \sum_{z=0}^{8+1} \delta \left(S (k \oplus\alpha)-S(k),\gamma+z\right) $$ is the average probability of the integer differential. Implemneted as


This finds the maximal value, which would be the upper bound.


I've obtained the estimate of this parameter for the 8-bit S-block specifed in [1] equal 0.08203125. Let's take a look at the distribution of parameter $\Delta$ for 8-bit S-blocks. The statistic may not show the whole picture, because it takes values only of one million random S-blocks, when there are 256! of them.

enter image description hereenter image description here

As we can see, estimate for Kyznyechik is close to the least value among obtained results. This means the cipher is resistant against th integer differential cryptanalysis of this kind.

2. operation * is addition modulo $2^8$ and round differences are modulo $2^8=256$

$$\Delta_+ = \max_{ \alpha , \gamma = 1,...,255}2^{-8} \sum_{k=0,...,255} \sum_{z=0}^{8+1} \delta \left(S (k +\alpha)-S(k),\gamma+z\right) $$ is the average probability of the integer differential. Implemneted as


The maximal value (upper bound) is found the same way as the in the previous case. The estimate of this parameter for Kyznyechik is equal 0.0898437. If we look at the distribution of parameter $\Delta_+$ for 8-bit S-blocks we'll see it is also close to the least value.

enter image description hereenter image description here

We can claim the cipher is resistant against th integer differential cryptanalysis of this kind.


According to the estimates of practical resistance we now canclaim that the S-block specified for Kuznyechik cipher is resistant to integer differential cryptanalysis. This result is really cool for cryptology, because Kuznyechik seems to be the first cipher in history, to use by default the S-block designed with respect to resistance on this attacks (of course, we can’t say for sure if this was made on purpose or is just a coincidence).


I would like to thank my mentor Dr. Ludmila Kovalchuk for guidance and assistance with obtaining those results. Unfortunately, there is only one of her works available in English [2].

Thank you for reading!


  1. National Standard of the Russian Federation GOST R 34.12–2015 (English Version)

  2. L. V. Kovalchuk , N. V. Kuchinska Upper-bound estimates for the average probabilities of integer differentials of round functions of certain block ciphers


Improved some code. Thanks to Sander Huisman

4 Replies

Thanks for sharing! Very interesting.

In your code:


You might be able to speed this up considerably by not repeatedly appending things to tabs, but rather using Sow and Reap like so (i did not test it, but should work):

tabs =  Reap[Table[Do[Sow[RandomSample[rows[[RandomInteger[{1, l}]]]]],{size}],{quan}]][[2,1]];

Since you don't use 'Table' to store things, it might be faster to use a Do loop as well. And you can combine the two do loops for additional speed:

Do[......,{quan},{size}]  (* the opposite order*)

and now since Mathematica 10 (I believe) you can even simplify that further:




If i understand correctly if gam just a number. In that case you can make it faster and neater doing this:


Once again, thanks for sharing!

These are really good advices, thank you!

You're welcome.

I'm just puzzled by this line of code:

    Map[Mod[#,mod]&, Table[(-1)^(i+j) Det[Delete[#,j]&/@Delete[matrix,i]],{j,16},{i,16}]*PowerMod[Det[matrix],-1,mod],{2}];

Very intricate code :-D

Btw Mod[Table[................],mod] will just work fine, no need to Map it, Mod is listable...

enter image description here - you earned "Featured Contributor" badge, congratulations !

This is a great post and it has been selected for the curated Staff Picks group. Your profile is now distinguished by a "Featured Contributor" badge and displayed on the "Featured Contributor" board.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract