Skip to content

Commit

Permalink
Be compitable with Groth16
Browse files Browse the repository at this point in the history
  • Loading branch information
eigmax committed Jun 9, 2023
1 parent 03477c1 commit d803c54
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/config/config.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <string>
#include <fstream>
#include <nlohmann/json.hpp>
#include "definitions.hpp"
#include "config.hpp"
Expand Down Expand Up @@ -263,7 +264,13 @@ void Config::load(json &config)
finalVerifier = configPath + "/final/final.verifier.dat";
finalVerkey = configPath + "/final/final.fflonk.verkey.json";
finalStarkZkey = configPath + "/final/final.fflonk.zkey";

// check if file exists
ifstream f;
f.open(finalVerkey);
if (f.fail()) {
finalVerkey = configPath + "/final/final.verkey.json";
finalStarkZkey = configPath + "/final/final.g16.0001.zkey";
}

if (config.contains("rom") && config["rom"].is_string())
rom = config["rom"];
Expand Down
11 changes: 6 additions & 5 deletions src/prover/prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ Prover::Prover(Goldilocks &fr,
cout << "Prover::genBatchProof() successfully allocated " << polsSize << " bytes" << endl;
}

prover = new Fflonk::FflonkProver<AltBn128::Engine>(AltBn128::Engine::engine, pAddress, polsSize);
prover->setZkey(zkey.get());
if (Zkey::FFLONK_PROTOCOL_ID == protocolId) {
prover = new Fflonk::FflonkProver<AltBn128::Engine>(AltBn128::Engine::engine, pAddress, polsSize);
prover->setZkey(zkey.get());
}

StarkInfo _starkInfoRecursiveF(config, config.recursivefStarkInfo);
pAddressStarksRecursiveF = (void *)malloc(_starkInfoRecursiveF.mapTotalN * sizeof(Goldilocks::Element));
Expand Down Expand Up @@ -142,8 +144,6 @@ Prover::~Prover()
BinFileUtils::BinFile *pZkey = zkey.release();
ZKeyUtils::Header *pZkeyHeader = zkeyHeader.release();

assert(groth16Prover.get() == nullptr);
assert(groth16Prover == nullptr);
assert(zkey.get() == nullptr);
assert(zkey == nullptr);
assert(zkeyHeader.get() == nullptr);
Expand All @@ -168,7 +168,8 @@ Prover::~Prover()
}
free(pAddressStarksRecursiveF);

delete prover;
if (prover != NULL)
delete prover;

delete starkZkevm;
delete starksC12a;
Expand Down

0 comments on commit d803c54

Please sign in to comment.