getPublicKey function

String getPublicKey(
  1. String privateKey
)

Produces the public key from a private key

Takes privateKey, a 32-bytes hex-encoded string, i.e. 64 characters. Returns a public key as also 32-bytes hex-encoded.

Implementation

String getPublicKey(String privateKey) {
  final d0 = BigInt.parse(privateKey, radix: 16);
  ECPoint P = (secp256k1.G * d0)!;
  return P.x!.toBigInteger()!.toRadixString(16).padLeft(64, "0");
}