Skip to content

Document the wire-format invariants in one place, referenced from all three languages #344

Description

@Otaiki1

Context

Three independent implementations must agree byte for byte, and a disagreement is silent until a
claim fails on-chain with InvalidProof:

  1. The circuit's public signal order (circuits/membership.template.circom + the generated component main {public [...]} line).
  2. The contract's public_inputs vector order (contracts/sharibo/src/lib.rs, in claim).
  3. The SDK's G1/G2 byte encoding and field-element serialisation (packages/client/src/prove.ts).

Plus the external nullifier derivation, which is implemented twice — compute_external_nullifier in
Rust and computeExternalNullifier in TypeScript — and must produce identical values.

Each site has good comments. None of them is authoritative, and the recipient-binding work will change
the signal order in all three at once.

Where to build it

  • New file docs/wire-format.md.
  • circuits/membership.template.circom, contracts/sharibo/src/lib.rs, packages/client/src/prove.ts — replace the local prose with a pointer to the document.
  • test-vectors/ — the fixtures that make it checkable.

What to do

  • Specify the public signal order, with the index each signal occupies and the rule for adding a new one.
  • Specify the external nullifier derivation: SHA-256 over big-endian u64 circle_id || u32 round, reduced mod r. Note that both implementations must agree on byte order, and point at the test that proves it.
  • Specify the G1/G2 encoding: compression, endianness, byte lengths.
  • Specify vk.ic length as public_inputs + 1.
  • Add a "changing this" checklist naming every file that must move together.

Acceptance criteria

  • All three implementations point at this document instead of describing the format themselves.
  • The document is validated by the committed test vectors, not just prose.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programarchitectureSystem structure & module boundariesdocumentationImprovements or additions to documentationsecuritySecurity & robustness

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions