generatePrivateKey static method

KeyPair generatePrivateKey()

generates a new private key with a secure random generator

Implementation

static KeyPair generatePrivateKey() {
  final privKey = Helpers.getSecureRandomHex(32);
  final pubKey = getPublicKey(privKey);

  final privKeyHr = Helpers.encodeBech32(privKey, 'nsec');
  final pubKeyHr = Helpers.encodeBech32(pubKey, 'npub');

  return KeyPair(privKey, pubKey, privKeyHr, pubKeyHr);
}