aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_secretsharing_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_secretsharing_service.h')
-rw-r--r--src/include/gnunet_secretsharing_service.h119
1 files changed, 58 insertions, 61 deletions
diff --git a/src/include/gnunet_secretsharing_service.h b/src/include/gnunet_secretsharing_service.h
index 69cfa4514..40c98b857 100644
--- a/src/include/gnunet_secretsharing_service.h
+++ b/src/include/gnunet_secretsharing_service.h
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -60,39 +60,39 @@ extern "C"
60 * The q-parameter for ElGamal encryption, a 1024-bit safe prime. 60 * The q-parameter for ElGamal encryption, a 1024-bit safe prime.
61 */ 61 */
62#define GNUNET_SECRETSHARING_ELGAMAL_P_HEX \ 62#define GNUNET_SECRETSHARING_ELGAMAL_P_HEX \
63 "0x08a347d3d69e8b2dd7d1b12a08dfbccbebf4ca" \ 63 "0x08a347d3d69e8b2dd7d1b12a08dfbccbebf4ca" \
64 "6f4269a0814e158a34312964d946b3ef22882317" \ 64 "6f4269a0814e158a34312964d946b3ef22882317" \
65 "2bcf30fc08f772774cb404f9bc002a6f66b09a79" \ 65 "2bcf30fc08f772774cb404f9bc002a6f66b09a79" \
66 "d810d67c4f8cb3bedc6060e3c8ef874b1b64df71" \ 66 "d810d67c4f8cb3bedc6060e3c8ef874b1b64df71" \
67 "6c7d2b002da880e269438d5a776e6b5f253c8df5" \ 67 "6c7d2b002da880e269438d5a776e6b5f253c8df5" \
68 "6a16b1c7ce58def07c03db48238aadfc52a354a2" \ 68 "6a16b1c7ce58def07c03db48238aadfc52a354a2" \
69 "7ed285b0c1675cad3f3" 69 "7ed285b0c1675cad3f3"
70 70
71/** 71/**
72 * The q-parameter for ElGamal encryption, 72 * The q-parameter for ElGamal encryption,
73 * a 1023-bit Sophie Germain prime, q = (p-1)/2 73 * a 1023-bit Sophie Germain prime, q = (p-1)/2
74 */ 74 */
75#define GNUNET_SECRETSHARING_ELGAMAL_Q_HEX \ 75#define GNUNET_SECRETSHARING_ELGAMAL_Q_HEX \
76 "0x0451a3e9eb4f4596ebe8d895046fde65f5fa65" \ 76 "0x0451a3e9eb4f4596ebe8d895046fde65f5fa65" \
77 "37a134d040a70ac51a1894b26ca359f79144118b" \ 77 "37a134d040a70ac51a1894b26ca359f79144118b" \
78 "95e7987e047bb93ba65a027cde001537b3584d3c" \ 78 "95e7987e047bb93ba65a027cde001537b3584d3c" \
79 "ec086b3e27c659df6e303071e477c3a58db26fb8" \ 79 "ec086b3e27c659df6e303071e477c3a58db26fb8" \
80 "b63e958016d4407134a1c6ad3bb735af929e46fa" \ 80 "b63e958016d4407134a1c6ad3bb735af929e46fa" \
81 "b50b58e3e72c6f783e01eda411c556fe2951aa51" \ 81 "b50b58e3e72c6f783e01eda411c556fe2951aa51" \
82 "3f6942d860b3ae569f9" 82 "3f6942d860b3ae569f9"
83 83
84/** 84/**
85 * The g-parameter for ElGamal encryption, 85 * The g-parameter for ElGamal encryption,
86 * a generator of the unique size q subgroup of Z_p^* 86 * a generator of the unique size q subgroup of Z_p^*
87 */ 87 */
88#define GNUNET_SECRETSHARING_ELGAMAL_G_HEX \ 88#define GNUNET_SECRETSHARING_ELGAMAL_G_HEX \
89 "0x05c00c36d2e822950087ef09d8252994adc4e4" \ 89 "0x05c00c36d2e822950087ef09d8252994adc4e4" \
90 "8fe3ec70269f035b46063aff0c99b633fd64df43" \ 90 "8fe3ec70269f035b46063aff0c99b633fd64df43" \
91 "02442e1914c829a41505a275438871f365e91c12" \ 91 "02442e1914c829a41505a275438871f365e91c12" \
92 "3d5303ef9e90f4b8cb89bf86cc9b513e74a72634" \ 92 "3d5303ef9e90f4b8cb89bf86cc9b513e74a72634" \
93 "9cfd9f953674fab5d511e1c078fc72d72b34086f" \ 93 "9cfd9f953674fab5d511e1c078fc72d72b34086f" \
94 "c82b4b951989eb85325cb203ff98df76bc366bba" \ 94 "c82b4b951989eb85325cb203ff98df76bc366bba" \
95 "1d7024c3650f60d0da" 95 "1d7024c3650f60d0da"
96 96
97 97
98 98
@@ -119,19 +119,17 @@ struct GNUNET_SECRETSHARING_DecryptionHandle;
119/** 119/**
120 * Public key of a group sharing a secret. 120 * Public key of a group sharing a secret.
121 */ 121 */
122struct GNUNET_SECRETSHARING_PublicKey 122struct GNUNET_SECRETSHARING_PublicKey {
123{ 123 uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof(uint32_t)];
124 uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)];
125}; 124};
126 125
127 126
128/** 127/**
129 * Encrypted field element. 128 * Encrypted field element.
130 */ 129 */
131struct GNUNET_SECRETSHARING_Ciphertext 130struct GNUNET_SECRETSHARING_Ciphertext {
132{ 131 uint32_t c1_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof(uint32_t)];
133 uint32_t c1_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)]; 132 uint32_t c2_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof(uint32_t)];
134 uint32_t c2_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)];
135}; 133};
136 134
137 135
@@ -141,12 +139,11 @@ struct GNUNET_SECRETSHARING_Ciphertext
141 * Note that we are not operating in GF(2^n), thus not every 139 * Note that we are not operating in GF(2^n), thus not every
142 * bit pattern is a valid plain text. 140 * bit pattern is a valid plain text.
143 */ 141 */
144struct GNUNET_SECRETSHARING_Plaintext 142struct GNUNET_SECRETSHARING_Plaintext {
145{
146 /** 143 /**
147 * Value of the message. 144 * Value of the message.
148 */ 145 */
149 uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)]; 146 uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof(uint32_t)];
150}; 147};
151 148
152 149
@@ -205,15 +202,15 @@ typedef void
205 * @param cls closure for @a cb 202 * @param cls closure for @a cb
206 */ 203 */
207struct GNUNET_SECRETSHARING_Session * 204struct GNUNET_SECRETSHARING_Session *
208GNUNET_SECRETSHARING_create_session (const struct GNUNET_CONFIGURATION_Handle *cfg, 205GNUNET_SECRETSHARING_create_session(const struct GNUNET_CONFIGURATION_Handle *cfg,
209 unsigned int num_peers, 206 unsigned int num_peers,
210 const struct GNUNET_PeerIdentity *peers, 207 const struct GNUNET_PeerIdentity *peers,
211 const struct GNUNET_HashCode *session_id, 208 const struct GNUNET_HashCode *session_id,
212 struct GNUNET_TIME_Absolute start, 209 struct GNUNET_TIME_Absolute start,
213 struct GNUNET_TIME_Absolute deadline, 210 struct GNUNET_TIME_Absolute deadline,
214 unsigned int threshold, 211 unsigned int threshold,
215 GNUNET_SECRETSHARING_SecretReadyCallback cb, 212 GNUNET_SECRETSHARING_SecretReadyCallback cb,
216 void *cls); 213 void *cls);
217 214
218 215
219/** 216/**
@@ -223,7 +220,7 @@ GNUNET_SECRETSHARING_create_session (const struct GNUNET_CONFIGURATION_Handle *c
223 * @param s session to destroy 220 * @param s session to destroy
224 */ 221 */
225void 222void
226GNUNET_SECRETSHARING_session_destroy (struct GNUNET_SECRETSHARING_Session *s); 223GNUNET_SECRETSHARING_session_destroy(struct GNUNET_SECRETSHARING_Session *s);
227 224
228 225
229/** 226/**
@@ -240,9 +237,9 @@ GNUNET_SECRETSHARING_session_destroy (struct GNUNET_SECRETSHARING_Session *s);
240 * @return #GNUNET_YES on succes, #GNUNET_SYSERR if the message is invalid (invalid range) 237 * @return #GNUNET_YES on succes, #GNUNET_SYSERR if the message is invalid (invalid range)
241 */ 238 */
242int 239int
243GNUNET_SECRETSHARING_encrypt (const struct GNUNET_SECRETSHARING_PublicKey *public_key, 240GNUNET_SECRETSHARING_encrypt(const struct GNUNET_SECRETSHARING_PublicKey *public_key,
244 const struct GNUNET_SECRETSHARING_Plaintext *plaintext, 241 const struct GNUNET_SECRETSHARING_Plaintext *plaintext,
245 struct GNUNET_SECRETSHARING_Ciphertext *result_ciphertext); 242 struct GNUNET_SECRETSHARING_Ciphertext *result_ciphertext);
246 243
247 244
248/** 245/**
@@ -262,13 +259,13 @@ GNUNET_SECRETSHARING_encrypt (const struct GNUNET_SECRETSHARING_PublicKey *publi
262 * @return handle to cancel the operation 259 * @return handle to cancel the operation
263 */ 260 */
264struct GNUNET_SECRETSHARING_DecryptionHandle * 261struct GNUNET_SECRETSHARING_DecryptionHandle *
265GNUNET_SECRETSHARING_decrypt (const struct GNUNET_CONFIGURATION_Handle *cfg, 262GNUNET_SECRETSHARING_decrypt(const struct GNUNET_CONFIGURATION_Handle *cfg,
266 struct GNUNET_SECRETSHARING_Share *share, 263 struct GNUNET_SECRETSHARING_Share *share,
267 const struct GNUNET_SECRETSHARING_Ciphertext *ciphertext, 264 const struct GNUNET_SECRETSHARING_Ciphertext *ciphertext,
268 struct GNUNET_TIME_Absolute start, 265 struct GNUNET_TIME_Absolute start,
269 struct GNUNET_TIME_Absolute deadline, 266 struct GNUNET_TIME_Absolute deadline,
270 GNUNET_SECRETSHARING_DecryptCallback decrypt_cb, 267 GNUNET_SECRETSHARING_DecryptCallback decrypt_cb,
271 void *decrypt_cb_cls); 268 void *decrypt_cb_cls);
272 269
273 270
274/** 271/**
@@ -280,7 +277,7 @@ GNUNET_SECRETSHARING_decrypt (const struct GNUNET_CONFIGURATION_Handle *cfg,
280 * @param dh to cancel 277 * @param dh to cancel
281 */ 278 */
282void 279void
283GNUNET_SECRETSHARING_decrypt_cancel (struct GNUNET_SECRETSHARING_DecryptionHandle *dh); 280GNUNET_SECRETSHARING_decrypt_cancel(struct GNUNET_SECRETSHARING_DecryptionHandle *dh);
284 281
285 282
286/** 283/**
@@ -293,7 +290,7 @@ GNUNET_SECRETSHARING_decrypt_cancel (struct GNUNET_SECRETSHARING_DecryptionHandl
293 * @return The share, or NULL on error. 290 * @return The share, or NULL on error.
294 */ 291 */
295struct GNUNET_SECRETSHARING_Share * 292struct GNUNET_SECRETSHARING_Share *
296GNUNET_SECRETSHARING_share_read (const void *data, size_t len, size_t *readlen); 293GNUNET_SECRETSHARING_share_read(const void *data, size_t len, size_t *readlen);
297 294
298 295
299/** 296/**
@@ -308,21 +305,21 @@ GNUNET_SECRETSHARING_share_read (const void *data, size_t len, size_t *readlen);
308 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure. 305 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure.
309 */ 306 */
310int 307int
311GNUNET_SECRETSHARING_share_write (const struct GNUNET_SECRETSHARING_Share *share, 308GNUNET_SECRETSHARING_share_write(const struct GNUNET_SECRETSHARING_Share *share,
312 void *buf, size_t buflen, size_t *writelen); 309 void *buf, size_t buflen, size_t *writelen);
313 310
314 311
315void 312void
316GNUNET_SECRETSHARING_share_destroy (struct GNUNET_SECRETSHARING_Share *share); 313GNUNET_SECRETSHARING_share_destroy(struct GNUNET_SECRETSHARING_Share *share);
317 314
318 315
319int 316int
320GNUNET_SECRETSHARING_plaintext_generate (struct GNUNET_SECRETSHARING_Plaintext *plaintext, 317GNUNET_SECRETSHARING_plaintext_generate(struct GNUNET_SECRETSHARING_Plaintext *plaintext,
321 gcry_mpi_t exponent); 318 gcry_mpi_t exponent);
322 319
323int 320int
324GNUNET_SECRETSHARING_plaintext_generate_i (struct GNUNET_SECRETSHARING_Plaintext *plaintext, 321GNUNET_SECRETSHARING_plaintext_generate_i(struct GNUNET_SECRETSHARING_Plaintext *plaintext,
325 int64_t exponent); 322 int64_t exponent);
326 323
327 324
328#if 0 /* keep Emacsens' auto-indent happy */ 325#if 0 /* keep Emacsens' auto-indent happy */