VOIX: messages on chain (tier 1)
Protocol and consensus12.5.9+

VOIX: messages on chain (tier 1)

Messages on chain: announcements weighed by burn, directed and sealed messages with a stamp, and the node message box.

VOIX tier 1 puts messages in OP_RETURN outputs: public announcements weighed by the coins they burn, and directed messages, in clear text or sealed to the recipient's key, that pay the recipient a stamp. The node indexes them in the module voix, keeps the public key seen on chain for each address (for sealing to an address that published nothing), opens the records sealed to its own message box, and serves the public part under /api/v1/voice/*. The phone book records (types 0x10 to 0x15, same LOKAD id) are indexed by the module book; the onion-routed tier 2 is P2P only. The specification is doc/research/VOIX-PROTOCOL-12.5.8.md section 5; the byte formats are in doc/voix/formats.md and the test vectors in doc/voix/vectors/.

Status in this node #

  • Built-in module voix (class CVoixModule, src/modules/voix/voix_module.cpp), registered after eMPP and the phone book (src/modules/builtin_modules.cpp): it reads the block's eMPP segments and the recipients' prices from the book, both already indexed for the same block. It can be left out with -modules; eMPP is then still added for it when listed.
  • Database: <datadir>/modules/voix.sqlite.
  • Node message box: <datadir>/voix/box.sqlite (src/voix/box.cpp), local only, never served by REST. Node box keys M and B: random, made at first start, kept in node.sqlite (node_state key voix.nodebox, src/voix/nodekeys.cpp).
  • Indexing only: no consensus or relay rule. A malformed record is skipped.
  • LOKAD id: "VOIX" = 56 4f 49 58.
  • Sending (sendmessage, sendannouncement) is refused on mainnet with voix_review_pending until the external review of the formats (decision D19, constant VOIX_MAINNET_SEND_ENABLED in src/voix/node.h); a dry run works. Indexing runs on every chain.
  • No new node option.

Envelope #

TransportScript shapeDecoder
bareOP_RETURN <one canonical push: "VOIX" + body>voix::DecodeScript (src/voix/records.cpp)
eMPPOP_RETURN OP_RESERVED <push "VOIX" + body> [other segments]eMPP module (SegmentsForBlock), then voix::DecodeBody

One record per output: the first body of the output that decodes as MSG, SEALED, RECEIPT or DIGEST. A record is identified by its outpoint (txid, vout). The burn of a record is the value of its OP_RETURN output.

Byte layout #

Common header (research note 3.2): version | type | flags, then the type fields. The version is 02 for a signed record (MSG with a signer, DIGEST with a signer) and 01 otherwise; a signed record of version 01 (12.5.8 format) is not indexed (reason old_format_v1, owner decision M8, doc/voix/formats.md section 2.1). Integers are little-endian. An outpoint in a record is 34 bytes: txid in internal byte order, then vout as u16.

TypeNameFields
0x01MSGaudience u8; flag bit 0 topic (u8 n + [a-z0-9._-], 1..32); bit 1 reply_to (34); bit 2 supersedes (34); bit 3 expiry (u32 height); bit 4 to (u8 n, n × u16 output index, n = 1..16); bit 5 lang (2 ASCII lower case); bit 6 signer (33-byte key + 64-byte Schnorr signature over TH("lotus-voix v2 txsig", TH("lotus-voix v1 msg", magic ‖ body without the signature) ‖ outputs_digest), where outputs_digest is the SHA-256 of every other output of the transaction, value u64 LE ‖ varint len ‖ script, in order); then the content to the end: UTF-8 text up to 7,900 bytes, or with bit 7 a 32-byte BLOB id
0x02SEALEDflag bit 0 stealth; scheme u8 (01); view_tag u8; E (33); ciphertext of the padded inner message + 16-byte Poly1305 tag
0x40DIGESTfirst_height u32, last_height u32, count u32, Merkle root (32); flag bit 0: signer key (33) + signature (64)
0x41RECEIPTdigest (32) = SHA-256 of a tier 2 sealed body; to u8 = output index of the stamp, ff with flag bit 0 (stealth)

Sealing (research 5.3 with the tags of spec 3.2): ECDH with a fresh ephemeral key, HKDF-SHA256 with salt lotus-voix v1 seal, ChaCha20-Poly1305; the inner message is u8 flags [33 sender key ‖ 64 signature] [34 reply subject] [part, parts, 8-byte group] MSG body, padded with 80 00… to a multiple of 64 bytes. The inner signature covers TH("lotus-voix v1 inner", magic ‖ M ‖ inner without the signature), so a message cannot be re-sealed to someone else.

Validation rules #

Applied by CVoixModule::IndexTxLocked for each output:

  1. Author (research 3.1): the signer key when MSG flag bit 6 or DIGEST flag bit 0 is set, and the record is skipped if that signature fails; else the key of input 0 when it is a P2PKH spend (<sig> <33-byte key>) or a Taproot key-path spend (one push; the key is the commitment of the spent output, from voix_taproot_outs); else none (author_source none, empty author).
  2. Recipients. MSG with to: each index must name another, spendable output of the transaction, once; otherwise the record is skipped. SEALED: the output right after the record (vout + 1), when it exists and is spendable, is the recipient's (or, with stealth, the stealth stamp's) output. RECEIPT: the output to; with stealth, vout + 1. The stamp of a recipient is its output's value.
  3. Kind. An MSG without to and with audience 0 is skipped (neither an announcement nor directed). An MSG without to and audience ≠ 0 is an announcement. MSG with to, SEALED and RECEIPT are directed. A directed record with neither stamp nor burn is not indexed.
  4. Floor (D7) for an announcement: 1 XPI when the author has no listed announcement in the last 720 blocks; else 1 XPI × 2^k, where k is the streak of the author's last listed announcement (k = 1 for the first of a streak, k + 1 for each one within 720 blocks of the previous). Level above_floor when burn ≥ floor, else below_floor. Only above_floor announcements count in a streak. Anonymous announcements share one streak (author ""). The doubling stops at 2^40. Aged stake (D5, D14) is not counted yet.
  5. Prices (D8) for a directed record: each recipient's accept_price and notify_price come from the phone book (the subject covering the recipient's script) when the book module provides them, else the defaults 0.01 XPI and 0.04 XPI; a stealth recipient always uses the defaults. A recipient is priced_ok when its stamp ≥ accept_price, notify when ≥ notify_price. The record's level is priced_ok when one recipient is, else below_price.
  6. Edit and retraction. A MSG with supersedes marks the named MSG as superseded (superseded_by) when both have the same, non-empty author. Empty content is a retraction. The chain keeps both.

Indexing #

Tables of voix.sqlite (CVoixModule::CreateSchema):

TableKeyContent
voix_records(txid, vout)height, time, position, type, flags, envelope, author, author source, audience, topic, reply_to, supersedes, expiry, lang, burn, floor, streak, level, notify, content (clear MSG only), view tag and E (SEALED), size, digest or root, superseded_by (and its height), above_223, the record body
voix_recipients(txid, vout, n)output index, script, stamp, prices used, priced_ok, notify, stealth, height
voix_keysscriptpublic key and first height, from every P2PKH spend (p2pkh_spend) and every Taproot output (taproot_output): the key a sender may seal to (D12)
voix_taproot_outs(txid, vout)commitment of every Taproot output, for the input-0 author of a key-path spend
voix_meta, voix_tip_historytip_height, tip_hash, schema version; the last 10,000 block hashes

Block flow: one transaction per block writes the rows, the tip and its history. Disconnect and RollbackToHeight delete every row above the height, clear superseded_by set above it, and drop the node box copies of chain messages above it (the wallet inbox passes go back to the same height). Rescan (rescanmodule voix) reindexes a range with INSERT OR IGNORE: an indexed range is unchanged. Mempool records are not indexed.

Every SEALED record is also tried with the node box key M (one ECDH and a view tag check); what opens is stored in the node message box (box node). The node box also receives tier 2 bodies from the onion part (voix::DeliverInbound, box node, tier onion).

REST API #

All routes are public, answer through api::WriteSuccess, and check their path depth (404 unknown_subroute).

MethodPathDescription
GET/api/v1/voice/messages?audience=&topic=&level=&from_height=&limit=Announcements at level above_floor only (D13), not superseded, not expired, newest first. audience matches any common bit (or 255). level other than above_floor: 400 level_not_public. limit 1..500, default 50
GET/api/v1/voice/messages/<txid>/<vout>One record with its recipients, its body (hex), its listed replies and its history (the records it superseded). An announcement below the floor answers 404 not_found
GET/api/v1/voice/inbox/<address>?from_height=&limit=Directed records with an output to that address (clear MSG, SEALED envelopes, RECEIPTs), with priced_ok and notify per recipient
GET/api/v1/voice/sealed?from_height=&limit=View tag, E, size and stealth flag of every SEALED record, oldest first, for trial decryption; complete and last_height for paging
GET/api/v1/voice/keys/<address>known, pubkey, height, source of the key seen for the address (D12), and the prices a sender should pay
GET/api/v1/voice/statsCount and burn per type, count per level, keys known, book_available
GET / POST/api/v1/voice/rescan403 rescan_moved (rescans are on the RPC)

A record (/messages/<txid>/<vout>, inbox) has: txid, vout, height, time, type, flags, envelope, author (null when none), author_source (signer, input0, none), burn_sats, level, notify, size, above_223, recipients[] (output, address, stamp_sats, accept_price_sats, notify_price_sats, prices_from_book, priced_ok, notify, stealth); MSG: audience, topic, reply_to, supersedes, expiry, lang, floor_sats (announcements), text or blob, retraction, superseded_by; SEALED: view_tag, E, stealth; RECEIPT: digest, stealth; DIGEST: root.

RPC #

Authenticated JSON-RPC only.

MethodDoes
sendmessage <recipient> <text> {mode, stamp, burn, sign, stealth, clear, reply_to, topic, lang, from, dry_run}recipient: address, handle, 33-byte key or kind-1 subject (hex), node fingerprint. Sealed to the phone book M, else to the address key seen on chain (D12), else a clear MSG with a warning. mode: chain (record + stamp output at index 1, change last), onion (sealed body through the onion part, error onion_unavailable / no_route), both (RECEIPT with digest = H(body) and the stamp, then the body with lane = the receipt outpoint), default: onion when the recipient has a route and the onion part runs, else chain. Stamp default: max(0.04242 XPI, recipient's accept_price). A sent copy goes to the node box. Wallet RPC
sendannouncement <text> {audience, topic, lang, burn, expiry, reply_to, supersedes, from, dry_run}MSG signed by the author key (the wallet address from, default the address labelled voix); burn defaults to the author's current floor. Wallet RPC
listmessages {box, from, unread, include_unpriced, limit, rescan}The node box and the wallet inboxes (directed records to the wallets' scripts, sealed records their keys open; copied into the box at each call). box: node, wallet:<name>, sent, all. Below-price chain messages from non-contacts are hidden unless include_unpriced. box: "chain" (with from_height, type): the indexed records at every level
readmessage <id> [mark_read], deletemessage <id>Local store only: a record on chain cannot be deleted
voixcontacts add\|remove\|list\|block\|mute [who] [label]Local contacts; blocked senders are never listed, muted ones do not notify
getvoixinfoNode box public keys (M, B, mailbox_id), box counts, module tip, book_available, onion_available, send_allowed

Limits and edge cases #

  • The floor and the prices are listing rules of this module, not consensus: a record below them is on chain for ever and listed by the RPC.
  • The floor counts confirmed announcements only: two announcements of one author in the mempool are both priced at the same floor, and the later one may land below it.
  • Prices are read from the phone book's current state when the block is indexed; a rescan after a price change uses the new price.
  • Anyone can evade the doubling floor with a new key: the floor makes a key's voice cost more, not a person's.
  • A stealth SEALED record directed to a wallet's address key is not found by the wallet inbox (the wallet would have to try every key); stealth is meant for phone book messaging keys and the node box.
  • Sealing to a Taproot address uses the commitment as the key; a Taproot output with a script tree and an unspendable internal key cannot read what is sealed to it.
  • What sealed mail on a chain does not give (research 5.5): no forward secrecy, no protection against a future break of secp256k1, the funding inputs link the sender, no deniability when signed.

Source files #

  • src/modules/voix/voix_module.{h,cpp}: indexing, REST, wallet inbox pass.
  • src/voix/box.{h,cpp}: node message box; src/voix/nodekeys.{h,cpp}: node box keys.
  • src/voix/directory.{h,cpp}: seam to the phone book (lookups, prices); src/voix/chainview.{h,cpp}: floor, keys and the D19 gate for the senders.
  • src/voix/records.{h,cpp}, src/voix/seal.{h,cpp}: formats and sealing (core library).
  • src/rpc/voix.cpp, src/wallet/rpcvoix.cpp: RPCs.
  • Tests: src/test/voix_module_tests.cpp, test/functional/feature_voix_chain.py.
Source doc/protocols/voix.md in the lotusd repository