Bill Allombert on Wed, 05 Apr 2017 22:44:04 +0200

 Re: libpari: ellsea & ellcard caches

On Wed, Apr 05, 2017 at 10:25:12PM +0200, Jan Jancar wrote:
> Hi all,
> I'm currently using the ellsea and ellcard functions in
> libpari with some "cryptographic" sized curves.
> over F_p with p prime \in (2^128, 2^521) and
> over F_2^m with m \in (160, 512)
>
> I am doing so repeatedly in one execution of my binary [1],
> I noticed that even if I reset the stack pointer to a value
> it was before calling ellcard, ellsea or ellff_get_card the
> memory usage seems to go up more than I would expect.
>
> Does ellsea use some caches or otherwise allocate memory
> thats left after it returns? I am not getting memory leaks
> so not that.

Yes, the computed data are stored in the ellinit so that e.g.
ellorder does not need to recompute the curve order.
To free them do
obj_free(E);
where E is the ellinit.
Not that ellsea does not store the data in the ellinit.

However, we provide low level functions
Fp_ellcard, Fp_ellcard_SEA and F2xq_ellcard that you can use without the
need to create and free an ellinit.

Cheers,
Bill.