Enum Identity

Source
pub enum Identity {
    None,
    Public(PublicKey),
    Private(Arc<KeySigner>),
    Remote(BunkerClient),
}
Expand description

All states that your identity can be in

Variants§

§

None

No identity information

§

Public(PublicKey)

Public key only

§

Private(Arc<KeySigner>)

Private key

§

Remote(BunkerClient)

Remote Signer (Bunker)

Implementations§

Source§

impl Identity

Source

pub fn from_public_key(pk: PublicKey) -> Self

New Identity from a public key

Source

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

New Identity from a private key

Source

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

New Identity from an encrypted private key and a public key

Source

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

New Identity from an encrypted private key and its password

Source

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

Generate a new Identity

Source

pub fn inner_key_signer(&self) -> Option<Arc<KeySigner>>

Get access to the inner KeySigner

Source

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

Unlock

Source

pub fn lock(&self)

Lock access to the private key

Source

pub fn has_public_key(&self) -> bool

Has a public key

Source

pub fn has_private_key(&self) -> bool

Has a private key

Source

pub fn is_locked(&self) -> bool

Is the identity locked?

Source

pub fn is_unlocked(&self) -> bool

Is the identity unlocked?

Source

pub fn can_sign_if_unlocked(&self) -> bool

Can sign if unlocked

Source

pub 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

pub fn public_key(&self) -> Option<PublicKey>

What is the public key?

Source

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

What is the signer’s encrypted private key?

Source

pub async fn sign_id(&self, id: Id) -> Result<Signature, Error>

Sign a 32-bit hash

Source

pub async fn sign(&self, message: &[u8]) -> Result<Signature, Error>

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

Source

pub async fn encrypt( &self, other: &PublicKey, plaintext: &str, algo: ContentEncryptionAlgorithm, ) -> Result<String, Error>

Encrypt

Source

pub async fn decrypt( &self, other: &PublicKey, ciphertext: &str, ) -> Result<String, Error>

Decrypt

Source

pub async fn nip44_conversation_key( &self, other: &PublicKey, ) -> Result<[u8; 32], Error>

Get NIP-44 conversation key

Source

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

Get the security level of the private key

Source

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

Upgrade the encrypted private key to the latest format

Source

pub async fn create_metadata_event( &self, input: PreEvent, metadata: Metadata, ) -> Result<Event, Error>

Create an event that sets Metadata

Source

pub async fn create_zap_request_event( &self, recipient_pubkey: PublicKey, zapped_event: Option<Id>, millisatoshis: u64, relays: Vec<String>, content: String, ) -> Result<Event, Error>

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

Source

pub async fn decrypt_event_contents( &self, event: &Event, ) -> Result<String, Error>

Decrypt the contents of an event

Source

pub async fn unwrap_giftwrap(&self, event: &Event) -> Result<Rumor, Error>

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

Source

pub async fn generate_delegation_signature( &self, delegated_pubkey: PublicKey, delegation_conditions: &DelegationConditions, ) -> Result<Signature, Error>

Generate delegation signature

Source

pub async fn giftwrap( &self, input: PreEvent, pubkey: PublicKey, ) -> Result<Event, Error>

Giftwrap an event

Source

pub async fn sign_event(&self, input: PreEvent) -> Result<Event, Error>

Sign an event

Source

pub async fn sign_event_with_pow( &self, input: PreEvent, zero_bits: u8, work_sender: Option<Sender<u8>>, ) -> Result<Event, Error>

Sign an event with Proof-of-Work

Source

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

Verify delegation signature

Trait Implementations§

Source§

impl Debug for Identity

Source§

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

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

impl Default for Identity

Source§

fn default() -> Identity

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Identity

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 Serialize for Identity

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 Send for Identity

Source§

impl Sync for Identity

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