Skip to main content

Crate algochat

Crate algochat 

Source
Expand description

AlgoChat - Encrypted messaging on Algorand

Rust implementation of the AlgoChat protocol using X25519 + ChaCha20-Poly1305.

§Overview

AlgoChat provides end-to-end encrypted messaging on the Algorand blockchain. Messages are stored as encrypted transaction notes, providing immutable, decentralized messaging with cryptographic proof of authenticity.

§Modules

  • [algochat] - Main client interface
  • [crypto] - Message encryption and decryption
  • [envelope] - Wire format for encrypted messages
  • [keys] - Key derivation from Algorand accounts
  • [signature] - Ed25519 signature verification for key ownership
  • [models] - Data types for messages, conversations, etc.
  • [storage] - Message cache, public key cache, and key storage
  • [queue] - Message queue for offline support
  • [blockchain] - Algorand integration interfaces
  • [types] - Protocol constants and error types
  • [psk_types] - PSK protocol v1.1 constants and types
  • [psk_ratchet] - Two-level PSK ratchet key derivation
  • [psk_envelope] - PSK envelope encoding/decoding
  • [psk_state] - PSK counter state management
  • [psk_exchange] - PSK exchange URI format
  • [psk_crypto] - PSK encryption and decryption

Structs§

AccountInfo
Account information.
AlgoChat
The main AlgoChat client for encrypted messaging.
AlgoChatConfig
Configuration for the AlgoChat client.
AlgorandConfig
Configuration for Algorand node connections.
ChatAccount
A chat-enabled Algorand account with encryption keys.
ChatEnvelope
AlgoChat message envelope.
Conversation
A conversation between two Algorand addresses.
DecryptedContent
Decrypted message content.
DiscoveredKey
Result of discovering a user’s encryption key.
FileKeyStorage
File-based encryption key storage with password protection.
InMemoryKeyStorage
In-memory implementation of EncryptionKeyStorage (for testing).
InMemoryMessageCache
In-memory implementation of MessageCache.
Message
A chat message between Algorand addresses.
NoteTransaction
A note field transaction from the blockchain.
PSKContact
A PSK contact with the shared key and ratchet state.
PSKEnvelope
PSK message envelope containing all fields for a PSK-encrypted message.
PSKExchangeURI
A parsed PSK exchange URI containing all fields.
PSKState
State for a PSK conversation with a single peer.
PaginatedTransactions
Paginated transaction search result.
PendingMessage
A message queued for sending (for offline support).
PublicKeyCache
In-memory cache for public keys with TTL expiration.
QueueConfig
Configuration for the send queue.
ReplyContext
Context for a reply message, linking it to the original.
SendOptions
Options for sending a message.
SendQueue
A queue for managing pending outgoing messages.
SendResult
Result of a successful send operation.
SuggestedParams
Suggested transaction parameters.
TransactionInfo
Transaction information returned after submission.

Enums§

AlgoChatError
Errors that can occur during AlgoChat operations.
MessageDirection
Direction of a message relative to the current user.
PendingStatus
Status of a pending message in the send queue.

Constants§

DEFAULT_DISCOVERY_PAGE_SIZE
Default page size for key discovery pagination.
ED25519_SIGNATURE_SIZE
Size of an Ed25519 signature (64 bytes).
ENCRYPTED_SENDER_KEY_SIZE
Size of the encrypted sender key (32-byte key + 16-byte tag).
ENCRYPTION_INFO_PREFIX
Encryption info prefix for message encryption.
HEADER_SIZE
Size of the envelope header in bytes.
KEY_DERIVATION_INFO
Key derivation info.
KEY_DERIVATION_SALT
Key derivation salt.
MAX_PAYLOAD_SIZE
Maximum payload size in bytes.
MINIMUM_PAYMENT
Minimum payment amount in microAlgos (0.001 ALGO).
NONCE_SIZE
Size of the nonce in bytes.
PROTOCOL_ID
Protocol ID byte.
PROTOCOL_VERSION
Protocol version byte.
PSK_COUNTER_WINDOW
Counter window for replay protection.
PSK_ENCRYPTED_SENDER_KEY_SIZE
Size of the encrypted sender key (32-byte key + 16-byte tag).
PSK_HEADER_SIZE
Size of the PSK envelope header in bytes.
PSK_MAX_PAYLOAD_SIZE
Maximum payload size in bytes for PSK messages.
PSK_PROTOCOL_ID
PSK protocol ID byte (0x02 distinguishes from standard 0x01).
PSK_SESSION_SIZE
Number of positions in a single session before rotating.
PSK_TAG_SIZE
Size of the authentication tag in bytes.
PSK_VERSION
PSK protocol version byte.
PUBLIC_KEY_SIZE
Size of a public key in bytes.
SENDER_KEY_INFO_PREFIX
Sender key info prefix for bidirectional decryption.
SIGNATURE_SIZE
Size of an Ed25519 signature in bytes.
TAG_SIZE
Size of the authentication tag in bytes.

Traits§

AlgodClient
Trait for interacting with an Algorand node (algod).
EncryptionKeyStorage
Trait for storing encryption private keys.
IndexerClient
Trait for interacting with an Algorand indexer.
MessageCache
Trait for storing and retrieving messages.

Functions§

decode_psk_envelope
Decodes bytes into a PSK envelope.
decrypt_message
Decrypt a message from an envelope.
decrypt_psk_message
Decrypts a PSK message envelope.
derive_hybrid_symmetric_key
Derives a hybrid symmetric key combining ECDH shared secret and PSK.
derive_keys_from_seed
Derive X25519 key pair from a 32-byte seed using HKDF-SHA256.
derive_position_psk
Derives a position PSK from a session PSK and position within the session.
derive_psk_at_counter
Derives the PSK at a given ratchet counter value.
derive_sender_key
Derives a sender key for bidirectional decryption with PSK.
derive_session_psk
Derives a session PSK from the initial PSK and session index.
discover_encryption_key
Discovers the encryption public key for an Algorand address.
discover_encryption_key_paginated
Discovers the encryption public key with configurable pagination.
encode_psk_envelope
Encodes a PSK envelope to bytes.
encrypt_message
Encrypt a message for a recipient.
encrypt_psk_message
Encrypts a message using the PSK protocol.
fingerprint
Generates a human-readable fingerprint for an encryption public key.
generate_ephemeral_keypair
Generate a random ephemeral X25519 key pair for message encryption.
is_chat_message
Check if data looks like a valid AlgoChat envelope.
is_psk_message
Checks if data looks like a valid PSK message.
sign_encryption_key
Signs an encryption public key with an Ed25519 signing key.
verify_encryption_key
Verifies that an encryption public key was signed by an Ed25519 key.
verify_encryption_key_bytes
Verifies an encryption key using raw Ed25519 public key bytes.
x25519_ecdh
Perform X25519 ECDH key exchange.

Type Aliases§

Result