Skip to main content

luct_core/v1/
responses.rs

1//! The response structures of a v1 log.
2//!
3//! These structures correspond to the ones described in RFC 6962 Section 4.
4//! They can be parsed using `serde_json`, and then be transformed into other structures to be validated.
5
6use crate::{
7    signature::Signature,
8    utils::{base64::Base64, codec::Codec},
9    v1::{MerkleTreeLeaf, sth::TreeHeadSignature},
10};
11use serde::{Deserialize, Serialize};
12
13/// Response returned by call to `/ct/v1/get-sth`
14///
15/// See RFC 6962 4.3
16#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
17pub struct GetSthResponse {
18    pub(crate) tree_size: u64,
19    pub(crate) timestamp: u64,
20    pub(crate) sha256_root_hash: Base64<Vec<u8>>,
21    pub(crate) tree_head_signature: Base64<Codec<Signature<TreeHeadSignature>>>,
22}
23
24/// Response returned by call to `/ct/v1/get-sth-consistency`
25///
26/// See RFC 6962 4.4
27#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
28pub struct GetSthConsistencyResponse {
29    pub(crate) consistency: Vec<Base64<Vec<u8>>>,
30}
31
32/// Response returned by call to `/ct/v1/get-proof-by-hash`
33///
34/// See RFC 6962 4.5
35#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
36pub struct GetProofByHashResponse {
37    pub(crate) leaf_index: u64,
38    pub(crate) audit_path: Vec<Base64<Vec<u8>>>,
39}
40
41/// Response returned by call to `/ct/v1/get-entries`
42///
43/// See RFC 6962 4.6
44#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
45pub struct GetEntriesResponse {
46    pub(crate) entries: Vec<GetEntriesData>,
47}
48
49#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
50pub(crate) struct GetEntriesData {
51    pub(crate) leaf_input: Base64<Codec<MerkleTreeLeaf>>,
52    pub(crate) extra_data: Base64<Vec<u8>>,
53}
54
55/// Response returned by call to `/ct/v1/get-roots`
56///
57/// See RFC 6962 4.7
58#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
59pub struct GetRootsResponse {
60    pub(crate) certificates: Vec<Base64<Vec<u8>>>,
61}