Skip to content

Commit af6d041

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 6fc1650 commit af6d041

1 file changed

Lines changed: 19 additions & 31 deletions

File tree

source/numerics.tex

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,27 +3186,24 @@
31863186
\begin{codeblock}
31873187
@$i$@ = @$i$@ + 1
31883188
if (@$i$@ == @$n$@) {
3189-
@$Y$@ = Philox(@$K$@, @$X$@) // \seebelow
3190-
@$Z$@ = @$Z$@ + 1
3189+
@$Y$@ = Philox(@$K$@, @$X$@) // \seebelow
3190+
@$Z$@ = @$Z$@ + 1 // this updates $X$
31913191
@$i$@ = 0
31923192
}
31933193
\end{codeblock}
31943194

31953195
\pnum
31963196
The \tcode{Philox} function maps the length-$n/2$ sequence $K$ and
3197-
the length-$n$ sequence $X$ into a length-$n$ output sequence $Y$.
3197+
the length-$n$ sequence $X$ into a length-$n$ output sequence.
31983198
Philox applies an $r$-round substitution-permutation network to the values in $X$.
3199-
A single round of the generation algorithm performs the following steps:
3199+
That is, there are intermediate values $X^{(0)}, X^{(1)}, \dotsc, X^{(r)}$,
3200+
where $X^{(0)} \cedef X$, and for each round $q$ (with $q = 1, \dotsc, r$),
3201+
$X^{(q)}$ is computed from $X^{(q - 1)}$ as follows. The output sequence is $X^{(r)}$.
32003202
\begin{itemize}
32013203
\item
3202-
The output sequence $X'$ of the previous round
3203-
($X$ in case of the first round)
3204-
is permuted to obtain the intermediate state $V$:
3205-
\begin{codeblock}
3206-
@$V_j = X'_{f_n(j)}$@
3207-
\end{codeblock}
3208-
where $j = 0, \dotsc, n - 1$ and
3209-
$f_n(j)$ is defined in \tref{rand.eng.philox.f}.
3204+
An intermediate state $V^{(q)}$ is obtained by permuting the previous output,
3205+
$V^{(q)}_j \cedef X^{(q - 1)}_{f_n(j)}$,
3206+
where $j = 0, \dotsc, n - 1$, and $f_n(j)$ is defined in \tref{rand.eng.philox.f}.
32103207

32113208
\begin{floattable}{Values for the word permutation $\bm{f}_{\bm{n}}\bm{(j)}$}{rand.eng.philox.f}
32123209
{l|l|l|l|l|l}
@@ -3222,12 +3219,13 @@
32223219
\end{note}
32233220

32243221
\item
3225-
The following computations are applied to the elements of the $V$ sequence:
3226-
\begin{codeblock}
3227-
@$X_{2k + 0} = \mulhi(V_{2k}, M_{k}, w) \xor \mathit{key}^q_k \xor V_{2k + 1}$@
3228-
@$X_{2k + 1} = \mullo(V_{2k}, M_{k}, w)$@
3229-
\end{codeblock}
3230-
where:
3222+
The next output $X^{(q)}$ is computed from the elements of the $V^{(q)}$ as follows.
3223+
For $k = 0, \dotsc, n/2 - 1$,
3224+
\begin{itemize}
3225+
\item $X^{(q)}_{2k + 0} = \mulhi(V^{(q)}_{2k}, M_{k}, w) \xor K^{(q)}_k \xor V^{(q)}_{2k + 1}$, and
3226+
\item $X^{(q)}_{2k + 1} = \mullo(V^{(q)}_{2k}, M_{k}, w)$,
3227+
\end{itemize}
3228+
where
32313229
\begin{itemize}
32323230
\item
32333231
$\mullo(\tcode{a}, \tcode{b}, \tcode{w})$ is
@@ -3240,17 +3238,11 @@
32403238
$(\left\lfloor (\tcode{a} \cdot \tcode{b}) / 2^w \right\rfloor)$,
32413239

32423240
\item
3243-
$k = 0, \dotsc, n/2 - 1$ is the index in the sequences,
3241+
$K^{(q)}_k$ is the $k^\text{th}$ round key for round $q$,
3242+
$K^{(q)}_k \cedef (K_k + (q - 1) \cdot C_k) \mod 2^w$,
32443243

32453244
\item
3246-
$q = 0, \dotsc, r - 1$ is the index of the round,
3247-
3248-
\item
3249-
$\mathit{key}^q_k$ is the $k^\text{th}$ round key for round $q$,
3250-
$\mathit{key}^q_k \cedef (K_k + q \cdot C_k) \mod 2^w$,
3251-
3252-
\item
3253-
$K_k$ are the elements of the key sequence $K$,
3245+
$K_k$ is the $k^\text{th}$ element of the key sequence $K$,
32543246

32553247
\item
32563248
$M_k$ is \tcode{multipliers[$k$]}, and
@@ -3260,10 +3252,6 @@
32603252
\end{itemize}
32613253
\end{itemize}
32623254

3263-
\pnum
3264-
After $r$ applications of the single-round function,
3265-
\tcode{Philox} returns the sequence $Y = X'$.
3266-
32673255
\indexlibraryglobal{philox_engine}%
32683256
\indexlibrarymember{result_type}{philox_engine}%
32693257
\begin{codeblock}

0 commit comments

Comments
 (0)