aboutsummaryrefslogtreecommitdiff
path: root/trunnel/stfe.trunnel
blob: eb82942b58810a9f637fbeae3a5f09c90214a38b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const T_GET_ENTRIES_V1 = 1;
const T_GET_PROOF_BY_HASH_V1 = 2;
const T_GET_CONSISTENCY_PROOF_V1 = 3;
const T_INCLUSION_PROOF_V1 = 4;
const T_CONSISTENCY_PROOF_V1 = 5;
const T_SIGNED_TREE_HEAD_V1 = 6;
const T_SIGNED_CHECKSUM32_ED25519_V1 = 7;
const T_ED25519_V1 = 8;

struct req_get_entries_v1 {
  u64 start_size;
  u64 end_size;
};

struct req_get_proof_by_hash_v1 {
  u64 tree_size;
  u8 leaf_hash[32];
};

struct req_get_consistency_proof_v1 {
  u64 old_size;
  u64 new_size;
};

struct request_v1 {
  u64 format IN [ T_GET_ENTRIES_V1, T_GET_PROOF_BY_HASH_V1, T_GET_CONSISTENCY_PROOF_V1 ];

  union request[format] {
    T_GET_ENTRIES_V1: struct req_get_entries_v1 get_entries;
    T_GET_PROOF_BY_HASH_V1: struct req_get_proof_by_hash_v1 get_proof_by_hash;
    T_GET_CONSISTENCY_PROOF_V1: struct req_get_consistency_proof_v1 get_consistency_proof;
    default: fail;
  };
}	    

struct inclusion_proof_v1 {
  u64 format IN [ T_INCLUSION_PROOF_V1 ];
  struct ed25519_v1 identifier;
  u64 tree_size;
  u64 leaf_index;
  u64 length; /* TODO: constraint: multiple of 32 */
  u8 hashes[length];  
};

struct consistency_proof_v1 {
  u64 format IN [ T_CONSISTENCY_PROOF_V1 ];
  struct ed25519_v1 identifier;
  u64 old_size;
  u64 new_size;
  u64 length; /* TODO: constraint: multiple of 32 */
  u8 hashes[length];  
};

/* Not used
struct sigident {
  u8 signature[64];
  struct ed25519_v1 identifier;
}; */

struct signed_tree_head_v1 {
  u64 format IN [ T_SIGNED_TREE_HEAD_V1 ];
  u64 timestamp;
  u64 tree_size;
  u8 root_hash[32];
  u64 length; /* TODO: constraint: multiple of 104 */
  u8 sigident[length];
  /* Alternatively, if we would chose to replace length with n_items:
  u64 n_items;
  struct sigident[n_items]; */
};

struct signed_checksum32_ed25519_v1 {
  u64 format IN [ T_SIGNED_CHECKSUM32_ED25519_V1 ];
  u8 checksum[32];
  u64 length IN [ 1..127 ]; /* The spec contradicts itself on this point -- is it 127 or 128? */
  u8 identifier[length];
  u8 signature[64];
  struct ed25519_v1 namespace;  
};

struct ed25519_v1 {
  u64 format IN [ T_ED25519_V1 ];
  u8 pubkey[32];
};