Skip to content
 
 

Repository files navigation

Privacy-Preserving AI Bounty Judge

This submission upgrades the workshop bounty judge from public answers to a commit-reveal flow. The Solidity contract works on any EVM chain and still uses Ritual's LLM precompile for one batched judging request after answers are revealed.

Project Layout

  • hardhat/contracts/AIJudge.sol - commit-reveal bounty contract.
  • web/ - Next.js UI updated for commit and reveal phases.
  • docs/ARCHITECTURE.md - architecture note, including the Ritual-native hidden submission design.
  • docs/TEST_PLAN.md - reveal-case test plan.

Commit-Reveal Lifecycle

  1. The bounty owner calls createBounty(title, rubric, deadline) with ETH reward.
  2. Before deadline, a participant keeps their plaintext answer private and generates a random bytes32 salt.
  3. The participant computes commitment = keccak256(abi.encode(answer, salt, msg.sender, bountyId)).
  4. The participant calls submitCommitment(uint256 bountyId, bytes32 commitment). Only the hash is public on-chain.
  5. After deadline, the participant calls revealAnswer(uint256 bountyId, string calldata answer, bytes32 salt).
  6. The contract recomputes the commitment using the revealed answer, salt, sender, and bounty id. If it matches, the answer is stored as a revealed submission.
  7. The bounty owner calls judgeAll(uint256 bountyId, bytes calldata llmInput). The UI builds one batch prompt containing all valid revealed submissions.
  8. After the AI review is stored, the owner calls finalizeWinner(uint256 bountyId, uint256 winnerIndex) to pay the selected revealed submitter.

Required Functions

  • submitCommitment(uint256 bountyId, bytes32 commitment)
  • revealAnswer(uint256 bountyId, string calldata answer, bytes32 salt)
  • judgeAll(uint256 bountyId, bytes calldata llmInput)
  • finalizeWinner(uint256 bountyId, uint256 winnerIndex)

Security Properties

  • Answers are hidden during the submission phase because only commitment hashes are public.
  • Commitments are bound to msg.sender and bountyId, so another address cannot reveal someone else's commitment or reuse it on another bounty.
  • Participants cannot change an answer after committing unless they can find a hash collision.
  • Only revealed submissions are eligible for AI judging.
  • finalizeWinner validates the winner index before paying the reward.

Reflection

The bounty title, rubric, reward, deadline, commitment hashes, judging status, final winner, and payment should be public because participants need a shared source of truth. Plaintext answers should stay hidden during the submission phase so nobody can copy, remix, or front-run another participant's idea. Salts should also stay private until reveal, because the salt is what prevents observers from guessing common answers and checking the hash. The AI should evaluate revealed submissions against the rubric, summarize tradeoffs, and recommend a winner from a clearly delimited batch of entries. A human bounty owner should decide whether the AI result is acceptable, handle subjective edge cases, and finalize the actual winner. The system should make AI decisions auditable but not blindly automatic, because bounty quality can include context, ethics, and intent that may not fit inside one model response. The fairest design is one where the chain enforces timing and payouts, cryptography protects submissions, AI helps scale review, and humans remain accountable for final judgment.

About

Building and deploying an on-chain AI bounty judge on Ritual - 23.06.2026

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages