Enum enr::CombinedKey

source ·
pub enum CombinedKey {
    Secp256k1(SigningKey),
    Ed25519(SigningKey),
}
Expand description

A standard implementation of the EnrKey trait used to sign and modify ENR records. The variants here represent the currently supported in-built signing schemes.

Variants§

§

Secp256k1(SigningKey)

An secp256k1 keypair.

§

Ed25519(SigningKey)

An Ed25519 keypair.

Implementations§

source§

impl CombinedKey

source

pub fn generate_secp256k1() -> Self

Generates a new secp256k1 key.

source

pub fn generate_ed25519() -> Self

Generates a new ed25510 key.

source

pub fn secp256k1_from_bytes(bytes: &mut [u8]) -> Result<Self, DecoderError>

Imports a secp256k1 from raw bytes in any format.

source

pub fn ed25519_from_bytes(bytes: &mut [u8]) -> Result<Self, DecoderError>

Imports an ed25519 key from raw 32 bytes.

source

pub fn encode(&self) -> Vec<u8>

Encodes the CombinedKey into compressed (where possible) bytes.

Trait Implementations§

source§

impl EnrKey for CombinedKey

source§

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

Performs ENR-specific signing.

Note: that this library supports a number of signing algorithms. The ENR specification currently lists the v4 identity scheme which requires the secp256k1 signing algorithm. Using secp256k1 keys follow the v4 identity scheme, using other types do not, although they are supported.

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 = CombinedPublicKey

source§

impl From<SigningKey<Secp256k1>> for CombinedKey

source§

fn from(secret_key: SigningKey) -> Self

Converts to this type from the input type.
source§

impl From<SigningKey> for CombinedKey

source§

fn from(keypair: SigningKey) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V