Skip to content
Open app

Private witness encoding

AI-generated

The guest reads one vector with sp1_zkvm::io::read_vec. Use Witness::encode and Witness::decode from chainjump-protocol.

Outer integers, lengths, and counts are little-endian. Monero components retain their canonical inner serialization; binary fields contain raw bytes rather than hex text.

# Field Encoding
1 swap_id 32 raw bytes
2 recipient_address Exactly 95 ASCII bytes
3 winning_xmr_amount u64 little-endian, piconero
4 min_payment_height u64 little-endian
5 randomx_difficulty u128 little-endian
6 payment_prefix u32 byte length, then raw bytes
7 rct_base u32 byte length, then raw bytes
8 prunable_hash 32 raw bytes
9 output_index u64 little-endian
10 key_selector One byte: 0 primary, 1 additional
11 shared_secret 32-byte compressed Edwards point
12 c 32-byte canonical scalar
13 r 32-byte canonical scalar
14 miner_transaction u32 byte length, then raw bytes
15 payment_transaction_index u64 little-endian
16 miner_path u32 count, then that many 32-byte hashes
17 payment_path u32 count, then that many 32-byte hashes
18 linked_blocks u32 count, then that many u32-length-prefixed blobs
19 randomx_key Exactly 32 raw bytes

shared_secret, c, and r are the decoded outgoing-proof tuple. The guest derives the transaction ID and selected output key; neither is a separate witness field.

  • Complete vector: 1–100,000,000 bytes, inclusive.
  • linked_blocks: 1–65 blobs, or 0–64 links.
  • Tree paths: exactly the sibling count determined by transaction count/index.
  • Reject incomplete lengths, invalid inner encodings, and trailing bytes.

There are no smaller independent component byte caps. The envelope is a framing bound; all semantic checks still apply.

Take the statement from the live award. Collect the payment/miner components, select one output covering the quote, construct its outgoing proof and both inclusion paths, then link to qualifying work. Encode through the protocol library and compare the 352-byte public journal.

Native tests may inject a structural-test callback; the deployed guest executes real RandomX. Protect witness artifacts: a remote prover receives their contents.