Code base obscuration (for images) 1.0
It implements different obscuration methods on portable images (.pgm and .ppm)
|
This class implements the Paillier cryptosystem. More...
#include <Paillier.hpp>
Public Member Functions | |
Paillier () | |
Construct a new Paillier object. | |
~Paillier () | |
Destroy the Paillier object. | |
uint64_t | random64 (uint64_t min, uint64_t max) |
Generate a random 64-bit unsigned integer. | |
uint64_t | fastMod_64t (uint64_t x, uint64_t e, uint64_t n) |
Calculate the modular exponentiation of a base raised to a power modulo a modulus. | |
uint64_t | gcd_64t (uint64_t a, uint64_t b) |
Calculate the greatest common divisor (GCD) of two 64-bit unsigned integers. | |
std::vector< uint64_t > | calc_set_same_remainder_divide_euclide_64t (uint64_t n) |
Calculate the set of elements in (Z/n²Z)*. | |
std::vector< uint64_t > | calc_set_same_remainder_divide_euclide_64t_v2 (uint64_t n, const uint64_t &lambda) |
Calculate the set of elements in (Z/n²Z)* that satisfy the condition L(x) = (x-1)/n where x is a positive integer and mu exists. | |
uint64_t | choose_g_in_vec_64t (std::vector< uint64_t > &set, const uint64_t &n, const uint64_t &lambda) |
Choose g from the set of elements in (Z/n²Z)* that satisfy the condition L(x) = (x-1)/n where x is a positive integer and mu exists. | |
uint64_t | choose_g_in_vec_64t_v2 (std::vector< uint64_t > &set) |
Choose g from the set of elements in (Z/n²Z)*. | |
uint64_t | L_64t (uint64_t x, uint64_t n) |
Calculate L(x). | |
uint64_t | lcm_64t (uint64_t a, uint64_t b) |
Calculate the least common multiple (LCM) of two 64-bit unsigned integers. | |
uint64_t | modInverse_64t (uint64_t a, uint64_t n) |
Calculate the modular inverse of a 64-bit unsigned integer modulo a modulus. | |
uint64_t | pow_uint64_t (uint64_t x, uint64_t n) |
Calculate the power of a 64-bit unsigned integer. | |
uint64_t | randomZNStar (uint64_t n) |
Choose a random element from the set Z/nZ*. | |
std::vector< uint64_t > | get_set_ZNZStar (uint64_t n) |
Return the set Z/nZ* as a vector. | |
std::vector< uint64_t > | get_set_ZN2ZStar (uint64_t n, uint64_t lambda) |
Return the set Z/n²Z* that satisfy the condition gcd(L(g^lambda mod n²), n) = 1 as a vector. | |
uint64_t | generate_g_64t (uint64_t n, uint64_t lambda) |
Generate g for Paillier cryptosystem. | |
void | generateMu_64t (uint64_t &mu, const uint64_t &g, const uint64_t &lambda, const uint64_t &n) |
Generate Mu for Paillier cryptosystem. | |
void | generatePrivateKey_64t (uint64_t &lambda, uint64_t &mu, const uint64_t &p, const uint64_t &q, const uint64_t &n, const uint64_t &g) |
Generate private key for Paillier cryptosystem. | |
T_out | paillierEncryption (uint64_t n, uint64_t g, T_in m) |
Encrypt a message using Paillier cryptosystem. | |
T_out | paillierEncryption (uint64_t n, uint64_t g, T_in m, uint64_t r) |
Encrypt a message using Paillier cryptosystem with a given random value. | |
T_in | paillierDecryption (uint64_t n, uint64_t lambda, uint64_t mu, T_out c) |
Decrypt a ciphertext using Paillier cryptosystem. | |
This class implements the Paillier cryptosystem.
T_in | The input data type. |
T_out | The output data type. |
|
inline |
Construct a new Paillier object.
Destroy the Paillier object.
|
inline |
Calculate the set of elements in (Z/n²Z)*.
This function calculates the set of elements in (Z/n²Z)* that are coprime to n.
uint64_t | n - The n parameter of public key. |
|
inline |
Calculate the set of elements in (Z/n²Z)* that satisfy the condition L(x) = (x-1)/n where x is a positive integer and mu exists.
This function calculates the set of elements in (Z/n²Z)* that satisfy the condition L(x) = (x-1)/n where x is a positive integer and mu exists.
uint64_t | n - The n parameter of public key. |
const | uint64_t &lambda - The lambda parameter of private key. |
|
inline |
Choose g from the set of elements in (Z/n²Z)* that satisfy the condition L(x) = (x-1)/n where x is a positive integer and mu exists.
This function chooses g from the set of elements in (Z/n²Z)* that satisfy the condition L(x) = (x-1)/n where x is a positive integer and mu exists.
std::vector<uint64_t> | &set - The set of elements in (Z/n²Z)* that satisfy the condition L(x) = (x-1)/n where x is a positive integer and mu exists. |
const | uint64_t &n - The n parameter of public key. |
const | uint64_t &lambda - The lambda parameter of private key. |
|
inline |
Choose g from the set of elements in (Z/n²Z)*.
This function chooses g from the set of elements in (Z/n²Z)*.
std::vector<uint64_t> | &set - The set of elements in (Z/n²Z)*. |
|
inline |
Calculate the modular exponentiation of a base raised to a power modulo a modulus.
This function calculates the modular exponentiation of a base raised to a power modulo a modulus using the square-and-multiply algorithm.
uint64_t | x - The base value. |
uint64_t | e - The exponent value. |
uint64_t | n - The n parameter of public key. |
|
inline |
Calculate the greatest common divisor (GCD) of two 64-bit unsigned integers.
This function calculates the greatest common divisor (GCD) of two 64-bit unsigned integers using the Euclidean algorithm.
uint64_t | a - The first integer. |
uint64_t | b - The second integer. |
|
inline |
Generate g for Paillier cryptosystem.
This function generates g for Paillier cryptosystem such that gcd(L(g^lambda mod n²), n) = 1 where L(u) = (u-1)/n. From program Paillier.java (https://perso.liris.cnrs.fr/omar.hasan/pprs/paillierdemo/) developped by Omar Hasan.
uint64_t | n - The n parameter of public key. |
uint64_t | lambda - The lambda parameter of private key. |
|
inline |
Generate Mu for Paillier cryptosystem.
This function generates Mu for Paillier cryptosystem which is used in the decryption process.
uint64_t | &mu - The generated value of Mu. |
const | uint64_t &g - The generator value. |
const | uint64_t &lambda - The Carmichael function of n. |
const | uint64_t &n - The modulus value. |
|
inline |
Generate private key for Paillier cryptosystem.
This function generates the private key for Paillier cryptosystem which consists of lambda and Mu values.
uint64_t | &lambda - The generated value of lambda. |
uint64_t | &mu - The generated value of Mu. |
const | uint64_t &p - The first prime factor of n. |
const | uint64_t &q - The second prime factor of n. |
const | uint64_t &n - The n parameter of public key. |
const | uint64_t &g - The generator value. |
|
inline |
Return the set Z/n²Z* that satisfy the condition gcd(L(g^lambda mod n²), n) = 1 as a vector.
This function returns the set Z/n²Z* that satisfy the condition gcd(L(g^lambda mod n²), n) = 1 as a vector.
uint64_t | n - The n parameter of public key. |
uint64_t | lambda - The lambda parameter of private key. |
|
inline |
Return the set Z/nZ* as a vector.
This function returns the set Z/nZ* as a vector.
uint64_t | n - The n parameter of public key. |
|
inline |
Calculate L(x).
This function calculates L(x) which is used in the generation of Mu and the decryption by Paillier.
uint64_t | x - The value of x. |
uint64_t | n - The n parameter of public key. |
|
inline |
Calculate the least common multiple (LCM) of two 64-bit unsigned integers.
This function calculates the least common multiple (LCM) of two 64-bit unsigned integers using the GCD function.
uint64_t | a - The first integer. |
uint64_t | b - The second integer. |
|
inline |
Calculate the modular inverse of a 64-bit unsigned integer modulo a modulus.
This function calculates the modular inverse of a 64-bit unsigned integer modulo a modulus using the extended Euclidean algorithm.
uint64_t | a - The integer to calculate the modular inverse of. |
uint64_t | n - The n parameter of public key. |
|
inline |
Decrypt a ciphertext using Paillier cryptosystem.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function decrypts a ciphertext using Paillier cryptosystem.
uint64_t | n - The modulus value. |
uint64_t | lambda - The Carmichael function of n. |
uint64_t | mu - The Mu value. |
T_out | c - The ciphertext to be decrypted. |
|
inline |
Encrypt a message using Paillier cryptosystem.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function encrypts a message using Paillier cryptosystem.
uint64_t | n - The modulus value. |
uint64_t | g - The generator value. |
T_in | m - The message to be encrypted. |
|
inline |
Encrypt a message using Paillier cryptosystem with a given random value.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function encrypts a message using Paillier cryptosystem with a given random value.
uint64_t | n - The modulus value. |
uint64_t | g - The generator value. |
T_in | m - The message to be encrypted. |
uint64_t | r - The random value. |
|
inline |
Calculate the power of a 64-bit unsigned integer.
This function calculates the power of a 64-bit unsigned integer using recursion.
uint64_t | x - The base value. |
uint64_t | n - The exponent value. |
|
inline |
Generate a random 64-bit unsigned integer.
This function generates a random 64-bit unsigned integer between a given range using the Mersenne Twister algorithm.
uint64_t | min - The minimum value of the range. |
uint64_t | max - The maximum value of the range. |
|
inline |
Choose a random element from the set Z/nZ*.
This function chooses a random element from the set Z/nZ*. From program Paillier.java (https://perso.liris.cnrs.fr/omar.hasan/pprs/paillierdemo/) developped by Omar Hasan.
uint64_t | n - The n parameter of public key. |
author Katia Auxilien