Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various errors with polybori including segmentation fault #32083

Open
kliem opened this issue Jun 29, 2021 · 2 comments
Open

Various errors with polybori including segmentation fault #32083

kliem opened this issue Jun 29, 2021 · 2 comments

Comments

@kliem
Copy link
Contributor

kliem commented Jun 29, 2021

Looks a bit like #17143.

sage: def foo(): 
....:      sr = mq.SR(2,1,1,4,gf2=True, polybori=True)    
....:      F, s = sr.polynomial_system()      
....:      I = F.ideal()       
....:      return I.groebner_basis()
....:
sage: set_random_seed(0)                                                                                                              
sage: foo()                                                                                                                           
Polynomial Sequence with 36 Polynomials in 36 Variables
sage: foo()                                                                                                                           
terminate called recursively
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-68-c19b6d9633cf> in <module>
----> 1 foo()

<ipython-input-65-541c6b0ff85c> in foo()
      3      F, s = sr.polynomial_system()
      4      I = F.ideal()
----> 5      return I.groebner_basis()
      6 

/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/rings/polynomial/pbori/pbori.pyx in sage.rings.polynomial.pbori.pbori.BooleanPolynomialIdeal.groebner_basis (build/cythonized/sage/rings/polynomial/pbori/pbori.cpp:42385)()
   4999             if "redsb" not in kwds:
   5000                 kwds["redsb"]=True
-> 5001             sig_on()
   5002             gb = self._groebner_basis(**kwds)
   5003             sig_off()

RuntimeError: Aborted
sage: foo()                                                                                                                           
Polynomial Sequence with 36 Polynomials in 36 Variables
sage: foo()                                                                                                                           
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-70-c19b6d9633cf> in <module>
----> 1 foo()

<ipython-input-65-541c6b0ff85c> in foo()
      1 def foo():
      2      sr = mq.SR(Integer(2),Integer(1),Integer(1),Integer(4),gf2=True, polybori=True)
----> 3      F, s = sr.polynomial_system()
      4      I = F.ideal()
      5      return I.groebner_basis()

/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/crypto/mq/sr.py in polynomial_system(self, P, K, C)
   2137 
   2138         if ciphertext is None:
-> 2139             ciphertext = self(plaintext, key)
   2140         elif ciphertext is False:
   2141             raise TypeError("type %s of C not understood"%(type(ciphertext)))

/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/crypto/mq/sr.py in __call__(self, P, K)
   1386                 print("R[%02d].m_col   %s"%(self.n, self.hex_str_vector(P)))
   1387 
-> 1388         K = KeyExpansion(K, self._n)
   1389         if get_verbose() >= 2:
   1390             print("R[%02d].k_sch   %s"%(self.n, self.hex_str_vector(K)))

/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/crypto/mq/sr.py in key_schedule(self, kj, i)
   1179 
   1180         if r == 1:
-> 1181             s0 = SubByte(kj[0, c-1])
   1182 
   1183             if c > 1:

/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/crypto/mq/sr.py in sub_byte(self, b)
    726         if not b:
    727             if not self._allow_zero_inversions:
--> 728                 raise ZeroDivisionError("A zero inversion occurred during an encryption or key schedule.")
    729             else:
    730                 return self.sbox_constant()

ZeroDivisionError: A zero inversion occurred during an encryption or key schedule.

Depending on the session, the RuntimeError can also be a SignalError with segmentation fault.

Component: algebra

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

@kliem kliem added this to the sage-9.4 milestone Jun 29, 2021
@kliem
Copy link
Contributor Author

kliem commented Jun 29, 2021

comment:1

foo is a doctest from src/sage/rings/polynomial/pbori/pbori.pyx that I'm going to mark not tested in #29979).

@kliem

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants