There are various platforms and development kits that complement existing blockchains. For example, Kadena is a new private blockchain with novel ideas such as Scalable BFT. Various concepts such as sidechains, drivechains, and pegging have also been introduced with this growth of blockchain technologies.
This article is an excerpt taken from the book Advanced Blockchain Development by Packt Publishing, written by Imran Bashir, Narayan Prusty. This book covers the basic understanding of decentralized applications, mechanism behind bitcoin, blockchain solutions and much more.
Blockchain solutions, Kadena and Quoram and much more.
Kadena is a private blockchain that has successfully addressed scalability and privacy issues in blockchain systems. A new Turing incomplete language, called Pact, has also been introduced with Kadena that allows the development of smart contracts. A key innovation in Kadena is its Scalable BFT consensus algorithm, which has the potential to scale to thousands of nodes without performance degradation.
Scalable BFT is based on the original Raft algorithm and is a successor of Tangaroa and Juno. Tangaroa, which is a name given to an implementation of Raft with fault tolerance (a BFT Raft), was developed to address the availability and safety issues that arose from the behavior of Byzantine nodes in the Raft algorithm, and Juno was a fork of Tangaroa that was developed by JPMorgan.
Both of these proposals have a fundamental limitation—they cannot scale while maintaining a high level of high performance. As such, Juno could not gain much traction. Private blockchains have the more desirable property of maintaining high performance as the number of nodes increase, but the aforementioned proposals lack this feature. Kadena solves this issue with its proprietary Scalable BFT algorithm, which is expected to scale up to thousands of nodes without any performance degradation.
Moreover, confidentiality is another significant aspect of Kadena that enables privacy of transactions on the blockchain. This security service is achieved by using a combination of key rotation, symmetric on-chain encryption, incremental hashing, and Double Ratchet protocol.
Key rotation is used as a standard mechanism to ensure the security of the private blockchain. It is used as a best practice to thwart any attacks if the keys have been compromised, by periodically changing the encryption keys. There is native support for key rotation in Pact smart contract language.
Symmetric on-chain encryption allows encryption of transaction data on the blockchain. These transactions can be automatically decrypted by the participants of a particular private transaction. Double Ratchet protocol is used to provide key management and encryption functions.
Scalable BFT consensus protocol ensures that adequate replication and consensus has been achieved before smart contract execution. The consensus is achieved by following the process described here.
This is how a transaction originates and flows in the network:
- First, a new transaction is signed by the user and broadcasted over the blockchain network, which is picked up by a leader node that adds it to its immutable log. At this point, an incremental hash is also calculated for the log. Incremental hash is a type of hash function that allows computation of hash messages in the scenario where, if a previous original message which is already hashed is slightly changed, then the new hash message is computed from the already existing hash. This scheme is quicker and less resource intensive compared to a conventional hash function where an altogether new hash message is required to be generated even if the original message has only changed very slightly.
- Once the transaction is written to the log by the leader node, it signs the replication and incremental hash and broadcasts it to other nodes.
- Other nodes after receiving the transaction, verify the signature of the leader node, add the transaction into their own logs, and broadcast their own calculated incremental hashes (quorum proofs) to other nodes. Finally, the transaction is committed to the ledger permanently after an adequate number of proofs are received from other nodes.
A simplified version of this process is shown in the following diagram, where the leader node is recording the new transactions and then replicating them to the follower nodes:
Once the consensus is achieved, a smart contract execution can start and takes a number of steps, as follows:
- First, the signature of the message is verified.
- Pact smart contract layer takes over.
- Pact code is compiled.
- The transaction is initiated and executes any business logic embedded within the smart contract. In case of any failures, an immediate rollback is initiated that reverts that state back to what it was before the execution started.
- Finally, the transaction completes and relevant logs are updated.
Pact has been open sourced by Kadena and is available for download at http://kadena.io/pact/downloads.html.
This can be downloaded as a standalone binary that provides a REPL for Pact language. An example is shown here where Pact is run by issuing the ./pact command in Linux console:
A smart contract in Pact language is usually composed of three sections: keysets, modules, and tables. These sections are described here:
- Keysets: This section defines relevant authorization schemes for tables and modules.
- Modules: This section defines the smart contract code encompassing the business logic in the form of functions and pacts. Pacts within modules are composed of multiple steps and are executed sequentially.
- Tables: This section is an access-controlled construct defined within modules. Only administrators defined in the admin keyset have direct access to this table. Code within the module is granted full access, by default to the tables.
Pact also allows several execution modes. These modes include contract definition, transaction execution, and querying. These execution modes are described here:
- Contract definition: This mode allows a contract to be created on the blockchain via a single transaction message.
- Transaction execution: This mode entails the execution of modules of smart contract code that represent business logic.
- Querying: This mode is concerned with simply probing the contract for data and is executed locally on the nodes for performance reason. Pact uses LISP-like syntax and represents in the code exactly what will be executed on the blockchain, as it is stored on the blockchain in human-readable format. This is in contrast to Ethereum’s EVM, which compiles into bytecode for execution, which makes it difficult to verify what code is in execution on the blockchain. Moreover, it is Turing incomplete, supports immutable variables, and does not allow null values, which improves the overall safety of the transaction code execution.
The following example has been developed using the online Pact compiler available at http://kadena.io/try-pact/.
When the code is run, it produces the output shown as follows:
As shown in the preceding example, the execution output matches exactly with the code layout and structure, which allows for greater transparency and limits the possibility of malicious code execution.
Kadena is a new class of blockchains introducing the novel concept of pervasive determinism where, in addition to standard public/private key-based data origin security, an additional layer of fully deterministic consensus is also provided. It provides cryptographic security at all layers of the blockchain including transactions and consensus layer.
Relevant documentation and source code for Pact can be found here https://github.com/kadena-io/pact.
Kadena has also introduced a public blockchain in January, 2018 which is another leap forward in building blockchains with massive throughput. The novel idea in this proposal is to build a PoW parallel chain architecture. This scheme works by combining individually mined chains on peers into a single network. The result is massive throughput capable of processing more than 10,000 transactions per second.
The original research paper is available at http://kadena.io/docs/chainweb-v15.pdf.
This is a blockchain solution built by enhancing the existing Ethereum blockchain. There are several enhancements such as transaction privacy and a new consensus mechanism that has been introduced in Quorum. Quorum has introduced a new consensus model known as QuorumChain, which is based on a majority voting and time-based mechanism. Another feature called Constellation is also introduced which is a general-purpose mechanism for submitting information and allows encrypted communication between peers. Furthermore, permissions at node level is governed by smart contracts. It also provides a higher level of performance compared to public Ethereum blockchains.
Several components make up the Quorum blockchain ecosystem. These are listed in the following subsections.
This component enables access to encrypted transaction data. It also manages local storage on nodes and communication with other transaction managers on the network.
As the name suggests, this component is responsible for providing cryptographic services to ensure transaction privacy. It is also responsible for performing key management functions.
This is the key innovation in Quorum. It is a BFT consensus mechanism which allows verification and circulation of votes via transactions on the blockchain network. In this scheme, a smart contract is used to manage the consensus process and nodes can be given voting rights to vote on which new block should be accepted. Once an appropriate number of votes is received by the voters, the block is considered valid. Nodes can have two roles, namely Voter or Maker. The Voter node is allowed to vote, whereas the Maker node is the one that creates a new block. By design, a node can have either right, none, or only one.
This component provides an access control layer for the permissioned network.
A node in the quorum network can take several roles, for example, a Maker node that is allowed to create new blocks. Transaction privacy is provided using cryptography and the concept that certain transactions are meant to be viewable only by their relevant participants.
Transaction in a Quorum network consists of various elements such as the recipient, the digital signature of the sender, which is used to identify the transaction originator, optional Ether amount, the optional list of participants that are allowed to see the transaction, and a field that contains a hash in case of private transactions.
A transaction goes through several steps before it can reach its destination. These steps are described as follows in detail:
- User applications (DApps) send the transaction to the Quorum node via an API exposed by the blockchain network. This also contains the recipient address and transaction data.
- The API then encrypts the payload and applies any other necessary cryptographic algorithm in order to ensure the privacy of the transaction and is sent to the transaction manager. The hash of the encrypted payload is also calculated at this step.
- After receiving the transaction, the transaction manager validates the signature of the transaction sender and stores the message.
- The hash of the previously encrypted payload is sent to the Quorum node.
- Once the Quorum node starts to validate a block that contains the private transaction, it requests more relevant data from the transaction manager.
- Once this request is received by the transaction manager, it sends the encrypted payload and relevant symmetric keys to the requestor Quorum node.
- Once the Quorum node has all the data, it decrypts the payload and sends it to the EVM for execution. This is how Quorum achieves privacy with symmetric encryption on the blockchain, while it is able to use native Ethereum protocol and EVM for message transfer and execution respectively.
A similar concept, but quite different in a few aspects, has been proposed before in the form of HydraChain, which is based on Ethereum blockchain and allows the creation of permissioned distributed ledgers.
Quorum is available for download at https://github.com/jpmorganchase/quorum.
In this article we learned about the blockchain solutions, Kadena and Quoram and much more. To know more about decentralized applications and mechanism behind bitcoin, check out the book Advanced Blockchain Development by Packt Publishing.