module td_2a.homomorphic

Inheritance diagram of ensae_teaching_cs.td_2a.homomorphic

Short summary

module ensae_teaching_cs.td_2a.homomorphic

Implements « homomorphic number ».

source on GitHub

Classes

class truncated documentation
HomomorphicInt Implements an « homomorphic integer ».

Static Methods

staticmethod truncated documentation
find_e Finds one exposant for the RSA encryption.
lcm Computes the least common multiple (PPCM).
pgcd Computes the PGCD.

Methods

method truncated documentation
__add__ Addition.
__div__ Division, implies to find the inverse (so very costly).
__init__  
__mul__ Multiplication.
__pow__ Power operator.
__repr__ Usual
__sub__ Soustraction.
crypt_add Simple permutation.
crypt_mult Crypt a number and preserve multiplication. We use RSA.
decrypt_add Decrypt a number and preserve multiplication.
decrypt_mult Decrypt a number and preserve multiplication.
inv Inversion. This only works in all cases if n is a prime number. We use a^{-1} \equiv a^{n-2} \mod n. …
new_int Returns a HomomorphicInt with the same encrypted parameters.

Documentation

Implements « homomorphic number ».

source on GitHub

class ensae_teaching_cs.td_2a.homomorphic.HomomorphicInt(value, p=673, q=821, e=None)[source]

Bases : object

Implements an « homomorphic integer ».

source on GitHub

Paramètres:
  • value – initial value
  • p – p for RSA
  • q – q for RSA
  • e – e for RSA (e, and inverse e)

Other prime numbers can be found at The First 100,008 Primes.

source on GitHub

__add__(o)[source]

Addition.

source on GitHub

__div__(o)[source]

Division, implies to find the inverse (so very costly).

source on GitHub

__init__(value, p=673, q=821, e=None)[source]
Paramètres:
  • value – initial value
  • p – p for RSA
  • q – q for RSA
  • e – e for RSA (e, and inverse e)

Other prime numbers can be found at The First 100,008 Primes.

source on GitHub

__mul__(o)[source]

Multiplication.

source on GitHub

__pow__(n)[source]

Power operator.

source on GitHub

__repr__()[source]

Usual

source on GitHub

__slots__ = ['V', 'N', 'P', 'Q', 'E']
__sub__(o)[source]

Soustraction.

source on GitHub

crypt_add()[source]

Simple permutation.

source on GitHub

crypt_mult()[source]

Crypt a number and preserve multiplication. We use RSA.

source on GitHub

decrypt_add()[source]

Decrypt a number and preserve multiplication.

source on GitHub

decrypt_mult()[source]

Decrypt a number and preserve multiplication.

source on GitHub

static find_e(p, q)[source]

Finds one exposant for the RSA encryption.

source on GitHub

inv()[source]

Inversion. This only works in all cases if n is a prime number. We use a^{-1} \equiv a^{n-2} \mod n. The implementation can be improved (use binary decomposition) and cached.

source on GitHub

static lcm(a, b)[source]

Computes the least common multiple (PPCM).

source on GitHub

new_int(v)[source]

Returns a HomomorphicInt with the same encrypted parameters.

source on GitHub

static pgcd(a, b)[source]

Computes the PGCD.

source on GitHub