ChaChaEngine.Seed Method

Definition

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

Overload List

Seed(ReadOnlySpan<UInt32>) Directly sets the ChaCha key with counter/nonce initialized to zero.
Seed(SeedSequence) Initializes the engine state from a seed sequence.
Seed(ReadOnlySpan<UInt32>, ReadOnlySpan<UInt32>) Directly sets the ChaCha key and nonce.

Seed(ReadOnlySpan<UInt32>)

Directly sets the ChaCha key with counter/nonce initialized to zero.
C#
public void Seed(
	ReadOnlySpan<uint> key
)

Parameters

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

Remarks

This is an author-defined seeding routine for ChaCha that sets the key and initializes the counter to zero. Generates the initial block after setting state.

Exceptions

ArgumentExceptionThrown when key length is incorrect.

Seed(SeedSequence)

Initializes the engine state from a seed sequence.
C#
public void Seed(
	SeedSequence seed
)

Parameters

seed  SeedSequence
The seed sequence providing entropy.

Implements

IRandomEngine.Seed(SeedSequence)

Exceptions

ArgumentNullExceptionThrown when seed is null.

Seed(ReadOnlySpan<UInt32>, ReadOnlySpan<UInt32>)

Directly sets the ChaCha key and nonce.
C#
public void Seed(
	ReadOnlySpan<uint> key,
	ReadOnlySpan<uint> nonce
)

Parameters

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

Remarks

This is the author-defined seeding routine for ChaCha that directly sets the key and nonce. The nonce interpretation depends on the ChaCha variant:

  • For IETF ChaCha20 (96-bit nonce): nonce should be 3 × uint (counter starts at counter[0])
  • For original ChaCha (64-bit nonce): nonce should be 2 × uint (counter is counter[0..1])
  • For full counter mode: use 4-word nonce to set entire counter state

This implementation accepts a 4-word nonce/counter array and sets it directly as the counter state. Generates the initial block after setting state.

Exceptions

ArgumentExceptionThrown when key or nonce length is incorrect.

See Also