privateKeyBytes function

Uint8List privateKeyBytes(
  1. String mnemonic,
  2. [String hdPath = DEFAULT_HD_PATH]
)

Computes the private key derived from the given seed phrase and HD path

Implementation

Uint8List privateKeyBytes(String mnemonic, [String hdPath = DEFAULT_HD_PATH]) {
  if (bridge.nativeDvote == null)
    throw Exception("The library is not initialized");

  final mnemonicPtr = Utf8.toUtf8(mnemonic);
  final hdPathPtr = Utf8.toUtf8(hdPath ?? "");

  // The actual native call
  final resultPtr = bridge.computePrivateKey(mnemonicPtr, hdPathPtr);
  final result = bridge.handleResultStringPointer(resultPtr);

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