ZRCLib

Open Source SDK For Developers to Easily Build Private DeFi Primitives

Problem ZRCLib Solves

Privacy, interoperability, and ease of development are significant challenges for developers looking to build private DeFi primitives. ZRCLib, a robust Software Development Kit (SDK), addresses these issues by offering zero-knowledge privacy primitives for developers on Ethereum Virtual Machine (EVM) compatible chains. With ZRCLib, developers only need a few lines of code to build private DeFi primitives such as private transfer and private swap, without needing prior knowledge on ZK, as seen on example below (more details in the README in Github).

Get the standard ethers contract
const token = await ethers.Contract(address, abi, signer);

const account = Account.create(token, "password123");
await account.loginWithEthersSigner(signer);

// Generate proof that shields 1 token
const shieldProof = await account.proveShield(1e18);
await token.deposit(shieldProof);

// Generate proof that sends 0.5 tokens to toAddress
const transferProof = await account.proveTransfer(5e17, receiver);
await token.tranfer(transferProof);

Supported Features

ZRCLib currently supports a few features as described below.

Multi-Asset Shielded Pool: This feature adds an extra privacy layer for all tokens by hiding the sender, receiver, transaction amount, and asset type during internal transfers. It supports a wide array of token types like ERC20, ERC721, and ERC1155 at the circuit level, increasing the interoperability of the system and anonymity set, therefore also suitable for long-tailed assets.

Privacy-protected Swaps: ZRCLib provides a mechanism for executing asset swaps while maintaining the utmost privacy and avoiding liquidity bootstrapping issues. It achieves this by following the Un-shield -> ExecSwap -> Re-shield flow, making it a valuable tool for privacy-focused DeFi. With this mechanism, users can swap tokens within the shielded pool in one single transaction, and not losing privacy.

SDK API Design: ZRCLib also provides a well-designed API and abstracting the complexity of zero-knowledge proof mechanics. This makes it easier for developers to integrate privacy features into their blockchain applications. For example, the SDK handles all the client side proof generation.

To illustrate how the SDK can be used, we built a few examples - a decentralized private stablecoin and a wallet that allow users to do private deposits, transfers and swaps (located in the "examples" directory in the repository).

Summary

ZRCLib is an public goods open source library that empowers developers to build private DeFi primitives that are modular and composable with each other, without needing background or knowledge in ZK. We believe that privacy is a core layer in making DeFi applications more widely adopted in real world use cases.