Please give a mathematical description of the functions $f$ and $g$, including their (co)domains. If code is given, then try to find minimal shapes for it that introduce the framework of the problem in a clear way. Above, as in the other post, nothing, really nothing can be understood, not even guessed. For instance, the given curve E is defined simply as

And there is no connection to the polynomial ring $K[z]$ in a new variable $z$, that cannot be used in the context. Here, $K$ is the field with $25$ elements, generated by $a$ over F=GF(5), and we neither use (properly) a, nor K, nor R. A point on the curve has two components. And E is defined / F - not even over K. So z is forbidden in E!