> For the complete documentation index, see [llms.txt](https://comfox.gitbook.io/comfox-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://comfox.gitbook.io/comfox-docs/zero-knowledge-proof-for-referral-rewards-distribution.md).

# Zero-Knowledge Proof for Referral Rewards Distribution

Referral rewards are calculated off-chain using Merkle trees and verified on-chain <mark style="color:red;">(off-chain computation, on-chain proof)</mark>. The source data for the Merkle tree is entirely derived from on-chain data. Anyone can use third-party tools or write their own code to calculate the Merkle tree's Root value and compare it with the Root value stored in the MiningPool contract to verify the authenticity of reward distribution.<br>

<figure><img src="https://1923163131-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9sV7xh9MuRYozRL9PDF%2Fuploads%2Fma5GucfrXYC0AHygPzsP%2Fimage.png?alt=media&amp;token=31769978-6f69-44be-a240-c55d19926c8f" alt=""><figcaption></figcaption></figure>

1. How to Obtain Your Reward Proof?

For example, Account 1's reward proof consists of the following data: User1, Rewards1, Hash2, Hash34—essentially all data related to calculating the Root value.

<br>

2. What is a Zero-Knowledge Proof?

When submitting reward proof data to the smart contract, the contract calculates the Root value. If the calculated Root value matches the one stored in the contract, the proof is valid, and rewards can be claimed. Before users submit reward proof data to the contract, the contract only stores a Root value and no other user reward data. Yet, it can verify how much reward a user should receive—this is the essence of zero-knowledge proof.

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://comfox.gitbook.io/comfox-docs/zero-knowledge-proof-for-referral-rewards-distribution.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
