Reuse the hasher inside diversify_hash

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
str4d 2021-03-18 13:39:04 +13:00 committed by GitHub
parent 51fd94df72
commit 05e86a4d98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -59,10 +59,11 @@ pub(crate) fn commit_ivk(
///
/// [concretediversifyhash]: https://zips.z.cash/protocol/nu5.pdf#concretediversifyhash
pub(crate) fn diversify_hash(d: &[u8; 11]) -> pallas::Point {
let pk_d = pallas::Point::hash_to_curve("z.cash:Orchard-gd")(d);
let hasher = pallas::Point::hash_to_curve("z.cash:Orchard-gd");
let pk_d = hasher(d);
if pk_d.is_identity().into() {
// If the identity occurs, we replace it with a different fixed point.
pallas::Point::hash_to_curve("z.cash:Orchard-gd")(&[])
hasher(&[])
} else {
pk_d
}