Skip to content

Cyfrin/noir-programming-and-zk-circuits-cu

Repository files navigation

⚠️ Important: If you're looking for the foundry-full-course or moccasin-full-course you can find them here:

Foundry/Solidity: https://github.com/Cyfrin/foundry-full-course-cu

Moccasin/Vyper: https://github.com/Cyfrin/moccasin-full-course-cu

Noir Programming and ZK Circuits

An introduction to building circuits using Noir and using them to build on-chain privacy projects.

Stargazers Forks Contributors Issues MIT License



Welcome to the repository for the Noir Programming and ZK Circuits Course

This repository houses course resources and discussions for the course.

Please refer to this for an in-depth explanation of the content:

  • Website - Join Cyfrin Updraft and enjoy 50+ hours of smart contract development courses
  • Twitter - Stay updated with the latest course releases
  • LinkedIn - Add Updraft to your learning experiences
  • Discord - Join a community of 3000+ developers and auditors
  • Newsletter - Weekly security research tips and resources to level up your career
  • Codehawks - Smart contracts auditing competitions to help secure web3
  • Noir developer discord

Noir ZK Circuit Developer


Cyfrin Updraft Courses:

YouTube Link

Disclaimer

⚠️ All code associated with this course is for demo purposes only. They have not been audited and should not be considered production ready. Please use at your own risk.

The following content is provided strictly for educational purposes. This course demonstrates how privacy-preserving smart contracts like mixers work under the hood using zero-knowledge proofs. It is not intended to promote or encourage the use of privacy tools for illicit activity. We do not condone the violation of any laws or regulations. Please ensure you comply with your local laws when building or deploying smart contracts.

By continuing with this course, you acknowledge that the code and concepts shared are for learning only, and you accept full responsibility for how you use them.

Resources For This Course

Section 1: Welcome to Noir

Welcome

⌨️ Welcome

Introduction and Prerequisites

⌨️ Introduction and Prerequisites

Meet the Instructor

⌨️ Meet the Instructor

Why take this Course

⌨️ Why take this Course

Course Navigation

⌨️ Course Navigation

Section 2: ZK ECRecover

💻 Code: https://github.com/Cyfrin/zk-ecrecover-cu

Intro to Noir

⌨️ Intro to Noir

Noir Architecture

⌨️ Noir Architecture

ZK Protocol Architecture

⌨️ ZK Protocol Architecture

Nargo and Barretenberg Installation

⌨️ Nargo and Barretenberg Installation

Creating a Noir Project

⌨️ Creating a Noir Project

Noir Project Types and Layout

⌨️ Noir Project Types and Layout

Noir Data Types

⌨️ Noir Data Types

Assert and Test Functions

⌨️ Assert and Test Functions

Creating and Verifying a Proof Off-chain

⌨️ Creating and Verifying a Proof Off-chain

Using Dependencies in Noir

⌨️ Using Dependencies in Noir

Writing a Signature Verification Circuit

⌨️ Writing a Signature Verification Circuit

Creating the Noir ECDSA Inputs

⌨️ Creating the Noir ECDSA Inputs

ECDSA Proof and Verifier Contract

⌨️ ECDSA Proof and Verifier Contract

Noir ECDSA Summary

⌨️ Noir ECDSA Summary

Section 3: ZK Panagram App

💻 Code: https://github.com/Cyfrin/zk-panagram-cu

Introduction

⌨️ Introduction

Panagram Project Walkthrough

⌨️ Panagram Project Walkthrough

Creating the Panagram Circuit

⌨️ Creating the Panagram Circuit

Panagram Contract Setup

⌨️ Panagram Contract Setup

Inheriting ERC-1155

⌨️ Inheriting ERC-1155

Setting the Verifier Contract

⌨️ Setting the Verifier Contract

Writing the Panagram Contract Functions

⌨️ Writing the Panagram Contract Functions

Compiling the Panagram Contract

⌨️ Compiling the Panagram Contract

Starting the Tests

⌨️ Starting the Tests

Running Scripts in Forge Tests

⌨️ Running Scripts in Forge Tests

Setting up the Generate Proof Script

⌨️ Setting up the Generate Proof Script

Get Proof Function

⌨️ Get Proof Function

Writing the Proof Script

⌨️ Writing the Proof Script

Finishing the Tests

⌨️ Finishing the Tests

Panagram Recap

⌨️ Panagram Recap

Frontend Walkthrough

⌨️ Frontend Walkthrough

Fixing Bugs

⌨️ Fixing Bugs

Summary

⌨️ Summary

Section 4: ZK Mixer

💻 Code: https://github.com/Cyfrin/zk-mixer-cu

Introduction

⌨️ Introduction

Disclaimer

⌨️ Disclaimer

Tornado Cash

⌨️ Tornado Cash

Creating the Mixer Contract

⌨️ Creating the Mixer Contract

Creating the IMT Contract

⌨️ Creating the IMT Contract

Zero Subtrees

⌨️ Zero Subtrees

Inserting a Leaf

⌨️ Inserting a Leaf

Finishing Deposit

⌨️ Finishing Deposit

Nullifier Hash

⌨️ Nullifier Hash

Circuit Inputs

⌨️ Circuit Inputs

Circuit Logic

⌨️ Circuit Logic

Generate Verifier

⌨️ Generate Verifier

Finish Withdraw

⌨️ Finish Withdraw

Historical Roots

⌨️ Historical Roots

Mid way Summary

⌨️ Mid way Summary

Building the Project

⌨️ Building the Project

Setting up the tests

⌨️ Setting up the tests

Generate the Commitment

⌨️ Generate the Commitment

Testing Making a Deposit

⌨️ Testing Making a Deposit

Creating the Proof Helper Function

⌨️ Creating the Proof Helper Function

Generate Proof Script

⌨️ Generate Proof Script

Finish Withdraw Test

⌨️ Finish Withdraw Test

Reentrancy

⌨️ Reentrancy

## Unused Circuit Inputs

⌨️ unused-circuit-inputs

NATSPEC

⌨️ NATSPEC

Summary

⌨️ Summary

References

The following resources were consulted in creating this course:

Disclosures

Transparency is important! So we want to disclose any potential conflicts that might have affected my judgement so you can pick tools that are right for you. Patrick is co-founder of Alpha Chain, a blockchain infrastructure company. Alpha Chain runs Chainlink, Ethereum, Binance, Polygon, Harmony, Solana, Moonbeam, and Moonriver blockchain services. Alpha Chain often works with Alchemy and receives discounted services. Patrick is the co-founder of Cyfrin, and they do smart contract security & auditing services. Patrick is also the co-founder of Chain Accel, who is an advisor on the Peeranha project.

Because of all this, I have added alternatives to each section where we suggest a tool.

Sponsors

A huge thank you to our sponsors. These are the groups and technologies

Thank you

Thanks to everyone who is taking, participating in, and working on this course. It's been a passion project and a data dump of everything I've learnt in the web3 space to get you up to speed quickly. Also, a big thank you to Cyfrin & Chain Accel for encouraging this course to come to light, and many, many, many people from the community.

And thanks to the Cyfrin team for making this possible!

License

Cyfrin Updraft content is open-sourced licensed as GPLv3.

Cyfrin Twitter Cyfrin YouTube Cyfrin LinkedIn

(back to top) ⬆️

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published