java.lang.Object
edu.fiu.adwise.homomorphic_encryption.gm.GMCipher
All Implemented Interfaces:
CipherConstants

public class GMCipher extends Object implements CipherConstants
This class implements the Goldwasser-Micali (GM) encryption scheme. It provides methods for encrypting, decrypting, and performing XOR operations on encrypted bits using the GM cryptosystem.
  • Constructor Details

    • GMCipher

      public GMCipher()
  • Method Details

    • encrypt

      public static BigInteger[] encrypt(BigInteger message, GMPublicKey public_key)
      Encrypts a BigInteger plaintext using the Goldwasser-Micali encryption scheme.
      Parameters:
      message - The plaintext message to be encrypted.
      public_key - The public key used for encryption.
      Returns:
      An array of BigInteger representing the encrypted bits.
    • decrypt

      public static BigInteger decrypt(BigInteger[] cipher, GMPrivateKey private_key)
      Decrypts an array of Goldwasser-Micali encrypted bits.
      Parameters:
      cipher - The array of encrypted bits to be decrypted.
      private_key - The private key used for decryption.
      Returns:
      The decrypted plaintext as a BigInteger.
    • xor

      public static BigInteger[] xor(BigInteger[] cipher_1, BigInteger[] cipher_2, GMPublicKey public_key) throws HomomorphicException
      Performs a bitwise XOR operation on two arrays of Goldwasser-Micali encrypted bits.
      Parameters:
      cipher_1 - The first array of encrypted bits.
      cipher_2 - The second array of encrypted bits.
      public_key - The public key used for encryption.
      Returns:
      An array of BigInteger representing the XORed encrypted bits.
      Throws:
      HomomorphicException - If the lengths of the two ciphertext arrays are not equal.