Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nettle
nettle
Commits
d51ff03e
Commit
d51ff03e
authored
Sep 6, 2014
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
Notes on the Montgomery ladder.
parent
ac1e6e5a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc/ecc-formulas.tex
+69
-0
69 additions, 0 deletions
misc/ecc-formulas.tex
with
69 additions
and
0 deletions
misc/ecc-formulas.tex
+
69
−
0
View file @
d51ff03e
...
@@ -63,6 +63,75 @@ y_2)$:
...
@@ -63,6 +63,75 @@ y_2)$:
Again, very similar to the Weierstraß formulas, with only an
Again, very similar to the Weierstraß formulas, with only an
additional
$
b
$
term in the formula for
$
x
_
3
$
.
additional
$
b
$
term in the formula for
$
x
_
3
$
.
\subsection
{
Montgomery ladder
}
It's possible to do operations on a Montgomery curve in terms of the
$
x
$
coordinate only. Or, with homogeneous coordinates, use
$
X
$
and
$
Z
$
with
$
x
=
X
/
Z
$
.
For doubling,
\begin{align*}
x'
&
= (x
^
2 - z
^
2)
^
2 = (x-z)
^
2 (x+z)
^
2
\\
t
&
= (x+z)
^
2 - (x-z)
^
2
\\
z'
&
= 4 xz (x
^
2 + bzx + z
^
2) = t
\left
((x+z)
^
2 + b't
\right
)
\end{align*}
with
$
b'
=
(
b
-
2
)/
4
$
.
Addition is a bit trickier. If we have
$
x
$
and
$
z
$
for points
$
Q
_
1
$
,
$
Q
_
2
$
and
$
Q
_
3
$
, with
$
Q
_
3
=
Q
_
1
+
Q
_
3
$
, and
$
x
_
1
, z
_
1
\neq
0
$
, we
get the coordinates for
$
Q
_
2
+
Q
_
3
$
as
\begin{align*}
x'
&
= 4 (x
_
2 x
_
3 - z
_
2 z
_
3)
^
2 z
_
1 =
\left
((x
_
2 - z
_
2)(x
_
3 + z
_
3) +
(x
_
2 + z
_
2)(x
_
3 - z
_
3)
\right
)
^
2 z
_
1
\\
z'
&
= 4 (x
_
2 z
_
3 - z
_
2 x
_
3)
^
2 x
_
1 =
\left
((x
_
2 - z
_
2)(x
_
3 + z
_
3) -
(x
_
2 + z
_
2)(x
_
3 - z
_
3)
\right
)
^
2 x
_
1
\end{align*}
Note that the doubling formula is symmetric in
$
Q
_
2
$
and
$
Q
_
3
$
. Which
is consistent with negating of
$
Q
_
1
$
, which really is the negatiion of
the
$
y
$
-coordinate, which doesn't appear in the formula.
This can be used for a binary ``Montgomery ladder'' to compute
$
n Q
$
for any
$
n
$
. If we have the points
$
Q
$
,
$
n Q
$
, and
$
(
n
+
1
)
Q
$
, we can
compute the three points
\begin{align*}
(2n) Q
&
= 2 (nQ)
&&
\text
{
doubling
}
\\
(2n+1) Q
&
= (nQ) + (n+1)Q
&&
\text
{
addition
}
\\
(2n+2) Q
&
= 2((n+1) Q)
&&
\text
{
doubling
}
\end{align*}
The following algorithm is suggested by dj (see
\url
{
http://www.ietf.org/mail-archive/web/cfrg/current/msg05004.html
}
.
\begin{verbatim}
x2,z2,x3,z3 = 1,0,x1,1
for i in reversed(range(255)):
bit = 1
&
(n >> i)
x2,x3 = cswap(x2,x3,bit)
z2,z3 = cswap(z2,z3,bit)
x3,z3 = ((x2*x3-z2*z3)
^
2,x1*(x2*z3-z2*x3)
^
2)
x2,z2 = ((x2
^
2-z2
^
2)
^
2,4*x2*z2*(x2
^
2+A*x2*z2+z2
^
2))
x2,x3 = cswap(x2,x3,bit)
z2,z3 = cswap(z2,z3,bit)
return x2*z2
^
(p-2)
\end{verbatim}
It's not too hard to decipher this. The update for
$
x
_
2
, z
_
2
$
is the
doubling. The update for
$
x
_
3
, z
_
3
$
is an addition.
If the bit is zero, we get
$
x
_
2
', z
_
2
'
$
representing
$
Q
_
2
'
=
2
Q
_
2
$
,
and
$
x
_
3
', z
_
3
'
$
representing
$
Q
_
3
'
=
Q
_
2
+
Q
_
3
=
2
Q
_
2
+
Q
_
1
$
.
What if the bit is set? For the doubling, we get it applied to
$
Q
_
3
$
instead, so we get
$
x
_
3
', z
_
3
'
$
representing
$
Q
_
3
'
=
2
Q
_
3
=
2
Q
_
2
+
2
Q
_
1
$
. For the add, the initial swap flips the sign of one of the
intermediate values, but the end result is the same, so we get
$
x
_
2
',
z
_
2
'
$
representing
$
Q
_
2
'
=
Q
_
2
+
Q
_
3
=
2
Q
_
2
+
Q
_
1
$
, as desired.
Note that the initial conditional swap doesn't have to be a full swap;
if that's convenient in the implementation, a conditional assignment
should be sufficient to get the duplication formula appplied to the
right point. It looks like, in all cases, one will start by computing
$
x
_
2
\pm
z
_
2
$
and
$
x
_
3
\pm
z
_
3
$
, so maybe one can apply conditional
assignment to these values instead.
\section
{
Edwards curve
}
\section
{
Edwards curve
}
For an Edwards curve, we consider the special case
For an Edwards curve, we consider the special case
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment