Files
meshcore-spec/versions/v0.1.0/07-payload-anon-req.md
T
swaitsandClaude Opus 4.7 f83d4088e3 spec: link corpus references to GitHub, version-aware
Every "Test vectors: \`corpus/...\`" mention in the spec is now a
markdown link pointing at the corresponding file or directory on
GitHub. Each version build resolves its links to the correct git
ref:

  - /latest/ -> https://github.com/swaits/meshcore-spec/tree/main/corpus/...
  - /v0.1.0/ -> https://github.com/swaits/meshcore-spec/tree/v0.1.0/corpus/...
  - future /vX.Y.Z/ -> /tree/vX.Y.Z/corpus/...

Two changes:

1. src/*.md (18 files): the inline-code corpus paths in each
   "Cross-References" section are now markdown links. Directories
   point at /tree/main/corpus/..., individual .json files point at
   /blob/main/corpus/.... CHANGELOG and other non-corpus main links
   are intentionally left pointing at main — the canonical history
   lives there regardless of which version you're reading.

2. justfile: `cut-version` now also runs a sed over the snapshot's
   *.md files replacing /tree/main/corpus -> /tree/<VERSION>/corpus
   and /blob/main/corpus -> /blob/<VERSION>/corpus. So a freshly-cut
   version is self-consistent.

versions/v0.1.0/* regenerated by re-running
`just cut-version v0.1.0` after the new src/ links + recipe sed
landed.

Tagging the release commit (`git tag v0.1.0`) is now REQUIRED — not
"optional" — because the rendered /v0.1.0/ pages reference
/tree/v0.1.0/corpus/... on GitHub. Without the tag the links 404.
cut-version's output now says so.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 10:35:09 -06:00

2.9 KiB
Raw Blame History

MeshCore Protocol Specification

Section 7: Payload — Anonymous Request

Overview

The anonymous request payload allows a node to send an encrypted message to a recipient without the recipient needing to know the sender in advance. Instead of a 1-byte source hash, the full 32-byte Ed25519 public key of the sender is included, enabling the recipient to compute the shared secret for decryption.

Payload Type

Header payload type field: 0x07 (ANON_REQ)

Wire Format

 0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| dest_hash(1)  |                                               |
+-+-+-+-+-+-+-+-+                                               |
|                   Sender Public Key (32 bytes)                |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    Cipher MAC (2 bytes)       |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
|              Ciphertext (N × 16 bytes, N ≥ 1)                |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Fields

Field Offset Size Type Description
dest_hash 0 1 byte raw First byte of recipient's Ed25519 public key
sender_pub_key 1 32 bytes raw Full Ed25519 public key of sender
cipher_mac 33 2 bytes raw Truncated HMAC-SHA256 over ciphertext
ciphertext 35 variable (multiple of 16) raw AES-128-ECB encrypted data

Minimum Size

  • Minimum payload: 1 + 32 + 2 + 16 = 51 bytes

Encryption

  1. Sender computes ECDH shared secret using its private key and the recipient's public key.
  2. Encrypt plaintext using AES-128-ECB with first 16 bytes of shared secret.
  3. Compute HMAC-SHA256 over ciphertext with full 32-byte shared secret. Truncate to 2 bytes.
  4. Assemble: dest_hash || sender_pub_key || MAC || ciphertext.

Decryption

  1. Read dest_hash. If it does not match this node, the packet is not for us (but MAY be forwarded).
  2. Read 32-byte sender_pub_key. Construct an Identity from it.
  3. Compute ECDH shared secret between this node's private key and sender's public key.
  4. Verify the MAC and decrypt as in Section 14.

Cross-References

Reference Implementation

  • Mesh::createAnonDatagram() in src/Mesh.cpp — Encoding
  • Mesh::onRecvPacket(), case PAYLOAD_TYPE_ANON_REQ — Decoding