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, persistence, files, and application lifecycle remain platform-owned.
Structs§
- 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 Input - Binding-owned canonical kind-14 writer input.
- Chat
Message View - Flat complete kind-14 message view.
- Chat
Relation Input - Flat relation input for generated native bindings.
- Contact
- One canonical contact-backup entry.
- Deletion
View - Typed NIP-09 deletion view.
- Delivery
Decision - Stable host-facing delivery decision.
- Diagnostics
Snapshot - Monotonic process-local counters containing no protocol values.
- Edit
View - Typed Softchat kind-1010 edit view.
- External
Event Signing Request - Complete, immutable request that an external provider signs.
- External
Signer Capabilities - Capabilities advertised by one external identity provider.
- 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
Result - Result returned by an authoritative Room, GRDB, IndexedDB, or host adapter.
- Local
Identity - A locally held secret-key capability.
- Message
Projection - Pure text/deletion projection over one original and its event history.
- 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.
- 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.
- Reaction
Draft - Canonical private-reaction writer input.
- Reaction
Input - Binding-owned canonical private-reaction writer input.
- Reaction
View - Typed NIP-25 reaction view.
- Relay
Filter - A strict NIP-01 filter that retains generic
#<tag>constraints. - Relay
Session - One deterministic transport-independent relay session.
- Relay
Session Action - One transport/platform action emitted by
RelaySession. - Relay
Session Handle - Thread-safe generated-binding owner for one serialized relay session.
- Relay
Session Snapshot - Serializable non-secret session state for diagnostics and restoration policy.
- Signed
Nostr Event - One structurally and cryptographically validated NIP-01 event.
- Subject
Draft - Canonical group-subject writer input.
- Subject
Input - Binding-owned canonical group-subject writer input.
- Subject
View - Typed group-subject view.
- Typing
View - Typed ephemeral typing view.
- Unwrapped
Nip59 Envelope - A rumor exposed only after every NIP-59 layer has authenticated.
- User
Metadata Input - Binding-owned private user-metadata writer input.
- User
Metadata View - Typed private user metadata with retained unknown JSON.
Enums§
- AppData
Context - Accepted Softchat kind-30079 contexts.
- 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
State - Durable delivery state for one authored event.
- External
Signer Failure - Redacted failure returned by an external provider.
- Nip19
Identifier Kind - Supported NIP-19 identifier family.
- Nip59
Envelope Kind - The relay-storage behavior requested for one NIP-59 wrapper.
- Relay
Connection State - Transport-independent relay connection state.
- Relay
Response Frame - A validated relay-to-client frame.
- Relay
Session Action Kind - Action kind emitted by the pure session.
- Softchat
Error - Stable, redacted failures exposed by Softchat.
Constants§
- 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_ 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_
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_
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_
RELAY_ BATCH_ EVENTS - Maximum number of events in the deployed
EVENTSextension. - 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_ SUBSCRIPTIONS - Maximum simultaneous subscription identifiers.
- 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.
Traits§
- External
Signer - A keyless external signing and NIP-44 provider.
- Persistence
Adapter - Synchronous semantic contract for platform persistence adapters.
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.
- complete_
external_ event_ signing - Attach and verify a provider signature.
- create_
nip98_ authorization - Create an immutable, signed NIP-98 HTTP authorization plan.
- decrypt_
attachment_ bytes - Authenticate and decrypt a bounded released-client attachment value.
- decrypt_
with_ external - Decrypt UTF-8 through an external provider.
- 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.
- encrypt_
with_ external - Encrypt UTF-8 through an external provider and validate the result’s bounds.
- 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_ 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.
- prepare_
external_ event_ signing - Prepare one externally signed event without invoking a provider.
- project_
chat_ message - Apply authorized edit and deletion history without owning persistence.
- sign_
event_ with_ external - Invoke a native Rust provider and verify its result.
- 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 the library.