Skip to content

Commit 26d9b1d

Browse files
committed
convenience methods
1 parent 65530f2 commit 26d9b1d

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/header/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,7 @@ impl SphinxHeader {
352352
let shared_secret = PublicKey::from(shared_secret_bytes);
353353

354354
// the rest are for the encapsulated routing info
355-
let encapsulated_routing_info_bytes = bytes[32..HEADER_SIZE].to_vec();
356-
357-
let routing_info = Box::new(EncapsulatedRoutingInformation::from_bytes(
358-
&encapsulated_routing_info_bytes,
359-
)?);
355+
let routing_info = Box::new(EncapsulatedRoutingInformation::from_bytes(&bytes[32..])?);
360356

361357
Ok(SphinxHeader {
362358
shared_secret,

src/surb/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl SURBMaterial {
9999
}
100100

101101
#[allow(non_snake_case)]
102-
pub fn construct_legacy_SURB(self) -> Result<SURB> {
102+
pub fn construct_SURB(self) -> Result<SURB> {
103103
let surb_initial_secret = StaticSecret::random();
104104
SURB::new(surb_initial_secret, self)
105105
}
@@ -224,6 +224,21 @@ impl SURB {
224224
payload_keys_material,
225225
})
226226
}
227+
228+
pub fn first_hop(&self) -> NodeAddressBytes {
229+
self.first_hop_address
230+
}
231+
232+
pub fn materials_count(&self) -> usize {
233+
match &self.payload_keys_material {
234+
PayloadKeysMaterial::DerivedKeys(keys) => keys.len(),
235+
PayloadKeysMaterial::KeySeeds(seeds) => seeds.len(),
236+
}
237+
}
238+
239+
pub fn uses_key_seeds(&self) -> bool {
240+
matches!(self.payload_keys_material, PayloadKeysMaterial::KeySeeds(_))
241+
}
227242
}
228243

229244
#[cfg(test)]

0 commit comments

Comments
 (0)