Commit 3a5e3d65 authored by Peter Schwabe's avatar Peter Schwabe
Browse files

Updated structure and build system of the paper, step 1

parent d0114f8c
CSM.thm CSM.thm
tweetverif.tex !tweetverif-USENIX.pdf
\ No newline at end of file
In this section, we first give a brief summary of the mathematical background
on elliptic curves. We then describe X25519 and its implementation in TweetNaCl.
Finally, we provide a brief description of the formal tools we use in our proofs.
\subsection{Arithmetic on Montgomery curves}
Given a field \K, and $a,b \in \K$ such that $a^2 \neq 4$ and $b \neq 0$,
$M_{a,b}$ is the Montgomery curve defined over $\K$ with equation
$$M_{a,b}: by^2 = x^3 + ax^2 + x.$$
For any algebraic extension $\L \supseteq \K$, we call
$M_{a,b}(\L)$ the set of $\L$-rational points, defined as
$$M_{a,b}(\L) = \{\Oinf\} \cup \{(x,y) \in \L \times \L~|~by^2 = x^3 + ax^2 + x\}.$$
Here, the additional element $\Oinf$ denotes the point at infinity.
Details of the formalization can be found in \sref{subsec:ECC-Montgomery}.
For $M_{a,b}$ over a finite field $\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 \emph{quadratic twist} of $M_{a,b}$, i.e.,
a curve that is isomorphic over $\F{p^2}$~\cite{cryptoeprint:2017:212}.
Points in $M_{a,b}(\K)$ can be equipped with a structure of an abelian group
with the addition operation $+$ and with neutral element the point at infinity $\Oinf$.
For a point $P \in M_{a,b}(\K)$ and a positive integer $n$ we obtain the scalar product
$$n\cdot P = \underbrace{P + \cdots + P}_{n\text{ times}}.$$
In order to efficiently compute the scalar multiplication we use an algorithm
similar to square-and-multiply: the Montgomery ladder where the basic operations
are differential addition and doubling~\cite{MontgomerySpeeding}.
We consider \xcoord-only operations. Throughout the computation,
these $x$-coordinates are kept in projective representation
$(X : Z)$, with $x = X/Z$; the point at infinity is represented as $(1:0)$.
See \sref{subsec:ECC-projective} for more details.
We define the operation:
\texttt{xDBL\&ADD} & : (x_{Q-P}, (X_P:Z_P), (X_Q:Z_Q)) \mapsto \\
& ((X_{2 \cdot P}:Z_{2 \cdot P}), (X_{P + Q}:Z_{P + Q}))
In the Montgomery ladder, % notice that
% the arguments of \texttt{xADD} and \texttt{xDBL}
the arguments $P$ and $Q$ of \texttt{xDBL\&ADD}
are swapped depending on the value of the $k^{\text{th}}$ bit.
We use a conditional swap \texttt{CSWAP} to change the arguments of the above
function while keeping the same body of the loop. \label{cswap}
Given a pair $(P_0, P_1)$ and a bit $b$, \texttt{CSWAP} returns the pair
$(P_b, P_{1-b})$.
By using the differential addition and doubling operations we define the Montgomery ladder
computing a \xcoord-only scalar multiplication (see \aref{alg:montgomery-ladder}).
\caption{Montgomery ladder for scalar mult.}
\REQUIRE{\xcoord $x_P$ of a point $P$, scalar $n$ with $n < 2^m$}
\ENSURE{\xcoord $x_Q$ of $Q = n \cdot P$}
\STATE $Q = (X_Q:Z_Q) \leftarrow (1:0)$
\STATE $R = (X_R:Z_R) \leftarrow (x_P:1)$
\FOR{$k$ := $m$ down to $1$}
\STATE $(Q,R) \leftarrow \texttt{CSWAP}((Q,R), k^{\text{th}}\text{ bit of }n)$
% \STATE $Q \leftarrow \texttt{xDBL}(Q)$
% \STATE $R \leftarrow \texttt{xADD}(x_P,Q,R)$
\STATE $(Q,R) \leftarrow \texttt{xDBL\&ADD}(x_P,Q,R)$
\STATE $(Q,R) \leftarrow \texttt{CSWAP}((Q,R), k^{\text{th}}\text{ bit of }n)$
\subsection{The X25519 key exchange}
From now on let $\F{p}$ be the field with $p=2^{255}-19$ elements.
We consider the elliptic curve $E$ over $\F{p}$ defined by the
equation $y^2 = x^3 + 486662 x^2 + x$.
For every $x \in \F{p}$ there exists a point $P$ in $E(\F{p^2})$
such that $x$ is the \xcoord of $P$.
The core of the X25519 key-exchange protocol is a scalar\hyp{}multiplication
function, which we will also refer to as X25519.
This function receives as input two arrays of $32$ bytes each.
One of them is interpreted as the little-endian encoding of a
non-negative 256-bit integer $n$ (see \ref{sec:Coq-RFC}).
The other is interpreted as the little-endian encoding of
the \xcoord $x_P \in \F{p}$ of a point in $E(\F{p^2})$,
using the standard mapping of integers modulo $p$ to elements in $\F{p}$.
The X25519 function first computes a scalar $n'$ from $n$ by setting
bits at position 0, 1, 2 and 255 to \texttt{0}; and at position 254
to \texttt{1}.
This operation is often called ``clamping'' of the scalar $n$.
Note that $n' \in 2^{254} + 8\{0,1,\ldots,2^{251}-1\}$.
X25519 then computes the \xcoord of $n'\cdot P$.
RFC~7748~\cite{rfc7748} standardizes the X25519 Diffie–Hellman key-exchange algorithm.
Given the base point $B$ where $X_B=9$, each party generates a secret random number
$s_a$ (respectively $s_b$), and computes $X_{P_a}$ (respectively $X_{P_b}$), the
\xcoord of $P_A = s_a \cdot B$ (respectively $P_B = s_b \cdot B$).
The parties exchange $X_{P_a}$ and $X_{P_b}$ and compute their shared secret
$s_a \cdot s_b \cdot B$ with
X25519 on $s_a$ and $X_{P_b}$ (respectively $s_b$ and $X_{P_a}$).
\subsection{Coq, separation logic, and VST}
Coq~\cite{coq-faq} is an interactive theorem prover based on type theory. It
provides an expressive formal language to write mathematical definitions,
algorithms, and theorems together with their proofs. It has been used in the proof
of the four-color theorem~\cite{gonthier2008formal} and it is also the system
underlying the CompCert formally verified C compiler~\cite{Leroy-backend}.
Unlike systems like F*~\cite{DBLP:journals/corr/BhargavanDFHPRR17},
Coq does not rely on an SMT solver in its trusted code base.
It uses its type system to verify the applications of hypotheses,
lemmas, and theorems~\cite{Howard1995-HOWTFN}.
Hoare logic is a formal system which allows reasoning about programs.
It uses triples such as
where ${\color{doc@lstnumbers}\textbf{Pre}}$ and ${\color{doc@lstdirective}\textbf{Post}}$
are assertions and \texttt{Prog} is a fragment of code.
It is read as
``when the precondition ${\color{doc@lstnumbers}\textbf{Pre}}$ is met,
executing \texttt{Prog} will yield postcondition ${\color{doc@lstdirective}\textbf{Post}}$''.
We use compositional rules to prove the truth value of a Hoare triple.
For example, here is the rule for sequential composition:
Separation logic is an extension of Hoare logic which allows reasoning about
pointers and memory manipulation. This logic enforces strict conditions on the
memory shared such as being disjoint.
We discuss this limitation further in \sref{subsec:with-VST}.
The Verified Software Toolchain (VST)~\cite{cao2018vst-floyd} is a framework
which uses separation logic (proven correct with respect to CompCert semantics)
to prove the functional correctness of C programs.
The first step consists of translating the source code into Clight,
an intermediate representation used by CompCert.
For such purpose one uses the parser of CompCert called \texttt{clightgen}.
In a second step one defines the Hoare triple representing the specification of
the piece of software one wants to prove. Then using VST, one uses a strongest
postcondition approach to prove the correctness of the triple.
This can be seen as a forward symbolic execution of the program.
\section{Proving equivalence of X25519 in C and Coq}
In this section we prove the following theorem:
% In this section we outline the structure of our proofs of the following theorem:
The implementation of X25519 in TweetNaCl (\TNaCle{crypto_scalarmult}) matches
the specifications of RFC~7748~\cite{rfc7748} (\Coqe{RFC}).
More formally:
Theorem body_crypto_scalarmult:
(* VST boiler plate. *)
(* Clight translation of TweetNaCl. *)
(* Hoare triples for fct calls. *)
(* fct we verify. *)
(* Our Hoare triple, see below. *)
% We first describe the global structure of our proof (\ref{subsec:proof-structure}).
Using our formalization of RFC~7748 (\sref{sec:Coq-RFC}) we specify the Hoare
triple before proving its correctness with VST (\ref{subsec:with-VST}).
We provide an example of equivalence of operations over different number
representations (\ref{subsec:num-repr-rfc}).
% Then, we describe efficient techniques used in some of our more complex proofs (\ref{subsec:inversions-reflections}).
\subsection{Applying the Verifiable Software Toolchain}
We now turn our focus to the formal specification of \TNaCle{crypto_scalarmult}.
We use our definition of X25519 from the RFC in the Hoare triple and prove
its correctness.
We show the soundness of TweetNaCl by proving a correspondence between
the C version of TweetNaCl and a pure function in Coq formalizing the RFC.
% why "pure" ?
% A pure function is a function where the return value is only determined by its
% input values, without observable side effects (Side effect are e.g. printing)
This defines the equivalence between the Clight representation and our Coq
definition of the ladder (\coqe{RFC}).
Definition crypto_scalarmult_spec :=
DECLARE _crypto_scalarmult_curve25519_tweet
v_q: val, v_n: val, v_p: val, c121665:val,
sh : share,
q : list val, n : list Z, p : list Z
PRE [ _q OF (tptr tuchar),
_n OF (tptr tuchar),
_p OF (tptr tuchar) ]
PROP (writable_share sh;
Forall (fun x => 0 <= x < 2^8) p;
Forall (fun x => 0 <= x < 2^8) n;
Zlength q = 32; Zlength n = 32;
Zlength p = 32)
LOCAL(temp _q v_q; temp _n v_n; temp _p v_p;
gvar __121665 c121665)
SEP (sh [{ v_q }] <<(uch32)-- q;
sh [{ v_n }] <<(uch32)-- mVI n;
sh [{ v_p }] <<(uch32)-- mVI p;
Ews [{ c121665 }] <<(lg16)-- mVI64 c_121665)
POST [ tint ]
PROP (Forall (fun x => 0 <= x < 2^8) (RFC n p);
Zlength (RFC n p) = 32)
LOCAL(temp ret_temp (Vint
SEP (sh [{ v_q }] <<(uch32)-- mVI (RFC n p);
sh [{ v_n }] <<(uch32)-- mVI n;
sh [{ v_p }] <<(uch32)-- mVI p;
Ews [{ c121665 }] <<(lg16)-- mVI64 c_121665
In this specification we state preconditions like:
\item[] \VSTe{PRE}: \VSTe{_p OF (tptr tuchar)}\\
The function \TNaCle{crypto_scalarmult} takes as input three pointers to
arrays of unsigned bytes (\VSTe{tptr tuchar}) \VSTe{_p}, \VSTe{_q} and \VSTe{_n}.
\item[] \VSTe{LOCAL}: \VSTe{temp _p v_p}\\
Each pointer represent an address \VSTe{v_p},
\VSTe{v_q} and \VSTe{v_n}.
\item[] \VSTe{SEP}: \VSTe{sh [{ v_p $\!\!\}\!\!]\!\!\!$ <<(uch32)-- mVI p}\\
In the memory share \texttt{sh}, the address \VSTe{v_p} points
to a list of integer values \VSTe{mVI p}.
\item[] \VSTe{Ews [{ c121665 $\!\!\}\!\!]\!$ <<(lg16)-- mVI64 c_121665}\\
In the global memory share \texttt{Ews}, the address \VSTe{c121665} points
to a list of 16 64-bit integer values corresponding to $a/4 = 121665$.
\item[] \VSTe{PROP}: \VSTe{Forall (fun x => 0 <= x < 2^8) p}\\
In order to consider all the possible inputs, we assume each
element of the list \texttt{p} to be bounded by $0$ included and $2^8$
\item[] \VSTe{PROP}: \VSTe{Zlength p = 32}\\
We also assume that the length of the list \texttt{p} is 32. This defines the
complete representation of \TNaCle{u8[32]}.
As postcondition we have conditions like:
\item[] \VSTe{POST}: \VSTe{tint}\\
The function \TNaCle{crypto_scalarmult} returns an integer.
\item[] \VSTe{LOCAL}: \VSTe{temp ret_temp (Vint}\\
The returned integer has value $0$.
\item[] \VSTe{SEP}: \VSTe{sh [{ v_q $\!\!\}\!\!]\!\!\!$ <<(uch32)-- mVI (RFC n p)}\\
In the memory share \texttt{sh}, the address \VSTe{v_q} points
to a list of integer values \VSTe{mVI (RFC n p)} where \VSTe{RFC n p} is the
result of the \TNaCle{crypto_scalarmult} of \VSTe{n} and \VSTe{p}.
\item[] \VSTe{PROP}: \VSTe{Forall (fun x => 0 <= x < 2^8) (RFC n p)}\\
\VSTe{PROP}: \VSTe{Zlength (RFC n p) = 32}\\
We show that the computation for \VSTe{RFC} fits in \TNaCle{u8[32]}.
\TNaCle{crypto_scalarmult} computes the same result as \VSTe{RFC}
in Coq provided that inputs are within their respective bounds: arrays of 32 bytes.
The correctness of this specification is formally proven in Coq as
\coqe{Theorem body_crypto_scalarmult}.
% \begin{sloppypar}
% This specification (proven with VST) shows that \TNaCle{crypto_scalarmult} in C.
% \end{sloppypar}
% The Verifiable Software Toolchain uses a strongest postcondition strategy.
% The user must first write a formal specification of the function he wants to verify in Coq.
% This should be as close as possible to the C implementation behavior.
% This will simplify the proof and help with stepping through the Clight version of the software.
% With the range of inputs defined, VST mechanically steps through each instruction
% and ask the user to verify auxiliary goals such as array bound access, or absence of overflows/underflows.
% We call this specification a low level specification. A user will then have an easier
% time to prove that his low level specification matches a simpler higher level one.
% In order to further speed-up the verification process, it has to be know that to
% prove the specification \TNaCle{crypto_scalarmult}, a user only need the specification of e.g. \TNaCle{M}.
% This provide with multiple advantages: the verification by the Coq kernel can be done
% in parallel and multiple users can work on proving different functions at the same time.
% For the sake of completeness we proved all intermediate functions.
\subheading{Memory aliasing.}
The semicolon in the \VSTe{SEP} parts of the Hoare triples represents the \emph{separating conjunction} (often written as a star), which means that
the memory shares of \texttt{q}, \texttt{n} and \texttt{p} do not overlap.
In other words,
we only prove correctness of \TNaCle{crypto_scalarmult} when it is called without aliasing.
But for other TweetNaCl functions, like the multiplication function \texttt{M(o,a,b)}, we cannot ignore aliasing, as it is called in the ladder in an aliased manner.
In VST, a simple specification of this function will assume that the pointer arguments
point to non-overlapping space in memory.
When called with three memory fragments (\texttt{o, a, b}),
the three of them will be consumed. However assuming this naive specification
when \texttt{M(o,a,a)} is called (squaring), the first two memory areas (\texttt{o, a})
are consumed and VST will expect a third memory section (\texttt{a}) which does not \emph{exist} anymore.
Examples of such cases are illustrated in \fref{tikz:MemSame}.
\caption{Aliasing and Separation Logic}%
As a result, a function must either have multiple specifications or specify which
aliasing case is being used.
The first option would require us to do very similar proofs multiple times for a same function.
We chose the second approach: for functions with 3 arguments, named hereafter \texttt{o, a, b},
we define an additional parameter $k$ with values in $\{0,1,2,3\}$:
\item if $k=0$ then \texttt{o} and \texttt{a} are aliased.
\item if $k=1$ then \texttt{o} and \texttt{b} are aliased.
\item if $k=2$ then \texttt{a} and \texttt{b} are aliased.
\item else there is no aliasing.
In the proof of our specification, we do a case analysis over $k$ when needed.
This solution does not cover all the possible cases of aliasing over 3 pointers
(\eg \texttt{o} = \texttt{a} = \texttt{b}) but it is enough to satisfy our needs.
\subheading{Improving verification speed.}
To make the verification the smoothest, the Coq formal definition of the function
should be as close as possible to the C implementation.
Optimizations of such definitions are often counter-productive as they increase the
amount of proofs required for \eg bounds checking, loop invariants.
In order to further speed-up the verification process, to prove the specification
\TNaCle{crypto_scalarmult}, we only need the specification of the subsequently
called functions (\eg \TNaCle{M}).
This provide with multiple advantages: the verification by Coq can be
done in parallel and multiple users can work on proving different functions at
the same time.
% We proved all intermediate functions.
% %XXX-Peter: shouldn't verifying fixed-length for loops be rather standard?
% %XXX Benoit: it is simple if the argument is increasing or if the "recursive call"
% % is made before the computations.
% % This is not the case here: you compute idx 255 before 254...
% % Can we shorten the next paragraph?
% \subheading{Verifying \texttt{for} loops.}
% Final states of \texttt{for} loops are usually computed by simple recursive functions.
% However, we must define invariants which are true for each iteration step.
% Assume that we want to prove a decreasing loop where indexes go from 3 to 0.
% Define a function $g : \N \rightarrow State \rightarrow State $ which takes as
% input an integer for the index and a state, then returns a state.
% It simulates the body of the \texttt{for} loop.
% Define the recursion: $f : \N \rightarrow State \rightarrow State $ which
% iteratively applies $g$ with decreasing index:
% \begin{equation*}
% f ( i , s ) =
% \begin{cases}
% s & \text{if } s = 0 \\
% f( i - 1 , g ( i - 1 , s )) & \text{otherwise}
% \end{cases}
% \end{equation*}
% Then we have:
% \begin{align*}
% f(4,s) &= g(0,g(1,g(2,g(3,s))))
% \end{align*}
% To prove the correctness of $f(4,s)$, we need to prove that intermediate steps
% $g(3,s)$; $g(2,g(3,s))$; $g(1,g(2,g(3,s)))$; $g(0,g(1,g(2,g(3,s))))$ are correct.
% Due to the computation order of recursive function, our loop invariant for
% $i\in\{0,1,2,3,4\}$ cannot use $f(i)$.
% To solve this, we define an auxiliary function with an accumulator such that
% given $i\in\{0,1,2,3,4\}$, it will compute the first $i$ steps of the loop.
% We then prove for the complete number of steps, the function with the accumulator
% and without returns the same result.
% We formalized this result in a generic way in Appendix~\ref{subsubsec:for}.
% Using this formalization, we prove that the 255 steps of the Montgomery ladder
% in C provide the same computations as in \coqe{RFC}.
% % %
\subsection{Number representation and C implementation}
As described in \sref{subsec:Number-TweetNaCl}, numbers in \TNaCle{gf} are represented
in $2^{16}$ and we use a direct mapping to represent that array as a list
integers in Coq. However, in order to show the correctness of the basic operations,
we need to convert this number to an integer.
We reuse the mapping
$\text{\coqe{ZofList}} : \Z \rightarrow \texttt{list}~\Z \rightarrow \Z$ from \sref{sec:Coq-RFC}
and define a notation where $n$ is $16$, placing us with a radix of $2^{16}$.
Notation "Z16.lst A" := (ZofList 16 A).
To facilitate working in $\Zfield$, we define the \coqe{:GF} notation.
Notation "A :GF" := (A mod (2^255-19)).
Later in \sref{subsec:Zmodp}, we formally define $\Ffield$ as a field.
Equivalence between operations in $\Zfield$ (\ie under \coqe{:GF}) and in $\Ffield$ are easily proven.
Using these two definitions, we prove intermediate lemmas such as the correctness of the
multiplication \Coqe{Low.M} where \Coqe{Low.M} replicates the computations and steps done in C.
\Coqe{Low.M} correctly implements the multiplication over $\Zfield$.
And specified in Coq as follows:
Lemma mult_GF_Zlength :
forall (a:list Z) (b:list Z),
Zlength a = 16 ->
Zlength b = 16 ->
(Z16.lst (Low.M a b)) :GF =
(Z16.lst a * Z16.lst b) :GF.
However for our purpose, simple functional correctness is not enough.
We also need to define the bounds under which the operation is correct,
allowing us to chain them, guaranteeing us the absence of overflow.
if all the values of the input arrays are constrained between $-2^{26}$ and $2^{26}$,
then the output of \coqe{Low.M} will be constrained between $-38$ and $2^{16} + 38$.
And seen in Coq as follows:
Lemma M_bound_Zlength :
forall (a:list Z) (b:list Z),
Zlength a = 16 ->
Zlength b = 16 ->
Forall (fun x => -2^26 < x < 2^26) a ->
Forall (fun x => -2^26 < x < 2^26) b ->
Forall (fun x => -38 <= x < 2^16 + 38) (Low.M a b).
TEX := $(filter-out tweetverif.tex,$(wildcard *.tex)) SOURCES= code-tweetnacl.tex collection.bib conclusion.tex coq.tex highlevel.tex intro.tex lowlevel.tex preliminaries.tex proofs.tex rfc.tex t.bib tweetverif.tex
FILES := $(TEX) $(wildcard tikz/*.tex) $(wildcard *.sty)
REVIEWS := _reviews.tex $(wildcard _reviews/*.tex) $(wildcard *.sty)
RED = "\033[38;5;009m"
GREEN = "\033[38;5;010m"
YELLOW = "\033[38;5;011m"
ORANGE = "\033[38;5;214m"
LIGHTPURPLE = "\033[38;5;177m"
PURPLE = "\033[38;5;135m"
CYAN = "\033[38;5;014m"
LIGHTGRAY = "\033[38;5;252m"
DARKGRAY = "\033[38;5;242m"
BRIGHTRED = "\033[91m"
BOLD = "\033[1m"
all: tweetverif.pdf reviews.pdf
# main pdf
tweetverif.pdf: FORCE tweetverif.tex tweetnacl.diff
@echo $(BOLD)$(LIGHTPURPLE)"Building tweetverif.pdf"$(NO_COLOR)$(DARKGRAY)
python3 tweetverif.tex
# main tex
tweetverif.tex: FORCE $(FILES) collection.bib
@echo $(BOLD)$(YELLOW)"Generating tweetverif.tex"$(NO_COLOR)$(DARKGRAY)
python3 tweetverif.tex
# list dependencies
@for f in $(FILES) ; do \
echo $$f; \
# generate diff between verified code and reference code
@echo $(BOLD)$(YELLOW)"Generating tweetnacl.diff"$(NO_COLOR)$(DARKGRAY)
diff -u ../proofs/vst/c/tweetnacl.c ../proofs/vst/c/tweetnaclVerifiableC.c > tweetnacl.diff.tmp; [ $$? -eq 1 ]
sed -i -e 1,2d tweetnacl.diff.tmp
echo '--- tweetnacl.c' >> tweetnacl.diff
echo '+++ tweetnaclVerifiableC.c' >> tweetnacl.diff
cat tweetnacl.diff.tmp >> tweetnacl.diff
rm tweetnacl.diff.tmp
tweetverif.pdf: ${SOURCES}
pdflatex tweetverif.tex
bibtex twetverif
pdflatex tweetverif.tex
pdflatex tweetverif.tex
.PHONY: clean
clean: clean:
@echo $(BOLD)$(RED)"cleaning..."$(NO_COLOR) -rm tweetverif.aux
@rm -fr latex.out 2> /dev/null || true -rm tweetverif.log
@rm tweetverif.pdf 2> /dev/null || true -rm tweetverif.out
@rm reviews.pdf 2> /dev/null || true -rm tweetverif.pdf
@rm *.aux 2> /dev/null || true -rm tweetverif.thm
@rm *.bbl 2> /dev/null || true
@rm *.blg 2> /dev/null || true
@rm *.brf 2> /dev/null || true
@rm *.dvi 2> /dev/null || true
@rm *.fdb_latexmk 2> /dev/null || true
@rm *.fls 2> /dev/null || true
@rm *.log 2> /dev/null || true
@rm *.out 2> /dev/null || true
@rm *.bck 2> /dev/null || true
@rm *.bak 2> /dev/null || true
@rm */*.aux 2> /dev/null || true
@rm tweetverif.tex 2> /dev/null || true
@rm tweetnacl.diff 2> /dev/null || true
@for f in $(TEX) ; do \
aspell -t -c $$f; \
# Bunch of other pdfs
@echo $(BOLD)$(LIGHTPURPLE)"Building feedback.pdf"$(NO_COLOR)$(DARKGRAY)
python3 _includes/_feedback.tex
@mv _feedback.pdf feedback.pdf
reviews.pdf: FORCE _reviews.tex $(REVIEWS)
@echo $(BOLD)$(LIGHTPURPLE)"Building reviews.pdf"$(NO_COLOR)$(DARKGRAY)
python3 _reviews.tex
@mv _reviews.pdf reviews.pdf
specs_map.pdf: FORCE _files.tex
@echo $(BOLD)$(LIGHTPURPLE)"Building specs_map.pdf"$(NO_COLOR)$(DARKGRAY)
python3 _files.tex
@echo $(BOLD)$(ORANGE)"Moving specs_map.pdf to ../"$(NO_COLOR)$(DARKGRAY)
@mv _files.pdf ../specs_map.pdf
This diff is collapsed.
This diff is collapsed.
%XXX-Peter: Does this subsection really belong here? My understanding is that it describes
%the full picture (Sections 4 and 5) and not just what is happening in this section.
% \subsection{Structure of our proof}
% \label{subsec:proof-structure}
% % XXX-Peter: This whole paragraph can go away; we already said this before.
% In order to prove the correctness of X25519 in TweetNaCl code \TNaCle{crypto_scalarmult},
% we use VST to prove that the code matches our functional Coq specification of \Coqe{RFC}.
% Then, we prove that our specification of the scalar multiplication matches the mathematical definition
% of elliptic curves and Theorem 2.1 by Bernstein~\cite{Ber06} (\sref{sec:maths}).
% Verifying \TNaCle{crypto_scalarmult} also implies verifying all the functions
% subsequently called: \TNaCle{unpack25519}; \TNaCle{A}; \TNaCle{Z}; \TNaCle{M};
% \TNaCle{S}; \TNaCle{car25519}; \TNaCle{inv25519}; \TNaCle{set25519}; \TNaCle{sel25519};
% \TNaCle{pack25519}.
% We prove that the implementation of X25519 is \textbf{sound}, \ie:
% \begin{itemize}
% \item absence of access out-of-bounds of arrays (memory safety).
% \item absence of overflows/underflow in the arithmetic.
% \end{itemize}
% We also prove that TweetNaCl's code is \textbf{correct}:
% \begin{itemize}
% \item X25519 is correctly implemented (we get what we expect) .
% \item Operations on \TNaCle{gf} (\TNaCle{A}, \TNaCle{Z}, \TNaCle{M}, \TNaCle{S})
% are equivalent to operations ($+,-,\times,x^2$) in $\Zfield$.
% \item The Montgomery ladder computes the multiple of a point.
% %XXX-Peter: We don't prove this last statement in this section
% \end{itemize}
% In order to prove the soundness and correctness of \TNaCle{crypto_scalarmult},
% we reuse the generic Montgomery ladder defined in \sref{sec:Coq-RFC}.
% We define a high-level specification by instantiating the ladder with a generic
% field $\K$, this allows us to prove the correctness of the ladder with respect
% to the theory of elliptic curves.
% This high-level specification does not rely on the parameters of Curve25519.
% We later specialize $\K$ with $\Ffield$, and the parameters of Curve25519 ($a = 486662, b = 1$),
% to derive the correctness of \coqe{RFC} (\sref{sec:maths}).
% %XXX-Peter: not in this section, correct?
% We define a mid-level specification by instantiating the ladder over $\Zfield$.
% Additionally we also provide a low-level specification close to the \texttt{C} code
% (over lists of $\Z$). We show this specification to be equivalent to the
% \emph{semantic version} of C (Clight) using VST.
% This low level specification gives us the soundness assurance.