# FHE Consensus

## Mind Network's Research Results:

* Academic Publication: Mind Network researched and developed to enable a new encrypted consensus through FHE (paper title: Enabling Encrypted Consensus through Fully HomomorphicEncryption in Proof of Intelligence Mechanisms). The research paper is under publication peer-review and can share upon request.
* FHE Consensus Node (FCN): [Repo](https://github.com/mind-network/mind-sdk-fcn-rust), [Crates](https://crates.io/crates/mind_sdk_fcn).<br>

## Mind Network's Research Details:

🔍 In **Mind Network**, FHE validators vote in Hubs and are known as Hub Independent Validators (SIV). This improved POS mechanism is termed POSIV (POS with Independent Validation). We've developed [SDKs](https://github.com/mind-network/Awesome-Mind-Network) in multiple languages to facilitate FHE Validation. SIVs encrypt their votes using a specified FHE Public Key and submit them to the FHE Validation Consensus. To participate in validation, SIVs must register, meet staking criteria, and opt-in to specific validation tasks. The end-to-end flow architecture are like bellow:

<figure><img src="https://1430718782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhJfyUe1I7P47fzKlldpK%2Fuploads%2FVCPRMYdWep7Mg14EuPsC%2F1280X1280.PNG?alt=media&#x26;token=92c3c6d4-62ca-4762-b582-7c85b7e0ea74" alt=""><figcaption></figcaption></figure>

### 🔍 **Understanding POSIV**

In this section, we'll delve into reaching consensus for FHE validation work post private voting and upon receiving all encrypted votes. It comprises four main components: **POSIV\_Input**, **POSIV\_Output**, **POSIV\_Consensus**, and optionally, **POSIV\_Decryption**.

<figure><img src="https://1430718782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhJfyUe1I7P47fzKlldpK%2Fuploads%2FLCRMIDhdBWmUtxYAaqXA%2F1280X1280%20(1).PNG?alt=media&#x26;token=a688c15b-5134-41de-8116-449f8a776a62" alt=""><figcaption></figcaption></figure>

### **POSIV\_Input** 📥

POSIV\_Input gathers encrypted votes from each SIV and records them as immutable data for verification. Its size and voting windows are defined by the Hub. For instance, the Hub can decide to:

* Accept a fixed number of initial votes (e.g., `fixCountCriteria=100 SIVs`)
* Begin consensus after a fixed time period (e.g., `fixIntervalCriteria=1 minute`)
* Accept a fixed portion of opt-in SIVs (e.g., `fixPercentageCriteria=70% of Opt-in SIVs`)
* Or a combination of these criteria. Once criteria are met, POSIV\_Input stops receiving new private voting entries and triggers POSIV\_Consensus.<br>

### **POSIV\_Consensus** 🤝

**POSIV\_Consensus** activates after **POSIV\_Input** and conducts a determined FHE Computation, converting an array of FHE encrypted values into one. The FHE Activation Function (`fheActivationFunction`) is specified by Hub in the Task Definition, for example`fheMean`, `fheAverage`, `fheMajority`, `fheRank`, etc. **POSIV\_Consensus** is a Hub dedicated focus on FHE Validation Consensus and in permissionless mode to accept FCN (FHE Consensus Node). Each FCN can opt-in a particular task and run the `fheActivationFunction` and send the result to **POSIV\_Output**. Let us take **fheAverage** as an example. Each FCN will run **fheAverage** on all the stake by encrypted votes and send to **POSIV\_Output**.

<figure><img src="https://1430718782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhJfyUe1I7P47fzKlldpK%2Fuploads%2Fo8elVNPxFJAag0jSrFWY%2F1280X1280%20(2).PNG?alt=media&#x26;token=3b45cb40-27f1-4b89-917d-27c24a67c837" alt=""><figcaption></figcaption></figure>

### **POSIV\_Output** 📊

Since `fheActivationFunction` is deterministic, each FCN should generate the same output with the same **POSIV\_Input**. Thus, **POSIV\_Output** conducts majority votes by checking if 2/3 FCNs respond to the same encrypted value, similar to classical POS consensus. It represents the output of FHE Consensus from all FCN responses.<br>

### **POSIV\_Decryption** 🔑

Some Hubs prefer complete control and conduct `fheDecrypt` by themselves or a trusted party, completing the consensus here. Others may use Mind for `fheDecrypt`, where POSIV\_Decryption comes into play. POSIV\_Decryption focuses on FHE Validation Decryption with FDNs (FHE Decryption Nodes). Each FDN decrypts a portion and aggregates to the final true result in POSIV\_Output. The decrypted result can be directly consumed by RPC or trigger calls to other smart contracts, or for example, to distribute rewards.

<figure><img src="https://1430718782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhJfyUe1I7P47fzKlldpK%2Fuploads%2Fg07i132gWpXl359FU3cI%2F1280X1280%20(3).PNG?alt=media&#x26;token=59ccfddc-17a1-4cd2-b70d-02bc85187677" alt=""><figcaption></figcaption></figure>

<figure><img src="https://mindnetwork.sg.larksuite.com/space/api/box/stream/download/asynccode/?code=ODAwY2QzZDhmZDI4NDc0ZGI1MTM3NzBhNmZhYjkxYzFfb2tkVW5nNlVPNDc0U3lOZGRUeDhlWWRDZU94QUtXa0FfVG9rZW46VUhGUGJTUnE1b1dFRXR4bVk2QWw5RjcyZzNiXzE3NDE2NjE1MjY6MTc0MTY2NTEyNl9WNA" alt=""><figcaption></figcaption></figure>
