Skip to content

Commit 59c59ee

Browse files
authored
Updated docstrings and included doctests
1 parent e594552 commit 59c59ee

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/sage/crypto/sbox.pyx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,54 @@ cdef class SBox(SageObject):
638638
[0 0 2 2 2 2 0 0]
639639
[0 2 2 0 0 2 2 0]
640640
[0 0 0 0 2 2 2 2]
641+
sage: S = SBox(7,4,8,6)
642+
sage: S.difference_distribution_table()
643+
[4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
644+
[0 0 0 2 0 0 0 0 0 0 0 0 0 0 2 0]
645+
[0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 2]
646+
[0 2 0 0 0 0 0 0 0 0 0 0 2 0 0 0]
647+
648+
TESTS::
649+
650+
Testing square SBoxes::
651+
652+
sage: from sage.crypto.sbox import SBox
653+
sage: S = SBox(7,6,0,4,2,5,1,3)
654+
sage: S.difference_distribution_table()
655+
[8 0 0 0 0 0 0 0]
656+
[0 2 2 0 2 0 0 2]
657+
[0 0 2 2 0 0 2 2]
658+
[0 2 0 2 2 0 2 0]
659+
[0 2 0 2 0 2 0 2]
660+
[0 0 2 2 2 2 0 0]
661+
[0 2 2 0 0 2 2 0]
662+
[0 0 0 0 2 2 2 2]
663+
664+
Testing non-square SBoxes::
665+
666+
sage: from sage.crypto.sbox import SBox
667+
sage: S = SBox(8,8,8,8)
668+
sage: S.difference_distribution_table()
669+
[4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
670+
[4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
671+
[4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
672+
[4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
673+
sage: S = SBox(7,4,8,6)
674+
sage: S.difference_distribution_table()
675+
[4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
676+
[0 0 0 2 0 0 0 0 0 0 0 0 0 0 2 0]
677+
[0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 2]
678+
[0 2 0 0 0 0 0 0 0 0 0 0 2 0 0 0]
679+
sage: S = SBox(0,0,0,1,0,0,1,3)
680+
sage: S.difference_distribution_table()
681+
[8 0 0 0]
682+
[4 2 2 0]
683+
[2 4 0 2]
684+
[2 4 0 2]
685+
[4 2 2 0]
686+
[6 0 0 2]
687+
[2 4 0 2]
688+
[2 4 0 2]
641689
"""
642690
cdef Py_ssize_t nrows = 1 << self.m
643691
cdef Py_ssize_t ncols = 1 << self.n

0 commit comments

Comments
 (0)