Getting Started
Installation
-
Install dependencies, you'll only need two things: the nix package manager and direnv. They're compatible with most OSes and will not collide with your system.
After installing
direnv
do not forget to add the hook! -
Clone our repository with SSH:
git clone https://github.com/blocksense-network/noir.git
-
Navigate to the folder
noir
.cd noir
-
Run direnv command:
direnv allow
Depending on your
nix
installation, you may get aPermission denied
error. In that case, it's best to start a superuser shell and continue from there:sudo su # Start superuser shell eval "$(direnv hook bash)" # Setup the direnv hook direnv allow
This should result in a plethora of things happening in the background and foreground. Sit back, relax, and wait it out. By the end you'll have everything ready to start work.
-
Test if everything works:
cargo test zk_dungeon
This will also take a little bit of time, until the project fully compiles.
Using
We're now ready to create our first proof!
-
Create a new project:
nargo new my_program
-
Navigate to the folder:
cd my_program
-
Update the program with your favorite text editor to:
fn main(x: pub u64, y: u64) { assert(x % y == 0); }
This program allows one to prove that they know of a private factor
y
of a public integerx
. -
Run a small check to generate what you need:
nargo check
-
We're almost there, change prove inputs to:
x = "4611686014132420609" y = "2147483647"
-
Finally, we're ready to start proving:
nargo prove
Congratulations 🎉, you've made your first proof! Now we can verify it:
nargo verify
You've now successfully written and proven a Noir program! Feel free to play around, for example, if you change y
to 3
in Prover.toml
, you'll get a prove error.
Once you're done, head over to noir-lang.org and start learning about the language.