@@ -100,36 +100,9 @@ where
100100 // - (u1 + u3) * G
101101 // - u2 * pubkey + u3 * G
102102 // are not equal
103- //
104- // TODO: Technically they could be equal for a valid signature, but this happens with
105- // vanishing probability for an ECDSA signature constructed in a standard way
106- // coordinates of u1_mul and u2_mul are in proper bigint form, and lie in but are not
107- // constrained to [0, n) we therefore need hard inequality here
108103 let u1_u2_x_eq = ecc_chip. is_equal ( ctx, & u1u3_mul, & u2_pk_u3_g) ;
109104 let u1_u2_not_eq = base_chip. range . gate ( ) . not ( ctx, Existing ( u1_u2_x_eq) ) ;
110105
111- // check u1*G and u2*pubkey are not negate of each other
112- // that means the sum of
113- // - (u1 + u3) * G
114- // - u2 * pubkey + u3 * G
115- // should not equal to 2u3 * G
116- let u1_u2_not_neg = {
117- // again we get 2u3*G from constant to avoid scalar_multiply
118- let two_generator = GA :: generator ( ) ;
119- let neg_two_generator = -two_generator;
120- let two_generator = ecc_chip. assign_constant_point ( ctx, two_generator) ;
121- let neg_two_generator = ecc_chip. assign_constant_point ( ctx, neg_two_generator) ;
122- let two_u3_g = ecc_chip. select ( ctx, & neg_two_generator, & two_generator, & u1_is_one) ;
123-
124- base_chip. enforce_less_than_p ( ctx, u1u3_mul. x ( ) ) ;
125- base_chip. enforce_less_than_p ( ctx, u2_pk_u3_g. x ( ) ) ;
126- // safe: we have already checked (u1 + u3) * G != u2 * pubkey + u3 * G
127- let sum = ec_add_unequal ( base_chip, ctx, & u1u3_mul, & u2_pk_u3_g, false ) ;
128-
129- let is_equal = ecc_chip. is_equal ( ctx, & sum, & two_u3_g) ;
130- base_chip. range . gate ( ) . not ( ctx, Existing ( is_equal) )
131- } ;
132-
133106 // compute (x1, y1) = u1 * G + u2 * pubkey and check (r mod n) == x1 as integers
134107 // which is basically u1u3_mul + u2_mul - u3_mul
135108 // WARNING: For optimization reasons, does not reduce x1 mod n, which is
@@ -184,12 +157,8 @@ where
184157 let res5 = base_chip
185158 . range
186159 . gate ( )
187- . and ( ctx, Existing ( res4) , Existing ( u1_u2_not_neg) ) ;
188- let res6 = base_chip
189- . range
190- . gate ( )
191- . and ( ctx, Existing ( res5) , Existing ( equal_check) ) ;
192- ( res6, sum. y )
160+ . and ( ctx, Existing ( res4) , Existing ( equal_check) ) ;
161+ ( res5, sum. y )
193162}
194163
195164fn scalar_field_element_is_one < F : PrimeField , SF : PrimeField > (
0 commit comments