/* This is a wrapper around libsnark which provides basic R1CS zk-SNARK support using the ALT_BN128 curve. */ #include "gadgetlib1/gadgets/basic_gadgets.hpp" #include "zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.hpp" #include "common/default_types/r1cs_ppzksnark_pp.hpp" #include "common/utils.hpp" using namespace libsnark; using namespace std; extern "C" void tinysnark_init_public_params() { default_r1cs_ppzksnark_pp::init_public_params(); } extern "C" void tinysnark_test() { typedef Fr FieldT; protoboard pb; linear_combination sum; sum = sum + 1; pb.add_r1cs_constraint(r1cs_constraint(1, sum, 1), "testing"); assert(pb.is_satisfied()); const r1cs_constraint_system constraint_system = pb.get_constraint_system(); cout << "Number of R1CS constraints: " << constraint_system.num_constraints() << endl; auto keypair = r1cs_ppzksnark_generator(constraint_system); auto proof = r1cs_ppzksnark_prover(keypair.pk, pb.primary_input(), pb.auxiliary_input()); r1cs_primary_input input; assert(r1cs_ppzksnark_verifier_strong_IC(keypair.vk, input, proof)); }