Last updated a month ago
Implementing zk-dApps in Cardano is a difficult task due to the limited availability of verifiers and the lack of tooling for circuit construction, creating barriers for developers.
This is the total amount allocated to Designing an API for ZK-Snark proof verification in Aiken - Eryx. 1 out of 5 milestones are completed.
1/5
Research and Selection of Proving System
Cost: ₳ 30,000
Delivery: Month 1 - Feb 2025
2/5
Develop Circuit Library
Cost: ₳ 60,000
Delivery: Month 3 - Apr 2025
3/5
On-Chain Verification
Cost: ₳ 50,000
Delivery: Month 4 - May 2025
4/5
Develop Gadgets for Advanced Circuits
Cost: ₳ 30,000
Delivery: Month 5 - Jun 2025
5/5
Final Polishing and Documentation
Cost: ₳ 30,000
Delivery: Month 6 - Jul 2025
NB: Monthly reporting was deprecated from January 2024 and replaced fully by the Milestones Program framework. Learn more here
Simplify zk-dApp development by creating an intuitive API for circuit construction and ZK-Snark proof verification in Aiken, enhancing developer experience and reducing complexity.
No dependencies.
The tools will be open source and available on GitHub under the Apache 2.0 license.
There are some on-chain proving systems already in the Cardano Ecosystem (like Groth16, Plonk (1), (2), and Bulletproofs). Yet there’s still a need for an easy way to use them in a smart contract.
In our ideal world, we would code our smart contracts in Aiken with the ability to define “private” or “off-chain” functionality depending on “privacy” settings. This would automatically compile into a set of ZK-circuits and Plutus code, that would allow an off-chain prover to run “private” functions, that would then be verified on-chain. By building appropriate tooling we can hide most of the ZK-jargon under the hood.
There are projects in other ecosystems that are going in this direction with some degree of success. One example is Noir. This DSL allows programmers to code functions with private and public inputs in a syntax similar to rust, and compiles to ACIR (Abstract Circuit Intermediate Representation), allowing different proving backends. Another example is o1js, this programming language is an extension of TypeScript that allows describing circuit constraints in a straightforward fashion inside smart contracts. Another example of DSL that provides provable code is Cairo, although its verifier uses a STARK-based proving system. All these options help developers by abstracting away some of the complexity of writing provable code.
Our final goal is to implement similar solutions in Cardano, that would allow programmers to implement smart contracts with some “off chain” functions.
The spirit of this proposal is to be a first step in that direction. We aim to develop an Aiken library that provides an easy to use API for the construction of ZK-circuits and its verification. Some popular proving systems such as Plonky2 provide this kind of functionality.
The requirements are:
One would think that since the circuit generation happens off-chain it is not necessary to write it in Aiken. Although this is true, our expected user is a smart contract developer, and the idea is that learning another language shouldn’t be a prerequisite to use ZK in the first place.
One important design choice is which proving system to support as a first approach. Some considerations in this regard are:
The mechanisms to send transactions and generate the offchain proofs are out of the scope of this proposal, but will be considered in our design choices. As an example, o1js instantiates the smart contract as an object, which you provide to the Tx, and then you can call prove() on said Tx before signing it and sending it. An idea would be integrating MeshJS to easily support the ZK proving counterpart of the on-chain verifiers.
Aiken is a modern and widely used language for developing smart contracts in Cardano. This proposal aims to give Aiken developers the ability to seamlessly write circuits that can be verified on-chain.
Zero-Knowledge (ZK) smart contracts would benefit the Cardano ecosystem in two important directions:
Eryx is a worker-owned labor cooperative with over 10 years of experience solving complex problems involving mathematics and software. We are a group of nerdy PhDs with a solid background in math and computer science. Our team has extensive experience in blockchain development, cryptography, and privacy-focused protocols, which gives us the expertise required to successfully deliver the project.
Among other things, we’ve been core contributors to the Lambdaworks library and implemented the CircleSTARKS protocol in GPU alongside with Nethermind. This involved implementing several ZK cryptographic primitives (field operations, polynomial commitment schemes, FRI protocols, FFTs), in different platforms and languages. Furthermore, we implemented a proving system based on the Plonk protocol. During this project we wrote a simple interface to design circuits. It included basic operations and conditionals that made the building blocks for more complex cryptographic primitives.
In relation to this proposal, we recently developed a Plonky2 backend for Aztec's Noir, funded by the Ethereum Foundation. During this project we learned much about DSL compilers and how they interact with proving systems. Also, we extended Plonky2 with several gadgets that were necessary to be fully compatible with Noir code.
Research: Compare different options of proving systems and existing libraries in the ecosystem, taking into account their limitations. Select one of these to use as a first verifier. Some of the features we would like to review are proof size, proving and verifying time, popularity, recursion friendly, and support for optimizations such as lookups and range checks.
Circuit library: implement a library for circuit construction in Aiken. This library will be compatible with the chosen verifier. Generate a set of primitives that allow for the creation of basic programs. These would include simple operations such as assert_eq, add, sub, neg, mul and conditionals. Code an example program such as Fibonacci.
On-chain verification: Once we have a basic circuit, we aim to make the library compatible with the chosen verifier. We will verify a simple program on the testnet.
Gadgets: add a series of gadgets that allow for the creation of more complex programs using advanced cryptographic primitives without the need of implementing them from scratch. At these step we’ll research other tools and look for input from the community to build the most impactful gadgets. These gadgets will provide ready to use high level zk-constraints for hashes, merkle trees, polynomial evaluation and polynomial interpolation among other primitives.
Final polishing and documentation: Refactors, extended testing, writing comprehensive documentation and tutorials.
Final Report:
Sergio Chouhy
Agustín Garassino
Carlo Ferrari
Agustin Franchella
The rest of the Eryx team will be available to contribute or advise on this proposal as needed.
Budget Breakdown
FTE = Full-time equivalent
Development: ₳180,000 total
The activities of this item will consider: Aiken Development; Mathematical and cryptographical research; circuit design and integration.
Cardano developer: 0.5 FTE x 4 months = ₳60,000
ZK Cryptographer: 0.5 FTE x 4 months = ₳60,000
ZK Cryptographer: 0.5 FTE x 4 months = ₳60,000
Project Management: ₳20,000
The activities of this item will be: Organize the project execution, create reports and write the documentation, and maintain communication with the community and reviewers.
Project Management: ½ FTE x 4 months = ₳20,000
Total Budget Request: ₳200,000
We decided to focus on spending the expenses of the project in the development hours. In that regard, it is important to note:
Development hours: 960 hours
Cost per hour (₳): 188₳
Cost per hour ( at $0.35 * ₳): $65
Developer projected annual salary: 135,200 dollars
The projected annual salary is around $140,000 USD a year per developer. According to https://web3.career/web3-salaries/blockchain-develope is within the range of salaries of developers, these salaries vary from $50,000 to $250,000 with an average of 140,000 up to 200,000k for the web3 developer.