AI Audit Flow
How to use AI to audit the complete lottery lifecycle end-to-end.
Overview
The AI Audit Flow helps verify lottery integrity using on-chain evidence and deterministic winner recomputation.
Important Disclaimer
AI assistants provide analysis assistance only. Final trust must come from on-chain data and reproducible calculations.
TLDR: Audit With AI
- Open a settled lottery and click Audit
- Export the audit package (events + accounts)
- Ask AI to recompute the draw from reveal-included participants and tickets
The Audit Flow
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Gather │────▶│ Prepare │────▶│ Query AI │
│ On-Chain Data │ │ Audit Package │ │ with Evidence │
└──────────────────┘ └──────────────────┘ └──────────────────┘
Step-by-Step Guide
Step 1: Open the Audit Modal
- Navigate to a settled lottery
- Click the Audit button
- Review event sequence and account snapshots
Step 2: Validate Event Sequence
| Event Type | What to Check |
|---|---|
| Lottery Created | Parameters and windows are sane |
| Tickets Purchased | Ticket totals and commitments are present |
| Upload Phase Began | Upload timing is valid |
| Attestation Submitted | Votes and attestation counts match |
| Reveals Uploaded | Reveals match commitment hashes (when attesters exist) |
| Winners Finalized | Winners and merkle data finalized |
| Payouts Complete | Amounts and recipients are correct |
Step 3: Ask AI Deterministic Questions
Use prompts like:
Verify Commitments
"Given these reveals (if present), verify each reveal hashes to the stored proof_of_chance_hash."
Recompute Seed
"Sort reveal-included participants by wallet, then recompute seed chain from (wallet, tickets_bought) and lottery header fields plus poc_aggregate_hash."
Recompute Draw Rounds
"For each round j, compute SHA256(0x494B494741495F5250445F56325F44524157 || seed || j_le64), modulo remaining tickets, and walk ticket ranges to select winners."
Validate Payout Commitment
"Recompute merkle root from (index, recipient, amount) winner tuples and compare with on-chain winners_merkle_root."
Human-Followable Draw Logic
Winner selection rule version: reveal-plaintext-draw-v2
- Sort reveal-included eligible participants by wallet bytes.
- Build deterministic seed from lottery fields +
poc_aggregate_hash+ participant(wallet, tickets)tuples. - For each round, hash
(seed + round)and modulo remaining tickets. - Walk ticket ranges, select winner, remove winner, repeat.
No oracle or VRF dependency is required for reproducibility.
What to Look For
Green Flags ✅
- Canonical wallet sorting is consistent
- Seed recomputation matches report seed
- Round-by-round modulo/ticket-range selection matches winners
- Merkle root matches finalized winners/payout amounts
Yellow Flags ⚠️
- Incomplete off-chain reveal evidence when attesters exist
- Unclear participant list ordering in audit tooling
- Missing commitment bytes for any winner candidate
Red Flags ❌
- Winner cannot be reproduced from seed + ticket ranges
- On-chain winners diverge from deterministic recomputation
- Merkle root mismatch for finalized payouts
Edge Case: No Attesters
If attested_count == 0, winner finalization is rejected and refunds are issued via FinalizeNoAttesters.
If attested_count > 0 but zero reveals are uploaded by deadline, refunds are also issued.
Beyond AI
For strongest assurance:
- Recompute the seed and rounds yourself from exported inputs
- Verify account snapshots directly from chain RPC/explorer
- Cross-check transaction signatures against emitted events
AI helps explain and accelerate audits, but chain data remains the source of truth.