pub struct LocalIdentity { /* private fields */ }Expand description
A locally held secret-key capability.
Secret bytes are parsed once and then owned by the upstream secret-bearing
key type, whose destructor performs best-effort erasure. Debug never
exposes secret material.
Implementations§
Source§impl LocalIdentity
impl LocalIdentity
Sourcepub fn create_user_metadata(
&self,
created_at: u64,
name: Option<String>,
display_name: Option<String>,
about: Option<String>,
picture: Option<String>,
website: Option<String>,
banner: Option<String>,
bot: Option<bool>,
unknown_json: &str,
) -> Result<UserMetadataView, SoftchatError>
pub fn create_user_metadata( &self, created_at: u64, name: Option<String>, display_name: Option<String>, about: Option<String>, picture: Option<String>, website: Option<String>, banner: Option<String>, bot: Option<bool>, unknown_json: &str, ) -> Result<UserMetadataView, SoftchatError>
Create canonical private kind-0 user metadata.
Unknown fields are supplied as a JSON object and retained unless they collide with the seven known fields.
§Errors
Returns SoftchatError::InvalidUserMetadata for malformed values.
Sourcepub fn create_follow_list(
&self,
created_at: u64,
contacts: Vec<Contact>,
) -> Result<FollowListView, SoftchatError>
pub fn create_follow_list( &self, created_at: u64, contacts: Vec<Contact>, ) -> Result<FollowListView, SoftchatError>
Create a canonical private author-copy kind-3 contact backup.
§Errors
Returns SoftchatError::InvalidContactList for duplicate contacts,
malformed relay hints, or excessive list size.
Sourcepub fn create_application_data(
&self,
created_at: u64,
identifier: String,
content: String,
) -> Result<ApplicationDataView, SoftchatError>
pub fn create_application_data( &self, created_at: u64, identifier: String, content: String, ) -> Result<ApplicationDataView, SoftchatError>
Create a direct signed generic NIP-78 event.
§Errors
Returns SoftchatError::InvalidApplicationData for an empty
identifier or an oversized event.
Sourcepub fn create_app_data_sync(
&self,
created_at: u64,
context: AppDataContext,
json: &str,
) -> Result<AppDataSyncView, SoftchatError>
pub fn create_app_data_sync( &self, created_at: u64, context: AppDataContext, json: &str, ) -> Result<AppDataSyncView, SoftchatError>
Create direct signed, self-encrypted Softchat application data.
§Errors
Returns SoftchatError::InvalidApplicationData for invalid JSON,
bounds, encryption, or signing failure.
Sourcepub fn decrypt_app_data_sync(
&self,
event: &SignedNostrEvent,
) -> Result<AppDataSyncView, SoftchatError>
pub fn decrypt_app_data_sync( &self, event: &SignedNostrEvent, ) -> Result<AppDataSyncView, SoftchatError>
Validate and self-decrypt one kind-30079 event.
§Errors
Returns SoftchatError::InvalidApplicationData unless the event is
authored by this identity and all encrypted JSON authenticates.
Source§impl LocalIdentity
impl LocalIdentity
Sourcepub fn create_chat_message(
&self,
draft: ChatMessageDraft,
) -> Result<ChatMessageView, SoftchatError>
pub fn create_chat_message( &self, draft: ChatMessageDraft, ) -> Result<ChatMessageView, SoftchatError>
Create a canonical one-to-one or group kind-14 message rumor.
§Errors
Returns SoftchatError::SoftchatEventCreationFailed for invalid
participants, relations, attachment metadata, or extension tags.
Sourcepub fn create_subject(
&self,
draft: SubjectDraft,
) -> Result<SubjectView, SoftchatError>
pub fn create_subject( &self, draft: SubjectDraft, ) -> Result<SubjectView, SoftchatError>
Create a canonical subject update with dual Android/iOS icon tags.
§Errors
Returns SoftchatError::SoftchatEventCreationFailed for invalid input.
Sourcepub fn create_reaction(
&self,
draft: ReactionDraft,
) -> Result<ReactionView, SoftchatError>
pub fn create_reaction( &self, draft: ReactionDraft, ) -> Result<ReactionView, SoftchatError>
Create a canonical private reaction rumor.
§Errors
Returns a stable creation failure for malformed references or reaction.
Sourcepub fn create_deletion(
&self,
participants: Vec<NostrPublicKey>,
event_ids: Vec<NostrEventId>,
reason: String,
created_at: u64,
) -> Result<DeletionView, SoftchatError>
pub fn create_deletion( &self, participants: Vec<NostrPublicKey>, event_ids: Vec<NostrEventId>, reason: String, created_at: u64, ) -> Result<DeletionView, SoftchatError>
Create a canonical private deletion request.
§Errors
Returns a stable creation failure for empty, duplicate, or oversized IDs.
Sourcepub fn create_edit(
&self,
participants: Vec<NostrPublicKey>,
original_event_id: NostrEventId,
content: String,
emoji_tags: Vec<NostrTag>,
created_at: u64,
) -> Result<EditView, SoftchatError>
pub fn create_edit( &self, participants: Vec<NostrPublicKey>, original_event_id: NostrEventId, content: String, emoji_tags: Vec<NostrTag>, created_at: u64, ) -> Result<EditView, SoftchatError>
Create a canonical text-and-emoji-only kind-1010 edit.
§Errors
Returns a stable creation failure for invalid participants or emoji tags.
Sourcepub fn create_typing(
&self,
participants: Vec<NostrPublicKey>,
created_at: u64,
) -> Result<TypingView, SoftchatError>
pub fn create_typing( &self, participants: Vec<NostrPublicKey>, created_at: u64, ) -> Result<TypingView, SoftchatError>
Create one ephemeral kind-21234 typing rumor.
§Errors
Returns a stable creation failure for an invalid participant set.
Source§impl LocalIdentity
impl LocalIdentity
Sourcepub fn from_secret_bytes(secret_key: &[u8]) -> Result<Self, SoftchatError>
pub fn from_secret_bytes(secret_key: &[u8]) -> Result<Self, SoftchatError>
Import a secret key from exactly 32 bytes.
The caller remains responsible for clearing its own input buffer after this synchronous import returns.
§Errors
Returns SoftchatError::InvalidSecretKey for an invalid scalar.
Sourcepub fn from_secret_hex(secret_key: &str) -> Result<Self, SoftchatError>
pub fn from_secret_hex(secret_key: &str) -> Result<Self, SoftchatError>
Import a secret key from exactly 64 hexadecimal characters.
This is retained for native Rust and legacy binding compatibility. Byte import is preferred for scoped foreign-language identities.
§Errors
Returns SoftchatError::InvalidSecretKey for an invalid scalar.
Sourcepub fn public_key(&self) -> NostrPublicKey
pub fn public_key(&self) -> NostrPublicKey
Return this identity’s public key.
Sourcepub fn sign_event(
&self,
draft: NostrEventDraft,
) -> Result<SignedNostrEvent, SoftchatError>
pub fn sign_event( &self, draft: NostrEventDraft, ) -> Result<SignedNostrEvent, SoftchatError>
Sign one explicit NIP-01 draft with this identity.
The draft’s timestamp, kind, tags, and content are preserved exactly. No hidden clock read or tag normalization occurs.
§Errors
Returns a stable draft-validation, size, or signing failure.
Sourcepub fn encrypt(
&self,
recipient: &NostrPublicKey,
plaintext: &[u8],
) -> Result<Nip44EncryptedMessage, SoftchatError>
pub fn encrypt( &self, recipient: &NostrPublicKey, plaintext: &[u8], ) -> Result<Nip44EncryptedMessage, SoftchatError>
Encrypt arbitrary non-empty bytes with NIP-44 v2.
§Errors
Returns a stable validation or redacted encryption failure.
Sourcepub fn encrypt_utf8(
&self,
recipient: &NostrPublicKey,
plaintext: &str,
) -> Result<Nip44EncryptedMessage, SoftchatError>
pub fn encrypt_utf8( &self, recipient: &NostrPublicKey, plaintext: &str, ) -> Result<Nip44EncryptedMessage, SoftchatError>
Encrypt one non-empty UTF-8 string with NIP-44 v2.
§Errors
Returns a stable validation or redacted encryption failure.
Sourcepub fn decrypt(
&self,
message: &Nip44EncryptedMessage,
) -> Result<Vec<u8>, SoftchatError>
pub fn decrypt( &self, message: &Nip44EncryptedMessage, ) -> Result<Vec<u8>, SoftchatError>
Authenticate and decrypt a NIP-44 message to bytes.
§Errors
All authentication, encoding, padding, and version failures map to
SoftchatError::DecryptionFailed.
Sourcepub fn decrypt_utf8(
&self,
message: &Nip44EncryptedMessage,
) -> Result<String, SoftchatError>
pub fn decrypt_utf8( &self, message: &Nip44EncryptedMessage, ) -> Result<String, SoftchatError>
Authenticate and decrypt a NIP-44 message as UTF-8.
§Errors
All authentication, encoding, padding, version, and UTF-8 failures map
to SoftchatError::DecryptionFailed.
Source§impl LocalIdentity
impl LocalIdentity
Sourcepub fn create_rumor(
&self,
draft: NostrEventDraft,
) -> Result<NostrRumor, SoftchatError>
pub fn create_rumor( &self, draft: NostrEventDraft, ) -> Result<NostrRumor, SoftchatError>
Create one unsigned rumor whose author is this identity.
The draft timestamp remains the canonical application timestamp.
§Errors
Returns a stable draft-validation or event-size failure.
Sourcepub fn gift_wrap(
&self,
recipient: &NostrPublicKey,
rumor: &NostrRumor,
kind: Nip59EnvelopeKind,
now: u64,
) -> Result<SignedNostrEvent, SoftchatError>
pub fn gift_wrap( &self, recipient: &NostrPublicKey, rumor: &NostrRumor, kind: Nip59EnvelopeKind, now: u64, ) -> Result<SignedNostrEvent, SoftchatError>
Wrap one authenticated rumor for exactly one recipient.
A fresh wrapper key is generated for every call. Seal and wrapper
timestamps are sampled independently from [now - 172800, now].
§Errors
Returns SoftchatError::Nip59EnvelopeCreationFailed if the rumor
author, timestamp, nested size, encryption, or signing checks fail.
Sourcepub fn unwrap_gift_wrap(
&self,
outer: &SignedNostrEvent,
) -> Result<UnwrappedNip59Envelope, SoftchatError>
pub fn unwrap_gift_wrap( &self, outer: &SignedNostrEvent, ) -> Result<UnwrappedNip59Envelope, SoftchatError>
Authenticate and unwrap one already verified NIP-59 outer event.
No rumor is returned unless route, kind, both encrypted layers, seal signature, seal shape, rumor ID, and author binding all validate.
§Errors
Every invalid layer maps to SoftchatError::InvalidNip59Envelope.
Source§impl LocalIdentity
impl LocalIdentity
Sourcepub fn create_nip17_text_message(
&self,
recipient: &NostrPublicKey,
created_at: u64,
content: impl Into<String>,
) -> Result<Nip17TextMessage, SoftchatError>
pub fn create_nip17_text_message( &self, recipient: &NostrPublicKey, created_at: u64, content: impl Into<String>, ) -> Result<Nip17TextMessage, SoftchatError>
Create one minimal one-to-one NIP-17 text-message rumor.
The writer emits exactly one canonical p tag and no extension tags.
Callers explicitly create separate NIP-59 copies for the recipient and
sender when recoverable local history is required.
§Errors
Returns SoftchatError::Nip17MessageCreationFailed for self-addressed
messages, empty text, invalid timestamps, or oversized rumors.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for LocalIdentity
impl RefUnwindSafe for LocalIdentity
impl Send for LocalIdentity
impl Sync for LocalIdentity
impl Unpin for LocalIdentity
impl UnsafeUnpin for LocalIdentity
impl UnwindSafe for LocalIdentity
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
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read more