@@ -16,6 +16,9 @@ int main()
16
16
{
17
17
18
18
typedef Fr<default_r1cs_ppzksnark_pp> FieldT;
19
+
20
+ // Initialize the curve parameters.
21
+ default_r1cs_ppzksnark_pp::init_public_params ();
19
22
20
23
// Create protoboard
21
24
@@ -24,20 +27,27 @@ int main()
24
27
// Define variables
25
28
26
29
pb_variable<FieldT> x;
27
- pb_variable<FieldT> out;
28
30
pb_variable<FieldT> sym_1;
29
31
pb_variable<FieldT> y;
30
32
pb_variable<FieldT> sym_2;
33
+ pb_variable<FieldT> out;
31
34
32
35
// Allocate variables to protoboard
33
36
// The strings (like "x") are only for debugging purposes
34
37
35
- x.allocate (pb, " x" );
36
38
out.allocate (pb, " out" );
39
+ x.allocate (pb, " x" );
37
40
sym_1.allocate (pb, " sym_1" );
38
41
y.allocate (pb, " y" );
39
42
sym_2.allocate (pb, " sym_2" );
40
43
44
+ // This sets up the protoboard variables
45
+ // so that the first one (out) represents the public
46
+ // input and the rest is private input
47
+ pb.set_input_sizes (1 );
48
+
49
+ cout << " Number of variables: " << pb.num_variables () << endl;
50
+
41
51
// Add R1CS constraints to protoboard
42
52
43
53
// x*x = sym_1
@@ -60,36 +70,27 @@ int main()
60
70
pb.val (y) = 27 ;
61
71
pb.val (sym_2) = 30 ;
62
72
63
-
64
73
if (pb.is_satisfied ()) {
65
74
cout << " Constraint system is satisfied." << endl;
66
75
}
67
76
else {
68
77
cout << " Constraint system is not satisfied." << endl;
69
78
}
70
79
71
- // This is not working for some reason
72
- cout << " Value of x: " << pb.val (x) << endl;
73
-
74
80
const r1cs_constraint_system<FieldT> constraint_system = pb.get_constraint_system ();
75
81
76
82
cout << " Number of R1CS constraints: " << constraint_system.num_constraints () << endl;
77
- cout << " Number of variables: " << pb.num_variables () << endl;
78
-
79
- // Initialize the curve parameters.
80
- default_r1cs_ppzksnark_pp::init_public_params ();
81
83
82
84
r1cs_ppzksnark_keypair<default_r1cs_ppzksnark_pp> keypair = r1cs_ppzksnark_generator<default_r1cs_ppzksnark_pp>(constraint_system);
83
85
84
86
r1cs_ppzksnark_proof<default_r1cs_ppzksnark_pp> proof = r1cs_ppzksnark_prover<default_r1cs_ppzksnark_pp>(keypair.pk , pb.primary_input (), pb.auxiliary_input ());
85
-
86
- vector<FieldT> empty;
87
87
88
- bool verified = r1cs_ppzksnark_verifier_strong_IC<default_r1cs_ppzksnark_pp>(keypair.vk , empty , proof);
88
+ bool verified = r1cs_ppzksnark_verifier_strong_IC<default_r1cs_ppzksnark_pp>(keypair.vk , pb. primary_input () , proof);
89
89
90
- cout << " Verification status: " << verified << endl;
90
+ cout << " Primary (public) input: " << pb.primary_input () << endl;
91
+ cout << " Auxiliary (private) input: " << pb.auxiliary_input () << endl;
91
92
92
- cout << " made it here " << endl;
93
+ cout << " Verification status: " << verified << endl;
93
94
94
95
return 0 ;
95
96
}
0 commit comments