diff --git a/src/sage/crypto/cryptosystem.py b/src/sage/crypto/cryptosystem.py index 33cc87cf08e..488b9a014b5 100644 --- a/src/sage/crypto/cryptosystem.py +++ b/src/sage/crypto/cryptosystem.py @@ -5,7 +5,9 @@ This module contains base classes for various cryptosystems, including symmetric key and public-key cryptosystems. The classes defined in this module should not be called directly. It is the responsibility of child -classes to implement specific cryptosystems. Take for example the +classes to implement specific cryptosystems. + +Take for example the Hill or matrix cryptosystem as implemented in :class:`HillCryptosystem `. It is a symmetric key cipher so @@ -27,22 +29,21 @@ class of | + VigenereCryptosystem + PublicKeyCryptosystem """ - -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2007 David Kohel # # Distributed under the terms of the GNU General Public License (GPL) # -# http://www.gnu.org/licenses/ -#***************************************************************************** - -import sage.structure.parent_old as parent_old +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.sets.set import Set_generic -class Cryptosystem(parent_old.Parent, Set_generic): + +class Cryptosystem(Set_generic): r""" A base cryptosystem class. This is meant to be extended by other specialized child classes that implement specific cryptosystems. + A cryptosystem is a pair of maps .. MATH:: @@ -143,7 +144,9 @@ def __init__(self, plaintext_space, ciphertext_space, key_space, def __eq__(self, right): r""" - Comparing ``self`` with ``right``. Two ``Cryptosystem`` objects + Comparing ``self`` with ``right``. + + Two ``Cryptosystem`` objects are the same if they satisfy all of these conditions: - share the same type @@ -323,7 +326,9 @@ def key_space(self): def block_length(self): r""" - Return the block length of this cryptosystem. For some cryptosystems + Return the block length of this cryptosystem. + + For some cryptosystems this is not relevant, in which case the block length defaults to 1. EXAMPLES: @@ -348,6 +353,7 @@ def period(self): raise TypeError("Argument has no associated period.") return self._period + class SymmetricKeyCryptosystem(Cryptosystem): r""" The base class for symmetric key, or secret key, cryptosystems. @@ -373,6 +379,7 @@ def alphabet_size(self): """ return self._cipher_domain.ngens() + class PublicKeyCryptosystem(Cryptosystem): r""" The base class for asymmetric or public-key cryptosystems.