2016-05-04 17:25:42 -07:00
|
|
|
#ifndef _ZCADDRESS_H_
|
|
|
|
#define _ZCADDRESS_H_
|
|
|
|
|
|
|
|
#include "uint256.h"
|
2016-05-16 08:50:31 -07:00
|
|
|
#include "uint252.h"
|
2016-05-04 17:25:42 -07:00
|
|
|
#include "serialize.h"
|
|
|
|
|
|
|
|
namespace libzcash {
|
|
|
|
|
|
|
|
class PaymentAddress {
|
|
|
|
public:
|
|
|
|
uint256 a_pk;
|
|
|
|
uint256 pk_enc;
|
|
|
|
|
|
|
|
PaymentAddress() : a_pk(), pk_enc() { }
|
|
|
|
PaymentAddress(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, int nType, int nVersion) {
|
|
|
|
READWRITE(a_pk);
|
|
|
|
READWRITE(pk_enc);
|
|
|
|
}
|
2016-08-08 18:34:58 -07:00
|
|
|
|
2016-08-23 20:50:45 -07:00
|
|
|
friend inline bool operator==(const PaymentAddress& a, const PaymentAddress& b) { return a.a_pk == b.a_pk && a.pk_enc == b.pk_enc; }
|
2016-08-08 18:34:58 -07:00
|
|
|
friend inline bool operator<(const PaymentAddress& a, const PaymentAddress& b) { return a.a_pk < b.a_pk; }
|
2016-05-04 17:25:42 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class ViewingKey : public uint256 {
|
|
|
|
public:
|
|
|
|
ViewingKey(uint256 sk_enc) : uint256(sk_enc) { }
|
|
|
|
|
|
|
|
uint256 pk_enc();
|
|
|
|
};
|
|
|
|
|
2016-05-16 08:50:31 -07:00
|
|
|
class SpendingKey : public uint252 {
|
2016-05-04 17:25:42 -07:00
|
|
|
public:
|
2016-05-16 08:50:31 -07:00
|
|
|
SpendingKey() : uint252() { }
|
|
|
|
SpendingKey(uint252 a_sk) : uint252(a_sk) { }
|
2016-05-04 17:25:42 -07:00
|
|
|
|
|
|
|
static SpendingKey random();
|
|
|
|
|
2016-08-08 18:34:58 -07:00
|
|
|
ViewingKey viewing_key() const;
|
|
|
|
PaymentAddress address() const;
|
2016-05-04 17:25:42 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-15 13:58:30 -07:00
|
|
|
#endif // _ZCADDRESS_H_
|