fromPublicBytes static method

Key fromPublicBytes({
  1. required KeyAlgorithm algorithm,
  2. required Uint8List publicKey,
})

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

Throws an AskarKeyException if key creation fails.

Implementation

static Key fromPublicBytes({
  required KeyAlgorithm algorithm,
  required Uint8List publicKey,
}) {
  try {
    return Key(askarKeyFromPublicBytes(algorithm, publicKey).getValueOrException());
  } catch (e) {
    throw AskarKeyException('Failed to get key from public bytes: $e');
  }
}