Skip to content

Commit

Permalink
use zip_212_enforcement
Browse files Browse the repository at this point in the history
  • Loading branch information
oxarbitrage committed May 18, 2024
1 parent bca2c28 commit 3e4aa04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion zebra-chain/src/parameters/network_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub const NETWORK_UPGRADES_IN_ORDER: [NetworkUpgrade; 8] = [
///
/// Network upgrades can change the Zcash network protocol or consensus rules in
/// incompatible ways.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Ord, PartialOrd)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub enum NetworkUpgrade {
/// The Zcash protocol for a Genesis block.
Expand Down
8 changes: 7 additions & 1 deletion zebra-chain/src/primitives/zcash_note_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ pub fn decrypts_successfully(transaction: &Transaction, network: &Network, heigh

let null_sapling_ovk = sapling::keys::OutgoingViewingKey([0u8; 32]);

let zip_212_enforcement = if network_upgrade >= NetworkUpgrade::Canopy {
sapling::note_encryption::Zip212Enforcement::On
} else {
sapling::note_encryption::Zip212Enforcement::Off
};

if let Some(bundle) = alt_tx.sapling_bundle() {
for output in bundle.shielded_outputs().iter() {
let recovery = sapling::note_encryption::try_sapling_output_recovery(
&null_sapling_ovk,
output,
sapling::note_encryption::Zip212Enforcement::GracePeriod,
zip_212_enforcement,
);
if recovery.is_none() {
return false;
Expand Down

0 comments on commit 3e4aa04

Please sign in to comment.