ciphers.diffie

Attributes

prime

Functions

find_primitive(→ int | None)

Find a primitive root modulo modulus, if one exists.

Module Contents

ciphers.diffie.find_primitive(modulus: int) int | None

Find a primitive root modulo modulus, if one exists.

Args:

modulus : The modulus for which to find a primitive root.

Returns:

The primitive root if one exists, or None if there is none.

Examples: >>> find_primitive(7) # Modulo 7 has primitive root 3 3 >>> find_primitive(11) # Modulo 11 has primitive root 2 2 >>> find_primitive(8) == None # Modulo 8 has no primitive root True

ciphers.diffie.prime