newSecretKeyFromBytes method

Future<SecretKey> newSecretKeyFromBytes(
  1. List<int> bytes
)
inherited

Constructs a new SecretKey from the bytes.

Throws ArgumentError if the argument length is not secretKeyLength.

Implementation

Future<SecretKey> newSecretKeyFromBytes(List<int> bytes) async {
  if (bytes.length != secretKeyLength) {
    throw ArgumentError('Invalid secret key length');
  }
  return SecretKeyData(
    Uint8List.fromList(bytes),
    overwriteWhenDestroyed: true, // We copied the bytes so overwriting is ok.
  );
}