Skip to content
Open app

ProtocolLog entry format

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.

A Log entry, field by field, as the chain holds it.

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.

OffsetBytesFieldContent
08discriminator[223, 96, 234, 236, 158, 106, 145, 94]
864proof AThe A point, negated: x, then q − y, each 32 bytes big-endian.
72128proof BThe B point: x.c1, x.c0, y.c1, y.c0, each 32 bytes big-endian.
20064proof CThe C point: x, then y.
26432rootThe pool root the proof was made against.
2968dayThe day number, u64 little-endian.
30432nullifierPoseidon(secret, day, counter).
3364payload lengthu32 little-endian.
340npayloadThe 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.

OffsetBytesFieldContent
01version1
132slot 0 ephemeral keyA fresh X25519 public key for this slot.
331slot 0 view tagThe first byte of SHA-256(shared secret).
3472slot 0 wrapped keyThe content key, sealed.
10632slot 1 ephemeral keyA fresh X25519 public key for this slot.
1381slot 1 view tag
13972slot 1 wrapped key
211mciphertextThe 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.

FigureBytes
Largest payload3,408
Largest ciphertext, nonce and tag included3,197
Largest body before encryption3,157
ASCII text characters in one part, in the SDK's body2,614
Text the SDK puts in one part700 UTF-8 bytes
Measured sample transaction1,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:

Text
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.

#AccountWritableSigner
0relayyesyes
1config
2pool
3vaultyes
4nullifieryes
5system program

The relay builds the bytes in this order:

BytesContent
10x81: transaction version 1
1required signatures: 1
1read-only signed accounts: 0
1read-only unsigned accounts: 4
4configuration mask, u32 LE: 12
32recent blockhash
1instruction count: 1
1key count: 7
224the seven keys, the relay first
4compute unit limit, u32 LE
4loaded account data limit, u32 LE: 1,048,576
4instruction header: program key index (u8), account count 6 (u8), data length (u16 LE)
6account key indexes
340 + ninstruction data
64the 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#

  1. Fetch the transaction

    Read it with getTransaction and maxSupportedTransactionVersion: 1. A Log entry is only a successful transaction.

  2. Find the post

    Take each top-level instruction whose program is 5hJVoxABR1b9QqnQ7FfZDtY2fgNGkUsQtPBqjyBLPTU3 and 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's relay account, the signer the Vault paid; a relay sends the transaction as version 1 with itself as the only signer.

  3. Split the data

    Cut the fields at the offsets above, then split the payload at bytes 1, 106 and 211.

  4. Rebuild the public inputs

    root, day and nullifier as given, the payload hash as above, and the relay address as two 128-bit limbs: its 32 bytes read big-endian, low limb value mod 2^128, high limb value >> 128.

decode-post.ts
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 post instruction's relay account, 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 of ephemeralKey (base64, 32 bytes), viewTag (0 to 255) and wrappedContentKey (base64, 72 bytes); ciphertextBase64; ciphertextLength (40 to 3,885).

Required

publicInputsobject
root, day, nullifier, payloadHash (below 2^248) and relay (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, unavailable or fixture), scheme (groth16-bn254), checkedAt and message. verified means 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.