Pinaivu-AI/contracts. Three modules, each building on the one
before it:
pinaivu::enclave
EnclaveConfig<ENCLAVE>— shared object holding the expected PCR triple. The admin holdingCap<ENCLAVE>rotates PCRs after every reproducible build viaupdate_pcrs.Enclave<ENCLAVE>— shared object created byregister_enclaveafter a fresh NSM attestation document is verified against the config’s PCRs. Stores the Ed25519 pubkey extracted from that document.verify_signature<ENCLAVE, P: drop>(enclave, intent, timestamp_ms, payload, signature)— wraps the payload in anIntentMessage, BCS-encodes it, and verifies with Sui’sed25519precompile.
pinaivu::receipts
Payout { sui_address: address, amount: u64 }ReceiptPayload { request_id: vector<u8>, aggregated_output_hash: vector<u8>, payouts: vector<Payout> }verify_completion_receipt(enclave, timestamp_ms, request_id, hash, payouts, &signature)— convenience wrapper that callsenclave::verify_signature::<ENCLAVE, ReceiptPayload>(...)with the reservedINTENT_ROUTING_RECEIPT = 1intent scope.
pinaivu::vault
A treasury model — Pinaivu pre-funds a shared Balance<T> per
supported coin type. Clients do not deposit per request (see the
honest centralization caveat
about this being an intentional simplification, not the long-term design).
settle aborts unless:
(request_id, payee)hasn’t been settled beforeverify_completion_receipt(...)returns true (signature valid)(payee, amount)appears in thepayoutslist- The treasury has enough balance left
TreasuryToppedUp + Settled events for the off-chain explorer to
index.
Why settle is safe even if the coordinator operator key leaks
The operator key (held by the in-enclave sidecar) signs and submits
the settle() PTB but does not authorise the disbursement. The
disbursement is authorised by the separate enclave-attested Ed25519
key (registered via register_enclave) which signs the
ReceiptPayload BCS bytes. The sidecar cannot forge that signature — only
the coordinator running attested code can.
A compromised operator key can pay gas to submit valid receipts faster, or
DOS the vault by submitting bogus PTBs (they all abort without moving
money). It cannot drain funds. This split is the practical expression of
the Sui pillar described in Decentralization & verifiability model.
Deploy outline
Coordinator registration
Registration is authoritative on the EC2 host, not inside the enclave. The in-enclave path still runs in parallel (capped retries) for redundancy, but its calls go through the sidecar’s HTTPS bridge to Sui RPC and tend to lose a race againstupdate_pcrs: when an enclave’s NSM
attestation contains PCRs that differ from EnclaveConfig.pcrs on-chain,
register_enclave aborts with EInvalidPcrs. The host-side path runs
update_pcrs first and therefore always converges.
The host’s scripts/register-coordinator.sh:
- Parses
out/coordinator.pcrs. - Calls
enclave::update_pcrsso the on-chainEnclaveConfig<ENCLAVE>matches this build’s PCRs. - Fetches the live enclave’s NSM document from
GET /get_attestation. - Converts the attestation bytes into a Sui CLI PTB vector literal.
- Chains
0x2::nitro_attestation::load_nitro_attestation→pinaivu::enclave::register_enclave<ENCLAVE>(config, cap, doc)in a single transaction. - Extracts the new
Enclave<ENCLAVE>shared object id from the transaction’s object changes. - Persists
PINAIVU_ENCLAVE_OBJECT_IDso the next enclave boot picks it up automatically. - Pushes the new id into the currently running coordinator via an
authenticated admin endpoint, so
vault::settlecalls work in the same deploy that registered.
Why Sui
Why this is built on Move + Nautilus + Walrus specifically, not “a chain”
Glossary
PCR, NSM, EIF, IntentMessage, and every other term used on this page