Trait KeyIdMapper

Source
pub trait KeyIdMapper<S: SphinxSuite, H: SphinxHeaderSpec> {
    // Required methods
    fn map_key_to_id(&self, key: &<S::P as Keypair>::Public) -> Option<H::KeyId>;
    fn map_id_to_public(
        &self,
        id: &H::KeyId,
    ) -> Option<<S::P as Keypair>::Public>;

    // Provided methods
    fn map_keys_to_ids(
        &self,
        keys: &[<S::P as Keypair>::Public],
    ) -> Vec<Option<H::KeyId>> { ... }
    fn map_ids_to_keys(
        &self,
        ids: &[H::KeyId],
    ) -> Vec<Option<<S::P as Keypair>::Public>> { ... }
}
Expand description

Trait that defines 1:1 mapper between key identifiers and the actual public keys.

This is used to uniquely map between short public key identifiers used in the Sphinx header, and actual routing addresses (public keys) of the nodes.

Required Methods§

Source

fn map_key_to_id(&self, key: &<S::P as Keypair>::Public) -> Option<H::KeyId>

Maps public key to its unique identifier.

Source

fn map_id_to_public(&self, id: &H::KeyId) -> Option<<S::P as Keypair>::Public>

Maps public key identifier to the actual public key.

Provided Methods§

Source

fn map_keys_to_ids( &self, keys: &[<S::P as Keypair>::Public], ) -> Vec<Option<H::KeyId>>

Convenience method to map a slice of public keys to IDs.

Source

fn map_ids_to_keys( &self, ids: &[H::KeyId], ) -> Vec<Option<<S::P as Keypair>::Public>>

Convenience method to map a slice of IDs to public keys.

Implementations on Foreign Types§

Source§

impl<S, H> KeyIdMapper<S, H> for BiHashMap<H::KeyId, <S::P as Keypair>::Public>
where S: SphinxSuite, H: SphinxHeaderSpec, <S::P as Keypair>::Public: Eq + Hash, H::KeyId: Eq + Hash,

Source§

fn map_key_to_id(&self, key: &<S::P as Keypair>::Public) -> Option<H::KeyId>

Source§

fn map_id_to_public(&self, id: &H::KeyId) -> Option<<S::P as Keypair>::Public>

Implementors§