From c88f3e1b9da0fbca51aa2947858c25c4185806d6 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Thu, 9 Mar 2023 15:22:13 -0700 Subject: [PATCH 1/2] Remove the `recipient` parameter from zcash_note_encyption::Domain::note_plaintext_bytes The `Domain::Note` type is now expected to contain information about the recipient of the note, eliminating the need to pass this information in via the encryption context. --- components/zcash_note_encryption/CHANGELOG.md | 7 +++++++ components/zcash_note_encryption/src/lib.rs | 19 +++---------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/components/zcash_note_encryption/CHANGELOG.md b/components/zcash_note_encryption/CHANGELOG.md index 676ef9bfc..58f9c777d 100644 --- a/components/zcash_note_encryption/CHANGELOG.md +++ b/components/zcash_note_encryption/CHANGELOG.md @@ -7,6 +7,13 @@ and this library adheres to Rust's notion of ## [Unreleased] +### Changed +- The `recipient` parameter has been removed from `Domain::note_plaintext_bytes`. +- The `recipient` parameter has been removed from `NoteEncryption::new`. Since + the `Domain::Note` type is now expected to contain information about the + recipient of the note, there is no longer any need to pass this information + in via the encryption context. + ## [0.2.0] - 2022-10-13 ### Added - `zcash_note_encryption::Domain`: diff --git a/components/zcash_note_encryption/src/lib.rs b/components/zcash_note_encryption/src/lib.rs index ab8f0c220..fb01b0d6d 100644 --- a/components/zcash_note_encryption/src/lib.rs +++ b/components/zcash_note_encryption/src/lib.rs @@ -180,11 +180,7 @@ pub trait Domain { /// future crate release, once [`zcash_primitives` has been refactored]. /// /// [`zcash_primitives` has been refactored]: https://github.com/zcash/librustzcash/issues/454 - fn note_plaintext_bytes( - note: &Self::Note, - recipient: &Self::Recipient, - memo: &Self::Memo, - ) -> NotePlaintextBytes; + fn note_plaintext_bytes(note: &Self::Note, memo: &Self::Memo) -> NotePlaintextBytes; /// Derives the [`OutgoingCipherKey`] for an encrypted note, given the note-specific /// public data and an `OutgoingViewingKey`. @@ -349,7 +345,6 @@ pub struct NoteEncryption { epk: D::EphemeralPublicKey, esk: D::EphemeralSecretKey, note: D::Note, - to: D::Recipient, memo: D::Memo, /// `None` represents the `ovk = ⊥` case. ovk: Option, @@ -358,18 +353,12 @@ pub struct NoteEncryption { impl NoteEncryption { /// Construct a new note encryption context for the specified note, /// recipient, and memo. - pub fn new( - ovk: Option, - note: D::Note, - to: D::Recipient, - memo: D::Memo, - ) -> Self { + pub fn new(ovk: Option, note: D::Note, memo: D::Memo) -> Self { let esk = D::derive_esk(¬e).expect("ZIP 212 is active."); NoteEncryption { epk: D::ka_derive_public(¬e, &esk), esk, note, - to, memo, ovk, } @@ -384,14 +373,12 @@ impl NoteEncryption { esk: D::EphemeralSecretKey, ovk: Option, note: D::Note, - to: D::Recipient, memo: D::Memo, ) -> Self { NoteEncryption { epk: D::ka_derive_public(¬e, &esk), esk, note, - to, memo, ovk, } @@ -412,7 +399,7 @@ impl NoteEncryption { let pk_d = D::get_pk_d(&self.note); let shared_secret = D::ka_agree_enc(&self.esk, &pk_d); let key = D::kdf(shared_secret, &D::epk_bytes(&self.epk)); - let input = D::note_plaintext_bytes(&self.note, &self.to, &self.memo); + let input = D::note_plaintext_bytes(&self.note, &self.memo); let mut output = [0u8; ENC_CIPHERTEXT_SIZE]; output[..NOTE_PLAINTEXT_SIZE].copy_from_slice(&input.0); From c696069f93ddf2d0d4919c0afc3fc679956c08a3 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Fri, 10 Mar 2023 14:13:52 -0700 Subject: [PATCH 2/2] Bump zcash_note_encryption to version 0.3.0 for release. This removes the path-based dependencies on the `zcash_note_encryption` crate in favor of using versioned dependencies locally. This better reflects the future state in which `zcash_note_encryption` is factored out of the workspace and maintained in a separate repository. --- Cargo.toml | 1 - components/zcash_note_encryption/Cargo.toml | 2 +- zcash_client_backend/Cargo.toml | 2 +- zcash_client_sqlite/Cargo.toml | 2 +- zcash_primitives/Cargo.toml | 1 - 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 953c6f8d7..8a04203e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ codegen-units = 1 [patch.crates-io] zcash_encoding = { path = "components/zcash_encoding" } -zcash_note_encryption = { path = "components/zcash_note_encryption" } orchard = { git = "https://github.com/zcash/orchard.git", rev = "6cbde279e90974201bedbd9b5ddf155e8f8b1e8e" } halo2_gadgets = { git = "https://github.com/zcash/halo2.git", rev = "642924d614305d882cc122739c59144109f4bd3f" } halo2_proofs = { git = "https://github.com/zcash/halo2.git", rev = "642924d614305d882cc122739c59144109f4bd3f" } diff --git a/components/zcash_note_encryption/Cargo.toml b/components/zcash_note_encryption/Cargo.toml index 51812e036..c2b73ac80 100644 --- a/components/zcash_note_encryption/Cargo.toml +++ b/components/zcash_note_encryption/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "zcash_note_encryption" description = "Note encryption for Zcash transactions" -version = "0.2.0" +version = "0.3.0" authors = [ "Jack Grigg ", "Kris Nuttycombe " diff --git a/zcash_client_backend/Cargo.toml b/zcash_client_backend/Cargo.toml index d42ace95e..05e3bf7a3 100644 --- a/zcash_client_backend/Cargo.toml +++ b/zcash_client_backend/Cargo.toml @@ -22,7 +22,7 @@ development = ["zcash_proofs"] [dependencies] zcash_address = { version = "0.2", path = "../components/zcash_address" } zcash_encoding = { version = "0.2", path = "../components/zcash_encoding" } -zcash_note_encryption = { version = "0.2", path = "../components/zcash_note_encryption" } +zcash_note_encryption = "0.2" zcash_primitives = { version = "0.10", path = "../zcash_primitives", default-features = false } # Dependencies exposed in a public API: diff --git a/zcash_client_sqlite/Cargo.toml b/zcash_client_sqlite/Cargo.toml index 6b3a26e64..4628d99f6 100644 --- a/zcash_client_sqlite/Cargo.toml +++ b/zcash_client_sqlite/Cargo.toml @@ -50,7 +50,7 @@ proptest = "1.0.0" rand_core = "0.6" regex = "1.4" tempfile = "3" -zcash_note_encryption = { version = "0.2", path = "../components/zcash_note_encryption" } +zcash_note_encryption = "0.2" zcash_proofs = { version = "0.10", path = "../zcash_proofs" } zcash_primitives = { version = "0.10", path = "../zcash_primitives", features = ["test-dependencies"] } zcash_address = { version = "0.2", path = "../components/zcash_address", features = ["test-dependencies"] } diff --git a/zcash_primitives/Cargo.toml b/zcash_primitives/Cargo.toml index 9f9293255..4c97690a7 100644 --- a/zcash_primitives/Cargo.toml +++ b/zcash_primitives/Cargo.toml @@ -81,7 +81,6 @@ fpe = "0.5" [dependencies.zcash_note_encryption] version = "0.2" -path = "../components/zcash_note_encryption" features = ["pre-zip-212"] [dev-dependencies]