Nostr constructor

Nostr({
  1. String privateKey = '',
  2. int powDifficulty = 0,
  3. bool disableSignatureVerification = false,
})

Creates a Nostr client.

privateKey is the user's secret key used for signing event messages and must be a 32-byte hexadecimal string otherwise it will be ignored. If it is not provided the client will be unable to publish events and attempts to do so will throw an exception. However, the secret key can be provided after client creation using Nostr.privateKey.

powDifficulty specifies the target of proof-of-work difficulty that will be performed before publishing events. If powDifficulty is not provided proof-of-work is not performed.

disableSignatureVerification disables signature verification of received events when set to true. WARNING: By enabling this setting you will have no proof that received events have been created by who they say they are. This option is a temporary work-around until performance of signature verification is improved. By default signature verification is performed. If signature verification is disabled you can still verify the signature of individual events on a case-by-case basis with Event.isValid.

Example:

final nostr = Nostr(privateKey: "91cf9..4e5ca", powDifficulty: 16);

Implementation

Nostr(
    {String privateKey = '',
    this.powDifficulty = 0,
    this.disableSignatureVerification = false})
    : _privateKey = privateKey {
  _publicKey = privateKey.isNotEmpty ? getPublicKey(privateKey) : '';
  pool =
      RelayPool(disableSignatureVerification: disableSignatureVerification);
}