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§
- Account
Info - Account information.
- Algo
Chat - The main AlgoChat client for encrypted messaging.
- Algo
Chat Config - Configuration for the AlgoChat client.
- Algorand
Config - Configuration for Algorand node connections.
- Chat
Account - A chat-enabled Algorand account with encryption keys.
- Chat
Envelope - AlgoChat message envelope.
- Conversation
- A conversation between two Algorand addresses.
- Decrypted
Content - Decrypted message content.
- Discovered
Key - Result of discovering a user’s encryption key.
- File
KeyStorage - File-based encryption key storage with password protection.
- InMemory
KeyStorage - In-memory implementation of EncryptionKeyStorage (for testing).
- InMemory
Message Cache - In-memory implementation of MessageCache.
- Message
- A chat message between Algorand addresses.
- Note
Transaction - 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.
- Paginated
Transactions - Paginated transaction search result.
- Pending
Message - A message queued for sending (for offline support).
- Public
KeyCache - In-memory cache for public keys with TTL expiration.
- Queue
Config - Configuration for the send queue.
- Reply
Context - Context for a reply message, linking it to the original.
- Send
Options - Options for sending a message.
- Send
Queue - A queue for managing pending outgoing messages.
- Send
Result - Result of a successful send operation.
- Suggested
Params - Suggested transaction parameters.
- Transaction
Info - Transaction information returned after submission.
Enums§
- Algo
Chat Error - Errors that can occur during AlgoChat operations.
- Message
Direction - Direction of a message relative to the current user.
- Pending
Status - 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§
- Algod
Client - Trait for interacting with an Algorand node (algod).
- Encryption
KeyStorage - Trait for storing encryption private keys.
- Indexer
Client - Trait for interacting with an Algorand indexer.
- Message
Cache - 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.