Zero-Knowledge Proof for Referral Rewards Distribution
Last updated
Last updated
Referral rewards are calculated off-chain using Merkle trees and verified on-chain (off-chain computation, on-chain proof). 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.
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.
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.