From f49be89f351806c25387e2a83a6e0ee089c95ae8 Mon Sep 17 00:00:00 2001 From: Dmitry Demin Date: Mon, 19 Jun 2023 10:01:51 +0200 Subject: [PATCH 1/3] Update code to refer to the upgraded version of librustzcash and reflect the corresponding changes --- Cargo.toml | 6 +++--- src/builder.rs | 1 - src/note_encryption_v3.rs | 26 ++++---------------------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c8c88fe56..006f98c3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ reddsa = "0.5" nonempty = "0.7" serde = { version = "1.0", features = ["derive"] } subtle = "2.3" -zcash_note_encryption = "0.2" +zcash_note_encryption = "0.4" incrementalmerkletree = "0.4" # Logging @@ -57,7 +57,7 @@ criterion = "0.3" halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "zsa1", features = ["test-dependencies"] } hex = "0.4" proptest = "1.0.0" -zcash_note_encryption = { version = "0.2", features = ["pre-zip-212"] } +zcash_note_encryption = { version = "0.4", features = ["pre-zip-212"] } incrementalmerkletree = { version = "0.4", features = ["test-dependencies"] } [target.'cfg(unix)'.dev-dependencies] @@ -92,4 +92,4 @@ debug = true debug = true [patch.crates-io] -zcash_note_encryption = { git = "https://github.com/QED-it/librustzcash.git", rev = "07c377ddedf71ab7c7a266d284b054a2dafc2ed4" } +zcash_note_encryption = { git = "https://github.com/QED-it/librustzcash.git", branch = "upgrade_for_orchard_v05_new" } diff --git a/src/builder.rs b/src/builder.rs index 70cd3dc77..bf3c7b581 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -287,7 +287,6 @@ impl ActionInfo { let encryptor = OrchardNoteEncryption::new( self.output.ovk, note, - self.output.recipient, self.output.memo.unwrap_or_else(|| { let mut memo = [0; 512]; memo[0] = 0xf6; diff --git a/src/note_encryption_v3.rs b/src/note_encryption_v3.rs index 4333f6dba..7594b588d 100644 --- a/src/note_encryption_v3.rs +++ b/src/note_encryption_v3.rs @@ -16,7 +16,6 @@ use crate::{ OutgoingViewingKey, PreparedEphemeralPublicKey, PreparedIncomingViewingKey, SharedSecret, }, note::{ExtractedNoteCommitment, Nullifier, RandomSeed}, - spec::diversify_hash, value::{NoteValue, ValueCommitment}, Address, Note, }; @@ -253,11 +252,7 @@ impl Domain for OrchardDomainV3 { secret.kdf_orchard(ephemeral_key) } - fn note_plaintext_bytes( - note: &Self::Note, - _: &Self::Recipient, - memo: &Self::Memo, - ) -> NotePlaintextBytes { + fn note_plaintext_bytes(note: &Self::Note, memo: &Self::Memo) -> NotePlaintextBytes { let mut np = [0u8; NOTE_PLAINTEXT_SIZE_V3]; np[0] = 0x03; np[1..12].copy_from_slice(note.recipient().diversifier().as_array()); @@ -312,22 +307,9 @@ impl Domain for OrchardDomainV3 { fn parse_note_plaintext_without_memo_ovk( &self, pk_d: &Self::DiversifiedTransmissionKey, - esk: &Self::EphemeralSecretKey, - ephemeral_key: &EphemeralKeyBytes, plaintext: &CompactNotePlaintextBytes, ) -> Option<(Self::Note, Self::Recipient)> { - orchard_parse_note_plaintext_without_memo(self, plaintext, |diversifier| { - if esk - .derive_public(diversify_hash(diversifier.as_array())) - .to_bytes() - .0 - == ephemeral_key.0 - { - Some(*pk_d) - } else { - None - } - }) + orchard_parse_note_plaintext_without_memo(self, plaintext, |_| Some(*pk_d)) } fn extract_memo( @@ -499,7 +481,7 @@ mod tests { let memo = &crate::test_vectors::note_encryption::test_vectors()[0].memo; // Encode. - let mut plaintext = OrchardDomainV3::note_plaintext_bytes(¬e, ¬e.recipient(), memo); + let mut plaintext = OrchardDomainV3::note_plaintext_bytes(¬e, memo); // Decode. let domain = OrchardDomainV3 { rho: note.rho() }; @@ -622,7 +604,7 @@ mod tests { // Test encryption // - let ne = OrchardNoteEncryption::new_with_esk(esk, Some(ovk), note, recipient, tv.memo); + let ne = OrchardNoteEncryption::new_with_esk(esk, Some(ovk), note, tv.memo); assert_eq!(ne.encrypt_note_plaintext().as_ref(), &tv.c_enc[..]); assert_eq!( From 21d7273e49ea5f82f2def32916c390aa039af9b6 Mon Sep 17 00:00:00 2001 From: Dmitry Demin Date: Fri, 23 Jun 2023 13:06:48 +0200 Subject: [PATCH 2/3] Use tag instead of branch for zcash_note_encryption (librustzcash) ref in root Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 006f98c3a..484210f8d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,4 +92,4 @@ debug = true debug = true [patch.crates-io] -zcash_note_encryption = { git = "https://github.com/QED-it/librustzcash.git", branch = "upgrade_for_orchard_v05_new" } +zcash_note_encryption = { git = "https://github.com/QED-it/librustzcash.git", tag = "O.5_compatible" } From 62d4ae70aede0632bc9a6a6e226a55c3204aa23b Mon Sep 17 00:00:00 2001 From: Dmitry Demin Date: Fri, 23 Jun 2023 14:08:23 +0200 Subject: [PATCH 3/3] Change tag name for zcash_note_encryption in root Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 484210f8d..0e7f64ea6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,4 +92,4 @@ debug = true debug = true [patch.crates-io] -zcash_note_encryption = { git = "https://github.com/QED-it/librustzcash.git", tag = "O.5_compatible" } +zcash_note_encryption = { version = "0.4", git = "https://github.com/QED-it/librustzcash.git", tag = "orchard_zsa_0.5.0_compatible" }