package ff

  1. Overview
  2. Docs
OCaml implementation of Finite Field operations

Install

Dune Dependency

Authors

Maintainers

Sources

ocaml-ff-0.5.0.tar.gz
md5=bb169cc29473e0f41f3c57382a4b9268
sha512=a23741b42ad362320c2e554b58181941cd8a1e2d078e5c2625126be622216f2efc0d6367e6a4c6a80abd101f10602617c42e821cc4b7175f6891bf2791b0fd27

Description

OCaml implementation of Finite Field operations

Published: 24 Nov 2020

README

OCaml FF

Play with Finite Field in OCaml

This library provides functors to instantiate finite field of arbitrary orders (in the limit of Zarith, the dependency to handle arbitrary integers).

module F13 = Ff.MakeFp (struct let prime_order = Z.of_string "13" end)
module BLSFr = Ff.MakeFp (
  struct
    let prime_order = Z.of_string "52435875175126190479447740508185965837690552500527637822603658699938581184513"
  end
)

JavaScript compatibility

This library can be transpiled in JavaScript using js_of_ocaml. An example is provided in js/test_js.ml, with the corresponding dune file. It instantiates Fp with p = 53. dune will compile this into a FiniteField.js file, exporting methods like add, toString, random, etc. FiniteField can be used as a Node module. See js/test/test_js.js for an example.

# Generate FiniteField.js
dune build js
cp _build/default/js/FiniteField.js ./
node
var FF = require("./FiniteField.js");
let x = FF.random();
let y = FF.random();
let x_plus_y = FF.add(x, y);

Documentation

See here

PBT testing

A package ff-pbt is also included and published providing Property Based Testing of finite fields based on the generic finite fields interface given in ff. If you have a library implementing finite fields, but not using the functors provided by ff, you can use:

(* You module is MyField *)

module MyFieldProperties = Ff_pbt.MakeFieldProperties (MyField)

let () =
  let open Alcotest in
  run "MyField" [MyFieldProperties.get_tests()]

It is stronly relying on the random function implemented by the finite field module.

Dependencies (4)

  1. ff-sig = "0.5.0"
  2. zarith >= "1.9.1" & < "2.0"
  3. dune >= "2.0"
  4. ocaml >= "4.08"

Dev Dependencies (2)

  1. ff-pbt = "0.5.0" & with-test
  2. alcotest with-test

Used by (2)

  1. polynomial < "0.4.0"
  2. tezos-plompiler < "1.0.0"

Conflicts

None

OCaml

Innovation. Community. Security.