BlsPublicKeyType

Trait BlsPublicKeyType 

Source
pub trait BlsPublicKeyType: 'static {
    type Buffer: Clone + Debug + PartialEq + Sized + Zeroize;
    type BufferSize: ArrayLength<u8>;
    type BufferSizeWide: ArrayLength<u8>;

    const ALG_TYPE: BlsCurves;
    const JWK_CURVE: &'static str;
    const JWK_CURVE_OKP: &'static str;

    // Required methods
    fn from_secret_scalar(secret: &Scalar) -> Self::Buffer;
    fn from_public_bytes(key: &[u8]) -> Result<Self::Buffer, Error>;
    fn with_bytes<O>(
        buf: &Self::Buffer,
        alg: Option<KeyAlg>,
        f: impl FnOnce(&[u8]) -> O,
    ) -> O;
    fn with_bytes_uncompressed<O>(
        buf: &Self::Buffer,
        alg: Option<KeyAlg>,
        f: impl FnOnce(&[u8]) -> O,
    ) -> O;

    // Provided method
    fn get_jwk_curve(_alg: Option<KeyAlg>) -> &'static str { ... }
}
Available on crate feature bls only.
Expand description

Trait implemented by supported BLS public key types

Required Associated Constants§

Source

const ALG_TYPE: BlsCurves

The associated algorithm type

Source

const JWK_CURVE: &'static str

The associated JWK curve name

Source

const JWK_CURVE_OKP: &'static str

The associated JWK curve name (OKP variant)

Required Associated Types§

Source

type Buffer: Clone + Debug + PartialEq + Sized + Zeroize

The concrete key representation

Source

type BufferSize: ArrayLength<u8>

The size of the serialized compressed public key

Source

type BufferSizeWide: ArrayLength<u8>

The size of the serialized uncompressed public key

Required Methods§

Source

fn from_secret_scalar(secret: &Scalar) -> Self::Buffer

Initialize from the secret scalar

Source

fn from_public_bytes(key: &[u8]) -> Result<Self::Buffer, Error>

Initialize from the compressed bytes

Source

fn with_bytes<O>( buf: &Self::Buffer, alg: Option<KeyAlg>, f: impl FnOnce(&[u8]) -> O, ) -> O

Access the bytes of the public key

Source

fn with_bytes_uncompressed<O>( buf: &Self::Buffer, alg: Option<KeyAlg>, f: impl FnOnce(&[u8]) -> O, ) -> O

Access the coordinates of the public key

Provided Methods§

Source

fn get_jwk_curve(_alg: Option<KeyAlg>) -> &'static str

Get the JWK curve for a specific key algorithm

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 BlsPublicKeyType for G1

Source§

const ALG_TYPE: BlsCurves = BlsCurves::G1

Source§

const JWK_CURVE: &'static str = "BLS12381G1"

Source§

const JWK_CURVE_OKP: &'static str = "BLS12381_G1"

Source§

type Buffer = G1Affine

Source§

type BufferSize = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B0>, B0>

Source§

type BufferSizeWide = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B0>, B0>, B0>

Source§

impl BlsPublicKeyType for G2

Source§

const ALG_TYPE: BlsCurves = BlsCurves::G2

Source§

const JWK_CURVE: &'static str = "BLS12381G2"

Source§

const JWK_CURVE_OKP: &'static str = "BLS12381_G2"

Source§

type Buffer = G2Affine

Source§

type BufferSize = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B0>, B0>, B0>

Source§

type BufferSizeWide = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B0>, B0>, B0>, B0>