NostrKeys class
This class is responsible for generating key pairs and deriving public keys from private keys..
- Implemented types
Constructors
- NostrKeys({required NostrClientUtils utils})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- utils → NostrClientUtils
-
General utils to be used in a whole Nostr instance.
final
Methods
-
decodeNpubKeyToPublicKey(
String npubKey) → String -
Decodes a Nostr
npubKey
to a public key.override -
decodeNsecKeyToPrivateKey(
String nsecKey) → String -
Decodes a Nostr
nsecKey
to a private key.override -
derivePublicKey(
{required String privateKey}) → String -
Derives a public key from a
privateKey
directly, use this if you want a quick way to get a public key from a private key.override -
encodePrivateKeyToNsec(
String privateKey) → String -
Encodes a Nostr
privateKey
to an nsec key (bech32 encoding).override -
encodePublicKeyToNpub(
String publicKey) → String -
Encodes a Nostr
publicKey
to an npub key (bech32 encoding).override -
freeAllResources(
) → bool - Clears all the cached key pairs.
-
generateKeyPair(
) → NostrKeyPairs -
You can use this method to generate a key pair for your end users.
override
-
generateKeyPairFromExistingPrivateKey(
String privateKey) → NostrKeyPairs -
Generates a key pair from an existing
privateKey
, use this if you want to generate a key pair from an existing private key.override -
generatePrivateKey(
) → String -
You can use this method to generate a key pair for your end users.
it returns the private key of the generated key pair.
override
-
isValidPrivateKey(
String key) → bool -
Weither the
key
is a valid Nostr private key or not.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sign(
{required String privateKey, required String message}) → String -
You can use this method to sign a
message
with aprivateKey
.override -
toString(
) → String -
A string representation of this object.
inherited
-
verify(
{required String publicKey, required String message, required String signature}) → bool -
You can use this method to verify a
message
with apublicKey
and it'ssignature
. it returns a bool that indicates if themessage
is verified or not.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getPrivateKeyFromMnemonic(
String mnemonic) → String -
Derives a private key from a
mnemonic
directly, use this if you want a quick way to get a private key from a mnemonic. -
isMnemonicValid(
String text) → bool -
Wether the given
text
is a valid mnemonic or not.