Defalt initialize q to p, e to 0. The following loop will properly assign them.

This commit is contained in:
Imbus 2025-02-13 00:38:24 +01:00
parent e6e63f2d32
commit 563778716c

4
main.c
View file

@ -34,7 +34,7 @@ int main() {
enter_blink(); enter_blink();
uint64_t p = gen_prime(1 << 15, 1 << 16); uint64_t p = gen_prime(1 << 15, 1 << 16);
uint64_t q = gen_prime(1 << 15, 1 << 16); uint64_t q = p;
while (p == q) p = gen_prime(1 << 15, 1 << 16); while (p == q) p = gen_prime(1 << 15, 1 << 16);
@ -42,7 +42,7 @@ int main() {
uint64_t phi_n = (p - 1) * (q - 1); uint64_t phi_n = (p - 1) * (q - 1);
// 'e' is public. E for encrypt. // 'e' is public. E for encrypt.
uint64_t e = prand_range(3, phi_n - 1); uint64_t e = 0;
while (gcd(e, phi_n) != 1) e = prand_range(3, phi_n - 1); while (gcd(e, phi_n) != 1) e = prand_range(3, phi_n - 1);
// 'd' is our private key. D as in decrypt // 'd' is our private key. D as in decrypt