From 742e08cbd6a39c7d50a6a2baf8b86a369ca46e9d Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 14 Nov 2023 12:33:24 +0000 Subject: [PATCH 1/2] Derive Clone for SURB --- src/header/mod.rs | 3 +-- src/header/routing/destination.rs | 2 +- src/header/routing/nodes.rs | 2 +- src/surb/mod.rs | 1 + 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/header/mod.rs b/src/header/mod.rs index dcec760..f28a9df 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -34,8 +34,7 @@ pub mod routing; // 32 represents size of a MontgomeryPoint on Curve25519 pub const HEADER_SIZE: usize = 32 + HEADER_INTEGRITY_MAC_SIZE + ENCRYPTED_ROUTING_INFO_SIZE; -#[derive(Debug)] -#[cfg_attr(test, derive(Clone))] +#[derive(Debug, Clone)] pub struct SphinxHeader { pub shared_secret: SharedSecret, pub routing_info: EncapsulatedRoutingInformation, diff --git a/src/header/routing/destination.rs b/src/header/routing/destination.rs index 69282df..cdb6985 100644 --- a/src/header/routing/destination.rs +++ b/src/header/routing/destination.rs @@ -76,7 +76,7 @@ impl FinalRoutingInformation { // return D || I || PAD PaddedFinalRoutingInformation { value: std::iter::once(self.flag) - .chain(self.version.to_bytes().into_iter()) + .chain(self.version.to_bytes()) .chain(self.destination.as_bytes().iter().cloned()) .chain(self.identifier.iter().cloned()) .chain(padding.iter().cloned()) diff --git a/src/header/routing/nodes.rs b/src/header/routing/nodes.rs index 31358ff..87d5881 100644 --- a/src/header/routing/nodes.rs +++ b/src/header/routing/nodes.rs @@ -69,7 +69,7 @@ impl RoutingInformation { .chain(self.version.to_bytes().iter().cloned()) .chain(self.node_address.as_bytes_ref().iter().cloned()) .chain(self.delay.to_bytes().iter().cloned()) - .chain(self.header_integrity_mac.into_inner().into_iter()) + .chain(self.header_integrity_mac.into_inner()) .chain(self.next_routing_information.iter().cloned()) .collect() } diff --git a/src/surb/mod.rs b/src/surb/mod.rs index 7a88f57..d07a0f9 100644 --- a/src/surb/mod.rs +++ b/src/surb/mod.rs @@ -12,6 +12,7 @@ use std::fmt; /// the address of the first hop in the route of the SURB, and the key material /// used to layer encrypt the payload. #[allow(non_snake_case)] +#[derive(Clone)] pub struct SURB { SURB_header: header::SphinxHeader, first_hop_address: NodeAddressBytes, From cbd182ca874fdeaca5d75b0652fa86ae97e63955 Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 14 Nov 2023 15:26:33 +0000 Subject: [PATCH 2/2] Derive Clone on ProcessedHeader --- src/header/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/header/mod.rs b/src/header/mod.rs index f28a9df..3f81dac 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -40,6 +40,7 @@ pub struct SphinxHeader { pub routing_info: EncapsulatedRoutingInformation, } +#[derive(Clone)] pub enum ProcessedHeader { ForwardHop(Box, NodeAddressBytes, Delay, PayloadKey), FinalHop(DestinationAddressBytes, SURBIdentifier, PayloadKey),