Skip to content

Commit 350e730

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 1542d98 commit 350e730

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
@@ -3100,27 +3100,24 @@
31003100
\begin{codeblock}
31013101
@$i$@ = @$i$@ + 1
31023102
if (@$i$@ == @$n$@) {
3103-
@$Y$@ = Philox(@$K$@, @$X$@) // \seebelow
3104-
@$Z$@ = @$Z$@ + 1
3103+
@$Y$@ = Philox(@$K$@, @$X$@) // \seebelow
3104+
@$Z$@ = @$Z$@ + 1 // this updates $X$
31053105
@$i$@ = 0
31063106
}
31073107
\end{codeblock}
31083108

31093109
\pnum
31103110
The \tcode{Philox} function maps the length-$n/2$ sequence $K$ and
3111-
the length-$n$ sequence $X$ into a length-$n$ output sequence $Y$.
3111+
the length-$n$ sequence $X$ into a length-$n$ output sequence.
31123112
Philox applies an $r$-round substitution-permutation network to the values in $X$.
3113-
A single round of the generation algorithm performs the following steps:
3113+
That is, there are intermediate values $X^{(0)}, X^{(1)}, \dotsc, X^{(r)}$,
3114+
where $X^{(0)} \cedef X$, and for each round $q$ (with $q = 1, \dotsc, r$),
3115+
$X^{(q)}$ is computed from $X^{(q - 1)}$ as follows. The output sequence is $X^{(r)}$.
31143116
\begin{itemize}
31153117
\item
3116-
The output sequence $X'$ of the previous round
3117-
($X$ in case of the first round)
3118-
is permuted to obtain the intermediate state $V$:
3119-
\begin{codeblock}
3120-
@$V_j = X'_{f_n(j)}$@
3121-
\end{codeblock}
3122-
where $j = 0, \dotsc, n - 1$ and
3123-
$f_n(j)$ is defined in \tref{rand.eng.philox.f}.
3118+
An intermediate state $V^{(q)}$ is obtained by permuting the previous output,
3119+
$V^{(q)}_j \cedef X^{(q - 1)}_{f_n(j)}$,
3120+
where $j = 0, \dotsc, n - 1$, and $f_n(j)$ is defined in \tref{rand.eng.philox.f}.
31243121

31253122
\begin{floattable}{Values for the word permutation $\bm{f}_{\bm{n}}\bm{(j)}$}{rand.eng.philox.f}
31263123
{l|l|l|l|l|l}
@@ -3136,12 +3133,13 @@
31363133
\end{note}
31373134

31383135
\item
3139-
The following computations are applied to the elements of the $V$ sequence:
3140-
\begin{codeblock}
3141-
@$X_{2k + 0} = \mulhi(V_{2k}, M_{k}, w) \xor \mathit{key}^q_k \xor V_{2k + 1}$@
3142-
@$X_{2k + 1} = \mullo(V_{2k}, M_{k}, w)$@
3143-
\end{codeblock}
3144-
where:
3136+
The next output $X^{(q)}$ is computed from the elements of the $V^{(q)}$ as follows.
3137+
For $k = 0, \dotsc, n/2 - 1$,
3138+
\begin{itemize}
3139+
\item $X^{(q)}_{2k + 0} = \mulhi(V_{2k}, M_{k}, w) \xor K^{(q)}_k \xor V_{2k + 1}$, and
3140+
\item $X^{(q)}_{2k + 1} = \mullo(V_{2k}, M_{k}, w)$,
3141+
\end{itemize}
3142+
where
31453143
\begin{itemize}
31463144
\item
31473145
$\mullo(\tcode{a}, \tcode{b}, \tcode{w})$ is
@@ -3154,17 +3152,11 @@
31543152
$(\left\lfloor (\tcode{a} \cdot \tcode{b}) / 2^w \right\rfloor)$,
31553153

31563154
\item
3157-
$k = 0, \dotsc, n/2 - 1$ is the index in the sequences,
3155+
$K^{(q)}_k$ is the $k^\text{th}$ round key for round $q$,
3156+
$K^{(q)}_k \cedef (K_k + (q - 1) \cdot C_k) \mod 2^w$,
31583157

31593158
\item
3160-
$q = 0, \dotsc, r - 1$ is the index of the round,
3161-
3162-
\item
3163-
$\mathit{key}^q_k$ is the $k^\text{th}$ round key for round $q$,
3164-
$\mathit{key}^q_k \cedef (K_k + q \cdot C_k) \mod 2^w$,
3165-
3166-
\item
3167-
$K_k$ are the elements of the key sequence $K$,
3159+
$K_k$ is the $k^\text{th}$ element of the key sequence $K$,
31683160

31693161
\item
31703162
$M_k$ is \tcode{multipliers[$k$]}, and
@@ -3174,10 +3166,6 @@
31743166
\end{itemize}
31753167
\end{itemize}
31763168

3177-
\pnum
3178-
After $r$ applications of the single-round function,
3179-
\tcode{Philox} returns the sequence $Y = X'$.
3180-
31813169
\indexlibraryglobal{philox_engine}%
31823170
\indexlibrarymember{result_type}{philox_engine}%
31833171
\begin{codeblock}

0 commit comments

Comments
 (0)