Zeynep Ekşi
Digital Marketing Specialist
August 12, 2024
Noir: The Rising Star of Zero-Knowledge Development
Noir, introduced in October 2022, is a domain-specific language (DSL) designed for zero-knowledge (ZK) programming. It offers a high-level programming language with syntax similar to Rust, and its main goal is to make the process of developing ZK applications simpler. The language compiles down to ZK circuits but it's also “platform-agnostic” (designed to operate across various systems), and this makes Noir available for various proving systems.
Noir was created as an open-source language by Aztec Labs, and one of the other goals of Noir is to create a general ZK programming language that can be used by everyone, and also independent of any specific platforms and this means allowing the developers to build their Full-stack without necessarily integrating with any of the Aztec’s systems.
Architecture and Goals
Architecture of Noir is designed to support the Layer 2 ecosystem that reflects the smart contract capabilities of Ethereum but with private state as default. This pretty much means that private data is the default and developers can easily incorporate private information into their applications. Achieving this especially requires a solid and fast working ZK proving system, and Noir’s architecture provides this with a language mainly designed to program these contracts.
Noir has an official reference repository called Noir-Starter, a full-stack project using Next.js and Hardhat, serving as an excellent starting point for those interested in Noir development.
How Noir Works
Noir’s compiling system is an intermediate representation called ACIR (Abstract Circuit Intermediate Representation), and this acts like a middle-man, rather than compiling directly to circuits or constraints. This step allows the ACIR program to be translated into constraints compatible with any cryptographic backend that could be used. This design is actually similar to how programming languages compile to an intermediate representation before being translated to machine code for various architectures.
Noir is a modular language, and this allows it to be more flexible, and while it is possible to use Noir in different contexts, like the Miden error context, it may not be the fastest option as it involves also converting the IR to other forms of IR.
Installing and Using Noir
Noir is built on Rust, and it borrows its fast execution speed and strong safety with the compile-time checks. Like mentioned before in this article, it comes with lots of helpful tools and libraries for building, proving, and verifying zero knowledge circuits.
After installing Git and Rust, developers should first clone and get in the Noir project directory, and install Nargo. Nargo is the command-line tool for interacting with Noir programs (much like Rust’s cargo), and supports various commands for compiling, proving, verifying, and more. These characteristics of the language allows developers to use Noir without needing a background in ZK proofs.
Here’s a basic example to demonstrate creating and verifying a proofs in Noir, which can also be found in the Noir Docs:
Basic Example: Hello, World for a Noir Proof
First, we should create a new Noir Project:
Navigate to the project directory and compile:
Two files will be generated from this process. Prover.toml for input values, and Verifier.toml for public values.
And main.nr should be looking like this:
Like the data, inputs in Noir are also private by default. However, if you want to use a public input on a specific part, you are free to do so as long as you label it using the `pub` keyword. After setting input values in the `Prover.toml`s file, (for example x=”1” and y=”2”), you prove and verify the proof:
You’ve done it! 🎉
Here are some use-cases which we think are helpful for understanding the idea of the language.
- Private Transactions: Handle confidential transactions on blockchain networks where transaction details remain hidden.
- Identity Verification: Implement identity systems where users can prove their identity without revealing sensitive information. (a classic example, but: you are supposed to get authorized to enter a dapp, and the condition is for you to be at least 18 years old. Now, you are 24 but you don’t want them to know that, only thing they should know is you are either 18 or older)
- Gaming: Build zk-based games where certain aspects of the game (card hands, strategy games, etc.) remain fully-private until converted into public.
- zk-SNARKs for Voting: Create secure and private voting systems that ensure voter privacy and also election integrity.
Noir aims to improve zero-knowledge proof development by providing a high-level and easy-to-use language. Especially, if you know Rust from before, we assure you that you don’t got much to worry about. Its architecture, based on an intermediate representation, allows flexibility and modularity across different proving systems. Noir's open-source nature and extensive tooling make it an ideal choice for developers looking to build privacy-preserving applications efficiently and securely.
By avoiding the complex and complicated parts of underlying cryptographic operations, Noir helps developers to focus on application logic, making zero-knowledge proof technology more accessible and practical for a wider range of applications.
*We sincerely thank Aztec Labs for providing the visual featured in this blog post.