Struct KeySigner

Source
pub struct KeySigner { /* private fields */ }
Expand description

Signer with a local private key (and public key)

Implementations§

Source§

impl KeySigner

Source

pub fn from_locked_parts(epk: EncryptedPrivateKey, pk: PublicKey) -> Self

Create a Signer from an EncryptedPrivateKey

Source

pub fn from_private_key( privk: PrivateKey, password: &str, log_n: u8, ) -> Result<Self, Error>

Create a Signer from a PrivateKey

Source

pub fn from_encrypted_private_key( epk: EncryptedPrivateKey, pass: &str, ) -> Result<Self, Error>

Create a Signer from an EncryptedPrivateKey and a password to unlock it

Source

pub fn generate(password: &str, log_n: u8) -> Result<Self, Error>

Create a Signer by generating a new PrivateKey

Trait Implementations§

Source§

impl Debug for KeySigner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for KeySigner

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl ExportableSigner for KeySigner

Source§

fn export_private_key_in_hex<'life0, 'life1, 'async_trait>( &'life0 self, pass: &'life1 str, log_n: u8, ) -> Pin<Box<dyn Future<Output = Result<(String, bool), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Export the private key in hex. Read more
Source§

fn export_private_key_in_bech32<'life0, 'life1, 'async_trait>( &'life0 self, pass: &'life1 str, log_n: u8, ) -> Pin<Box<dyn Future<Output = Result<(String, bool), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Export the private key in bech32. Read more
Source§

impl LockableSigner for KeySigner

Source§

fn is_locked(&self) -> bool

Is the signer locked?
Source§

fn unlock(&self, password: &str) -> Result<(), Error>

Try to unlock access to the private key
Source§

fn lock(&self)

Lock access to the private key
Source§

fn change_passphrase( &self, old: &str, new: &str, log_n: u8, ) -> Result<(), Error>

Change the passphrase used for locking access to the private key
Source§

fn upgrade(&self, pass: &str, log_n: u8) -> Result<(), Error>

Upgrade the encrypted private key to the latest format
Source§

impl Serialize for KeySigner

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Signer for KeySigner

Source§

fn public_key(&self) -> PublicKey

What is the signer’s public key?
Source§

fn encrypted_private_key(&self) -> Option<EncryptedPrivateKey>

What is the signer’s encrypted private key?
Source§

fn sign_event<'life0, 'async_trait>( &'life0 self, input: PreEvent, ) -> Pin<Box<dyn Future<Output = Result<Event, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sign an event
Source§

fn encrypt<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, other: &'life1 PublicKey, plaintext: &'life2 str, algo: ContentEncryptionAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Encrypt
Source§

fn decrypt<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, other: &'life1 PublicKey, ciphertext: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Decrypt NIP-04 or NIP-44
Source§

fn key_security(&self) -> Result<KeySecurity, Error>

Get the security level of the private key
Source§

fn giftwrap<'life0, 'async_trait>( &'life0 self, input: PreEvent, pubkey: PublicKey, ) -> Pin<Box<dyn Future<Output = Result<Event, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Giftwrap an event
Source§

fn create_metadata_event<'life0, 'async_trait>( &'life0 self, input: PreEvent, metadata: Metadata, ) -> Pin<Box<dyn Future<Output = Result<Event, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create an event that sets Metadata
Source§

fn create_zap_request_event<'life0, 'async_trait>( &'life0 self, recipient_pubkey: PublicKey, zapped_event: Option<Id>, millisatoshis: u64, relays: Vec<String>, content: String, ) -> Pin<Box<dyn Future<Output = Result<Event, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a ZapRequest event These events are not published to nostr, they are sent to a lnurl.
Source§

fn decrypt_event_contents<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 Event, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Decrypt the contents of an event
Source§

fn unwrap_giftwrap<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 Event, ) -> Pin<Box<dyn Future<Output = Result<Rumor, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

If a gift wrap event, unwrap and return the inner Rumor
Source§

impl SignerExt for KeySigner

Source§

fn sign_id<'life0, 'async_trait>( &'life0 self, id: Id, ) -> Pin<Box<dyn Future<Output = Result<Signature, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sign a 32-bit hash asynchronously
Source§

fn sign<'life0, 'life1, 'async_trait>( &'life0 self, message: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<Signature, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Sign a message asynchronously (this hashes with SHA-256 first internally)
Source§

fn nip44_conversation_key<'life0, 'life1, 'async_trait>( &'life0 self, other: &'life1 PublicKey, ) -> Pin<Box<dyn Future<Output = Result<[u8; 32], Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get NIP-44 conversation key
Source§

fn generate_delegation_signature<'life0, 'life1, 'async_trait>( &'life0 self, delegated_pubkey: PublicKey, delegation_conditions: &'life1 DelegationConditions, ) -> Pin<Box<dyn Future<Output = Result<Signature, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generate delegation signature
Source§

fn verify_delegation_signature( &self, delegated_pubkey: PublicKey, delegation_conditions: &DelegationConditions, signature: &Signature, ) -> Result<(), Error>

Verify delegation signature
Source§

fn sign_event_with_pow<'life0, 'async_trait>( &'life0 self, input: PreEvent, zero_bits: u8, work_sender: Option<Sender<u8>>, ) -> Pin<Box<dyn Future<Output = Result<Event, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Sign an event with Proof-of-Work

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T