enr

Trait 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.

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.

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.

Source§

type PublicKey = VerifyingKey

Source§

impl EnrKey for SecretKey

Source§

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

Source§

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§