pub struct CachingKeyExpander(RwLock<HashMap<OffchainPublicKey, ExpandedOffchainPublicKey>>);Expand description
A KeyExpander that memoizes the decompressed form of a packet key.
Deriving shared secrets for an outgoing packet needs the expanded key of every hop, on both the forward path and each SURB return path - up to twelve per packet. Decompression is a field exponentiation, so paying it per packet would be a measurable share of packet construction, whereas the set of relays a sender uses turns over slowly.
This memoizes a pure function of public data, so it deliberately avoids an eviction-tracking
cache: a plain map behind an RwLock costs nothing to construct and a read is a single hash,
where a managed cache would charge per-entry bookkeeping on the packet path.
Tuple Fields§
§0: RwLock<HashMap<OffchainPublicKey, ExpandedOffchainPublicKey>>Trait Implementations§
Source§impl Debug for CachingKeyExpander
impl Debug for CachingKeyExpander
Source§impl Default for CachingKeyExpander
impl Default for CachingKeyExpander
Source§fn default() -> CachingKeyExpander
fn default() -> CachingKeyExpander
Returns the “default value” for a type. Read more
Source§impl KeyExpander for CachingKeyExpander
impl KeyExpander for CachingKeyExpander
Source§fn expand(&self, key: &OffchainPublicKey) -> Result<ExpandedOffchainPublicKey>
fn expand(&self, key: &OffchainPublicKey) -> Result<ExpandedOffchainPublicKey>
Returns the expanded form of
key, failing if it is not a point on the curve.Source§fn expand_path(
&self,
keys: &[OffchainPublicKey],
) -> Result<Vec<ExpandedOffchainPublicKey>, CryptoError>
fn expand_path( &self, keys: &[OffchainPublicKey], ) -> Result<Vec<ExpandedOffchainPublicKey>, CryptoError>
Expands an entire path, in order.
Auto Trait Implementations§
impl !Freeze for CachingKeyExpander
impl !RefUnwindSafe for CachingKeyExpander
impl Send for CachingKeyExpander
impl Sync for CachingKeyExpander
impl Unpin for CachingKeyExpander
impl UnsafeUnpin for CachingKeyExpander
impl UnwindSafe for CachingKeyExpander
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more