Browse Source

Write R1CS output to file in GenerateParams.

metaverse
Sean Bowe 8 years ago
parent
commit
0a958ae7f6
  1. 6
      src/zcash/GenerateParams.cpp
  2. 13
      src/zcash/JoinSplit.cpp
  3. 1
      src/zcash/JoinSplit.hpp

6
src/zcash/GenerateParams.cpp

@ -9,18 +9,20 @@ int main(int argc, char **argv)
return 1;
}
if(argc != 3) {
std::cerr << "Usage: " << argv[0] << " provingKeyFileName verificationKeyFileName" << std::endl;
if(argc != 4) {
std::cerr << "Usage: " << argv[0] << " provingKeyFileName verificationKeyFileName r1csFileName" << std::endl;
return 1;
}
std::string pkFile = argv[1];
std::string vkFile = argv[2];
std::string r1csFile = argv[3];
auto p = ZCJoinSplit::Generate();
p->saveProvingKey(pkFile);
p->saveVerifyingKey(vkFile);
p->saveR1CS(r1csFile);
delete p;

13
src/zcash/JoinSplit.cpp

@ -111,14 +111,23 @@ public:
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;
joinsplit_gadget<FieldT, NumInputs, NumOutputs> g(pb);
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);
pk = keypair.pk;

1
src/zcash/JoinSplit.hpp

@ -62,6 +62,7 @@ public:
virtual void saveProvingKey(std::string path) = 0;
virtual void loadVerifyingKey(std::string path) = 0;
virtual void saveVerifyingKey(std::string path) = 0;
virtual void saveR1CS(std::string path) = 0;
virtual ZCProof prove(
const boost::array<JSInput, NumInputs>& inputs,

Loading…
Cancel
Save