desprout
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// Copyright (c) 2019-2020 The Hush developers
|
||||
|
||||
#ifndef ZC_ADDRESS_H_
|
||||
#define ZC_ADDRESS_H_
|
||||
|
||||
@@ -26,34 +28,6 @@ const size_t SerializedSaplingSpendingKeySize = 32;
|
||||
|
||||
typedef std::array<unsigned char, ZC_DIVERSIFIER_SIZE> diversifier_t;
|
||||
|
||||
class SproutPaymentAddress {
|
||||
public:
|
||||
uint256 a_pk;
|
||||
uint256 pk_enc;
|
||||
|
||||
SproutPaymentAddress() : a_pk(), pk_enc() { }
|
||||
SproutPaymentAddress(uint256 a_pk, uint256 pk_enc) : a_pk(a_pk), pk_enc(pk_enc) { }
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
||||
READWRITE(a_pk);
|
||||
READWRITE(pk_enc);
|
||||
}
|
||||
|
||||
//! Get the 256-bit SHA256d hash of this payment address.
|
||||
uint256 GetHash() const;
|
||||
|
||||
friend inline bool operator==(const SproutPaymentAddress& a, const SproutPaymentAddress& b) {
|
||||
return a.a_pk == b.a_pk && a.pk_enc == b.pk_enc;
|
||||
}
|
||||
friend inline bool operator<(const SproutPaymentAddress& a, const SproutPaymentAddress& b) {
|
||||
return (a.a_pk < b.a_pk ||
|
||||
(a.a_pk == b.a_pk && a.pk_enc < b.pk_enc));
|
||||
}
|
||||
};
|
||||
|
||||
class ReceivingKey : public uint256 {
|
||||
public:
|
||||
ReceivingKey() { }
|
||||
@@ -62,45 +36,6 @@ public:
|
||||
uint256 pk_enc() const;
|
||||
};
|
||||
|
||||
class SproutViewingKey {
|
||||
public:
|
||||
uint256 a_pk;
|
||||
ReceivingKey sk_enc;
|
||||
|
||||
SproutViewingKey() : a_pk(), sk_enc() { }
|
||||
SproutViewingKey(uint256 a_pk, ReceivingKey sk_enc) : a_pk(a_pk), sk_enc(sk_enc) { }
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
||||
READWRITE(a_pk);
|
||||
READWRITE(sk_enc);
|
||||
}
|
||||
|
||||
SproutPaymentAddress address() const;
|
||||
|
||||
friend inline bool operator==(const SproutViewingKey& a, const SproutViewingKey& b) {
|
||||
return a.a_pk == b.a_pk && a.sk_enc == b.sk_enc;
|
||||
}
|
||||
friend inline bool operator<(const SproutViewingKey& a, const SproutViewingKey& b) {
|
||||
return (a.a_pk < b.a_pk ||
|
||||
(a.a_pk == b.a_pk && a.sk_enc < b.sk_enc));
|
||||
}
|
||||
};
|
||||
|
||||
class SproutSpendingKey : public uint252 {
|
||||
public:
|
||||
SproutSpendingKey() : uint252() { }
|
||||
SproutSpendingKey(uint252 a_sk) : uint252(a_sk) { }
|
||||
|
||||
static SproutSpendingKey random();
|
||||
|
||||
ReceivingKey receiving_key() const;
|
||||
SproutViewingKey viewing_key() const;
|
||||
SproutPaymentAddress address() const;
|
||||
};
|
||||
|
||||
//! Sapling functions.
|
||||
class SaplingPaymentAddress {
|
||||
public:
|
||||
@@ -218,8 +153,8 @@ public:
|
||||
SaplingPaymentAddress default_address() const;
|
||||
};
|
||||
|
||||
typedef boost::variant<InvalidEncoding, SproutPaymentAddress, SaplingPaymentAddress> PaymentAddress;
|
||||
typedef boost::variant<InvalidEncoding, SproutViewingKey, SaplingIncomingViewingKey> ViewingKey;
|
||||
typedef boost::variant<InvalidEncoding, SaplingPaymentAddress> PaymentAddress;
|
||||
typedef boost::variant<InvalidEncoding, SaplingIncomingViewingKey> ViewingKey;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user