Table of Contents

Class IncrementalParallelHash

Namespace
CryptoHives.Foundation.Security.Cryptography.Hash
Assembly
CryptoHives.Foundation.Security.Cryptography.dll

Provides incremental ParallelHash computation.

public sealed class IncrementalParallelHash : IDisposable
Inheritance
IncrementalParallelHash
Implements
Inherited Members

Remarks

Absorbing is streaming: each block is fed straight into a reused inner XOF and, once full, collapsed to a chaining value that goes directly into the final cSHAKE. Nothing but the sponge states and a byte counter is retained, so the instance is O(1) in the message length.

Constructors

IncrementalParallelHash(ShakeType, int, ReadOnlySpan<byte>)

Initializes a new instance of the IncrementalParallelHash class.

public IncrementalParallelHash(IncrementalParallelHash.ShakeType type = ShakeType.Shake128, int blockSizeBytes = 1048576, ReadOnlySpan<byte> customization = default)

Parameters

type IncrementalParallelHash.ShakeType

The SHAKE variant used for the ParallelHash construction.

blockSizeBytes int

The block size in bytes.

customization ReadOnlySpan<byte>

Optional customization string S (default: empty).

Fields

DefaultBlockSizeBytes

The default block size in bytes (1 MiB).

public const int DefaultBlockSizeBytes = 1048576

Field Value

int

Methods

Absorb(ReadOnlySpan<byte>)

Absorbs data into the ParallelHash instance.

public void Absorb(ReadOnlySpan<byte> data)

Parameters

data ReadOnlySpan<byte>

The data to absorb.

Exceptions

InvalidOperationException

Thrown after the hash has been squeezed.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Reset()

Resets the instance for reuse.

public void Reset()

Squeeze(Span<byte>)

Squeezes the final hash output.

public Span<byte> Squeeze(Span<byte> output)

Parameters

output Span<byte>

The span to receive the hash value.

Returns

Span<byte>

The output span containing the hash value.

Remarks

ParallelHash encodes the requested output length into the digest, so this may be called only once per message; use Reset() to start another.

Exceptions

InvalidOperationException

Thrown when called more than once.