xtrace_sdk.crypto.encryption.goldwasser_micali

Attributes

BIT_STRING_LENGTH

Classes

Goldwasser_Micali

A self implemented Goldwasser Micali encryption scheme

Module Contents

xtrace_sdk.crypto.encryption.goldwasser_micali.BIT_STRING_LENGTH = 1024
class xtrace_sdk.crypto.encryption.goldwasser_micali.Goldwasser_Micali(keys)

Bases: xtrace_sdk.crypto.encryption.homomorphic_base.HomomorphicBase[list[int], list[int], xtrace_sdk.utils.xtrace_types.GoldwasserMicaliKeyPair, xtrace_sdk.utils.xtrace_types.GoldwasserMicaliPublicKey]

A self implemented Goldwasser Micali encryption scheme

Parameters:

keys (xtrace_sdk.utils.xtrace_types.GoldwasserMicaliKeyPair)

keys
static key_gen(key_len)

Key generation routine for the Goldwasser_Micali crypto scheme.

Parameters:

key_len (int) – the number of bits in PK SK

Returns:

Goldwasser_Micali PK, SK pair

Return type:

Goldwasser_MicaliKeyPair

static generate_random_r(pk)

Helper function for encryption required by Goldwasser_Micali scheme

Parameters:

pk (GoldwasserMicaliPublicKey) – the public key

Returns:

a random r to be used for encryption.

Return type:

int

static encrypt(plaintext, pk)

Encryption with PK

Parameters:
  • plaintext (int) – the plaintext to be encrypted.

  • pk (GoldwasserMicaliPublicKey) – the public key to be used for encryption

Returns:

Goldwasser Micali cipher

Return type:

int

static decrypt(ciphertext, keys)

Decrypts a cihpher with Goldwasser Micali key pair and returns the plaintext

Parameters:
  • ciphertext (int) – cipher to be decrypted

  • keys (GoldwasserMicaliKeyPair) – pk,sk pair where sk is used to encrypt ct.

Returns:

plaintext

Return type:

int

static add(ciphertext1, ciphertext2, pk)
Abstractmethod:

Parameters:
  • ciphertext1 (list)

  • ciphertext2 (list)

  • pk (xtrace_sdk.utils.xtrace_types.GoldwasserMicaliPublicKey)

Return type:

list

Not supported for Goldwasser_Micali.

static multiply(ciphertext1, ciphertext2, pk)
Abstractmethod:

Parameters:
  • ciphertext1 (list)

  • ciphertext2 (list)

  • pk (xtrace_sdk.utils.xtrace_types.GoldwasserMicaliPublicKey)

Return type:

list

Not supported for Goldwasser_Micali.

static xor(ciphertext1, ciphertext2, pk)

Homomorphic xor of Goldwasser_Micali crypto system.

Parameters:
  • ciphertext1 (int) – one the ciphers to be xor’ed

  • ciphertext2 (int) – one the ciphers to be xor’ed

  • pk (GoldwasserMicaliPublicKey) – Pailier public key

Returns:

ciphertext3 such that decrypt(ct3,sk) = decrypt(ct1,sk) [xor] decrypt(ct2,sk)

Return type:

int

static L(x, n)

Helper method for decryption

Parameters:
Return type:

int