#elliptic-curve #bls12-381 #pairing #construction #group #pairing-friendly #cosmian

no-std cosmian_bls12_381

Implementation of the BLS12-381 pairing-friendly elliptic curve construction

2 releases

0.4.1 Nov 26, 2021
0.4.0 Nov 25, 2021

#1975 in Cryptography

Download history 3/week @ 2024-02-19 26/week @ 2024-02-26 4/week @ 2024-03-11 7/week @ 2024-03-25 51/week @ 2024-04-01

62 downloads per month
Used in 2 crates



cosmian_bls12_381 Crates.io

This crate provides an implementation of the BLS12-381 pairing-friendly elliptic curve construction.

Forked by Cosmian

July 2021

Novembre 2021

  • Hence no there is no plan to add Gt serialization, the crate is pusblished as cosmian_bls12_381 in 0.4.0 version.

    • A Github-PR will be made soon on bls12_381 original crate.
  • But there is a remaining problem:

    Cosmian dit not update last version of bls12_381 (version 0.5) since it includes a dependency problem. Indeed, bls12_381-0.5 uses ff-0.10 which uses bitvec-0.22. The problem comes from the dependency funty-1.2.0 which did a breaking change (exposing another struct named BITS, confusing with same struct in bitvec crate). A comment on the funty crate has been made on July 2021 (followed by multiple same posts): https://github.com/myrrlyn/funty/issues/3#issuecomment-877833781

  • This implementation has not been reviewed or audited. Use at your own risk.
  • This implementation targets Rust 1.47 or later.
  • This implementation does not require the Rust standard library.
  • All operations are constant time unless explicitly noted.


  • groups (on by default): Enables APIs for performing group arithmetic with G1, G2, and GT.
  • pairings (on by default): Enables some APIs for performing pairings.
  • alloc (on by default): Enables APIs that require an allocator; these include pairing optimizations.
  • nightly: Enables subtle/nightly which tries to prevent compiler optimizations that could jeopardize constant time operations. Requires the nightly Rust compiler.
  • endo (on by default): Enables optimizations that leverage curve endomorphisms. Deprecated, will be removed in a future release.


Curve Description

BLS12-381 is a pairing-friendly elliptic curve construction from the BLS family, with embedding degree 12. It is built over a 381-bit prime field GF(p) with...

  • z = -0xd201000000010000
  • p = (z - 1)2(z4 - z2 + 1) / 3 + z
    • = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab
  • q = z4 - z2 + 1
    • = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001

... yielding two source groups G1 and G2, each of 255-bit prime order q, such that an efficiently computable non-degenerate bilinear pairing function e exists into a third target group GT. Specifically, G1 is the q-order subgroup of E(Fp) : y2 = x3 + 4 and G2 is the q-order subgroup of E'(Fp2) : y2 = x3 + 4(u + 1) where the extension field Fp2 is defined as Fp(u) / (u2 + 1).

BLS12-381 is chosen so that z has small Hamming weight (to improve pairing performance) and also so that GF(q) has a large 232 primitive root of unity for performing radix-2 fast Fourier transforms for efficient multi-point evaluation and interpolation. It is also chosen so that it exists in a particularly efficient and rigid subfamily of BLS12 curves.

Curve Security

Pairing-friendly elliptic curve constructions are (necessarily) less secure than conventional elliptic curves due to their small "embedding degree". Given a small enough embedding degree, the pairing function itself would allow for a break in DLP hardness if it projected into a weak target group, as weaknesses in this target group are immediately translated into weaknesses in the source group.

In order to achieve reasonable security without an unreasonably expensive pairing function, a careful choice of embedding degree, base field characteristic and prime subgroup order must be made. BLS12-381 uses an embedding degree of 12 to ensure fast pairing performance but a choice of a 381-bit base field characteristic to yield a 255-bit subgroup order (for protection against Pollard's rho algorithm) while reaching close to a 128-bit security level.

There are known optimizations of the Number Field Sieve algorithm which could be used to weaken DLP security in the target group by taking advantage of its structure, as it is a multiplicative subgroup of a low-degree extension field. However, these attacks require an (as of yet unknown) efficient algorithm for scanning a large space of polynomials. Even if the attack were practical it would only reduce security to roughly 117 to 120 bits. (This contrasts with 254-bit BN curves which usually have less than 100 bits of security in the same situation.)

Alternative Curves

Applications may wish to exchange pairing performance and/or G2 performance by using BLS24 or KSS16 curves which conservatively target 128-bit security. In applications that need cycles of elliptic curves for e.g. arbitrary proof composition, MNT6/MNT4 curve cycles are known that target the 128-bit security level. In applications that only need fixed-depth proof composition, curves of this form have been constructed as part of Zexe.


Please see Cargo.toml for a list of primary authors of this codebase.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~25K SLoC