Log entry format
The bytes of a post, of its payload and of its transaction, and the Log entry the API serves for it.
A Log entry is one post instruction in a confirmed Transaction V1. Everything in it is in the instruction data and the transaction's one signature. This page gives those bytes in order, and the JSON object the API builds from them.
Post instruction data#
Arguments follow Anchor's discriminator in Borsh. Field elements are 32-byte big-endian scalars; the day is a little-endian u64.
| Offset | Bytes | Field | Content |
|---|---|---|---|
| 0 | 8 | discriminator | [223, 96, 234, 236, 158, 106, 145, 94] |
| 8 | 64 | proof A | The A point, negated: x, then q − y, each 32 bytes big-endian. |
| 72 | 128 | proof B | The B point: x.c1, x.c0, y.c1, y.c0, each 32 bytes big-endian. |
| 200 | 64 | proof C | The C point: x, then y. |
| 264 | 32 | root | The pool root the proof was made against. |
| 296 | 8 | day | The day number, u64 little-endian. |
| 304 | 32 | nullifier | Poseidon(secret, day, counter). |
| 336 | 4 | payload length | u32 little-endian. |
| 340 | n | payload | The payload. |
q is the BN254 base field modulus. The proof is 256 bytes in all, the form groth16-solana verifies. The instruction data is 340 + n bytes.
Payload version 1#
The payload is a header of 211 bytes, two key slots of 105 bytes each after a version byte, and then the ciphertext.
| Offset | Bytes | Field | Content |
|---|---|---|---|
| 0 | 1 | version | 1 |
| 1 | 32 | slot 0 ephemeral key | A fresh X25519 public key for this slot. |
| 33 | 1 | slot 0 view tag | The first byte of SHA-256(shared secret). |
| 34 | 72 | slot 0 wrapped key | The content key, sealed. |
| 106 | 32 | slot 1 ephemeral key | A fresh X25519 public key for this slot. |
| 138 | 1 | slot 1 view tag | |
| 139 | 72 | slot 1 wrapped key | |
| 211 | m | ciphertext | The encrypted body. |
Slot 0 opens the message for its reader: the reader's inbox key, a room's key or a private link's key. Slot 1 opens it for the writer's own inbox key, so the writer's other devices read their sent messages back.
A wrapped key is 72 bytes: a 24-byte nonce, the 32-byte content key encrypted with XChaCha20-Poly1305, and its 16-byte tag. The ciphertext is a 24-byte nonce, the encrypted body, and a 16-byte tag; its additional data is the whole 211-byte header, so a changed slot fails to open. Cryptography gives every key and the body inside.
Sizes#
The smallest payload the program accepts is 251 bytes: the 211-byte header and a 40-byte ciphertext, the nonce and tag around an empty body.
The post transaction is 688 + n bytes for a payload of n bytes, which makes the largest payload 3,408 bytes within the 4,096-byte limit. A relay refuses a larger payload with PAYLOAD_TOO_LARGE.
| Figure | Bytes |
|---|---|
| Largest payload | 3,408 |
| Largest ciphertext, nonce and tag included | 3,197 |
| Largest body before encryption | 3,157 |
| ASCII text characters in one part, in the SDK's body | 2,614 |
| Text the SDK puts in one part | 700 UTF-8 bytes |
| Measured sample transaction | 1,540, with a 852-byte payload |
A transaction of exactly 4,096 bytes with a real proof was simulated and accepted; one byte more was refused. The body's JSON, its two MACs and non-ASCII text take part of the room, so the SDK splits text at 700 UTF-8 bytes a part, one post per part.
Payload hash#
The proof binds the payload through one public input:
payloadHash = 0x00 || SHA-256(payload)[0..31]
That is, the first 31 bytes of the SHA-256 digest of the whole payload, read as a big-endian integer below 2^248, so it fits the BN254 field. The program computes it from the instruction data, and a relay checks that the payload it is given hashes to the payloadHash of the proof's public inputs before it signs.
The post transaction#
A post is a Transaction V1 with one instruction and one signature, the relay's. It names seven keys: the six accounts of post and the program id.
| # | Account | Writable | Signer |
|---|---|---|---|
| 0 | relay | yes | yes |
| 1 | config | ||
| 2 | pool | ||
| 3 | vault | yes | |
| 4 | nullifier | yes | |
| 5 | system program |
The relay builds the bytes in this order:
| Bytes | Content |
|---|---|
| 1 | 0x81: transaction version 1 |
| 1 | required signatures: 1 |
| 1 | read-only signed accounts: 0 |
| 1 | read-only unsigned accounts: 4 |
| 4 | configuration mask, u32 LE: 12 |
| 32 | recent blockhash |
| 1 | instruction count: 1 |
| 1 | key count: 7 |
| 224 | the seven keys, the relay first |
| 4 | compute unit limit, u32 LE |
| 4 | loaded account data limit, u32 LE: 1,048,576 |
| 4 | instruction header: program key index (u8), account count 6 (u8), data length (u16 LE) |
| 6 | account key indexes |
| 340 + n | instruction data |
| 64 | the relay's Ed25519 signature over everything before it |
The message carries no compute budget instruction: the limit sits in the header's configuration. The writer and the reader appear nowhere in it.
Decoding an entry#
Fetch the transaction
Read it with
getTransactionandmaxSupportedTransactionVersion: 1. A Log entry is only a successful transaction.Find the post
Take each top-level instruction whose program is
5hJVoxABR1b9QqnQ7FfZDtY2fgNGkUsQtPBqjyBLPTU3and whose data begins with the post discriminator. A post nested in another program's call is not an entry. The entry's relay is the instruction'srelayaccount, the signer the Vault paid; a relay sends the transaction as version 1 with itself as the only signer.Split the data
Cut the fields at the offsets above, then split the payload at bytes 1, 106 and 211.
Rebuild the public inputs
root,dayandnullifieras given, the payload hash as above, and the relay address as two 128-bit limbs: its 32 bytes read big-endian, low limbvalue mod 2^128, high limbvalue >> 128.
const POST = [223, 96, 234, 236, 158, 106, 145, 94]
const field = (bytes: Uint8Array) => BigInt('0x' + Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join(''))
export function decodePost(data: Uint8Array) {
if (!POST.every((b, i) => data[i] === b)) return null
const view = new DataView(data.buffer, data.byteOffset, data.byteLength)
const length = view.getUint32(336, true)
const payload = data.slice(340, 340 + length)
return {
proof: data.slice(8, 264),
root: field(data.slice(264, 296)),
day: view.getBigUint64(296, true),
nullifier: field(data.slice(304, 336)),
version: payload[0],
keySlots: [0, 1].map((n) => {
const at = 1 + n * 105
return { ephemeralKey: payload.slice(at, at + 32), viewTag: payload[at + 32], wrappedContentKey: payload.slice(at + 33, at + 105) }
}),
ciphertext: payload.slice(211),
}
}
The SDK exports decodePayload(payloadBase64), which returns the same split of a payload as the API's payload field.
The LogEntry object#
GET /log/entries/:signature, GET /log/head (in tail), GET /log/segments/:n and the entry events of GET /log/stream all serve this object. Integers are decimal strings, field elements are decimal strings, bytes are padded base64, times are UTC ISO 8601.
- indexstring
- The entry's position in the Log, from 0, in slot order and then in the order of the block.
Required
- signaturestring
- The transaction signature, base58.
Required
- slotstring
- The slot it landed in.
Required
- blockTimestring
- The block's time.
Required
- relaystring
- The relay's address: the
postinstruction'srelayaccount, which signed it and was paid the relay fee.Required
- daystring
- The day the proof is for:
floor(unix seconds / dayLengthSeconds).Required
- nullifierstring
- The nullifier, a field element.
Required
- rootstring
- The pool root, a field element.
Required
- proofBase64string, 256 bytes
- The proof bytes as the instruction holds them.
Required
- payloadBase64string
- The whole payload, 251 to 4,096 bytes, first byte 1.
Required
- payloadobject
- The payload split:
version(1);keySlots, two ofephemeralKey(base64, 32 bytes),viewTag(0 to 255) andwrappedContentKey(base64, 72 bytes);ciphertextBase64;ciphertextLength(40 to 3,885).Required
- publicInputsobject
root,day,nullifier,payloadHash(below 2^248) andrelay(base58).Required
- publicSignalsstring[6]
- The circuit's order: root, day, nullifier, payload hash, relay low 128 bits, relay high 128 bits.
Required
- verificationobject
status(verified,invalid,unavailableorfixture),scheme(groth16-bn254),checkedAtandmessage.verifiedmeans a confirmed program execution verified this proof against these public inputs.Required
Nothing in the object names the writer or the reader. The Log covers how entries are ordered and served, and API reference the routes.