Package sage :: Package crypto :: Package mq :: Module mpolynomialsystem :: Class MPolynomialRoundSystem_generic
[hide private]
[frames] | no frames]

Class MPolynomialRoundSystem_generic

source code

                      object --+    
                               |    
structure.sage_object.SageObject --+
                                   |
                                  MPolynomialRoundSystem_generic

Instance Methods [hide private]
 
__init__(self, R, gens)
Construct an object representing the equations of a single round (e.g.
source code
 
__copy__(self)
Return a copy of this round system.
source code
 
__cmp__(self, other)
Compare the ring and generators of self and other.
source code
 
ring(self)
Return the base ring.
source code
 
ngens(self)
Return number of polynomials in self.
source code
 
gens(self)
Return list of polynomials in self.
source code
 
variables(self)
Return unordered list of variables apprearing in polynomials in self.
source code
 
monomials(self)
Return unordered list of monomials appearing in polynomials in self.
source code
 
subs(self, *args, **kwargs)
Substitute variables for every polynomial in self.
source code
 
_repr_(self)
Return string representation of self.
source code
 
__getitem__(self, i)
Return the i-th generator of self.
source code
 
__add__(self, right)
Addition is the union of generators.
source code
 
__contains__(self, element)
Return True if element is in the list of generators for self.
source code
 
__len__(self)
Return self.ngens().
source code
 
__iter__(self)
Iterate over the generators of self.
source code
 
_singular_(self)
Return SINGULAR ideal representation of self.
source code
 
_magma_(self)
Return MAGMA ideal representation of self.
source code

Inherited from structure.sage_object.SageObject: __hash__, __new__, __repr__, _axiom_, _axiom_init_, _gap_, _gap_init_, _gp_, _gp_init_, _interface_, _interface_init_, _interface_is_cached_, _kash_, _kash_init_, _macaulay2_, _macaulay2_init_, _magma_init_, _maple_, _maple_init_, _mathematica_, _mathematica_init_, _maxima_, _maxima_init_, _octave_, _octave_init_, _pari_, _pari_init_, _r_init_, _sage_, _singular_init_, category, db, dump, dumps, plot, rename, reset_name, save, version

Inherited from object: __delattr__, __getattribute__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, R, gens)
(Constructor)

source code 

Construct an object representing the equations of a single
round (e.g. of a block cipher).

INPUT:
    R -- base ring
    gens -- list (default: [])

EXAMPLE:
    sage: P.<x,y,z> = PolynomialRing(GF(2),3)
    sage: mq.MPolynomialRoundSystem(P,[x*y +1, z + 1])
    [x*y + 1, z + 1]

Overrides: object.__init__

__copy__(self)

source code 

Return a copy of this round system.

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True)
    sage: F,s = sr.polynomial_system()
    sage: r = F.round(0)
    sage: copy(r)
    [w100 + k000 + (a^3 + a + 1), w101 + k001 + (a^3 + 1),
    w102 + k002 + (a^3 + a^2 + 1), w103 + k003 + (a^3 + a^2 +
    a)]

__cmp__(self, other)
(Comparison operator)

source code 

Compare the ring and generators of self and other.

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True)
    sage: F,s = sr.polynomial_system()
    sage: F == copy(F) # indirect doctest
    True

ring(self)

source code 

Return the base ring.

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True,gf2=True,order='block')
    sage: F,s = sr.polynomial_system()
    sage: R0 = F.round(0)
    sage: print R0.ring().repr_long()
    Polynomial Ring
     Base Ring : Finite Field of size 2
          Size : 20 Variables
      Block  0 : Ordering : degrevlex
                 Names    : k100, k101, k102, k103, x100, x101, x102, x103, w100, w101, w102, w103, s000, s001, s002, s003
      Block  1 : Ordering : degrevlex
                 Names    : k000, k001, k002, k003

ngens(self)

source code 

Return number of polynomials in self.

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True,gf2=True,order='block')
    sage: F,s = sr.polynomial_system()
    sage: R0 = F.round(0)
    sage: R0.ngens()
    4

gens(self)

source code 

Return list of polynomials in self.

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True,gf2=True,order='block')
    sage: F,s = sr.polynomial_system()
    sage: R1 = F.round(1)
    sage: l = R1.gens()
    sage: l[0]
    k000^2 + k000

variables(self)

source code 

Return unordered list of variables apprearing in polynomials
in self.

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True,gf2=True,order='block')
    sage: F,s = sr.polynomial_system()
    sage: R1 = F.round(1)
    sage: sorted(R1.variables())
    [k003, k002, k001, k000]

monomials(self)

source code 

Return unordered list of monomials appearing in polynomials
in self.

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True,gf2=True,order='block')
    sage: F,s = sr.polynomial_system()
    sage: R1 = F.round(1)
    sage: sorted(R1.monomials())
    [k003, k002, k001, k000, k003^2, k002^2, k001^2, k000^2]

subs(self, *args, **kwargs)

source code 

Substitute variables for every polynomial in self. See
MPolynomial.subs for calling convention.

INPUT:
    args -- arguments to be passed to MPolynomial.subs
    kwargs -- keyword arguments to be passed to MPolynomial.subs

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True,gf2=True,order='block')
    sage: F,s = sr.polynomial_system()
    sage: R1 = F.round(1)
    sage: R1.subs(s) # the solution
    sage: R1
    [0, 0, 0, 0]

_repr_(self)

source code 

Return string representation of self.

EXAMPLE:
    sage: P.<x,y,z> = PolynomialRing(GF(2),3)
    sage: F = mq.MPolynomialRoundSystem(P,[x*y +1, z + 1])
    sage: str(F) # indirect doctest
    '[x*y + 1, z + 1]'

__getitem__(self, i)
(Indexing operator)

source code 

Return the i-th generator of self.

EXAMPLE:
    sage: P.<x,y,z> = PolynomialRing(GF(2),3)
    sage: F = mq.MPolynomialRoundSystem(P,[x*y +1, z + 1])
    sage: F[0] # indirect doctest
    x*y + 1

__add__(self, right)
(Addition operator)

source code 

Addition is the union of generators.

INPUT:
    right -- MPolynomialSystem, list or tuple

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True,gf2=True,order='block')
    sage: F,s = sr.polynomial_system()
    sage: R1 = F.round(1)
    sage: len(R1 + F.round(2)) # indirect doctest
    28
    sage: len(R1 + list(F.round(2)))
    28

__contains__(self, element)
(In operator)

source code 

Return True if element is in the list of generators for self.

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True,gf2=True,order='block')
    sage: F,s = sr.polynomial_system()
    sage: R1 = F.round(1)
    sage: P = F.ring()
    sage: f = P('k000^2 + k000')
    sage: f in R1
    True
    sage: f+1 in R1
    False

__len__(self)
(Length operator)

source code 

Return self.ngens().

EXAMPLE:
    sage: P.<x,y,z> = PolynomialRing(GF(2),3)
    sage: F = mq.MPolynomialRoundSystem(P,[x*y +1, z + 1])
    sage: len(F)
    2

__iter__(self)

source code 

Iterate over the generators of self.

EXAMPLE:
    sage: P.<x,y,z> = PolynomialRing(GF(2),3)
    sage: F = mq.MPolynomialRoundSystem(P,[x*y +1, z + 1])
    sage: for f in F:
    ...     print f
    x*y + 1
    z + 1

_singular_(self)

source code 

Return SINGULAR ideal representation of self.

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True,gf2=True,order='block')
    sage: F,s = sr.polynomial_system()
    sage: R1 = F.round(1)
    sage: R1._singular_()
    k000^2+k000,
    k001^2+k001,
    k002^2+k002,
    k003^2+k003

Overrides: structure.sage_object.SageObject._singular_

_magma_(self)

source code 

Return MAGMA ideal representation of self.

EXAMPLE:
    sage: sr = mq.SR(allow_zero_inversions=True,gf2=True)
    sage: F,s = sr.polynomial_system()
    sage: R1 = F.round(1)
    sage: R1._magma_() # optional, requires MAGMA
    Ideal of Polynomial ring of rank 20 over GF(2)
    Graded Reverse Lexicographical Order
    Variables: k100, k101, k102, k103, x100, x101, x102, x103, w100, w101, w102, w103, s000, s001, s002, s003, k000, k001, k002, k003
    Basis:
    [
    k000^2 + k000,
    k001^2 + k001,
    k002^2 + k002,
    k003^2 + k003
    ]

Overrides: structure.sage_object.SageObject._magma_