|
3106 | 3106 | \begin{codeblock} |
3107 | 3107 | @$i$@ = @$i$@ + 1 |
3108 | 3108 | if (@$i$@ == @$n$@) { |
3109 | | - @$Y$@ = Philox(@$K$@, @$X$@) // \seebelow |
3110 | | - @$Z$@ = @$Z$@ + 1 |
| 3109 | + @$Y$@ = Philox(@$K$@, @$X$@) // \seebelow |
| 3110 | + @$Z$@ = @$Z$@ + 1 // this updates $X$ |
3111 | 3111 | @$i$@ = 0 |
3112 | 3112 | } |
3113 | 3113 | \end{codeblock} |
3114 | 3114 |
|
3115 | 3115 | \pnum |
3116 | 3116 | The \tcode{Philox} function maps the length-$n/2$ sequence $K$ and |
3117 | | -the length-$n$ sequence $X$ into a length-$n$ output sequence $Y$. |
| 3117 | +the length-$n$ sequence $X$ into a length-$n$ output sequence. |
3118 | 3118 | Philox applies an $r$-round substitution-permutation network to the values in $X$. |
3119 | | -A single round of the generation algorithm performs the following steps: |
| 3119 | +That is, there are intermediate values $X^{(0)}, X^{(1)}, \dotsc, X^{(r)}$, |
| 3120 | +where $X^{(0)} \cedef X$, and for each round $q$ (with $q = 1, \dotsc, r$), |
| 3121 | +$X^{(q)}$ is computed from $X^{(q - 1)}$ as follows. The output sequence is $X^{(r)}$. |
3120 | 3122 | \begin{itemize} |
3121 | 3123 | \item |
3122 | | -The output sequence $X'$ of the previous round |
3123 | | -($X$ in case of the first round) |
3124 | | -is permuted to obtain the intermediate state $V$: |
3125 | | -\begin{codeblock} |
3126 | | -@$V_j = X'_{f_n(j)}$@ |
3127 | | -\end{codeblock} |
3128 | | -where $j = 0, \dotsc, n - 1$ and |
3129 | | -$f_n(j)$ is defined in \tref{rand.eng.philox.f}. |
| 3124 | +An intermediate state $V^{(q)}$ is obtained by permuting the previous output, |
| 3125 | +$V^{(q)}_j \cedef X^{(q - 1)}_{f_n(j)}$, |
| 3126 | +where $j = 0, \dotsc, n - 1$, and $f_n(j)$ is defined in \tref{rand.eng.philox.f}. |
3130 | 3127 |
|
3131 | 3128 | \begin{floattable}{Values for the word permutation $\bm{f}_{\bm{n}}\bm{(j)}$}{rand.eng.philox.f} |
3132 | 3129 | {l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l} |
|
3144 | 3141 | \end{note} |
3145 | 3142 |
|
3146 | 3143 | \item |
3147 | | -The following computations are applied to the elements of the $V$ sequence: |
3148 | | -\begin{codeblock} |
3149 | | -@$X_{2k + 0} = \mullo(V_{2k + 1}, M_{k}, w)$@ |
3150 | | -@$X_{2k + 1} = \mulhi(V_{2k + 1}, M_{k}, w) \xor \mathit{key}^q_k \xor V_{2k}$@ |
3151 | | -\end{codeblock} |
3152 | | -where: |
| 3144 | +The next output $X^{(q)}$ is computed from the elements of the $V^{(q)}$ as follows. |
| 3145 | +For $k = 0, \dotsc, n/2 - 1$, |
| 3146 | +\begin{itemize} |
| 3147 | +\item $X^{(q)}_{2k + 0} = \mullo(V^{(q)}_{2k + 1}, M_{k}, w)$, and |
| 3148 | +\item $X^{(q)}_{2k + 1} = \mulhi(V^{(q)}_{2k + 1}, M_{k}, w) \xor K^{(q)}_k \xor V^{(q)}_{2k}$, |
| 3149 | +\end{itemize} |
| 3150 | +where |
3153 | 3151 | \begin{itemize} |
3154 | 3152 | \item |
3155 | 3153 | $\mullo(\tcode{a}, \tcode{b}, \tcode{w})$ is |
|
3162 | 3160 | $(\left\lfloor (\tcode{a} \cdot \tcode{b}) / 2^w \right\rfloor)$, |
3163 | 3161 |
|
3164 | 3162 | \item |
3165 | | - $k = 0, \dotsc, n/2 - 1$ is the index in the sequences, |
| 3163 | + $K^{(q)}_k$ is the $k^\text{th}$ round key for round $q$, |
| 3164 | + $K^{(q)}_k \cedef (K_k + (q - 1) \cdot C_k) \mod 2^w$, |
3166 | 3165 |
|
3167 | 3166 | \item |
3168 | | - $q = 0, \dotsc, r - 1$ is the index of the round, |
3169 | | - |
3170 | | - \item |
3171 | | - $\mathit{key}^q_k$ is the $k^\text{th}$ round key for round $q$, |
3172 | | - $\mathit{key}^q_k \cedef (K_k + q \cdot C_k) \mod 2^w$, |
3173 | | - |
3174 | | - \item |
3175 | | - $K_k$ are the elements of the key sequence $K$, |
| 3167 | + $K_k$ is the $k^\text{th}$ element of the key sequence $K$, |
3176 | 3168 |
|
3177 | 3169 | \item |
3178 | 3170 | $M_k$ is \tcode{multipliers[$k$]}, and |
|
3182 | 3174 | \end{itemize} |
3183 | 3175 | \end{itemize} |
3184 | 3176 |
|
3185 | | -\pnum |
3186 | | -After $r$ applications of the single-round function, |
3187 | | -\tcode{Philox} returns the sequence $Y = X'$. |
3188 | | - |
3189 | 3177 | \indexlibraryglobal{philox_engine}% |
3190 | 3178 | \indexlibrarymember{result_type}{philox_engine}% |
3191 | 3179 | \begin{codeblock} |
|
0 commit comments