Update code to refer to the upgraded version of librustzcash and reflect the corresponding changes

This commit is contained in:
Dmitry Demin 2023-06-19 10:01:51 +02:00
parent 5b003f8b53
commit f49be89f35
3 changed files with 7 additions and 26 deletions

View File

@ -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" }

View File

@ -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;

View File

@ -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(&note, &note.recipient(), memo);
let mut plaintext = OrchardDomainV3::note_plaintext_bytes(&note, 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!(