Write R1CS output to file in GenerateParams.
This commit is contained in:
@@ -9,18 +9,20 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(argc != 3) {
|
if(argc != 4) {
|
||||||
std::cerr << "Usage: " << argv[0] << " provingKeyFileName verificationKeyFileName" << std::endl;
|
std::cerr << "Usage: " << argv[0] << " provingKeyFileName verificationKeyFileName r1csFileName" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string pkFile = argv[1];
|
std::string pkFile = argv[1];
|
||||||
std::string vkFile = argv[2];
|
std::string vkFile = argv[2];
|
||||||
|
std::string r1csFile = argv[3];
|
||||||
|
|
||||||
auto p = ZCJoinSplit::Generate();
|
auto p = ZCJoinSplit::Generate();
|
||||||
|
|
||||||
p->saveProvingKey(pkFile);
|
p->saveProvingKey(pkFile);
|
||||||
p->saveVerifyingKey(vkFile);
|
p->saveVerifyingKey(vkFile);
|
||||||
|
p->saveR1CS(r1csFile);
|
||||||
|
|
||||||
delete p;
|
delete p;
|
||||||
|
|
||||||
|
|||||||
@@ -111,14 +111,23 @@ public:
|
|||||||
throw std::runtime_error("cannot save verifying key; key doesn't exist");
|
throw std::runtime_error("cannot save verifying key; key doesn't exist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void saveR1CS(std::string path) {
|
||||||
|
auto r1cs = generate_r1cs();
|
||||||
|
|
||||||
void generate() {
|
saveToFile(path, r1cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
r1cs_constraint_system<FieldT> generate_r1cs() {
|
||||||
protoboard<FieldT> pb;
|
protoboard<FieldT> pb;
|
||||||
|
|
||||||
joinsplit_gadget<FieldT, NumInputs, NumOutputs> g(pb);
|
joinsplit_gadget<FieldT, NumInputs, NumOutputs> g(pb);
|
||||||
g.generate_r1cs_constraints();
|
g.generate_r1cs_constraints();
|
||||||
|
|
||||||
const r1cs_constraint_system<FieldT> constraint_system = pb.get_constraint_system();
|
return pb.get_constraint_system();
|
||||||
|
}
|
||||||
|
|
||||||
|
void generate() {
|
||||||
|
const r1cs_constraint_system<FieldT> constraint_system = generate_r1cs();
|
||||||
r1cs_ppzksnark_keypair<ppzksnark_ppT> keypair = r1cs_ppzksnark_generator<ppzksnark_ppT>(constraint_system);
|
r1cs_ppzksnark_keypair<ppzksnark_ppT> keypair = r1cs_ppzksnark_generator<ppzksnark_ppT>(constraint_system);
|
||||||
|
|
||||||
pk = keypair.pk;
|
pk = keypair.pk;
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public:
|
|||||||
virtual void saveProvingKey(std::string path) = 0;
|
virtual void saveProvingKey(std::string path) = 0;
|
||||||
virtual void loadVerifyingKey(std::string path) = 0;
|
virtual void loadVerifyingKey(std::string path) = 0;
|
||||||
virtual void saveVerifyingKey(std::string path) = 0;
|
virtual void saveVerifyingKey(std::string path) = 0;
|
||||||
|
virtual void saveR1CS(std::string path) = 0;
|
||||||
|
|
||||||
virtual ZCProof prove(
|
virtual ZCProof prove(
|
||||||
const boost::array<JSInput, NumInputs>& inputs,
|
const boost::array<JSInput, NumInputs>& inputs,
|
||||||
|
|||||||
Reference in New Issue
Block a user