From 079ac4766cca3d2ff5a82eec7f7c65fa38d207a6 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 23 Jan 2024 14:03:37 +0100 Subject: [PATCH] Cleanup verifer.js --- verifier/verifier.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/verifier/verifier.js b/verifier/verifier.js index 83269fb..0e2d77c 100644 --- a/verifier/verifier.js +++ b/verifier/verifier.js @@ -1,8 +1,6 @@ const fs = require("fs") -const ethers = require("ethers") -const { BigNumber } = ethers -const BASE_PATH = __dirname + "/../verifier/networks" +const BASE_PATH = __dirname + "/networks" const PROOF_FILE_NAME = "example-proof/proof.json" const PUBLIC_INPUT_FILE_NAME = "example-proof/public.json" const VERIFICATION_KEY_FILE_NAME = @@ -23,9 +21,8 @@ function G2ToStruct(point) { } function loadProof(name) { - const proof = JSON.parse( - fs.readFileSync(`${BASE_PATH}/${name}/${PROOF_FILE_NAME}`) - ) + const path = `${BASE_PATH}/${name}/${PROOF_FILE_NAME}` + const proof = JSON.parse(fs.readFileSync(path)) return { a: G1ToStruct(proof["pi_a"]), b: G2ToStruct(proof["pi_b"]), @@ -34,16 +31,14 @@ function loadProof(name) { } function loadPublicInput(name) { - const input = JSON.parse( - fs.readFileSync(`${BASE_PATH}/${name}/${PUBLIC_INPUT_FILE_NAME}`) - ) + const path = `${BASE_PATH}/${name}/${PUBLIC_INPUT_FILE_NAME}` + const input = JSON.parse(fs.readFileSync(path)) return input } function loadVerificationKey(name) { - const key = JSON.parse( - fs.readFileSync(`${BASE_PATH}/${name}/${VERIFICATION_KEY_FILE_NAME}`) - ) + const path = `${BASE_PATH}/${name}/${VERIFICATION_KEY_FILE_NAME}` + const key = JSON.parse(fs.readFileSync(path)) return { alpha1: G1ToStruct(key["vk_alpha_1"]), beta2: G2ToStruct(key["vk_beta_2"]),