Skip to main content

Crate softchat

Crate softchat 

Source
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§

AppDataSyncView
Authenticated and self-decrypted Softchat kind-30079 data.
ApplicationDataView
Generic direct NIP-78 application data.
AttachmentDecryptionStream
Incremental authenticated decryption for a private staged destination.
AttachmentEncryptionStream
Incremental encryption compatible with released clients’ combined nonce12 || ciphertext || tag16 attachment format.
AttachmentMetadata
Parsed canonical Softchat imeta metadata.
AttachmentStreamFinal
Final authentication and hash values for one staged attachment transform.
BatchAcknowledgement
One terminal relay result for a submitted event.
BatchProgress
Deterministic per-event batch progress in original submission order.
BuildFingerprint
Stable build metadata safe to include in logs and crash reports.
ChatMessageDraft
Canonical complete kind-14 message writer input.
ChatMessageInput
Binding-owned canonical kind-14 writer input.
ChatMessageView
Flat complete kind-14 message view.
ChatRelationInput
Flat relation input for generated native bindings.
Contact
One canonical contact-backup entry.
DeletionView
Typed NIP-09 deletion view.
DeliveryDecision
Stable host-facing delivery decision.
DiagnosticsSnapshot
Monotonic process-local counters containing no protocol values.
EditView
Typed Softchat kind-1010 edit view.
ExternalEventSigningRequest
Complete, immutable request that an external provider signs.
ExternalSignerCapabilities
Capabilities advertised by one external identity provider.
FollowListView
Typed private kind-3 contact backup.
GenericRepostView
Validated receive-only NIP-18 generic repost.
HttpAuthorizationPlan
Immutable NIP-98 authorization result for platform HTTP adapters.
IngestionBatch
One bounded atomic ingestion request to a platform-owned store.
IngestionResult
Result returned by an authoritative Room, GRDB, IndexedDB, or host adapter.
LocalIdentity
A locally held secret-key capability.
MessageProjection
Pure text/deletion projection over one original and its event history.
NegentropyClient
Serialized, bounded Negentropy initiator.
NegentropyItem
One event timestamp/ID pair in a local reconciliation set.
NegentropyStep
Result of one stateful client reconciliation step.
Nip17TextMessage
A validated one-to-one kind-14 text-message rumor.
Nip19Identifier
A bounded, parsed NIP-19 value.
Nip19Tlv
One unknown NIP-19 TLV retained for forward-compatible re-encoding.
Nip44EncryptedMessage
A typed native-Rust NIP-44 v2 message.
Nip44Payload
One bounded, encoded NIP-44 v2 payload.
NoiseClientHandshake
Single-use client handshake capability.
NoiseTransport
Established, serialized Noise transport capability.
NostrEventDraft
An explicit, validated NIP-01 event body waiting for a signature.
NostrEventId
A validated canonical lowercase hexadecimal Nostr event ID.
NostrEventKind
A NIP-01 event kind in the inclusive 0...65535 range.
NostrEventSignature
A validated canonical lowercase BIP-340 Schnorr signature.
NostrPublicKey
A validated lowercase hexadecimal Nostr public key.
NostrRumor
One unsigned NIP-59 rumor with a verified canonical event ID.
NostrTag
One exact, non-empty NIP-01 tag array.
ReactionDraft
Canonical private-reaction writer input.
ReactionInput
Binding-owned canonical private-reaction writer input.
ReactionView
Typed NIP-25 reaction view.
RelayFilter
A strict NIP-01 filter that retains generic #<tag> constraints.
RelaySession
One deterministic transport-independent relay session.
RelaySessionAction
One transport/platform action emitted by RelaySession.
RelaySessionHandle
Thread-safe generated-binding owner for one serialized relay session.
RelaySessionSnapshot
Serializable non-secret session state for diagnostics and restoration policy.
SignedNostrEvent
One structurally and cryptographically validated NIP-01 event.
SubjectDraft
Canonical group-subject writer input.
SubjectInput
Binding-owned canonical group-subject writer input.
SubjectView
Typed group-subject view.
TypingView
Typed ephemeral typing view.
UnwrappedNip59Envelope
A rumor exposed only after every NIP-59 layer has authenticated.
UserMetadataInput
Binding-owned private user-metadata writer input.
UserMetadataView
Typed private user metadata with retained unknown JSON.

Enums§

AppDataContext
Accepted Softchat kind-30079 contexts.
BatchEventState
Terminal state for one event in a batch projection.
ChatRelation
One validated message relation.
ChatRelationKind
Relation semantics exposed by a kind-14 message view.
ClientRelayFrame
A validated client-to-relay frame.
DeliveryState
Durable delivery state for one authored event.
ExternalSignerFailure
Redacted failure returned by an external provider.
Nip19IdentifierKind
Supported NIP-19 identifier family.
Nip59EnvelopeKind
The relay-storage behavior requested for one NIP-59 wrapper.
RelayConnectionState
Transport-independent relay connection state.
RelayResponseFrame
A validated relay-to-client frame.
RelaySessionActionKind
Action kind emitted by the pure session.
SoftchatError
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 imeta tag 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 EVENTS extension.
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§

ExternalSigner
A keyless external signing and NIP-44 provider.
PersistenceAdapter
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 OK without 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 EVENTS extension.
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 imeta tag 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 OK results 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.