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.h56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/include/gnunet_secretsharing_service.h b/src/include/gnunet_secretsharing_service.h
index 7eb372ef5..8569e15ea 100644
--- a/src/include/gnunet_secretsharing_service.h
+++ b/src/include/gnunet_secretsharing_service.h
@@ -46,6 +46,8 @@ extern "C"
46 * Number of bits for secretsharing keys. 46 * Number of bits for secretsharing keys.
47 * Must be smaller than the Pallier key size used internally 47 * Must be smaller than the Pallier key size used internally
48 * by the secretsharing service. 48 * by the secretsharing service.
49 * When changing this value, other internal parameters must also
50 * be adjusted.
49 */ 51 */
50#define GNUNET_SECRETSHARING_KEY_BITS 1024 52#define GNUNET_SECRETSHARING_KEY_BITS 1024
51 53
@@ -58,8 +60,8 @@ struct GNUNET_SECRETSHARING_Session;
58 60
59/** 61/**
60 * Share of a secret shared with a group of peers. 62 * Share of a secret shared with a group of peers.
61 * Contains both the share and information about the peers that have 63 * Contains the secret share itself, the public key, the list of peers, and the
62 * the other parts of the share. 64 * exponential commitments to the secret shares of the other peers.
63 */ 65 */
64struct GNUNET_SECRETSHARING_Share; 66struct GNUNET_SECRETSHARING_Share;
65 67
@@ -84,7 +86,8 @@ struct GNUNET_SECRETSHARING_PublicKey
84 */ 86 */
85struct GNUNET_SECRETSHARING_Ciphertext 87struct GNUNET_SECRETSHARING_Ciphertext
86{ 88{
87 uint32_t bits[2 * GNUNET_SECRETSHARING_KEY_BITS / 8 / sizeof (uint32_t)]; 89 uint32_t c1_bits[GNUNET_SECRETSHARING_KEY_BITS / 8 / sizeof (uint32_t)];
90 uint32_t c2_bits[GNUNET_SECRETSHARING_KEY_BITS / 8 / sizeof (uint32_t)];
88}; 91};
89 92
90 93
@@ -97,7 +100,7 @@ struct GNUNET_SECRETSHARING_Message
97 /** 100 /**
98 * Value of the message. 101 * Value of the message.
99 */ 102 */
100 gcry_mpi_t value; 103 uint32_t bits[GNUNET_SECRETSHARING_KEY_BITS / 8 / sizeof (uint32_t)];
101}; 104};
102 105
103 106
@@ -206,15 +209,19 @@ GNUNET_SECRETSHARING_encrypt (struct GNUNET_SECRETSHARING_PublicKey *public_key,
206 * When the operation is canceled, the decrypt_cb is not called anymore, but the calling 209 * When the operation is canceled, the decrypt_cb is not called anymore, but the calling
207 * peer may already have irrevocably contributed his share for the decryption of the value. 210 * peer may already have irrevocably contributed his share for the decryption of the value.
208 * 211 *
212 * @param cfg configuration to use
209 * @param share our secret share to use for decryption 213 * @param share our secret share to use for decryption
210 * @param ciphertext ciphertext to publish in order to decrypt it (if enough peers agree) 214 * @param ciphertext ciphertext to publish in order to decrypt it (if enough peers agree)
211 * @param decrypt_cb callback called once the decryption succeeded 215 * @param decrypt_cb callback called once the decryption succeeded
216 * @param deadline By when should the decryption be finished?
212 * @param decrypt_cb_cls closure for @a decrypt_cb 217 * @param decrypt_cb_cls closure for @a decrypt_cb
213 * @return handle to cancel the operation 218 * @return handle to cancel the operation
214 */ 219 */
215struct GNUNET_SECRETSHARING_DecryptionHandle * 220struct GNUNET_SECRETSHARING_DecryptionHandle *
216GNUNET_SECRETSHARING_decrypt (struct GNUNET_SECRETSHARING_Share *share, 221GNUNET_SECRETSHARING_decrypt (struct GNUNET_CONFIGURATION_Handle *cfg,
222 struct GNUNET_SECRETSHARING_Share *share,
217 struct GNUNET_SECRETSHARING_Ciphertext *ciphertext, 223 struct GNUNET_SECRETSHARING_Ciphertext *ciphertext,
224 struct GNUNET_TIME_Absolute deadline,
218 GNUNET_SECRETSHARING_DecryptCallback decrypt_cb, 225 GNUNET_SECRETSHARING_DecryptCallback decrypt_cb,
219 void *decrypt_cb_cls); 226 void *decrypt_cb_cls);
220 227
@@ -234,41 +241,32 @@ GNUNET_SECRETSHARING_decrypt_cancel (struct GNUNET_SECRETSHARING_DecryptionHandl
234/** 241/**
235 * Read a share from its binary representation. 242 * Read a share from its binary representation.
236 * 243 *
237 * @param data binary representation of the share 244 * @param data Binary representation of the share.
238 * @param len length of @a data 245 * @param len Length of @a data.
239 * @return the share, or NULL on error 246 * @param[out] readlen Number of bytes read,
247 * ignored if NULL.
248 * @return The share, or NULL on error.
240 */ 249 */
241struct GNUNET_SECRETSHARING_Share * 250struct GNUNET_SECRETSHARING_Share *
242GNUNET_SECRETSHARING_share_read (void *data, size_t len); 251GNUNET_SECRETSHARING_share_read (const void *data, size_t len, size_t *readlen);
243 252
244 253
245/** 254/**
246 * Convert a share to its binary representation. Use 255 * Convert a share to its binary representation.
247 * #GNUNET_SECRETSHARING_share_size to get the necessary size for the binary 256 * Can be called with a NULL @a buf to get the size of the share.
248 * representation.
249 * 257 *
250 * @param share share to write 258 * @param share Share to write.
251 * @param buf buffer to write to 259 * @param buf Buffer to write to.
252 * @param buflen number of writable bytes in @a buffer 260 * @param buflen Number of writable bytes in @a buf.
253 * @param[out] writelen pointer to store number of bytes written, 261 * @param[out] writelen Pointer to store number of bytes written,
254 * ignored if NULL 262 * ignored if NULL.
255 * @return GNUNET_YES on success, GNUNET_NO on failure 263 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure.
256 */ 264 */
257int 265int
258GNUNET_SECRETSHARING_share_write (struct GNUNET_SECRETSHARING_Share *share, 266GNUNET_SECRETSHARING_share_write (const struct GNUNET_SECRETSHARING_Share *share,
259 void *buf, size_t buflen, size_t *writelen); 267 void *buf, size_t buflen, size_t *writelen);
260 268
261 269
262/**
263 * Get the number of bytes necessary to represent the given share.
264 *
265 * @param share share
266 * @return number of bytes necessary to represent @a share
267 */
268size_t
269GNUNET_SECRETSHARING_share_size (struct GNUNET_SECRETSHARING_Share *share);
270
271
272 270
273#if 0 /* keep Emacsens' auto-indent happy */ 271#if 0 /* keep Emacsens' auto-indent happy */
274{ 272{