Move esk derivation check to beginning of plaintext_checks_without_height()

This commit is contained in:
therealyingtong 2020-08-19 14:25:49 +08:00
parent 2361228144
commit 992007ecbc
No known key found for this signature in database
GPG Key ID: 179F32A1503D607E
1 changed files with 8 additions and 8 deletions

View File

@ -369,6 +369,14 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_wit
const uint256 &cmu
)
{
if (plaintext.get_leadbyte() != 0x01) {
// ZIP 212: Additionally check that the esk provided to this function
// is consistent with the esk we can derive
if (esk != plaintext.generate_or_derive_esk()) {
return boost::none;
}
}
// ZIP 212: The recipient MUST derive esk and check that epk is consistent with it.
// https://zips.z.cash/zip-0212#changes-to-the-process-of-receiving-sapling-notes
uint256 expected_epk;
@ -396,14 +404,6 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_wit
return boost::none;
}
if (plaintext.get_leadbyte() != 0x01) {
// ZIP 212: Additionally check that the esk provided to this function
// is consistent with the esk we can derive
if (esk != plaintext.generate_or_derive_esk()) {
return boost::none;
}
}
return plaintext;
}