Cha Cha Engine.Generate Block Method
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
Overload List
| Generate | Computes the output block for the current key and counter. |
| Generate | Generates the ChaCha stream block for a 16-word (512-bit) state. |
GenerateBlock
Remarks
This method applies the algorithm-specific permutation function (e.g., Philox rounds, Threefry rounds, ChaCha quarter-rounds) to compute the output block for the current key/counter combination. The generated block is stored in engine-owned storage and can be accessed via the engine's Output(Int32) method.
This method does not advance the counter. It materializes the cached block for the current coordinates, bringing the engine from an inconsistent state to a consistent state.
After calling GenerateBlock(), the engine is in a consistent state and output methods may be safely invoked.
GenerateBlock(ReadOnlySpan<UInt32>, Int32, Span<UInt32>)
public static void GenerateBlock(
ReadOnlySpan<uint> state,
int rounds,
Span<uint> block
)Parameters
- state ReadOnlySpan<UInt32>
- The 16-word state to permute. Must have exactly 16 elements.
- rounds Int32
- The number of rounds to apply (must be 8, 12, or 20).
- block Span<UInt32>
- On return, the 16-word block.
Remarks
This method performs the ChaCha permutation in-place on the provided state. The state is modified directly and represents the output after the specified number of rounds.
Note: This method performs the permutation step and adds the original state.
Exceptions
| Argument | Thrown when state length is not 16 or rounds is not 8, 12, or 20. |