zcash / librustzcash

Rust-language assets for Zcash
Other
335 stars 250 forks source link

`zcash_address`: Fix raw encoding representation #462

Closed str4d closed 2 years ago

str4d commented 2 years ago

ZIP 316 defines the raw encoding of a UA as the concatenation of the TLV-encoded receivers. This is unjumbled and without padding, and has no dependency on the network.

zcash_address defines a (fortunately crate-private) unified::Address::to_bytes method that is documented as returning the raw encoding. However, it appends padding and then outputs the jumbled data.

We should fix unified::Address::to_bytes to return the raw encoding, and then have a separate (also crate-private) method to return the jumbled encoding that is used within Bech32m. Then if we end up needing to expose the raw encoding at some later stage, it is the correct one.

nuttycom commented 2 years ago

This looks like it was fixed in 914363f9b75f713ba1215662e57eb3996f051022

nuttycom commented 2 years ago

On the principle of YAGNI, I'm going to say that this is done; if we need to expose the raw encoding as a function that returns bytes, we can add that later.