Skip to content

Commit

Permalink
Adjust cases in pczt::Spend::fvk_for_validation
Browse files Browse the repository at this point in the history
Co-authored-by: Daira-Emma Hopwood <[email protected]>
  • Loading branch information
str4d and daira authored Dec 13, 2024
1 parent 3d951b4 commit 3a5e66f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/pczt/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down

0 comments on commit 3a5e66f

Please sign in to comment.