Trait enr::EnrKey

source ·
pub trait EnrKey: Send + Sync + Unpin + 'static {
    type PublicKey: EnrPublicKey + Clone;

    // Required methods
    fn sign_v4(&self, msg: &[u8]) -> Result<Vec<u8>, SigningError>;
    fn public(&self) -> Self::PublicKey;
    fn enr_to_public(
        content: &BTreeMap<Vec<u8>, Bytes>,
    ) -> Result<Self::PublicKey, DecoderError>;
}
Expand description

The trait required for a key to sign and modify an ENR record.

Required Associated Types§

Required Methods§

source

fn sign_v4(&self, msg: &[u8]) -> Result<Vec<u8>, SigningError>

Performs ENR-specific signing for the v4 identity scheme.

source

fn public(&self) -> Self::PublicKey

Returns the public key associated with current key pair.

source

fn enr_to_public( content: &BTreeMap<Vec<u8>, Bytes>, ) -> Result<Self::PublicKey, DecoderError>

Provides a method to decode a raw public key from an ENR BTreeMap to a useable public key.

This method allows a key type to decode the raw bytes in an ENR to a useable EnrPublicKey. It takes the ENR’s BTreeMap and returns a public key.

Note: This specifies the supported key schemes for an ENR.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl EnrKey for SigningKey

source§

fn sign_v4(&self, msg: &[u8]) -> Result<Vec<u8>, SigningError>

Performs ENR-specific signing.

Using ed25519 keys do not currently follow the v4 identity scheme, which dictates secp256k1 keys should be used.

source§

fn public(&self) -> Self::PublicKey

Returns the public key associated with the private key.

source§

fn enr_to_public( content: &BTreeMap<Vec<u8>, Bytes>, ) -> Result<Self::PublicKey, DecoderError>

Decodes the raw bytes of an ENR’s content into a public key if possible.

§

type PublicKey = VerifyingKey

source§

impl EnrKey for SecretKey

§

type PublicKey = PublicKey

source§

fn sign_v4(&self, msg: &[u8]) -> Result<Vec<u8>, SigningError>

source§

fn public(&self) -> Self::PublicKey

source§

fn enr_to_public( content: &BTreeMap<Vec<u8>, Bytes>, ) -> Result<Self::PublicKey, DecoderError>

source§

impl EnrKey for SigningKey

§

type PublicKey = VerifyingKey<Secp256k1>

source§

fn sign_v4(&self, msg: &[u8]) -> Result<Vec<u8>, SigningError>

source§

fn public(&self) -> Self::PublicKey

source§

fn enr_to_public( content: &BTreeMap<Vec<u8>, Bytes>, ) -> Result<Self::PublicKey, DecoderError>

Implementors§