Elliptic curve arithmetic - ECC 2017Elliptic curve arithmetic Wouter Castryck ECC school, Nijmegen,...
Transcript of Elliptic curve arithmetic - ECC 2017Elliptic curve arithmetic Wouter Castryck ECC school, Nijmegen,...
Elliptic curve arithmetic
Wouter Castryck
ECC school, Nijmegen, 9-11 November 2017
๐1
๐2
๐1 + ๐2
Tangent-chord arithmeticon cubic curves
IntroductionConsequence of Bรฉzoutโs theorem: on a cubic curve
๐ถ โถ ๐ ๐ฅ, ๐ฆ = ฯ๐+๐=3๐๐๐๐ฅ๐๐ฆ๐ = 0,
new points can be constructed from known points using tangents and chords.
This principle was already known to 17th century natives like Fermat and Newton.
๐ ๐ฅ, ๐ฆ = 0
Pierre de Fermat
Isaac Newton
Introduction
This construction was known to respect the base field.
This means: if ๐ ๐ฅ, ๐ฆ โ ๐[๐ฅ, ๐ฆ] with ๐ some field, and one starts from points having coordinates in ๐, then new points obtained through the tangent-chord method also have coordinates in ๐.
Informal reason:
Consider two points on the ๐ฅ-axis ๐1 = ๐, 0 and ๐2 = (๐, 0).Then the โchordโ is ๐ฆ = 0.
The intersection is computed by ๐ ๐ฅ, 0 = ๐ฅ โ ๐ โ ๐ฅ โ ๐ โ linear factor
always has a root over ๐!
๐1
๐2
๐ ๐ฅ, ๐ฆ = 0
IntroductionThus: tangents and chords give some sort of composition law on the set of ๐-rational points of a cubic curve.
Later it was realized that by adding in a second step, this gives the curve an abelian group structure! only after an incredible historical detour which took more than 200 yearsโฆ
First formalized by Poincarรฉ in 1901.
Henri Poincarรฉ
choose a base point
๐
๐1
๐2
๐1 + ๐2
๐
2๐ commutativity:๐1 + ๐2 = ๐2 + ๐1
associativity: ๐1 + ๐2 + ๐3 = ๐1 + (๐2 + ๐3)
neutral element:๐ + ๐ = ๐
inverse element:โ โ๐ โถ ๐ + โ๐ = ๐
Introduction
Conditions for this to work:
1) One should work projectively (as opposed to affinely):
Homogenize
๐ ๐ฅ, ๐ฆ = ฯ๐+๐=3๐๐๐๐ฅ๐๐ฆ๐ to ๐น ๐ฅ, ๐ฆ, ๐ง = ฯ๐+๐=3๐๐๐๐ฅ
๐๐ฆ๐๐ง3โ๐โ๐
and consider points ๐ฅ: ๐ฆ: ๐ง โ (0: 0: 0), up to scaling.
Two types of points:
affine points points at infinity
๐ง = 0
๐ง โ 0: the point is of the form (๐ฅ: ๐ฆ: 1)
But then ๐ฅ, ๐ฆ is an affine point!
๐ง = 0: points of the form (๐ฅ: ๐ฆ: 0) up to scaling.
(Up to three such points.)
Introduction
Conditions for this to work:
2) The curve should be smooth, meaning that
๐ =๐๐
๐๐ฅ=
๐๐
๐๐ฆ=
๐๐
๐๐ง= 0
has no solutions.
This ensures that every point ๐ has a well-defined tangent line
๐ โถ๐๐
๐๐ฅ๐ โ ๐ฅ +
๐๐
๐๐ฆ๐ โ ๐ฆ +
๐๐
๐๐ง๐ โ ๐ง = 0.
Introduction
Conditions for this to work:
3) ๐ should have coordinates in ๐, in order for the arithmetic to work over ๐.
๐
Definition: an elliptic curve over ๐ is a smooth projectivecubic curve ๐ธ/๐ equipped with a ๐-rational base point ๐.
(Caution: there exist more general and less general definitions.)
Under these assumptions we have as wanted:Tangent-chord arithmetic turns ๐ธ into an abelian group with neutral element ๐.The set of ๐-rational points ๐ธ(๐) form a subgroup.
Exercises
1) Describe geometrically what it means to invert a point ๐, i.e. to find a point โ๐ such that
๐ + โ๐ = ๐.
๐
2) Why does this construction simplify considerably if ๐ is a flex (= point at which its tangent line meets the curve triply)?
3) If ๐ is a flex then
3๐ โ ๐ + ๐ + ๐ = ๐ if and only if ๐ is a flex.
Explain why.
On the terminologyโelliptic curvesโ
On the terminology
In the 18th century, unrelated to all this, Fagnano and Euler revisited the unsolvedproblem of determining the circumference of an ellipse.
Giulio Fagnano
Leonhard Euler
?
They got stuck on difficult integrals, now called elliptic integrals.
On the terminology
In the 19th century Abel and Jacobi studied the inverse functions of elliptic integrals.
๐ก = ๐(๐ ) ?
When viewed as complex functions, they observeddoubly periodic behaviour: there exist ๐1, ๐2 โ ๐ suchthat
๐ ๐ง + ๐1๐1 + ๐2๐2 = ๐ ๐ง for all ๐1, ๐2 โ ๐.
Niels H. Abel
Carl G. Jacobi
Compare to: sin ๐ฅ + ๐ โ 2๐๐ = sin ๐ฅ for all ๐ โ ๐, etc.
Such generalized trigonometric functions became known as elliptic functions.
On the terminology
In other words: elliptic functions on ๐ are well-defined modulo ๐๐1 + ๐๐2.
๐1
๐2
Karl Weierstrass
Mid 19th century Weierstrass classified all elliptic functions forany given ๐1, ๐2, and used this to define a biholomorphism
๐/(๐๐1 + ๐๐2) โ ๐ธ: ๐ง โฆ (โ ๐ง ,โโฒ ๐ง )
to a certain algebraic curve ๐ธโฆ
Note that ๐/(๐๐1 + ๐๐2) is an abelian group, almost by definition.
The biholomorphism endows ๐ธ with the same group structureโฆ โฆ where it turns out to correspond to tangent-chord arithmetic!
โฆ which he called an elliptic curve!
Weierstrass curves andtheir arithmetic
The concrete type of elliptic curves found by Weierstrassnow carry his name. They are the most famous shapes ofelliptic curves.
Assume char ๐ โ 2,3.
๐ฆ2 = ๐ฅ3 + ๐ด๐ฅ + ๐ต๐ฆ2๐ง = ๐ฅ3 + ๐ด๐ฅ๐ง2 + ๐ต๐ง3
(typical plot for ๐ = ๐)
Weierstrass curves๐ง = 0 ๐ = (0: 1: 0)
Definition: a Weierstrass elliptic curve is defined by
where ๐ด, ๐ต โ ๐ satisfy 4๐ด3 + 27๐ต2 โ 0.The base point ๐ is the unique point at infinity.
Can be shown: up to โisomorphismโ every elliptic curve is Weierstrass.
Note:
1) the lines through ๐ = (0: 1: 0) are thevertical lines (except for the line at infinity๐ง = 0).
2) The equation ๐ฆ2 = ๐ฅ3 + ๐ด๐ฅ + ๐ต is symmetric in ๐ฆ.
Weierstrass curves
(๐ฅ, ๐ฆ)This gives a first feature: inverting a point on a Weierstrass curve is super easy!
Indeed: if ๐ = (๐ฅ, ๐ฆ) is an affine point then
โ๐ = ๐ฅ,โ๐ฆ .
๐
๐
(๐ฅ, โ๐ฆ)
What about point addition?
Weierstrass curves
Write ๐1 + ๐2 = ๐ฅ3, ๐ฆ3 .
Line through ๐1 = (๐ฅ1, ๐ฆ1) and ๐2 = (๐ฅ2, ๐ฆ2) is
๐ฆ โ ๐ฆ1 = ๐ ๐ฅ โ ๐ฅ1 where ๐ =๐ฆ2โ๐ฆ1
๐ฅ2โ๐ฅ1.
๐1
๐2
๐1 + ๐2
Substituting ๐ฆ โ ๐ฆ1 + ๐ ๐ฅ โ ๐ฅ1 in the curve equation ๐ฅ3 + ๐ด๐ฅ + ๐ต โ ๐ฆ2 = 0:
๐ฅ3 + ๐ด๐ฅ + ๐ต โ (๐2๐ฅ2 +โฏ) = 0.๐ฅ3 + ๐ด๐ฅ + ๐ต โ ๐ฆ1 + ๐ ๐ฅ โ ๐ฅ12= 0.๐ฅ3 โ ๐2๐ฅ2 +โฏ = 0.
So, sum of the roots is ๐2. But ๐ฅ1, ๐ฅ2 are roots!
We find: แ๐ฅ3 = ๐2 โ ๐ฅ1 โ ๐ฅ2๐ฆ3 = โ๐ฆ1 โ ๐(๐ฅ3 โ ๐ฅ1)
Weierstrass curves
๐
2๐
where ๐ =๐ฆ2โ๐ฆ1
๐ฅ2โ๐ฅ1.
We find: แ๐ฅ3 = ๐2 โ ๐ฅ1 โ ๐ฅ2๐ฆ3 = โ๐ฆ1 โ ๐(๐ฅ3 โ ๐ฅ1)
But what if ๐ฅ1 = ๐ฅ2?
Two cases:
Either ๐ฆ1 = ๐ฆ2 โ 0, i.e. ๐1 = ๐2 = ๐.
In this case we need to replace ๐ by
๐ =3๐ฅ1
2+2๐ด๐ฅ1
2๐ฆ1.
Or ๐ฆ1 = โ๐ฆ2, in which case ๐1 + ๐2 = ๐.
๐
๐1
๐2
Conclusion: formulas for computing on a Weierstrass curve are not too bad, but case distinctive.
More efficient elliptic curve arithmetic?
The Weierstrass addition formulas are reasonably good for several purposesโฆโฆ but can they be boosted? Huge amount of activity starting in the 1980โs.
One reason: Koblitz and Millerโs suggestion to use elliptic curves in crypto!
Initial reason: Lenstraโs elliptic curve method (ECM) for integer factorization.
agree on ๐ธ/๐ ๐ and ๐ โ ๐ธ(๐ ๐)
chooses secret ๐ โ ๐ chooses secret ๐ โ ๐
computes ๐๐ computes ๐๐receives receivescomputes ๐ ๐๐ = ๐๐๐ computes ๐ ๐๐ = ๐๐๐
(Example: Diffie-Hellman key exchange.)
Victor Miller
Neal Koblitz
Generic methods for efficientscalar multiplication
Efficient scalar multiplication
The most important operation in both(discrete-log based) elliptic curve cryptography,the elliptic curve method for integer factorization,
is scalar multiplication: given a point ๐ and a positive integer ๐, compute
๐๐ โ ๐ + ๐ +โฏ+ ๐
๐ times.
Note: adding ๐ consecutively to itself ๐ โ 1 times is not an option!
in practice ๐ consists of hundreds of bits!
Efficient scalar multiplication: double-and-add
Much better idea: double-and-add, walking through the binary expansion of ๐.
Toy example: replace the 15 additions in
16๐ = ๐ + ๐ + ๐ + ๐ + ๐ + ๐ + ๐ + ๐ + ๐ + ๐ + ๐ + ๐ + ๐ + ๐ + ๐ + ๐
by the 4 doublings in
16๐ = 2 2 2 2๐ .
General method:
๐ = 101100010โฆ0101 ๐ท
double
๐๐ท
double and add
๐ ๐๐ท + ๐ท
double and add
๐ ๐ ๐๐ท + ๐ท + ๐ท
double
๐(๐ ๐ ๐๐ท + ๐ท + ๐ท)
double
๐(๐ ๐ ๐ ๐๐ท + ๐ท + ๐ท )
double
๐ ๐ ๐ ๐ ๐ ๐๐ท + ๐ท + ๐ท
double and add
๐ ๐ ๐ ๐ ๐ ๐ ๐๐ท + ๐ท + ๐ท + ๐ท
double
๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐๐ท + ๐ท + ๐ท + ๐ท
Exercise: verify that this computes ๐๐ using ๐(log ๐) additions or doublings, as opposed to ๐(๐).(Hornerโs rule, basically.)
Warning: finding the most optimal chain of additions and doublings to compute ๐๐ is a very difficult combinatorial problem.
We donโt want to spend more time on it than on computing ๐๐ itself!
Efficient scalar multiplication: double-and-add
Asymptotically this is as good as we can expectโฆ
โฆ but in practice, considerable speed-ups over naive double-and-add are possible!
Example: double-and-add computes 15๐ as
๐, 2๐, 3๐, 6๐, 7๐, 14๐, 15๐.
However it would have been more efficient to compute it as
๐, 2๐, 3๐, 6๐, 12๐, 15๐
๐๐ท
Efficient scalar multiplication: windowing
In double-and-add, processing a 0 (doubling) is less costly than processing a 1 (doubling and adding ๐). Is there a structural way of reducing the number of additions?
Example with ๐ค = 2:
๐ = 101100010โฆ0101 ๐ ๐๐ท + ๐๐ท
quadruple and add ๐๐ท
๐(๐ ๐๐ท + ๐๐ท)
quadruple
๐ ๐ ๐ ๐๐ท + ๐๐ท + ๐ท
quadruple and add ๐ทRequires precomputation of ๐,โฆ , 2๐คโ1๐ which grows exponentially with ๐ค.
Method can be spiced up by allowing the window to slide to the next window starting with a 1.
One idea to achieve this: windowing, which is the same as double-and-add, but we now processblocks (= windows ) of ๐ค bits in one time.
Efficient scalar multiplication: signed digitsRecall that on a Weierstrass elliptic curve, inverting a point is quasi cost-free:
โ ๐ฅ, ๐ฆ = (๐ฅ,โ๐ฆ).
Idea: use negative digits in the expansion, at the benefit of having more 0โs.
The non-adjacent form (NAF) of an integer ๐ is a base 2 expansion-> with digits taken from {โ1,0,1}-> in which no two consecutive digits are non-zero.
Such an expansion always exists, is unique, and easy to find.
๐ท
double
๐๐ท
double
๐ ๐๐ท
double and subtract
๐ ๐ ๐๐ท โ ๐ท
double
๐(๐ ๐ ๐๐ท โ ๐ท)
double and subtract
๐ ๐ ๐ ๐ ๐๐ท โ ๐ท โ ๐ท
double
๐ ๐ ๐ ๐ ๐ ๐๐ท โ ๐ท โ ๐ท
double and add
๐ ๐ ๐ ๐ ๐ ๐ ๐๐ท โ ๐ท โ ๐ท + ๐ท
double
๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐๐ท โ ๐ท โ ๐ท + ๐ท๐ = 1 0 0 -1 0 -1 0 1 0 โฆ 0 1 0 0 1
This method also comes in a windowing version (๐ค-NAF).
Efficient scalar multiplication
Tons of variations to the foregoing ideas have been investigated and proposed.
Some examples (far from exhaustive!):
Work with respect to base 3 and use an expansion with digits โ {โ1,0,1}.(Requires a tripling formula.)
If ๐ has a known finite order ๐, check if ๐ ยฑ ๐๐ has better properties for some small ๐ โ ๐.
Multi-exponentiation: efficient methods for computing a ๐-linear combination ฯ๐ ๐๐๐๐.
Exercise: find a smarter way to compute ๐๐ + ๐๐ than first computing ๐๐, ๐๐ separately.
Caution with double-and-add and its variants
When working through the digits of the scalar
๐ = 110100110101100010โฆ1110,
an attacker might notice differences betweenprocessing a 0 and processing a 1. Parameters he can monitor are time, power consumption, noise, โฆ
If one is uncareful then this will give away ๐ for free!Huge threat, unless ๐ is public anyway (as in signature verification).
Countermeasures:
Adding unnecessary computations, using uniform addition formulas, โฆ but the problem is somewhat inherent to double-and-add.
Use a Montgomery ladder for scalar multiplication.
Elliptic-curve-specificspeed-ups
Using projective coordinatesRemember the addition resp. doubling formula for Weierstrass curve arithmetic:
แ๐ฅ3 = ๐2 โ ๐ฅ1 โ ๐ฅ2๐ฆ3 = โ๐ฆ1 โ ๐(๐ฅ3 โ ๐ฅ1)
where ๐ =๐ฆ2โ๐ฆ1
๐ฅ2โ๐ฅ1resp. ๐ =
3๐ฅ12+2๐ด๐ฅ1
2๐ฆ1.
Each step in the addition/subtraction chain requires a computation of ๐, which involves a costlyfield inversion.
Way around: use projective coordinates, computing
๐3 = (๐ฅ3: ๐ฆ3: ๐ง3) from ๐1 = ๐ฅ1: ๐ฆ1: ๐ง1 and ๐2 = ๐ฅ2: ๐ฆ2: ๐ง2 .
Resulting formulas are inversion-free and even less case distinctive!
At the end of the double-and-add iteration, we can do a single inversion of the ๐ง-coordinate to finda point of the form ๐ฅ, ๐ฆ = (๐ฅ: ๐ฆ: 1), as wanted.
Using projective coordinates
Formulas for this are easy to establish: replace ๐ฅ1 โ๐ฅ1
๐ง1, ๐ฆ1 โ
๐ฆ1
๐ง1, ๐ฅ2 โ
๐ฅ2
๐ง2, ๐ฆ2 โ
๐ฆ2
๐ง2and put on
common denominators. For example in the case of addition this gives:
๐3 = ( ๐ฅ2๐ง1 โ ๐ฅ1๐ง2 ๐ฆ2๐ง1 โ ๐ฆ1๐ง22๐ง1๐ง2 โ ๐ฅ2๐ง1 + ๐ฅ1๐ง2 ๐ฅ2๐ง1 โ ๐ฅ1๐ง2
3: โฆ : ๐ฅ2๐ง1 โ ๐ฅ1๐ง23๐ง1๐ง2).
Looks ugly, but is more efficient!
Remember the addition resp. doubling formula for Weierstrass curve arithmetic:
แ๐ฅ3 = ๐2 โ ๐ฅ1 โ ๐ฅ2๐ฆ3 = โ๐ฆ1 โ ๐(๐ฅ3 โ ๐ฅ1)
where ๐ =๐ฆ2โ๐ฆ1
๐ฅ2โ๐ฅ1resp. ๐ =
3๐ฅ12+2๐ด๐ฅ1
2๐ฆ1.
Each step in the addition/subtraction chain requires a computation of ๐, which involves a costlyfield inversion.
Literature contains various clever ways of evaluating these formulas efficiently.Useful other types of homogeneous coordinates (e.g. weighted).
Other formulasThe formulas for addition and doubling on a Weierstrass curve are not unique. Using the identities
๐ฆ12 = ๐ฅ1
3 + ๐ด๐ฅ1 + ๐ต and ๐ฆ22 = ๐ฅ2
3 + ๐ด๐ฅ2 + ๐ต,
it is possible to rewrite them.
One possibility: obtain a single formula that works for both addition and doubling! Interestingagainst side-channel attacks. Example:
๐ฅ3 =๐ฅ1๐ฅ2 โ 2๐ด ๐ฅ1๐ฅ2 โ 4๐ต ๐ฅ1 + ๐ฅ2 + ๐ด2
๐ฅ1๐ฅ2 + ๐ด ๐ฅ1 + ๐ฅ2 + 2๐ฆ1๐ฆ2 + 2๐ต
๐ฆ3 =๐ฅ1๐ฅ2 ๐ฅ1 + ๐ฅ2 โ ๐ฅ3 ๐ฅ1 + ๐ฅ2
2 โ ๐ฅ1๐ฅ2 + ๐ด โ ๐ฆ1๐ฆ2 โ ๐ต
๐ฆ1 + ๐ฆ2
Remark: new exceptional point pairs will appear, but they are less likely to be hit by anaddition/subtraction chain.
Other curve shapes
Weierstrass curves are not the only shapes of elliptic curves that have been studied! Among themother cubics: Hessian curves, Montgomery curves, โฆ
But itโs worth even leaving the realm of cubics! Annoying feature for this talk: arithmetic is no longer using tangents and chords.
Most prominent example: if char ๐ โ 2 then we can consider the (twisted) Edwards curves
๐๐ฅ2 + ๐ฆ2 = 1 + ๐๐ฅ2๐ฆ2
where ๐, ๐ โ ๐ satisfy ๐๐ ๐ โ ๐ โ 0 and ๐ = (0,1). It admits the amazing addition formula
๐ฅ1, ๐ฆ1 + ๐ฅ2, ๐ฆ2 =๐ฅ1๐ฆ2 + ๐ฆ1๐ฅ2
1 + ๐๐ฅ1๐ฅ2๐ฆ1๐ฆ2,๐ฆ1๐ฆ2 โ ๐๐ฅ1๐ฅ21 โ ๐๐ฅ1๐ฅ2๐ฆ1๐ฆ2
,
which are very efficient and can be used for doubling as well (uniformity).
Other curve shapes
A priori annoying aspect of Edwards curves: there are two singular points at infinity, each of whichsecretly corresponds to two points on the complete non-singular model.
But in fact this is a feature!
If ๐ is a non-zero square and ๐ is a non-square, then these four points are not defined over ๐.
Therefore they are never encountered duringarithmetic over ๐, or in other words we have an entirely affine group structure.
๐๐ฅ2 + ๐ฆ2 = 1 + ๐๐ฅ2๐ฆ2
Moreover, the addition formula is complete in this case, i.e. it has no exceptional points.
๐-coordinate only arithmetic and the Montgomery ladder
As we have observed earlier:
๐ and ๐ have the same ๐ฅ-coordinate โ ๐ = ยฑ๐
Therefore the ๐ฅ-coordinate of ๐๐ only depends on the ๐ฅ-coordinate of ๐, so it should be possibleto compute it without any involvement of ๐ฆ-coordinates.
Problem: every double-and-add routine involves addition steps, and there the idea breaks down: ๐ฅ(๐) and ๐ฅ(๐) do not suffice to find ๐ฅ(๐ + ๐).
๐-coordinate only arithmetic and the Montgomery ladder
But it is true that ๐ฅ(๐ + ๐) is determined by ๐ฅ ๐ , ๐ฅ(๐) and ๐ฅ(๐ โ ๐).
Peter L. Montgomery
Montgomery found a way to exploit this: recursively compute
๐ฅ ๐๐ , ๐ฅ( ๐ + 1 ๐) from ๐ฅ๐
2๐ , ๐ฅ(
๐
2+ 1 ๐)
using one doubling and one appropriate addition. Note that ๐ฅ(๐) is known.
Very fast.Very uniform: good against side-channel attacks.Possible to recover the ๐ฆ-coordinate from the end result (Lopez-Dahab).Comes in projective version: coordinates ๐ฅ: ๐ง โ ๐1(๐).Montgomery chose a more efficient curve form: ๐ต๐ฆ2 = ๐ฅ3 + ๐ด๐ฅ2 + ๐ฅ
Questions?