Algebraic model

class AlgebraicModel(cipher)

Bases: object

connection_polynomials()

Return a list of polynomials that connects system of equations from each component.

INPUT:

  • None

EXAMPLES:

sage: from claasp.ciphers.toys.fancy_block_cipher import FancyBlockCipher
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: fancy = FancyBlockCipher(number_of_rounds=1)
sage: connection = AlgebraicModel(fancy).connection_polynomials()
sage: connection[:24]
[plaintext_y0 + sbox_0_0_x0,
 plaintext_y1 + sbox_0_0_x1,
 plaintext_y2 + sbox_0_0_x2,
 ...
 plaintext_y21 + sbox_0_5_x1,
 plaintext_y22 + sbox_0_5_x2,
 plaintext_y23 + sbox_0_5_x3]
connection_polynomials_at_round(r)

Return a list of connection polynomials at round r.

INPUT:

  • rinteger

EXAMPLES:

sage: from claasp.ciphers.toys.fancy_block_cipher import FancyBlockCipher
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: fancy = FancyBlockCipher(number_of_rounds=1)
sage: connection = AlgebraicModel(fancy).connection_polynomials_at_round(0)
sage: connection[:24]
[plaintext_y0 + sbox_0_0_x0,
 plaintext_y1 + sbox_0_0_x1,
 plaintext_y2 + sbox_0_0_x2,
 ...
 plaintext_y21 + sbox_0_5_x1,
 plaintext_y22 + sbox_0_5_x2,
 plaintext_y23 + sbox_0_5_x3]
is_algebraically_secure(timeout)

Return True if the cipher is resistant against algebraic attack.

INPUT:

  • timeoutinteger; the timeout for the Groebner basis computation in seconds

EXAMPLES:

sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: from claasp.ciphers.toys.toyspn1 import ToySPN1
sage: toyspn = ToySPN1()
sage: algebraic = AlgebraicModel(toyspn)
sage: algebraic.is_algebraically_secure(30)
False
nvars()

Return the number of variables.

INPUT:

  • None

EXAMPLES:

sage: from claasp.ciphers.toys.fancy_block_cipher import FancyBlockCipher
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: fancy = FancyBlockCipher(number_of_rounds=1)
sage: AlgebraicModel(fancy).nvars()
96
polynomial_system()

Return a polynomial system for the cipher.

INPUT:

  • None

EXAMPLES:

sage: from claasp.ciphers.toys.toyspn1 import ToySPN1
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: toyspn = ToySPN1()
sage: AlgebraicModel(toyspn).polynomial_system()
Polynomial Sequence with 74 Polynomials in 42 Variables

sage: from claasp.ciphers.toys.fancy_block_cipher import FancyBlockCipher
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: fancy = FancyBlockCipher(number_of_rounds=1)
sage: AlgebraicModel(fancy).polynomial_system()
Polynomial Sequence with 228 Polynomials in 144 Variables

sage: from claasp.ciphers.block_ciphers.speck_block_cipher import SpeckBlockCipher
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: speck = SpeckBlockCipher(number_of_rounds=2)
sage: AlgebraicModel(speck).polynomial_system()
Polynomial Sequence with 192 Polynomials in 256 Variables

sage: from claasp.ciphers.block_ciphers.aes_block_cipher import AESBlockCipher
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: aes = AESBlockCipher(word_size=4, state_size=2, number_of_rounds=1)
sage: AlgebraicModel(aes).polynomial_system()
Polynomial Sequence with 174 Polynomials in 104 Variables

sage: from claasp.ciphers.block_ciphers.tea_block_cipher import TeaBlockCipher
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: tea = TeaBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=1)
sage: AlgebraicModel(tea).polynomial_system()
Polynomial Sequence with 288 Polynomials in 384 Variables

sage: from claasp.ciphers.permutations.gift_permutation import GiftPermutation
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: gift = GiftPermutation(number_of_rounds=1)
sage: AlgebraicModel(gift).polynomial_system()
Polynomial Sequence with 448 Polynomials in 640 Variables
polynomial_system_at_round(r, method_call_flag=False)

Return a polynomial system at round r.

INPUT:

  • rinteger; round index

EXAMPLES:

sage: from claasp.ciphers.toys.fancy_block_cipher import FancyBlockCipher
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: fancy = FancyBlockCipher(number_of_rounds=1)
sage: AlgebraicModel(fancy).polynomial_system_at_round(0)
Polynomial Sequence with 228 Polynomials in 144 Variables
ring()

Return the polynomial ring for the system of equations.

INPUT:

  • None

EXAMPLES:

sage: from claasp.ciphers.toys.fancy_block_cipher import FancyBlockCipher
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: from claasp.cipher_modules.models.algebraic.boolean_polynomial_ring import is_boolean_polynomial_ring
sage: fancy = FancyBlockCipher(number_of_rounds=1)
sage: ring = AlgebraicModel(fancy).ring()
sage: is_boolean_polynomial_ring(ring)
True

sage: ring.ngens()
432
var_names()

Return a list of variable names in the polynomial ring.

INPUT:

  • None

EXAMPLES:

sage: from claasp.ciphers.toys.fancy_block_cipher import FancyBlockCipher
sage: from claasp.cipher_modules.models.algebraic.algebraic_model import AlgebraicModel
sage: fancy = FancyBlockCipher(number_of_rounds=1)
sage: var_names = AlgebraicModel(fancy).var_names()
sage: var_names[0]
'sbox_0_0_x0'