package bls12-381

  1. Overview
  2. Docs
Virtual package for BLS12-381 primitives

Install

Dune Dependency

Authors

Maintainers

Sources

ocaml-bls12-381-1.1.1.tar.bz2
md5=32a535b7e01cc49580bbb951e753d771
sha512=0fcb37697b98709306123bbf2db8658caf914c5cc34af40c336061582e4662f682827bffbfe1fa47fba84365498e422c4f2cdfb8676504a40ea24683335d96e0

Description

Published: 13 Jan 2022

README

OCaml implementation of BLS12-381

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

# 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

See below how to use in your project.

Run tests

dune runtest

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

Run the benchmarks

opam install core_bench
dune exec benchmark/bench_fr.exe
dune exec benchmark/bench_g1.exe
dune exec benchmark/bench_g2.exe
dune exec benchmark/bench_pairing.exe
dune exec benchmark/bench_signature.exe

Documentation

opam install odoc
dune build @doc

Dependencies (4)

  1. zarith >= "1.10" & < "2.0"
  2. ff-sig >= "0.6.1" & < "0.7.0"
  3. dune >= "2.8.4"
  4. ocaml >= "4.08"

Dev Dependencies

None

Used by (3)

  1. bls12-381-unix = "1.1.1"
  2. scaml >= "1.5.0"
  3. tezos-protocol-environment >= "12.0" & < "13.0"

Conflicts

None

OCaml

Innovation. Community. Security.