This module is part of Nightfall. Most users will only be interested in using the application as a whole, we direct those readers to the main README. This file provides additional information on how this module works so you can learn about, tinker and improve it.
You will need to have completed the trusted setup. This is done simply by running (from the Nightfall root):
./nightfall-generate-trusted-setup
If you have previously run the Nightfall application, you will already have completed this step and there is no need to repeat it (it takes about and hour so it's worth avoiding where possible!).
Alternatively, if you change one of the proofs in the Nightfall suite, then you can perform the trusted setup for just that proof, which is a lot faster by running
npm run setup -- -i gm17/<dir containing your proof>
Also, before running these tests, don't forget to make sure you have a current version of the zkp container. If in doubt, run:
docker-compose build zkp
After your trusted setup is complete run:
docker-compose run --rm truffle-zkp compile --all && docker-compose run --rm truffle-zkp migrate --reset --network=default
This will run ganache in a container; compile all of the nightfall contracts; and deploy them.
To run the zkp unit tests (in another terminal window):
docker-compose run --rm zkp npm test
The relevant files for these tests can be found under zkp/__tests__
.
f-token-controller.test.js
- These are units tests to verify mint, transfer and burn of ERC-20 tokens and ERC-20 commitmentsnf-token-controller.test.js
- These are units tests to verify mint, transfer and burn of ERC-721 tokens and ERC-721 commitmentsutils.test.js
- These are unit tests for utils used for running the tests.
Note that the zkp service tests take a while to run (approx. 1 hour)
Running the zkp module as part of the fully application is handled by Docker Compose. But you will be running this directly on your machine. Prerequesites for development of Nightfall are documented in the main project README. Satisfy those first before proceeding.
Build and run service (on port 80)
# These instructions are interpreted from docker-compose.yml, zkp section, and the zkp Dockerfile
cd zkp
npm ci
npm start
Troubleshooting
# REQUIRES NPM V6.10.1+
# Source https://github.com/ethereum/web3.js/issues/2863#issuecomment-514226742
npm update -g npm
Run trusted setup
NODE_ENV=setup npx babel-node code/index.js
Clean
rm -rf node_modules
- README-tools-trusted-setup.md Instructions for manually generating the verification keys and proving keys for ZoKrates from the .pcode files.
- README-manual-trusted-setup.md is a deeper walkthrough of the "generating key pairs" task above.
- README-tools-code-preprop.md explains "pcode", an abbreviated language Nightfall uses that transpiles down to the ZoKrates "code" language.