# Ticket #6139: trac_6139-reviewer.patch

File trac_6139-reviewer.patch, 2.5 KB (added by mvngu, 11 years ago)
• ## sage/crypto/mq/sbox.py

```# HG changeset patch
# User Minh Van Nguyen <nguyenminh2@gmail.com>
# Date 1244063741 25200
# Node ID 689dd263587e61791ba6eecd8cdcf808921dae94
# Parent  bd947776c71906b6235ea36126c5d32d27d2cfdc
trac 6139: reviewer patch

diff -r bd947776c719 -r 689dd263587e sage/crypto/mq/sbox.py```
 a r""" S-Boxes and Their Algebraic Representations. S-Boxes and Their Algebraic Representations """ from sage.combinat.integer_vector import IntegerVectors Note that by default bits are interpreted in big endian order. This is not consistent with the rest of Sage, which has a strong bias towards little endian, but is consistent with most cryptographic literature.:: cryptographic literature:: sage: S([0,0,0,1]) [0, 1, 0, 1] """ Apply substitution to ``X``. If X is a list, it is interpreted as a sequence of bits If ``X`` is a list, it is interpreted as a sequence of bits depending on the bit order of this S-box. INPUT:: INPUT: - ``X`` - either an integer, a tuple of `\GF{2}` elements of length ``len(self)`` or a finite field element in The rows of ``A`` encode the differences ``Delta I`` of the input and the columns encode the difference ``Delta O`` for the output. The bits are ordered according to the endianess of this S-box. The value at ``A[Delta I,Delta O]`` encoded how this S-box. The value at ``A[Delta I,Delta O]`` encodes how often ``Delta O`` is the actual output difference given ``Delta I`` as input difference. [ 0 -2  2  0 -2  0  0 -2] According to this matrix the first bit of the input is equal to the third bit of the output 6 out of 8 times.:: to the third bit of the output 6 out of 8 times:: sage: for i in srange(8): print S.to_bits(i) == S.to_bits(S(i)) False We can get a direct representation by computing a lexicographical Groebner basis with respect to the right variable ordering, i.e. a variable orderings where the output variable ordering, i.e. a variable ordering where the output bits are greater than the input bits:: sage: P. = PolynomialRing(GF(2),6,order='lex')
{"ft_lang_label":"__label__en","ft_lang_prob":0.63045603,"math_prob":0.8358506,"size":2541,"snap":"2020-24-2020-29","text_gpt3_token_len":839,"char_repetition_ratio":0.08908159,"word_repetition_ratio":0.08558559,"special_character_ratio":0.45336482,"punctuation_ratio":0.12224449,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97693104,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-06-04T06:03:57Z\",\"WARC-Record-ID\":\"<urn:uuid:10ca6359-8396-41eb-898b-e00165f6d2a2>\",\"Content-Length\":\"19477\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:1faa8ab5-4f79-4838-a8e2-df95ca29ca0e>\",\"WARC-Concurrent-To\":\"<urn:uuid:3c30f7ef-9e0e-47c9-9eee-409f37ce34a0>\",\"WARC-IP-Address\":\"104.197.143.230\",\"WARC-Target-URI\":\"https://trac.sagemath.org/attachment/ticket/6139/trac_6139-reviewer.patch\",\"WARC-Payload-Digest\":\"sha1:PBP5CUSTYA2BFQJXZACYCNQRQKJ6U6N4\",\"WARC-Block-Digest\":\"sha1:USSE2QNDJOWBMUDB27VG4FFD2CPP2STV\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347439019.86_warc_CC-MAIN-20200604032435-20200604062435-00476.warc.gz\"}"}