decodeNsecKeyToPrivateKey method

String decodeNsecKeyToPrivateKey(
  1. String nsecKey
)

Decodes a Nostr nsecKey to a private key.

final privateKey = Nostr.instance.services.keys.decodeNsecKeyToPrivateKey(yourNsecKey);
print(privateKey); // ...

Implementation

String decodeNsecKeyToPrivateKey(String nsecKey) {
  assert(nsecKey.startsWith(NostrConstants.nsec));
  final decodedKeyComponents = decodeBech32(nsecKey);

  return decodedKeyComponents.first;
}