DEV Community

A Travel Rule gate where the verdict is public and the customer data is not

The FATF Travel Rule (Recommendation 16) asks a virtual-asset service provider to collect and pass on originator and beneficiary information with a transfer. Data-protection law asks the same provider to minimise that information and keep it away from anyone who does not need it. On a transparent chain those two demands collide: either the identity data goes on chain, or the compliance check happens somewhere nobody can verify.

At DPO2U we are building a gate in Compact, Midnight's smart-contract language, that splits the problem along a different line: the verdict is public, the data is shielded. This post walks through how it works and where its limits are.

What goes on chain and what doesn't

The contract's state separates cleanly:

  • Public: a per-transfer verdict (PASS or FAIL), a coarse reason code, a root commitment of each party's data, the hash of the policy that produced the verdict, and the metadata of any disclosure grant.

  • Shielded: names, account identifiers, document numbers and the amount. They enter the circuit as witnesses and never touch the ledger.

struct Party {
  name_hash: Bytes<32>;
  account_hash: Bytes<32>;
  doc_hash: Bytes<32>;
  vasp_id: Bytes<32>;
  salt: Bytes<32>;
}
witness originator_data(): Party;
witness beneficiary_data(): Party;
witness transfer_amount(): Uint<64>;
Enter fullscreen mode Exit fullscreen mode

The rule runs inside the proof

evaluateTransfer reads the private witnesses and computes the verdict in-circuit:

const complete = o.name_hash != zero && o.account_hash != zero
              && b.name_hash != zero && b.account_hash != zero;
const above = amt >= threshold_cents;
const id_ok = !above || o.doc_hash != zero;
const vasp_ok = attested_vasps.member(disclose(b.vasp_id)) || passport.isValid(disclose(b.vasp_id));
Enter fullscreen mode Exit fullscreen mode

The reason code is deliberately coarse: 1 missing party info, 2 missing originator ID above the threshold, 3 counterparty VASP not attested, 4 sanctions hit. An observer learns that a transfer failed and roughly why, not who was involved or how much moved.

Two details matter for auditors. The amount is compared against the threshold inside the proof, so the threshold is public but the amount is not. And every verdict stores policy_hash, so you can later prove which version of the rule produced it.

Per-field commitments, so one field can be opened alone

Each party's data is committed field by field, with a label so that opening one field reveals nothing about the others:

export pure circuit field_commit(v: Bytes<32>, salt: Bytes<32>, label: Bytes<32>): Bytes<32> {
  const s = persistentHash<Vector<2, Bytes<32>>>([salt, label]);
  return persistentCommit<Bytes<32>>(v, s);
}
Enter fullscreen mode Exit fullscreen mode

The four commitments are hashed into a root stored on chain. A supervisor who receives one field off chain can recompute the root from that opening plus the other three commitments, and check it against the ledger.

Linked contracts (Ledger 9)

With contract-to-contract calls on Midnight, the gate checks two other contracts directly:

  • the counterparty VASP passes if this VASP attested it or it holds a valid passport in a PsavPassport contract;

  • releaseTransfer reverts unless this VASP itself holds a current attestation in a ComplianceRegistry contract.

assert(registry.hasAttestation(self_company_id) == 1,
       "VASP has no compliance attestation in the registry");
Enter fullscreen mode Exit fullscreen mode

No off-chain orchestrator has to be trusted to have run those checks.

Signed sanctions lists

Proving non-membership in a sanctions list inside the circuit is still an open problem for us (a naive Set.member on a private hash would publish the hash). What the gate does prove is which list the screening was made against: the list snapshot has to be signed with Schnorr over Jubjub by a registered provider, and still valid at block time.

assert(blockTimeLt(disclose(l.valid_until)), "Sanctions list expired");
const ok = jubjubSchnorrVerify<4>(sanctions_message(l.list_root, l.provider_id, l.issued_at, l.valid_until),
                                  l.signature, sanctions_provider_key.lookup(id));
assert(disclose(ok), "Sanctions list signature invalid");
Enter fullscreen mode Exit fullscreen mode

The "not on the list" statement remains the VASP's, but it is now bound to a signed, unexpired list that is recorded with the verdict.

Four eyes before anyone sees data

A supervisor can get access, but not on the operator's say-so alone. The VASP owner requests a grant with a scope bitmask (name, account, document, VASP), an expiry and the hash of its legal basis. The grant stays inactive until a separate approver key, typically the DPO, calls approveDisclosure. The constructor refuses an approver equal to the owner.

export circuit isGrantActive(grant_id: Bytes<32>): Boolean {
  return grant_scope.member(disclose(grant_id))
      && grant_approved.member(disclose(grant_id))
      && !grant_revoked.member(disclose(grant_id))
      && blockTimeLt(grant_expires.lookup(disclose(grant_id)));
}
Enter fullscreen mode Exit fullscreen mode

The data itself travels off chain, encrypted per grant. The chain holds the proof that access was requested, approved, scoped and time-limited.

Honest limits

Sanctions non-membership is attested by the VASP, not proven in-circuit.
The counterparty VASP id is public on purpose: it is a regulated entity's identity, not customer data.
The "viewing key" is an application-level per-grant key, not a Midnight wallet viewing key.
The v10 version with linked contracts has been checked with compactc 0.36.0 and in the simulator; it has not been exercised on a public network yet.

Why Midnight

disclose() is the part I keep coming back to. In Compact, private data cannot reach public state unless you wrap it explicitly, so the list of everything this gate makes public is literally a grep away. For a compliance product, that turns "we minimise data" from a policy statement into something an examiner can check in the code.

If you are building for regulated finance on Midnight: which check would you move in-circuit first, sanctions non-membership or the amount threshold per corridor?

Top comments (0)