James Bachini

RAILGUN 2.0 | ZK Privacy Protocol

railgun 2.0 zk wallet

Railgun just announced the launch of version 2.0 this week and in this article we are going to explore the zero knowledge wallet and discuss why privacy protocols are important.

In August 2022 Alexey Pertsev was arrested and he has been imprisoned without trial ever since. He was a developer on a ZK mixer called Tornado Cash and was accused of money laundering.

Privacy is a basic human right and I think the teams still working on ZK privacy protocols are doing an incredible job in the face of adversity.

In this article we will look at Railgun a zero knowledge based permissionless contract on Ethereum, BSC & Polygon.

  1. Do We Need Privacy Protocols
  2. A Zero Knowledge Wallet
  3. How Railgun Works
  4. RAIL Tokenomics
  5. ZK-Snarks In Solidity
  6. Conclusion
James On YouTube

Do We Need Privacy Protocols

The Tornado Cash situation was caused by hackers using it to obfuscate funds gained from DeFi hacks. There are however plenty of genuine reasons to strive for privacy on public blockchains.

  • Private personal data, such as direct messages or social media profiles
  • Private on-chain voting in a political setting
  • Trading privately to avoid copy/counter trading
  • Censorship resistance for legitimate use cases
  • Private payments i.e. paying employees salary

Private transactions are coming to blockchain whether the governments like it or not because the genuine use cases are too powerful to ignore.


Zero Knowledge Railway Wallet

Railgun works differently to a mixer service. You can transfer funds in the form of ETH or ERC20 tokens to a ZK wallet called “Railway” where they go into a combined contract pool.

The idea is that we can generate and use a zero knowledge wallet in much the same way that we use metamask today. For example we can use the Railgun app to carry out swaps on a DeX and funds will go in and out of the zk wallet.

RAILGUN ZK Wallet

How Railgun Works

The account allocations and permissions are managed via a system built on ZK-Snarks which are a form of zero knowledge proofs.

Zero Knowledge proofs are a cryptographic tool used to prove the truth of a statement without revealing any information other than the truth of the statement. They could be used to prove a user has permission to spend funds for example without revealing the owner of the wallet.

How Zero Knowledge Cryptography Works
How Zero Knowledge Cryptography Works

ZK-Snark stands for “Zero Knowledge Succinct Non-Interactive Argument of Knowledge”. They are a form of zero knowledge proof which allows one party (the prover) to prove to another (the verifier) that a certain statement is true, without revealing any information about the statement itself.

ZK-snarks allows the prover to generate a proof that securely and concisely conveys the required information to the verifier. The prover sends a message to the verifier that contains the proof, and the verifier checks the proof to determine if it is valid.

I recently wrote an article on Zero Knowledge cryptography if you would like to know more about how this technology works and why it’s becoming the buzz word for the blockchain sector.


RAIL Tokenomics

The RAIL token is the governance token for Railgun. It can be staked to get voting rights within the DAO.

Total Supply100,000,000 RAIL
Supply at launch
○ 25% allocated during the Airdrop
○ 25% allocated to the Foundation
○ 50% allocated to the RAILGUN DAO
50,000,000 RAIL
Staking IncentivesStakers receive airdrops when launching on new chains.
Unstaking Period30 days from last vote to encourage long term participation in ecosystem
Liquidity ProvisionSupply distributed over 10 year period as incentives to LPs

There was a tweet shortly after publishing suggesting active governor rewards for staked RAIL tokens.

https://twitter.com/RAILGUN_Project/status/1600296856592187392

ZK-Snarks In Solidity

Before we draw a conclusion let’s take this opportunity to look at how ZK-Snarks are implemented within the Solidity contracts.

The main library is here: https://github.com/Railgun-Privacy/contract/blob/main/contracts/logic/Snark.sol

This is then imported into Verifier.sol where we have this code

bool validity = verifyProof(verifyingKey, _transaction.proof, inputs);

So we are passing in the key, proof and inputs to this function which in turn calls Snark.verify() from the library.

There is also an incremental merkle tree in Commitments.sol which is based on this code by Maci who has some interesting code at:
https://github.com/privacy-scaling-explorations


Conclusion

Railgun is an interesting new project which is at the forefront of the cambrian explosion of zero knowledge technolgy in the blockchain sector. It has real use cases and applications on desktop, iOS, Android and a dApp web interface.

The risk is that it get used in the same way as Tornado Cash and suffers the same fate with sanctions and FOMC listings. However I hope that regulators can look at some of the positives in this technology and take a more sensible approach rather than arresting developers.


Get The Blockchain Sector Newsletter, binge the YouTube channel and connect with me on Twitter

The Blockchain Sector newsletter goes out a few times a month when there is breaking news or interesting developments to discuss. All the content I produce is free, if you’d like to help please share this content on social media.

Thank you.

James Bachini

Disclaimer: Not a financial advisor, not financial advice. The content I create is to document my journey and for educational and entertainment purposes only. It is not under any circumstances investment advice. I am not an investment or trading professional and am learning myself while still making plenty of mistakes along the way. Any code published is experimental and not production ready to be used for financial transactions. Do your own research and do not play with funds you do not want to lose.