|
3186 | 3186 | \begin{codeblock} |
3187 | 3187 | @$i$@ = @$i$@ + 1 |
3188 | 3188 | 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$ |
3191 | 3191 | @$i$@ = 0 |
3192 | 3192 | } |
3193 | 3193 | \end{codeblock} |
3194 | 3194 |
|
3195 | 3195 | \pnum |
3196 | 3196 | 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. |
3198 | 3198 | 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)}$. |
3200 | 3202 | \begin{itemize} |
3201 | 3203 | \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}. |
3210 | 3207 |
|
3211 | 3208 | \begin{floattable}{Values for the word permutation $\bm{f}_{\bm{n}}\bm{(j)}$}{rand.eng.philox.f} |
3212 | 3209 | {l|l|l|l|l|l} |
|
3222 | 3219 | \end{note} |
3223 | 3220 |
|
3224 | 3221 | \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 |
3231 | 3229 | \begin{itemize} |
3232 | 3230 | \item |
3233 | 3231 | $\mullo(\tcode{a}, \tcode{b}, \tcode{w})$ is |
|
3240 | 3238 | $(\left\lfloor (\tcode{a} \cdot \tcode{b}) / 2^w \right\rfloor)$, |
3241 | 3239 |
|
3242 | 3240 | \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$, |
3244 | 3243 |
|
3245 | 3244 | \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$, |
3254 | 3246 |
|
3255 | 3247 | \item |
3256 | 3248 | $M_k$ is \tcode{multipliers[$k$]}, and |
|
3260 | 3252 | \end{itemize} |
3261 | 3253 | \end{itemize} |
3262 | 3254 |
|
3263 | | -\pnum |
3264 | | -After $r$ applications of the single-round function, |
3265 | | -\tcode{Philox} returns the sequence $Y = X'$. |
3266 | | - |
3267 | 3255 | \indexlibraryglobal{philox_engine}% |
3268 | 3256 | \indexlibrarymember{result_type}{philox_engine}% |
3269 | 3257 | \begin{codeblock} |
|
0 commit comments