[ANN] bindings to the PARI algebra library

Hello!

I wrote ocaml-pari, an OCaml library providing bindings to the PARI algebra library. The bindings are automatically generated from the library’s header files. In addition, a light wrapper offers a thin layer of static typing to not only encode part of the written documentation into types by means of phantom types, but to encode actual invariants to prevent mismatches between functions and arguments. E.g., to prevent from multiplying a group element by a polynomial. One can find code samples in the examples directory, notably cryptographic polynomial commitments (kzg.ml) and an attack on a knapsack cryptosystem (knapsack_lll.ml).

The underlying library, PARI, is written in C and relies on a single recursive type to represent all objects. With the wrapper, this type is (‘kind, ‘structure) t so as to annotate it with its kind and the operations it supports. It is thus possible to write a generic algorithm that works with group elements (‘a, group) t for instance. The library is available from OPAM: opam install pari.

9 Likes

This looks cool. Could you say a few words about your own use-case for this library?

Sure! To prototype some cryptographic protocols, carry out attacks on cryptosystems found in the scientific literature, and deepen my knowledge in (computational) algebra. I’m considering writing blog posts about it in the process!