@@ -139,7 +139,8 @@ namespace nil {
139
139
for (std::size_t c_index = 0 ; c_index < gates[g_index].constraints .size (); c_index++) {
140
140
gate_lines += 2 ;
141
141
for (std::size_t t_index = 0 ; t_index < gates[g_index].constraints [c_index].terms .size (); t_index++) {
142
- gate_lines += 1 ;
142
+ if (gates[g_index].constraints [c_index].terms [t_index].coeff != FieldType::value_type::one ())
143
+ gate_lines += 1 ;
143
144
for (std::size_t v_index = 0 ; v_index < gates[g_index].constraints [c_index].terms [t_index].vars .size (); v_index++) {
144
145
gate_lines += 1 ;
145
146
}
@@ -405,18 +406,27 @@ namespace nil {
405
406
static std::string generate_term (
406
407
const profiling_params_type &profiling_params,
407
408
const Vars &vars,
408
- columns_rotations_type &columns_rotations
409
+ columns_rotations_type &columns_rotations,
410
+ bool coeff_one = false
409
411
) {
410
412
std::stringstream res;
413
+ bool first = true ;
414
+
411
415
for ( auto it = std::cbegin (vars); it != std::end (vars); it++){
416
+ if ( first ){
417
+ first = false ;
418
+ if (coeff_one){
419
+ res << " \t\t\t terms:=" << generate_variable (profiling_params, *it, columns_rotations) << std::endl;
420
+ continue ;
421
+ }
422
+ }
412
423
res << " \t\t\t terms:=mulmod(terms, " ;
413
424
res << generate_variable (profiling_params, *it, columns_rotations);
414
425
res << " , modulus)" << std::endl;
415
426
}
416
427
return res.str ();
417
428
}
418
429
419
- // TODO: optimise coeff = 0x1;
420
430
template <typename Terms>
421
431
static std::string generate_terms (
422
432
const profiling_params_type &profiling_params,
@@ -425,8 +435,12 @@ namespace nil {
425
435
) {
426
436
std::stringstream res;
427
437
for ( auto it = std::cbegin (terms); it != std::cend (terms); it++ ){
428
- res << " \t\t\t terms:=0x" << std::hex << it->coeff .data << std::dec << std::endl;
429
- res << generate_term (profiling_params, it->vars , columns_rotations);
438
+ if (it->coeff == FieldType::value_type::one ())
439
+ res << generate_term (profiling_params, it->vars , columns_rotations, true );
440
+ else {
441
+ res << " \t\t\t terms:=0x" << std::hex << it->coeff .data << std::dec << std::endl;
442
+ res << generate_term (profiling_params, it->vars , columns_rotations, false );
443
+ }
430
444
res << " \t\t\t mstore("
431
445
" add(local_vars, CONSTRAINT_EVAL_OFFSET),"
432
446
" addmod("
@@ -672,7 +686,6 @@ namespace nil {
672
686
std::stringstream executions;
673
687
674
688
if (!profiling_params.optimize_gates ){
675
- std::cout << " Non-optimized gates" << std::endl;
676
689
for (const auto &gate : bp.gates ()) {
677
690
imports << " import \" ./gate" << i << " .sol\" ;" << std::endl;
678
691
executions << " \t\t (local_vars.gates_evaluation, local_vars.theta_acc) = gate" << i <<" .evaluate_gate_be(gate_params, local_vars);" << std::endl;
0 commit comments