#![no_std]
#![cfg_attr(feature = "cargo-clippy", deny(warnings))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::many_single_char_names))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::write_literal))]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(missing_debug_implementations)]
pub use group;
use core::ops::{Add, AddAssign, Mul};
use group::{
ff::PrimeField,
prime::{PrimeCurve, PrimeCurveAffine},
Group, GroupOps, GroupOpsOwned, ScalarMul, ScalarMulOwned, UncompressedEncoding,
};
pub trait Engine: Sized + 'static + Clone + Sync + Send + core::fmt::Debug {
type Fr: PrimeField;
type G1: PrimeCurve<Scalar = Self::Fr, Affine = Self::G1Affine>
+ From<Self::G1Affine>
+ GroupOps<Self::G1Affine>
+ GroupOpsOwned<Self::G1Affine>
+ ScalarMul<Self::Fr>
+ ScalarMulOwned<Self::Fr>;
type G1Affine: PairingCurveAffine<
Scalar = Self::Fr,
Curve = Self::G1,
Pair = Self::G2Affine,
PairingResult = Self::Gt,
> + From<Self::G1>
+ Mul<Self::Fr, Output = Self::G1>
+ for<'a> Mul<&'a Self::Fr, Output = Self::G1>;
type G2: PrimeCurve<Scalar = Self::Fr, Affine = Self::G2Affine>
+ From<Self::G2Affine>
+ GroupOps<Self::G2Affine>
+ GroupOpsOwned<Self::G2Affine>
+ ScalarMul<Self::Fr>
+ ScalarMulOwned<Self::Fr>;
type G2Affine: PairingCurveAffine<
Scalar = Self::Fr,
Curve = Self::G2,
Pair = Self::G1Affine,
PairingResult = Self::Gt,
> + From<Self::G2>
+ Mul<Self::Fr, Output = Self::G2>
+ for<'a> Mul<&'a Self::Fr, Output = Self::G2>;
type Gt: Group<Scalar = Self::Fr> + ScalarMul<Self::Fr> + ScalarMulOwned<Self::Fr>;
fn pairing(p: &Self::G1Affine, q: &Self::G2Affine) -> Self::Gt;
}
pub trait PairingCurveAffine: PrimeCurveAffine + UncompressedEncoding {
type Pair: PairingCurveAffine<Pair = Self>;
type PairingResult: Group;
fn pairing_with(&self, other: &Self::Pair) -> Self::PairingResult;
}
pub trait MultiMillerLoop: Engine {
type G2Prepared: Clone + Send + Sync + From<Self::G2Affine>;
type Result: MillerLoopResult<Gt = Self::Gt>;
fn multi_miller_loop(terms: &[(&Self::G1Affine, &Self::G2Prepared)]) -> Self::Result;
}
pub trait MillerLoopResult:
Clone
+ Copy
+ Default
+ core::fmt::Debug
+ Send
+ Sync
+ Add<Output = Self>
+ for<'a> Add<&'a Self, Output = Self>
+ AddAssign
+ for<'a> AddAssign<&'a Self>
{
type Gt: Group;
fn final_exponentiation(&self) -> Self::Gt;
}