Expand description
Portable Softchat protocol values and cryptographic operations.
The native API uses validated values and retained capabilities. Callers construct protocol data explicitly: signing does not read a hidden clock or normalize exact Nostr tag arrays.
§Protocol workflow
use softchat::{
LocalIdentity, NostrEventDraft, NostrEventKind, NostrTag,
SignedNostrEvent,
};
let alice = LocalIdentity::from_secret_hex(
"5c0c523f52a5b6fad39ed2403092df8cebc36318b39383bca6c00808626fab3a",
)?;
let bob = LocalIdentity::from_secret_hex(
"4b22aa260e4acb7021e32f38a6cdf4b673c6a277755bfce287e370c924dc936d",
)?;
let encrypted = alice.encrypt_utf8(&bob.public_key(), "hello")?;
assert_eq!(bob.decrypt_utf8(&encrypted)?, "hello");
let recipient = NostrTag::new(vec![
"p".to_owned(),
bob.public_key().to_hex(),
String::new(),
String::new(),
])?;
let draft = NostrEventDraft::new(
1_700_000_000,
NostrEventKind::SHORT_TEXT_NOTE,
vec![recipient],
"A signed protocol event",
)?;
let authored = alice.sign_event(draft)?;
let received = SignedNostrEvent::from_json(&authored.to_json()?)?;
assert_eq!(received, authored);The keys above are fixtures. Never use them outside tests or examples.
Network transport, attachment files, and application lifecycle remain
platform-owned. With sqlite-storage, Rust also owns the Android account
schema, transactions, authenticated truth, delivery recovery, and bounded
use-case queries; Android supplies only an app-private path and lifecycle.
Structs§
- Account
Database - One account-scoped SQLite owner.
- Account
Database Info - Static database information returned after opening one account.
- Account
Diagnostics - Redacted bounded account health information for support and recovery UI.
- Account
Draft - One portable draft stored with its conversation.
- Account
Engine - Stateless semantic account planner.
- Account
Event Node - One use-case node derived from authenticated protocol truth.
- Account
Media Item - One attachment projected into an account media gallery.
- Account
Media Lease - Exclusive bounded lease for one platform-owned media transfer.
- Account
Media Operation - One durable logical media operation.
- Account
Media Operation Page - One stable page of non-terminal media operations for a platform executor.
- Account
Message - One bounded message view derived without replacing protocol truth.
- Account
Message View - Complete effective message consumed by product UI.
- Account
Mutation Result - Generic result for a transaction that changed account state.
- Account
Operation Result - Result of an idempotent outgoing operation transaction.
- Account
Profile - Effective authenticated or explicitly local profile.
- Account
Projection - One authenticated projection with exact protocol truth attached.
- Account
Read State - Effective cross-device read state for one conversation.
- Account
Settings - Versioned platform-neutral account settings.
- Account
Settings Mutation - Result of a committed settings patch.
- Account
Transport Action - One correlated, bounded platform action.
- Account
Transport Batch - Complete result of one correlated state-machine transition.
- Account
Transport Result - Correlated result returned by the Android system executor.
- Account
Typing Indicator - One authenticated non-durable typing indicator retained until expiry.
- AppData
Sync View - Authenticated and self-decrypted Softchat kind-30079 data.
- Application
Data View - Generic direct NIP-78 application data.
- Attachment
Decryption Stream - Incremental authenticated decryption for a private staged destination.
- Attachment
Encryption Stream - Incremental encryption compatible with released clients’ combined
nonce12 || ciphertext || tag16attachment format. - Attachment
Metadata - Parsed canonical Softchat
imetametadata. - Attachment
Stream Final - Final authentication and hash values for one staged attachment transform.
- Batch
Acknowledgement - One terminal relay result for a submitted event.
- Batch
Progress - Deterministic per-event batch progress in original submission order.
- Build
Fingerprint - Stable build metadata safe to include in logs and crash reports.
- Chat
Message Draft - Canonical complete kind-14 message writer input.
- Chat
Message View - Flat complete kind-14 message view.
- Chat
Relation Input - Flat relation input for generated native bindings.
- Claimed
Delivery - One committed delivery lease and the exact bytes Android may send.
- Contact
- One canonical contact-backup entry.
- Conversation
Cursor - Stable conversation-list paging cursor.
- Conversation
Page - One bounded page of complete conversations.
- Conversation
Record - Complete conversation state consumed by product UI.
- Conversation
Summary - Bounded conversation list item derived from authenticated projections.
- Conversation
View - One complete conversation-list use case returned in a single native call.
- Custom
Emoji Reference - Versioned platform-neutral account settings.
- Deletion
View - Typed NIP-09 deletion view.
- Delivery
Claim - One bounded exclusive delivery lease.
- Delivery
Decision - Stable host-facing delivery decision.
- Delivery
Intent Snapshot - Store snapshot used by the pure delivery reducer.
- Delivery
Payload - Exact payload attached to one claimed relay-delivery intent.
- Delivery
Reducer - Stateless durable-delivery reducer.
- Delivery
State Mutation - State mutation returned for an atomic platform transaction.
- Diagnostics
Snapshot - Monotonic process-local counters containing no protocol values.
- DnsRelay
Record - One authenticated DNS URI record supplied by the Android system adapter.
- Draft
Span - One bounded half-open UTF-16 range in a portable draft.
- Edit
View - Typed Softchat kind-1010 edit view.
- Follow
List View - Typed private kind-3 contact backup.
- Generic
Repost View - Validated receive-only NIP-18 generic repost.
- Http
Authorization Plan - Immutable NIP-98 authorization result for platform HTTP adapters.
- Ingestion
Batch - One bounded atomic ingestion request to a platform-owned store.
- Ingestion
Receipt - Platform result for one complete incoming transaction.
- Ingestion
Result - Result returned by an authoritative Room, GRDB, IndexedDB, or host adapter.
- Link
Preview Record - One cached HTTP link-preview result.
- Local
Contact Record - One Android-local address-book entry.
- Local
Identity - A locally held secret-key capability.
- Managed
Account Transport - SDK-owned WSS/Noise executor for one
crate::SoftchatAccount. - Managed
Transport Snapshot - Complete observable state of one SDK-owned account transport.
- Media
Completion Result - Result of acknowledging one completed attachment lease.
- Media
Preparation Input - One platform source selected for an attachment-dependent message.
- Message
Content Input - Complete user-authored message input.
- Message
Cursor - Stable newest-first message paging cursor.
- Message
Local Extras - Sparse account-local non-protocol data attached to one message.
- Message
Page - One bounded page of messages.
- Message
Projection - Pure text/deletion projection over one original and its event history.
- Message
Reaction Input - User-selected reaction input.
- Message
Reaction View - One effective reaction attached to a message.
- Negentropy
Client - Serialized, bounded Negentropy initiator.
- Negentropy
Item - One event timestamp/ID pair in a local reconciliation set.
- Negentropy
Step - Result of one stateful client reconciliation step.
- Nip17
Text Message - A validated one-to-one kind-14 text-message rumor.
- Nip19
Identifier - A bounded, parsed NIP-19 value.
- Nip19
Tlv - One unknown NIP-19 TLV retained for forward-compatible re-encoding.
- Nip44
Encrypted Message - A typed native-Rust NIP-44 v2 message.
- Nip44
Payload - One bounded, encoded NIP-44 v2 payload.
- Nip59
Envelope Route - Verified outer-envelope routing metadata that does not expose plaintext.
- Noise
Client Handshake - Single-use client handshake capability.
- Noise
Transport - Established, serialized Noise transport capability.
- Nostr
Event Draft - An explicit, validated NIP-01 event body waiting for a signature.
- Nostr
Event Id - A validated canonical lowercase hexadecimal Nostr event ID.
- Nostr
Event Kind - A NIP-01 event kind in the inclusive
0...65535range. - Nostr
Event Signature - A validated canonical lowercase BIP-340 Schnorr signature.
- Nostr
Public Key - A validated lowercase hexadecimal Nostr public key.
- Nostr
Rumor - One unsigned NIP-59 rumor with a verified canonical event ID.
- Nostr
Tag - One exact, non-empty NIP-01 tag array.
- Operation
Snapshot - Aggregate operation state derived entirely from durable intent rows.
- Outbound
Relay Frame - One ordered text frame removed from the session’s bounded outbound queue.
- Pending
Asset Replacement - One durable public asset replacement and its platform upload dependency.
- Pending
Media Message - Durable message intent with its ordered logical attachment operations.
- Prepared
Event Copy - One independently randomized NIP-59 recipient copy.
- Prepared
Incoming Batch - One bounded atomic ingestion request for a platform-native database.
- Prepared
Incoming Event - One fully authenticated event and its optional inner rumor.
- Prepared
Outgoing Operation - One outgoing operation that must be persisted before any socket write.
- Prepared
Relay Intent - One durable event-copy/relay delivery intent.
- Product
Operation Result - High-level command result with the complete effective message when relevant.
- Projection
Mutation - One normalized immutable projection mutation.
- Reaction
Draft - Canonical private-reaction writer input.
- Reaction
View - Typed NIP-25 reaction view.
- Relay
Catalog Entry - Complete platform-persisted relay catalog row.
- Relay
Catalog Mutation - Persisted relay catalog mutation.
- Relay
Catalog Plan - Deterministic full-state catalog replacement.
- Relay
Catalog Reducer - Stateless relay catalog reducer.
- Relay
Delivery Result - Stable redacted relay result.
- Relay
Endpoint Plan - Validated system-transport plan for one configured relay URL.
- Relay
Failover Mutation - Result of atomically selecting a failover relay and rebinding unfinished work.
- Relay
Filter - A strict NIP-01 filter that retains generic
#<tag>constraints. - Relay
Retry Plan - Bounded retry plan; the host chooses jitter inside the declared range.
- Relay
Session - One deterministic transport-independent relay session.
- Relay
Session Action - One transport/platform action emitted by
RelaySession. - Relay
Session Snapshot - Serializable non-secret session state for diagnostics only.
- Signed
Nostr Event - One structurally and cryptographically validated NIP-01 event.
- Softchat
Account - Android-facing owner of one identity and one Rust-managed account database.
- Sticker
Record - One cached custom emoji or sticker descriptor.
- Stored
Event Json - Exact stored event payload selected by an authenticated ID.
- Stored
Ingestion - Result of one atomic authenticated ingestion.
- Stored
Relay Catalog Plan - Persisted authenticated relay-discovery reconciliation.
- Subject
Draft - Canonical group-subject writer input.
- Subject
View - Typed group-subject view.
- Sync
Action - One transport/database action with fields selected by
SyncActionKind. - Sync
Engine - Serialized synchronization state machine.
- Sync
Engine Snapshot - Redacted serializable synchronization state.
- Typing
View - Typed ephemeral typing view.
- Unwrapped
Nip59 Envelope - A rumor exposed only after every NIP-59 layer has authenticated.
- User
Metadata View - Typed private user metadata with retained unknown JSON.
Enums§
- Account
Media Operation State - Logical media-operation state.
- Account
Media Protection - Confidentiality policy for one platform-executed media transfer.
- Account
Transport Action Kind - One system effect Android executes for the active account transport.
- Account
Transport Result Kind - Typed outcome of exactly one transport action.
- AppData
Context - Accepted Softchat kind-30079 contexts.
- Asset
Replacement Target - Public asset changed after one durable upload dependency completes.
- Batch
Event State - Terminal state for one event in a batch projection.
- Chat
Relation - One validated message relation.
- Chat
Relation Kind - Relation semantics exposed by a kind-14 message view.
- Client
Relay Frame - A validated client-to-relay frame.
- Delivery
Intent State - Durable delivery-intent state.
- Delivery
State - Durable delivery state for one authored event.
- Draft
Span Kind - Portable semantic span kind for one draft.
- Managed
Transport Failure - Stable redacted reason for the most recent managed-transport failure.
- Nip19
Identifier Kind - Supported NIP-19 identifier family.
- Nip59
Envelope Kind - The relay-storage behavior requested for one NIP-59 wrapper.
- Operation
State - User-visible aggregate operation state.
- Pending
Asset Replacement State - Logical state of one upload-dependent public asset replacement.
- Pending
Media Message State - Logical state of one attachment-dependent outgoing message.
- Projection
Kind - Semantic projection family selected after authentication.
- Push
Platform - Supported released push-registration wire profiles.
- Relay
Catalog Source - Consumer-visible source of one relay.
- Relay
Connection State - Transport-independent relay connection state.
- Relay
Delivery Result Kind - Relay result class accepted by the delivery reducer.
- Relay
Failure Kind - Transport failure class consumed by the Rust retry policy.
- Relay
Response Frame - A validated relay-to-client frame.
- Relay
Retry Action - Retry/failover action selected by Rust.
- Relay
Session Action Kind - Action kind emitted by the pure session.
- Softchat
Error - Stable, redacted failures exposed by Softchat.
- Sync
Action Kind - Action emitted by the host-driven synchronization coordinator.
- Sync
Phase - Durable synchronization phase.
Constants§
- ACCOUNT_
READ_ STATE_ SCHEMA_ VERSION - Current portable read-state schema.
- ACCOUNT_
SETTINGS_ SCHEMA_ VERSION - Current portable settings schema.
- DEFAULT_
FALLBACK_ RELAY_ TTL_ SECONDS - Default refresh lifetime assigned to the compiled fallback.
- MAX_
ACCOUNT_ INGESTION_ BYTES - Maximum canonical event bytes prepared in one incoming transaction.
- MAX_
ACCOUNT_ INGESTION_ EVENTS - Maximum events prepared in one incoming transaction.
- MAX_
ACCOUNT_ READ_ STATE_ BYTES - Maximum UTF-8 bytes in one complete read-state snapshot.
- MAX_
ACCOUNT_ READ_ STATE_ ENTRIES - Maximum conversations retained in one cross-device read-state snapshot.
- MAX_
ACCOUNT_ SETTINGS_ BYTES - Maximum UTF-8 bytes in retained settings JSON.
- MAX_
APP_ DATA_ JSON_ BYTES - Maximum decrypted application-data JSON accepted by the shared layer.
- MAX_
ATTACHMENT_ COMPATIBILITY_ BYTES - Maximum input for the whole-buffer released-client compatibility helper.
- MAX_
ATTACHMENT_ FALLBACKS - Maximum number of fallback URLs in one canonical attachment.
- MAX_
ATTACHMENT_ METADATA_ FIELDS - Maximum number of fields after the leading
imetatag name. - MAX_
ATTACHMENT_ STREAM_ BYTES - Maximum plaintext bytes processed by one staged streaming operation.
- MAX_
ATTACHMENT_ STREAM_ CHUNK_ BYTES - Maximum bytes accepted by one cross-language streaming call.
- MAX_
CHAT_ ATTACHMENTS - Maximum inline attachments on one canonical chat message.
- MAX_
CHAT_ EMOJI_ TAGS - Maximum custom emoji definitions on one event.
- MAX_
CHAT_ EXTENSION_ TAGS - Maximum typed extension tags accepted from a writer.
- MAX_
CHAT_ PARTICIPANTS - Maximum participant count in one Softchat rumor.
- MAX_
CIPHERTEXT_ BYTES - Compatibility name for the current encoded-payload reader limit.
- MAX_
CONTACTS - Maximum contacts in one private backup.
- MAX_
DELIVERY_ CLAIM_ BYTES - Maximum canonical payload bytes returned in one platform lease.
- MAX_
DELIVERY_ CLAIM_ INTENTS - Maximum delivery rows returned in one platform lease.
- MAX_
DNS_ RELAY_ RECORDS - Maximum authenticated DNS URI records accepted in one refresh.
- MAX_
HTTP_ AUTHORIZATION_ PAYLOAD_ BYTES - Maximum request-body bytes hashed by the whole-buffer NIP-98 helper.
- MAX_
HTTP_ AUTHORIZATION_ URL_ BYTES - Maximum normalized URL bytes accepted by one NIP-98 plan.
- MAX_
INFLIGHT_ INGESTION - Maximum received events awaiting authoritative platform persistence.
- MAX_
NEGENTROPY_ FRAME_ BYTES - Largest Negentropy frame allowed inside the 512-KiB relay profile.
- MAX_
NEGENTROPY_ ITEMS - Maximum items accepted by one portable reconciliation capability.
- MAX_
NIP19_ IDENTIFIER_ CHARS - Maximum accepted encoded identifier length.
- MAX_
NIP19_ RELAYS - Maximum relay hints retained in one shareable identifier.
- MAX_
NIP44_ BINARY_ WRITER_ PLAINTEXT_ BYTES - Maximum arbitrary-byte plaintext emitted through the native Rust API.
- MAX_
NIP44_ ENCODED_ PAYLOAD_ BYTES - Cheap encoded-payload bound applied before base64 decoding.
- MAX_
NIP44_ READER_ PLAINTEXT_ BYTES - Maximum plaintext size accepted by the Softchat NIP-44 v2 reader.
- MAX_
NIP44_ WRITER_ PLAINTEXT_ BYTES - Maximum plaintext size emitted by the Softchat NIP-44 v2 writer.
- MAX_
NIP59_ TIMESTAMP_ TWEAK_ SECONDS - Maximum number of seconds subtracted independently from private timestamps.
- MAX_
NOISE_ FRAME_ CIPHERTEXT - Largest encrypted WebSocket frame.
- MAX_
NOISE_ FRAME_ PLAINTEXT - Largest plaintext that fits in one unchunked encrypted frame.
- MAX_
NOISE_ MESSAGE_ SIZE - Largest logical message accepted by the deployed chunking profile.
- MAX_
NOSTR_ EVENT_ JSON_ BYTES - Maximum standalone NIP-01 event JSON accepted by the portable boundary.
- MAX_
OPERATION_ DELIVERY_ INTENTS - Maximum event/relay intents retained by one outgoing operation.
- MAX_
OPERATION_ EVENT_ COPIES - Maximum event copies retained by one outgoing operation.
- MAX_
OPERATION_ RELAYS - Maximum relay destinations attached to one outgoing operation.
- MAX_
OUTBOUND_ RELAY_ FRAMES - Maximum queued outbound frames in one session.
- MAX_
PENDING_ PUBLISHES - Maximum authored events retained for durable delivery intent.
- MAX_
PLAINTEXT_ BYTES - Compatibility name for the native arbitrary-byte writer limit.
- MAX_
PORTABLE_ TIMESTAMP_ SECONDS - Largest Unix timestamp represented exactly by JavaScript
number. - MAX_
PRODUCT_ ATTACHMENT_ TAG_ BYTES - Maximum compact JSON bytes reserved for one outgoing
imetatag. - MAX_
PRODUCT_ DRAFT_ ATTACHMENTS - Maximum logical attachment preparation references in one draft.
- MAX_
PRODUCT_ DRAFT_ SPANS - Maximum portable rich-text spans in one draft.
- MAX_
PRODUCT_ MEDIA_ OPERATION_ LOOKUPS - Maximum exact media operations resolved by one ordered lookup.
- MAX_
PRODUCT_ MESSAGE_ BYTES - Maximum UTF-8 bytes in a portable message draft.
- MAX_
PRODUCT_ MESSAGE_ LOOKUPS - Maximum exact messages resolved by one ordered product lookup.
- MAX_
PRODUCT_ PROFILE_ LOOKUPS - Maximum exact profiles resolved by one ordered product lookup.
- MAX_
PRODUCT_ QUERY_ PAGE - Maximum requested rows for one product query.
Media gallery pages finish the last message’s attachment group and may
return at most
limit + MAX_CHAT_ATTACHMENTS - 1items. - MAX_
PRODUCT_ SEARCH_ BYTES - Maximum UTF-8 bytes in one search query.
- MAX_
PRODUCT_ TRANSCRIPT_ BYTES - Maximum UTF-8 bytes in one local transcript.
- MAX_
PRODUCT_ WAVEFORM_ SAMPLES - Maximum normalized waveform samples stored for one message.
- MAX_
RELAY_ BATCH_ EVENTS - Maximum number of events in the deployed
EVENTSextension. - MAX_
RELAY_ CATALOG_ ENTRIES - Maximum effective relay records retained for one account.
- MAX_
RELAY_ FILTERS - Maximum number of filters in one query.
- MAX_
RELAY_ FILTER_ VALUES - Maximum values in one filter field or generic-tag constraint.
- MAX_
RELAY_ FRAME_ BYTES - Maximum accepted logical relay frame size.
- MAX_
RELAY_ MESSAGE_ CHARS - Maximum bounded diagnostic/challenge string accepted from a relay.
- MAX_
RELAY_ RETRY_ DELAY_ MS - Maximum reconnect delay before host-selected jitter.
- MAX_
RELAY_ RETRY_ JITTER_ MS - Host-selected retry jitter range is always zero through this value.
- MAX_
RELAY_ SUBSCRIPTIONS - Maximum simultaneous subscription identifiers.
- MAX_
RELAY_ TTL_ SECONDS - Maximum DNS URI TTL accepted by the portable policy.
- MAX_
SUBSCRIPTION_ ID_ CHARS - NIP-01 maximum subscription identifier length in Unicode scalar values.
- MIN_
NEGENTROPY_ FRAME_ BYTES - Smallest accepted non-zero Negentropy frame limit.
- NIP42_
AUTH_ WINDOW_ SECONDS - Accepted NIP-42 authentication timestamp skew in seconds.
- NIP44_
V2_ ALGORITHM - Algorithm identifier carried by encrypted-message binding values.
- NOISE_
PROTOCOL_ NAME - Exact deployed Noise protocol name.
- SYNC_
BASE_ PAGE_ LIMIT - Default relay/local snapshot page size.
- SYNC_
EVENT_ REQUEST_ CHUNK - Maximum IDs in one ordinary NIP-01 fetch or resend request.
- SYNC_
MAX_ PAGE_ LIMIT - Maximum page expansion used to capture a complete timestamp cohort.
Functions§
- build_
fingerprint - Return stable build metadata.
- classify_
application_ data - Validate a direct generic NIP-78 event.
- classify_
chat_ message - Validate a binding-owned rumor as a complete kind-14 message.
- classify_
deletion - Validate a binding-owned rumor as a deletion request.
- classify_
delivery_ acknowledgement - Classify one standard
OKwithout trusting its human-readable message as identity. - classify_
edit - Validate a binding-owned rumor as a kind-1010 edit.
- classify_
follow_ list - Validate a binding-owned private contact-backup rumor.
- classify_
generic_ repost - Validate a signed receive-only NIP-18 generic repost.
- classify_
reaction - Validate a binding-owned rumor as a reaction.
- classify_
subject - Validate a binding-owned rumor as a subject update.
- classify_
typing - Validate a binding-owned rumor as a typing event.
- classify_
user_ metadata - Validate a binding-owned private user-metadata rumor.
- conversation_
id - Compute the released-Android conversation ID from complete participants.
- create_
nip98_ authorization - Create an immutable, signed NIP-98 HTTP authorization plan.
- create_
nip98_ authorization_ for_ payload_ hash - Create a NIP-98 plan from a SHA-256 produced while streaming a request body.
- decrypt_
attachment_ bytes - Authenticate and decrypt a bounded released-client attachment value.
- diagnostics_
snapshot - Read monotonic process-local counters using relaxed atomics.
- encode_
events_ frame - Encode the deployed flat, non-empty
EVENTSextension. - encrypt_
attachment_ bytes - Encrypt a bounded released-client-compatible attachment value.
- latest_
application_ data - Select the deterministic latest addressable application-data event.
- latest_
user_ metadata - Select the deterministic latest private metadata rumor.
- parse_
attachment_ metadata - Parse one complete
imetatag at generated binding boundaries. - parse_
client_ relay_ frame - Parse one bounded client-to-relay JSON frame.
- parse_
relay_ endpoint - Validate one configured relay and split protocol from system transport data.
- parse_
relay_ response_ frame - Parse one bounded relay-to-client JSON frame.
- plan_
nip42_ authentication - Create a signed NIP-42 authentication event for one challenge and relay.
- plan_
relay_ retry - Select the exact retry/failover behavior for one failed attempt.
- project_
chat_ message - Apply authorized edit and deletion history without owning persistence.
- route_
nip59_ envelope - Verify a bounded gift-wrap event and extract its account-routing hint.
- track_
batch_ acknowledgements - Project unordered and repeated
OKresults onto one submitted batch. - validate_
ingestion_ result - Verify that a platform transaction classified every requested event exactly once.
- validate_
nip42_ authentication - Validate a NIP-42 authentication event against its exact connection context.
- version
- Return the Softchat semantic version compiled into this library.