publicKeyBytes function

Uint8List publicKeyBytes(
  1. String hexPrivateKey,
  2. bool uncompressed
)

Computes the public key corresponding to the given private one

Implementation

Uint8List publicKeyBytes(String hexPrivateKey, bool uncompressed) {
  if (bridge.nativeDvote == null)
    throw Exception("The library is not initialized");

  final privKeyPtr = Utf8.toUtf8(hexPrivateKey.replaceAll(r"^0x", ""));

  // The actual native call
  final resultPtr = uncompressed
      ? bridge.computePublicKeyUncompressed(privKeyPtr)
      : bridge.computePublicKey(privKeyPtr);
  final result = bridge.handleResultStringPointer(resultPtr);

  // return HEX.decode(result.replaceAll(RegExp(r"^0x"), ""));
  return HEX.decode(result);
}