Commit a44e68e652347fb4e44de6fef72b767fdebca1a6

Daniel Mendler 2019-10-24T17:43:31

remove MP_IS_* macros

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
diff --git a/mp_add_d.c b/mp_add_d.c
index 3be2d23..cd0d47a 100644
--- a/mp_add_d.c
+++ b/mp_add_d.c
@@ -12,7 +12,7 @@ mp_err mp_add_d(const mp_int *a, mp_digit b, mp_int *c)
 
    /* fast path for a == c */
    if (a == c &&
-       !MP_IS_ZERO(c) &&
+       !mp_iszero(c) &&
        c->sign == MP_ZPOS &&
        c->dp[0] + b < MP_DIGIT_MAX) {
       c->dp[0] += b;
diff --git a/mp_cnt_lsb.c b/mp_cnt_lsb.c
index a2cd5f8..7ae8bc1 100644
--- a/mp_cnt_lsb.c
+++ b/mp_cnt_lsb.c
@@ -14,7 +14,7 @@ int mp_cnt_lsb(const mp_int *a)
    mp_digit q, qq;
 
    /* easy out */
-   if (MP_IS_ZERO(a)) {
+   if (mp_iszero(a)) {
       return 0;
    }
 
diff --git a/mp_count_bits.c b/mp_count_bits.c
index 76257c8..52b463d 100644
--- a/mp_count_bits.c
+++ b/mp_count_bits.c
@@ -10,7 +10,7 @@ int mp_count_bits(const mp_int *a)
    mp_digit q;
 
    /* shortcut */
-   if (MP_IS_ZERO(a)) {
+   if (mp_iszero(a)) {
       return 0;
    }
 
diff --git a/mp_div.c b/mp_div.c
index e9f4f50..23a2acf 100644
--- a/mp_div.c
+++ b/mp_div.c
@@ -8,7 +8,7 @@ mp_err mp_div(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d)
    mp_err err;
 
    /* is divisor zero ? */
-   if (MP_IS_ZERO(b)) {
+   if (mp_iszero(b)) {
       return MP_VAL;
    }
 
diff --git a/mp_div_d.c b/mp_div_d.c
index 331b285..98b6b24 100644
--- a/mp_div_d.c
+++ b/mp_div_d.c
@@ -18,7 +18,7 @@ mp_err mp_div_d(const mp_int *a, mp_digit b, mp_int *c, mp_digit *d)
    }
 
    /* quick outs */
-   if ((b == 1u) || MP_IS_ZERO(a)) {
+   if ((b == 1u) || mp_iszero(a)) {
       if (d != NULL) {
          *d = 0;
       }
diff --git a/mp_exptmod.c b/mp_exptmod.c
index fcc894b..8f8a9e9 100644
--- a/mp_exptmod.c
+++ b/mp_exptmod.c
@@ -62,7 +62,7 @@ LBL_ERR:
    }
 
    /* if the modulus is odd or dr != 0 use the montgomery method */
-   if (MP_HAS(S_MP_EXPTMOD_FAST) && (MP_IS_ODD(P) || (dr != 0))) {
+   if (MP_HAS(S_MP_EXPTMOD_FAST) && (mp_isodd(P) || (dr != 0))) {
       return s_mp_exptmod_fast(G, X, P, Y, dr);
    } else if (MP_HAS(S_MP_EXPTMOD)) {
       /* otherwise use the generic Barrett reduction technique */
diff --git a/mp_exteuclid.c b/mp_exteuclid.c
index 5b850da..eb8ad37 100644
--- a/mp_exteuclid.c
+++ b/mp_exteuclid.c
@@ -24,7 +24,7 @@ mp_err mp_exteuclid(const mp_int *a, const mp_int *b, mp_int *U1, mp_int *U2, mp
    if ((err = mp_copy(b, &v3)) != MP_OKAY)                        goto LBL_ERR;
 
    /* loop while v3 != 0 */
-   while (!MP_IS_ZERO(&v3)) {
+   while (!mp_iszero(&v3)) {
       /* q = u3/v3 */
       if ((err = mp_div(&u3, &v3, &q, NULL)) != MP_OKAY)          goto LBL_ERR;
 
diff --git a/mp_gcd.c b/mp_gcd.c
index 79b6749..4f6b6cc 100644
--- a/mp_gcd.c
+++ b/mp_gcd.c
@@ -11,10 +11,10 @@ mp_err mp_gcd(const mp_int *a, const mp_int *b, mp_int *c)
    mp_err err;
 
    /* either zero than gcd is the largest */
-   if (MP_IS_ZERO(a)) {
+   if (mp_iszero(a)) {
       return mp_abs(b, c);
    }
-   if (MP_IS_ZERO(b)) {
+   if (mp_iszero(b)) {
       return mp_abs(a, c);
    }
 
@@ -59,7 +59,7 @@ mp_err mp_gcd(const mp_int *a, const mp_int *b, mp_int *c)
       }
    }
 
-   while (!MP_IS_ZERO(&v)) {
+   while (!mp_iszero(&v)) {
       /* make sure v is the largest */
       if (mp_cmp_mag(&u, &v) == MP_GT) {
          /* swap u and v to make sure v is >= u */
diff --git a/mp_invmod.c b/mp_invmod.c
index b797d4e..e43eb3e 100644
--- a/mp_invmod.c
+++ b/mp_invmod.c
@@ -12,7 +12,7 @@ mp_err mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
    }
 
    /* if the modulus is odd we can use a faster routine instead */
-   if (MP_HAS(S_MP_INVMOD_FAST) && MP_IS_ODD(b)) {
+   if (MP_HAS(S_MP_INVMOD_FAST) && mp_isodd(b)) {
       return s_mp_invmod_fast(a, b, c);
    }
 
diff --git a/mp_is_square.c b/mp_is_square.c
index c2428f8..f1df73e 100644
--- a/mp_is_square.c
+++ b/mp_is_square.c
@@ -40,7 +40,7 @@ mp_err mp_is_square(const mp_int *arg, mp_bool *ret)
       return MP_VAL;
    }
 
-   if (MP_IS_ZERO(arg)) {
+   if (mp_iszero(arg)) {
       return MP_OKAY;
    }
 
diff --git a/mp_kronecker.c b/mp_kronecker.c
index 3111a78..0ac6338 100644
--- a/mp_kronecker.c
+++ b/mp_kronecker.c
@@ -25,7 +25,7 @@ mp_err mp_kronecker(const mp_int *a, const mp_int *p, int *c)
 
    static const int table[8] = {0, 1, 0, -1, 0, -1, 0, 1};
 
-   if (MP_IS_ZERO(p)) {
+   if (mp_iszero(p)) {
       if ((a->used == 1) && (a->dp[0] == 1u)) {
          *c = 1;
       } else {
@@ -34,7 +34,7 @@ mp_err mp_kronecker(const mp_int *a, const mp_int *p, int *c)
       return MP_OKAY;
    }
 
-   if (MP_IS_EVEN(a) && MP_IS_EVEN(p)) {
+   if (mp_iseven(a) && mp_iseven(p)) {
       *c = 0;
       return MP_OKAY;
    }
@@ -69,7 +69,7 @@ mp_err mp_kronecker(const mp_int *a, const mp_int *p, int *c)
    }
 
    for (;;) {
-      if (MP_IS_ZERO(&a1)) {
+      if (mp_iszero(&a1)) {
          if (mp_cmp_d(&p1, 1uL) == MP_EQ) {
             *c = k;
             goto LBL_KRON;
diff --git a/mp_log_u32.c b/mp_log_u32.c
index cff9e48..31d9662 100644
--- a/mp_log_u32.c
+++ b/mp_log_u32.c
@@ -9,7 +9,7 @@ mp_err mp_log_u32(const mp_int *a, uint32_t base, uint32_t *c)
       return MP_VAL;
    }
 
-   if (MP_IS_ZERO(a)) {
+   if (mp_iszero(a)) {
       return MP_VAL;
    }
 
diff --git a/mp_lshd.c b/mp_lshd.c
index eb9a5c3..b0a8454 100644
--- a/mp_lshd.c
+++ b/mp_lshd.c
@@ -15,7 +15,7 @@ mp_err mp_lshd(mp_int *a, int b)
       return MP_OKAY;
    }
    /* no need to shift 0 around */
-   if (MP_IS_ZERO(a)) {
+   if (mp_iszero(a)) {
       return MP_OKAY;
    }
 
diff --git a/mp_mod.c b/mp_mod.c
index 349fece..3eced35 100644
--- a/mp_mod.c
+++ b/mp_mod.c
@@ -17,7 +17,7 @@ mp_err mp_mod(const mp_int *a, const mp_int *b, mp_int *c)
       goto LBL_ERR;
    }
 
-   if (MP_IS_ZERO(&t) || (t.sign == b->sign)) {
+   if (mp_iszero(&t) || (t.sign == b->sign)) {
       err = MP_OKAY;
       mp_exch(&t, c);
    } else {
diff --git a/mp_neg.c b/mp_neg.c
index 01fb276..2fc1854 100644
--- a/mp_neg.c
+++ b/mp_neg.c
@@ -13,7 +13,7 @@ mp_err mp_neg(const mp_int *a, mp_int *b)
       }
    }
 
-   if (!MP_IS_ZERO(b)) {
+   if (!mp_iszero(b)) {
       b->sign = (a->sign == MP_ZPOS) ? MP_NEG : MP_ZPOS;
    } else {
       b->sign = MP_ZPOS;
diff --git a/mp_prime_frobenius_underwood.c b/mp_prime_frobenius_underwood.c
index 0e2ba64..bb56ea7 100644
--- a/mp_prime_frobenius_underwood.c
+++ b/mp_prime_frobenius_underwood.c
@@ -112,7 +112,7 @@ mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result)
 
    mp_set_u32(&T1z, (uint32_t)((2 * a) + 5));
    if ((err = mp_mod(&T1z, N, &T1z)) != MP_OKAY)                  goto LBL_FU_ERR;
-   if (MP_IS_ZERO(&sz) && (mp_cmp(&tz, &T1z) == MP_EQ)) {
+   if (mp_iszero(&sz) && (mp_cmp(&tz, &T1z) == MP_EQ)) {
       *result = MP_YES;
    }
 
diff --git a/mp_prime_is_prime.c b/mp_prime_is_prime.c
index 1a61bb6..e4f9214 100644
--- a/mp_prime_is_prime.c
+++ b/mp_prime_is_prime.c
@@ -39,7 +39,7 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result)
    }
 
    /* N must be odd */
-   if (MP_IS_EVEN(a)) {
+   if (mp_iseven(a)) {
       return MP_OKAY;
    }
    /* N is not a perfect square: floor(sqrt(N))^2 != N */
diff --git a/mp_prime_next_prime.c b/mp_prime_next_prime.c
index 3256e37..c8f7603 100644
--- a/mp_prime_next_prime.c
+++ b/mp_prime_next_prime.c
@@ -58,7 +58,7 @@ mp_err mp_prime_next_prime(mp_int *a, int t, mp_bool bbs_style)
          }
       }
    } else {
-      if (MP_IS_EVEN(a)) {
+      if (mp_iseven(a)) {
          /* force odd */
          if ((err = mp_sub_d(a, 1uL, a)) != MP_OKAY) {
             return err;
diff --git a/mp_prime_strong_lucas_selfridge.c b/mp_prime_strong_lucas_selfridge.c
index 895a481..0aee33d 100644
--- a/mp_prime_strong_lucas_selfridge.c
+++ b/mp_prime_strong_lucas_selfridge.c
@@ -206,7 +206,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
          if ((err = mp_mul(&U2mz, &Uz, &T4z)) != MP_OKAY)         goto LBL_LS_ERR;
          if ((err = s_mp_mul_si(&T4z, Ds, &T4z)) != MP_OKAY)      goto LBL_LS_ERR;
          if ((err = mp_add(&T1z, &T2z, &Uz)) != MP_OKAY)          goto LBL_LS_ERR;
-         if (MP_IS_ODD(&Uz)) {
+         if (mp_isodd(&Uz)) {
             if ((err = mp_add(&Uz, a, &Uz)) != MP_OKAY)           goto LBL_LS_ERR;
          }
          /* CZ
@@ -214,16 +214,16 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
           * Thomas R. Nicely used GMP's mpz_fdiv_q_2exp().
           * But mp_div_2() does not do so, it is truncating instead.
           */
-         oddness = MP_IS_ODD(&Uz) ? MP_YES : MP_NO;
+         oddness = mp_isodd(&Uz) ? MP_YES : MP_NO;
          if ((err = mp_div_2(&Uz, &Uz)) != MP_OKAY)               goto LBL_LS_ERR;
          if ((Uz.sign == MP_NEG) && (oddness != MP_NO)) {
             if ((err = mp_sub_d(&Uz, 1uL, &Uz)) != MP_OKAY)       goto LBL_LS_ERR;
          }
          if ((err = mp_add(&T3z, &T4z, &Vz)) != MP_OKAY)          goto LBL_LS_ERR;
-         if (MP_IS_ODD(&Vz)) {
+         if (mp_isodd(&Vz)) {
             if ((err = mp_add(&Vz, a, &Vz)) != MP_OKAY)           goto LBL_LS_ERR;
          }
-         oddness = MP_IS_ODD(&Vz) ? MP_YES : MP_NO;
+         oddness = mp_isodd(&Vz) ? MP_YES : MP_NO;
          if ((err = mp_div_2(&Vz, &Vz)) != MP_OKAY)               goto LBL_LS_ERR;
          if ((Vz.sign == MP_NEG) && (oddness != MP_NO)) {
             if ((err = mp_sub_d(&Vz, 1uL, &Vz)) != MP_OKAY)       goto LBL_LS_ERR;
@@ -239,7 +239,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
 
    /* If U_d or V_d is congruent to 0 mod N, then N is a prime or a
       strong Lucas pseudoprime. */
-   if (MP_IS_ZERO(&Uz) || MP_IS_ZERO(&Vz)) {
+   if (mp_iszero(&Uz) || mp_iszero(&Vz)) {
       *result = MP_YES;
       goto LBL_LS_ERR;
    }
@@ -262,7 +262,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
       if ((err = mp_sqr(&Vz, &Vz)) != MP_OKAY)                    goto LBL_LS_ERR;
       if ((err = mp_sub(&Vz, &Q2kdz, &Vz)) != MP_OKAY)            goto LBL_LS_ERR;
       if ((err = mp_mod(&Vz, a, &Vz)) != MP_OKAY)                 goto LBL_LS_ERR;
-      if (MP_IS_ZERO(&Vz)) {
+      if (mp_iszero(&Vz)) {
          *result = MP_YES;
          goto LBL_LS_ERR;
       }
diff --git a/mp_radix_size.c b/mp_radix_size.c
index 6c3e582..47f2f68 100644
--- a/mp_radix_size.c
+++ b/mp_radix_size.c
@@ -15,7 +15,7 @@ mp_err mp_radix_size(const mp_int *a, int radix, size_t *size)
       return MP_VAL;
    }
 
-   if (MP_IS_ZERO(a)) {
+   if (mp_iszero(a)) {
       *size = 2;
       return MP_OKAY;
    }
diff --git a/mp_read_radix.c b/mp_read_radix.c
index dc5e167..0e4f848 100644
--- a/mp_read_radix.c
+++ b/mp_read_radix.c
@@ -71,7 +71,7 @@ mp_err mp_read_radix(mp_int *a, const char *str, int radix)
    }
 
    /* set the sign only if a != 0 */
-   if (!MP_IS_ZERO(a)) {
+   if (!mp_iszero(a)) {
       a->sign = neg;
    }
    return MP_OKAY;
diff --git a/mp_set_double.c b/mp_set_double.c
index f7e3b8d..467d7fd 100644
--- a/mp_set_double.c
+++ b/mp_set_double.c
@@ -30,7 +30,7 @@ mp_err mp_set_double(mp_int *a, double b)
       return err;
    }
 
-   if (((cast.bits >> 63) != 0uLL) && !MP_IS_ZERO(a)) {
+   if (((cast.bits >> 63) != 0uLL) && !mp_iszero(a)) {
       a->sign = MP_NEG;
    }
 
diff --git a/mp_sqrt.c b/mp_sqrt.c
index 2839868..b51f615 100644
--- a/mp_sqrt.c
+++ b/mp_sqrt.c
@@ -15,7 +15,7 @@ mp_err mp_sqrt(const mp_int *arg, mp_int *ret)
    }
 
    /* easy out */
-   if (MP_IS_ZERO(arg)) {
+   if (mp_iszero(arg)) {
       mp_zero(ret);
       return MP_OKAY;
    }
diff --git a/mp_sqrtmod_prime.c b/mp_sqrtmod_prime.c
index 723332f..96b2836 100644
--- a/mp_sqrtmod_prime.c
+++ b/mp_sqrtmod_prime.c
@@ -51,7 +51,7 @@ mp_err mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret)
    /* Q = prime - 1 */
    mp_zero(&S);
    /* S = 0 */
-   while (MP_IS_EVEN(&Q)) {
+   while (mp_iseven(&Q)) {
       if ((err = mp_div_2(&Q, &Q)) != MP_OKAY)                    goto cleanup;
       /* Q = Q / 2 */
       if ((err = mp_add_d(&S, 1uL, &S)) != MP_OKAY)               goto cleanup;
diff --git a/mp_sub_d.c b/mp_sub_d.c
index a8a0d38..e453d36 100644
--- a/mp_sub_d.c
+++ b/mp_sub_d.c
@@ -12,7 +12,7 @@ mp_err mp_sub_d(const mp_int *a, mp_digit b, mp_int *c)
 
    /* fast path for a == c */
    if (a == c &&
-       !MP_IS_ZERO(c) &&
+       !mp_iszero(c) &&
        c->sign == MP_ZPOS &&
        c->dp[0] > b) {
       c->dp[0] -= b;
diff --git a/mp_to_radix.c b/mp_to_radix.c
index b0564a1..78ad989 100644
--- a/mp_to_radix.c
+++ b/mp_to_radix.c
@@ -42,7 +42,7 @@ mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, i
    }
 
    /* quick out if its zero */
-   if (MP_IS_ZERO(a)) {
+   if (mp_iszero(a)) {
       *str++ = '0';
       *str = '\0';
       if (written != NULL) {
@@ -68,7 +68,7 @@ mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, i
       --maxlen;
    }
    digs = 0u;
-   while (!MP_IS_ZERO(&t)) {
+   while (!mp_iszero(&t)) {
       if (--maxlen < 1u) {
          /* no more room */
          err = MP_BUF;
diff --git a/s_mp_div_small.c b/s_mp_div_small.c
index 56b1335..c89023a 100644
--- a/s_mp_div_small.c
+++ b/s_mp_div_small.c
@@ -37,11 +37,11 @@ mp_err s_mp_div_small(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d)
    sign = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
    if (c != NULL) {
       mp_exch(c, &q);
-      c->sign  = MP_IS_ZERO(c) ? MP_ZPOS : sign;
+      c->sign  = mp_iszero(c) ? MP_ZPOS : sign;
    }
    if (d != NULL) {
       mp_exch(d, &ta);
-      d->sign = MP_IS_ZERO(d) ? MP_ZPOS : a->sign;
+      d->sign = mp_iszero(d) ? MP_ZPOS : a->sign;
    }
 LBL_ERR:
    mp_clear_multi(&ta, &tb, &tq, &q, NULL);
diff --git a/s_mp_invmod_fast.c b/s_mp_invmod_fast.c
index 0d00ea9..ed1fc4a 100644
--- a/s_mp_invmod_fast.c
+++ b/s_mp_invmod_fast.c
@@ -16,7 +16,7 @@ mp_err s_mp_invmod_fast(const mp_int *a, const mp_int *b, mp_int *c)
    mp_err  err;
 
    /* 2. [modified] b must be odd   */
-   if (MP_IS_EVEN(b)) {
+   if (mp_iseven(b)) {
       return MP_VAL;
    }
 
@@ -32,7 +32,7 @@ mp_err s_mp_invmod_fast(const mp_int *a, const mp_int *b, mp_int *c)
    if ((err = mp_mod(a, b, &y)) != MP_OKAY)                       goto LBL_ERR;
 
    /* if one of x,y is zero return an error! */
-   if (MP_IS_ZERO(&x) || MP_IS_ZERO(&y)) {
+   if (mp_iszero(&x) || mp_iszero(&y)) {
       err = MP_VAL;
       goto LBL_ERR;
    }
@@ -44,12 +44,12 @@ mp_err s_mp_invmod_fast(const mp_int *a, const mp_int *b, mp_int *c)
 
 top:
    /* 4.  while u is even do */
-   while (MP_IS_EVEN(&u)) {
+   while (mp_iseven(&u)) {
       /* 4.1 u = u/2 */
       if ((err = mp_div_2(&u, &u)) != MP_OKAY)                    goto LBL_ERR;
 
       /* 4.2 if B is odd then */
-      if (MP_IS_ODD(&B)) {
+      if (mp_isodd(&B)) {
          if ((err = mp_sub(&B, &x, &B)) != MP_OKAY)               goto LBL_ERR;
       }
       /* B = B/2 */
@@ -57,12 +57,12 @@ top:
    }
 
    /* 5.  while v is even do */
-   while (MP_IS_EVEN(&v)) {
+   while (mp_iseven(&v)) {
       /* 5.1 v = v/2 */
       if ((err = mp_div_2(&v, &v)) != MP_OKAY)                    goto LBL_ERR;
 
       /* 5.2 if D is odd then */
-      if (MP_IS_ODD(&D)) {
+      if (mp_isodd(&D)) {
          /* D = (D-x)/2 */
          if ((err = mp_sub(&D, &x, &D)) != MP_OKAY)               goto LBL_ERR;
       }
@@ -84,7 +84,7 @@ top:
    }
 
    /* if not zero goto step 4 */
-   if (!MP_IS_ZERO(&u)) {
+   if (!mp_iszero(&u)) {
       goto top;
    }
 
diff --git a/s_mp_invmod_slow.c b/s_mp_invmod_slow.c
index 4fecfb8..28cd6cd 100644
--- a/s_mp_invmod_slow.c
+++ b/s_mp_invmod_slow.c
@@ -10,7 +10,7 @@ mp_err s_mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
    mp_err  err;
 
    /* b cannot be negative */
-   if ((b->sign == MP_NEG) || MP_IS_ZERO(b)) {
+   if ((b->sign == MP_NEG) || mp_iszero(b)) {
       return MP_VAL;
    }
 
@@ -25,7 +25,7 @@ mp_err s_mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
    if ((err = mp_copy(b, &y)) != MP_OKAY)                         goto LBL_ERR;
 
    /* 2. [modified] if x,y are both even then return an error! */
-   if (MP_IS_EVEN(&x) && MP_IS_EVEN(&y)) {
+   if (mp_iseven(&x) && mp_iseven(&y)) {
       err = MP_VAL;
       goto LBL_ERR;
    }
@@ -38,12 +38,12 @@ mp_err s_mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
 
 top:
    /* 4.  while u is even do */
-   while (MP_IS_EVEN(&u)) {
+   while (mp_iseven(&u)) {
       /* 4.1 u = u/2 */
       if ((err = mp_div_2(&u, &u)) != MP_OKAY)                    goto LBL_ERR;
 
       /* 4.2 if A or B is odd then */
-      if (MP_IS_ODD(&A) || MP_IS_ODD(&B)) {
+      if (mp_isodd(&A) || mp_isodd(&B)) {
          /* A = (A+y)/2, B = (B-x)/2 */
          if ((err = mp_add(&A, &y, &A)) != MP_OKAY)               goto LBL_ERR;
          if ((err = mp_sub(&B, &x, &B)) != MP_OKAY)               goto LBL_ERR;
@@ -54,12 +54,12 @@ top:
    }
 
    /* 5.  while v is even do */
-   while (MP_IS_EVEN(&v)) {
+   while (mp_iseven(&v)) {
       /* 5.1 v = v/2 */
       if ((err = mp_div_2(&v, &v)) != MP_OKAY)                    goto LBL_ERR;
 
       /* 5.2 if C or D is odd then */
-      if (MP_IS_ODD(&C) || MP_IS_ODD(&D)) {
+      if (mp_isodd(&C) || mp_isodd(&D)) {
          /* C = (C+y)/2, D = (D-x)/2 */
          if ((err = mp_add(&C, &y, &C)) != MP_OKAY)               goto LBL_ERR;
          if ((err = mp_sub(&D, &x, &D)) != MP_OKAY)               goto LBL_ERR;
@@ -87,7 +87,7 @@ top:
    }
 
    /* if not zero goto step 4 */
-   if (!MP_IS_ZERO(&u)) {
+   if (!mp_iszero(&u)) {
       goto top;
    }
 
diff --git a/tommath_private.h b/tommath_private.h
index e26025f..07a8985 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -1,3 +1,4 @@
+
 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
 /* SPDX-License-Identifier: Unlicense */
 
@@ -149,11 +150,6 @@ extern void MP_FREE(void *mem, size_t size);
 /* Static assertion */
 #define MP_STATIC_ASSERT(msg, cond) typedef char mp_static_assert_##msg[(cond) ? 1 : -1];
 
-/* ---> Basic Manipulations <--- */
-#define MP_IS_ZERO(a) ((a)->used == 0)
-#define MP_IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
-#define MP_IS_ODD(a)  (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
-
 #define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
 #define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))