getPublicKey method

Future<Uint8List> getPublicKey(
  1. Uint8List privateKey, {
  2. bool withZeroByte = true,
})

Implementation

Future<Uint8List> getPublicKey(
  Uint8List privateKey, {
  bool withZeroByte = true,
}) async {
  final ed25519 = Ed25519();
  final signature = await ed25519.newKeyPairFromSeed(privateKey);
  final publicKey = await signature.extractPublicKey();

  if (withZeroByte == true) {
    final dataBytes = Uint8List(33);
    dataBytes[0] = 0x00;
    dataBytes.setRange(1, 33, publicKey.bytes);
    return dataBytes;
  } else {
    return Uint8List.fromList(publicKey.bytes);
  }
}