# Consensus Mechanism

The L1X blockchain utilizes a two-tiered hybrid consensus mechanism, known as Proof of X (PoX), to achieve consensus among decentralized nodes regarding transaction validity and chronological order. This innovative approach incentivizes both active participation and stakeholding, striking a balance between the interests of users and stakeholders. It represents a forward-thinking and dynamic method of consensus building within the L1X network.

In the L1X PoX consensus, mobile devices with limited computation and memory capacity are empowered to actively participate in the consensus process by continuously tracking and sharing the latest state of the blockchain. This inclusive approach allows even mobile devices to contribute to the consensus, enhancing the overall decentralization and resilience of the network.

Meanwhile, full nodes within the L1X blockchain play a critical role in consensus by holding and staking L1X coins. By staking their tokens, these nodes demonstrate their commitment to the network and earn the right to validate transactions and propose new blocks. This stakeholding mechanism ensures that participants with a vested interest in the network have influence over the consensus process.

The design principles of the L1X blockchain, coupled with the PoX consensus mechanism, offer several advantages. Firstly, it incentivizes active participation from both mobile devices and full nodes, fostering a more inclusive and diverse network. Secondly, it balances the interests of users and stakeholders, promoting fairness and transparency in consensus building. Lastly, this dynamic approach allows for adaptability and scalability as the network grows, ensuring its long-term viability and effectiveness.



## L1X Consensus Mechanism Working <a href="#toc140645913" id="toc140645913"></a>

Transactions in byte format, such as RLP (Recursive Length Prefix), are received by L1X full nodes through the RPC (Remote Procedure Call). The full nodes append a Receival Timestamp to the transactions before initiating transaction authentication. During this authentication process, various aspects of the transaction, including its structure, balance sufficiency, addresses, and digital signature, are meticulously verified. Once authenticated, an Authentication Timestamp is added, and the transaction is forwarded to the MemPool.

The MemPool, or Memory Pool, serves as a storage mechanism for unconfirmed transactions. In L1X, user accounts are partitioned into Clustered Databases to enhance efficiency. Each Clustered Database holds the account states for a specific subset of users. Mobile nodes maintain the Cluster Registry, which maps account records to the corresponding full nodes. By periodically synchronizing the Cluster Registry from mobile nodes, the full nodes ensure that up-to-date information is available.

Leveraging the Cluster Registry, the MemPool identifies the relevant clusters and the associated full nodes that hold the Clustered Databases containing the account records relevant to the transaction. The transaction is broadcasted to all the pertinent cluster nodes. Subsequently, these nodes perform Non-Technical Validation, an essential step involving the verification of smart contracts, adherence to predefined rules, testing edge cases, and confirming transaction accuracy. This validation process ensures the overall integrity of the blockchain.

Beyond the Clustered Databases and Cluster Registry, full nodes also maintain the Stake Registry. The Stake Registry records which full nodes have staked tokens to participate in consensus and propose blocks. This information is stored locally within each full node. Random selection of a Block Proposer ensures true randomization outcomes while maintaining privacy by applying homomorphic encryption to node identities. The chosen Block Proposer constructs the block and applies Zero Knowledge Proof (ZKP) to enable succinct and fast verification of block. The block, along with the ZKP proof, is exclusively broadcasted to the relevant cluster nodes. Full nodes validate the integrity or correctness of block with much smaller proof sizes and transmit it for further validation.

In cases where a transaction involves accounts across different Clustered Databases, Cross Cluster Messaging is employed to facilitate data sharing. The Aggregated Cluster Checkpoint plays a pivotal role in this process by maintaining the last updated timestamp for each full node's Clustered Database. Regular synchronization between full nodes and mobile nodes ensures that the Clustered Databases and Aggregated Cluster Checkpoint remain consistently updated.

The implementation of Hierarchical Temporal Memory enables real-time detection of malicious nodes by identifying abnormal transaction patterns. This robust security mechanism is applied both during the transaction submission phase and when blocks are broadcasted across the network, actively safeguarding the L1X blockchain network against malicious activities.

The consensus mechanism of the L1X blockchain, thus, employs multiple stages, including transaction authentication, Non-Technical Validation, block proposal, and data synchronization. These stages, combined with techniques like homomorphic encryption and Hierarchical Temporal Memory, ensure the integrity, security, and privacy of the L1X blockchain network, providing a robust and trustworthy decentralized ecosystem.



## Block Proposer Selection: True Randomization and Homomorphic Encryption <a href="#toc140645914" id="toc140645914"></a>

In the L1X blockchain, the process of selecting a block proposer plays a critical role in maintaining the security and fairness of the network. The block proposer is responsible for creating and adding new blocks to the blockchain, contributing to the overall consensus mechanism. To ensure the integrity and robustness of the blockchain, a randomized algorithm is employed for the selection of the block proposer.

### **PoX Consensus Metrics**

In the quest for achieving consensus and decentralization, the participation of network participants holds the utmost importance. Trust in the L1X blockchain network and the availability of trusted participants are crucial factors that drive the success and sustainability of the blockchain ecosystem. To address this, a mechanism that efficiently considers both old and new participants in the PoX consensus is proposed. By incorporating metrics such as StakeScore, KinScore, and XScore, we aim to evaluate participants' stake holdings, active involvement, and adherence to security measures. These metrics play a vital role in achieving consensus, promoting decentralization, and ensuring the integrity and security of the network. In the subsequent sections, we will delve into the significance of each metric, highlighting their importance in maintaining a robust and reliable PoX consensus mechanism.

* **StakeScore**: This is a measure of a node's commitment to the network, based on the amount of L1X coins they have staked, the length of time they have been staking, and the length of time they have agreed to lock up their coins. A high StakeScore indicates that a node is more likely to behave honestly, as they have more to lose if they are caught cheating.
* **KinScore**: This is a measure of a node's reliability and trustworthiness, based on their uptime, participation history, response time, and security measures. A high KinScore indicates that a node is more likely to be able to participate in the consensus process reliably and without disruption.
* **XScore**: This is a combined measure of StakeScore and KinScore, which is used to determine which nodes are eligible to participate in the PoX consensus. A higher XScore indicates that a node is more likely to be a reliable and trustworthy participant in the consensus process.

The PoX consensus metrics are designed to achieve consensus and decentralization by rewarding nodes that are committed to the network, reliable, and trustworthy. By ensuring that the network is sufficiently decentralized, the PoX consensus helps to protect the network from attack and ensure that it is fair and transparent.

### **PoX Consensus Process**

XScore, StakeScore, and KinScore are integral components of the sophisticated block proposer selection process in the L1X blockchain ecosystem.

![Figure 2 PoX Consensus Process](https://2881198403-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4R4yL4HyysdEvMsBOUt3%2Fuploads%2F2gyAESYnNwGvZf8pKMZp%2F6.jpeg?alt=media)

To calculate XScore, the process considers all nodes that have staked a minimum balance and are actively available within the network. These nodes undergo evaluation to determine their XScore, which subsequently plays a significant role in determining their eligibility for the next epoch of the consensus process. Nodes with an XScore exceeding the defined XScore Threshold (that varies based on network dynamics) are deemed eligible for participation.

To ensure data privacy and security, homomorphic encryption is applied to XScore. This cryptographic technique enables computations to be performed on encrypted data without compromising its confidentiality. By leveraging homomorphic encryption, the privacy of XScore calculations is preserved, allowing for a secure evaluation process.

Furthermore, a randomized algorithm is applied to the homomorphically encrypted XScores. This algorithm introduces an element of randomness in the selection of the block proposer. By employing a randomized approach, the consensus protocol mitigates potential biases and ensures a fair and decentralized block proposer selection process.

Overall, the intricate interplay between XScore, StakeScore, KinScore, homomorphic encryption, and randomized algorithms forms a robust framework that enables accurate evaluation, privacy preservation, and fair selection within the L1X blockchain network. The randomness injected into the selection process prevents any undue advantage or bias towards specific nodes, fostering a level playing field for all participants. Furthermore, the use of homomorphic encryption ensures that the privacy of the nodes is preserved, enhancing the overall security posture of the L1X blockchain.

## PoX Mathematical Model <a href="#toc140645915" id="toc140645915"></a>

Multi-objective optimization is a fundamental concept in mathematical optimization that involves optimizing multiple objective functions while considering a set of constraints. In the context of blockchain consensus, the StakeScore, KinScore, and XScore calculation problem can be viewed as a multi-objective optimization problem. This problem aims to simultaneously optimize groups of conflicting objectives in order to achieve an optimal solution.

### **Stakescore Multi-Objective Model**

Let USS represent the Universal set for Stake Score. A general Stake Score metric combines Stake Balance, Stake Age and Locking Period. To consider the relative importance of objectives, the selection model is formulated by the weighted arithmetic mean operator.

#### **Stake Balance Membership Function**

Let _sb_ represent the fuzzy set of Stake Balance. Since, a large Stake Balance indicates more trust in the network and willingness to invest, its membership function for a node _i_ can be defined as:

`USS(`_`sbi`_`) =`` `_`sbi – sbmin`_` ``/`` `_`sbmax -sbmin`_` ``if`` `_`sbmin <= sbi`_ _`<= sbmax`_

`USS(`_`sbi`_`) = 0, if`` `_`sbmin > sbi`_

`USS(`_`sbi`_`)=1, if`` `_`sbmax < sbi`_

A value of Stake Balance _sbi_ close to maximum stake balance _sbmax_ indicates that the node is committed to network success and hence, can be considered for consensus process.

#### **Stake Age Membership Function**

Let fuzzy set of Stake Age be represented by _sa_. Since, a longer Stake Age indicates commitment to the network, its membership function for a node _i_ can be defined as:

`USS(`_`sai`_`) =`` `_`sai – samin / samax - samin`_` ``if`` `_`samin <= sai <= samax`_

`USS(`_`sai`_`) = 0, if`` `_`samin > sai`_

`USS(`_`sai`_`) = 1, if`` `_`samax < sai`_

A value of Stake Age _sai_ close to maximum stake age _samax_ indicates that the node has trust in the network and is therefore, committed to network by investing tokens since a longer period of time and hence, is a suitable candidate for consensus process.

#### **Locking Period Membership Function**

Let _lp_ represent the fuzzy set of Locking Period. A longer Locking Period indicates sense of responsibility and dedication. Therefore, its membership function for a node _i_ can be defined as:

`USS(`_`lpi`_`) =`` `_`lpi`_` ``–`` `_`lpmin / lpmax - lpmin`_` ``if`` `_`lpmin`_` ``<=`` `_`lpi`_` ``<=`` `_`lpmax`_

`USS(`_`lpi`_`) = 0, if`` `_`lpmin`_` ``>`` `_`lpi`_

`USS(`_`lpi`_`) = 1, if`` `_`lpmax`_` ``<`` `_`lpi`_

A value of Locking Period _lpi_ close to the maximum locking period _lpmax_ indicates that the node doesn’t have opportunistic behaviour and is dedicated as it is willing to stake coins for a considerably longer period. It is a good consensus candidate.

#### **StakeScore Weighted Arithmetic Model**

To consider the relative importance of objectives, the selection model is formulated by the weighted arithmetic mean operator i.e., Maximize U\*WT

`wsb + wsa + wlp = 1, for wsb, wsa, wlp ϵ [0,1]`&#x20;

`where Wss is the weight vector containing wsb,`&#x20;

`wsa, wlp wsb means the weight of stake balance,`

`wsa means the weight of stake age,`

`wlp means the weight of locking period.`

Thus, weight factors will help the model to be flexible and can be used to evaluate significance of each parameter to maximize StakeScore. The degree of overall satisfaction is the sum of all membership values. The fuzzy decision may be considered as the choice that satisfies all of the objectives.

_`λSS(i)`_` ``= wsb*USS(`_`sbi`_`) + wsa*USS(`_`sai`_`) + wlp*USS(`_`lpi`_`)`



### **Kinscore Multi-Objective Model**

Let UKS represent the Universal set for KinScore. A general KinScore metric combines Uptime, Active Participation History, Response Time and Security Measure. To consider the relative importance of objectives, the selection model is formulated by the weighted arithmetic mean operator.

#### Uptime Membership Function

Let _ut_ represent the fuzzy set of Uptime for a node. A node _i_ with larger uptime contributes to maintaining stable network, therefore its membership function can be defined as:

`UKS(`_`uti`_`) =`` `_`uti - utmin / utmax - utmin`_` ``if`` `_`utmin <= uti <= utmax`_

`UKS(`_`uti`_`) = 0, if`` `_`utmin > uti`_

`UKS(`_`uti`_`) =1, if`` `_`utmax < uti`_

A value of Uptime _uti_ close to maximum uptime _utmax_ indicates that the node is committed to network success and hence, can be considered for consensus process.

#### Active Participation History Membership Function

Let _ph_ represent the fuzzy set of active participation history. A node _i_ actively involved in transaction validation and block proposal is a significant contributor to the network consensus. Its membership function can be defined as:

`UKS(`_`phi`_`) =`` `_`phi - phmin / phmax - phmin`_` ``if`` `_`phmin <= phi <= phmax`_

`UKS(`_`phi`_`) = 0, if`` `_`phmin > phi`_

`UKS(`_`phi`_`) =1, if`` `_`phmax < phi`_

A value of _phi_ close to maximum active participation history _phmax_ indicates that the node is actively engaged in efficient and reliable PoX consensus, making it a good candidate for further consensus process.

#### Response Time Membership Function

Let _rt_ represent the fuzzy set of Response Time for a node. A node _i_ with a smaller response time is quickly validating the transactions and therefore its membership function can be defined as:&#x20;

`UKS(`_`rti`_`) =`` `_`rtmax - rti / rtmax - rtmin`_` ``if`` `_`rtmin <= rti <= rtmax`_

`UKS(`_`rti`_`) = 1, if`` `_`rtmin > rti`_

`UKS(`_`rti`_`) = 0, if`` `_`rtmax < rti`_

A value of Response Time _rti_ close to minimum response time _rtmin_ indicates that the node has a low latency and is making the L1X network more responsive and faster. Such a node is suitable for the consensus process.

#### Security Measures Membership Function

Let _sm_ represent the fuzzy set of Security measures for a node. A node _i_ with more security measures is making the L1X network secure and reliable, therefore its membership function can be defined as:

`UKS(`_`smi`_`) =`` `_`smi - smmin / smmax - smmin`_` ``if`` `_`smmin <= smi <= smmax`_

`UKS(`_`smi`_`) = 0, if`` `_`smmin > smi`_

`UKS(`_`smi`_`) = 1, if`` `_`smmax < smi`_

A value of Security Measure _smi_ close to the maximum Security Measure _smmax_ indicates that the node is genuine and concerned about the overall security of the L1X network. It is, therefore, a suitable candidate for consensus process.

#### KinScore Weighted Arithmetic Model

To consider the relative importance of objectives, the selection model is formulated by the weighted arithmetic mean operator. Maximize U\*WT

`WKS = wut + wph + wrt + wsm = 1, for wut, wph, wrt, wsm ϵ [0,1]`

`where WKS is the weight vector containing wut, wph, wrt, wsm`

`wut means the weight of uptime,`

`wph means the weight of active participation history,`

`wrt means the weight of response time,`

`wsm means the weight of security measures.`

Thus, weight factors will help the model to be flexible and can be used to evaluate the significance of each parameter to maximize KinScore. The degree of overall satisfaction is the sum of all membership values. The fuzzy decision may be considered as the choice that satisfies all of the objectives.

_`λKS(i)`_` ``= wut*UKS(`_`uti`_`) + wph*UKS(`_`phi`_`) + wrt*UKS(`_`rti`_`) + wsm*UKS(`_`smi`_`)`

#### **Xscore Weighted Arithmetic Model**

XScore is a combination of StakeScore and KinScore. Weighted Arithmetic Model is also employed for XScore so that flexibility in the PoX consensus can be easily provided. This feature will help to customize consensus as per business requirements.

`WXS = WSS + WKS = 1, for WSS, WKS ϵ [0,1]`

where WXS is the weight vector containing wss and wks wss means the weight of StakeScore,

wks means the weight of KinScore.

The fuzzy decision may be considered as the choice that satisfies all of the objectives.

_`λXS(i)`_` ``= WSS`_`*λSS +`_` ``WKS`_`*λKS`_

`where`` `_`λXS(i)`_` ``is the XScore of the node`` `_`i`_`.`

Based on the XScore Threshold (_TXS_), all the nodes having XScore greater than the threshold are suitable candidates for the consensus process in the next epoch. For nodes n in the network, this can be represented as:

`∀ i, 1 ≤ i ≤ n:`

if _λXS(i)_ > _TXS_, then Node _i_ is a suitable candidate for the consensus process in the next epoch.



## Zero Knowledge Proof <a href="#toc140645916" id="toc140645916"></a>

The Block Proposer applies Zero Knowledge Proof (ZKP) on the block created and then broadcasts it in the network. Applying ZKP to the block before broadcasting it to the network serves multiple purposes. It ensures the integrity and correctness of the block by verifying that it adheres to the predefined rules and structure of the blockchain. This prevents the inclusion of invalid or malicious transactions in the block, enhancing the overall security of the network.

The application of ZKP in the L1X blockchain also leads to improved network efficiency. Since the block undergoes ZKP before broadcasting, the size of the block is significantly reduced. This reduction in block size enables faster transmission and lower latency within the network. Consequently, the overall performance and scalability of the L1X blockchain are enhanced, allowing for a smoother and more efficient consensus process.

## &#x20;<a href="#toc140645917" id="toc140645917"></a>

## Malicious Node Detection – Hierarchical Temporal Memory <a href="#toc140645917" id="toc140645917"></a>

Hierarchical Temporal Memory (HTM) is a powerful machine learning algorithm renowned for its ability to identify anomalies in temporal patterns. In the context of blockchain technology, where maintaining security is of utmost importance, HTM serves as a valuable tool for detecting and mitigating malicious activities within the network.

Malicious nodes in a blockchain network often exhibit abnormal behaviour over time, such as initiating fraudulent transactions or generating an unusually high volume of transactions. By leveraging the capabilities of HTM, these behavioural patterns can be analyzed to identify deviations from the norm. HTM excels at processing large volumes of transactions in real-time, making it an ideal solution for monitoring the activities of all nodes within the network.

One of the significant advantages of HTM is its ability to learn and adapt to changing behavioural patterns, including newly emerging attack techniques. As the blockchain landscape evolves, attackers continuously devise new strategies to exploit vulnerabilities. HTM's adaptability enables it to recognize and respond to these evolving threats, thereby bolstering the security and resilience of the L1X blockchain.

The integration of HTM within the L1X blockchain plays a crucial role in identifying malicious nodes by promptly detecting anomalies in their behaviour. By applying HTM at two key stages—the transaction entry point and the block broadcasting stage—L1X ensures comprehensive coverage and robust security throughout the blockchain network.

At the transaction entry point, HTM analyzes incoming transactions, allowing for the immediate detection of suspicious or fraudulent activities. This early detection capability prevents potentially harmful transactions from entering the network, mitigating the risk of security breaches.

Similarly, HTM is employed when blocks are broadcasted to nodes within the network. By analyzing the temporal patterns of block propagation and processing, HTM can identify any irregularities or deviations from expected behaviours. This enables the system to take appropriate measures to address potential threats and maintain the integrity of the blockchain. As a result, HTM serves as a critical component in upholding the security and trustworthiness of the L1X blockchain ecosystem.



## Benefits <a href="#toc140645918" id="toc140645918"></a>

The PoX consensus mechanism offers a multitude of advantages in achieving genuine decentralization while ensuring a secure and scalable blockchain infrastructure capable of high throughput as listed below:

1. **Efficient transaction validation**: The PoX consensus mechanism in L1X reduces energy consumption by eliminating the need for high computational power, resulting in a more sustainable blockchain network.
2. **Scalability through active microdevice participation**: With PoX, the network's scalability is maintained even as the number of validators increases. The active engagement of microdevices ensures consistent network performance, accommodating a growing user base.
3. **Pure decentralization**: PoX enables a purely decentralized network by actively involving microdevices in the consensus process. The random selection of block proposer ensures fairness and prevents any single or group of nodes from gaining unfair advantages.
4. **Enhanced security and privacy through ZKP**: L1X applies ZKP on blocks before broadcasting them, ensuring the correctness of blocks while preserving sensitive transaction information. ZKP enhances security by reducing the block size, enabling faster transmission, and minimizing the risk of data exposure.
5. **Enhanced privacy through Homomorphic Encryption:** Utilizing homomorphic encryption to protect the privacy of full node identities during consensus brings significant advantages to the blockchain ecosystem, as it ensures that the selection process remains secure and unbiased while maintaining the confidentiality of node participants. By encrypting identities and applying a randomization algorithm, the blockchain network enhances privacy and prevents malicious entities from manipulating the selection process.
6. **Proactive detection of malicious nodes**: The utilization of HTM in L1X allows for the real-time identification of anomalies and abnormal transaction patterns associated with malicious nodes. HTM's ability to handle large transaction volumes and adapt to emerging attack patterns strengthens network security.
7. **Protection against targeted attacks**: Random selection of block proposers makes it difficult for attackers to target specific nodes. This additional layer of security ensures the integrity and resilience of the L1X blockchain network.
8. **Robust network integrity**: By combining transaction authentication, Non-Technical Validation, data synchronization, and security measures, the PoX consensus mechanism in L1X ensures the overall integrity and reliability of the blockchain network.

These benefits collectively contribute to a more efficient, scalable, secure, and decentralized blockchain ecosystem in L1X. By reducing energy consumption, promoting scalability, preserving privacy, and detecting and preventing malicious activities, the PoX consensus mechanism enables the L1X blockchain to meet the demands of a growing network while maintaining a high level of security and integrity.
