@@ -48,7 +48,10 @@ bool qapblockvalid(const masterkey& mk, const datablock& db) {
4848 // alpha check
4949 opt_atePairing (e1 , mk.g_al , db.comm );
5050 opt_atePairing (e2 , db.commal , g1);
51- if (e1 !=e2 ) { cerr << " *** c-alpha pairing check failed" << endl; }
51+ if (e1 !=e2 ) {
52+ cerr << " *** c-alpha pairing check failed" << endl;
53+ return false ;
54+ }
5255
5356 return true ;
5457}
@@ -64,12 +67,18 @@ bool qapblockver(const masterkey& mk, const datablock& db, const blockvk& bvk, c
6467 // alpha' check
6568 opt_atePairing (e1 , bvk.g2al , block.comm );
6669 opt_atePairing (e2 , block.commal , g1);
67- if (e1 !=e2 ) { cerr << " *** c'-alpha pairing check failed" << endl; }
70+ if (e1 !=e2 ) {
71+ cerr << " *** c'-alpha pairing check failed" << endl;
72+ return false ;
73+ }
6874
6975 // z check
7076 opt_atePairing (e1 , bvk.g2beta , db.comm + block.comm );
7177 opt_atePairing (e2 , g2, block.commz );
72- if (e1 !=e2 ) { cerr << " *** block z pairing check failed" << endl; }
78+ if (e1 !=e2 ) {
79+ return false ;
80+ cerr << " *** block z pairing check failed" << endl;
81+ }
7382
7483 return true ;
7584}
@@ -89,23 +98,35 @@ bool qapver(const qapvk& qvk, const qapproof& proof, const wirevalt& pubwires, s
8998 // alpha checks
9099 opt_atePairing (e1 , proof.p_ravx , g1);
91100 opt_atePairing (e2 , qvk.g2alv , proof.p_rvx );
92- if (e1 !=e2 ) { cerr << " *** p_ravx pairing check failed" << endl; }
101+ if (e1 !=e2 ) {
102+ cerr << " *** p_ravx pairing check failed" << endl;
103+ return false ;
104+ }
93105
94106 opt_atePairing (e1 , g2, proof.p_rawx );
95107 opt_atePairing (e2 , proof.p_rwx , qvk.g1alw );
96- if (e1 !=e2 ) { cerr << " *** p_rawx pairing check failed" << endl; }
108+ if (e1 !=e2 ) {
109+ cerr << " *** p_rawx pairing check failed" << endl;
110+ return false ;
111+ }
97112
98113 opt_atePairing (e1 , proof.p_rayx , g1);
99114 opt_atePairing (e2 , qvk.g2aly , proof.p_ryx );
100- if (e1 !=e2 ) { cerr << " *** p_rayx pairing check failed" << endl; }
115+ if (e1 !=e2 ) {
116+ cerr << " *** p_rayx pairing check failed" << endl;
117+ return false ;
118+ }
101119
102120 // s check
103121 Ec1 versum = proof.p_rvx +proof.p_ryx ;
104122 for (auto const & it: proof.blocks ) versum += it.second .comm ;
105123 opt_atePairing (e1 , g2, proof.p_z );
106124 opt_atePairing (e2 , qvk.g2bet , versum);
107125 opt_atePairing (e3 , proof.p_rwx , qvk.g1bet );
108- if (e1 !=(e2 *e3 )) { cerr << " *** beta check failed" << endl; }
126+ if (e1 !=(e2 *e3 )) {
127+ cerr << " *** beta check failed" << endl;
128+ return false ;
129+ }
109130
110131 Ec1 pub_rvx = g10;
111132 Ec2 pub_rwx = g20;
@@ -122,7 +143,10 @@ bool qapver(const qapvk& qvk, const qapproof& proof, const wirevalt& pubwires, s
122143 opt_atePairing (e1 , pub_rwx + proof.p_rwx , pub_rvx + proof.p_rvx );
123144 opt_atePairing (e2 , qvk.g2ryt , proof.p_h );
124145 opt_atePairing (e3 , g2, pub_ryx + proof.p_ryx );
125- if (e1 !=(e2 *e3 )) { cerr << " *** divisibility check failed" << endl; }
146+ if (e1 !=(e2 *e3 )) {
147+ cerr << " *** divisibility check failed" << endl;
148+ return false ;
149+ }
126150
127151 return true ;
128152}
0 commit comments