Today we’re announcing Aztec.nr, a powerful new smart contract framework for Aztec applications. Aztec.nr enables smart contract developers to intuitively manage private state.
In other words, Aztec now has a smart contract language.
Aztec.nr is a framework built on top of Noir, an open-source, universal zk programming language to which Aztec Labs is a core contributor.
Aztec.nr allows developers to write private smart contracts in Noir and extend their functionality with templated functions that simplify state management.
Last week we teased how simple and intuitive private state management would be on Aztec.
📕 Read the first post in this series: Privacy Abstraction with Aztec
Today we’re explaining how Aztec.nr works and showing how you can get started building smart contracts and full-fledged privacy-preserving applications on Aztec.
The point of Aztec.nr
The Aztec.nr framework helps you deal with complex note management that is critical to privacy preservation within smart contract development.
But it does so in a way that makes it so that developers don’t have to rebuild smart contract functionality from scratch every time they write a Noir program.
Without Aztec.nr, you wouldn’t be able to emit events, make calls to other contracts, or even have the notion of a contract or an address. You’d have no
msg.sender or access to historic blockchain.
Aztec.nr takes Noir — a general zero knowledge programming language — and gives it the smart contract functionality and syntax developers might expect coming from Solidity.
Developers can now access a complete set of smart contract features:
- Contracts (including callable contract functions and inter-contract function calls)
- Persistent state variables
- Contract address semantics
- Access to msg.sender and other call context information
- Access to transaction context information
- Access to historic blockchain data
- Events (logs) (both encrypted and unencrypted)
- Cryptographic primitives
- Cross-chain (L1 -> L2 and L2 -> L1) message passing
For examples of Aztec.nr at work, check out examples of:
How we got here
At Aztec Labs we harbor two very strong beliefs:
- Privacy is the major unlock for the next leg of adoption. Having every single address, transaction, and balance exposed in plaintext is a non-starter for everyday users, businesses, and institutions coming on-chain.
- Privacy UX has to be better than the existing state of the art in blockchains. Privacy-preserving technology is only useful if the experience of using it isn’t better than what is available today.
The Aztec.nr framework is a major step in improving the developer experience for managing private state — functionality that “vanilla” Noir doesn’t have.
For example for a simple private token contract, Aztec.nr includes helper functions like:
In other words, the kinds of functions you might expect to call in a standard token contract!
Let’s walk through this private token contract to show you how Aztec.nr helps with abstracting private note management:
Follow along in the Github repo of our private token contract example here
Say Alice wants to send funds to Bob. Practically, she would have to aggregate all of the existing non-nullified notes they have of the asset she were sending, add up the values, and once she had enough notes to send the amount, create a change note to reconcile her balance.
For example, say Alice had two UTXO’s of 0.25 ETH each, and wanted to send 0.4 ETH to Bob. In order to spend the note Alice would have to sum the two 0.25 ETH notes together, nullify them both, and create a change note for herself of 0.1 ETH.
Thankfully, Aztec.nr makes it easy to manage notes. Take for example the
decrement_by_at_most functions written by the Aztec Labs team for the private token example above.
Follow along with the
1. Find notes to decrement. The function begins by getting some notes that add up to
max_amount or less from the set of notes owned by
2. Destroy selected notes. It then iterates over these selected notes and destroys them, adding their values to a variable
3. Handle Change: If the total value of the destroyed notes (
decremented) is greater than
max_amount, it creates a new note with the excess value (
change_value) and assigns it back to the owner.
4. Return the Decrement: Finally, the function returns the total value that was decremented, which is stored in
decrement example is a perfect showcase for how Aztec.nr makes it easy to manage notes and nullifiers with built-in
If a dev wanted to write this without Aztec.nr (as in, write it with “vanilla” aka non-smart-contract Noir), they would have to write their own Merkle trees to insert and prove membership of notes and support non-membership checks for nullifiers.
But as a developer, you don’t have to worry about rebuilding core privacy primitives — the Aztec Labs team has already done all of that work on your behalf.
You just focus on smart contract logic.
When will I get to play with all this cool tech?
Soon, anon, soon.
We’ll soon release a local developer environment for developers to write and test Aztec smart contracts against a local instance of an Aztec node.
Developers will soon get a full-fledged development kit for building smart contracts and applications on Aztec, supported by Aztec.nr’s functionality.
But for now, you can preview what comes in the box.
Explore the Aztec.nr Github repo here
Start familiarizing yourself with Noir syntax, since Aztec.nr is simply a smart contract framework written in vanilla Noir.
To get started learning Noir, check out:
Finally, sign up for Aztec Labs’ developer e-mail list to stay apprised of all technical developments across Noir and Aztec:
Join our team
Aztec Labs is on the lookout for talented engineers, cryptographers, and business people to accelerate our vision of encrypted Ethereum.
If joining our mission to bring scalable privacy to Ethereum excites you, check out our open roles.
And continue the conversation with us on Twitter.