sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.22k stars 424 forks source link

Our PolyBoRi's GB calculation in AES mode is broken #3440

Closed malb closed 15 years ago

malb commented 16 years ago

Burcin says this broke when the iterators changed:

sage: sr = mq.SR(2,1,1,4,gf2=True)
sage: F,s = sr.polynomial_system()
sage: R = F.ring()
sage: B = BooleanPolynomialRing(R.ngens(),R.variable_names())
sage: I = Ideal([B(f) for f in F])
sage: type(I)
<class 'sage.rings.polynomial.pbori.BooleanPolynomialIdeal'>
sage: I.groebner_basis(aes=True)
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)
...
/usr/local/sage-3.0/local/lib/python2.5/site-packages/polybori/PyPolyBoRi.py in <lambda>(x)
     21 OrderCode.__dict__ = order_dict
     22
---> 23 Variable = lambda x: get_cring().gen(x)
     24
     25 def Ring(n, order='lp'):

/home/malb/pbori.pyx in sage.rings.polynomial.pbori.BooleanPolynomialRing.gen (sage/rings/polynomial/pbori.cpp:3333)()

<type 'exceptions.TypeError'>: an integer is required

CC: @sagetrac-PolyBoRi @burcin

Component: commutative algebra

Keywords: polybori

Issue created by migration from https://trac.sagemath.org/ticket/3440

1998e663-c3b5-4cf6-92c3-7f1771ca5185 commented 16 years ago
comment:1

in PolyBoRi 0.5 will change iterators again ;-). I hope more SAGE-friendly

for variable in m.variables() for term in p.terms()

malb commented 15 years ago

this fixes the first issue

malb commented 15 years ago
comment:2

Attachment: trac_3440_gen.patch.gz

The attache patch fixes the issue above, however now:

sage: sr = mq.SR(2,1,1,4,gf2=True)
sage: F,s = sr.polynomial_system()
sage: R = F.ring()
sage: B = BooleanPolynomialRing(R.ngens(),R.variable_names())
sage: I = Ideal([B(f) for f in F])
sage: type(I)
<class 'sage.rings.polynomial.pbori.BooleanPolynomialIdeal'>
sage: I.groebner_basis(aes=True)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
...
/usr/local/sage-3.0.6/local/lib/python2.5/site-packages/polybori/aes.py in preprocess(I, prot)
     55     global cache
     56     if get_order_code()==OrderCode.lp:
---> 57       import cache as cache_module
     58       cache=cache_module.cache
     59       del cache_module
ImportError: No module named cache

Ideas, thoughts, work-arounds?

1998e663-c3b5-4cf6-92c3-7f1771ca5185 commented 15 years ago
comment:3

personally, at the moment, I don't feel, that it is good to expose this option to users. I did that for aes systems initially. But it is not about: Use that option and everything will work well...

Nevertheless: workaround replace 57/58 by

cache={}

which will make it slower. I think, we don't distribute cache.py (which contains some GB of the 8BIT SBOX).

malb commented 15 years ago
comment:4

I vote for applying my patch then and closing this ticket. We don't actively expose aes=True to the user, i.e. it is not documented etc. It just happens to work since we pass the parameters thru to PolyBoRi.

burcin commented 15 years ago
comment:6

Trivial patch, looks good to me.

Sorry for the very late review.

85eec1a4-3d04-4b4d-b711-d4db03337c41 commented 15 years ago
comment:7

Merged in Sage 3.1.2.alpha2