# Example

## Example: Commit-Reveal Scoring (Inference Subnet)

The **inference-subnet** built on the Hypertensor template demonstrates a powerful example of decentralized coordination using a **commit-reveal** model. This model ensures fairness, verifiability, and resistance to manipulation during scoring phases for both **hosters** and **validators**.

### Commit-Reveal Workflow Example

This subnet divides each epoch into **phases**, where nodes submit **commits** (cryptographic hashes of data) followed by **reveals** (the actual data), enabling transparent scoring without early data leaks.

### **Step-by-Step Process:**

1. **Validator Prompt Commit (0-15%)**
   * At the start of the epoch, the **elected validator** publishes a **randomized prompt tensor** to the DHT.
   * This prompt is validated using a **Pydantic schema** to ensure proper format and tensor structure.
   * If the validator doesn't submit one by the 10% mark of the epoch, anyone can take over this task.
2. **Randomized Seed  (0-15%)** ⸺ Score multiplier
   * At the start of the epoch, the **elected validator** publishes a **randomized float** to the DHT.
   * This prompt is validated using a **Pydantic schema** to ensure it's a float and is verified to be between the minimum and maximum values.
   * If the validator doesn't submit one by the 10% mark of the epoch, anyone can take over this task.
3. **Hoster Inference & Commit Phase (15-50%)**
   * Each **hoster** runs inference on the validator’s prompt.
   * Instead of revealing the output immediately, each hoster commits a **hash** of the result (e.g., `SHA256(salt + tensor)`).
   * This hash is stored in the DHT to prevent tampering or early reveals.
4. **Reveal Phase (50-60%)**
   * After the commit phase ends (based on epoch progress), each **hoster reveals** their output and salt.
   * The **validator** also reveals its own **score commit** from the previous epoch (i.e., the scores it assigned to each hoster).
   * These reveals are matched against the original commits to verify integrity later when scored.
5. **Scoring (60-100%)**
   * **Hosters** are scored based on the **distance of their output** from the **mean tensor** across all valid hoster reveals.
   * **Validators** are scored based on:
     * The **accuracy** of their revealed scores
     * How closely their scores align with the previous validator's on-chain scores in relation to the attestation ratio.
6. **Validator Commit Scores (60-100%)**
   * Validators commit a hash of their scores to the DHT that is revealed on the following epoch.

***

#### [Predicate Validator](/subnet-template/dht-records/record-validator/predicate-validator.md) Integration

All commit and reveal actions are **validated by a `PredicateValidator`**, which:

* Enforces **phase correctness** (e.g., commits and reveals in specific periods of an epoch)
* Ensures each record (commit or reveal) is **schema-compliant** and **authenticated**
* Prevents out-of-order or invalid submissions

***

#### Authentication Requirement

Every reveal must be cryptographically linked to its original commit using the same keypair. This ensures:

* No node can **forge or steal** another node’s output
* Scores are only assigned to **authenticated participants**

***

#### Why This Matters

This design enables decentralized, trustless coordination and evaluation of AI work — all without central servers or privileged roles.

> 🔐 The commit-reveal model ensures fairness, resists manipulation, and enables transparent peer scoring at scale.

## Overview

<figure><img src="/files/hQ9ONKIor1nJ4036xwvR" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hypertensor.org/build-a-subnet/consensus/scoring/example.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
