Skip to main content

KeyExpander

Trait KeyExpander 

Source
pub trait KeyExpander: Sync {
    // Required method
    fn expand(
        &self,
        key: &OffchainPublicKey,
    ) -> Result<ExpandedOffchainPublicKey>;

    // Provided method
    fn expand_path(
        &self,
        keys: &[OffchainPublicKey],
    ) -> Result<Vec<ExpandedOffchainPublicKey>> { ... }
}
Expand description

Supplies the expanded form of a packet key to the Sphinx sender path.

Packet keys are stored, routed and compared in their compact form, but deriving the shared secrets for an outgoing packet needs the decompressed point for every hop. That is the only place in the protocol where the expanded form is required, so it is reached through this trait rather than by widening the types that carry a path.

Expansion is CPU-intensive and a sender keeps using the same handful of relays, so implementations are free to memoize; see CachingKeyExpander in hopr-protocol-hopr.

Required Methods§

Source

fn expand(&self, key: &OffchainPublicKey) -> Result<ExpandedOffchainPublicKey>

Returns the expanded form of key, failing if it is not a point on the curve.

Provided Methods§

Source

fn expand_path( &self, keys: &[OffchainPublicKey], ) -> Result<Vec<ExpandedOffchainPublicKey>>

Expands an entire path, in order.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: KeyExpander + ?Sized> KeyExpander for &T

Source§

fn expand(&self, key: &OffchainPublicKey) -> Result<ExpandedOffchainPublicKey>

Source§

fn expand_path( &self, keys: &[OffchainPublicKey], ) -> Result<Vec<ExpandedOffchainPublicKey>>

Implementors§