fullcodec_bls12_381/
lib.rs

1//! # `bls12_381`
2//!
3//! This crate provides an implementation of the BLS12-381 pairing-friendly elliptic
4//! curve construction.
5//!
6//! * **This implementation has not been reviewed or audited. Use at your own risk.**
7//! * This implementation targets Rust `1.36` or later.
8//! * This implementation does not require the Rust standard library.
9//! * All operations are constant time unless explicitly noted.
10
11#![cfg_attr(not(feature = "std"), no_std)]
12// Catch documentation errors caused by code changes.
13#![deny(rustdoc::broken_intra_doc_links)]
14#![deny(missing_debug_implementations)]
15#![deny(missing_docs)]
16#![allow(clippy::too_many_arguments)]
17#![allow(clippy::unreadable_literal)]
18#![allow(clippy::many_single_char_names)]
19// This lint is described at
20// https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_arithmetic_impl
21// In our library, some of the arithmetic involving extension fields will necessarily
22// involve various binary operators, and so this lint is triggered unnecessarily.
23#![allow(clippy::suspicious_arithmetic_impl)]
24
25#[cfg(test)]
26#[macro_use]
27extern crate std;
28
29#[cfg(test)]
30mod tests;
31
32#[macro_use]
33mod util;
34
35/// Notes about how the BLS12-381 elliptic curve is designed, specified
36/// and implemented by this library.
37pub mod notes {
38    pub mod design;
39    pub mod serialization;
40}
41
42mod scalar;
43
44pub use scalar::Scalar as BlsScalar;
45pub use scalar::{GENERATOR, ROOT_OF_UNITY, TWO_ADACITY};
46
47mod fp;
48mod fp2;
49mod g1;
50mod g2;
51
52pub use g1::{G1Affine, G1Projective};
53pub use g2::{G2Affine, G2Projective};
54
55mod fp12;
56mod fp6;
57
58// The BLS parameter x for BLS12-381 is -0xd201000000010000
59const BLS_X: u64 = 0xd201000000010000;
60const BLS_X_IS_NEGATIVE: bool = true;
61
62mod pairings;
63
64pub use pairings::{pairing, Gt, MillerLoopResult};
65
66pub use pairings::{multi_miller_loop, G2Prepared};
67
68pub mod multiscalar_mul;