Skip to content

Commit 2fb64b2

Browse files
committed
Inline verify is slow, this is what unit tests are for
1 parent dd08f03 commit 2fb64b2

File tree

2 files changed

+0
-68
lines changed

2 files changed

+0
-68
lines changed

src/impl/group.h

-18
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,6 @@ void static secp256k1_gej_mul_lambda(secp256k1_gej_t *r, const secp256k1_gej_t *
271271
}
272272

273273
void static secp256k1_gej_split_exp(secp256k1_num_t *r1, secp256k1_num_t *r2, const secp256k1_num_t *a) {
274-
#ifdef VERIFY
275-
secp256k1_num_t a2;
276-
secp256k1_num_init(&a2);
277-
secp256k1_num_copy(&a2, a);
278-
#endif
279-
280274
const secp256k1_ge_consts_t *c = secp256k1_ge_consts;
281275
secp256k1_num_t bnc1, bnc2, bnt1, bnt2, bnn2;
282276

@@ -305,18 +299,6 @@ void static secp256k1_gej_split_exp(secp256k1_num_t *r1, secp256k1_num_t *r2, co
305299
secp256k1_num_mul(&bnt2, &bnc2, &c->a1b2);
306300
secp256k1_num_sub(r2, &bnt1, &bnt2);
307301

308-
#ifdef VERIFY
309-
secp256k1_num_t check;
310-
secp256k1_num_init(&check);
311-
secp256k1_num_mul(&check, r2, &c->lambda);
312-
secp256k1_num_add(&check, &check, r1);
313-
secp256k1_num_mod(&check, &c->order);
314-
secp256k1_num_mod(&a2, &c->order);
315-
assert(secp256k1_num_cmp(&check, &a2) == 0);
316-
secp256k1_num_free(&check);
317-
secp256k1_num_free(&a2);
318-
#endif
319-
320302
secp256k1_num_free(&bnc1);
321303
secp256k1_num_free(&bnc2);
322304
secp256k1_num_free(&bnt1);

src/impl/num_gmp.h

-50
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,6 @@ void static secp256k1_num_mod_inverse(secp256k1_num_t *r, const secp256k1_num_t
107107
secp256k1_num_sanity(a);
108108
secp256k1_num_sanity(m);
109109

110-
#ifdef VERIFY
111-
secp256k1_num_t a2 = *a;
112-
secp256k1_num_t m2 = *m;
113-
#endif
114-
115110
// mpn_gcdext computes: (G,S) = gcdext(U,V), where
116111
// * G = gcd(U,V)
117112
// * G = U*S + V*T
@@ -142,12 +137,6 @@ void static secp256k1_num_mod_inverse(secp256k1_num_t *r, const secp256k1_num_t
142137
} else {
143138
r->limbs = sn;
144139
}
145-
146-
#ifdef VERIFY
147-
secp256k1_num_t c;
148-
secp256k1_num_mod_mul(&c, &a2, r, m);
149-
assert(c.limbs == 1 && c.data[0] == 1);
150-
#endif
151140
}
152141

153142
int static secp256k1_num_is_zero(const secp256k1_num_t *a) {
@@ -190,44 +179,16 @@ void static secp256k1_num_subadd(secp256k1_num_t *r, const secp256k1_num_t *a, c
190179
void static secp256k1_num_add(secp256k1_num_t *r, const secp256k1_num_t *a, const secp256k1_num_t *b) {
191180
secp256k1_num_sanity(a);
192181
secp256k1_num_sanity(b);
193-
194-
#ifdef VERIFY
195-
secp256k1_num_t a2 = *a;
196-
secp256k1_num_t b2 = *b;
197-
#endif
198-
199182
secp256k1_num_subadd(r, a, b, 0);
200-
201-
#ifdef VERIFY
202-
secp256k1_num_t c = *r;
203-
secp256k1_num_subadd(&c, &c, &b2, 1);
204-
assert(secp256k1_num_cmp(&c, &a2) == 0);
205-
#endif
206183
}
207184

208185
void static secp256k1_num_sub(secp256k1_num_t *r, const secp256k1_num_t *a, const secp256k1_num_t *b) {
209-
#ifdef VERIFY
210-
secp256k1_num_t a2 = *a;
211-
secp256k1_num_t b2 = *b;
212-
#endif
213186
secp256k1_num_sanity(a);
214187
secp256k1_num_sanity(b);
215-
216188
secp256k1_num_subadd(r, a, b, 1);
217-
218-
#ifdef VERIFY
219-
secp256k1_num_t c;
220-
secp256k1_num_subadd(&c, r, &b2, 0);
221-
assert(secp256k1_num_cmp(&c, &a2) == 0);
222-
#endif
223189
}
224190

225191
void static secp256k1_num_mul(secp256k1_num_t *r, const secp256k1_num_t *a, const secp256k1_num_t *b) {
226-
#ifdef VERIFY
227-
secp256k1_num_t a2 = *a;
228-
secp256k1_num_t b2 = *b;
229-
#endif
230-
231192
secp256k1_num_sanity(a);
232193
secp256k1_num_sanity(b);
233194

@@ -248,17 +209,6 @@ void static secp256k1_num_mul(secp256k1_num_t *r, const secp256k1_num_t *a, cons
248209
assert(r->limbs <= 2*NUM_LIMBS);
249210
mpn_copyi(r->data, tmp, r->limbs);
250211
r->neg = a->neg ^ b->neg;
251-
252-
secp256k1_num_sanity(&a2);
253-
secp256k1_num_sanity(&b2);
254-
255-
#ifdef VERIFY
256-
secp256k1_num_t c;
257-
secp256k1_num_div(&c, r, &b2);
258-
assert(secp256k1_num_cmp(&a2, &c) == 0);
259-
secp256k1_num_div(&c, r, &a2);
260-
assert(secp256k1_num_cmp(&b2, &c) == 0);
261-
#endif
262212
}
263213

264214
void static secp256k1_num_div(secp256k1_num_t *r, const secp256k1_num_t *a, const secp256k1_num_t *b) {

0 commit comments

Comments
 (0)