Home > Back-end >  Miracl library of large number write Paillier homomorphic encryption, powmod function leads to the c
Miracl library of large number write Paillier homomorphic encryption, powmod function leads to the c

Time:03-27

 int main () {
Mip=mirsys (500, 0);//each number 500, type according to the need to transform
Mip - & gt; IOBASE=10;
//Encryption (mirvar (20));//input plaintext and random number r
Pailliertesrt ();
Mirexit ();
system("pause");
return 0;
}

Big Encryption (big M) {

Big temp=mirvar (0);
Big temp1=mirvar (0);
Big rr=mirvar (5);
Ccode=mirvar (0);
//n=mirvar (0);
P=mirvar (59747);
Q=mirvar (40387);
Lamdba=mirvar (1206450978);
N=mirvar (2413002089);
N_square=mirvar (5822579081518363921);
G=mirvar (2);
//ccode=g r ^ ^ m * n mod n_square
Powmod (rr, n, n_square, temp);//calculate ccode=rr ^ n mod n_square

Powmod (g, M, n_square, temp1);
Multiply (temp, temp1, temp);
Powmod (temp, mirvar (1), n_square, ccode);
//this function will work
Printf (" Paillier ccode: \ n ");
Cotnum (ccode, stdout);
Mirkill (temp);
Mirkill (temp1);
Mirkill (rr);
Mirkill (p);
Mirkill (q);
Mirkill (g);
Mirkill (n_square);
Return ccode;
}
  • Related