The Big Unlock: Easy, Powerful, Production-Grade zkApps Are Coming to Mina

TL;DR: Mina’s major upgrade brings about innovative zero knowledge use cases, introducing the ability to execute smart contracts off-chain within client-side environments like browsers or servers.


TL;DR: Mina’s major upgrade brings about innovative zero knowledge use cases, introducing the ability to execute smart contracts off-chain within client-side environments like browsers or servers. This post explores the significance of zkApps (zk-enabled applications), their potential impact on Web3, and the crucial role of Mina’s upcoming Berkeley Upgrade.

In the rapidly evolving landscape of Web3, recent breakthroughs in zero knowledge have ushered in a new era. From faster rollups and light clients to bridges, advancements in zk infrastructure have been making waves. But we believe a truly game-changing capability has emerged — the execution of smart contracts entirely off-chain, within client-side environments such as browsers or servers.

Take it off-chain!

How is this possible? The crux of this innovation lies in crafting smart contracts using zk application (zkApp) code. This code ensures tamper-proof execution and is capable of proving correct operation to third parties without introducing new trust assumptions, essentially mirroring the functionality of on-chain smart contracts.

The implications of these zk-enabled apps are profound. By moving smart contract execution off-chain, numerous challenges associated with on-chain execution — such as gas costs, data constraints, scale limitations, and time lags — can be overcome. Additionally, zkApps offer enhanced privacy that allow for the verification of sensitive information, like age, without revealing precise personal details such as the date of birth.

The introduction of zkApps is poised to unleash a wave of innovation, breathing new life into the Web3 cypherpunk ethos and revitalizing ideas from the past 5–10 years that were once considered unattainable.

But anchor it back on-chain!

Despite the off-chain capabilities of zkApps, anchoring back to the chain still remains crucial. Mina’s Berkeley Upgrade, after more than two years in development, is reaching its final stages of preparation. Why do zkApps need a chain? Because off-chain zkApp proofs require verification, and leveraging a chain brings several compelling trust and verification advantages:

  • Automated, expert verification by a neutral entity — the chain itself
  • Automatic triggers for subsequent actions based on verifications (for example, when you prove you are over 18, your DeFi account opening completes and your deal closes)
  • Eternal storage of verifications for future reference
  • Verifications that are bridged to other chains

Let’s face it, between off-chain smart contracts and on-chain verification, verification sounds like the far less sexy step, but it’s the anchor of everything, and it’s where the benefits of the off-chain approach can erode quickly if not done right. Without a purpose-built chain like Mina, smart contract verification can be big, complex, and gas-expensive. Mina has been built from the ground up to handle zero knowledge proofs (ZKPs). After the Berkeley Upgrade, the Mina blockchain will be an excellent place to verify proofs from off-chain applications. Why will Mina be a great place to verify zkApps?

  • There will be no gas cost. The cost to verify a proof on-chain will always be cheap, regardless of whether the off-chain smart contract is small or the size of a football field.
  • Mina’s tiny state means that in the near future a full node should be able to run in a user’s browser, allowing proofs to be submitted without using a third-party Remote Procedure Call (RPC) protocol — perfect for privacy.
  • Mina’s tiny state also means it can be represented on other chains using state-proof-based bridges (no tokens to hack), so Mina can act as a modular proof layer for the whole of Web3. Among many other things, this could allow you to write a zk application once, verify output once on Mina, and then bridge the verification to multiple other chains. Presto! An instant, multi-chain DApp.

Verification can happen directly on EVM chains, but in the software world, we all know that ‘can’ does not equal ‘should’. EVM could in theory also be used as a data availability (DA) layer and decentralized sequencer for other chains, but the Web3 world is already convinced that modularity is the way to go for those specialized functions, and verification of proofs is a highly specialized function.

The off-chain revolution

Let’s get back to the application code. Looking forward to the rest of 2024, we at o1Labs anticipate a surge in applications and use case innovation driven by zk off-chain computation. This off-chain revolution brings several exciting possibilities of what’s newly possible:

  • Gas-free computation: zk off-chain computation allows for gas-free computation of unlimited size, trustlessly.
  • Verifiable privacy: Client-side zk ensures widespread availability of verifiable privacy.
  • Web2 data usage: ‘Notarization’ using multiparty computation (MPC) and ZK enables everyday usage of Web2 data.
  • Easy building of zkApps: New Domain Specific Languages (DSLs) like o1js, using TypeScript, make it fast and easy for developers to build zk applications.

o1js: Making zk code off-chain accessible

Building zk code off-chain has been possible in the past, but only with difficulty. o1js makes it easy. By leveraging TypeScript, o1js provides a high-level, intuitive language that you can deploy and maintain more easily. Because o1js enables WebAssembly (WASM) features, your zkApp can also run seamlessly in a user’s browser. Furthermore, multiple proofs from off-chain calculations can be rolled up and compressed back into a single small proof using the o1js recursion capability.

o1js has been available since 2022, and it’s not only matured, it’s also gaining new capabilities. A recent, exciting round of add-ons to o1js’ basic capabilities is enabling a wide range of inputs to a zk application. Examples include:

  • The release of ECDSA and Keccak handling primitives, so that you can use data from Ethereum sources, signed by MetaMask.
  • Support for SHA-256 cryptography, which underpins many sources of data in the Web2 world, for example, passport data.
  • Notarization and witnessing primitives that enable information from Web2 sessions to become attested data (e.g., your bank account balance). Stay tuned for more on this!

Join the zkApp revolution

The advent of zkApps on Mina marks a pivotal moment in the evolution of Web3, unlocking a realm of possibilities that were once deemed impractical. We’re excited to see what the ecosystem will build after the Berkeley upgrade. Stay up-to-date on the latest with Berkeley by following us on Twitter/X, and joining the Mina Discord.