Matlab taking forever to give a simple result - something that java does in seconds
Mostrar comentarios más antiguos
I am trying to do encryption in Matlab using Paillier, I found online implementation in Java, since I know matlab and am very bad at java. I implemented that code in matlab. I want to know if matlab very bad at this or is my implementation wrong?
I'm having performance issues with matlab using large prime numbers. I am using vpi for all my inputs and it is still taking hours.
I'm encrypting a number using Paillier encryption, using:
n = p*q;
cipherText = mod(g^pixel_value*random_number^n,n^2);
This works and I can decrypt the result as well using small prime numbers such as p = 43 and q = 47. But for this to be effective I have to use large prime numbers, so I tried with p = 41983 and q = 42013, and random_number = 743. I am unable to get a result for that above calculation.
It has been over 2 hours and its still busy processing for a pixel_value = vpi(10).
Whereas on the other hand in Java, my p and q are of 512 bits each and I get the encryption and decryption done within seconds. Here is the code in java for encryption:
public BigInteger Encryption(BigInteger m) {
BigInteger r = new BigInteger(bitLength, new Random());
return g.modPow(m, nsquare).multiply(r.modPow(n, nsquare)).mod(nsquare);
using the following p and q respectively:
97397929462509430948085750131928345276271739093186875584416638279790842581747
90403725479134903380301300689889714727885388292269807925961915682035739163693
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Performance and Memory en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!