Skip to content

poloniex/tools-go-merkle-verify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Poloniex Merkle Verify Tool

Background

Poloniex launches Proof of Reserves (PoR) to improve the security and transparency of user's assets. These tools will allow you to verify the validity of your assets in the merkle sum tree by verify merkle proof file, in order to confirm your assets in Poloniex.

Introduction

Building the source

Download the latest build for your operating system and architecture. Also, you can build the source by yourself.

Building this open source tool requires Go (version >= 1.16).

Install dependencies

 go mod vendor

build

 make merkle_verify

run

./build/MerkleVerify --file ./merkle_sum_proof.json

Poloniex Merkle Verify Tool V2

1. Prover service

By using the r1cs circuit and pk and vk files generated by the keygen program, the required proof files are generated and stored in the database, allowing users to verify. The service is performed on the server side, and its built-in already includes verify, so after the prover runs, the verify will succeed as long as it runs according to the correct steps.

Operation method: Make sure that the current working directory is under zkmerkleverify, that is, under the upper directory of src. The config file is merkle_groth16/src/prover/config/config.json

MysqlDataSource is the dsn of you save your proofs Redis is the source you save your treeroot DbSuffix is the proof table suffix ZkKeyName is corresponding to the batchsize

(1) When only one host is used to enable the prover service, use the following command to use the prover service:

 go run merkle_groth16/src/prover/main.go

When prover is run correctly, it will output: "there is no published status witness in db, so quit" "prover run finish..."

(2) When multiple hosts are used to enable the prover service, all hosts are guaranteed to be in the above-mentioned working directory, and then use the same command:

 go run merkle_groth16/src/prover/main.go

When the command of all hosts ends, the following output will be

  "there is no published status witness in db, so quit"
  "prover run finish..."

Use the following command:

 go run merkle_groth16/src/prover/main.go -rerun

To check whether there is a prover program that has not been run, if there is, run it to completion, when the program runs normally, the final output shows:

   "there is no received status witness in db, so quit"
   "prover rerun finish..."

2. Verifier service

Uses the verifier service to provide users with self-verification por verification services and userproof verification services. The customer uses the proof form and vk generated by the prover service to perform por verification and userproof verification. Among them, por verification is our zero-knowledge asset proof verification, and userproof is our zero-knowledge Merkle tree verification. Operation methods:Make sure that the current working directory is under zkmerkleverify, which is the upper directory of src.

Before using this service, you need to use the following command to download the proof0.csv required by the user: The config file of it is merkle_groth16/load_proof_from_database/config/config.json

MysqlDataSource is the dsn that you save your proofs

 go run merkle_groth16/test/main/main.go 

Use the following command to download the config.json required by the user: The config file is merkle_groth16/src/dbtool/config/config.json

MysqlDataSource is the dsn of you save your proofs TreeDB is the source you save your treeroot DbSuffix is the proof table suffix

 go run merkle_groth16/src/dbtool/main.go 

Use the following command to verify por: The config file is merkle_groth16/src/verifier/config/config.json

 go run merkle_groth16/src/verifier/main.go 

If the verification is passed, it will output

  "All proofs verify passed!!!"

otherwise output

  "proof verify failed:"

Use the following command to perform userproof verification The config file is merkle_groth16/src/verifier/config/user_config.json

 go run merkle_groth16/src/verifier/main.go -user

If the verification is passed, the output will be:

  "verify pass!!!"

Otherwise output:

  "verify failed..."