xtrace_sdk.crypto.encryption.paillier
Classes
A self implemented paillier encryption scheme |
Module Contents
- class xtrace_sdk.crypto.encryption.paillier.Paillier(keys)
Bases:
xtrace_sdk.crypto.encryption.homomorphic_base.HomomorphicBase[gmpy2.mpz,gmpy2.mpz,xtrace_sdk.utils.xtrace_types.PaillierKeyPair,xtrace_sdk.utils.xtrace_types.PaillierPublicKey]A self implemented paillier encryption scheme
- Parameters:
keys (xtrace_sdk.utils.xtrace_types.PaillierKeyPair)
- keys
- static key_gen(key_len)
Key generation routine for the Paillier crypto scheme.
- Parameters:
key_len (int) – the number of bits in PK SK
- Returns:
Paillier PK, SK pair
- Return type:
PaillierKeyPair
- static generate_random_r(pk)
Helper function for encryption required by Paillier scheme
- Parameters:
pk (PaillierPublicKey) – the public key
- Returns:
a random r to be used for encryption.
- Return type:
gmpy2.mpz
- static encrypt(plaintext, pk)
Encryption with PK
- Parameters:
plaintext (gmpy2.mpz) – the plaintext to be encrypted.
pk (PaillierPublicKey) – the public key to be used for encryption
- Returns:
Paillier cipher
- Return type:
gmpy2.mpz
- static decrypt(ciphertext, keys)
Decrypts a cihpher with paillier key pair and returns the plaintext
- Parameters:
ciphertext (gmpy2.mpz) – cipher to be decrypted
keys (PaillierKeyPair) – pk,sk pair where sk is used to encrypt ct.
- Returns:
plaintext
- Return type:
gmpy2.mpz
- static add(ciphertext1, ciphertext2, pk)
Homomorphic addition of Paillier crypto system.
- static multiply(ciphertext1, ciphertext2, pk)
- Abstractmethod:
- Parameters:
ciphertext1 (gmpy2.mpz)
ciphertext2 (gmpy2.mpz)
pk (xtrace_sdk.utils.xtrace_types.PaillierPublicKey)
- Return type:
gmpy2.mpz
Not supported for Paillier.
- static xor(ciphertext1, ciphertext2, pk)
- Abstractmethod:
- Parameters:
ciphertext1 (gmpy2.mpz)
ciphertext2 (gmpy2.mpz)
pk (xtrace_sdk.utils.xtrace_types.PaillierPublicKey)
- Return type:
gmpy2.mpz
Not supported for Paillier.