Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 8879430

Browse files
committed
Proof aggregation scheme compatibility updates #3
1 parent e019f2d commit 8879430

11 files changed

+146
-163
lines changed

include/nil/crypto3/zk/snark/components/curves/detail/mnt4.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ namespace nil {
5858

5959
typedef typename curve_type::pairing::pair_curve_type pair_curve_type; // mnt6
6060

61-
typedef typename pair_curve_type::pairing::Fqe_type fqe_type;
62-
typedef typename pair_curve_type::pairing::Fqk_type fqk_type;
61+
typedef typename pair_curve_type::pairing::fqe_type fqe_type;
62+
typedef typename pair_curve_type::pairing::fqk_type fqk_type;
6363

64-
typedef typename curve_type::pairing::Fp_type field_type;
64+
typedef typename curve_type::pairing::fp_type field_type;
6565

6666
public:
6767
typedef Fp3_variable<fqe_type> Fqe_variable_type;

include/nil/crypto3/zk/snark/components/curves/detail/mnt6.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ namespace nil {
5858

5959
typedef typename curve_type::pairing::pair_curve_type pair_curve_type; // mnt4
6060

61-
typedef typename pair_curve_type::pairing::Fqe_type fqe_type;
62-
typedef typename pair_curve_type::pairing::Fqk_type fqk_type;
61+
typedef typename pair_curve_type::pairing::fqe_type fqe_type;
62+
typedef typename pair_curve_type::pairing::fqk_type fqk_type;
6363

64-
typedef typename curve_type::pairing::Fp_type field_type;
64+
typedef typename curve_type::pairing::fp_type field_type;
6565

6666
public:
6767
typedef Fp2_variable<fqe_type> Fqe_variable_type;

include/nil/crypto3/zk/snark/components/curves/weierstrass_g1_component.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace nil {
7676
const typename CurveType::pairing::pair_curve_type::g1_type::value_type &P) :
7777
component<FieldType>(bp) {
7878
typename CurveType::pairing::pair_curve_type::g1_type::value_type Pcopy =
79-
P.to_affine_coordinates();
79+
P.to_affine();
8080

8181
X.assign(bp, Pcopy.X);
8282
Y.assign(bp, Pcopy.Y);
@@ -89,7 +89,7 @@ namespace nil {
8989
void generate_r1cs_witness(
9090
const typename CurveType::pairing::pair_curve_type::g1_type::value_type &el) {
9191
typename CurveType::pairing::pair_curve_type::g1_type::value_type el_normalized =
92-
el.to_affine_coordinates();
92+
el.to_affine();
9393

9494
this->bp.lc_val(X) = el_normalized.X;
9595
this->bp.lc_val(Y) = el_normalized.Y;

include/nil/crypto3/zk/snark/components/curves/weierstrass_g2_component.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ namespace nil {
5555
*/
5656
template<typename CurveType>
5757
class g2_variable : public component<typename CurveType::scalar_field_type> {
58-
using field_type = typename CurveType::pairing::Fp_type;
58+
using field_type = typename CurveType::pairing::fp_type;
5959

60-
using fqe_type = typename CurveType::pairing::pair_curve_type::pairing::Fqe_type;
61-
using fqk_type = typename CurveType::pairing::pair_curve_type::pairing::Fqk_type;
60+
using fqe_type = typename CurveType::pairing::pair_curve_type::pairing::fqe_type;
61+
using fqk_type = typename CurveType::pairing::pair_curve_type::pairing::fqk_type;
6262

6363
using component_policy = basic_curve_component_policy<CurveType>;
6464

@@ -79,7 +79,7 @@ namespace nil {
7979
const typename CurveType::pairing::pair_curve_type::g2_type::value_type &Q) :
8080
component<field_type>(bp) {
8181
typename CurveType::pairing::pair_curve_type::g2_type::value_type Q_copy =
82-
Q.to_affine_coordinates();
82+
Q.to_affine();
8383

8484
X.reset(new typename component_policy::Fqe_variable_type(bp, Q_copy.X));
8585
Y.reset(new typename component_policy::Fqe_variable_type(bp, Q_copy.Y));
@@ -91,7 +91,7 @@ namespace nil {
9191
void generate_r1cs_witness(
9292
const typename CurveType::pairing::pair_curve_type::g2_type::value_type &Q) {
9393
typename CurveType::pairing::pair_curve_type::g2_type::value_type Qcopy =
94-
Q.to_affine_coordinates();
94+
Q.to_affine();
9595

9696
X->generate_r1cs_witness(Qcopy.X);
9797
Y->generate_r1cs_witness(Qcopy.Y);
@@ -112,9 +112,9 @@ namespace nil {
112112
*/
113113
template<typename CurveType>
114114
class G2_checker_component : public component<typename CurveType::scalar_field_type> {
115-
typedef typename CurveType::pairing::Fp_type field_type;
116-
using fqe_type = typename CurveType::pairing::pair_curve_type::pairing::Fqe_type;
117-
using fqk_type = typename CurveType::pairing::pair_curve_type::pairing::Fqk_type;
115+
typedef typename CurveType::pairing::fp_type field_type;
116+
using fqe_type = typename CurveType::pairing::pair_curve_type::pairing::fqe_type;
117+
using fqk_type = typename CurveType::pairing::pair_curve_type::pairing::fqk_type;
118118

119119
using component_policy = basic_curve_component_policy<CurveType>;
120120

include/nil/crypto3/zk/snark/components/pairing/as_waksman.hpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace nil {
5959
*/
6060
template<typename CurveType>
6161
class g1_precomputation {
62-
typedef typename CurveType::pairing::Fp_type FieldType;
62+
typedef typename CurveType::pairing::fp_type FieldType;
6363
using component_policy = basic_pairing_component_policy<CurveType>;
6464

6565
public:
@@ -74,7 +74,7 @@ namespace nil {
7474
blueprint<FieldType> &bp,
7575
const typename CurveType::pairing::pair_curve_type::g1_type::value_type &P_val) {
7676
typename CurveType::pairing::pair_curve_type::g1_type::value_type P_val_copy =
77-
P_val.to_affine_coordinates();
77+
P_val.to_affine();
7878
P.reset(new g1_variable<CurveType>(bp, P_val_copy));
7979
PY_twist_squared.reset(new typename component_policy::Fqe_variable_type(
8080
bp,
@@ -92,7 +92,7 @@ namespace nil {
9292
using component_policy = basic_pairing_component_policy<CurveType>;
9393

9494
public:
95-
using fqk_type = typename CurveType::pairing::pair_curve_type::pairing::Fqk_type;
95+
using fqk_type = typename CurveType::pairing::pair_curve_type::pairing::fqk_type;
9696

9797
g1_precomputation<CurveType> &precomp; // must be a reference.
9898

@@ -160,7 +160,7 @@ namespace nil {
160160
using component_policy = basic_pairing_component_policy<CurveType>;
161161

162162
public:
163-
typedef typename CurveType::pairing::Fp_type FieldType;
163+
typedef typename CurveType::pairing::fp_type FieldType;
164164

165165
std::shared_ptr<typename component_policy::Fqe_variable_type> RX;
166166
std::shared_ptr<typename component_policy::Fqe_variable_type> RY;
@@ -194,7 +194,7 @@ namespace nil {
194194
using component_policy = basic_pairing_component_policy<CurveType>;
195195

196196
public:
197-
typedef typename CurveType::pairing::Fp_type FieldType;
197+
typedef typename CurveType::pairing::fp_type FieldType;
198198

199199
std::shared_ptr<g2_variable<CurveType>> Q;
200200

@@ -208,7 +208,7 @@ namespace nil {
208208
Q.reset(new g2_variable<CurveType>(bp, Q_val));
209209
const typename CurveType::pairing::pair_curve_type::pairing::affine_ate_g2_precomp
210210
native_precomp =
211-
affine_ate_precompute_G2<typename CurveType::pairing::pair_curve_type>(Q_val);
211+
affine_ate_precompute_g2<typename CurveType::pairing::pair_curve_type>(Q_val);
212212

213213
coeffs.resize(native_precomp.coeffs.size() +
214214
1); // the last precomp remains for convenient programming
@@ -251,8 +251,8 @@ namespace nil {
251251
using component_policy = basic_pairing_component_policy<CurveType>;
252252

253253
public:
254-
typedef typename CurveType::pairing::Fp_type FieldType;
255-
using fqe_type = typename CurveType::pairing::pair_curve_type::Fqe_type;
254+
typedef typename CurveType::pairing::fp_type FieldType;
255+
using fqe_type = typename CurveType::pairing::pair_curve_type::fqe_type;
256256

257257
precompute_G2_component_coeffs<CurveType> cur;
258258
precompute_G2_component_coeffs<CurveType> next;
@@ -368,8 +368,8 @@ namespace nil {
368368
using component_policy = basic_pairing_component_policy<CurveType>;
369369

370370
public:
371-
typedef typename CurveType::pairing::Fp_type FieldType;
372-
using fqe_type = typename CurveType::pairing::pair_curve_type::pairing::Fqe_type;
371+
typedef typename CurveType::pairing::fp_type FieldType;
372+
using fqe_type = typename CurveType::pairing::pair_curve_type::pairing::fqe_type;
373373

374374
bool invert_Q;
375375
precompute_G2_component_coeffs<CurveType> cur;
@@ -466,7 +466,7 @@ namespace nil {
466466
using component_policy = basic_pairing_component_policy<CurveType>;
467467

468468
public:
469-
typedef typename CurveType::pairing::Fp_type FieldType;
469+
typedef typename CurveType::pairing::fp_type FieldType;
470470

471471
std::vector<std::shared_ptr<precompute_G2_component_addition_step<CurveType>>> addition_steps;
472472
std::vector<std::shared_ptr<precompute_G2_component_doubling_step<CurveType>>> doubling_steps;

include/nil/crypto3/zk/snark/components/pairing/weierstrass_final_exponentiation.hpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ namespace nil {
8484
std::shared_ptr<Fqk_mul_component<curve_type>> compute_el_inv_q_3_minus_1;
8585
std::shared_ptr<Fqk_mul_component<curve_type>> compute_inv_beta;
8686

87-
std::shared_ptr<exponentiation_component<curve_type>::pairing::Fqk_type,
87+
std::shared_ptr<exponentiation_component<curve_type>::pairing::fqk_type,
8888
Fp6_2over3_variable,
8989
Fp6_2over3_mul_component,
9090
Fp6_2over3_cyclotomic_sqr_component,
9191
algebra::mnt6_q_limbs> > compute_w1;
92-
std::shared_ptr<exponentiation_component<curve_type>::pairing::Fqk_type,
92+
std::shared_ptr<exponentiation_component<curve_type>::pairing::fqk_type,
9393
Fp6_2over3_variable,
9494
Fp6_2over3_mul_component,
9595
Fp6_2over3_cyclotomic_sqr_component,
@@ -129,15 +129,15 @@ namespace nil {
129129
compute_inv_beta.reset(
130130
new Fqk_mul_component<curve_type>(bp, *inv_alpha, *el_inv_q_3_minus_1, *inv_beta));
131131

132-
compute_w1.reset(new exponentiation_component<curve_type>::pairing::Fqk_type,
132+
compute_w1.reset(new exponentiation_component<curve_type>::pairing::fqk_type,
133133
Fp6_2over3_variable,
134134
Fp6_2over3_mul_component,
135135
Fp6_2over3_cyclotomic_sqr_component,
136136
algebra::mnt6_q_limbs >
137137
(bp, *beta_q, algebra::mnt6_final_exponent_last_chunk_w1, *w1));
138138

139139
compute_w0.reset(
140-
new exponentiation_component<curve_type>::pairing::Fqk_type,
140+
new exponentiation_component<curve_type>::pairing::fqk_type,
141141
Fp6_2over3_variable,
142142
Fp6_2over3_mul_component,
143143
Fp6_2over3_cyclotomic_sqr_component,
@@ -152,7 +152,7 @@ namespace nil {
152152

153153
void generate_r1cs_constraints() {
154154
one->generate_r1cs_equals_const_constraints(
155-
pairing::pair_curve_type<curve_type>::pairing::Fqk_type::value_type::one());
155+
curve_type::pairing::pair_curve_type::pairing::fqk_type::value_type::one());
156156

157157
compute_el_inv->generate_r1cs_constraints();
158158
compute_el_q_3_minus_1->generate_r1cs_constraints();
@@ -177,7 +177,7 @@ namespace nil {
177177

178178
void generate_r1cs_witness() {
179179
one->generate_r1cs_witness(
180-
pairing::pair_curve_type<curve_type>::pairing::Fqk_type::value_type::one());
180+
curve_type::pairing::pair_curve_type::pairing::fqk_type::value_type::one());
181181
el_inv->generate_r1cs_witness(el.get_element().inversed());
182182

183183
compute_el_inv->generate_r1cs_witness();
@@ -230,12 +230,12 @@ namespace nil {
230230
std::shared_ptr<Fqk_mul_component<curve_type>> compute_el_q_2_minus_1;
231231
std::shared_ptr<Fqk_mul_component<curve_type>> compute_el_inv_q_2_minus_1;
232232

233-
std::shared_ptr<exponentiation_component<curve_type>::pairing::Fqk_type,
233+
std::shared_ptr<exponentiation_component<curve_type>::pairing::fqk_type,
234234
Fp4_variable,
235235
Fp4_mul_component,
236236
Fp4_cyclotomic_sqr_component,
237237
algebra::mnt4_q_limbs> > compute_w1;
238-
std::shared_ptr<exponentiation_component<curve_type>::pairing::Fqk_type,
238+
std::shared_ptr<exponentiation_component<curve_type>::pairing::fqk_type,
239239
Fp4_variable,
240240
Fp4_mul_component,
241241
Fp4_cyclotomic_sqr_component,
@@ -267,14 +267,14 @@ namespace nil {
267267
new Fqk_mul_component<curve_type>(bp, *el_inv_q_2, el, *el_inv_q_2_minus_1));
268268

269269
compute_w1.reset(
270-
new exponentiation_component<curve_type>::pairing::Fqk_type,
270+
new exponentiation_component<curve_type>::pairing::fqk_type,
271271
Fp4_variable,
272272
Fp4_mul_component,
273273
Fp4_cyclotomic_sqr_component,
274274
algebra::mnt4_q_limbs >
275275
(bp, *el_q_3_minus_q, algebra::mnt4_final_exponent_last_chunk_w1, *w1));
276276
compute_w0.reset(
277-
new exponentiation_component<curve_type>::pairing::Fqk_type,
277+
new exponentiation_component<curve_type>::pairing::fqk_type,
278278
Fp4_variable,
279279
Fp4_mul_component,
280280
Fp4_cyclotomic_sqr_component,
@@ -289,7 +289,7 @@ namespace nil {
289289

290290
void generate_r1cs_constraints() {
291291
one->generate_r1cs_equals_const_constraints(
292-
pairing::pair_curve_type<curve_type>::pairing::Fqk_type::value_type::one());
292+
curve_type::pairing::pair_curve_type::pairing::fqk_type::value_type::one());
293293

294294
compute_el_inv->generate_r1cs_constraints();
295295
compute_el_q_2_minus_1->generate_r1cs_constraints();
@@ -308,7 +308,7 @@ namespace nil {
308308

309309
void generate_r1cs_witness() {
310310
one->generate_r1cs_witness(
311-
pairing::pair_curve_type<curve_type>::pairing::Fqk_type::value_type::one());
311+
curve_type::pairing::pair_curve_type::pairing::fqk_type::value_type::one());
312312
el_inv->generate_r1cs_witness(el.get_element().inversed());
313313

314314
compute_el_inv->generate_r1cs_witness();
@@ -326,7 +326,6 @@ namespace nil {
326326
field_type::value_type::zero());
327327
}
328328
};
329-
330329
} // namespace components
331330
} // namespace snark
332331
} // namespace zk

0 commit comments

Comments
 (0)