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
impl Identity
Sourcepub fn from_public_key(pk: PublicKey) -> Self
pub fn from_public_key(pk: PublicKey) -> Self
New Identity
from a public key
Sourcepub fn from_private_key(
pk: PrivateKey,
pass: &str,
log_n: u8,
) -> Result<Self, Error>
pub fn from_private_key( pk: PrivateKey, pass: &str, log_n: u8, ) -> Result<Self, Error>
New Identity
from a private key
Sourcepub fn from_locked_parts(pk: PublicKey, epk: EncryptedPrivateKey) -> Self
pub fn from_locked_parts(pk: PublicKey, epk: EncryptedPrivateKey) -> Self
New Identity
from an encrypted private key and a public key
Sourcepub fn from_encrypted_private_key(
epk: EncryptedPrivateKey,
pass: &str,
) -> Result<Self, Error>
pub fn from_encrypted_private_key( epk: EncryptedPrivateKey, pass: &str, ) -> Result<Self, Error>
New Identity
from an encrypted private key and its password
Sourcepub fn inner_key_signer(&self) -> Option<Arc<KeySigner>>
pub fn inner_key_signer(&self) -> Option<Arc<KeySigner>>
Get access to the inner KeySigner
Sourcepub fn has_public_key(&self) -> bool
pub fn has_public_key(&self) -> bool
Has a public key
Sourcepub fn has_private_key(&self) -> bool
pub fn has_private_key(&self) -> bool
Has a private key
Sourcepub fn is_unlocked(&self) -> bool
pub fn is_unlocked(&self) -> bool
Is the identity unlocked?
Sourcepub fn can_sign_if_unlocked(&self) -> bool
pub fn can_sign_if_unlocked(&self) -> bool
Can sign if unlocked
Sourcepub fn change_passphrase(
&self,
old: &str,
new: &str,
log_n: u8,
) -> Result<(), Error>
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
Sourcepub fn public_key(&self) -> Option<PublicKey>
pub fn public_key(&self) -> Option<PublicKey>
What is the public key?
Sourcepub fn encrypted_private_key(&self) -> Option<EncryptedPrivateKey>
pub fn encrypted_private_key(&self) -> Option<EncryptedPrivateKey>
What is the signer’s encrypted private key?
Sourcepub async fn sign(&self, message: &[u8]) -> Result<Signature, Error>
pub async fn sign(&self, message: &[u8]) -> Result<Signature, Error>
Sign a message (this hashes with SHA-256 first internally)
Sourcepub async fn encrypt(
&self,
other: &PublicKey,
plaintext: &str,
algo: ContentEncryptionAlgorithm,
) -> Result<String, Error>
pub async fn encrypt( &self, other: &PublicKey, plaintext: &str, algo: ContentEncryptionAlgorithm, ) -> Result<String, Error>
Encrypt
Sourcepub async fn decrypt(
&self,
other: &PublicKey,
ciphertext: &str,
) -> Result<String, Error>
pub async fn decrypt( &self, other: &PublicKey, ciphertext: &str, ) -> Result<String, Error>
Decrypt
Sourcepub async fn nip44_conversation_key(
&self,
other: &PublicKey,
) -> Result<[u8; 32], Error>
pub async fn nip44_conversation_key( &self, other: &PublicKey, ) -> Result<[u8; 32], Error>
Get NIP-44 conversation key
Sourcepub fn key_security(&self) -> Result<KeySecurity, Error>
pub fn key_security(&self) -> Result<KeySecurity, Error>
Get the security level of the private key
Sourcepub fn upgrade(&self, pass: &str, log_n: u8) -> Result<(), Error>
pub fn upgrade(&self, pass: &str, log_n: u8) -> Result<(), Error>
Upgrade the encrypted private key to the latest format
Sourcepub async fn create_metadata_event(
&self,
input: PreEvent,
metadata: Metadata,
) -> Result<Event, Error>
pub async fn create_metadata_event( &self, input: PreEvent, metadata: Metadata, ) -> Result<Event, Error>
Create an event that sets Metadata
Sourcepub async fn create_zap_request_event(
&self,
recipient_pubkey: PublicKey,
zapped_event: Option<Id>,
millisatoshis: u64,
relays: Vec<String>,
content: String,
) -> Result<Event, Error>
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.
Sourcepub async fn decrypt_event_contents(
&self,
event: &Event,
) -> Result<String, Error>
pub async fn decrypt_event_contents( &self, event: &Event, ) -> Result<String, Error>
Decrypt the contents of an event
Sourcepub async fn unwrap_giftwrap(&self, event: &Event) -> Result<Rumor, Error>
pub async fn unwrap_giftwrap(&self, event: &Event) -> Result<Rumor, Error>
If a gift wrap event, unwrap and return the inner Rumor
Sourcepub async fn generate_delegation_signature(
&self,
delegated_pubkey: PublicKey,
delegation_conditions: &DelegationConditions,
) -> Result<Signature, Error>
pub async fn generate_delegation_signature( &self, delegated_pubkey: PublicKey, delegation_conditions: &DelegationConditions, ) -> Result<Signature, Error>
Generate delegation signature
Sourcepub async fn giftwrap(
&self,
input: PreEvent,
pubkey: PublicKey,
) -> Result<Event, Error>
pub async fn giftwrap( &self, input: PreEvent, pubkey: PublicKey, ) -> Result<Event, Error>
Giftwrap an event
Sourcepub async fn sign_event_with_pow(
&self,
input: PreEvent,
zero_bits: u8,
work_sender: Option<Sender<u8>>,
) -> Result<Event, Error>
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
Sourcepub fn verify_delegation_signature(
&self,
delegated_pubkey: PublicKey,
delegation_conditions: &DelegationConditions,
signature: &Signature,
) -> Result<(), Error>
pub fn verify_delegation_signature( &self, delegated_pubkey: PublicKey, delegation_conditions: &DelegationConditions, signature: &Signature, ) -> Result<(), Error>
Verify delegation signature