Add Sapling key classes to wallet, with new librustzcash APIs
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include "prf.h"
|
||||
#include "streams.h"
|
||||
|
||||
#include <librustzcash.h>
|
||||
|
||||
namespace libzcash {
|
||||
|
||||
uint256 SproutPaymentAddress::GetHash() const {
|
||||
@@ -36,6 +38,43 @@ SproutPaymentAddress SproutSpendingKey::address() const {
|
||||
return viewing_key().address();
|
||||
}
|
||||
|
||||
//! Sapling
|
||||
SaplingFullViewingKey SaplingExpandedSpendingKey::full_viewing_key() const {
|
||||
uint256 ak;
|
||||
uint256 nk;
|
||||
librustzcash_ask_to_ak(ask.begin(), ak.begin());
|
||||
librustzcash_nsk_to_nk(nsk.begin(), nk.begin());
|
||||
return SaplingFullViewingKey(ak, nk, ovk);
|
||||
}
|
||||
|
||||
SaplingExpandedSpendingKey SaplingSpendingKey::expanded_spending_key() const {
|
||||
return SaplingExpandedSpendingKey(PRF_ask(*this), PRF_nsk(*this), PRF_ovk(*this));
|
||||
}
|
||||
|
||||
SaplingFullViewingKey SaplingSpendingKey::full_viewing_key() const {
|
||||
return expanded_spending_key().full_viewing_key();
|
||||
}
|
||||
|
||||
SaplingInViewingKey SaplingFullViewingKey::in_viewing_key() const {
|
||||
uint256 ivk;
|
||||
librustzcash_crh_ivk(ak.begin(), nk.begin(), ivk.begin());
|
||||
return SaplingInViewingKey(ivk);
|
||||
}
|
||||
|
||||
SaplingSpendingKey SaplingSpendingKey::random() {
|
||||
return SaplingSpendingKey(random_uint256());
|
||||
}
|
||||
|
||||
SaplingPaymentAddress SaplingInViewingKey::address(diversifier_t d) const {
|
||||
uint256 pk_d;
|
||||
librustzcash_ivk_to_pkd(this->begin(), d.data(), pk_d.begin());
|
||||
return SaplingPaymentAddress(d, pk_d);
|
||||
}
|
||||
|
||||
SaplingPaymentAddress SaplingSpendingKey::default_address() const {
|
||||
return full_viewing_key().in_viewing_key().address(default_diversifier(*this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user