pub struct Keys {
pub public_key: PublicKey,
/* private fields */
}Expand description
Nostr keys
Fields§
§public_key: PublicKeyPublic key
Implementations§
Source§impl Keys
impl Keys
Sourcepub fn parse(secret_key: &str) -> Result<Keys, Error>
pub fn parse(secret_key: &str) -> Result<Keys, Error>
Parse secret key and construct keys.
Check SecretKey::parse to learn more about secret key parsing.
Sourcepub fn parse_with_ctx<C>(
secp: &Secp256k1<C>,
secret_key: &str,
) -> Result<Keys, Error>where
C: Signing,
pub fn parse_with_ctx<C>(
secp: &Secp256k1<C>,
secret_key: &str,
) -> Result<Keys, Error>where
C: Signing,
Parse secret key and construct keys.
Check SecretKey::parse to learn more about secret key parsing.
Sourcepub fn generate() -> Keys
pub fn generate() -> Keys
Generate random keys
This constructor uses a random number generator that retrieves randomness from the operating system (see OsRng).
Use Keys::generate_with_rng to specify a custom random source.
Check Keys::generate_with_ctx to learn more about how this constructor works internally.
Sourcepub fn generate_with_rng<R>(rng: &mut R) -> Keys
pub fn generate_with_rng<R>(rng: &mut R) -> Keys
Generate random keys using a custom random source
Check Keys::generate_with_ctx to learn more about how this constructor works internally.
Sourcepub fn generate_with_ctx<C, R>(secp: &Secp256k1<C>, rng: &mut R) -> Keys
pub fn generate_with_ctx<C, R>(secp: &Secp256k1<C>, rng: &mut R) -> Keys
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Get public key
Sourcepub fn secret_key(&self) -> &SecretKey
pub fn secret_key(&self) -> &SecretKey
Get secret key
Sourcepub fn sign_schnorr(&self, message: &Message) -> Signature
pub fn sign_schnorr(&self, message: &Message) -> Signature
Trait Implementations§
Source§impl NostrSigner for Keys
Available on crate feature std only.
impl NostrSigner for Keys
Available on crate feature
std only.Source§fn backend(&self) -> SignerBackend<'_>
fn backend(&self) -> SignerBackend<'_>
Signer backend
Source§fn get_public_key(
&self,
) -> Pin<Box<dyn Future<Output = Result<PublicKey, SignerError>> + Send + '_>>
fn get_public_key( &self, ) -> Pin<Box<dyn Future<Output = Result<PublicKey, SignerError>> + Send + '_>>
Get signer public key
Source§fn sign_event(
&self,
unsigned: UnsignedEvent,
) -> Pin<Box<dyn Future<Output = Result<Event, SignerError>> + Send + '_>>
fn sign_event( &self, unsigned: UnsignedEvent, ) -> Pin<Box<dyn Future<Output = Result<Event, SignerError>> + Send + '_>>
Sign an unsigned event
Source§fn nip04_encrypt<'a>(
&'a self,
_public_key: &'a PublicKey,
_content: &'a str,
) -> Pin<Box<dyn Future<Output = Result<String, SignerError>> + Send + 'a>>
fn nip04_encrypt<'a>( &'a self, _public_key: &'a PublicKey, _content: &'a str, ) -> Pin<Box<dyn Future<Output = Result<String, SignerError>> + Send + 'a>>
NIP04 encrypt (deprecate and unsecure)
Source§fn nip04_decrypt<'a>(
&'a self,
_public_key: &'a PublicKey,
_content: &'a str,
) -> Pin<Box<dyn Future<Output = Result<String, SignerError>> + Send + 'a>>
fn nip04_decrypt<'a>( &'a self, _public_key: &'a PublicKey, _content: &'a str, ) -> Pin<Box<dyn Future<Output = Result<String, SignerError>> + Send + 'a>>
NIP04 decrypt
Source§impl Ord for Keys
impl Ord for Keys
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Keys
impl PartialOrd for Keys
impl Eq for Keys
Auto Trait Implementations§
impl !Freeze for Keys
impl RefUnwindSafe for Keys
impl Send for Keys
impl Sync for Keys
impl Unpin for Keys
impl UnsafeUnpin for Keys
impl UnwindSafe for Keys
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more