Search code examples
paripari-gpfinite-field

In pari-gp, any stuff to map the finite field to its some extension?


Say, I have a polynomial p(x) over GF(2) and a polynomial g(x) over GF(4). For example,

gf2 = gf(2, 1);
gf4 = gf(2, 2);

p2 = Polrev(vector(5, i, random(gf2)));
p4 = Polrev(vector(7, i, random(gf4)));

p2 * p4
>> ***   at top-level: p2*p4
>> ***                   ^---
>> *** _*_: inconsistent multiplication t_FFELT * t_FFELT.

Does pari-gp provide any stuff to proceed in this case? If no, how can I do the desired embedding?


Solution

  • Unfortunately, the solution is at your own. PARI/GP provides no stuff for finite field embedding. For my purposes I develop the following function for finite field embedding:

    get_gf_embedding(f: t_FFELT, g: t_FFELT) =
    {
        if(f.p != g.p,
            error("** get_gf_embedding: fields are of different characterisitics")
        );
        if(f.p != g.p || poldegree(g.mod) % poldegree(f.mod) != 0,
            error("** get_gf_embedding: finite fields are not embeddable")
        );
    
        my (smaller_field_min_poly = subst(f.mod, variable(f.mod), 'x));
        my (larger_field_min_poly = subst(g.mod, variable(g.mod), 'y));
        my (subfield_prim =
            g^0 *
            subst(
                polrootsff(smaller_field_min_poly, f.p, larger_field_min_poly)[1].pol,
                'y,
                g
            )
        );
        embedding(elt) =
            subfield_prim^0 * subst((f^0 * elt).pol, variable((f^0 * elt).pol), subfield_prim)
    };
    

    For algorithmic details, please see http://johnkerl.org/doc/ffcomp.pdf (section 5.11). Using the code above you must rewrite your code as follows:

    embed = get_gf_embedding(gf2, gf4);
    Polrev(apply(embed, Vecrev(p2))) * p4