Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
isekai 1.0
Browse files Browse the repository at this point in the history
Integrate Aurora and Ligero schemes from  libiop
  • Loading branch information
guipublic committed Nov 7, 2019
1 parent 3130702 commit 7856d02
Show file tree
Hide file tree
Showing 14 changed files with 12,625 additions and 9,962 deletions.
Binary file modified lib/libsnarc/libsnarc.a
Binary file not shown.
53 changes: 42 additions & 11 deletions lib/libsnarc/src/cwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "skAurora.hpp"
#include "skLigero.hpp"
#include "skFractal.hpp"
#include "util.hpp""
using namespace std;
Expand Down Expand Up @@ -90,30 +91,35 @@ char * Prove(char * setup, char * inputs, char * proofFile, int scheme)
{
std::string ts(setup);
std::string ins(inputs);
std::string pfile = "";
if (proofFile != NULL)
pfile = std::string(proofFile);
Snarks::zkp_scheme zcheme = Snarks::zkp_scheme(scheme);
if (scheme == Snarks::zkp_scheme::aurora)
{
skAurora aurora; //TODO try factory pattern
aurora.Proof(ins, ts);
nlohmann::json jkey = aurora.Proof(ins, ts);
skUtils::WriteJson2File(pfile, jkey);
return ""; //TODO
}
else if (scheme == Snarks::zkp_scheme::ligero)
{
skLigero ligero;
ligero.Proof(ins, ts);
return ""; //TODO
nlohmann::json jkey = ligero.Proof(ins, ts);
skUtils::WriteJson2File(pfile, jkey);
return "";
}
else if (scheme == Snarks::zkp_scheme::fractal)
{
skFractal fractal;
fractal.Proof(ins, ts);
nlohmann::json jkey = fractal.Proof(ins, ts);
skUtils::WriteJson2File(pfile, jkey);
return ""; //TODO
}
Snarks r1cs;
std::string pfile = "";
if (proofFile != NULL)
pfile = std::string(proofFile);
nlohmann::json jkey = r1cs.Proof(ins, ts, zcheme);
if (pfile.length() > 0)
Expand All @@ -133,9 +139,34 @@ char * Prove(char * setup, char * inputs, char * proofFile, int scheme)
//proof: file name of the proof in json format.
bool Verify(char * setup, char * inputs, char * proof)
{
Snarks r1cs;
std::string ts(setup);
std::string ins(inputs);
//load proof from file
std::string p(proof);
return r1cs.Verify(ts, ins, p);
std::string ins(inputs);
json jProof = skUtils::LoadJsonFromFile(p);
if (jProof["type"] == "ligero")
{
skLigero ligero;
return ligero.Verify(ins, jProof);
}
else if (jProof["type"] == "aurora")
{
skAurora aurora;
return aurora.Verify(ins, jProof);
}
else if (jProof["type"] == "fractal")
{
// skFractal fractal;
// return fractal.Verify(ins, jProof);
}
else
{
Snarks r1cs;
std::string ts(setup);
return r1cs.Verify(ts, ins, jProof);
}
return false;
}
Loading

0 comments on commit 7856d02

Please sign in to comment.