Given
This is an ElGamal / discrete log setting.
Typical tasks:
Public key:
Secret key:
Encryption:
Ciphertext: (B, C)
Decryption:
Inverse:
Input: m, b, p, α, A
Input: (B, C), x
Goal:
Use:
Solve x mod qiei, then combine via CRT.
FactorsInt(p-1);
Compute:
Table:
Find:
PowerMod(alpha, (p-1)/q, p);
PowerMod(A, (p-1)/q, p);
A := A * InverseMod(PowerMod(alpha, x0, p), p);
Now:
For digit xi:
Then remove:
Repeat until all digits are found.
This gives:
After computing all residues:
ChineseRem([a1, a2, ...], [m1, m2, ...]);
Final result:
Each step projects the problem into a subgroup of order q, isolating one digit of x at a time.