]>
Commit | Line | Data |
---|---|---|
369df065 SB |
1 | #ifndef _ZCADDRESS_H_ |
2 | #define _ZCADDRESS_H_ | |
3 | ||
4 | #include "uint256.h" | |
5 | #include "serialize.h" | |
6 | ||
7 | namespace libzcash { | |
8 | ||
9 | class PaymentAddress { | |
10 | public: | |
11 | uint256 a_pk; | |
12 | uint256 pk_enc; | |
13 | ||
14 | PaymentAddress() : a_pk(), pk_enc() { } | |
15 | PaymentAddress(uint256 a_pk, uint256 pk_enc) : a_pk(a_pk), pk_enc(pk_enc) { } | |
16 | ||
17 | ADD_SERIALIZE_METHODS; | |
18 | ||
19 | template <typename Stream, typename Operation> | |
20 | inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { | |
21 | unsigned char leadingByte = 0x92; | |
22 | READWRITE(leadingByte); | |
23 | ||
24 | if (leadingByte != 0x92) { | |
25 | throw std::ios_base::failure("unrecognized payment address lead byte"); | |
26 | } | |
27 | ||
28 | READWRITE(a_pk); | |
29 | READWRITE(pk_enc); | |
30 | } | |
31 | }; | |
32 | ||
33 | class ViewingKey : public uint256 { | |
34 | public: | |
35 | ViewingKey(uint256 sk_enc) : uint256(sk_enc) { } | |
36 | ||
37 | uint256 pk_enc(); | |
38 | }; | |
39 | ||
40 | class SpendingKey : public uint256 { | |
41 | public: | |
42 | SpendingKey() : uint256() { } | |
43 | SpendingKey(uint256 a_sk) : uint256(a_sk) { } | |
44 | ||
45 | static SpendingKey random(); | |
46 | ||
47 | ViewingKey viewing_key(); | |
48 | PaymentAddress address(); | |
49 | }; | |
50 | ||
51 | } | |
52 | ||
53 | #endif // _ZCADDRESS_H_ |