zk-SNARKs -Vital for Digital Privacy?

by ImmuneBytes

Blockchain Security has been a hot topic in recent years. As Etherium grows into its metropolis phase, it is going to deploy some changes, making it more abstraction friendly. One such change is zk-SNARKs, a powerful weapon against security and privacy breaches.

Known for its widespread use in Zcash, zk-SNARKs is an acronym for zero-knowledge, Succinct, Non-interactive Argument for Knowledge. The prospects of zk-SNARKs are impressive. The underlying technology falls under the umbrella of zero-knowledge cryptography that proves the possession of information without revealing the information and without having the prover and verifier to interact with each other.

Surely, Blockchain companies have made it their goal to increase transparency but with that comes its limitations and zk-SNARKs is helping with just that. It is allowing companies to build smarter automated systems that can substantiate facts without having to reveal the data behind them.

What is so special in Zk-Snarks?

Would a company want to reveal how much it charges its clients? Of course, not. ZCash, a  privacy-protecting digital currency, using zero-knowledge proofs is helping with exactly that. Instead of making all the information public, users can choose to pay with “zerocoins”, protecting the identity of the payer, the recipient, and the amount.

zk-SNARKs allow proofs to be much more efficient and uses fewer data. Considering the fact that it requires no interaction between the two parties, it is comparatively faster, enabling them to be verified nearly instantly.

Technical Analysis

The sender function is given as: 

function senderFunction(x, w) {

  return (

    w.senderBalanceBefore > w.value &&

   sha256(w.value) == x.hashValue &&

    sha256(w.senderBalanceBefore) == x.hashSenderBalanceBefore &&

  sha256(w.senderBalanceBefore – w.value) == x.hashSenderBalanceAfter



The receiver function as:

function receiverFunction(x, w) {

  return (

    sha256(w.value) == x.hashValue &&

    sha256(w.receiverBalanceBefore) == x.hashReceiverBalanceBefore &&

    sha256(w.receiverBalanceBefore + w.value) == x.hashReceiverBalanceAfter



A zk-SNARK token in a contract would look something like:

function transfer(address _to, bytes32 hashValue, bytes32 hashSenderBalanceAfter, bytes32 hashReceiverBalanceAfter, bytes zkProofSender, bytes zkProofReceiver) {

bytes32 hashSenderBalanceBefore = balanceHashes[msg.sender];

  bytes32 hashReceiverBalanceBefore = balanceHashes[_to];

bool senderProofIsCorrect = zksnarkverify(confTxSenderVk, [hashSenderBalanceBefore, hashSenderBalanceAfter, hashValue], zkProofSender);

bool receiverProofIsCorrect = zksnarkverify(confTxReceiverVk, [hashReceiverBalanceBefore, hashReceiverBalanceAfter, hashValue], zkProofReceiver);

if(senderProofIsCorrect && receiverProofIsCorrect) {

    balanceHashes[msg.sender] = hashSenderBalanceAfter;

    balanceHashes[_to] = hashReceiverBalanceAfter;



Hence, the updates on the blockchain are the hashes of the balance and not the balance itself. And yet we can know that the balances are updated correctly because we can check that the proof has been verified.

Could it possibly change the future of Audits?

It is said that the fewer parts a machine has, the lesser it is exposed to failure. Contrary to that, as levels of abstraction increase, the system becomes more complicated and so do the requirements to safeguard it. 

The introduction of zk-SNARKs could possibly change the upcoming scenario forb as more companies are making progress towards deploying zero-knowledge proof Smart Contracts. But there are, of course, certain concerns that put the work into the hands of the Auditing companies to ensure that no one is able to access any loopholes.

We at Immunebytes make sure that the zero-knowledge proof Smart Contracts go through utmost scrutiny in order to remove even the smallest vulnerabilities present. 


  • Tron deployed a version of zk-SNARKs onto its network- although not all transactions are private. 
  • Aztec, a project trying to bring zero-knowledge proofs to the existing Ethereum network by building privacy-focused Smart Contracts.
  • Mina, developed by O(1) Labs, uses recursive zk-SNARK to create a blockchain that is always 22kb in size, making it the world’s lightest blockchain.
  • A couple of years ago, JP Morgan Chase adopted Zcash’s zk-SNARKs-based proof of concept to bolster the privacy of its native blockchain ecosystem called Quorum.

As the world continues to automate with time, the companies will collect more and more of our data, zk-SNARK is one such innovation that offers a solution to shelter our data and safeguard our privacy which is paramount in this digital age.

Spread the love

You may also like