Use "let mutable" to introduce mutable variables in algorithms.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2020-11-05 13:35:28 +00:00
parent 9c9ad74fad
commit 775b5f3b5d
1 changed files with 30 additions and 29 deletions

View File

@ -5895,15 +5895,15 @@ be the \incomingViewingKey corresponding to $\AuthPrivate$, and let $\TransmitPu
\vspace{1ex}
\begin{algorithm}
\item Initialize $\ReceivedSet \typecolon \powerset{\NoteTypeSprout \times \MemoType} = \setof{}$.
\item Initialize $\SpentSet \typecolon \powerset{\NoteTypeSprout} = \setof{}$.
\item Initialize $\NullifierMap \typecolon \PRFOutputSprout \rightarrow \NoteTypeSprout$ to the empty mapping.
\item let mutable $\ReceivedSet \typecolon \powerset{\NoteTypeSprout \times \MemoType} := \setof{}$
\item let mutable $\SpentSet \typecolon \powerset{\NoteTypeSprout} := \setof{}$
\item let mutable $\NullifierMap \typecolon \PRFOutputSprout \rightarrow \NoteTypeSprout :=$ the empty mapping
\vspace{1ex}
\item For each \transaction $\tx$,
\item \tab For each \joinSplitDescription in $\tx$,
\item \tab \tab Let $(\EphemeralPublic, \TransmitCiphertext{\allNew})$ be the \notesCiphertext
of the \joinSplitDescription.
\item \tab \tab For $i$ in $\allNew$,
\item for each \transaction $\tx$:
\item \tab for each \joinSplitDescription in $\tx$:
\item \tab \tab let $(\EphemeralPublic, \TransmitCiphertext{\allNew})$ be the \notesCiphertext
of the \joinSplitDescription
\item \tab \tab for $i$ in $\allNew$:
\item \tab \tab \tab Attempt to decrypt the \notesCiphertext component
$(\EphemeralPublic, \TransmitCiphertext{i})$ using $\InViewingKey$ with the
\vspace{-1.2ex}
@ -5916,12 +5916,12 @@ be the \incomingViewingKey corresponding to $\AuthPrivate$, and let $\TransmitPu
as described in \crossref{notes}.
\item \tab \tab \tab \tab Add the mapping $\nf \rightarrow \NoteTuple{}$ to $\NullifierMap$.
\item \blank
\item \tab \tab Let $\nf_{\allOld}$ be the \nullifiers of the \joinSplitDescription.
\item \tab \tab For $i$ in $\allOld$,
\item \tab \tab \tab If $\nf_i$ is present in $\NullifierMap$, add $\NullifierMap(\nf_i)$
to $\SpentSet$.
\item \tab \tab let $\nf_{\allOld}$ be the \nullifiers of the \joinSplitDescription
\item \tab \tab for $i$ in $\allOld$:
\item \tab \tab \tab if $\nf_i$ is present in $\NullifierMap$, add $\NullifierMap(\nf_i)$
to $\SpentSet$
\item \blank
\item Return $(\ReceivedSet, \SpentSet)$.
\item return $(\ReceivedSet, \SpentSet)$.
\end{algorithm}
@ -5950,26 +5950,26 @@ and its final status (spent or unspent).
\vspace{1ex}
\begin{algorithm}
\item Initialize $\ReceivedSet \typecolon \powerset{\NoteTypeSapling \times \MemoType} = \setof{}$.
\item Initialize $\SpentSet \typecolon \powerset{\NoteTypeSapling} = \setof{}$.
\item Initialize $\NullifierMap \typecolon \PRFOutputNfSapling \rightarrow \NoteTypeSapling$ to the empty mapping.
\item let mutable $\ReceivedSet \typecolon \powerset{\NoteTypeSapling \times \MemoType} := \setof{}$
\item let mutable $\SpentSet \typecolon \powerset{\NoteTypeSapling} := \setof{}$
\item let mutable $\NullifierMap \typecolon \PRFOutputNfSapling \rightarrow \NoteTypeSapling :=$ the empty mapping
\vspace{1ex}
\item For each \transaction $\tx$,
\item \tab For each \outputDescription in $\tx$ with \notePosition $\NotePosition$,
\item for each \transaction $\tx$:
\item \tab for each \outputDescription in $\tx$ with \notePosition $\NotePosition$:
\item \tab \tab Attempt to decrypt the \noteCiphertext components
$\EphemeralPublic$ and $\TransmitCiphertext{}$ using $\InViewingKey$ with the algorithm\vspace{-1.2ex}%
\item \tab \tab in \crossref{saplingdecryptivk}. If this succeeds giving $\NotePlaintext{}$:
\item \tab \tab \tab Extract $\NoteTuple{}$ and $\Memo \typecolon \MemoType$ from $\NotePlaintext{}$.
\item \tab \tab \tab Add $(\NoteTuple{}, \Memo)$ to $\ReceivedSet$.
\item \tab \tab \tab Extract $\NoteTuple{}$ and $\Memo \typecolon \MemoType$ from $\NotePlaintext{}$
\item \tab \tab \tab Add $(\NoteTuple{}, \Memo)$ to $\ReceivedSet$
\item \tab \tab \tab Calculate the nullifier $\nf$ of $\NoteTuple{}$ using $\AuthProvePublic$
and $\NotePosition$ as described in \crossref{notes}.
\item \tab \tab \tab Add the mapping $\nf \rightarrow \NoteTuple{}$ to $\NullifierMap$.
\item \blank
\item \tab For each \spendDescription in $\tx$,
\item \tab \tab Let $\nf$ be the \nullifier of the \spendDescription.
\item \tab \tab If $\nf$ is present in $\NullifierMap$, add $\NullifierMap(\nf)$ to $\SpentSet$.
\item \tab for each \spendDescription in $\tx$:
\item \tab \tab let $\nf$ be the \nullifier of the \spendDescription
\item \tab \tab if $\nf$ is present in $\NullifierMap$, add $\NullifierMap(\nf)$ to $\SpentSet$
\item \blank
\item Return $(\ReceivedSet, \SpentSet)$.
\item return $(\ReceivedSet, \SpentSet)$.
\end{algorithm}
\begin{nnotes}
@ -10789,7 +10789,7 @@ Filippo Valsorda, Zaki Manian, Tracy Hu, Brian Warner, Mary Maller,
Michael Dixon, Andrew Poelstra, Eirik Ogilvie-Wigley, Benjamin Winston,
Kobi Gurkan, Weikeng Chen, Henry de Valence, Deirdre Connolly, Chelsea Komlo,
Zancas Wilcox, Jane Lusby, Teor, Izaak Meckler, Zac Williamson, Vitalik Buterin,
and no doubt others.
Jakub Zalewski. and no doubt others.
We would also like to thank the designers and developers of \Bitcoin.
\Zcash has benefited from security audits performed by NCC Group, Coinspect,
@ -10855,9 +10855,10 @@ Peter Newell's illustration of the Jubjub bird, from \cite{Carroll1902}.
possibilities is prefix-free. (The human-readable forms are prefix-free but the
raw encodings are not; for example, the \rawEncoding of a \Sapling \spendingKey
can be a prefix of several of the other encodings.)
\item Use ``let mutable'' to introduce mutable variables in algorithms.
\item Include a reference to \cite{BFIJSV2010} for batch pairing verification techniques.
\item Acknowledge Jack Gavigan as a co-designer of \Sapling and of the \Zcash protocol.
\item Acknowledge Izaak Meckler, Zac Williamson, and Vitalik Buterin.
\item Acknowledge Izaak Meckler, Zac Williamson, Vitalik Buterin, and Jakub Zalewski.
\item Acknowledge Alexandra Elbakyan.
\end{itemize}
@ -13426,11 +13427,11 @@ Define $\BlakeTwos{256} \typecolon (p \typecolon \byteseq{8}) \times (x \typecol
\item \blank
\item let $h \typecolon \typeexp{\binaryrange{32}}{8} =
\listcomp{\LEOStoIPOf{32}{\BlakeParamBlock_{\barerange{4 \mult i}{4 \mult i\,+\,3}}} \xor \BlakeIV_i \for i \from 0 \upto 7}$
\item let $v \typecolon \typeexp{\binaryrange{32}}{16} =
h \bconcat\,[\,\BlakeIV_0, \BlakeIV_1, \BlakeIV_2, \BlakeIV_3,
t_0 \xor \BlakeIV_4, t_1 \xor \BlakeIV_5, f_0 \xor \BlakeIV_6, f_1 \xor \BlakeIV_7\,]$
\item let $m \typecolon \typeexp{\binaryrange{32}}{16} =
\listcomp{\LEOStoIPOf{32}{x_{\barerange{4 \mult i}{4 \mult i\,+\,3}}} \for i \from 0 \upto 15}$
\item let mutable $v \typecolon \typeexp{\binaryrange{32}}{16} :=
h \bconcat\,[\,\BlakeIV_0, \BlakeIV_1, \BlakeIV_2, \BlakeIV_3,
t_0 \xor \BlakeIV_4, t_1 \xor \BlakeIV_5, f_0 \xor \BlakeIV_6, f_1 \xor \BlakeIV_7\,]$
\vspace{1ex}
\item for $r$ from $0$ up to $9$:
\vspace{-2ex}