package bls12-381-js-gen

  1. Overview
  2. Docs
Functors to generate BLS12-381 JavaScript primitives based on stubs

Install

Dune Dependency

Authors

Maintainers

Sources

ocaml-bls12-381-0.4.1.tar.bz2
md5=8e9aa7459420c090c2f664554357adf4
sha512=d3d11088fe3a338a7c1e6f62aed8590edccabdde47f0d49cc564bc803d9a5e6aef9917b6f07629f0f831defa7c24294b234a8788661c80a4948dd956b35037b8

Description

Functors to generate BLS12-381 JavaScript primitives based on stubs

Published: 12 Feb 2021

README

OCaml implementation of BLS12-381

Install

# if you implement a library and you don't need an actual implementation
opam install bls12-381
# to target UNIX
opam insall bls12-381-unix
# to target JavaScript, to be used with jsoo.
opam install bls12-381-js

See below how to use in your project.

Run tests

dune runtest
dune build @test/js/browser/serve # Check _build/default/test/js/browser and run `npm run serve`

To get the coverage (only ok for bls12-381-unix and bls12-381-gen)

dune runtest --instrument-with bisect_ppx --force
bisect-ppx-report html

How to use in my project

If you are developing a library using bls12-381, you only need to add bls12-381 in the dependency list. However, if you are writing a binary, three packages are relevant:

  • bls12-381-unix: to be used for UNIX

  • bls12-381-js: to be used to target JavaScript. It does rely on the node packages listed here, version >= 0.8.1, and suppose this module is loaded before in the global namespace under the name _RUSTC_BLS12_381. See test/js/browser/ for an example. You need to use the appropriate package depending on the platform you target (Node or a bundler for the browser). For instance, if you target Node (resp. a bundler like webpack for a browser usage), you must use @dannywillems/rustc-bls12-381-node (resp. @dannywillems/rustc-bls12-381).

  • bls12-381-js-gen: if the module is loaded somewhere else than in the global namespace like the previous package supposes, you can use this third library that provides functors. The functors are expecting a module of the signature:

    sig
      val rust_module : unit -> Jsoo_lib.ESModule.t
    
      val get_wasm_memory_buffer : unit -> Jsoo_lib.Memory.Buffer.t
    end
    

    (note: functions are not directly evaluated values are required because the module might not already be loaded when loading the JavaScript resulting file and the wasm memory buffer being a view over a ArrayBuffer might be invalid if the buffer size is increased at runtime). You can see an example in the src/js.

For more examples, see the test directories.

Run the benchmarks

opam install core_bench
dune exec benchmark/bench_ec.exe
dune exec benchmark/bench_ff.exe
dune exec benchmark/bench_pairing.exe

Documentation

opam install odoc
dune build @doc

Dependencies (11)

  1. bls12-381 = version
  2. bls12-381-gen = version
  3. js_of_ocaml-ppx >= "3.7.1"
  4. js_of_ocaml-compiler >= "3.7.1"
  5. js_of_ocaml >= "3.7.1"
  6. zarith_stubs_js
  7. zarith >= "1.10" & < "2.0"
  8. ff-sig >= "0.6.1" & < "0.7.0"
  9. dune-configurator build
  10. dune >= "2.8.4"
  11. ocaml >= "4.08"

Dev Dependencies

None

Used by (1)

  1. bls12-381-js < "0.4.2"

Conflicts

None