feat: create new snarkjs groth16 template

Former-commit-id: 74a5653406
This commit is contained in:
cedoor
2022-04-04 11:57:02 +02:00
parent 51fe424473
commit 9e2b54ef16
3 changed files with 220 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ async function exec(command: string) {
async function main() {
const buildPath = config.paths.build.snark
const templatesPath = config.paths["snarkjs-templates"]
const solidityVersion = config.solidity.version
if (!fs.existsSync(buildPath)) {
@@ -53,7 +54,7 @@ async function main() {
let verifierCode = await zKey.exportSolidityVerifier(
`${buildPath}/semaphore_final.zkey`,
{ groth16: fs.readFileSync("./node_modules/snarkjs/templates/verifier_groth16.sol.ejs", "utf8") },
{ groth16: fs.readFileSync(`${templatesPath}/verifier_groth16.sol.ejs`, "utf8") },
logger
)
verifierCode = verifierCode.replace(/pragma solidity \^\d+\.\d+\.\d+/, `pragma solidity ^${solidityVersion}`)