On Wed, Mar 13, 2019 at 12:12 PM Friedrich Wiemer <friedrichwie...@gmail.com> wrote: > > I discussed this again with my colleagues and maybe its just not so sure what > the correct way to do is? > > Is it actually clear what the "correct" ordering of finite field elements is? > The canonical ordering is 0, 1, a^1, a^2, ..., - but then this representation > and ordering depends on the representation of the actual instance, so which > polynomial is picked.
I'm not even sure whether a primitive element is always available in a Sage finite field. A field might be constructed from any irreducible polynomial, and IMHO finding a primitive element is not very quick for large fields. > If instead the elements are ordered after the representing polynomial is > chosen, we get 0, 1, a, a+1, ... - but for example list(GF(2^3)) is > differently ordered, depending on the chosen implementation. pari and ntl > results in 0, 1, a, a+1, ... while givaro gives 0, a, a+1, ..., 1. > > Regarding this, it might be ok to work with the output of `sorted(GF(...))`, > as its done currently. Nevertheless, there remains the problem with different > polynomials for representing the finite field and thus the resulting S-box > might be different. Here is an example of what I mean: > > sage: F1 = GF(2^3, name='a', modulus=PolynomialRing(GF(2), 'a')('a^3 + a + > 1')) > ....: F2 = GF(2^3, name='a', modulus=PolynomialRing(GF(2), 'a')('a^3 + a^2 + > 1')) > ....: R1 = PolynomialRing(F1, 'x') > ....: R2 = PolynomialRing(F2, 'x') > ....: inv1 = R1.gen()**(2**3-2) > ....: inv2 = R2.gen()**(2**3-2) > ....: S1 = SBox([inv1(v) for v in sorted(F1)]) > ....: S2 = SBox([inv2(v) for v in sorted(F2)]) > ....: S1, S2 > (0, 1, 5, 6, 7, 2, 3, 4), > (0, 1, 6, 4, 3, 7, 2, 5) > > OK, so not so sure if this all makes sense in the context of the above > question, but this behaviour should at least be mentioned in the docs, I > think. > Regarding the above discussed point, I still think that the current behaviour > is 'wrong' in the way that one would expect a different result. > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.