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

Upgrade orchard to v0.5 and integrate corresponding librustzcash upgrade (new) #75

Merged
merged 4 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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 = { version = "0.4", git = "https://github.com/QED-it/librustzcash.git", tag = "orchard_zsa_0.5.0_compatible" }
1 change: 0 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,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;
Expand Down
26 changes: 4 additions & 22 deletions src/note_encryption_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::{
OutgoingViewingKey, PreparedEphemeralPublicKey, PreparedIncomingViewingKey, SharedSecret,
},
note::{ExtractedNoteCommitment, Nullifier, RandomSeed},
spec::diversify_hash,
value::{NoteValue, ValueCommitment},
Address, Note,
};
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(&note, &note.recipient(), memo);
let mut plaintext = OrchardDomainV3::note_plaintext_bytes(&note, memo);

// Decode.
let domain = OrchardDomainV3 { rho: note.rho() };
Expand Down Expand Up @@ -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!(
Expand Down
Loading