Skip to content

Latest commit

 

History

History
94 lines (62 loc) · 3.32 KB

README.md

File metadata and controls

94 lines (62 loc) · 3.32 KB

Nightfall Zero-Knowledge Proof Service

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.

Tasks you can perform

Run zkp service unit tests

You will need to have completed the trusted setup. This is done simply by running (from the Nightfall root):

npm run setupAll

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.

Then start the merkle-tree microservice, which will start filtering the Shield contracts and populating the merkle-tree database:

docker-compose -f docker-compose.merkle-tree.yml up --build

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 commitments
  • nf-token-controller.test.js - These are units tests to verify mint, transfer and burn of ERC-721 tokens and ERC-721 commitments
  • utils.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)

Development

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

Further reading