]>
Commit | Line | Data |
---|---|---|
369df065 SB |
1 | #ifndef _ZCNOTE_H_ |
2 | #define _ZCNOTE_H_ | |
3 | ||
4 | #include "uint256.h" | |
5 | #include "Zcash.h" | |
6 | #include "Address.hpp" | |
7 | #include "NoteEncryption.hpp" | |
8 | ||
9 | namespace libzcash { | |
10 | ||
11 | class Note { | |
12 | public: | |
13 | uint256 a_pk; | |
14 | uint64_t value; | |
15 | uint256 rho; | |
16 | uint256 r; | |
17 | ||
18 | Note(uint256 a_pk, uint64_t value, uint256 rho, uint256 r) | |
19 | : a_pk(a_pk), value(value), rho(rho), r(r) {} | |
20 | ||
21 | Note(); | |
22 | ||
23 | uint256 cm() const; | |
24 | uint256 nullifier(const SpendingKey& a_sk) const; | |
25 | }; | |
26 | ||
27 | class NotePlaintext { | |
28 | public: | |
29 | uint64_t value; | |
30 | uint256 rho; | |
31 | uint256 r; | |
32 | boost::array<unsigned char, ZC_MEMO_SIZE> memo; | |
33 | ||
34 | NotePlaintext() {} | |
35 | ||
36 | NotePlaintext(const Note& note, boost::array<unsigned char, ZC_MEMO_SIZE> memo); | |
37 | ||
38 | Note note(const PaymentAddress& addr) const; | |
39 | ||
40 | ADD_SERIALIZE_METHODS; | |
41 | ||
42 | template <typename Stream, typename Operation> | |
43 | inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { | |
44 | unsigned char leadingByte = 0x00; | |
45 | READWRITE(leadingByte); | |
46 | ||
47 | if (leadingByte != 0x00) { | |
48 | throw std::ios_base::failure("lead byte of NotePlaintext is not recognized"); | |
49 | } | |
50 | ||
51 | READWRITE(value); | |
52 | READWRITE(rho); | |
53 | READWRITE(r); | |
54 | READWRITE(memo); | |
55 | } | |
56 | ||
57 | static NotePlaintext decrypt(const ZCNoteDecryption& decryptor, | |
58 | const ZCNoteDecryption::Ciphertext& ciphertext, | |
59 | const uint256& ephemeralKey, | |
60 | const uint256& h_sig, | |
61 | unsigned char nonce | |
62 | ); | |
63 | ||
64 | ZCNoteEncryption::Ciphertext encrypt(ZCNoteEncryption& encryptor, | |
65 | const uint256& pk_enc | |
66 | ) const; | |
67 | }; | |
68 | ||
69 | } | |
70 | ||
71 | #endif // _ZCNOTE_H_ |