Commit Graph

165 Commits

Author SHA1 Message Date
Kris Nuttycombe 8d34e62114 Clean up proptest generation for unified containers. 2022-01-04 15:31:20 -07:00
Kris Nuttycombe 6065c07003 Update test vectors to respect item ordering. 2022-01-04 11:48:23 -07:00
Kris Nuttycombe 2fa73ed368 Remove `Ord` instances for sealed items.
There are two canonical orderings for sealed items: preference
order and encoding order. Removing the `Ord` instances means
that a user can't accidentally choose the wrong ordering;
these orderings are replaced by explicit `preference_order`
and `encoding_order` comparison functions.
2022-01-04 11:48:23 -07:00
Kris Nuttycombe e413f12fb5 Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-01-04 11:48:23 -07:00
Kris Nuttycombe 4c4c0b1e63 Makes unified container parsing enforce typecode order.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-01-04 11:48:23 -07:00
Jack Grigg d5a375919d blake2{b,s}_simd 1 2021-12-17 23:44:06 +00:00
Jack Grigg 142a38e792 zcash_note_encryption 0.1.0 2021-12-17 20:00:46 +00:00
Jack Grigg c4cbb2dd74 zcash_note_encryption: License files and readme 2021-12-17 15:16:17 +00:00
Jack Grigg e8a755f633 zcash_note_encryption: Clean up dependencies
Several dependencies were copied over during the extraction of this
crate's logic from `zcash_primitives`, but are in fact only required for
the protocol-specific logic. We can also remove the `std` feature flag,
since we no longer have a dependency on `blake2b_simd` that needs its
`std` flag exposed for performance.
2021-12-17 15:06:22 +00:00
Jack Grigg d511a788c4 zcash_note_encryption: Crate documentation 2021-12-17 15:06:22 +00:00
Jack Grigg edc3557e30 zcash_note_encryption: Document APIs 2021-12-17 14:12:18 +00:00
Jack Grigg 5409291b0c zcash_note_encryption: Add `doc_cfg` annotations 2021-12-17 14:12:18 +00:00
Jack Grigg 76f364593a zcash_note_encryption: Constrain outgoing ciphertext size
This replaces a length assertion, making the API more predictable.
2021-12-17 05:23:53 +00:00
Jack Grigg 4fcd83d74e zcash_note_encryption: Constrain `ShieldedOutput` ciphertext size
Previously we were returning the ciphertext as a slice, and then
asserting its length within the APIs the caller passed it into. Now
instead we require the caller to define whether or not the output is
compact, to make the API more predictable.

This doesn't place any additional constraints on users of this trait,
because the assertions already prevented a full output from being passed
to a compact trial decryption API.
2021-12-17 05:23:53 +00:00
Jack Grigg d54e1f0bf7 zcash_note_encryption: Remove `Domain::check_epk_bytes`
`Domain::derive_esk` provides sufficient information to determine
whether or not we need to enforce `EphemeralSecretKey`-specific
decryption checks, as it returns `None` for pre-ZIP 212 notes.
2021-12-17 04:30:57 +00:00
Jack Grigg 7c1687dcc1 zcash_note_encryption: Use `*PlaintextBytes` structs in `Domain` APIs
`Domain::parse_note_plaintext_without_memo_ivk` is used with both full
note plaintexts and compact notes, so continues to accept a slice. For
all other `Domain` APIs, we constrain the input to `NotePlaintextBytes`
or `OutPlaintextBytes` as appropriate.
2021-12-17 04:30:57 +00:00
Jack Grigg 01c768dbeb zcash_note_encryption: Place pre-ZIP 212 APIs behind a feature flag 2021-12-17 04:30:57 +00:00
Kris Nuttycombe fd786f28b7 Ensure unrecognized prefixes map to ParseError::NotZcash 2021-12-07 12:59:41 -07:00
Kris Nuttycombe 4e906508ae Make unified container construction correctly sort items.
Newly constructed unified containers now obey ZIP 316 item
ordering rules, while parsing and reserialization preserve
order.
2021-12-07 11:07:15 -07:00
Kris Nuttycombe e7c57e4a02 Use `from` instead of a possibly-future-incompatible cast 2021-12-07 09:25:50 -07:00
Kris Nuttycombe cc8c2868eb Ensure that unknown typecodes don't duplicate known typecodes. 2021-12-07 09:16:55 -07:00
Kris Nuttycombe cccc493067 Add unknown typecodes to UA proptests. 2021-12-06 11:34:12 -07:00
Kris Nuttycombe e30f4bd094 Fix incorrect ordering of receivers in writing raw encoding. 2021-12-06 08:32:07 -07:00
Kris Nuttycombe 9144aaef0a Ensure shrinking will work properly for ufvk proptests. 2021-12-03 15:27:25 -07:00
Kris Nuttycombe fd300e0061 Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-12-03 14:26:02 -07:00
Kris Nuttycombe a6420858f4 Fix clippy lints. 2021-12-03 14:21:40 -07:00
Kris Nuttycombe 76082e4287 Return correct errors for incorrectly encoded unified containers. 2021-12-03 14:15:02 -07:00
Kris Nuttycombe ba3ff42e13 Address comments from code review. 2021-12-03 12:07:26 -07:00
Kris Nuttycombe 8cf43d255f Fix clippy complaints. 2021-12-02 14:44:38 -07:00
Kris Nuttycombe 914363f9b7 Rename "to_bytes" internal method to "to_jumbled_bytes" 2021-12-02 14:44:38 -07:00
Kris Nuttycombe 2ffe5963a1 Fix the byte length of Sapling and Transparent UFVK components. 2021-12-02 14:44:38 -07:00
Kris Nuttycombe 7e629db29f Adds high-level encoding and decoding functions for unified types.
This renames the `FromReceivers` trait to `UnifiedEncoding` and makes
its public methods (as well as the private to_bytes method) function in
terms of network values rather than explicit HRP arguments. It also adds
high-level encoding and decoding methods that handle conversion to and
from the Bech32m-encoded transport format for all supported types, and
then delegates to these from locations that previously used lower-level
utilities.
2021-12-02 14:44:38 -07:00
Kris Nuttycombe 3b70731cc4 Adds `unified::SealedContainer::network_hrp` 2021-12-02 14:44:38 -07:00
Kris Nuttycombe 7d801cf71b Expose unified addresses, IVKs and Fvks 2021-12-02 14:44:38 -07:00
ying tong c8993881ae kind::unified: Make ivk::Ivk, fvk::Fvk available outside the crate.
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2021-12-02 14:44:38 -07:00
therealyingtong c4ceb8e9df Test both Sapling and Orchard receivers in arb_shielded_* proptests. 2021-12-02 14:44:38 -07:00
therealyingtong b4c1ca11c9 Remove P2SH variant for FVK and IVK. 2021-12-02 14:44:38 -07:00
therealyingtong cb06bbcf05 unified::fvk::tests: Add unit tests for parsing UFVK. 2021-12-02 14:44:38 -07:00
therealyingtong 194a790335 unified::fvk: Parse unified full viewing keys. 2021-12-02 14:44:38 -07:00
therealyingtong fc82523e31 unified::ivk::tests: Add unit tests for parsing UIVK. 2021-12-02 14:44:38 -07:00
therealyingtong 7cd12f4ee2 unified::ivk: Parse unified incoming viewing keys. 2021-12-02 14:44:38 -07:00
Kris Nuttycombe 1c32172209
Merge pull request #460 from zcash/unified-encoding-logic
kind::unified: Extract common unified encoding logic.
2021-12-02 12:43:27 -07:00
Kris Nuttycombe 566c973ea7
Fix comment in components/zcash_address/src/kind/unified.rs
Co-authored-by: str4d <jack@electriccoin.co>
2021-12-02 11:35:54 -07:00
Kris Nuttycombe 82be04dfaf Generalize the naming of unified containers and items. 2021-12-02 09:10:03 -07:00
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