PORT="8000" ADDRESS="0.0.0.0" ED25519CIRCOM_PATH="../ed25519circom" GNARK_JS_PATH="../.nvm/versions/node/v18.19.0/bin/snarkjs" cargo run
- Recieved request to generate proof.
- Run backgound task to generate proof
- Serelized inputs and write input into cicruit root folder :
{ed25519_circom_path}/data.json - run
npm test.testH2.test.jsread the data.json and store batchinput.json into{ed25519_circom_path}/circuits/batchverify_js/batchinput.json - Change directory to
{ed25519_circom_path}/circuits/batchverify_js - Execute
node generate_witness.js batchverify.wasm batchinput.json witness.wtns-> generated witness.wtns - Change directory
{ed25519_circom_path}/circuits - Execute
snarkjs groth16 prove batchverify_0001.zkey ./batchverify_js/witness.wtns proof_{h}.json public_{h}.json - Recived request to get the generated proof by block height from relayer. Read
proof.jsonfile from{ed25519_circom_path}/circuits/proof_{h}.jsonand return proof as a string json to the caller.
- To run server you need:
- Install
nodeandnpm+gnarkjs - Installing dependencies
- Set env variable : ED25519CIRCOM_PATH - path to ComposableFi/ed25519circom branch zk-service-gnark.
- Set env variable : GNARK_JS_PATH - path to executable gnarkjs library
ED25519CIRCOM_PATH="../ed25519circom" GNARK_JS_PATH="../.nvm/versions/node/v18.19.0/bin/snarkjs" cargo run
- Install
- Server only handle one proof at a time and DO NOT put/store any request from relayer into the queue to generate proof in future.
- Server will ignore any request to generate proof in 2 cases:
- server busy generating some proof
- proof for specifed block height already was generated and stored on disk.
- Relayer(caller side) need wait and call
generate_proofuntill remote zk api return back json with aproof_idthat means that server started to generate. In other wordgenerate_proofapi method will response back with aproof_idto indicate that genration of proof started during this API request.
GET http://localhost:8000/status HTTP/1.1
POST http://localhost:8000/create_proof HTTP/1.1
content-type: application/json
{
"messages": [],
"pub_keys": [],
"signatures": [],
"height: u64,
}
POST http://localhost:8000/get_proof HTTP/1.1
content-type: application/json
{
"proof_id": "50",
"height" : 50,
}