restoreState method

  1. @override
BLAKE2b restoreState(
  1. Blake2bState savedState
)
override

Restores the hash state to a previously saved state object.

This method restores the internal state of the BLAKE2b hash function to a previously saved state, including the state vector, buffer, buffer length, counters, flags, and whether it represents the last node in a tree.

Parameters:

  • savedState: The saved hash state to restore.

Returns: The BLAKE2b instance with the state restored to that of the saved state.

Implementation

@override
BLAKE2b restoreState(Blake2bState savedState) {
  _state.setAll(0, savedState.state);
  _buffer.setAll(0, savedState.buffer);
  _bufferLength = savedState.bufferLength;
  _ctr.setAll(0, savedState.ctr);
  _flag.setAll(0, savedState.flag);
  _lastNode = savedState.lastNode;

  if (_paddedKey != null) {
    zero(_paddedKey!);
  }

  _paddedKey = savedState.paddedKey != null
      ? List<int>.from(savedState.paddedKey!)
      : null;

  _initialState.setAll(0, savedState.initialState);

  return this;
}