Skip to content

Commit 2d897bb

Browse files
author
Matthias Koeppe
committed
sage.crypto: More block tags, fixup
1 parent d256d96 commit 2d897bb

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/sage/crypto/classical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ def block_length(self):
14351435
return self.key_space().nrows()
14361436

14371437
def random_key(self):
1438-
"""
1438+
r"""
14391439
A random key within the key space of this Hill cipher. That is,
14401440
generate a random `m \times m` matrix to be used as a block
14411441
permutation, where `m` is the block length of this Hill cipher. If

src/sage/crypto/classical_cipher.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,27 +470,29 @@ def __init__(self, parent, key):
470470
471471
EXAMPLES::
472472
473+
sage: # needs sage.groups
473474
sage: S = AlphabeticStrings()
474-
sage: E = TranspositionCryptosystem(S,14); E # needs sage.groups
475+
sage: E = TranspositionCryptosystem(S,14); E
475476
Transposition cryptosystem on
476477
Free alphabetic string monoid on A-Z of block length 14
477478
sage: K = [ 14-i for i in range(14) ]; K
478479
[14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
479-
sage: e = E(K) # needs sage.groups
480+
sage: e = E(K)
480481
sage: m = S("THECATINTHEHAT")
481-
sage: e(m) # needs sage.groups
482+
sage: e(m)
482483
TAHEHTNITACEHT
483484
484485
EXAMPLES::
485486
487+
sage: # needs sage.groups
486488
sage: S = AlphabeticStrings()
487-
sage: E = TranspositionCryptosystem(S,15) # needs sage.groups
489+
sage: E = TranspositionCryptosystem(S,15)
488490
sage: m = S("THECATANDTHEHAT")
489-
sage: G = E.key_space(); G # needs sage.groups
491+
sage: G = E.key_space(); G
490492
Symmetric group of order 15! as a permutation group
491-
sage: g = G([ 3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13 ]) # needs sage.groups
492-
sage: e = E(g) # needs sage.groups
493-
sage: e(m) # needs sage.groups
493+
sage: g = G([ 3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13 ])
494+
sage: e = E(g)
495+
sage: e(m)
494496
EHTTACDNAEHTTAH
495497
496498
TESTS::

src/sage/crypto/lwe.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ def __init__(self, n, q, D, secret_dist='uniform', m=None):
297297
fix the representation and recover the correct standard deviation of the
298298
noise::
299299
300-
sage: from numpy import std # optional - numpy
301-
sage: while abs(std([e if e <= 200 else e-401 for e in S()]) - 3.0) > 0.01: # optional - numpy
300+
sage: from numpy import std # needs numpy
301+
sage: while abs(std([e if e <= 200 else e-401 for e in S()]) - 3.0) > 0.01: # needs numpy
302302
....: L = [] # reset L to avoid quadratic behaviour
303303
....: add_samples()
304304
@@ -591,12 +591,12 @@ def __call__(self):
591591
sage: # needs sage.libs.pari
592592
sage: from sage.crypto.lwe import DiscreteGaussianDistributionPolynomialSampler, RingLWE
593593
sage: N = 16
594-
sage: n = euler_phi(N) # needs sage.libs.pari
595-
sage: D = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], n, 5) # needs sage.libs.pari
596-
sage: ringlwe = RingLWE(N, 257, D, secret_dist='uniform') # needs sage.libs.pari
597-
sage: ringlwe()[0].parent() # needs sage.libs.pari
594+
sage: n = euler_phi(N)
595+
sage: D = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], n, 5)
596+
sage: ringlwe = RingLWE(N, 257, D, secret_dist='uniform')
597+
sage: ringlwe()[0].parent()
598598
Vector space of dimension 8 over Ring of integers modulo 257
599-
sage: ringlwe()[1].parent() # needs sage.libs.pari
599+
sage: ringlwe()[1].parent()
600600
Vector space of dimension 8 over Ring of integers modulo 257
601601
"""
602602
if self.m is not None:

src/sage/crypto/mq/rijndael_gf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
272272
sage: # needs sage.libs.gap
273273
sage: rcpc = rgf.compose(rgf.shift_rows_poly_constr(),
274-
....: rgf.mix_columns_poly_constr()); rcpc # needs sage.libs.gap
274+
....: rgf.mix_columns_poly_constr()); rcpc
275275
A polynomial constructor of a round component of Rijndael-GF block cipher
276276
with block length 4, key length 6, and 12 rounds.
277277
sage: rcpc(2, 1)

0 commit comments

Comments
 (0)