The scalability of Ethereum is the biggest problem of the blockchain, which is trying to be solved with solutions like Plasma, Raiden or Sharding, but it seems that the answer to on-chain scalability comes from somewhere else thanks to zk-snarks.
When you look at the numbers, it’s obvious that Ethereum has a big scalability problem because it can barely process 15 transactions per second (TpS) while Visa, for example, processes 45 thousand.
This is also a problem for Dapps that would like to reach millions of users. Considering these numbers, in fact, it would be almost impossible to see a social network like Facebook on Ethereum.
Ethereum’s scalability problem can be attributed to the fact that every transaction that takes place on the blockchain must be done in parallel by each node of the network, which means that the blockchain cannot process more transactions than a single node.
To improve all this, Ethereum developers are working on various solutions both on-chain and off-chain, but the best at the moment would seem to be snarks.
Sharding is an on-chain solution, it’s about implementing a technology so that it is not required that every single node processes every single operation.
The sharding operations quite simple and consists of dividing the blockchain’s state of the history into smaller pieces called shards. Each shard contains its own history of status and transactions. Shards can have sub-shards. Scalability stems from the fact that each node must validate the transactions of its shard and not the entire status of the blockchain. This type of solution, however, creates a problem for communication between the various shards.
State channel or Raiden is an off-chain or layer 2 solution that does not require all transactions to be validated by all nodes but can take place between the two parties of the transaction.
It is enough that the parties reach a consensus and have proof of the transfer of assets to receive a global consensus. State channels make transactions faster, are private and do not require gas, but there is the possibility of centralization as some nodes can open more channels than others.
Plasma is an off-chain or layer 2 solution that tries to take the most out of Ethereum’s existing capacity.
It consists of creating “daughter” chains attached to the main Ethereum blockchain, creating a network around the main blockchain, a sort of hierarchical tree.
Thanks to this method, entire decentralized applications with thousands of users can be hosted on these “child” chains without overloading Ethereum.
Although this solution is attractive because each chain can have its own mechanism of consent, there is no shortage of problems: one is the security of the network and, as work progresses, new obstacles appear that slow down everything by creating different variations of the plasma that create problems of viability.
During the recently concluded Devcon4, David Knott, Plasma researcher for OmiseGo explained that there are “time constraints, it is horrible for the user interface and it is vulnerable to network congestion”.
Zk-Snarks, a step forward in Ethereum scalability
On September 22nd, Vitalik Buterin published an article on the implementation of snarks as a valid solution for the scalability of Ethereum.
In his paper, he writes that thanks to zk-snarks used to validate mass transactions it would be possible to obtain about 500 TPS on-chain, which is layer 1.
And there are layer 2's without data availability tradeoffs or liveness requirements, eg. tx mass-validation via ZK-SNARKs can reduce costs to < 1000 gas per tx if done well. That's ~500 tx/sec on-chain with all the security guarantees of on-chain.
— Vitalik Non-giver of Ether (@VitalikButerin) September 22, 2018
What are Zk-snarks
Zk-snark is Zcash’s core technology involving two parties to a transaction, each party can prove to the other that it has a specific set of information, without revealing what that information is. With Zk-SNARK you can then prove through a mathematical test the possession of a password without ever having to reveal it.
As cryptic as this phrase may be, the principle is quite easy to understand and Eric Gorski of the Gnosis project who implements snarks in his project, explains the functioning of the technology using the story of the viper and the parrot.
How do snarks work: the story of the viper and the parrot
The viper and the parrot cross the jungle and arrive under a mango tree. The viper, who is colourblind, insists that the mangoes are all the same, but the parrot who sees the colours says that the fruits are different.
The parrot proposes a game to prove that he is right, but without revealing the difference.
The viper must hide two mangoes at each turn and choose only one to reveal. The parrot must then decide whether the fruit he sees is that of the previous round or not. The bird passes the test perfectly because it sees the difference in colours while the viper does not. The viper, on the other hand, knows that it is true because it was she who chose the mangoes.
Thanks to this story we know that a certain statement is true (that the two mangoes are different) without revealing why because they are of different colours).
If we use this “zero-knowledge” or the anonymity of information in token transfers we can prove the ownership of a token and send it to someone else without revealing the value of the token or the identity of the recipient.
How do zk-snarks improve scalability
The researchers at Ethereum have realized that this technology, developed mainly for the needs of privacy, is also suitable for scalability and that it could help Ethereum in a much better way than the other technologies so far adopted.
Zk-snarks are like cryptographic hashes that compress computational evidence into small, easy to verify fingerprints even if the calculation was performed off-chain. As well as signatures, zk-snark certifies the validity of a given operation.
Zk-snark tests are generated off-chain and those are the ones that require a lot of computational power so it makes sense to keep them off-chain while the verification of tests takes place on-chain. This system saves the amount of on-chain resources per operation which allows for more operations by increasing scalability.
There are various approaches to managing scalability with zk-snarks and they consist of blockchain synchronization, ultra-light clients, extracting and archiving code and universal state channels.
Zk-snarks remove the need to explicitly verify transaction signatures one at a time. A single zk-snark can attest to all signatures of a block. This means that the calculation requirements for blockchain synchronization can be significantly reduced.
By extracting and archiving the code, zk-snarks can condense the status of a smart contract into a single hash, blurring both the underlying code and storage space. This technique also allows the dosage of changing the status of the blockchain which creates a state channel. Changes in the state are recorded on the blockchain only with a single zk-snark check and the blockchain itself retains only a hash of a smart contract…
Zk-snarks not only allow to strengthen the privacy of transactions on the blockchain, but they open a new horizon for Ethereum giving the hope of a new beginning. Even Daniel Larimer, the creator of EOS, has admitted that Plasma is a failure, but sees a promise in snarks: