npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ligolang/ocaml-bls12-381

v5.0.0-dev.2

Published

This library provides a fast implementation of: - operations over the scalar field, including (i)FFT. - operations over the groups G1 and G2, including EC-FFT, hash_to_curve as described [in this specification](https://datatracker.ietf.org/doc/draft-i

Downloads

2

Readme

OCaml implementation of BLS12-381

This library provides a fast implementation of:

  • operations over the scalar field, including (i)FFT.
  • operations over the groups G1 and G2, including EC-FFT, hash_to_curve as described in this specification and the pippenger algorithm for fast multi scalar exponentiation.
  • operations over the target group of the pairing (GT), written additively.
  • pairing from G1 x G2 to GT

Encoding

Scalar

The scalar field is Fr = GF(0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001), encoded on 32 bytes in little endian.

Groups

For G1, the base field is Fq: GF(0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab) and E(Fq) := y^2 = x^3 + 4. An element of the base field can be encoded on 48 bytes (using only 381 bits, leaving 3 bits unused).

For G2, the base field is Fq2 := Fq[Z]/(X^2 + 1) and E(Fq2) := y^2 = x^3 + 4 (Z + 1). An element of the base field can be encoded on 2 * 48 bytes representing each coefficient of the polynomial. 3 bits of each coefficient encoding are unused.

The « uncompressed » form (x, y) of G1 and G2 is the concatenation of the elements x and y encoded in big endian.

The « compressed » form uses the first 3 most significant (and unused) bits of the coordinate x.

  • the first most significant bit is always set to 1 to carry the information it is the compressed encoding of a point.
  • the second most significant bit is set to 1 if the element is the identity of the curve.
  • the third most significant bit is the sign of y. It is set to 1 if y is lexicographically larger than -y.

Install

opam install bls12-381

By default, if the architecture supports ADX, bls12-381 with be compiled using ADX opcodes (giving optimisations up to 20% for some arithmetic operations). If you don't want to build using ADX, you can add the environment variable BLST_PORTABLE and set it to any value. For instance,

BLST_PORTABLE=y opam install bls12-381

will instruct to build bls12-381 without ADX. This might be useful if you build docker images on ADX machines but you need the image to be portable on architecture not supporting ADX.

If the architecture does not support ADX, bls12-381 will be compiled without ADX opcodes.

Run tests

dune runtest

To get the coverage:

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

Run the benchmarks

Install core_bench:

opam install core_bench

See files listed in the directory benchmark and execute it with dune exec. For instance:

dune exec ./benchmark/bench_fr.exe

Documentation

opam install odoc
dune build @doc