Ed25519PublicKey.fromBytes constructor

Ed25519PublicKey.fromBytes(
  1. List<int> bytes
)

Wraps the 32 raw key bytes.

Throws ProtocolException if bytes is not exactly 32 bytes long.

Implementation

factory Ed25519PublicKey.fromBytes(List<int> bytes) {
  if (bytes.length != 32) {
    throw ProtocolException(
      'Ed25519 public key must be 32 bytes, got ${bytes.length}',
    );
  }
  final copy = Uint8List.fromList(bytes);
  return Ed25519PublicKey._(
    copy,
    convert.base64.encode(copy).replaceAll('=', ''),
  );
}