unmarshal static method

Future<PrivateKey> unmarshal(
  1. Uint8List bytes
)

Creates an Ed25519PrivateKey from its protobuf bytes

Implementation

static Future<PrivateKey> unmarshal(Uint8List bytes) async {

  final pbKey = pb.PrivateKey.fromBuffer(bytes);

  if (pbKey.type != pb.KeyType.Ed25519) {
    throw FormatException('Not an Ed25519 private key');
  }

  final kp = await generateEd25519KeyPairFromSeed(Uint8List.fromList(pbKey.data));

  return await Ed25519PrivateKey.create(kp as crypto.SimpleKeyPair);

}