# module 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 ». See Homomorphic encryption. …

## 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 . …

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)

Bases : object

Implements an « homomorphic integer ». See Homomorphic encryption.

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)

Addition.

source on GitHub

__div__(o)

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

source on GitHub

__init__(value, p=673, q=821, e=None)
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)

Multiplication.

source on GitHub

__pow__(n)

Power operator.

source on GitHub

__repr__()

Usual

source on GitHub

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

Soustraction.

source on GitHub

crypt_add()

Simple permutation.

source on GitHub

crypt_mult()

Crypt a number and preserve multiplication. We use RSA.

source on GitHub

decrypt_add()

Decrypt a number and preserve multiplication.

source on GitHub

decrypt_mult()

Decrypt a number and preserve multiplication.

source on GitHub

static find_e(p, q)

Finds one exposant for the RSA encryption.

source on GitHub

inv()

Inversion. This only works in all cases if n is a prime number. We use . The implementation can be improved (use binary decomposition) and cached.

source on GitHub

static lcm(a, b)

Computes the least common multiple (PPCM).

source on GitHub

new_int(v)

Returns a HomomorphicInt with the same encrypted parameters.

source on GitHub

static pgcd(a, b)

Computes the PGCD.

source on GitHub