OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_CERT_MERKLE_AUDIT_PROOF_H_ | 5 #ifndef NET_CERT_MERKLE_AUDIT_PROOF_H_ |
6 #define NET_CERT_MERKLE_AUDIT_PROOF_H_ | 6 #define NET_CERT_MERKLE_AUDIT_PROOF_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 namespace ct { | 17 namespace ct { |
18 | 18 |
19 // Returns the length of the audit path for a leaf at |leaf_index| in a Merkle | 19 // Returns the length of the audit path for a leaf at |leaf_index| in a Merkle |
20 // tree containing |tree_size| leaves. | 20 // tree containing |tree_size| leaves. |
21 // The |leaf_index| must be less than the |tree_size|. | 21 // The |leaf_index| must be less than the |tree_size|. |
22 NET_EXPORT uint64_t CalculateAuditPathLength(uint64_t leaf_index, | 22 NET_EXPORT uint64_t CalculateAuditPathLength(uint64_t leaf_index, |
23 uint64_t tree_size); | 23 uint64_t tree_size); |
24 | 24 |
25 // Audit proof for a Merkle tree leaf, as defined in section 2.1.1. of RFC6962. | 25 // Audit proof for a Merkle tree leaf, as defined in section 2.1.1. of RFC6962. |
26 struct NET_EXPORT MerkleAuditProof { | 26 struct NET_EXPORT MerkleAuditProof { |
27 MerkleAuditProof(); | 27 MerkleAuditProof(); |
28 MerkleAuditProof(uint64_t leaf_index, | 28 MerkleAuditProof(uint64_t leaf_index, |
| 29 uint64_t tree_size, |
29 const std::vector<std::string>& audit_path); | 30 const std::vector<std::string>& audit_path); |
30 ~MerkleAuditProof(); | 31 ~MerkleAuditProof(); |
31 | 32 |
32 // Index of the tree leaf in the log. | 33 // Index of the tree leaf in the log. |
| 34 // Must be provided when fetching the proof from the log. |
33 uint64_t leaf_index = 0; | 35 uint64_t leaf_index = 0; |
34 | 36 |
| 37 // The proof works only in conjunction with an STH for this tree size. |
| 38 // Must be provided when fetching the proof from the log. |
| 39 uint64_t tree_size = 0; |
| 40 |
35 // Audit path nodes. | 41 // Audit path nodes. |
| 42 // Using the leaf hash and these nodes, the STH hash can be reconstructed to |
| 43 // prove that leaf was included in the log's tree. |
36 std::vector<std::string> nodes; | 44 std::vector<std::string> nodes; |
37 }; | 45 }; |
38 | 46 |
39 } // namespace ct | 47 } // namespace ct |
40 } // namespace net | 48 } // namespace net |
41 | 49 |
42 #endif // NET_CERT_MERKLE_AUDIT_PROOF_H_ | 50 #endif // NET_CERT_MERKLE_AUDIT_PROOF_H_ |
OLD | NEW |