[Help in Formula implementation] Why am I getting a float value when a integer value is expected?
Mostra commenti meno recenti
I'm trying to implement the Paillier cryptosystem in Matlab using the key generation guidance available here: https://en.wikipedia.org/wiki/Paillier_cryptosystem#Key_generation, but the problem is that with any combination of prime numbers I try, I get a float gMu required for the private key.
The first step is:
> Choose two large prime numbers p and q
Just for a starting point I chose ``p = 17 and q = 19``.
> Compute n=p*q and
Which I achieved in Matlab using:
n = p*q;
lambda = lcm((p - 1), (q - 1));
This gives me "n = 323" and "lambda = 144"
> Third step:
Select random integer g
I read that "g = n + 1" satisfies all the required conditions so I went with that, which gives me a "g = 324".
> Fourth step is to compute mu using:
where
I achieved this using:
a = (powermod(g, lambda, n*n) - 1) / n;
gMu = mod(inv(a),n);
So at this stage, the public key is supposed to be "(n,g) = (323,324)" and the private key would be "(lambda,mu)" which in my case comes to "(144,0.0069)".
Why am I getting a float value of "gMu" whereas all the implementations I have seen online provide a integer value of private keys.
Where am I getting this wrong?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Number Theory in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!