Skip to content

functionally/noir-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Development environment for Noir

A Nix development environment with Noir and related ZK tools.

Entering the environment

One can either clone this repository and enter the development environment from within it:

git clone https://github.com/functionally/noir-env
cd noir-env
nix develop

Or enter the environment without cloning the repository:

nix develop github:functionally/noir-env

Available tools

The following command-line tools are available in this enviornment.

Example

1. Create a new project

$ nargo new example

$ cd example

Project successfully created! It is located at noir-env/example

$ tree

.
├── Nargo.toml
└── src
    └── main.nr

$ cat src/main.nr

fn main(x: Field, y: pub Field) {
    assert(x != y);
}

#[test]
fn test_main() {
    main(1, 2);

    // Uncomment to make test fail
    // main(1, 1);
}

2. Create a Prover.toml file for the inputs

$ nargo check

$ cat Prover.toml

x = ""
y = ""

3. Set the inputs x = 1 and y = 2

$ sed -e 's/x = ""/x = "1"/' -e 's/y = ""/y = "2"/' -i Prover.toml

$ cat Prover.toml

x = "1"
y = "2"

4. Compile and execute the circuit

$ nargo execute

[example] Circuit witness successfully solved
[example] Witness saved to target/example.gz

5. Create the proof

$ bb prove -b ./target/example.json -w ./target/example.gz --write_vk -o target                                                                                                                        

Scheme is: ultra_honk, num threads: 16 (mem: 12.69 MiB)
CircuitProve: Proving key computed in 11 ms (mem: 32.10 MiB)
WARNING: computing verification key while proving. Pass in a precomputed vk for better performance. (mem: 32.10 MiB)
Public inputs saved to "target/public_inputs" (mem: 35.10 MiB)
Proof saved to "target/proof" (mem: 35.10 MiB)
VK saved to "target/vk" (mem: 35.10 MiB)
VK Hash saved to "target/vk_hash" (mem: 35.10 MiB)

$ tree

.
├── Nargo.toml
├── Prover.toml
├── src
│   └── main.nr
└── target
    ├── example.gz
    ├── example.json
    ├── proof
    ├── public_inputs
    ├── vk
    └── vk_hash

3 directories, 9 files

6. View the public inputs

od -t x1 -w32 target/public_inputs

7. Verify the proof

$ bb verify -p ./target/proof -k ./target/vk -i ./target/public_inputs

Scheme is: ultra_honk, num threads: 16 (mem: 12.69 MiB)
Proof verified successfully (mem: 15.73 MiB)

About

A Nix development environment with Noir and related ZK tools.

Topics

Resources

License

Stars

Watchers

Forks

Languages