*Update: Leila Wang from our team made a much more convenient tool where you can experiment with what’s written below directly in a browser*

Hey,

I made this very basic tool for people wanting to experiment with barretenberg easily.

It only supports what we call “standard PLONK”,

where you have a single type of add-multiply gate as I will explain (see also here).

To use it you should build barretenberg as explained in the README; but use this branch).

Now in the `build`

directory, you will create a file called `constraintsystem.json`

Here is an example of what to put in it:

`{"varnum":4,"pubvarnum":0,"constraintnum":1,"constraints":[{"a":1,"b":2,"c":3,"ql":1,"qr":1,"qm":0,"qo":-1,"qc":0}]}`

`varnum`

- is the total variable numbers

`pubvarnum`

- is the number of public variables (though this will be ignored for now)

`constraintnum`

- is the total number of constraints.

`constraints`

- is an array describing the constraints, where each constraint has the following form:

`a,b,c`

are integers describing the indices of the witness variables to be used in the constraint.

Suppose the variables used in the constraint are `x,y,z`

.

The constraint itself has the form

q_l\cdot x + q_r\cdot y + q_o\cdot z + q_m\cdot x\cdot y + q_c =0.

For the constants `ql,qr,qo,qm,qc`

of the constraint.

Thus in the above example the constraint is x+y=z.

Now in the `build`

directory, also create a file `witness.json`

of the following form, for example:

`{"witness":[0,1,2,3]}`

For technical reasons, the vector must always start with a zero, followed by the actual witness values.

Note that this sequence of values indeed satisfies the constraint.

Now to generate a proof and verify it, run from the same directory:

`./src/aztec/plonk/composer/composer_tests --gtest_filter=standard_composer. prove_and_verify_from_file`

You can try modifying the witness so that the last value is not the sum of the former two, and see if it rejects.

You can make your own examples, but here is one more for the pair of constraints x+y=z, y\cdot z +1=w:

`{"varnum":4,"pubvarnum":0,"constraintnum":2,"constraints":[{"a":1,"b":2,"c":3,"ql":1,"qr":1,"qm":0,"qo":-1,"qc":0},{"a":2,"b":3,"c":4,"ql":0,"qr":0,"qm":1,"qo":-1,"qc":1}]}`

`{"witness":[0,1,2,3,7]}`

## Separate proving and verifying

Suppose you want to write the proof into a file, instead of proving and verifying in one test.

With the same files `witness.json`

and `constraintsystem.json`

in the directory, use:

`./src/aztec/plonk/composer/composer_tests --gtest_filter=standard_composer. write_proof_and_keys_to_file`

This will write the proof, proving key and verifying key to the files `proof.data,pk.data,vk.data`

respectively.

To verify, you must add a file `PI.json`

with public inputs, e.g.

`{"pubvarnum":1,"PI":[1]}`

And now run

`./src/aztec/plonk/composer/composer_tests --gtest_filter=standard_composer. write_proof_and_keys_to_file`

You are encouraged to try and tinker with the test code.