zcash_note_encryption: Enforce ZIP 212 check on esk from outPlaintext
It needs to equal the esk derived from the note (for v2 note plaintexts).
Extracted from: 16627b4569
This commit is contained in:
parent
c78a79c998
commit
22d0991a46
10
src/lib.rs
10
src/lib.rs
|
@ -64,7 +64,7 @@ pub enum NoteValidity {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Domain {
|
pub trait Domain {
|
||||||
type EphemeralSecretKey;
|
type EphemeralSecretKey: ConstantTimeEq;
|
||||||
type EphemeralPublicKey;
|
type EphemeralPublicKey;
|
||||||
type SharedSecret;
|
type SharedSecret;
|
||||||
type SymmetricKey: AsRef<[u8]>;
|
type SymmetricKey: AsRef<[u8]>;
|
||||||
|
@ -490,6 +490,14 @@ pub fn try_output_recovery_with_ock<D: Domain, Output: ShieldedOutput<D>>(
|
||||||
domain.parse_note_plaintext_without_memo_ovk(&pk_d, &esk, output.epk(), &plaintext)?;
|
domain.parse_note_plaintext_without_memo_ovk(&pk_d, &esk, output.epk(), &plaintext)?;
|
||||||
let memo = domain.extract_memo(&plaintext);
|
let memo = domain.extract_memo(&plaintext);
|
||||||
|
|
||||||
|
// ZIP 212: Check that the esk provided to this function is consistent with the esk we
|
||||||
|
// can derive from the note.
|
||||||
|
if let Some(derived_esk) = D::derive_esk(¬e) {
|
||||||
|
if (!derived_esk.ct_eq(&esk)).into() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let NoteValidity::Valid =
|
if let NoteValidity::Valid =
|
||||||
check_note_validity::<D>(¬e, output.epk(), &output.cmstar_bytes())
|
check_note_validity::<D>(¬e, output.epk(), &output.cmstar_bytes())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue