Skip to content

Commit c480d4b

Browse files
committed
[rand.eng.philox] Make the round states explicit.
This clarifies which state is the final result, and avoids the use of the vaguely defined variable $X'$. It changes the index variable $q$ to be 1-based. The single sequence $V$ is replaced with the sequence of sequences $V^{(q)}$. We also rename $\mathit{key}^q_k$ to $K^{(q)}_{k}$, since ISO requires that variable names consist of only a single letter. This creates a nice parallel between $X$/$X^{(q)}$ and $K$/$K^{(q)}$.
1 parent 0245380 commit c480d4b

File tree

1 file changed

+19
-31
lines changed

1 file changed

+19
-31
lines changed

source/numerics.tex

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,27 +3108,24 @@
31083108
\begin{codeblock}
31093109
@$i$@ = @$i$@ + 1
31103110
if (@$i$@ == @$n$@) {
3111-
@$Y$@ = Philox(@$K$@, @$X$@) // \seebelow
3112-
@$Z$@ = @$Z$@ + 1
3111+
@$Y$@ = Philox(@$K$@, @$X$@) // \seebelow
3112+
@$Z$@ = @$Z$@ + 1 // this updates $X$
31133113
@$i$@ = 0
31143114
}
31153115
\end{codeblock}
31163116

31173117
\pnum
31183118
The \tcode{Philox} function maps the length-$n/2$ sequence $K$ and
3119-
the length-$n$ sequence $X$ into a length-$n$ output sequence $Y$.
3119+
the length-$n$ sequence $X$ into a length-$n$ output sequence.
31203120
Philox applies an $r$-round substitution-permutation network to the values in $X$.
3121-
A single round of the generation algorithm performs the following steps:
3121+
That is, there are intermediate values $X^{(0)}, X^{(1)}, \dotsc, X^{(r)}$,
3122+
where $X^{(0)} \cedef X$, and for each round $q$ (with $q = 1, \dotsc, r$),
3123+
$X^{(q)}$ is computed from $X^{(q - 1)}$ as follows. The output sequence is $X^{(r)}$.
31223124
\begin{itemize}
31233125
\item
3124-
The output sequence $X'$ of the previous round
3125-
($X$ in case of the first round)
3126-
is permuted to obtain the intermediate state $V$:
3127-
\begin{codeblock}
3128-
@$V_j = X'_{f_n(j)}$@
3129-
\end{codeblock}
3130-
where $j = 0, \dotsc, n - 1$ and
3131-
$f_n(j)$ is defined in \tref{rand.eng.philox.f}.
3126+
An intermediate state $V^{(q)}$ is obtained by permuting the previous output,
3127+
$V^{(q)}_j \cedef X^{(q - 1)}_{f_n(j)}$,
3128+
where $j = 0, \dotsc, n - 1$, and $f_n(j)$ is defined in \tref{rand.eng.philox.f}.
31323129

31333130
\begin{floattable}{Values for the word permutation $\bm{f}_{\bm{n}}\bm{(j)}$}{rand.eng.philox.f}
31343131
{l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l}
@@ -3146,12 +3143,13 @@
31463143
\end{note}
31473144

31483145
\item
3149-
The following computations are applied to the elements of the $V$ sequence:
3150-
\begin{codeblock}
3151-
@$X_{2k + 0} = \mullo(V_{2k + 1}, M_{k}, w)$@
3152-
@$X_{2k + 1} = \mulhi(V_{2k + 1}, M_{k}, w) \xor \mathit{key}^q_k \xor V_{2k}$@
3153-
\end{codeblock}
3154-
where:
3146+
The next output $X^{(q)}$ is computed from the elements of the $V^{(q)}$ as follows.
3147+
For $k = 0, \dotsc, n/2 - 1$,
3148+
\begin{itemize}
3149+
\item $X^{(q)}_{2k + 0} = \mullo(V^{(q)}_{2k + 1}, M_{k}, w)$, and
3150+
\item $X^{(q)}_{2k + 1} = \mulhi(V^{(q)}_{2k + 1}, M_{k}, w) \xor K^{(q)}_k \xor V^{(q)}_{2k}$,
3151+
\end{itemize}
3152+
where
31553153
\begin{itemize}
31563154
\item
31573155
$\mullo(\tcode{a}, \tcode{b}, \tcode{w})$ is
@@ -3164,17 +3162,11 @@
31643162
$(\left\lfloor (\tcode{a} \cdot \tcode{b}) / 2^w \right\rfloor)$,
31653163

31663164
\item
3167-
$k = 0, \dotsc, n/2 - 1$ is the index in the sequences,
3165+
$K^{(q)}_k$ is the $k^\text{th}$ round key for round $q$,
3166+
$K^{(q)}_k \cedef (K_k + (q - 1) \cdot C_k) \mod 2^w$,
31683167

31693168
\item
3170-
$q = 0, \dotsc, r - 1$ is the index of the round,
3171-
3172-
\item
3173-
$\mathit{key}^q_k$ is the $k^\text{th}$ round key for round $q$,
3174-
$\mathit{key}^q_k \cedef (K_k + q \cdot C_k) \mod 2^w$,
3175-
3176-
\item
3177-
$K_k$ are the elements of the key sequence $K$,
3169+
$K_k$ is the $k^\text{th}$ element of the key sequence $K$,
31783170

31793171
\item
31803172
$M_k$ is \tcode{multipliers[$k$]}, and
@@ -3184,10 +3176,6 @@
31843176
\end{itemize}
31853177
\end{itemize}
31863178

3187-
\pnum
3188-
After $r$ applications of the single-round function,
3189-
\tcode{Philox} returns the sequence $Y = X'$.
3190-
31913179
\indexlibraryglobal{philox_engine}%
31923180
\indexlibrarymember{result_type}{philox_engine}%
31933181
\begin{codeblock}

0 commit comments

Comments
 (0)