Skip to main content

EnrKey

Trait EnrKey 

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, Error>;
}
Expand description

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

Required Associated Types§

type PublicKey: EnrPublicKey + Clone

Required Methods§

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

Performs ENR-specific signing for the v4 identity scheme.

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

Returns the public key associated with current key pair.

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

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

Implementations on Foreign Types§

§

impl EnrKey for SecretKey

§

type PublicKey = PublicKey

§

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

§

fn public(&self) -> <SecretKey as EnrKey>::PublicKey

§

fn enr_to_public( content: &BTreeMap<Vec<u8>, Bytes>, ) -> Result<<SecretKey as EnrKey>::PublicKey, Error>

§

impl EnrKey for SigningKey

§

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.

§

fn public(&self) -> <SigningKey as EnrKey>::PublicKey

Returns the public key associated with the private key.

§

fn enr_to_public( content: &BTreeMap<Vec<u8>, Bytes>, ) -> Result<<SigningKey as EnrKey>::PublicKey, Error>

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

§

type PublicKey = VerifyingKey

§

impl EnrKey for SigningKey<Secp256k1>

§

type PublicKey = VerifyingKey<Secp256k1>

§

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

§

fn public(&self) -> <SigningKey<Secp256k1> as EnrKey>::PublicKey

§

fn enr_to_public( content: &BTreeMap<Vec<u8>, Bytes>, ) -> Result<<SigningKey<Secp256k1> as EnrKey>::PublicKey, Error>

Implementors§

§

impl EnrKey for CombinedKey

§

type PublicKey = CombinedPublicKey