diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-11-05 00:08:13 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-11-05 00:08:13 +0000 |
commit | ca2c7bdfa64a30c0013598f0718dcfe7e6d98b2a (patch) | |
tree | 3bedd0e18f88371c2e75bd1953e0bc321629c828 /src/include/gnunet_secretsharing_service.h | |
parent | 6c3bf6b3486fd31402ab991f5ddef76bf9cd93c4 (diff) | |
download | gnunet-ca2c7bdfa64a30c0013598f0718dcfe7e6d98b2a.tar.gz gnunet-ca2c7bdfa64a30c0013598f0718dcfe7e6d98b2a.zip |
- implemented missing set functionality
- secretsharing api changes
Diffstat (limited to 'src/include/gnunet_secretsharing_service.h')
-rw-r--r-- | src/include/gnunet_secretsharing_service.h | 98 |
1 files changed, 75 insertions, 23 deletions
diff --git a/src/include/gnunet_secretsharing_service.h b/src/include/gnunet_secretsharing_service.h index d7bc46135..9f0df55af 100644 --- a/src/include/gnunet_secretsharing_service.h +++ b/src/include/gnunet_secretsharing_service.h | |||
@@ -48,6 +48,11 @@ extern "C" | |||
48 | */ | 48 | */ |
49 | struct GNUNET_SECRETSHARING_Session; | 49 | struct GNUNET_SECRETSHARING_Session; |
50 | 50 | ||
51 | /** | ||
52 | * Share of a secret shared with a group of peers. | ||
53 | */ | ||
54 | struct GNUNET_SECRETSHARING_Share; | ||
55 | |||
51 | 56 | ||
52 | /** | 57 | /** |
53 | * Handle to cancel a cooperative decryption operation. | 58 | * Handle to cancel a cooperative decryption operation. |
@@ -56,22 +61,14 @@ struct GNUNET_SECRETSHARING_DecryptionHandle; | |||
56 | 61 | ||
57 | 62 | ||
58 | /** | 63 | /** |
59 | * Parameters of the crypto system. | 64 | * Public key of a group sharing a secret. |
60 | */ | 65 | */ |
61 | struct GNUNET_SECRETSHARING_Parameters | 66 | struct GNUNET_SECRETSHARING_PublicKey |
62 | { | 67 | { |
63 | /** | 68 | /** |
64 | * Prime with p = 2q+1. | 69 | * Value of the private key. |
65 | */ | ||
66 | gcry_mpi_t p; | ||
67 | /** | ||
68 | * Prime. | ||
69 | */ | 70 | */ |
70 | gcry_mpi_t q; | 71 | gcry_mpi_t value; |
71 | /** | ||
72 | * Generator of G_q. | ||
73 | */ | ||
74 | gcry_mpi_t g; | ||
75 | }; | 72 | }; |
76 | 73 | ||
77 | 74 | ||
@@ -92,20 +89,35 @@ struct GNUNET_SECRETSHARING_Ciphertext | |||
92 | 89 | ||
93 | 90 | ||
94 | /** | 91 | /** |
92 | * Plain, unencrypted message that can be encrypted with | ||
93 | * a group public key. | ||
94 | */ | ||
95 | struct GNUNET_SECRETSHARING_Message | ||
96 | { | ||
97 | /** | ||
98 | * Value of the message. | ||
99 | */ | ||
100 | gcry_mpi_t value; | ||
101 | }; | ||
102 | |||
103 | |||
104 | /** | ||
95 | * Called once the secret has been established with all peers, or the deadline is due. | 105 | * Called once the secret has been established with all peers, or the deadline is due. |
96 | * | 106 | * |
97 | * Note that the number of peers can be smaller that 'k' (this threshold parameter), which | 107 | * Note that the number of peers can be smaller that 'k' (this threshold parameter), which |
98 | * makes the threshold crypto system useledd. However, in this case one can still determine which peers | 108 | * makes the threshold crypto system useless. However, in this case one can still determine which peers |
99 | * were able to participate in the secret sharing successfully. | 109 | * were able to participate in the secret sharing successfully. |
100 | * | 110 | * |
101 | * @param cls closure | 111 | * @param cls closure |
112 | * @param my_share the share of this peer | ||
102 | * @param public_key public key of the session | 113 | * @param public_key public key of the session |
103 | * @param num_ready_peers number of peers in @ready_peers | 114 | * @param num_ready_peers number of peers in ready_peers |
104 | * @parem ready_peers peers that successfuly participated in establishing | 115 | * @param ready_peers peers that successfuly participated in establishing |
105 | * the shared secret | 116 | * the shared secret |
106 | */ | 117 | */ |
107 | typedef void (*GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls, | 118 | typedef void (*GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls, |
108 | gcry_mpi_t public_key, | 119 | const struct GNUNET_SECRETSHARING_Share *my_share, |
120 | const struct GNUNET_SECRETSHARING_PublicKey public_key, | ||
109 | unsigned int num_ready_peers, | 121 | unsigned int num_ready_peers, |
110 | const struct GNUNET_PeerIdentity *ready_peers); | 122 | const struct GNUNET_PeerIdentity *ready_peers); |
111 | 123 | ||
@@ -114,10 +126,10 @@ typedef void (*GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls, | |||
114 | * Called when a decryption has succeeded. | 126 | * Called when a decryption has succeeded. |
115 | * | 127 | * |
116 | * @param cls closure | 128 | * @param cls closure |
117 | * @param result decrypted value | 129 | * @param result decrypted value, must be free'd by the callback eventually |
118 | */ | 130 | */ |
119 | typedef void (*GNUNET_SECRETSHARING_DecryptCallback) (void *cls, | 131 | typedef void (*GNUNET_SECRETSHARING_DecryptCallback) (void *cls, |
120 | gcry_mpi_t result); | 132 | struct GNUNET_SECRETSHARING_Message *result); |
121 | 133 | ||
122 | 134 | ||
123 | /** | 135 | /** |
@@ -125,11 +137,11 @@ typedef void (*GNUNET_SECRETSHARING_DecryptCallback) (void *cls, | |||
125 | * with the other peers. | 137 | * with the other peers. |
126 | * | 138 | * |
127 | * @param cfg configuration to use | 139 | * @param cfg configuration to use |
128 | * @param num_peers number of peers in @peers | 140 | * @param num_peers number of peers in 'peers' |
141 | * @param peers array of peers that we will share secrets with, can optionally contain the local peer | ||
129 | * @param session_id unique session id | 142 | * @param session_id unique session id |
130 | * @param deadline point in time where the session must be established; taken as hint | 143 | * @param deadline point in time where the session must be established; taken as hint |
131 | * by underlying consensus sessions | 144 | * by underlying consensus sessions |
132 | * @param parameters parameters for the crypto system | ||
133 | * @param threshold minimum number of peers that must cooperate to decrypt a value | 145 | * @param threshold minimum number of peers that must cooperate to decrypt a value |
134 | * @param cb called when the secret has been established | 146 | * @param cb called when the secret has been established |
135 | * @param cls closure for cb | 147 | * @param cls closure for cb |
@@ -140,13 +152,51 @@ GNUNET_SECRETSHARING_create_session (const struct GNUNET_CONFIGURATION_Handle *c | |||
140 | const struct GNUNET_PeerIdentity *peers, | 152 | const struct GNUNET_PeerIdentity *peers, |
141 | const struct GNUNET_HashCode *session_id, | 153 | const struct GNUNET_HashCode *session_id, |
142 | struct GNUNET_TIME_Absolute deadline, | 154 | struct GNUNET_TIME_Absolute deadline, |
143 | struct GNUNET_SECRETSHARING_Parameters *parameters, | ||
144 | unsigned int threshold, | 155 | unsigned int threshold, |
145 | GNUNET_SECRETSHARING_SecretReadyCallback *cb, | 156 | GNUNET_SECRETSHARING_SecretReadyCallback *cb, |
146 | void *cls); | 157 | void *cls); |
147 | 158 | ||
148 | 159 | ||
149 | /** | 160 | /** |
161 | * Load a session from an existing share. | ||
162 | * | ||
163 | * @param cfg configuration to use for connecting to the secretsharing service | ||
164 | * @param share share to load the session from | ||
165 | */ | ||
166 | struct GNUNET_SECRETSHARING_Session * | ||
167 | GNUNET_SECRETSHARING_load_session (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
168 | const struct GNUNET_SECRETSHARING_Share *share); | ||
169 | |||
170 | /** | ||
171 | * Convert a secret share to a string. | ||
172 | * | ||
173 | * @param share share to serialize | ||
174 | * @return the serialized secret share, to be freed by the caller | ||
175 | */ | ||
176 | char * | ||
177 | GNUNET_SECRETSHARING_share_to_string (const struct GNUNET_SECRETSHARING_Share *share); | ||
178 | |||
179 | |||
180 | /** | ||
181 | * Convert a secret share to a string. | ||
182 | * | ||
183 | * @param str string to deserialize | ||
184 | * @return the serialized secret share, to be freed by the caller | ||
185 | */ | ||
186 | const struct GNUNET_SECRETSHARING_Share * | ||
187 | GNUNET_SECRETSHARING_share_from_string (const char *str); | ||
188 | |||
189 | |||
190 | /** | ||
191 | * Destroy a secret share. | ||
192 | * | ||
193 | * @param share secret share to destroy | ||
194 | */ | ||
195 | void | ||
196 | GNUNET_SECRETSHARING_share_destroy (const struct GNUNET_SECRETSHARING_Share *share); | ||
197 | |||
198 | |||
199 | /** | ||
150 | * Destroy a secret sharing session. | 200 | * Destroy a secret sharing session. |
151 | * | 201 | * |
152 | * @param session session to destroy | 202 | * @param session session to destroy |
@@ -165,12 +215,12 @@ GNUNET_SECRETSHARING_destroy_session (struct GNUNET_SECRETSHARING_Session *sessi | |||
165 | * @param session session to take the key for encryption from, | 215 | * @param session session to take the key for encryption from, |
166 | * the session's ready callback must have been already called | 216 | * the session's ready callback must have been already called |
167 | * @param message message to encrypt | 217 | * @param message message to encrypt |
168 | * @param result_cyphertext pointer to store the resulting ciphertext | 218 | * @param result_ciphertext pointer to store the resulting ciphertext |
169 | * @return GNUNET_YES on succes, GNUNET_SYSERR if the message is invalid (invalid range) | 219 | * @return GNUNET_YES on succes, GNUNET_SYSERR if the message is invalid (invalid range) |
170 | */ | 220 | */ |
171 | int | 221 | int |
172 | GNUNET_SECRETSHARING_encrypt (const struct GNUNET_SECRETSHARING_Session *session, | 222 | GNUNET_SECRETSHARING_encrypt (const struct GNUNET_SECRETSHARING_Session *session, |
173 | gcry_mpi_t message, | 223 | const struct GNUNET_SECRETSHARING_Message *message, |
174 | struct GNUNET_SECRETSHARING_Ciphertext *result_ciphertext); | 224 | struct GNUNET_SECRETSHARING_Ciphertext *result_ciphertext); |
175 | 225 | ||
176 | 226 | ||
@@ -206,6 +256,8 @@ void | |||
206 | GNUNET_SECRETSHARING_cancel_decrypt (struct GNUNET_SECRETSHARING_DecryptionHandle *decryption_handle); | 256 | GNUNET_SECRETSHARING_cancel_decrypt (struct GNUNET_SECRETSHARING_DecryptionHandle *decryption_handle); |
207 | 257 | ||
208 | 258 | ||
259 | |||
260 | |||
209 | #if 0 /* keep Emacsens' auto-indent happy */ | 261 | #if 0 /* keep Emacsens' auto-indent happy */ |
210 | { | 262 | { |
211 | #endif | 263 | #endif |