dcrypt_algorithms/ec/bls12_381/
mod.rs1#[cfg(feature = "alloc")]
7extern crate alloc;
8
9mod field;
11mod g1;
12mod g2;
13mod pairings;
14mod scalar;
15mod hash_to_curve;
16
17#[cfg(test)]
18mod tests;
19
20use crate::error::Result;
22use scalar::Scalar;
23
24pub use g1::{G1Affine, G1Projective};
26pub use g2::{G2Affine, G2Projective};
27pub use hash_to_curve::{hash_to_curve_g1, hash_to_curve_g2};
28pub use pairings::{pairing, Bls12, Gt, MillerLoopResult};
29pub use self::scalar::Scalar as Bls12_381Scalar;
30
31#[cfg(feature = "alloc")]
32pub use pairings::{multi_miller_loop, G2Prepared};
33
34const BLS_X: u64 = 0xd201_0000_0001_0000;
37const BLS_X_IS_NEGATIVE: bool = true;
39
40impl G1Projective {
41 pub fn hash_to_curve(msg: &[u8], dst: &[u8]) -> Result<Self> {
43 hash_to_curve_g1(msg, dst)
44 }
45}
46
47impl G2Projective {
48 pub fn hash_to_curve(msg: &[u8], dst: &[u8]) -> Result<Self> {
50 hash_to_curve_g2(msg, dst)
51 }
52}