Because of the need of the project, I want to develop a simple public key cryptography algorithm, but I have doubts when generating the key pair.
I have learned about the key generation process of RSA. It is to prepare two coprime numbers (p, q), multiply them to obtain N, and then calculate L (that is, L=lcm (p-1, q-1)), calculate the public key (pk is a number larger than 1 and smaller than L, and the maximum common divisor of pk and L is 1), and calculate the private key (sk is a number larger than 1 and smaller than L, and the public key multiplied by sk modulus L is 1).
This is a simplified version of my algorithm (to better explain it to you):
The encryption process is "C = M * PK^3 mod 65537", and the decryption process is "M = C * SK^3 mod 65537".
I want to know how to quickly find the public key based on the private key after generating the private key.
This is the nature of public and private keys:
Both public and private keys are greater than 1 and less than 65537.
The encryption and decryption process has been given above.
I used a simple random algorithm to generate a private key (greater than 1, less than 65537), and then used a loop to try to find the value of the public key corresponding to the private key.
like this(This is a piece of pseudocode):
#define E(m, k) ((m * k^3) mod 65537)
#define D(c, k) ((c * k^3) mod 65537)
sk = 18392;
for(int i = 2; i < 65537; ++i) {
if (D(E(3, i), sk) == 3) {
pk = i;
break;
}
}
As you can see, this is a very bad way to find the public key.
So I want to know what is the right way? (That is, the key pair can be generated more quickly like RSA)