Skip to content

feat(examples): add multi-chain TDIP delegation chain example#27

Closed
hilarl wants to merge 1 commit intoagent-intent:mainfrom
hilarl:tenzro/multichain-tdip-example
Closed

feat(examples): add multi-chain TDIP delegation chain example#27
hilarl wants to merge 1 commit intoagent-intent:mainfrom
hilarl:tenzro/multichain-tdip-example

Conversation

@hilarl
Copy link
Copy Markdown

@hilarl hilarl commented May 2, 2026

examples: add multi-chain delegation example with Plonky3 cart-hash anchoring

Follow-up to #25 (which introduced protocol-landscape/tenzro-tdip.md

Motivation

TDIP's DelegationScope already lists allowed_chains as a first-
class axis alongside max_transaction_value, max_daily_spend,
allowed_operations, allowed_payment_protocols, and time_bound. Of
those six axes, allowed_chains is the most-tested in the upstream
Rust crate (crates/tenzro-identity/src/delegation.rs) but the
least-demonstrated in any portable example — partly because
single-VM agentic-commerce demos rarely surface it.

This example fills that gap. A single VI L1 + L2 + four per-purchase
L3a records drive purchases across four Tenzro VM facades:

  • Ethereum via wTNZO ERC-20 pointer (0x7a4bcb...)
  • Solana via wTNZO-SPL adapter
  • Canton via TNZO CIP-56 holding
  • Polygon not in allowed_chains — rejected with the typed
    ChainNotAllowed reason.

Each accepted purchase generates a Plonky3 STARK over a canonical cart
payload, computes the 32-byte
compute_zk_commitment(circuit_id, proof_bytes, public_inputs) =
SHA-256(circuit_id ‖ proof_bytes ‖ Σ(len_le(pi) ‖ pi)), and records
it in a mock ZkCommitmentRegistry. The VI L3a transaction_id carries
the same canonical cart hash, so the off-chain VI record and the
on-chain ZK commitment are cross-verifiable — useful for the case where
a merchant on chain X wants to confirm an authorization that settled on
chain Y.

What's in this PR

examples/tenzro_did_chain_multichain.py (new, ~520 lines)

Self-contained, mocks both TDIP and the on-chain registry. With
TENZRO_RPC_URL set (e.g. https://rpc.tenzro.network), the example
issues real tenzro_createZkProof JSON-RPC calls instead of computing
proof bytes locally. The five-ceiling check at the heart of the
example:

  1. VI chain validity (verify_chain)
  2. VI per-purchase constraints (check_constraints)
  3. TDIP DelegationScope::enforce_operation — operation, value,
    protocol, time
  4. TDIP DelegationScope.allowed_chains membership (per-VM gate)
  5. TDIP runtime SpendingPolicy::check

(In the Rust source, (3) and (4) are a single enforce_operation call;
the Python mock surfaces the chain check separately to make the
denial path readable.)

pytest examples/tenzro_did_chain_multichain.py is green; the example
asserts every accepted purchase settles, asserts the denied purchase
fails specifically on ChainNotAllowed, and asserts each accepted
purchase produces a unique 32-byte commitment.

protocol-landscape/tenzro-tdip.md (extension, no new file)

Adds a single subsection — Multi-chain delegation enforcement — to
the file landed in #25. The patch is provided as a separate
tenzro-tdip.patch.md describing exactly where the new prose goes;
the maintainer can squash it into the merged file. If the maintainer
prefers the patch lifted into a separate tenzro-tdip-multichain.md
(parallel to how UCP/AP2/ACP each have their own page), I'll respin.

Files

examples/tenzro_did_chain_multichain.py     # new, ~520 lines
protocol-landscape/tenzro-tdip.md           # extended (one new subsection)

No changes to spec/. No changes to src/. No changes to existing
protocol-landscape/ pages other than the same tenzro-tdip.md
extended via this PR.

Tests

  • pytest clean against this PR.
  • python examples/tenzro_did_chain_multichain.py runs end-to-end and
    prints the same banner-formatted output style as autonomous_flow.py
    and tenzro_tdip_flow.py from docs(protocol-landscape): add Tenzro TDIP integration mapping + example #25.
  • All four ceilings are asserted per accepted purchase; the denied
    purchase is asserted to fail specifically on the chain gate.

SDK consistency

No SDK changes are required. The example uses only the existing
verifiable_intent SDK surface (create_layer1, create_layer2_autonomous,
create_layer3_payment, verify_chain, check_constraints,
build_selective_presentation, decode_sd_jwt, resolve_disclosures,
hash_disclosure). The TDIP primitives and ZkCommitmentRegistry are
mocked locally in the example file. Pointers to the real Rust
implementations:

  • crates/tenzro-identity/src/delegation.rsDelegationScope,
    is_chain_allowed
  • crates/tenzro-zkcompute_zk_commitment, ZkCommitmentRegistry
    hash construction
  • crates/tenzro-vm/src/precompiles.rsZK_VERIFY precompile
    (O(1) HashSet lookup)

Protocol-agnostic language

The VI core spec (spec/) is unchanged. All TDIP- and chain-specific
language lives in protocol-landscape/tenzro-tdip.md and the new
example. The example deliberately uses Tenzro testnet endpoints
(rpc.tenzro.network) and marks Solana / Canton facade addresses as
placeholders; nothing is mainnet-specific.

DCO sign-off

All commits in this PR carry Signed-off-by: Hilal Agil <hilal@tenzro.com>.

AI assistance disclosure

Per the project's contribution norms: parts of the wording in this PR
description, the patch to tenzro-tdip.md, and code comments in the
example were prepared with AI assistance from Claude Code. All
technical decisions, the multi-chain mapping itself, and final wording
were reviewed and authored by the human author (Hilal Agil,
hilal@tenzro.com). The TDIP and Plonky3 reference implementations in
tenzro/tenzro-network were developed independently.

Checklist

  • PR title in Conventional Commits format:
    examples: add multi-chain delegation example with Plonky3 cart-hash anchoring.
  • Every commit Signed-off-by (DCO).
  • No changes to spec/ (TDIP-specific content stays in
    protocol-landscape/).
  • Single new example file under examples/.
  • pytest clean against the change.
  • Example exercised end-to-end and asserts the four-plus-chain
    ceiling pattern.
  • No new SDK changes required; verifiable_intent surface is
    unchanged.
  • References docs(protocol-landscape): add Tenzro TDIP integration mapping + example #25 and complements (does not duplicate) its
    single-chain example.

New runnable example demonstrating a single Verifiable Intent L1 + L2 + four L3a delegation records spanning Ethereum (wTNZO), Solana (wTNZO-SPL), Canton (CIP-56), and a denial scenario (Polygon).

Signed-off-by: Hilal Agil <hilaal@gmail.com>
@hilarl
Copy link
Copy Markdown
Author

hilarl commented May 3, 2026

Withdrawing.

@hilarl hilarl closed this May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant