Introduction to Zk SNARK and Zk Rollup Technologies
1. Introduction:
The cryptography world has hit the world by storm, even since ancient times and through World War 2, and now, with the revolution of the Crypto-currency world, it is here to revitalize our age-long financial systems and perhaps, the power-structure of the world.
I don’t feel the need to elaborate how the crypto world has changed the world so far, as I write this, entire countries ( like El Salvador) have adopted the currencies in order to revitalize their economies and organizational changes ( such as DAO) are sweeping the world by storm.
Before we go into details about zk technology, I feel that, for us to better understand its importance it is first important to understand cryptography at large, and especially its relevance to the IT field.
2. Brief Overview of Cryptography and Its importance:
Since ancient times, cryptography was used to deliver a message between several parties in which, all of the parties participating had the ‘key’ to decode the message. In its very basic essence, it is the art of delivering information in plain site while only the selected few, who hold the key, are able to access the contents of that information while others cannot.
The function of turning ‘plain text’ to ‘encrypted message’ – is called a ‘cipher’ , and was used much throughout the ancient world and through-out World War 2 with the tales of the German encryption machine ‘Enigma’ which Alan Turing and his team, we’re tasked with deciphering, in the age of limited computing capabilities. After successfully deciphering Enigma, Alan Turing delivered us the first, official ‘Computer’.
Up until that point, A ‘Computer’ was a person working at a cubicle, performing various complex computations on paper for some accountant or governmental office.
While I would gladly write about the various Classical Ciphers and their historic progression, this is not the main topic of this article and so I’d like to move on to Stream Ciphers and Hash Functions
Stream Ciphers, are random, algorithmic ciphers that take a short message and cipher it randomly into a random, long ‘Stream’. Thus, making it very unlikely for a machine to decode without using the key.
Hash Functions, are what we mostly are interested in, since they make the Blockchain revolution a reality by creating unique, random, hashes from long pieces of information.
So where Stream Ciphers take short input and output a randomly generated, long text,
Hash Functions receive long input and output a short string of Hashes.
( Example of output from a Hashing Function: “3338be694f50c5f338814986cdf0686453a888b84f424d792af4b9202398f392” )
So, for example, we can take an entire contents of a folder and insert it into a Hash Function Algorithm, a ‘blender’ of sorts that keeps the integrity of the folder and outputs a unique hash (look at the example above) and therefore allow to store it in plain-sight, but only the computer who created the said hash, can re-access that folder.
(I’m using very simple language, and not elaborating on code-signing for the sake of simplicity, I am aware that things under the hood are a little more complex but please feel free to explore these concepts on your own)
The capabilities of Hash Functions, and their unique hashes, allow us to store information publicly but access it privately – and we can also validate their integrity, allowing us to store massive amount of files and information while at the same time making it completely safe and secure – thus enabling the blockchain and cryptocurrency revolution.
3. Zk Snarks:
Zk – Snarks are an acronym for “ Zero Knowledge Succinct Non-interactive Argument Of Knowledge”, and is a cryptographic proof whereby two separate parties can verify that they hold the same information without revealing that information.
So if we have two parties – call them, “Prover” and “Verifier”.
The proof in itself, generates a True or False statement and thus the “Prover” does not have to reveal the information.
If, when the verifier, accesses the generate proof of information (Lets see it at the moment as some hash algorithm, I will go into details in a later date) – and it is True, then the Verifier will Validate the Prover.
If the proof is cheated, or falsified in someway, the Verifier will not be able to Validate the Prover.
Therefore, the soundness of the information is intact – since all that is revealed is if the proof-statement is either True or False.
4. Zk Rollup
Much like Zk SNARKS, a roll-up consists of ‘transactors’ and ‘relayers’.
The transactors create their respective transfers, accounting for the following information:
‘to’ and ‘from’ wallet addresses, value or information to transact, network fee and nonce ( A unique cryptographic number that is used to confirm that the following action was only created once and thus disabling the possibility of replay attacks).
The smart-contract knows to store the information in a data-structure called ‘Merkle Trees’ , one for addresses and one for transfer amounts.
The ‘transactors’ model is the current state of the blockchain, where all information is kept on the main-ledger, and so far there is nothing new. But here’s the ingenious part…
‘Relayers’ collect a large amount of ‘Transactors’ and generate a SNARK proof – which is just a hash proof of the current state of the blockchain at a current point, it does so by providing a ‘delta’ of the blockchain – whereby the current block is compared to the previous validated block and thus creating a unique, validated snapshot of the state of the blockchain at a given time.
Knowing what we know about SNARK proofs now, no information is exposed and we can confirm the validity of the information at all times.
The collection of ‘Transactors’ created by the ‘Relayers’ is called a ‘Rollup’ and thus we get “Zero Knowledge Rollup” (Zk Rollups).
Conclusions:
By enabling Zk Rollup technology and implementing it on the various blockchains, we are able to prove the overall speed of the chain, reduce transaction fees and not compromise over the integrity of the information of the chain.
The security is therefore kept, while the overall capability is improved.
It is worth mentioning that there is a live implementation of Rollups live on the Ethereum mainnet called ZkSync