Programming languages in crypto

It is surprising and worrying that everyone talks about blockchain, ICOs or tokens so frequently yet not much is said about the building blocks underlying these blockchains or cryptocurrencies. People often use the word blockchain as if it was some kind of magical structure with some sort of mining to make it work.

Let’s take C++. Most people have heard about C++ and there is nothing too magical or special about it. Well, let’s take a look at the projects that are mainly based on C++: Bitcoin, Bitcoin Cash, Ripple, Monero, EOS and Stellar. So, how can this be? Bitcoin is just some fancy lines of code in C++? Yes. Some fancy lines of code that are putting together things that existed before in a smart way: public/private key cryptography, peer to peer networks, hash algorithms/merkle trees and proof of work to secure the blockchain by forcing any malicious actor that tampers with any block to recalculate the proof of work for all the following blocks, unlikely to succeed given a high hash rate for the network.

What about Ethereum? We need to distinguish here between the programming language for Ethereum and the one for the smart contracts. Ethereum is written in GO while its smart contracts in Solidity. While it may seem that C++ is the top programming language in crypto that is not the case. Why? Simply because all ERC20 tokens are smart contracts and are written in Solidity, this makes Solidity the top language in crypto.

What about other projects? NEO is based in C# and where we start to find some interesting functional programming languages is in Cardano and Tezos. Cardano is based in Haskell and Tezos in Ocaml. These programming languages are more secure than imperative languages. However, they are still not languages related to what is called “formal verification”, a technology that repels the hackers, its code as trustworthy as a mathematical proof. Let’s clarify that this is not something new, the dream to create formally verified software has existed since the beginning of the field of computer science.

Formal verification, hackers’ nightmare

Most computer code, which is written informally, is evaluated based mainly on whether it works. However, unit testing cannot guarantee that software will always work correctly because there is no way to run a program through every conceivable input. Given most blockchain code and projects are open source and deal with huge amounts of money, if there are errors in the code, hackers will find them such as in the DAO, stealing millions of dollars.

Thankfully, there exists an alternative, a really powerful formal verification language which has stayed under the radar and that will teach the crypto community that innovation matters also in the building blocks.

F* is a functional language aimed at formal verification developed by Microsoft Research. F*’s key advantages are that it is both reasonably similar to F#, OCaml and Haskell, and also more practical for program verification than comparable tools like Coq which is notoriously difficult to use for general purpose programming (Coq was designed as a proof-assistant, not a programming language). Tezos, for example, uses Coq to write proofs about their OCaml code.

Formal verification is especially important in smart contracts because here is where most errors are likely to occur. All smart contract platforms have to deal with two key problems: correct execution and resource consumption which are particularly hard to solve on a decentralized platform.

Zen Protocol takes F* as the starting point for defining smart contracts and built ZF* a powerful proof techniques both to create proofs of correctness and to prove that contracts execute in a limited amount of time.

But what does all this mean? What benefits that this brings? Stressing hackers, making them rush before Zen Protocol launches and forcing them to search for a new job is definitely a desirable benefit. However, to show how powerful ZF* really is, key advantages of Zen Protocol over Ethereum will be presented here for the first time that will give Zen Protocol a huge advantage and will attract people to build on it.

Zen Protocol: key advantages over Ethereum

First of all, smart contracts in Zen Protocol, thanks to ZF*, provide proof of resource bounds. Why is this important? Because there is absolutely no need to look up gas prices, to subtract gas prices or to check remaining gas like in Ethereum. In Ethereum Virtual Machine (EVM), nothing less than 60% of the time is spent just counting steps in this gas model. Zen Protocol has a 2.5x increase as only 40% of these resources are needed.

But there is still more. Since we are not concerned about gas prices in Zen Protocol, there is no need to represent smart contracts as a set of instructions like in Ethereum. In Zen Protocol, the source code can be kept, and this lets miners execute smart contracts faster and they are easier to optimize automatically. In other words, Zen Protocol is the first NoVM smart contracting platform: instead of using an interpreter and interpreted code, Zen Protocol uses compiled code. This is orders of magnitude faster.

Furthermore, because Zen Protocol is stateless, multiple contracts can be run at the same time. Assuming having only eight threads that would be 8x speed. Ethereum’s EVM runs smart contracts one by one. ERC20 tokens are smart contracts which is why ICOs for example can and have clogged the network before. In Zen Protocol smart contracts can run in parallel because there is no shared global state taking advantage of parallelism in modern computers.

Also, instead of having a first class or main token as ETH and then all the other second class ERC20 tokens, in Zen Protocol all tokens are first class UTXO. The implication of this is that smart contracts are not needed and simple transactions as in bitcoin blockchain can be done. In fact, Zen Protocol will be interoperable with the bitcoin blockchain.

In summary, Zen Protocol can process more smart contracts in less time than Ethereum, its smart contracts are faster to run than those in Ethereum and for transferring tokens there is no need of smart contracts as with Ethereum ERC20 tokens.

Formal verification is not a dream anymore.  Zen Protocol is here and it will be, without a doubt, one of the most important blockchains of 2018. But don’t trust me, see it for yourself: testnet is already available on the docs http://docs.zenprotocol.com/.

LEAVE A REPLY

Please enter your comment!
Please enter your name here