Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zcash_address: Add support for ZIP 316, Revision 1 #1135

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/f4jumble/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod test_vectors_long;
/// Length of F4Jumbled message must lie in the range VALID_LENGTH.
///
/// VALID_LENGTH = 48..=4194368
pub const VALID_LENGTH: RangeInclusive<usize> = 48..=4194368;
pub const VALID_LENGTH: RangeInclusive<usize> = 38..=4194368;

/// Errors produced by F4Jumble.
#[derive(Debug)]
Expand Down
31 changes: 29 additions & 2 deletions components/zcash_address/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@ and this library adheres to Rust's notion of

## [Unreleased]

### Added
- `zcash_address::unified`:
- `Address::receivers`
- `DataTypecode`
- `Item`
- `MetadataItem`
- `MetadataTypecode`
- `Revision`
- `impl serde::{Serialize, Deserialize} for zcash_address::ZcashAddress` behind
the `serde` feature flag.

### Changed
- `zcash_address::unified`:
- `Typecode` has changed. Instead of having a variant for each receiver type,
it now has two variants, `Typecode::Data` and `Typecode::Metadata`.
- `Encoding::try_from_items` arguments have changed.
- The result type of `Container::items_as_parsed` has changed.
- The `Container` trait has an added `revision` accessor method.
- `ParseError::InvalidTypecodeValue` now wraps a `u32` instead of a `u64`.
- `ParseError` has added variant `NotUnderstood`.

### Removed
- `zcash_address::unified::Container::items` Preference order is only
significant when considering unified address receivers; use
`Address::receivers` instead.
- `zcash_address::kind::unified::address::testing`:
- `{arb_transparent_typecode,, arb_shielded_typecode, arb_typecodes, arb_unified_address_for_typecodes}`

## [0.6.2] - 2024-12-13
### Fixed
- Migrated to `f4jumble 0.1.1` to fix `no-std` support.
Expand All @@ -25,8 +53,7 @@ and this library adheres to Rust's notion of

## [0.4.0] - 2024-08-19
### Added
- `zcash_address::ZcashAddress::{can_receive_memo, can_receive_as, matches_receiver}`
- `zcash_address::unified::Address::{can_receive_memo, has_receiver_of_type, contains_receiver}`
- `zcash_address::ZcashAddress::{has_receiver_of_type, contains_receiver, contains_receiver}`
- Module `zcash_address::testing` under the `test-dependencies` feature.
- Module `zcash_address::unified::address::testing` under the
`test-dependencies` feature.
Expand Down
1 change: 1 addition & 0 deletions components/zcash_address/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ f4jumble = { version = "0.1.1", path = "../f4jumble", default-features = false,
zcash_protocol.workspace = true
zcash_encoding.workspace = true
proptest = { workspace = true, optional = true }
static_assertions.workspace = true

[dev-dependencies]
assert_matches.workspace = true
Expand Down
21 changes: 17 additions & 4 deletions components/zcash_address/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ mod tests {
use assert_matches::assert_matches;

use super::*;
use crate::{kind::unified, Network};
use crate::{
kind::unified,
unified::{Item, Receiver, Revision},
Network,
};

fn encoding(encoded: &str, decoded: ZcashAddress) {
assert_eq!(decoded.to_string(), encoded);
Expand Down Expand Up @@ -236,21 +240,30 @@ mod tests {
"u1qpatys4zruk99pg59gcscrt7y6akvl9vrhcfyhm9yxvxz7h87q6n8cgrzzpe9zru68uq39uhmlpp5uefxu0su5uqyqfe5zp3tycn0ecl",
ZcashAddress {
net: Network::Main,
kind: AddressKind::Unified(unified::Address(vec![unified::address::Receiver::Sapling([0; 43])])),
kind: AddressKind::Unified(unified::Address {
revision: Revision::R0,
receivers: vec![Item::Data(Receiver::Sapling([0; 43]))]
}),
},
);
encoding(
"utest10c5kutapazdnf8ztl3pu43nkfsjx89fy3uuff8tsmxm6s86j37pe7uz94z5jhkl49pqe8yz75rlsaygexk6jpaxwx0esjr8wm5ut7d5s",
ZcashAddress {
net: Network::Test,
kind: AddressKind::Unified(unified::Address(vec![unified::address::Receiver::Sapling([0; 43])])),
kind: AddressKind::Unified(unified::Address {
revision: Revision::R0,
receivers: vec![Item::Data(Receiver::Sapling([0; 43]))]
}),
},
);
encoding(
"uregtest15xk7vj4grjkay6mnfl93dhsflc2yeunhxwdh38rul0rq3dfhzzxgm5szjuvtqdha4t4p2q02ks0jgzrhjkrav70z9xlvq0plpcjkd5z3",
ZcashAddress {
net: Network::Regtest,
kind: AddressKind::Unified(unified::Address(vec![unified::address::Receiver::Sapling([0; 43])])),
kind: AddressKind::Unified(unified::Address {
revision: Revision::R0,
receivers: vec![Item::Data(Receiver::Sapling([0; 43]))]
}),
},
);

Expand Down
Loading
Loading