Code base obscuration (for images) 1.0
It implements different obscuration methods on portable images (.pgm and .ppm)
Loading...
Searching...
No Matches
PaillierController Class Reference

Superclass of Paillier main that contains common methods between subclasses. More...

#include <PaillierController.hpp>

Inheritance diagram for PaillierController:
Collaboration diagram for PaillierController:

Public Member Functions

PaillierModelgetModel ()
 Gets the model.
 
commandLineInterfacegetView ()
 Gets the view.
 
const char * getCKeyFile () const
 Gets the key file.
 
void setCKeyFile (char *newCKeyFile)
 Sets the key file.
 
void generateAndSaveKeyPair ()
 Generates and saves the key pair.
 
void readKeyFile (bool isEncryption)
 Reads the key file.
 

Protected Member Functions

bool endsWith (const std::string &str, const std::string &suffix)
 Checks if the given string ends with the specified suffix.
 
void convertToLower (char *arg_in[], int size_arg_in)
 Converts the given arguments to lower case.
 
bool isPrime (uint64_t n, uint64_t i=2)
 Checks if the given number is prime.
 
uint64_t check_p_q_arg (char *arg)
 Checks if the given argument is a prime number.
 
virtual void init ()
 Initializes the controller.
 
 PaillierController ()
 Constructor for PaillierController.
 
 ~PaillierController ()
 Destructor for PaillierController.
 

Protected Attributes

char * c_key_file
 Pointer to the key file.
 
PaillierModelmodel = PaillierModel::getInstance()
 Instance of PaillierModel.
 
commandLineInterfaceview = commandLineInterface::getInstance()
 Instance of commandLineInterface.
 

Detailed Description

Superclass of Paillier main that contains common methods between subclasses.

Author
Katia Auxilien
Date
28 May 2024, 13:48:00

Constructor & Destructor Documentation

◆ PaillierController()

PaillierController::PaillierController ( )
protected

Constructor for PaillierController.

This is the default constructor for PaillierController. It initializes the controller and its associated model and view.

Author
Katia Auxilien
Date
30 April 2024

◆ ~PaillierController()

PaillierController::~PaillierController ( )
protected

Destructor for PaillierController.

This is the destructor for PaillierController. It cleans up any resources allocated by the controller and its associated model and view.

Author
Katia Auxilien
Date
30 April 2024

Member Function Documentation

◆ check_p_q_arg()

uint64_t PaillierController::check_p_q_arg ( char * arg)
protected

Checks if the given argument is a prime number.

Verification of the argument in parameter, to see if it is indeed a number and if it is prime.

Parameters
char*arg The argument to check.
Author
Katia Auxilien
Date
30 April 2024
Returns
uint64_t The prime number if the argument is a prime number, 0 otherwise.

◆ convertToLower()

void PaillierController::convertToLower ( char * arg_in[],
int size_arg_in )
protected

Converts the given arguments to lower case.

Parameters
char*arg_in[] The arguments to convert.
intsize_arg_in The size of the arguments array.
Author
Katia Auxilien
Date
15 May 2024

◆ endsWith()

bool PaillierController::endsWith ( const std::string & str,
const std::string & suffix )
protected

Checks if the given string ends with the specified suffix.

Verification of the argument in parameter, to see if it is indeed a file name ending with .?.

Parameters
conststd::string &str The string to check.
conststd::string &suffix The suffix to check for.
Author
Katia Auxilien
Date
30 April 2024
Returns
bool True if the string ends with the suffix, false otherwise.

◆ generateAndSaveKeyPair()

void PaillierController::generateAndSaveKeyPair ( )

Generates and saves the key pair.

This function generates a new key pair and saves it to the key file associated with this controller.

Author
Katia Auxilien
Date
30 April 2024

◆ getCKeyFile()

const char * PaillierController::getCKeyFile ( ) const

Gets the key file.

This function returns the key file associated with this controller.

Author
Katia Auxilien
Date
30 April 2024
Returns
const char* The key file.

◆ getModel()

PaillierModel * PaillierController::getModel ( )
inline

Gets the model.

This function returns a pointer to the PaillierModel associated with this controller.

Author
Katia Auxilien
Date
30 April 2024
Returns
PaillierModel* The model.

◆ getView()

commandLineInterface * PaillierController::getView ( )
inline

Gets the view.

This function returns a pointer to the commandLineInterface associated with this controller.

Author
Katia Auxilien
Date
30 April 2024
Returns
commandLineInterface* The view.

◆ init()

virtual void PaillierController::init ( )
inlineprotectedvirtual

Initializes the controller.

This is a virtual function that can be overridden in derived classes to perform specific initialization tasks.

Author
Katia Auxilien
Date
30 April 2024

Reimplemented in PaillierControllerPGM, PaillierControllerStatG, and PaillierControllerStatR.

◆ isPrime()

bool PaillierController::isPrime ( uint64_t n,
uint64_t i = 2 )
protected

Checks if the given number is prime.

Parameters
uint64_tn The number to check.
uint64_ti The starting index for the check.
Author
Katia Auxilien
Date
30 April 2024
Returns
bool True if the number is prime, false otherwise.

◆ readKeyFile()

void PaillierController::readKeyFile ( bool isEncryption)

Reads the key file.

This function reads the key file associated with this controller and sets the model's public and private keys accordingly.

Author
Katia Auxilien
Date
30 April 2024
Parameters
boolisEncryption True if the key is for encryption, false otherwise.

◆ setCKeyFile()

void PaillierController::setCKeyFile ( char * newCKeyFile)

Sets the key file.

This function sets the key file associated with this controller.

Author
Katia Auxilien
Date
30 April 2024
Parameters
char*newCKeyFile The new key file.

Member Data Documentation

◆ c_key_file

char* PaillierController::c_key_file
protected

Pointer to the key file.

◆ model

PaillierModel* PaillierController::model = PaillierModel::getInstance()
protected

Instance of PaillierModel.

◆ view

commandLineInterface* PaillierController::view = commandLineInterface::getInstance()
protected

Instance of commandLineInterface.