Exemplo n.º 1
0
Arquivo: rsa.py Projeto: hellman/cry
 def polyring(self, n=None, names=None):
     if isinstance(names, str):
         assert n is None
         names = names.replace(",", " ").split()
     elif isinstance(names, (tuple, list)):
         assert n is None
     else:
         if n is None:
             n = 1
         assert names is None
         names = list("xyzwuv")[:n]
     PR = PolynomialRing(Zmod(self.n), names=",".join(names))
     return (PR, ) + tuple(PR.gens())
Exemplo n.º 2
0
def power(e, n=None, field=None):
    assert (n is not None) ^ (field is not None)
    field = field or GF(2**n, name='a')
    x = PolynomialRing(field, names='x').gen()
    return SBox2(x**e)
Exemplo n.º 3
0
 def get_x(cls, n=None, field=None):
     assert (n is not None) ^ (field is not None)
     field = field or GF(2**n, name='a')
     return PolynomialRing(field, names='x').gen()
Exemplo n.º 4
0
def all_irreducible_polynomials(N, p=2):
    FR = PolynomialRing(GF(p), names=("X", ))
    for poly in FR.polynomials(of_degree=N):
        if poly.is_irreducible():
            yield poly