2024-01-10 15:12:18 +01:00
|
|
|
const fs = require("fs")
|
2024-01-15 16:25:30 +01:00
|
|
|
const ethers = require("ethers")
|
2024-01-18 09:54:21 +01:00
|
|
|
const { BigNumber } = ethers
|
2024-01-05 12:27:53 +01:00
|
|
|
|
2024-01-18 09:54:21 +01:00
|
|
|
const BASE_PATH = __dirname + "/../verifier/networks"
|
|
|
|
const PROOF_FILE_NAME = "example-proof/proof.json"
|
|
|
|
|
2024-01-18 13:37:33 +01:00
|
|
|
function G1ToUInts(point) {
|
|
|
|
return [
|
|
|
|
point[0],
|
|
|
|
point[1]
|
|
|
|
]
|
2024-01-18 09:54:21 +01:00
|
|
|
}
|
|
|
|
|
2024-01-18 13:37:33 +01:00
|
|
|
function G2ToUInts(point) {
|
|
|
|
return [
|
|
|
|
point[0][1],
|
|
|
|
point[0][0],
|
|
|
|
point[1][1],
|
|
|
|
point[1][0]
|
|
|
|
]
|
2024-01-18 09:54:21 +01:00
|
|
|
}
|
2024-01-05 12:27:53 +01:00
|
|
|
|
2024-01-10 15:12:18 +01:00
|
|
|
function loadProof(name) {
|
|
|
|
const proof = JSON.parse(
|
|
|
|
fs.readFileSync(`${BASE_PATH}/${name}/${PROOF_FILE_NAME}`)
|
|
|
|
)
|
2024-01-18 13:37:33 +01:00
|
|
|
return []
|
|
|
|
.concat(G1ToUInts(proof['pi_a']))
|
|
|
|
.concat(G2ToUInts(proof['pi_b']))
|
|
|
|
.concat(G1ToUInts(proof['pi_c']))
|
2024-01-05 12:27:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { loadProof }
|