From 3a5e66f992a717778c459741e75a48cc0e264864 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 13 Dec 2024 07:48:00 +0000 Subject: [PATCH] Adjust cases in `pczt::Spend::fvk_for_validation` Co-authored-by: Daira-Emma Hopwood --- src/pczt/verify.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pczt/verify.rs b/src/pczt/verify.rs index 5ab0b1801..721a93e6d 100644 --- a/src/pczt/verify.rs +++ b/src/pczt/verify.rs @@ -38,14 +38,11 @@ impl super::Spend { expected_fvk: Option<&'a FullViewingKey>, ) -> Result<&'a FullViewingKey, VerifyError> { match (expected_fvk, self.fvk.as_ref(), self.value.as_ref()) { - // Dummy notes use random FVKs, which must be provided. - (_, Some(fvk), Some(value)) if value.inner() == 0 => Ok(fvk), - (_, None, Some(value)) if value.inner() == 0 => Err(VerifyError::MissingFullViewingKey), - // If the FVK field has been pruned, assume the caller provided the correct FVK. - (Some(expected_fvk), None, _) => Ok(expected_fvk), - // This is not a dummy note; if the FVK field is present, it must match. (Some(expected_fvk), Some(fvk), _) if fvk == expected_fvk => Ok(fvk), + // `expected_fvk` is ignored if the spent note is a dummy note. + (Some(_), Some(fvk), Some(value)) if value.inner() == 0 => Ok(fvk), (Some(_), Some(_), _) => Err(VerifyError::MismatchedFullViewingKey), + (Some(expected_fvk), None, _) => Ok(expected_fvk), (None, Some(fvk), _) => Ok(fvk), (None, None, _) => Err(VerifyError::MissingFullViewingKey), }