privateKeyToPublic function

String privateKeyToPublic(
  1. Uint8List privateKey
)

Generates a public key for the given private key using the ecdsa curve which Ethereum uses.

Implementation

String privateKeyToPublic(Uint8List privateKey) {
  BigInt privateKeyNum = numbers.bytesToInt(privateKey);

  ECPoint p = (params.G * privateKeyNum)!;
  Uint8List result = p.getEncoded(true);

  return numbers.bytesToHex(result);
}