getPublicKey function

Uint8List getPublicKey(
  1. Uint8List privateKey, [
  2. bool withZeroByte = true
])

Implementation

Uint8List getPublicKey(Uint8List privateKey, [bool withZeroByte = true]) {
  final keyPair = ed25519.newKeyFromSeed(privateKey);
  final signPk = Uint8List.fromList(keyPair.bytes.sublist(32));
  if (!withZeroByte) return signPk;
  final zero = Uint8List.fromList([0]);
  final data = Uint8List(zero.lengthInBytes + signPk.lengthInBytes);
  data.addAll(zero);
  data.addAll(signPk);
  return data;
}