aboutsummaryrefslogtreecommitdiff
path: root/src/secretsharing/secretsharing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/secretsharing/secretsharing.h')
-rw-r--r--src/secretsharing/secretsharing.h121
1 files changed, 99 insertions, 22 deletions
diff --git a/src/secretsharing/secretsharing.h b/src/secretsharing/secretsharing.h
index 0af21028d..232721410 100644
--- a/src/secretsharing/secretsharing.h
+++ b/src/secretsharing/secretsharing.h
@@ -27,13 +27,22 @@
27#define SECRETSHARING_H 27#define SECRETSHARING_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_common.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_time_lib.h" 31#include "gnunet_time_lib.h"
32#include "gnunet_common.h"
32#include "gnunet_secretsharing_service.h" 33#include "gnunet_secretsharing_service.h"
33 34
34 35
35GNUNET_NETWORK_STRUCT_BEGIN 36GNUNET_NETWORK_STRUCT_BEGIN
36 37
38struct GNUNET_SECRETSHARING_FieldElement
39{
40 /**
41 * Value of an element in <elgamal_g>.
42 */
43 unsigned char bits[GNUNET_SECRETSHARING_KEY_BITS / 8];
44};
45
37 46
38struct GNUNET_SECRETSHARING_CreateMessage 47struct GNUNET_SECRETSHARING_CreateMessage
39{ 48{
@@ -67,31 +76,46 @@ struct GNUNET_SECRETSHARING_CreateMessage
67}; 76};
68 77
69 78
70struct GNUNET_SECRETSHARING_SecretReadyMessage 79
80struct GNUNET_SECRETSHARING_ShareHeaderNBO
71{ 81{
72 /** 82 /**
73 * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY 83 * Threshold for the key this share belongs to.
74 */ 84 */
75 struct GNUNET_MessageHeader header; 85 uint16_t threshold;
86
87 /**
88 * Peers that have the share.
89 */
90 uint16_t num_peers;
76 91
77 /** 92 /**
78 * Secret share in network byte order. 93 * Index of our peer in the list.
79 */ 94 */
80 unsigned char secret[GNUNET_SECRETSHARING_KEY_BITS / 8]; 95 uint16_t my_peer;
81 96
82 /** 97 /**
83 * Secret share in network byte order. 98 * Public key. Must correspond to the product of
99 * the homomorphic share commitments.
84 */ 100 */
85 struct GNUNET_SECRETSHARING_PublicKey public_key; 101 struct GNUNET_SECRETSHARING_PublicKey public_key;
86 102
87 /** 103 /**
88 * Number of peers at the end of this message. 104 * Share of 'my_peer'
89 * Includes peers that are part of the established
90 * threshold crypto system.
91 */ 105 */
92 uint16_t num_secret_peers GNUNET_PACKED; 106 struct GNUNET_SECRETSHARING_FieldElement my_share;
107};
108
109
110struct GNUNET_SECRETSHARING_SecretReadyMessage
111{
112 /**
113 * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY
114 */
115 struct GNUNET_MessageHeader header;
116
117 /* rest: the serialized share */
93 118
94 /* struct GNUNET_PeerIdentity[num_peers]; */
95}; 119};
96 120
97 121
@@ -103,35 +127,88 @@ struct GNUNET_SECRETSHARING_DecryptRequestMessage
103 struct GNUNET_MessageHeader header; 127 struct GNUNET_MessageHeader header;
104 128
105 /** 129 /**
106 * Ciphertext to request decryption for. 130 * Until when should the decryption be finished?
107 */ 131 */
108 unsigned char ciphertext[GNUNET_SECRETSHARING_KEY_BITS / 8]; 132 struct GNUNET_TIME_AbsoluteNBO deadline;
109 133
110 /** 134 /**
111 * Number of peers at the end of this message. 135 * Ciphertext we want to decrypt.
112 * Includes peers that are part of the established
113 * threshold crypto system.
114 */ 136 */
115 uint16_t num_secret_peers GNUNET_PACKED; 137 struct GNUNET_SECRETSHARING_Ciphertext ciphertext;
116 138
117 /* struct GNUNET_PeerIdentity[num_peers]; */ 139 /* the share with payload */
118}; 140};
119 141
120 142
121struct GNUNET_SECRETSHARING_DecryptResponseMessage 143struct GNUNET_SECRETSHARING_DecryptResponseMessage
122{ 144{
123 /** 145 /**
124 * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_RESPONSE 146 * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_DONE
125 */ 147 */
126 struct GNUNET_MessageHeader header; 148 struct GNUNET_MessageHeader header;
127 149
128 /** 150 /**
129 * Ciphertext to request decryption for. 151 * Zero if decryption failed, non-zero if decryption succeeded.
152 * If the decryption failed, plaintext is also zero.
130 */ 153 */
131 unsigned char plaintext[GNUNET_SECRETSHARING_KEY_BITS / 8]; 154 uint32_t success;
155
156 /**
157 * Decrypted plaintext.
158 */
159 struct GNUNET_SECRETSHARING_FieldElement plaintext;
132}; 160};
133 161
134 162
135GNUNET_NETWORK_STRUCT_END 163GNUNET_NETWORK_STRUCT_END
136 164
165
166/**
167 * A share, with all values in in host byte order.
168 */
169struct GNUNET_SECRETSHARING_Share
170{
171 /**
172 * Threshold for the key this share belongs to.
173 */
174 uint16_t threshold;
175
176 /**
177 * Peers that have the share.
178 */
179 uint16_t num_peers;
180
181 /**
182 * Index of our peer in the list.
183 */
184 uint16_t my_peer;
185
186 /**
187 * Public key. Must correspond to the product of
188 * the homomorphic share commitments.
189 */
190 struct GNUNET_SECRETSHARING_PublicKey public_key;
191
192 /**
193 * Share of 'my_peer'
194 */
195 struct GNUNET_SECRETSHARING_FieldElement my_share;
196
197 /**
198 * Peer identities (includes 'my_peer')
199 */
200 struct GNUNET_PeerIdentity *peers;
201
202 /*
203 * Homomorphic commitments to each peer's share (includes 'my_peer')
204 */
205 struct GNUNET_SECRETSHARING_FieldElement *hom_share_commitments;
206
207 /*
208 * Original indices of peers from the DKG round.
209 */
210 uint16_t *original_indices;
211};
212
213
137#endif 214#endif