Patent ID: 8577025

Claim:
A method of executing an algorithm, said method comprising protecting an electronic device by affine masking, wherein said device executes operations on secret variables x, said secret variables x being binary vectors of a given size N other than zero, said method further comprising replacing said secret variables x using an affine masking operation, by the following affine function: m(x)=R.x+r, where R is a random invertible binary matrix with N rows and N columns and r is a random binary vector of size N, wherein said electronic device executes at least one linear operation on a set of secret variables z 1 , . . . , z m , producing the result z=A 1 z 1 +A 2 z 2 + . . . +A m z m , where the variables A 1 , A 2 . . . A m are matrices, each of which commutes with the matrix R and its inverse R −1 , and the operation of the affine masking of said result z is carried out by the following steps: apply said operation of affine masking to the set of said variables z 1 , . . . z m in order to produce the set of masked variables z 1 , . . . , z m ; determine, from said random vector r and a second random binary vector r′, a third random vector r″=r′(A 1 + . . . +A m )r; and determine the result z of the affine masking operation applied to the result z of said linear operation, by the following calculation steps: z =A 1 z 1 + r″ For i varying from 2 to m, z = z +A i z i z = z +r+r′.