xtrace_sdk.crypto.encryption.paillier_lookup
Attributes
Classes
A self implemented paillier encryption scheme |
Module Contents
- xtrace_sdk.crypto.encryption.paillier_lookup.MSG_BITS = 8
- xtrace_sdk.crypto.encryption.paillier_lookup.NOISE_TABLE_SIZE = 256
- xtrace_sdk.crypto.encryption.paillier_lookup.NOISE_MULTIPLES = 14
- class xtrace_sdk.crypto.encryption.paillier_lookup.Paillier_Lookup(keys)
Bases:
xtrace_sdk.crypto.encryption.homomorphic_base.HomomorphicBase[int,int,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, alpha_len)
Key generation routine for the Paillier crypto scheme.
- static precompute_g_table(g, n, key_len, msg_bits=MSG_BITS)
- static precompute_noise_table(g, n, size=NOISE_TABLE_SIZE)
- static gen_dsa_params_custom(p_bits, q_bits)
1024-bit DSA => q is 160-bit (FIPS 186-4).
- 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:
- static encrypt(plaintext, pk, g_table=None, noise_table=None, message_chunks=0)
Encryption with PK
- static decrypt(ciphertext, keys)
Decrypts a cihpher with paillier key pair and returns the plaintext
- static add(ciphertext1, ciphertext2, pk)
Homomorphic addition of Paillier crypto system.
- static multiply(ciphertext1, ciphertext2, pk)
- Abstractmethod:
- Parameters:
- Return type:
Not supported for Paillier.
- static xor(ciphertext1, ciphertext2, pk)
- Abstractmethod:
- Parameters:
- Return type:
Not supported for Paillier.
- static bitlen(x)
Helper method to get bit length of gmpy mpz integers
- Parameters:
x (gmpy2.mpz)
- Return type:
- static crt_pair(a1, m1, a2, m2)
Helper method for Chinsese Remainder Theorem
- Parameters:
a1 (gmpy2.mpz)
m1 (gmpy2.mpz)
a2 (gmpy2.mpz)
m2 (gmpy2.mpz)
- Return type:
tuple[gmpy2.mpz, gmpy2.mpz]
- static lift_to_p2_with_p_component(g_mod_p, p)
Multiply by (1+p) to inject an order-p component in Z_{p^2}*
- Parameters:
g_mod_p (gmpy2.mpz)
p (gmpy2.mpz)
- Return type:
gmpy2.mpz