Commit Graph

97 Commits

Author SHA1 Message Date
Kris Nuttycombe 75591047f7 Separates raw encoding from jumbling of unified container contents. 2021-12-02 09:04:46 -07:00
therealyingtong a6e6f8ace2 kind::unified: Make address::Address available outside the crate. 2021-11-30 09:05:24 -05:00
therealyingtong da1c6224f8 kind::unified: Split Unified trait into FromReceivers, ToReceivers.
This allows us to move to_bytes() into the private::SealedContainer
trait without introducing a circular dependency. This also lets us
move the Receivers type to a public trait.
2021-11-29 14:21:43 -05:00
therealyingtong c31db1b839 Move HRPs into from public Unified trait to SealedContainer trait.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-11-29 13:49:24 -05:00
therealyingtong b8ff3d2d48 kind::unified: Introduce private::SealedContainer and Unified traits.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-11-28 18:56:24 -05:00
therealyingtong 18393eefa8 kind::unified: Introduce private::SealedReceiver trait.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-11-28 18:55:37 -05:00
therealyingtong 406e62e7e5 [move-only] Move Receiver and test code into kind::unified::address.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-11-28 17:09:59 -05:00
Jack Grigg e13e746e8a Move F4Jumble implementation into f4jumble crate 2021-09-22 14:21:48 +01:00
Kris Nuttycombe 3c42fcff6d Fix upper CompactSize bound.
Co-authored-by: str4d <jack@electriccoin.co>
2021-09-15 10:27:27 -06:00
Kris Nuttycombe 4b67977ec0 Use u32 for typecodes.
Co-authored-by: str4d <jack@electriccoin.co>
2021-09-14 18:08:21 -06:00
Kris Nuttycombe 74d430102a Add test vector checking for long f4jumble values. 2021-09-14 17:11:37 -06:00
Daira Hopwood f9522ed2bc
Add a test that uses the second bytes of the index to G 2021-09-13 14:41:45 +01:00
str4d eca002dae0
zcash_address: Assert that the unified encoding is exactly consumed 2021-09-02 23:24:23 +01:00
Kris Nuttycombe ce6ac7aee6 Avoid reallocation in read_receiver. 2021-09-02 16:12:11 -06:00
Kris Nuttycombe cd3d40aab3 Update f4jumble personalization.
Also, update the test vectors for both f4jumble and
unified addresses.
2021-09-01 14:46:44 -06:00
Kris Nuttycombe b7ae3ddfe5 Modify unified address encoding to use CompactSize for typecode & address length 2021-09-01 14:46:44 -06:00
Kris Nuttycombe 2945905d52 Implement manual serialization for incremental Merkle tree components.
This also adds parsing of the legacy CommitmentTree format,
to permit easy migration of persisted data.
2021-08-05 09:32:44 -06:00
str4d c02931dc82
Tweak test comment 2021-07-30 20:35:23 +01:00
Jack Grigg 00b369b2a4 zcash_address: Include HRP inside Unified Address Padding bytes
Closes zcash/librustzcash#418.
2021-07-30 15:34:36 +01:00
Jack Grigg b875f6c34b zcash_address: Fix clippy lint by using matches! macro 2021-07-12 21:17:25 +01:00
Jack Grigg 8527dcbc32 zcash_address: Remove outdated unified::Receiver documentation
Receiver ordering is now explicitly defined by Typecode, and Receiver
is now a public type.
2021-07-12 21:11:24 +01:00
Jack Grigg 478625f72d zcash_address: Add UA test cases for truncation and invalid padding 2021-07-12 20:56:35 +01:00
Jack Grigg 77d1f0c778 zcash_address: Invert Typecode::is_shielded to Typecode::is_transparent
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-12 20:19:26 +01:00
Jack Grigg 060a15eaf8 zcash_address: Enable constructing a unified::Address from Vec<Receiver>
This enforces the same structural validity checks as at parsing time.
2021-07-12 13:39:01 +01:00
Jack Grigg 384af079a8 zcash_address: Add `unified::Address::receivers{_as_parsed}` APIs
These expose the receivers in sorted order, and in parsed order.
2021-07-12 13:35:06 +01:00
Jack Grigg b175b9bec9 zcash_address: Use preference ordering for Receivers 2021-07-12 13:34:44 +01:00
Jack Grigg 7708b27202 zcash_address: Enforce UA structural validity checks 2021-07-12 12:10:23 +01:00
Jack Grigg cd94b41d61 zcash_address: Introduce UA-specific parser error type 2021-07-12 11:45:25 +01:00
Jack Grigg 01a8dba450 zcash_address: Add a Typecode enum 2021-07-12 11:42:49 +01:00
Jack Grigg 752ee442f8 zcash_address: Add Unified Address test vectors 2021-06-18 20:06:02 +01:00
Jack Grigg af02e1142b zcash_address: Fix clippy lint 2021-06-07 00:13:21 +01:00
str4d 1590565f04
zcash_address: Minor cleanups
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-06-06 23:58:52 +01:00
str4d f36034cfac
zcash_address: Use exhaustive matching in Display impl
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-06-06 23:54:11 +01:00
Jack Grigg ff94f66d8e 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.
2021-05-25 21:24:47 +01:00
Jack Grigg ff8695de03 zcash_address: Add failing test showing unified::Address encoding bug 2021-05-25 21:24:47 +01:00
Jack Grigg e982d7211f zcash_address: Implement Unified Address encoding / decoding 2021-05-20 22:50:59 +01:00
Jack Grigg 6717cd821c Move F4Jumble implementation into zcash_address 2021-05-20 22:50:59 +01:00
Jack Grigg ae2b8bfd6d zcash_address: Replace Orchard address encodings with Unified Addresses
This commit removes the now-undefined Orchard encoding logic, and adds
the general Bech32m encoding/decoding logic for Unified Addresses. The
internal data format of Unified Addresses is not correct in this commit.
2021-05-20 22:50:59 +01:00
Jack Grigg 9f7398cd05 zcash_address: Add convert::ToAddress helper trait 2021-05-20 14:54:27 +01:00
Jack Grigg ce8797e4b1 zcash_address: impl {Clone, Copy, Eq, Hash} for ZcashAddress 2021-05-20 14:54:27 +01:00
Jack Grigg ff07eeaabb zcash_address: Document ZcashAddress::convert 2021-05-20 14:54:27 +01:00
Jack Grigg b9f704955a zcash_address: Move ZcashAddress::convert into root
Using two separate `impl ZcashAddress` blocks resulted in separate
blocks in the documentation, which is unnecessary.
2021-05-20 14:54:27 +01:00
Jack Grigg c7fcee27a2 zcash_address: Add ZcashAddress::try_from_encoded method
This places parsing documentation front and centre, while also making
it clear that `str::parse` is the anticipated main entry point.
2021-05-20 14:54:27 +01:00
Jack Grigg f7b1058171 zcash_address: Extend MaybeZcash heuristics to 64-byte addresses 2021-05-20 14:54:27 +01:00
Jack Grigg a366460157 zcash_address: ZcashAddress::convert() -> T: FromAddress
This enables easy conversion of an encoded Zcash address to a target
type, with automatic handling of Zcash address types that are not
supported by the target.
2021-05-20 14:54:27 +01:00
Jack Grigg ec77175d2b zcash_address: Add address-encoding support
This provides round-trip encoding for Zcash addresses.
2021-05-20 14:54:27 +01:00
Jack Grigg c754363c07 zcash_address: Initial empty library crate 2021-05-20 14:54:25 +01:00