Opened 7 years ago

Closed 6 years ago

# sage.crypto.gen_lattice: quotient parameter should accept polynomials

Reported by: Owned by: jdemeyer minor sage-6.10 cryptography vbraun Jeroen Demeyer Vincent Delecroix N/A 80df39c 80df39cb2daf7d1de65153b85492268568dfa85c

### Description

This works:

```sage: var('x')
x
sage: sage.crypto.gen_lattice(type='ideal', seed=42, quotient=x^4-1)
[11  0  0  0  0  0  0  0]
[ 0 11  0  0  0  0  0  0]
[ 0  0 11  0  0  0  0  0]
[ 0  0  0 11  0  0  0  0]
[ 4 -2 -3 -3  1  0  0  0]
[-3  4 -2 -3  0  1  0  0]
[-3 -3  4 -2  0  0  1  0]
[-2 -3 -3  4  0  0  0  1]
```

But this should also work:

```sage: R.<x> = ZZ[]
sage: sage.crypto.gen_lattice(type='ideal', seed=42, quotient=x^4-1)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-387441ec01a8> in <module>()
----> 1 sage.crypto.gen_lattice(type='ideal', seed=Integer(42), quotient=x**Integer(4)-Integer(1))

/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/crypto/lattice.pyc in gen_lattice(type, n, m, q, seed, quotient, dual, ntl, lattice)
215         if quotient is None: raise \
216             ValueError('ideal bases require a quotient polynomial')
--> 217         x = quotient.default_variable()
218         if n != quotient.degree(x): raise \
219             ValueError('ideal bases require n  = quotient.degree()')

/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/structure/element.so in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4074)()

/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/structure/misc.so in sage.structure.misc.getattr_from_other_class (build/cythonized/sage/structure/misc.c:1631)()

AttributeError: 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint' object has no attribute 'default_variable'
```

### comment:1 Changed 7 years ago by jdemeyer

• Branch set to u/jdemeyer/ticket/17406
• Created changed from 11/27/14 10:08:11 to 11/27/14 10:08:11
• Modified changed from 11/27/14 10:08:11 to 11/27/14 10:08:11

### comment:2 Changed 7 years ago by jdemeyer

• Authors set to Jeroen Demeyer
• Status changed from new to needs_review

New commits:

 ​e72814e `Trac #17406: quotient parameter should accept polynomials`

### comment:3 Changed 7 years ago by chapoton

• Branch changed from u/jdemeyer/ticket/17406 to public/ticket/17406

correct failing doctest

New commits:

 ​d1e8909 `Merge branch 'u/jdemeyer/ticket/17406' into 6.7.b1` ​9696d98 `trac #17406 fixing doctest`

### comment:4 follow-up: ↓ 5 Changed 7 years ago by malb

```assert P.base_ring() is ZZ_q
```

I was under the impression we are encouraged to avoid `assert` unless it's really a bug in the program we are checking for.

### comment:5 in reply to: ↑ 4 Changed 7 years ago by jdemeyer

I was under the impression we are encouraged to avoid `assert` unless it's really a bug in the program we are checking for.

Absolutely! You must only use `assert` to check for bugs, not for bad user input.

### comment:6 Changed 6 years ago by vdelecroix

• Status changed from needs_review to needs_work

Does not merge on 6.10.beta6

### comment:7 Changed 6 years ago by git

• Commit changed from 9696d984d060eff5b30e608bf00d60e3675e0368 to 80df39cb2daf7d1de65153b85492268568dfa85c

Branch pushed to git repo; I updated commit sha1. New commits:

 ​80df39c `Merge tag '6.10.beta6' into t/17406/public/ticket/17406`

### comment:8 Changed 6 years ago by jdemeyer

• Status changed from needs_work to positive_review

### comment:9 Changed 6 years ago by jdemeyer

• Status changed from positive_review to needs_review

### comment:10 Changed 6 years ago by jdemeyer

Accidentally set to "positive review", let's hope Volker didn't merge it in this 11-second window :-)

### comment:11 Changed 6 years ago by vdelecroix

• Milestone changed from sage-6.5 to sage-6.10
• Reviewers set to Vincent Delecroix
• Status changed from needs_review to positive_review

### comment:12 Changed 6 years ago by vbraun

• Branch changed from public/ticket/17406 to 80df39cb2daf7d1de65153b85492268568dfa85c
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.