|
|
@ -36,42 +36,42 @@ pub trait Engine: Sized + 'static + Clone { |
|
|
|
|
|
|
|
|
|
|
|
/// The projective representation of an element in G1.
|
|
|
|
/// The projective representation of an element in G1.
|
|
|
|
type G1: CurveProjective< |
|
|
|
type G1: CurveProjective< |
|
|
|
Engine = Self, |
|
|
|
Engine = Self, |
|
|
|
Base = Self::Fq, |
|
|
|
Base = Self::Fq, |
|
|
|
Scalar = Self::Fr, |
|
|
|
Scalar = Self::Fr, |
|
|
|
Affine = Self::G1Affine, |
|
|
|
Affine = Self::G1Affine, |
|
|
|
> |
|
|
|
> |
|
|
|
+ From<Self::G1Affine>; |
|
|
|
+ From<Self::G1Affine>; |
|
|
|
|
|
|
|
|
|
|
|
/// The affine representation of an element in G1.
|
|
|
|
/// The affine representation of an element in G1.
|
|
|
|
type G1Affine: CurveAffine< |
|
|
|
type G1Affine: CurveAffine< |
|
|
|
Engine = Self, |
|
|
|
Engine = Self, |
|
|
|
Base = Self::Fq, |
|
|
|
Base = Self::Fq, |
|
|
|
Scalar = Self::Fr, |
|
|
|
Scalar = Self::Fr, |
|
|
|
Projective = Self::G1, |
|
|
|
Projective = Self::G1, |
|
|
|
Pair = Self::G2Affine, |
|
|
|
Pair = Self::G2Affine, |
|
|
|
PairingResult = Self::Fqk, |
|
|
|
PairingResult = Self::Fqk, |
|
|
|
> |
|
|
|
> |
|
|
|
+ From<Self::G1>; |
|
|
|
+ From<Self::G1>; |
|
|
|
|
|
|
|
|
|
|
|
/// The projective representation of an element in G2.
|
|
|
|
/// The projective representation of an element in G2.
|
|
|
|
type G2: CurveProjective< |
|
|
|
type G2: CurveProjective< |
|
|
|
Engine = Self, |
|
|
|
Engine = Self, |
|
|
|
Base = Self::Fqe, |
|
|
|
Base = Self::Fqe, |
|
|
|
Scalar = Self::Fr, |
|
|
|
Scalar = Self::Fr, |
|
|
|
Affine = Self::G2Affine, |
|
|
|
Affine = Self::G2Affine, |
|
|
|
> |
|
|
|
> |
|
|
|
+ From<Self::G2Affine>; |
|
|
|
+ From<Self::G2Affine>; |
|
|
|
|
|
|
|
|
|
|
|
/// The affine representation of an element in G2.
|
|
|
|
/// The affine representation of an element in G2.
|
|
|
|
type G2Affine: CurveAffine< |
|
|
|
type G2Affine: CurveAffine< |
|
|
|
Engine = Self, |
|
|
|
Engine = Self, |
|
|
|
Base = Self::Fqe, |
|
|
|
Base = Self::Fqe, |
|
|
|
Scalar = Self::Fr, |
|
|
|
Scalar = Self::Fr, |
|
|
|
Projective = Self::G2, |
|
|
|
Projective = Self::G2, |
|
|
|
Pair = Self::G1Affine, |
|
|
|
Pair = Self::G1Affine, |
|
|
|
PairingResult = Self::Fqk, |
|
|
|
PairingResult = Self::Fqk, |
|
|
|
> |
|
|
|
> |
|
|
|
+ From<Self::G2>; |
|
|
|
+ From<Self::G2>; |
|
|
|
|
|
|
|
|
|
|
|
/// The base field that hosts G1.
|
|
|
|
/// The base field that hosts G1.
|
|
|
@ -110,8 +110,8 @@ pub trait Engine: Sized + 'static + Clone { |
|
|
|
|
|
|
|
|
|
|
|
/// Projective representation of an elliptic curve point guaranteed to be
|
|
|
|
/// Projective representation of an elliptic curve point guaranteed to be
|
|
|
|
/// in the correct prime order subgroup.
|
|
|
|
/// in the correct prime order subgroup.
|
|
|
|
pub trait CurveProjective |
|
|
|
pub trait CurveProjective: |
|
|
|
: PartialEq |
|
|
|
PartialEq |
|
|
|
+ Eq |
|
|
|
+ Eq |
|
|
|
+ Sized |
|
|
|
+ Sized |
|
|
|
+ Copy |
|
|
|
+ Copy |
|
|
@ -121,7 +121,8 @@ pub trait CurveProjective |
|
|
|
+ fmt::Debug |
|
|
|
+ fmt::Debug |
|
|
|
+ fmt::Display |
|
|
|
+ fmt::Display |
|
|
|
+ rand::Rand |
|
|
|
+ rand::Rand |
|
|
|
+ 'static { |
|
|
|
+ 'static |
|
|
|
|
|
|
|
{ |
|
|
|
type Engine: Engine<Fr = Self::Scalar>; |
|
|
|
type Engine: Engine<Fr = Self::Scalar>; |
|
|
|
type Scalar: PrimeField + SqrtField; |
|
|
|
type Scalar: PrimeField + SqrtField; |
|
|
|
type Base: SqrtField; |
|
|
|
type Base: SqrtField; |
|
|
@ -180,9 +181,9 @@ pub trait CurveProjective |
|
|
|
|
|
|
|
|
|
|
|
/// Affine representation of an elliptic curve point guaranteed to be
|
|
|
|
/// Affine representation of an elliptic curve point guaranteed to be
|
|
|
|
/// in the correct prime order subgroup.
|
|
|
|
/// in the correct prime order subgroup.
|
|
|
|
pub trait CurveAffine |
|
|
|
pub trait CurveAffine: |
|
|
|
: Copy + Clone + Sized + Send + Sync + fmt::Debug + fmt::Display + PartialEq + Eq + 'static |
|
|
|
Copy + Clone + Sized + Send + Sync + fmt::Debug + fmt::Display + PartialEq + Eq + 'static |
|
|
|
{ |
|
|
|
{ |
|
|
|
type Engine: Engine<Fr = Self::Scalar>; |
|
|
|
type Engine: Engine<Fr = Self::Scalar>; |
|
|
|
type Scalar: PrimeField + SqrtField; |
|
|
|
type Scalar: PrimeField + SqrtField; |
|
|
|
type Base: SqrtField; |
|
|
|
type Base: SqrtField; |
|
|
@ -232,8 +233,9 @@ pub trait CurveAffine |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// An encoded elliptic curve point, which should essentially wrap a `[u8; N]`.
|
|
|
|
/// An encoded elliptic curve point, which should essentially wrap a `[u8; N]`.
|
|
|
|
pub trait EncodedPoint |
|
|
|
pub trait EncodedPoint: |
|
|
|
: Sized + Send + Sync + AsRef<[u8]> + AsMut<[u8]> + Clone + Copy + 'static { |
|
|
|
Sized + Send + Sync + AsRef<[u8]> + AsMut<[u8]> + Clone + Copy + 'static |
|
|
|
|
|
|
|
{ |
|
|
|
type Affine: CurveAffine; |
|
|
|
type Affine: CurveAffine; |
|
|
|
|
|
|
|
|
|
|
|
/// Creates an empty representation.
|
|
|
|
/// Creates an empty representation.
|
|
|
@ -261,9 +263,9 @@ pub trait EncodedPoint |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// This trait represents an element of a field.
|
|
|
|
/// This trait represents an element of a field.
|
|
|
|
pub trait Field |
|
|
|
pub trait Field: |
|
|
|
: Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static + rand::Rand |
|
|
|
Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static + rand::Rand |
|
|
|
{ |
|
|
|
{ |
|
|
|
/// Returns the zero element of the field, the additive identity.
|
|
|
|
/// Returns the zero element of the field, the additive identity.
|
|
|
|
fn zero() -> Self; |
|
|
|
fn zero() -> Self; |
|
|
|
|
|
|
|
|
|
|
@ -334,8 +336,8 @@ pub trait SqrtField: Field { |
|
|
|
/// This trait represents a wrapper around a biginteger which can encode any element of a particular
|
|
|
|
/// This trait represents a wrapper around a biginteger which can encode any element of a particular
|
|
|
|
/// prime field. It is a smart wrapper around a sequence of `u64` limbs, least-significant digit
|
|
|
|
/// prime field. It is a smart wrapper around a sequence of `u64` limbs, least-significant digit
|
|
|
|
/// first.
|
|
|
|
/// first.
|
|
|
|
pub trait PrimeFieldRepr |
|
|
|
pub trait PrimeFieldRepr: |
|
|
|
: Sized |
|
|
|
Sized |
|
|
|
+ Copy |
|
|
|
+ Copy |
|
|
|
+ Clone |
|
|
|
+ Clone |
|
|
|
+ Eq |
|
|
|
+ Eq |
|
|
@ -349,7 +351,8 @@ pub trait PrimeFieldRepr |
|
|
|
+ rand::Rand |
|
|
|
+ rand::Rand |
|
|
|
+ AsRef<[u64]> |
|
|
|
+ AsRef<[u64]> |
|
|
|
+ AsMut<[u64]> |
|
|
|
+ AsMut<[u64]> |
|
|
|
+ From<u64> { |
|
|
|
+ From<u64> |
|
|
|
|
|
|
|
{ |
|
|
|
/// Subtract another represetation from this one.
|
|
|
|
/// Subtract another represetation from this one.
|
|
|
|
fn sub_noborrow(&mut self, other: &Self); |
|
|
|
fn sub_noborrow(&mut self, other: &Self); |
|
|
|
|
|
|
|
|
|
|
|