Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Benoit Viguier
coq-verif-tweetnacl
Commits
42e02e38
Commit
42e02e38
authored
Aug 01, 2019
by
Benoit Viguier
Browse files
more text
parent
82cb77e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
paper/preliminaries.tex
View file @
42e02e38
...
...
@@ -9,53 +9,62 @@ Finally, we provide a brief description of the formal tools we use in our proofs
\label
{
subsec:montgomery
}
\begin{definition}
Let
$
a,b
\in
\K
$
,
$
M
_{
a,b
}$
is a Montgomery curve defined over a field
$
\K
$
with equation:
$$
M
_{
a,b
}
: by
^
2
=
x
^
3
+
ax
^
2
+
x
$$
where
$
a
^
2
\neq
4
$
and
$
b
\neq
0
$
.
Let
$
a,b
\in
\K
$
such that
$
a
^
2
\neq
4
$
and
$
b
\neq
0
$
,
$
M
_{
a,b
}$
is a
Montgomery curve defined over a field
$
\K
$
with equation:
$$
M
_{
a,b
}
: by
^
2
=
x
^
3
+
ax
^
2
+
x
$$
\end{definition}
\begin{definition}
For any algebraic extension
$
\L
$
of
$
\K
$
,
$
\K
\subseteq
\L
$
,
$
M
_{
a,b
}
(
\L
)
$
is the set of
$
\L
$
-rational points which satisfy the equation with
addition to the point at infinity
$
\Oinf
$
.
$$
M
_{
a,b
}
(
\L
)
=
\{\Oinf\}
\cup
\{
(
x,y
)
\in
\L
\times
\L
~|~by
^
2
=
x
^
3
+
ax
^
2
+
x
\}
$$
For any algebraic extension
$
\L
$
of
$
\K
$
,
$
\K
\subseteq
\L
$
,
$
M
_{
a,b
}
(
\L
)
$
is the set of
$
\L
$
-rational points which satisfy the equation with
addition to the point at infinity
$
\Oinf
$
.
$$
M
_{
a,b
}
(
\L
)
=
\{\Oinf\}
\cup
\{
(
x,y
)
\in
\L
\times
\L
~|~by
^
2
=
x
^
3
+
ax
^
2
+
x
\}
$$
\end{definition}
Details of the formalization can be found in Section~
\ref
{
montgomery
}
.
For
$
M
_{
a,b
}$
over
$
\F
{
p
}$
, the parameter
$
b
$
is known as the ``twisting factor'',
for
$
b'
\in
\F
{
p
}
\backslash\{
0
\}
$
and
$
b'
\neq
b
$
, the curves
$
M
_{
a,b
}$
and
$
M
_{
a,b'
}$
are isomorphic via
$
(
x,y
)
\mapsto
(
x,
\sqrt
{
b'
/
b
}
\cdot
y
)
$
.
When
$
b'
/
b
$
is not a square in
\F
{
p
}
,
$
M
_{
a,b'
}$
is a quadratic twist of
$
M
_{
a,b
}$
:
isomorphic over
$
\F
{
p
^
2
}$
~
\cite
{
cryptoeprint:2017:212
}
.
\begin{definition}
For
$
M
_{
a,b
}$
over
$
\F
{
p
}$
, the parameter
$
b
$
is known as the ``twisting factor'',
for
$
b'
\in
\F
{
p
}
\backslash\{
0
\}
$
and
$
b'
\neq
b
$
, the curves
$
M
_{
a,b
}$
and
$
M
_{
a,b'
}$
are isomorphic via
$
(
x,y
)
\mapsto
(
x,
\sqrt
{
b'
/
b
}
\cdot
y
)
$
.
When
$
b'
/
b
$
is not a square in
\F
{
p
}
,
$
M
_{
a,b'
}$
is a quadratic twist of
$
M
_{
a,b
}$
:
isomorphic over
$
\F
{
p
^
2
}$
~
\cite
{
cryptoeprint:2017:212
}
.
\end{definition}
Points over
$
M
_{
a,b
}
(
\K
)
$
can be equipped with a structure of an abelian group
with the addition operation
$
\oplus
$
and with neutral element the point at infinity
$
\Oinf
$
.
Using this law, we have the scalar multiplication over
$
M
_{
a,b
}
(
\K
)
$
defined by:
$$
n
\cdot
P
=
\underbrace
{
P
\oplus
\cdots
\oplus
P
}_{
n
\text
{
times
}}$$
We now consider x-coordinate-only operations. In order to simplify computations,
such coordinates are represented as
$
X
/
Z
$
fractions. We define two operations:
\begin{align*}
\texttt
{
xADD
}
&
: (X
_
P, Z
_
P, X
_
Q , Z
_
Q, X
_{
P-Q
}
, Z
_{
P-Q
}
)
\mapsto
(X
_{
P+Q
}
, Z
_{
P+Q
}
)
\\
\texttt
{
xDBL
}
&
: (X
_
P, Z
_
P)
\mapsto
(X
_{
2P
}
, Z
_{
2P
}
)
\\
\end{align*}
By using this differential addition and doubling operations we define the Montgomery ladder
computing a x-coordinate-only scalar multiplication (see Algorithm~
\ref
{
montgomery-ladder
}
).
\begin{algorithm}
\caption
{
Montgomery ladder for scalar mult.
}
\label
{
montgomery-ladder
}
\begin{algorithmic}
\REQUIRE
{
x-coordinate of
$
P
$
:
$
P.x
$
, scalars
$
n
$
and
$
m
$
,
$
n <
2
^
m
$}
\ENSURE
{$
Q
=
n
\cdot
P
$}
\STATE
$
Q
\leftarrow
(
X
_
P, Z
_
P
)
$
\STATE
$
R
\leftarrow
\Oinf
$
\STATE
$
Q
\leftarrow
\Oinf
$
\STATE
$
R
\leftarrow
(
X
_
P,Z
_
P
)
$
\FOR
{$
k
$
:=
$
m
$
down to
$
1
$}
\IF
{$
k
^{
\text
{
th
}}$
bit of
$
n
$
is
$
0
$}
\STATE
$
R
\leftarrow
\texttt
{
xADD
}
(
Q,R,X
_
P,Z
_
P
)
$
\STATE
$
Q
\leftarrow
\texttt
{
xDBL
}
(
X
_
P, Z
_
P
)
$
\STATE
$
Q
\leftarrow
\texttt
{
xDBL
}
(
Q
)
$
\ELSE
\STATE
$
Q
\leftarrow
\texttt
{
xADD
}
(
Q,R,X
_
P,Z
_
P
)
$
\STATE
$
R
\leftarrow
\texttt
{
xDBL
}
(
X
_
P, Z
_
P
)
$
\STATE
$
Q
\leftarrow
\texttt
{
xADD
}
(
Q,R,X
_
P,Z
_
P
)
$
\STATE
$
R
\leftarrow
\texttt
{
xDBL
}
(
R
)
$
\ENDIF
\ENDFOR
\end{algorithmic}
\end{algorithm}
$
n
$
is a secret input of algorithm~
\ref
{
montgomery-ladder
}
.
The if statements are secret-dependent and are replaced with constant-time
conditional swap between
$
Q
$
and
$
R
$
in the TweetNaCl implementation.
\subsection
{
The X25519 key exchange
}
\label
{
preliminaries:A
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment