fromSecretBytes static method

Key fromSecretBytes({
  1. required KeyAlgorithm algorithm,
  2. required Uint8List secretKey,
})

Creates a new key instance from a slice of key secret bytes.

Throws an AskarKeyException if key creation fails.

Implementation

static Key fromSecretBytes({
  required KeyAlgorithm algorithm,
  required Uint8List secretKey,
}) {
  try {
    return Key(askarKeyFromSecretBytes(algorithm, secretKey).getValueOrException());
  } catch (e) {
    throw AskarKeyException('Failed to get key from secret bytes: $e');
  }
}