|
3108 | 3108 | \begin{codeblock} |
3109 | 3109 | @$i$@ = @$i$@ + 1 |
3110 | 3110 | 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$ |
3113 | 3113 | @$i$@ = 0 |
3114 | 3114 | } |
3115 | 3115 | \end{codeblock} |
3116 | 3116 |
|
3117 | 3117 | \pnum |
3118 | 3118 | 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. |
3120 | 3120 | 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)}$. |
3122 | 3124 | \begin{itemize} |
3123 | 3125 | \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}. |
3132 | 3129 |
|
3133 | 3130 | \begin{floattable}{Values for the word permutation $\bm{f}_{\bm{n}}\bm{(j)}$}{rand.eng.philox.f} |
3134 | 3131 | {l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l} |
|
3146 | 3143 | \end{note} |
3147 | 3144 |
|
3148 | 3145 | \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 |
3155 | 3153 | \begin{itemize} |
3156 | 3154 | \item |
3157 | 3155 | $\mullo(\tcode{a}, \tcode{b}, \tcode{w})$ is |
|
3164 | 3162 | $(\left\lfloor (\tcode{a} \cdot \tcode{b}) / 2^w \right\rfloor)$, |
3165 | 3163 |
|
3166 | 3164 | \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$, |
3168 | 3167 |
|
3169 | 3168 | \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$, |
3178 | 3170 |
|
3179 | 3171 | \item |
3180 | 3172 | $M_k$ is \tcode{multipliers[$k$]}, and |
|
3184 | 3176 | \end{itemize} |
3185 | 3177 | \end{itemize} |
3186 | 3178 |
|
3187 | | -\pnum |
3188 | | -After $r$ applications of the single-round function, |
3189 | | -\tcode{Philox} returns the sequence $Y = X'$. |
3190 | | - |
3191 | 3179 | \indexlibraryglobal{philox_engine}% |
3192 | 3180 | \indexlibrarymember{result_type}{philox_engine}% |
3193 | 3181 | \begin{codeblock} |
|
0 commit comments