diff --git a/src/lib.rs b/src/lib.rs index 788c4e3..b4b8e4b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,7 +82,7 @@ pub struct NotePlaintextBytes(pub [u8; NOTE_PLAINTEXT_SIZE]); pub struct OutPlaintextBytes(pub [u8; OUT_PLAINTEXT_SIZE]); #[derive(Copy, Clone, PartialEq, Eq)] -pub enum NoteValidity { +enum NoteValidity { Valid, Invalid, } @@ -148,11 +148,6 @@ pub trait Domain { fn epk(ephemeral_key: &EphemeralKeyBytes) -> Option; - fn check_epk_bytes NoteValidity>( - note: &Self::Note, - check: F, - ) -> NoteValidity; - fn cmstar(note: &Self::Note) -> Self::ExtractedCommitment; fn parse_note_plaintext_without_memo_ivk( @@ -464,7 +459,7 @@ fn check_note_validity( cmstar_bytes: &D::ExtractedCommitmentBytes, ) -> NoteValidity { if &D::ExtractedCommitmentBytes::from(&D::cmstar(¬e)) == cmstar_bytes { - D::check_epk_bytes(¬e, |derived_esk| { + if let Some(derived_esk) = D::derive_esk(note) { if D::epk_bytes(&D::ka_derive_public(¬e, &derived_esk)) .ct_eq(&ephemeral_key) .into() @@ -473,7 +468,10 @@ fn check_note_validity( } else { NoteValidity::Invalid } - }) + } else { + // Before ZIP 212 + NoteValidity::Valid + } } else { // Published commitment doesn't match calculated commitment NoteValidity::Invalid