From 32e710ae07518b8964fd7249a5db8675d3e88ed1 Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Tue, 17 Oct 2017 20:51:19 +0200 Subject: [PATCH] remove trailing spaces --- etc/2kprime.c | 25 ++++++++++--------------- etc/drprime.c | 22 +++++++++++----------- etc/mersenne.c | 4 ++-- etc/mont.c | 15 +++++---------- 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/etc/2kprime.c b/etc/2kprime.c index 14da57e..f1cbcac 100644 --- a/etc/2kprime.c +++ b/etc/2kprime.c @@ -12,16 +12,16 @@ int main(void) FILE *out; clock_t t1; mp_digit z; - + mp_init_multi(&q, &p, NULL); - + out = fopen("2kprime.1", "w"); for (x = 0; x < (int)(sizeof(sizes) / sizeof(sizes[0])); x++) { top: mp_2expt(&q, sizes[x]); mp_add_d(&q, 3, &q); z = -3; - + t1 = clock(); for(;;) { mp_sub_d(&q, 4, &q); @@ -31,13 +31,13 @@ int main(void) printf("No primes of size %d found\n", sizes[x]); break; } - - if (clock() - t1 > CLOCKS_PER_SEC) { + + if (clock() - t1 > CLOCKS_PER_SEC) { printf("."); fflush(stdout); // sleep((clock() - t1 + CLOCKS_PER_SEC/2)/CLOCKS_PER_SEC); t1 = clock(); } - + /* quick test on q */ mp_prime_is_prime(&q, 1, &y); if (y == 0) { @@ -60,24 +60,19 @@ int main(void) break; } - + if (y == 0) { ++sizes[x]; goto top; } - + mp_toradix(&q, buf, 10); printf("\n\n%d-bits (k = %lu) = %s\n", sizes[x], z, buf); fprintf(out, "%d-bits (k = %lu) = %s\n", sizes[x], z, buf); fflush(out); } - + return 0; -} - - - - - +} /* ref: $Format:%D$ */ /* git commit: $Format:%H$ */ diff --git a/etc/drprime.c b/etc/drprime.c index 29d89db..c11c1c6 100644 --- a/etc/drprime.c +++ b/etc/drprime.c @@ -2,16 +2,17 @@ #include int sizes[] = { 1+256/DIGIT_BIT, 1+512/DIGIT_BIT, 1+768/DIGIT_BIT, 1+1024/DIGIT_BIT, 1+2048/DIGIT_BIT, 1+4096/DIGIT_BIT }; + int main(void) { int res, x, y; char buf[4096]; FILE *out; mp_int a, b; - + mp_init(&a); mp_init(&b); - + out = fopen("drprimes.txt", "w"); for (x = 0; x < (int)(sizeof(sizes)/sizeof(sizes[0])); x++) { top: @@ -21,14 +22,14 @@ int main(void) for (y = 1; y < sizes[x]; y++) { a.dp[y] = MP_MASK; } - + /* make a DR modulus */ a.dp[0] = -1; a.used = sizes[x]; - + /* now loop */ res = 0; - for (;;) { + for (;;) { a.dp[0] += 4; if (a.dp[0] >= MP_MASK) break; mp_prime_is_prime(&a, 1, &res); @@ -36,29 +37,28 @@ int main(void) printf("."); fflush(stdout); mp_sub_d(&a, 1, &b); mp_div_2(&b, &b); - mp_prime_is_prime(&b, 3, &res); + mp_prime_is_prime(&b, 3, &res); if (res == 0) continue; mp_prime_is_prime(&a, 3, &res); if (res == 1) break; } - + if (res != 1) { printf("Error not DR modulus\n"); sizes[x] += 1; goto top; } else { mp_toradix(&a, buf, 10); printf("\n\np == %s\n\n", buf); fprintf(out, "%d-bit prime:\np == %s\n\n", mp_count_bits(&a), buf); fflush(out); - } + } } fclose(out); - + mp_clear(&a); mp_clear(&b); - + return 0; } - /* ref: $Format:%D$ */ /* git commit: $Format:%H$ */ /* commit time: $Format:%ai$ */ diff --git a/etc/mersenne.c b/etc/mersenne.c index 432cec1..ca6ee5f 100644 --- a/etc/mersenne.c +++ b/etc/mersenne.c @@ -1,4 +1,4 @@ -/* Finds Mersenne primes using the Lucas-Lehmer test +/* Finds Mersenne primes using the Lucas-Lehmer test * * Tom St Denis, tomstdenis@gmail.com */ @@ -10,7 +10,7 @@ is_mersenne (long s, int *pp) { mp_int n, u; int res, k; - + *pp = 0; if ((res = mp_init (&n)) != MP_OKAY) { diff --git a/etc/mont.c b/etc/mont.c index ac14e06..e41ad45 100644 --- a/etc/mont.c +++ b/etc/mont.c @@ -13,21 +13,21 @@ int main(void) /* loop through various sizes */ for (x = 4; x < 256; x++) { printf("DIGITS == %3ld...", x); fflush(stdout); - + /* make up the odd modulus */ mp_rand(&modulus, x); modulus.dp[0] |= 1; - + /* now find the R value */ mp_montgomery_calc_normalization(&R, &modulus); mp_montgomery_setup(&modulus, &mp); - + /* now run through a bunch tests */ for (y = 0; y < 1000; y++) { mp_rand(&p, x/2); /* p = random */ mp_mul(&p, &R, &pp); /* pp = R * p */ mp_montgomery_reduce(&pp, &modulus, mp); - + /* should be equal to p */ if (mp_cmp(&pp, &p) != MP_EQ) { printf("FAILURE!\n"); @@ -36,15 +36,10 @@ int main(void) } printf("PASSED\n"); } - + return 0; } - - - - - /* ref: $Format:%D$ */ /* git commit: $Format:%H$ */ /* commit time: $Format:%ai$ */