ChaCha.FromKey Method

Definition

Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0

Overload List

FromKey(ReadOnlySpan<UInt32>) Creates a new ChaCha instance with the specified key and nonce/counter initialized to zero.
FromKey(ReadOnlySpan<UInt32>, ReadOnlySpan<UInt32>) Creates a new ChaCha instance with the specified key and nonce.

FromKey(ReadOnlySpan<UInt32>)

Creates a new ChaCha instance with the specified key and nonce/counter initialized to zero.
C#
public static ChaCha FromKey(
	ReadOnlySpan<uint> key
)

Parameters

key  ReadOnlySpan<UInt32>
The 256-bit key (8 × 32-bit words).

Return Value

ChaCha
A new ChaCha instance with the specified key and zero nonce/counter.

Remarks

This factory method directly sets the ChaCha key and initializes the nonce/counter to zero, providing direct access to the counter-based RNG's key/nonce interface.

Exceptions

ArgumentExceptionThrown when key length is not exactly 8.

FromKey(ReadOnlySpan<UInt32>, ReadOnlySpan<UInt32>)

Creates a new ChaCha instance with the specified key and nonce.
C#
public static ChaCha FromKey(
	ReadOnlySpan<uint> key,
	ReadOnlySpan<uint> nonce
)

Parameters

key  ReadOnlySpan<UInt32>
The 256-bit key (8 × 32-bit words).
nonce  ReadOnlySpan<UInt32>
The nonce (2, 3, or 4 × 32-bit words depending on ChaCha variant).

Return Value

ChaCha
A new ChaCha instance with the specified key and nonce.

Remarks

This factory method directly sets the ChaCha key and nonce, providing direct access to the counter-based RNG's key/nonce interface.

Exceptions

ArgumentExceptionThrown when key or nonce length is incorrect.

See Also