Sitemap
Beyond the Crypto Horizon

Beyond the Crypto Horizon investigates the changing world of cryptocurrencies through project research, news aggregation, and weekly fundraising updates.

Time to research: Railgun

11 min readApr 25, 2024

--

RAILGUN is a privacy system built directly on-chain for Ethereum, BSC, Polygon, and Arbitrum. It uses Zero-Knowledge (ZK) cryptography to enable private use of smart contracts and DeFi, all without leaving the security of the user’s preferred chain.

Press enter or click to view image in full size

RAILGUN refers only to the set of smart contracts that underpin the backend privacy infrastructure. Independent wallet providers can then choose to integrate the RAILGUN protocol.

As RAILGUN is simply on-chain smart contract logic, privacy is achieved without a separate Layer-2 validator set or a vulnerable bridge. This provides 2 main advantages:

  1. Security & Decentralization — Fewer questions on validator set and no bridge risk. RAILGUN is as secure as the EVM chain it’s deployed on.
  2. Full Ecosystem — Rather than an isolated ecosystem on a standalone privacy chain, RAILGUN users have access to all the economic activity on Ethereum and benefit from the rich history of existing dApps and builders.

The user experience is similar to using a public wallet like MetaMask to interact with Ethereum/EVM chains in terms of liquidity and DeFi, just with the added ability to transact privately.

RAILGUN has 2 main components:

  1. Integrated wallets — EVM wallets built by separate independent community developers through which users can use the RAILGUN protocol.
  2. Developer Tools — TypeScript SDKs for building RAILGUN privacy into existing/new wallets or a privacy enabled dApp.
Press enter or click to view image in full size

RAILGUN’s code is verified and publicly viewable, and its repository can be found here.

Privacy System

RAILGUN’s privacy system is a series of smart contracts that obscures blockchain transaction information from public view. For a cryptocurrency transaction to be private, four identifying details must be hidden:

  1. Sender of the transaction
  2. Recipient of the transaction
  3. Asset that is sent
  4. Amount of the asset that is sent
Press enter or click to view image in full size

RAILGUN protects this information for transactions in the system by utilizing Private Balances, that is an anonymous set of funds and users where transactions appear to originate from. These Private Balances are known as an anonymity set to an outside observer; transactions can be sent by anyone who has contributed funds to the pool.

The overall level of privacy from Private Balances is a function of:

  1. Total number of unique shield transactions and users.
  2. Total Value Locked in the RAILGUN smart contract.
  3. RAILGUN DeFi transaction and Private Send volume.

Generally, the more Shielded funds, the higher the level of anonymity as links are less likely to be drawn between depositor and asset as there is a higher number of potential depositors to try and attach transactions to. Some consideration must also be paid to token type.

However, RAILGUN has additional privacy boosting capabilities due to its support of complex smart contract transactions and Private Sends. Every transaction that takes place, decreases the likelihood a depositor can be linked to a specific asset or deposit transaction, increasing the level of privacy for all users. As RAILGUN enables trading, users can Shield a small amount of crypto and theoretically trade up to a larger position privately, so the total size of the anonymity set is less of a factor in maintaining privacy in RAILGUN.

This means that privacy in RAILGUN’s Private Balances is always greater than other privacy solutions with the same amount of TVL due to increased noise from transactions like Private Sends and swaps.

Relayers and UTXO

Sitting atop the Private Balances are a network of Relayers, which are wallets that pass information to the blockchain and pay gas fees on a user’s behalf.

RAILGUN’s transaction system uses Unspent Transaction Outputs (UTXOs), similar to Bitcoin and Zcash’s spending system. A UTXO represents the right or authorization to spend currency and is implemented in RAILGUN as a Merkle Tree, an organized and encrypted data tree which allows the RAILGUN smart contract to trace ownership and balances through cryptographic proofs. The difference here is that RAILGUN’s Merkle Tree is completely anonymized and held in the smart contract.

RAILGUN SDK

RAILGUN is low-level infrastructure with a SDK (Software Development Kit) for protocol integrations of private smart contract transactions and a private wallet. Users have a public on-chain address, that is a 0x address and an obfuscated RAILGUN address which begins with a 0zk.

Transactions sent from 0zk addresses are completely private and appear on blockchain scanners (like Etherscan) as originating from a Relayer address. Identifying details are hidden at all stages of the process by encryption through zk-SNARK proofs.

Zero-Knowledge Cryptography

RAILGUN heavily leverages Zero-Knowledge Proofs (ZKPs). ZKPs allow for advanced logic and contract interactions without any information leakage and are a revolutionary tool for privacy preservation.

What are zk-SNARKs?

Zero-Knowledge proofs are methods whereby one party, the prover, can mathematically satisfy another party, the verifier, the veracity, or truth of information without revealing the originating details of the information. This is achieved by the prover passing components of mathematical problems that relate to the truth of the information being proved onto the verifier multiple times. These interactions occur until the verifier is satisfied that it is statistically impossible for the information to not be true or is being faked by the prover, all without revealing the contents of the verified information.

zk-SNARK stands for “Zero-Knowledge Succinct Non-Interactive Argument of Knowledge”. Put simply, a zk-SNARK is a form of ZKP that does not require direct interaction between the prover and verifier. Rather, they achieve their non-interactivity through the prover simulating the interactions between prover and verifier, and the verifier simply needs to check that the simulation was performed correctly. These proofs rely on computational assumptions that cannot be cracked or will take millions of years to crack with currently available computational power.

What are circuits?

Within RAILGUN, zk-SNARKs take the form of arithmetic circuits. Arithmetic circuits are like Boolean circuits or even hardware circuits in computers/electronics. Like all other circuits, they contain wires and gates. Wires transmit information and gates are conditions that must be met for information to move through all the way until it reaches an output. In an arithmetic circuit like the ones used in RAILGUN, the gates are mathematical operations like addition or multiplication. In the context of RAILGUN’s zk-SNARKs, circuits are how verifiers can reach mathematical certainty that provers are providing true information.

Press enter or click to view image in full size
Example arithmetic circuit to prove the output using the mathematic gates and inputs a, b, and c

For RAILGUN’s privacy system, zk-SNARK circuits prove the validity of a transaction senders address and balances by checking they have a corresponding note on the Merkle Tree.

Wallets and Keys

RAILGUN wallets (and by extension 0zk addresses/keys) can be created by any wallet infrastructure linked to the RAILGUN SDK. The first such wallet is the Railway Wallet, developed by a partner project of RAILGUN.

The RAILGUN SDK follows the BIP-32 standard for key derivation from a seed, which allows for hierarchical deterministic wallets along an elliptic curve.

A Hierarchical Deterministic Wallet is the term used to describe a wallet which uses a seed to derive many public and private keys. These keys are generated in a deterministic way, and are used to send and receive bitcoin.

Users have access to 2 kinds of keys in their RAILGUN wallets:

  1. Spending Key — The key that allows users to cryptographically prove they own their assets and send transactions. Spending Keys are analogous to a regular cryptocurrency wallet private key, only with a private 0zk address.
  2. Viewing Key — A key that allows only viewing of all transactions (including private ones) sent by a particular address. Users can define the beginning and ending block for which, the Viewing Key can observe in a scoped way. This is useful for auditability purposes, for example, a user can define the beginning and end of a tax year for their Viewing Key by block number.

Both the public Viewing Key and Spending Key are encoded in the 0zk address, hence why private addresses on RAILGUN are longer than standard 0x addresses. The key generation method is identical to how most other crypto keys are generated. Private keys are of course, not revealed publicly at any stage in wallet generation nor are they shared with any components of the RAILGUN system such as provers, verifiers, or Relayers.

Shielding Tokens

The first step in using the RAILGUN Privacy System is to privatize cryptocurrency tokens. Shielding is the process whereby funds enter the wallet’s private 0zk address from the public 0x address. Once funds are in the 0zk address, users can send, swap, and interact with DeFi privately. Further, any token that exists on the public blockchain can be shielded, which would include any ERC-20 token as well as ERC-721 NFTs.

Users initiate shielding by sending a shield transaction which contains public data (the asset, the amount, and other values called) from their public wallet. The RAILGUN smart contracts then take these values and computes a commitment (called a note). Notes are a hashed value of the public data sent by the user at the start of the shielding process. The hashed value of a note (a circuit output) cannot be reversed to uncover the original value (an input). Inputs and outputs in this context are the transaction/asset data which a RAILGUN user wishes to obscure.

Gasless Transactions

Another major innovation brought by the RAILGUN system is the ability to send transactions without needing to spend the underlying blockchain’s gas currency. Through the power of Relayers and complex ZK circuits, users can interact with RAILGUN entirely in their currency of choice. For example, a user would not need to hold a small balance of $ETH to pay for transactions on the Ethereum network and could instead choose to only hold and spend a stablecoin like $DAI with all associated fees being paid in $DAI.

This is achieved through something called a “Meta Transaction”, a special form of Ethereum/blockchain transaction that is nested within another transaction. The gas fee can be paid in whatever asset the user specifies with the Relayer and nested transaction performing any conversion frictionlessly for the user.

RAILGUN V3

In December of last year, RAILGUN introduced its V3 which will propel RAILGUN further as the best choice for truly decentralized private DeFi on Ethereum and EVM.

Get ginoongbakulaw’s stories in your inbox

Join Medium for free to get updates from this writer.

The headline changes in v3:

  • Contract modularization & gas savings
  • Relayer alternatives
  • Private intents
  • New DeFi possibilities with Access Card NFTs

If you want to know more about these changes, read it here.

Use Cases

Alpha Protection

Keep your alpha close to your chest and trade freely with the knowledge you won’t lose your hard-fought informational advantages.

Private Payroll

Pay your employees privately through crypto without leaking salary data to the rest of the market.

Anonymized Analytics

Reduce tracking and labelling on analytics services like Etherscan or Nansen to ensure you are not personally identifiable from your DeFi activity.

Data Compliance

Help your business maintain compliance with data protection and privacy laws like GDPR and CCPA.

Platform Metrics

  • Total Volume
Press enter or click to view image in full size
  • Arbitrum TVL
  • Ethereum TVL
  • Polygon TVL
  • BNB Chain TVL
  • Overall TVL
Press enter or click to view image in full size

Ethereum Metrics

  • Unique users
Press enter or click to view image in full size
  • Treasury
Press enter or click to view image in full size
  • Daily shielders and unshielders
Press enter or click to view image in full size
  • Weekly volume
Press enter or click to view image in full size
  • Weekly fees
Press enter or click to view image in full size
  • TVL
Press enter or click to view image in full size

Polygon Metrics

  • Unique users
  • Treasury
  • Daily shielders and unshielders
Press enter or click to view image in full size
  • Weekly Volume
Press enter or click to view image in full size
  • Weekly fees
Press enter or click to view image in full size
  • TVL
Press enter or click to view image in full size

BNB Chain Metrics

  • Unique users
  • Treasury
  • Daily shielders and unshielders
Press enter or click to view image in full size
  • Weekly volume
Press enter or click to view image in full size
  • Weekly fees
Press enter or click to view image in full size
  • TVL
Press enter or click to view image in full size

Arbitrum Metrics

  • Unique users
  • Daily shielders and unshielders
Press enter or click to view image in full size
  • Weekly fees
Press enter or click to view image in full size
  • Weekly volume
Press enter or click to view image in full size
  • TVL
Press enter or click to view image in full size

$RAIL

Source: Coingecko
Press enter or click to view image in full size
  • Fundraising
Press enter or click to view image in full size
  • Total Staked
Press enter or click to view image in full size
  • Staked Ratio
Press enter or click to view image in full size
  • Staked Supply
Press enter or click to view image in full size
  • Ethereum volume and fees
  • Polygon volume and fees
  • BNB Chain volume and fees
  • Arbitrum volume and fees
  • Deposits and withdraws
  • Monthly Returns
Press enter or click to view image in full size
  • Quarterly Returns

Partners

Press enter or click to view image in full size
Press enter or click to view image in full size

Official Links

Website | Twitter/X | Discord | Telegram | Medium

If you like this research, hit that clap button and follow me here and on Twitter for more research soon. I dive into a wide range of projects in different chains and sectors to research. Thank you for reading!

--

--

Beyond the Crypto Horizon
Beyond the Crypto Horizon

Published in Beyond the Crypto Horizon

Beyond the Crypto Horizon investigates the changing world of cryptocurrencies through project research, news aggregation, and weekly fundraising updates.