Skip to content

Commit

Permalink
zcash_address: Fix padding and F4Jumble positions in Address::to_bytes
Browse files Browse the repository at this point in the history
These need to be applied to the entire UA encoding, not to the encoding
of each individual receiver.
  • Loading branch information
str4d committed May 25, 2021
1 parent ff8695d commit ff94f66
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions components/zcash_address/src/kind/unified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> {
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()
}
}

Expand Down

0 comments on commit ff94f66

Please sign in to comment.