From a3a98848db7a713fb7acd7838a5e6ac69cd86e76 Mon Sep 17 00:00:00 2001
From: Daan Sprenkels <hello@dsprenkels.com>
Date: Wed, 14 Aug 2019 11:40:46 +0200
Subject: [PATCH] Updated appendix captions

---
 algorithms.tex    | 41 ++++++++++++++++++++++++++++++++---------
 gen_algorithms.py | 14 ++++++++++++++
 2 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/algorithms.tex b/algorithms.tex
index be8ec29..b17c254 100644
--- a/algorithms.tex
+++ b/algorithms.tex
@@ -1,8 +1,22 @@
-\todo{dsprenkels: Elaborate these captions, especially \textsc{Red}}
+\newcommand{\sbcaptionextra}{
+    A rule (\rule{4ex}{0.4pt}) denotes a ``dead'' value, i.e.\ one
+    that has no meaning and is unused.
+    \textsc{Red} executes a coefficient-reduction chain.
+}
+\newcommand{\hcaptionextra}{
+    \sbcaptionextra
+    The additions/subtractions with large constants
+    ($2^{32}p$, $4p$ and $2^{37}p$)
+    are to ensure that all the values
+    are in the positive domain after subtraction.
+}
 
 \begin{algorithm}[h]
-\caption{Algorithm for point addition for Curve13318 as implemented on the
-Sandy Bridge microarchitecture.}
+\caption{
+    Algorithm for point addition for Curve13318 as implemented on the
+    Sandy Bridge microarchitecture.
+    \sbcaptionextra
+}
 \label{alg:add_asm_sandybridge}
 \begin{algorithmic}
 \Procedure{Add}{$X_1$, $Y_1$, $Z_1$, $X_2$, $Y_2$, $Z_2$}
@@ -23,8 +37,11 @@ Sandy Bridge microarchitecture.}
 \end{algorithm}
 
 \begin{algorithm}[h]
-\caption{Algorithm for point doubling for Curve13318 as implemented on the
-Sandy Bridge microarchitecture.}
+\caption{
+    Algorithm for point doubling for Curve13318 as implemented on the
+    Sandy Bridge microarchitecture.
+    \sbcaptionextra
+}
 \label{alg:double_asm_sandybridge}
 \begin{algorithmic}
 \Procedure{Double}{$X$, $Y$, $Z$}
@@ -45,8 +62,11 @@ Sandy Bridge microarchitecture.}
 \end{algorithm}
 
 \begin{algorithm}[h]
-\caption{Algorithm for point addition for Curve13318 as implemented on the
-Haswell microarchitecture.}
+\caption{
+    Algorithm for point addition for Curve13318 as implemented on the
+    Haswell microarchitecture.
+    \hcaptionextra
+}
 \label{alg:add_asm_haswell}
 \begin{algorithmic}
 \Procedure{Add}{$X_1$, $Y_1$, $Z_1$, $X_2$, $Y_2$, $Z_2$}
@@ -67,8 +87,11 @@ Haswell microarchitecture.}
 \end{algorithm}
 
 \begin{algorithm}[h]
-\caption{Algorithm for point doubling for Curve13318 as implemented on the
-Haswell microarchitecture.}
+\caption{
+    Algorithm for point doubling for Curve13318 as implemented on the
+    Haswell microarchitecture.
+    \hcaptionextra
+}
 \label{alg:double_asm_haswell}
 \begin{algorithmic}
 \Procedure{Double}{$X$, $Y$, $Z$}
diff --git a/gen_algorithms.py b/gen_algorithms.py
index 7f89c48..8a2e671 100755
--- a/gen_algorithms.py
+++ b/gen_algorithms.py
@@ -572,6 +572,13 @@ h_add.write(
         ('v35', 'v13', 'v31'),
         ('v41', 'v13', 'v23'),
     ))
+h_add.write(batch(
+    '+',
+    (None, None, None),
+    ('v39', 'v39', '2^{37}p'),
+    (None, None, None),
+    (None, None, None),
+))
 h_add.write(batch(
     '-',
     (None, None, None),
@@ -720,6 +727,13 @@ h_double.write(
         ('v34', 'v_{4v_2}', 'v28'),
         (None, None, None),
     ))
+h_double.write(batch(
+    '-',
+    ('v30', 'v30', '2^{37}p'),
+    (None, None, None),
+    (None, None, None),
+    (None, None, None),
+))
 h_double.write(batch(
     '-',
     ('v31', 'v15', 'v30'),
-- 
GitLab