diff --git a/src/zcash/prf.cpp b/src/zcash/prf.cpp index 1aa8142d8..99e9868e8 100644 --- a/src/zcash/prf.cpp +++ b/src/zcash/prf.cpp @@ -27,7 +27,7 @@ std::array PRF_expand(const uint256& sk, unsigned char t) uint256 PRF_rcm(const uint256& rseed) { uint256 rcm; - auto tmp = PRF_expand(rseed, 4); + auto tmp = PRF_expand(rseed, PRF_RCM_DIVERSIFIER); librustzcash_to_scalar(tmp.data(), rcm.begin()); return rcm; } @@ -35,7 +35,7 @@ uint256 PRF_rcm(const uint256& rseed) uint256 PRF_esk(const uint256& rseed) { uint256 esk; - auto tmp = PRF_expand(rseed, 5); + auto tmp = PRF_expand(rseed, PRF_ESK_DIVERSIFIER); librustzcash_to_scalar(tmp.data(), esk.begin()); return esk; } @@ -43,7 +43,7 @@ uint256 PRF_esk(const uint256& rseed) uint256 PRF_ask(const uint256& sk) { uint256 ask; - auto tmp = PRF_expand(sk, 0); + auto tmp = PRF_expand(sk, PRF_ASK_DIVERSIFIER); librustzcash_to_scalar(tmp.data(), ask.begin()); return ask; } @@ -51,7 +51,7 @@ uint256 PRF_ask(const uint256& sk) uint256 PRF_nsk(const uint256& sk) { uint256 nsk; - auto tmp = PRF_expand(sk, 1); + auto tmp = PRF_expand(sk, PRF_NSK_DIVERSIFIER); librustzcash_to_scalar(tmp.data(), nsk.begin()); return nsk; } @@ -59,7 +59,7 @@ uint256 PRF_nsk(const uint256& sk) uint256 PRF_ovk(const uint256& sk) { uint256 ovk; - auto tmp = PRF_expand(sk, 2); + auto tmp = PRF_expand(sk, PRF_OVK_DIVERSIFIER); memcpy(ovk.begin(), tmp.data(), 32); return ovk; } diff --git a/src/zcash/prf.h b/src/zcash/prf.h index b9256769a..5ab3ed1a3 100644 --- a/src/zcash/prf.h +++ b/src/zcash/prf.h @@ -25,6 +25,12 @@ uint256 PRF_ovk(const uint256& sk); uint256 PRF_rcm(const uint256& rseed); uint256 PRF_esk(const uint256& rseed); +const char PRF_ASK_DIVERSIFIER = 0; +const char PRF_NSK_DIVERSIFIER = 1; +const char PRF_OVK_DIVERSIFIER = 2; +const char PRF_RCM_DIVERSIFIER = 4; +const char PRF_ESK_DIVERSIFIER = 5; + std::array default_diversifier(const uint256& sk); #endif // ZC_PRF_H_