Mattoslg Gendream Article
Mattoslg Gendream Article
The encryption system is then very similar to the classic Algorithm 4 Baby-Step Giant-Step
El-Gamal system : it is the same system, but the field is √
replaced by an elliptic curve, and exponentiation by scalar m← n
multiplication. The system needs an invertible function f for j from 0 to m do
to translate a message m to its associated point M . Compute G[j] and store the pair (j, G[j]) in a hashtable
end for
Protocol El-Gamal encryption with elliptic curves Compute G[−m]
γ←H
1: Alice has a private key x (an integer), and a public key for i from 0 to m do
(E, G, H), where G is a generator of E and H = [x]G. if γ is the second component of some pair (j, G[j]) in
2: Bob chooses randomly an integer k. the hashtable then
3: Bob computes M = f (m), C1 = [k]G, C2 = M + [k]H, return im + j
and sends both to Alice end if
4: Alice receives (C1 , C2 ), retrieves m by computing γ ← γG[−m]
f −1 (C2 + [−x]C1 ) end for
3.2 Implementation All experiments in this paper have been run on Intel i7 @
2.0GHz and Intel i5 @ 1.8Ghz machines with 4 cores. In the
This attack has been implemented with the perturbation
case of the Chosen Point Input Attack, the computation of
caused by a simulated laser : at the beginning of the com-
the orders of all the possible points created by perturbations
putation of [n]P , the first coordinate of P is modified ran-
of a single byte of the generator element took, for the worst
domly. As a result, line 5 is not needed in our simulation,
case (that of the BN curve over 254 bits), approximately 5
because we already have the value of x˜P .
hours, while for the curves ECB-48 and SECP-112-R1 the
computations took a few seconds.
As the simulated laser only alters one byte, there are only
256 possible outcomes. Thus, the order of P̃ in Ẽ can be
The figure 1 presents the size (in bits) of the original order of
precomputed. This represents a major gain in the complex-
the curve along with the size of the smallest order found on
ity of the attack, as this computation was one of the most
each curve (see appendix A), and the byte of the coordinate
complex part of it. The pre-computation was made using
x to modify in order to get it (indexed as 0 being the least
the free computer algebra system PARI/GP[11]. This pre-
significant byte).
computation is quite long, but is made only once for each
curve. According to its results, we can choose the byte to be
We can observe in figure 1 that, for most of the curves that
used for the attack based on the size of the order of the points
were tested, the attack is able to reduce the order of the
generated by the modifications in this byte. The computa-
point by a factor of 210 independently of the size of the
tion time needed to calculate the orders for all 256 points
curve. The exception is the curve BN(2, 254), on which the
generated by modifications over a single byte is of approxi-
attack can be seen as very effective, from the point of view
mately 30 minutes for curves over fields of 200 bits or more,
of the point orders: often, their orders are around 2190 , the
for example, the last three curves presented at Appendix A.
minimum being 2188 as shown in the table.
All algorithms described (except the pre-computation of the
orders of the points and Cornacchia’s algorithm) have been 3.4 Analysis
implemented in the C++ language using the Givaro library These results give the complexity of the attack : computing
(http://givaro.forge.imag.fr/) for arbitrary size integers, the discrete logarithms in the curves with the smallest orders
fields and operations. To make the processing of the point until the product of these orders is larger than p gives the key
orders easier, some of the needed data, such as the curve pa- by the Chinese Remainder theorem. The figure 2 gives for
rameters and modified points was also implemented in C++, each curve the complexity of a direct discrete logarithm, and
leaving only the computation of the point orders itself to be the complexity of our attack, both as security indexes (if this
made by PARI/GP scripts. Some Python and shell scripts index is i, the attack would be equivalent to a brute-force
were also written to find and calculate automatically the rel- on a 2i bits key). We see here that our attack can make a
evant data from the pre-calculated point orders. All of these great difference in the time necessary to break an El-Gamal
are available at https://ensiwiki.ensimag.fr/index.ph over elliptic curves cypher : on the BN(2,254) curve, which
p/Perturbation_sur_ECC_(Projet_de_Sp%C3%A9cialit%C3% is among recommended curves, the loss of security was of 35
A9_2015). bits.
Curve Byte Direct logarithm Attack in Alg.6.
ECB-48 0 24 20
sepc112r1 0 56 52 Algorithm 6 Double-and-Add, corrected
Anomalous 0 102 98
n = n0 + 2n1 + · · · + 2m nm
NIST P-224 26 112 108
Q←0
BN(2,254) 4 128 95
for i from 0 to m do
if ni = 1 then
Figure 2: The base 2 logarithm of the complexity of the
Q←Q+P
chosen input point attack having pre-computed the point
end if
orders is given by the column attack. The column direct
P ← [2]P
logarithm corresponds to a brute-force attack, while byte
end for
indicates the byte that has to be attacked to obtain the best
if Q ∈ E then
results for the curve.
return Q
else
Curve Mininum Mean Maximum Mean return Error
ECB-48 46.052070106 46.6118360952 end if
sepc112r1 110.471819215 110.652386167
Anomalous 202.226933365 202.447171385
NIST P-224 222.745068969 222.849967956 But, if a laser can also be used to skip instructions, this
BN(2,254) 239.929644347 243.776578689 counter-measure is easily bypassed. Therefore, more ad-
vanced counter-measures have to be implemented.
Figure 3: This table presents the mean of the number of
bits of the pre-calculated orders of the perturbated points. First, doing the check P ∈ E at every iteration of the loop
The columns Minimum Mean and Maximum Mean show, will slow down the computation, but will be less easily by-
respectively, the minimum and the maximum of these means passed, as it will require the attacker to shoot lasers not
over the different bytes. just at the beginning and the end of the computation, but
at many very precise instants.
The best byte to modify depends on the curve, as seen in the
tables. However, to decide which one is the best byte, the
4. FAULTS IN THE CURVE PARAMETERS
attacker must have pre-computed the orders of the points 4.1 Theory
generated by modifications on every single byte of the gen- This attack is similar to the one described in section 3. But
erator point, which gives 256|x| orders to compute, where |x| here, instead of modifying the input point, we modify the
is the number of bytes of the x coordinate of the generator parameters of the curve, more precisely the a parameter,
point. Note that, as shown by the case of the BN curve, the into ã. For a given P , there is a b̃ ∈ Fp which gives P ∈ Ẽ,
best byte to attack is not necessarily the one with the point where
of lowest order, as it is necessary to apply the chinese re- Ẽ = {(x, y) ∈ Fp | y 2 = x3 + ãx + b̃}
mainder theorem to obtain the final result, and thus at least
As a result, after computation, we get Q̃ = [n]P ∈ Ẽ, which
2 points are needed. For this reason, it is preferred to choose
gives a second equation, and thus the system :
a byte that contains more than one point of reasonably low (
order. yP2 = x3P + ãxP + b̃
(5)
y˜Q 2 = x˜Q 3 + ãx˜Q + b̃
We observed that for most curves, the orders of the modi-
fied points are somewhat similar from byte to byte. In other As we have P and Q̃, this is a system which is easily solved,
words, the mean of the number of bits of the points gener- and gives the values of ã and b̃. Then, if Ẽ has a smaller
ated by modifications in a byte changes little compared to order than E, it may be possible to compute the discrete
that of another byte of the same curve. This fact is shown logarithm over this curve.
by the figure 3.
As in the previous attack, this gives n mod ordẼ (P ), where
We see, thus, that it is not stricly necessary to pre-compute ordẼ (P ) < ordE (P ). We therefore need several positive re-
the orders of every perturbated point of every byte, as the sults to compute the full value of n, with the Chinese Re-
obtained results tend to vary very little form byte to byte. mainder Theorem.
However, it remains necessary in practice to find points
whose order is sufficiently small for the discrete logarithm 4.2 Implementation
problem to be solved. As in the first attack, the modification by laser is simulated.
Thus, we do not need to compute ã with the system (5), as
3.5 Counter-measures it is the output of the modifying method.
A simple counter-measure is for the Double-and-add algo-
rithm to check whether the result is an element of E. If it is, Once again, the orders of the altered curves may be precom-
the algorithm returns normally, and if not, the algorithm re- puted, greatly reducing the attack’s complexity.
turns an error. As a result, the attacker will be unable to get
any information after modifying the value of P . Thus, the The code implementing this attack can also be found at http
corrected algorithm for Double-and-add will be as presented s://ensiwiki.ensimag.fr/index.php/Perturbation_sur_E
Curve Byte Basic order Smallest Order Curve Mininum Mean Maximum Mean
ECB-48 0 48 40 ECB-48 46.2221736458 46.4797858687
secp112r1 3 112 103 sepc112r1 110.412740083 110.750916624
Anomalous 11 204 191 Anomalous 202.262889712 202.334902929
NIST P-224 16 224 217 NIST P-224 222.501063704 222.860444558
BN(2,254) 21 256 246 BN(2,254) 251.737034185 252.067611836
Figure 4: The smallest point order found for each curve is Figure 6: This table presents the mean of the number of
given by the column Smallest Order, considering modifica- bits of the pre-calculated orders of the original generator
tions of a single byte of the parameter a of the curve. The element over a curve whose a parameter was changed by a
column Basic order shows the order of the point in the orig- single byte. The columns Minimum Mean and Maximum
inal curve, while Byte gives the byte where the modification Mean show, respectively, the minimum and the maximum
that causes the smallest point order occurs. of these means over the different bytes.
CC_(Projet_de_Sp%C3%A9cialit%C3%A9_2015). The scripts the private key for these curves. It is still possible that there
and C++ files provided are similar to those of the previous are curves that react to this attack in a similar way to that
attack. observed in section 3 for the BN curve in the case of the first
attack, where we saw a relevant loss of security.
4.3 Experimentation
As in section 3.3, we tried on several curves to modify a byte Once again the point orders are somewhat similar no matter
of the input, but here the modified input is the parameter which byte of the curve parameter a is changed, as shown
a. In the figure 4 we show the order of the points over the by figure 6. Even when we take the incomplete results of the
new curves, in the same way as the previous attack. BN curve, this property remains the same. One could argue
that the mean might not correctly represent the variation of
In the case of this attack, the time needed to calculate the the orders. However, according to the figure 4, we can also
point orders in their new curves seem to be much higher. see that the minimum value for the order of the points is
In approximately 5 hours, our scripts only finished 25% of always somewhat close to the mean in all the cases that we
the work for the BN curve. For this reason, we decided tested.
to use these partial results for this curve. Thus, in the ta-
bles corresponding to this attack, the data given for the BN Comparing the performance of both attacks, we can con-
curve corresponds to the partial results, while in the case of clude that, at least for these curves, the first attack is much
the other curves, all orders were computed. We emphasize more efficient - not only the point orders are calculated
that, although we didn’t proceed with the computation of faster, but the decrease in the number of bits of the security
the orders for the BN curve case, it is feasible to do it even of the algorithm is also better, being of approximately 10
on simple machines such as the ones we used, because this bits in the first case and 4 bits in the second.
computation has to be done only once.
A possible reason for the greater times of computation on
the faults in the curve parameters is that the arithmetic
4.4 Analysis over an elliptic curve depends only on its parameter a, being
As before, the results give us the cost to crack the cypher independent of b. Thus, in the case of the chosen point input
using our attack, which we can compare to the cost to crack attack, even though the parameter b of the curve is changed
it using directly a discrete logarithm. by the perturbation, the performance of the arithmetic over
the new curve is the same as that of the original one. The
We observe for this attack a small decrease in the complexity same doesn’t happen in the second case, where we change
of the discrete logarithm problem comparing to the brute a directly. The difference in speed is then explained by the
force version, although this decrease corresponds only to a fact that curves recommended for cryptography are usually
few bits of security for all 5 curves tested. For this reason, made not only to be secure, but also to have reasonably fast
it seems not to be enough to be useful in practice to retrieve arithmetic, and this property is not necessarily preserved
when we inject faults in the curve parameters.
Curve Byte Direct logarithm Attack
ECB-48 0 24 21 4.5 Counter-measures
sepc112r1 2 56 53 The simple counter-measure presented in section 3.5 will also
Anomalous 23 102 96 work in this case, because the a parameter is altered, but
NIST P-224 11 112 109 not the b. Checking P ∈ E will then return false if one
BN(2,254) 1 128 124 parameter have been altered.