From ff94f66d8e2b6e6efd89bfd2388d5a2c4c5887f2 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 25 May 2021 21:23:15 +0100 Subject: [PATCH] zcash_address: Fix padding and F4Jumble positions in Address::to_bytes These need to be applied to the entire UA encoding, not to the encoding of each individual receiver. --- components/zcash_address/src/kind/unified.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/zcash_address/src/kind/unified.rs b/components/zcash_address/src/kind/unified.rs index 560208802d..5c7b5e6a89 100644 --- a/components/zcash_address/src/kind/unified.rs +++ b/components/zcash_address/src/kind/unified.rs @@ -120,23 +120,23 @@ impl TryFrom<&[u8]> for Address { impl Address { /// Returns the raw encoding of this Unified Address. pub(crate) fn to_bytes(&self) -> Vec { - self.0 + let encoded: Vec<_> = self + .0 .iter() .flat_map(|receiver| { let addr = receiver.addr(); // Holds by construction. assert!(addr.len() < 256); - let encoded: Vec<_> = iter::empty() + iter::empty() .chain(Some(receiver.typecode())) .chain(Some(addr.len() as u8)) .chain(addr.into_iter().cloned()) - .chain(iter::repeat(0).take(PADDING_LEN)) - .collect(); - - f4jumble::f4jumble(&encoded).unwrap() }) - .collect() + .chain(iter::repeat(0).take(PADDING_LEN)) + .collect(); + + f4jumble::f4jumble(&encoded).unwrap() } }