Secret Tokens: Programmable Privacy for DeFi
How Secret Network can create network effects for privacy, providing the missing piece for DeFi mass adoption.
Part of the “Secret Solutions” series, this post explores how solving for privacy with Secret Network helps with adoption and growth of decentralized technologies. Today, Guy Zyskind writes about programmable privacy for decentralized finance and introduces the concept of “secret tokens”, which creates network effects for privacy. Read on to learn about our vision, see the code for “secret tokens,” (currently working on public testnet) and find out how you can start building alongside us!
As builders in the blockchain space, we believe in the promise of open protocols and economies. Decentralized finance (DeFi) can form a superior financial system both for users and innovators. Users can now opt-in to services they want to use at low cost, easily switch between services, and even become owners and earn voting rights for the products they use - all built on an interconnected system of blockchains. What have historically been passive assets now become productive assets. Creative minds can develop a practically unlimited list of financial instruments and services, all controlled by a series of smart contracts meant to ensure fair dealing and safety of funds.
Thanks to smart contract composability, the possibilities for DeFi appear endless, “compounding” on an almost daily basis. Why not make your ETH work for you by locking it on Maker to get Dai in return, then lending that Dai to earn interest on Compound, all while earning COMP tokens that can be used for governance, or sold for an additional gain? Even with all its recent growth, we’ve only scratched the surface of what’s possible with decentralized finance.
However, we are currently well short of achieving the actual promise of decentralized finance and open economies. Unfortunately, DeFi has inherited the same shortcoming of all blockchains - there is no privacy for users, and data is public by default. DeFi cannot hope to eventually reach mass adoption as a complex and complete open financial system if financial privacy must be sacrificed.
We are still in the bleeding-edge “innovators” phase of the adoption curve for DeFi. Recently we reached $4 billion of “total value locked” in DeFi. While that’s an impressive milestone, we should aspire to “cross the chasm” and reach a $4 trillion AUM target for DeFi. This target is more than 10x the current market cap of the crypto ecosystem and ~10% of AUM in traditional financial markets.
To reach trillions in value, we need meaningful retail and institutional adoption - and for that we need privacy. We are already seeing institutional players building consortium chains with privacy features and eschewing public chains. We cannot expect the vast majority institutional or retail users to adopt DeFi products when all their financial history is publicly visible.
While there has been some progress, privacy solutions in DeFi today haven’t gone far enough. “Transactional privacy” is the case of simple peer-to-peer transactions where the goal is to protect the privacy of individuals by hiding the sender and recipient of a transaction (anonymity) and the amount sent (confidentiality). Many potential solutions have emerged in recent years (zero knowledge proofs, ring signatures, Mimblewimble, coin mixers, etc.), illustrating how crucial solving the transactional privacy problem is for blockchains.
However, solving for this narrow transactional use case won’t be the sustainable long-term solution. More elaborate and flexible use cases will appear in time that utilize the full programmable potential of smart contracts. DeFi is beginning to prove this point at scale. Solving the privacy problem for any smart contract is the promise of Secret Network, which allows privacy to be fully baked into any smart contract, thus turning it into a Secret Contract.
It's Secret Network’s capacity for programmable privacy can provide the major missing piece for explosive DeFi growth. Read on to see how it works.
See our July Ecosystem Update for more info on Secret Network!
Introducing network effects for privacy in DeFi
Imagine a system where any operation you do, across any DeFi service (be it trading, staking, lending, providing liquidity, issuing synthetic tokens, etc.) happens with complete privacy. That’s the vision of programmable privacy and Secret Network. This is obviously great for data privacy, but actually, there’s something even bigger at play here.
Each DeFi user actually gains more privacy with each additional DeFi service and every dollar worth of additional value locked in the ecosystem, leading to privacy network effects. The reason for this is that the aggregate liquidity across all DeFi applications directly quantifies the level of privacy you obtain (this is also known as the anonymity set). Think about these privacy gains like vaccination: the more people who inoculate themselves by using Secret Network to protect their privacy, the more benefits everyone else in the Secret DeFi ecosystem can gain.
Many people already care about privacy – enough to use dedicated services like mixers. But mixers require users to come up with separate liquidity pools, failing to achieve network effects. Secret DeFi can combine the enthusiastic pioneers of DeFi with those who passionately believe in the necessity of privacy. Privacy enthusiasts would enter DeFi because the higher liquidity means more privacy. Conversely, DeFi enthusiasts would see more liquidity coming from both themselves and their privacy-aware peers.
So how can this work?
Step 1: Secret Tokens
It all starts with Secret Tokens, which is a token mimicking the ERC-20 standard that has the benefit of:
- Having all balances be encrypted
- Having the arguments into a transfer operation be encrypted
Simply put, this ensures that any transaction and all rolling balances are forever kept encrypted. Each person can still query their own (and only their own) balance, as well as send tokens to others, privately. With very small changes, Secret Network can take a normal implementation of a token standard (like ERC-20, but WASM-compatible) and turn it into Secret Token standard.
Excitingly, a functioning prototype of secret tokens is already available here and live on our public testnet!
Step 2: Non-private Collateral
With this reference implementation of a “Secret Token” standard, the next step is to allow depositing a regular (public) coin/token (e.g., ATOM, SCRT) and obtaining in return a synthetic Secret Token. Our reference implementation does this for SCRT - it allows you to deposit X amount of SCRT (which is not private by itself) and instead obtain X amount of “secretSCRT” – the privacy-preserving Secret Token version of SCRT. The same can be done for any asset in the Cosmos ecosystem (with IBC) – and in the future from Ethereum and other ecosystems as well.
Step 3: Use privately in DeFi
Now that you have a Secret Token version of your asset, you can use it on a variety of DeFi services that are built on the Secret Network ecosystem. Imagine a Secret Swap that works similarly to Uniswap, allowing users to add liquidity to a pool and trade against that pool. The balances of the Secret Tokens in the pool would be publicly available. This is essential to set the price for the trading pair. However, the individual contributors to the pool would remain anonymous because the contract state would remain encrypted. Users can then swap Secret Tokens privately and no one but the user themselves would be able to see their balance. This is because the state of the Secret Tokens contract, where all the balances and token holders are listed, would again be encrypted.
Similarly to secret swaps, users can lend Secret Tokens like they do today on Compound, contribute to different Automated Market Making (AMM) liquidity pools like Balancer, participate in auctions or order book based trading like in 0x, and participate in the governance of secret DeFi.
In addition, programmable privacy in DeFi solves the problem of front-running. Since orders are never visible on the mempool, no attacker or malicious miner can front-run orders and profit at users’ expense. (See the Enigma blog for our previous writing on DeFi front-running.)
Furthermore, programmable privacy can help preserve fair markets. Projects like Strike Protocol are looking into introducing AMM model to manage positions (clearing house) in a Leveraged PerpetualSwap product. However, this type of product can be exploited if all positions are public. If Alice publicly creates a positon at t = 1, and Bob (seeing this) publicly creates a position that’s public to the network (and therefore Alice as well) at t = 2, Alice can see this and strategically close her position to profit at the direct expense of Bob. With Secret DeFi, these positions would be private (part of the encrypted state) and impossible to directly exploit.
For more on this, you can refer to the “How It Works” section in the Strike Protocol documentation linked above.
Step 4: Withdraw
Once you’re done, you can withdraw the underlying assets by burning the corresponding synthetic Secret Tokens that make up your position. In the process, you may have taken a lot of actions (e.g., you may have started with SCRT, but ended up with ATOM, KAVA, LUNA, or even a synthetic version of BTC / ETH / ERC-20 tokens), but no one would be able to track the movement from the original deposit to the end result. You have gained privacy proportional to all the users using all DeFi services and all types of Secret Tokens that exist in the ecosystem. With Secret Network, privacy enjoys the benefit of network effects.
How can you help?
This all sounds pretty good - but we’re builders, not bloggers. Right now the entire Secret community is working together to set a direction for protocol development, educational and awareness initiatives, node runner adoption, governance, and perhaps most importantly, key use cases and applications like what we’ve described here.
With our incentivized testnets for secret contracts already active and the secret contract mainnet upgrade tentatively scheduled for early October, we are rapidly approaching the launch of these applications. Before (and when) this occurs, we are looking for developers, partners, and early users to help scale key applications like Secret Tokens.
In the meantime, we’d love your feedback on this post and your ideas on how to expand this vision for privacy-preserving open economies that gain from network effects! Please post here on the Secret Forum - we’d be happy to hear your thoughts and connect.
Onwards and upwards!
~ Guy Zyskind, Enigma CEO and cofounder
Thanks to Can Kisagun, Tom Schmidt, Avichal Garg, Ash Egan, and Zaki Manian for their comments and review of this article and concepts.