Trait EngineBLS

Source
pub trait EngineBLS {
    type Engine: Pairing;
    type Scalar: PrimeField;
    type PublicKeyGroupBaseField: Field;
    type PublicKeyGroupAffine: AffineRepr<ScalarField = Self::Scalar, Group = Self::PublicKeyGroup> + From<Self::PublicKeyGroup> + Into<Self::PublicKeyGroup> + Into<Self::PublicKeyPrepared>;
    type PublicKeyGroup: CurveGroup<Affine = Self::PublicKeyGroupAffine, ScalarField = Self::Scalar, BaseField = Self::PublicKeyGroupBaseField> + From<Self::PublicKeyGroupAffine> + Into<Self::PublicKeyGroupAffine> + MulAssign<Self::Scalar>;
    type PublicKeyPrepared: Default + Clone + Send + Sync + Debug + From<Self::PublicKeyGroupAffine>;
    type SignatureGroupBaseField: Field;
    type SignatureGroupAffine: AffineRepr<ScalarField = Self::Scalar, Group = Self::SignatureGroup> + From<Self::SignatureGroup> + Into<Self::SignatureGroup> + Into<Self::SignaturePrepared>;
    type SignatureGroup: CurveGroup<Affine = Self::SignatureGroupAffine, ScalarField = Self::Scalar, BaseField = Self::SignatureGroupBaseField> + Into<Self::SignatureGroupAffine> + From<Self::SignatureGroupAffine> + MulAssign<Self::Scalar>;
    type SignaturePrepared: Default + Clone + Send + Sync + Debug + From<Self::SignatureGroupAffine>;
    type HashToSignatureField: HashToField<Self::SignatureGroupBaseField>;
    type MapToSignatureCurve: MapToCurve<Self::SignatureGroup>;
Show 6 associated constants and 13 methods const PUBLICKEY_SERIALIZED_SIZE: usize; const SECRET_KEY_SIZE: usize; const CURVE_NAME: &'static [u8]; const SIG_GROUP_NAME: &'static [u8]; const CIPHER_SUIT_DOMAIN_SEPARATION: &'static [u8]; const SIGNATURE_SERIALIZED_SIZE: usize; // Required methods fn hash_to_curve_map( ) -> MapToCurveBasedHasher<Self::SignatureGroup, Self::HashToSignatureField, Self::MapToSignatureCurve>; fn miller_loop<'a, I>(i: I) -> MillerLoopOutput<Self::Engine> where Self::PublicKeyPrepared: 'a, Self::SignaturePrepared: 'a, I: IntoIterator<Item = &'a (<Self as EngineBLS>::PublicKeyPrepared, Self::SignaturePrepared)>; fn pairing<G1, G2>(p: G1, q: G2) -> <Self::Engine as Pairing>::TargetField where G1: Into<<Self::PublicKeyGroup as CurveGroup>::Affine>, G2: Into<<Self::SignatureGroup as CurveGroup>::Affine>; fn minus_generator_of_public_key_group_prepared() -> Self::PublicKeyPrepared; // Provided methods fn generate<R: Rng + RngCore>(rng: &mut R) -> Self::Scalar { ... } fn hash_to_signature_curve<M: Borrow<[u8]>>( message: M, ) -> Self::SignatureGroup { ... } fn final_exponentiation( e: MillerLoopOutput<Self::Engine>, ) -> Option<PairingOutput<Self::Engine>> { ... } fn verify_prepared<'a, I>( signature: Self::SignaturePrepared, inputs: I, ) -> bool where Self::PublicKeyPrepared: 'a, Self::SignaturePrepared: 'a, I: IntoIterator<Item = &'a (Self::PublicKeyPrepared, Self::SignaturePrepared)> { ... } fn generator_of_signature_group() -> Self::SignatureGroup { ... } fn prepare_public_key( g: impl Into<Self::PublicKeyGroupAffine>, ) -> Self::PublicKeyPrepared { ... } fn prepare_signature( g: impl Into<Self::SignatureGroupAffine>, ) -> Self::SignaturePrepared { ... } fn signature_point_to_byte(point: &Self::SignatureGroup) -> Vec<u8> { ... } fn public_key_point_to_byte(point: &Self::PublicKeyGroup) -> Vec<u8> { ... }
}
Expand description

A weakening of pairing::Engine to permit transposing the groups.

You cannot transpose the two groups in a pairing::Engine without first providing panicing implementations of pairing::PrimeField for Engine::Fqe, which is not a prime field, and second, providing wrapper types for the projective and affine group representations, which makes interacting with the original pairing::Engine annoying. This trait merely replicates transposable functionality from pairing::Engine by removing the fields of definition, but leaves the actual BLS signature scheme to wrapper types.

We also extract two functions users may with to override: random scalar generation and hashing to the singature curve.

Required Associated Constants§

Required Associated Types§

Source

type Engine: Pairing

Source

type Scalar: PrimeField

Source

type PublicKeyGroupBaseField: Field

Group where BLS public keys live

You should take this to be the Engine::G1 curve usually becuase all verifiers perform additions on this curve, or even scalar multiplicaitons with delinearization.

Source

type PublicKeyGroupAffine: AffineRepr<ScalarField = Self::Scalar, Group = Self::PublicKeyGroup> + From<Self::PublicKeyGroup> + Into<Self::PublicKeyGroup> + Into<Self::PublicKeyPrepared>

Source

type PublicKeyGroup: CurveGroup<Affine = Self::PublicKeyGroupAffine, ScalarField = Self::Scalar, BaseField = Self::PublicKeyGroupBaseField> + From<Self::PublicKeyGroupAffine> + Into<Self::PublicKeyGroupAffine> + MulAssign<Self::Scalar>

Source

type PublicKeyPrepared: Default + Clone + Send + Sync + Debug + From<Self::PublicKeyGroupAffine>

Source

type SignatureGroupBaseField: Field

Group where BLS signatures live

You should take this to be the Engine::G2 curve usually becuase only aggregators perform additions on this curve, or scalar multiplicaitons with delinearization.

Source

type SignatureGroupAffine: AffineRepr<ScalarField = Self::Scalar, Group = Self::SignatureGroup> + From<Self::SignatureGroup> + Into<Self::SignatureGroup> + Into<Self::SignaturePrepared>

Source

type SignatureGroup: CurveGroup<Affine = Self::SignatureGroupAffine, ScalarField = Self::Scalar, BaseField = Self::SignatureGroupBaseField> + Into<Self::SignatureGroupAffine> + From<Self::SignatureGroupAffine> + MulAssign<Self::Scalar>

Source

type SignaturePrepared: Default + Clone + Send + Sync + Debug + From<Self::SignatureGroupAffine>

Source

type HashToSignatureField: HashToField<Self::SignatureGroupBaseField>

Source

type MapToSignatureCurve: MapToCurve<Self::SignatureGroup>

Required Methods§

Source

fn hash_to_curve_map() -> MapToCurveBasedHasher<Self::SignatureGroup, Self::HashToSignatureField, Self::MapToSignatureCurve>

getter function for the hash to curve map

Source

fn miller_loop<'a, I>(i: I) -> MillerLoopOutput<Self::Engine>
where Self::PublicKeyPrepared: 'a, Self::SignaturePrepared: 'a, I: IntoIterator<Item = &'a (<Self as EngineBLS>::PublicKeyPrepared, Self::SignaturePrepared)>,

Run the Miller loop from Engine but orients its arguments to be a SignatureGroup and PublicKeyGroup.

Source

fn pairing<G1, G2>(p: G1, q: G2) -> <Self::Engine as Pairing>::TargetField
where G1: Into<<Self::PublicKeyGroup as CurveGroup>::Affine>, G2: Into<<Self::SignatureGroup as CurveGroup>::Affine>,

Performs a pairing operation e(p, q) by calling Engine::pairing but orients its arguments to be a PublicKeyGroup and SignatureGroup.

Source

fn minus_generator_of_public_key_group_prepared() -> Self::PublicKeyPrepared

Prepared negative of the generator of the public key curve.

Provided Methods§

Source

fn generate<R: Rng + RngCore>(rng: &mut R) -> Self::Scalar

Generate a random scalar for use as a secret key.

Source

fn hash_to_signature_curve<M: Borrow<[u8]>>(message: M) -> Self::SignatureGroup

Hash one message to the signature curve.

Source

fn final_exponentiation( e: MillerLoopOutput<Self::Engine>, ) -> Option<PairingOutput<Self::Engine>>

Perform final exponentiation on the result of a Miller loop.

Source

fn verify_prepared<'a, I>(signature: Self::SignaturePrepared, inputs: I) -> bool
where Self::PublicKeyPrepared: 'a, Self::SignaturePrepared: 'a, I: IntoIterator<Item = &'a (Self::PublicKeyPrepared, Self::SignaturePrepared)>,

Implement verification equation for aggregate BLS signatures provided as prepared points

This low-level routine does no verification of critical security properties like message distinctness. It exists purely to simplify replacing mid-level routines with optimized variants, like versions that cache public key preperation or use fewer pairings.

Source

fn generator_of_signature_group() -> Self::SignatureGroup

return the generator of signature group

Source

fn prepare_public_key( g: impl Into<Self::PublicKeyGroupAffine>, ) -> Self::PublicKeyPrepared

Process the public key to be use in pairing. This has to be implemented by the type of BLS system implementing the engine by calling either prepare_g1 or prepare_g2 based on which group is used by the signature system to host the public key

Source

fn prepare_signature( g: impl Into<Self::SignatureGroupAffine>, ) -> Self::SignaturePrepared

Process the signature to be use in pairing. This has to be implemented by the type of BLS system implementing the engine by calling either prepare_g1 or prepare_g2 based on which group is used by the signature system to host the public key

Source

fn signature_point_to_byte(point: &Self::SignatureGroup) -> Vec<u8>

Serialization helper for various sigma protocols

Source

fn public_key_point_to_byte(point: &Self::PublicKeyGroup) -> Vec<u8>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<E: Pairing, P: Bls12Config + CurveExtraConfig> EngineBLS for TinyBLS<E, P>

Source§

impl<E: Pairing, P: Bls12Config + CurveExtraConfig> EngineBLS for UsualBLS<E, P>