Add Base58 encoding of viewing keys
This commit is contained in:
@@ -365,6 +365,14 @@ template libzcash::PaymentAddress CZCEncoding<libzcash::PaymentAddress,
|
|||||||
CChainParams::ZCPAYMENT_ADDRRESS,
|
CChainParams::ZCPAYMENT_ADDRRESS,
|
||||||
libzcash::SerializedPaymentAddressSize>::Get() const;
|
libzcash::SerializedPaymentAddressSize>::Get() const;
|
||||||
|
|
||||||
|
// Explicit instantiations for libzcash::ViewingKey
|
||||||
|
template bool CZCEncoding<libzcash::ViewingKey,
|
||||||
|
CChainParams::ZCVIEWING_KEY,
|
||||||
|
libzcash::SerializedViewingKeySize>::Set(const libzcash::ViewingKey& vk);
|
||||||
|
template libzcash::ViewingKey CZCEncoding<libzcash::ViewingKey,
|
||||||
|
CChainParams::ZCVIEWING_KEY,
|
||||||
|
libzcash::SerializedViewingKeySize>::Get() const;
|
||||||
|
|
||||||
// Explicit instantiations for libzcash::SpendingKey
|
// Explicit instantiations for libzcash::SpendingKey
|
||||||
template bool CZCEncoding<libzcash::SpendingKey,
|
template bool CZCEncoding<libzcash::SpendingKey,
|
||||||
CChainParams::ZCSPENDING_KEY,
|
CChainParams::ZCSPENDING_KEY,
|
||||||
|
|||||||
11
src/base58.h
11
src/base58.h
@@ -118,6 +118,17 @@ public:
|
|||||||
CZCPaymentAddress(const libzcash::PaymentAddress& addr) { Set(addr); }
|
CZCPaymentAddress(const libzcash::PaymentAddress& addr) { Set(addr); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CZCViewingKey : public CZCEncoding<libzcash::ViewingKey, CChainParams::ZCVIEWING_KEY, libzcash::SerializedViewingKeySize> {
|
||||||
|
protected:
|
||||||
|
std::string PrependName(const std::string& s) const { return "viewing key" + s; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
CZCViewingKey() {}
|
||||||
|
|
||||||
|
CZCViewingKey(const std::string& strViewingKey) { SetString(strViewingKey.c_str(), 3); }
|
||||||
|
CZCViewingKey(const libzcash::ViewingKey& vk) { Set(vk); }
|
||||||
|
};
|
||||||
|
|
||||||
class CZCSpendingKey : public CZCEncoding<libzcash::SpendingKey, CChainParams::ZCSPENDING_KEY, libzcash::SerializedSpendingKeySize> {
|
class CZCSpendingKey : public CZCEncoding<libzcash::SpendingKey, CChainParams::ZCSPENDING_KEY, libzcash::SerializedSpendingKeySize> {
|
||||||
protected:
|
protected:
|
||||||
std::string PrependName(const std::string& s) const { return "spending key" + s; }
|
std::string PrependName(const std::string& s) const { return "spending key" + s; }
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ public:
|
|||||||
base58Prefixes[EXT_SECRET_KEY] = {0x04,0x88,0xAD,0xE4};
|
base58Prefixes[EXT_SECRET_KEY] = {0x04,0x88,0xAD,0xE4};
|
||||||
// guarantees the first 2 characters, when base58 encoded, are "zc"
|
// guarantees the first 2 characters, when base58 encoded, are "zc"
|
||||||
base58Prefixes[ZCPAYMENT_ADDRRESS] = {0x16,0x9A};
|
base58Prefixes[ZCPAYMENT_ADDRRESS] = {0x16,0x9A};
|
||||||
|
// guarantees the first 4 characters, when base58 encoded, are "ZiVK"
|
||||||
|
base58Prefixes[ZCVIEWING_KEY] = {0xA8,0xAB,0xD3};
|
||||||
// guarantees the first 2 characters, when base58 encoded, are "SK"
|
// guarantees the first 2 characters, when base58 encoded, are "SK"
|
||||||
base58Prefixes[ZCSPENDING_KEY] = {0xAB,0x36};
|
base58Prefixes[ZCSPENDING_KEY] = {0xAB,0x36};
|
||||||
|
|
||||||
@@ -241,6 +243,8 @@ public:
|
|||||||
base58Prefixes[EXT_SECRET_KEY] = {0x04,0x35,0x83,0x94};
|
base58Prefixes[EXT_SECRET_KEY] = {0x04,0x35,0x83,0x94};
|
||||||
// guarantees the first 2 characters, when base58 encoded, are "zt"
|
// guarantees the first 2 characters, when base58 encoded, are "zt"
|
||||||
base58Prefixes[ZCPAYMENT_ADDRRESS] = {0x16,0xB6};
|
base58Prefixes[ZCPAYMENT_ADDRRESS] = {0x16,0xB6};
|
||||||
|
// guarantees the first 4 characters, when base58 encoded, are "ZiVt"
|
||||||
|
base58Prefixes[ZCVIEWING_KEY] = {0xA8,0xAC,0x0C};
|
||||||
// guarantees the first 2 characters, when base58 encoded, are "ST"
|
// guarantees the first 2 characters, when base58 encoded, are "ST"
|
||||||
base58Prefixes[ZCSPENDING_KEY] = {0xAC,0x08};
|
base58Prefixes[ZCSPENDING_KEY] = {0xAC,0x08};
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public:
|
|||||||
|
|
||||||
ZCPAYMENT_ADDRRESS,
|
ZCPAYMENT_ADDRRESS,
|
||||||
ZCSPENDING_KEY,
|
ZCSPENDING_KEY,
|
||||||
|
ZCVIEWING_KEY,
|
||||||
|
|
||||||
MAX_BASE58_TYPES
|
MAX_BASE58_TYPES
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
namespace libzcash {
|
namespace libzcash {
|
||||||
|
|
||||||
const size_t SerializedPaymentAddressSize = 64;
|
const size_t SerializedPaymentAddressSize = 64;
|
||||||
|
const size_t SerializedViewingKeySize = 64;
|
||||||
const size_t SerializedSpendingKeySize = 32;
|
const size_t SerializedSpendingKeySize = 32;
|
||||||
|
|
||||||
class PaymentAddress {
|
class PaymentAddress {
|
||||||
|
|||||||
Reference in New Issue
Block a user