java.lang.Object
edu.fiu.adwise.homomorphic_encryption.socialistmillionaire.socialist_millionaires
edu.fiu.adwise.homomorphic_encryption.socialistmillionaire.bob
All Implemented Interfaces:
CipherConstants, bob_interface
Direct Known Subclasses:
bob_joye, bob_veugen

public class bob extends socialist_millionaires implements bob_interface
The bob class represents Bob in the Socialist Millionaire's Problem. It implements the bob_interface and extends socialist_millionaires. This class provides methods for secure equality testing and other cryptographic operations using homomorphic encryption techniques.

This specific class implements the first generation of encrypted comparison protocols

  • Constructor Details

    • bob

      public bob(KeyPair first, KeyPair second, KeyPair third)
      Constructs a Bob instance with three key pairs.
      Parameters:
      first - the first key pair (Paillier or DGK).
      second - the second key pair (DGK or Paillier).
      third - the third key pair (ElGamal), optional.
    • bob

      public bob(KeyPair first, KeyPair second)
      Constructs a Bob instance with two key pairs.
      Parameters:
      first - the first key pair (Paillier or DGK).
      second - the second key pair (DGK or Paillier).
  • Method Details

    • set_socket

      public void set_socket(Socket socket) throws IOException
      Sets the socket for communication with Alice.
      Specified by:
      set_socket in interface bob_interface
      Parameters:
      socket - the socket to use for communication.
      Throws:
      IOException - if an I/O error occurs.
      NullPointerException - if the provided socket is null.
    • sort

      Sorts a list of encrypted numbers using Protocol 2. This method repeatedly invokes Protocol 2 until the sorting is complete.
      Specified by:
      sort in interface bob_interface
      Throws:
      IOException - if an I/O error occurs.
      ClassNotFoundException - if a class cannot be found during deserialization.
      HomomorphicException - if an error occurs during homomorphic operations.
    • encrypted_equals

      public void encrypted_equals() throws IOException, HomomorphicException, ClassNotFoundException
      . Review "Protocol 1 EQT-1" from the paper "Secure Equality Testing Protocols in the Two-Party Setting"
      Specified by:
      encrypted_equals in interface bob_interface
      Throws:
      IOException - if an I/O error occurs.
      HomomorphicException - if an error occurs during homomorphic operations.
      ClassNotFoundException - if a class cannot be found during deserialization.
    • encrypt_bits

      public BigInteger[] encrypt_bits(BigInteger y) throws HomomorphicException
      Encrypts the bits of a given plaintext value.
      Parameters:
      y - the plaintext value to encrypt.
      Returns:
      an array of encrypted bits.
      Throws:
      HomomorphicException - if an error occurs during homomorphic operations.
    • compute_delta_b

      public int compute_delta_b(BigInteger[] C) throws HomomorphicException
      Computes the delta value (deltaB) for Bob based on the decrypted values in C.
      Parameters:
      C - the array of encrypted values.
      Returns:
      the computed delta value (deltaB).
      Throws:
      HomomorphicException - if an error occurs during homomorphic operations.
    • Protocol1

      Please review "Improving the DGK comparison protocol" - Protocol 1 Nicely enough; this is the same thing Bob needs to do for Veugen, Joye and checking if two encrypted numbers are equal! This is the original protocol from DGK, the improved versions are in alice_veugen. This protocol allows Bob to securely compare encrypted values with Alice and determine equality without revealing the plaintext values.
      Specified by:
      Protocol1 in interface bob_interface
      Parameters:
      y - the plaintext value to compare.
      Returns:
      true if the comparison result indicates equality, false otherwise.
      Throws:
      IOException - if an I/O error occurs during communication.
      ClassNotFoundException - if a class cannot be found during deserialization.
      IllegalArgumentException - if y has more bits than supported by the DGK keys.
      HomomorphicException - if an error occurs during homomorphic operations.
    • Protocol2

      public boolean Protocol2() throws ClassNotFoundException, IOException, HomomorphicException
      Please review "Improving the DGK comparison protocol" - Protocol 2 Executes Protocol 2 for secure comparison. This protocol allows Bob to securely compare encrypted values with Alice. This uses the original comparison protocol from DGK, the improved versions are in alice_veugen and alice_joye.
      Specified by:
      Protocol2 in interface bob_interface
      Returns:
      true if the comparison result indicates x >= y, false otherwise.
      Throws:
      IOException - if an I/O error occurs during communication.
      ClassNotFoundException - if a class cannot be found during deserialization.
      HomomorphicException - if an error occurs during homomorphic operations.
    • multiplication

      public void multiplication() throws IOException, ClassNotFoundException, HomomorphicException
      See the paper "Correction of a Secure Comparison Protocol for Encrypted Integers in IEEE WIFS 2012 (Short Paper)" This performs secure multiplication of two encrypted values. This method decrypts the values, performs multiplication, and re-encrypts the result, but the results are blinded by Alice, so Bob should not be aware what the actual product is.
      Specified by:
      multiplication in interface bob_interface
      Throws:
      IOException - if an I/O error occurs during communication.
      ClassNotFoundException - if a class cannot be found during deserialization.
      HomomorphicException - if an error occurs during homomorphic operations.
    • division

      public void division(long divisor) throws ClassNotFoundException, IOException, HomomorphicException
      Please review Protocol 2 in the "Encrypted Integer Division" paper by Thjis Veugen Performs secure division of an encrypted value received from Alice by a given divisor. The result is encrypted and sent back to Alice. Bob does not learn the plaintext result.
      Specified by:
      division in interface bob_interface
      Parameters:
      divisor - the divisor to divide the encrypted value by.
      Throws:
      ClassNotFoundException - if a class cannot be found during deserialization.
      IOException - if an I/O error occurs during communication.
      HomomorphicException - if an error occurs during homomorphic operations.
      IllegalArgumentException - if the received object is not a BigInteger.
    • sendPublicKeys

      public void sendPublicKeys() throws IOException
      Sends Bob's public keys (DGK, Paillier, and ElGamal) to Alice. If a key is not available, a placeholder value of BigInteger.ZERO is sent instead.
      Specified by:
      sendPublicKeys in interface bob_interface
      Throws:
      IOException - if an I/O error occurs during communication.