5
5
This module contains base classes for various cryptosystems, including
6
6
symmetric key and public-key cryptosystems. The classes defined in this
7
7
module should not be called directly. It is the responsibility of child
8
- classes to implement specific cryptosystems. Take for example the
8
+ classes to implement specific cryptosystems.
9
+
10
+ Take for example the
9
11
Hill or matrix cryptosystem as implemented in
10
12
:class:`HillCryptosystem <sage.crypto.classical.HillCryptosystem>`. It is a
11
13
symmetric key cipher so
@@ -27,22 +29,21 @@ class of
27
29
| + VigenereCryptosystem
28
30
+ PublicKeyCryptosystem
29
31
"""
30
-
31
- #*****************************************************************************
32
+ # ****************************************************************************
32
33
# Copyright (C) 2007 David Kohel <[email protected] >
33
34
#
34
35
# Distributed under the terms of the GNU General Public License (GPL)
35
36
#
36
- # http://www.gnu.org/licenses/
37
- #*****************************************************************************
38
-
39
- import sage .structure .parent_old as parent_old
37
+ # https://www.gnu.org/licenses/
38
+ # ****************************************************************************
40
39
from sage .sets .set import Set_generic
41
40
42
- class Cryptosystem (parent_old .Parent , Set_generic ):
41
+
42
+ class Cryptosystem (Set_generic ):
43
43
r"""
44
44
A base cryptosystem class. This is meant to be extended by other
45
45
specialized child classes that implement specific cryptosystems.
46
+
46
47
A cryptosystem is a pair of maps
47
48
48
49
.. MATH::
@@ -143,7 +144,9 @@ def __init__(self, plaintext_space, ciphertext_space, key_space,
143
144
144
145
def __eq__ (self , right ):
145
146
r"""
146
- Comparing ``self`` with ``right``. Two ``Cryptosystem`` objects
147
+ Comparing ``self`` with ``right``.
148
+
149
+ Two ``Cryptosystem`` objects
147
150
are the same if they satisfy all of these conditions:
148
151
149
152
- share the same type
@@ -323,7 +326,9 @@ def key_space(self):
323
326
324
327
def block_length (self ):
325
328
r"""
326
- Return the block length of this cryptosystem. For some cryptosystems
329
+ Return the block length of this cryptosystem.
330
+
331
+ For some cryptosystems
327
332
this is not relevant, in which case the block length defaults to 1.
328
333
329
334
EXAMPLES:
@@ -348,6 +353,7 @@ def period(self):
348
353
raise TypeError ("Argument has no associated period." )
349
354
return self ._period
350
355
356
+
351
357
class SymmetricKeyCryptosystem (Cryptosystem ):
352
358
r"""
353
359
The base class for symmetric key, or secret key, cryptosystems.
@@ -373,6 +379,7 @@ def alphabet_size(self):
373
379
"""
374
380
return self ._cipher_domain .ngens ()
375
381
382
+
376
383
class PublicKeyCryptosystem (Cryptosystem ):
377
384
r"""
378
385
The base class for asymmetric or public-key cryptosystems.
0 commit comments