Zero-Knowledge Proof lib for Gunero
$ cd depends
$ git submodule init
$ git submodule update
$ cd libsnark/depends
$ git submodule init
$ git submodule update
$ cd ../../../
$ mkdir build
# cd build
$ cmake ..
$ make- Generate proving and verifying keys for all circuits
$ cd demo
$ ../silencer generate --circuit=authorization \
--proving-key-output=./authorization-pk.json \
--verifying-key-output=./authorization-vk.json
$ ../silencer generate --circuit=receive \
--proving-key-output=./receive-pk.json \
--verifying-key-output=./receive-vk.json
$ ../silencer generate --circuit=spend \
--proving-key-output=./spend-pk.json \
--verifying-key-output=./spend-vk.json- Create a firearm token and previous transaction
$ echo [PICK RANDOM NUMBER] > ./firearm.rand
$ echo [PICK RANDOM SERIAL] > ./firearm.serial
$ python gen-token.py \
$(cat ./firearm.rand) \
$(cat ./firearm.serial) \
> ./token.hash
$ echo [PICK RANDOM ACCOUNT] > ./previous.acct
$ python gen-txn-hash.py \
$(cat ./previous.acct) \
$(cat ./sender.key) \
$(cat ./token.hash) \
$(cat ./auth-root.hash) \
> ./previous-transaction.hash- Generate authorization proof for both accounts
$ echo [PICK RANDOM NUMBER] > ./sender-view.rand
$ python gen-view-hash.py \
$(cat ./sender.acct) \
$(cat ./auth-root.hash) \
$(cat ./sender-view.rand) \
> ./sender-view.hash
$ ../silencer prove --circuit=authorization \
--proving-key=./authorization-pk.json \
--auth-root-hash=./auth-root.hash \
--account-status=1 \
--account-view-hash=./sender-view.hash \
--account-private-key=./sender.key \
--account-view-randomizer=./sender-view.rand \
--auth-sender-branch=./sender-branch.ls \
--output=./sender-auth.proofNote: Repeat above steps for receiver
- Receiver generates transaction hash
$ python gen-txn-hash.py \
$(cat ./sender.acct) \
$(cat ./receiver.key) \
$(cat ./token.hash) \
$(cat ./auth-root.hash) \
> ./transaction.hash- Generate the receiver proof with receiver's account
$ ../silencer prove --circuit=receive \
--proving-key=./receive-pk.json \
--auth-root-hash=./auth-root.hash \
--token=./token.hash \
--receiver-view-hash=./receiver-view.hash \
--sender-view-hash=./sender-view.hash \
--transaction-hash=./transaction.hash \
--receiver-private-key=./receiver.key \
--receiver-view-randomizer=./receiver-view.rand \
--sender-account=./sender.acct \
--sender-view-randomizer=./sender-view.rand \
--firearm-serial=./firearm.serial \
--firearm-view-randomizer=./firearm.rand \
--output=./receive.proof- Generate the spend proof with the sender's acocunt
$ ../silencer prove --circuit=spend \
--proving-key=./spend-pk.json \
--auth-root-hash=./auth-root.hash \
--token=./token.hash \
--receiver-view-hash=./receiver-view.hash \
--sender-view-hash=./sender-view.hash \
--previous-transaction-hash=./previous-transaction.hash \
--sender-private-key=./receiver.key \
--sender-view-randomizer=./sender-view.rand \
--receiver-view-randomizer=./receiver-view.rand \
--previous-account=./previous.acct \
--previous-auth-root-hash=./auth-root.hash
--output=./spend.proof- Validate all the proofs
$ ../silencer verify --circuit=authorization \
--verifying-key=./authorization-vk.json \
--auth-root-hash=./auth-root.hash \
--account-status=1 \
--account-view-hash=./sender-view.hash \
--proof=./sender-auth.proof
SUCCESS!
$ ../silencer verify --circuit=authorization \
--verifying-key=./authorization-vk.json \
--auth-root-hash=./auth-root.hash \
--account-status=1 \
--account-view-hash=./receiver-view.hash \
--proof=./receiver-auth.proof
SUCCESS!
$ ../silencer verify --circuit=receive \
--proving-key=./receive-vk.json \
--auth-root-hash=./auth-root.hash \
--token=./token.hash \
--receiver-view-hash=./receiver-view.hash \
--sender-view-hash=./sender-view.hash \
--transaction-hash=./transaction.hash \
--proof=./receive.proof
SUCCESS!
$ ../silencer verify --circuit=spend \
--proving-key=./spend-vk.json \
--auth-root-hash=./auth-root.hash \
--token=./token.hash \
--receiver-view-hash=./receiver-view.hash \
--sender-view-hash=./sender-view.hash \
--previous-transaction-hash=./previous-transaction.hash \
--proof=./spend.proof
SUCCESS!NOTE: Yes, the proofs do indeed fail if not consistent:
$ ../silencer verify --circuit=authorization \
--verifying-key=./authorization-vk.json \
--auth-root-hash=./auth-root.hash \
--account-status=1 \
--account-view-hash=./receiver-view.hash \
--proof=./sender-auth.proof
FAIL!
$ ../silencer verify --circuit=authorization \
--verifying-key=./authorization-vk.json \
--auth-root-hash=./auth-root.hash \
--account-status=1 \
--account-view-hash=./sender-view.hash \
--proof=./receiver-auth.proof
FAIL!