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.h102
1 files changed, 75 insertions, 27 deletions
diff --git a/src/include/gnunet_secretsharing_service.h b/src/include/gnunet_secretsharing_service.h
index 8569e15ea..1524c79fe 100644
--- a/src/include/gnunet_secretsharing_service.h
+++ b/src/include/gnunet_secretsharing_service.h
@@ -43,13 +43,53 @@ extern "C"
43 43
44 44
45/** 45/**
46 * Number of bits for secretsharing keys. 46 * Number of bits for secretsharing elements.
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 49 * When changing this value, other internal parameters must also
50 * be adjusted. 50 * be adjusted.
51 */ 51 */
52#define GNUNET_SECRETSHARING_KEY_BITS 1024 52#define GNUNET_SECRETSHARING_ELGAMAL_BITS 1024
53
54
55/**
56 * The q-parameter for ElGamal encryption, a 1024-bit safe prime.
57 */
58#define GNUNET_SECRETSHARING_ELGAMAL_P_HEX \
59 "0x08a347d3d69e8b2dd7d1b12a08dfbccbebf4ca" \
60 "6f4269a0814e158a34312964d946b3ef22882317" \
61 "2bcf30fc08f772774cb404f9bc002a6f66b09a79" \
62 "d810d67c4f8cb3bedc6060e3c8ef874b1b64df71" \
63 "6c7d2b002da880e269438d5a776e6b5f253c8df5" \
64 "6a16b1c7ce58def07c03db48238aadfc52a354a2" \
65 "7ed285b0c1675cad3f3"
66
67/**
68 * The q-parameter for ElGamal encryption,
69 * a 1023-bit Sophie Germain prime, q = (p-1)/2
70 */
71#define GNUNET_SECRETSHARING_ELGAMAL_Q_HEX \
72 "0x0451a3e9eb4f4596ebe8d895046fde65f5fa65" \
73 "37a134d040a70ac51a1894b26ca359f79144118b" \
74 "95e7987e047bb93ba65a027cde001537b3584d3c" \
75 "ec086b3e27c659df6e303071e477c3a58db26fb8" \
76 "b63e958016d4407134a1c6ad3bb735af929e46fa" \
77 "b50b58e3e72c6f783e01eda411c556fe2951aa51" \
78 "3f6942d860b3ae569f9"
79
80/**
81 * The g-parameter for ElGamal encryption,
82 * a generator of the unique size q subgroup of Z_p^*
83 */
84#define GNUNET_SECRETSHARING_ELGAMAL_G_HEX \
85 "0x05c00c36d2e822950087ef09d8252994adc4e4" \
86 "8fe3ec70269f035b46063aff0c99b633fd64df43" \
87 "02442e1914c829a41505a275438871f365e91c12" \
88 "3d5303ef9e90f4b8cb89bf86cc9b513e74a72634" \
89 "9cfd9f953674fab5d511e1c078fc72d72b34086f" \
90 "c82b4b951989eb85325cb203ff98df76bc366bba" \
91 "1d7024c3650f60d0da"
92
53 93
54 94
55/** 95/**
@@ -77,7 +117,7 @@ struct GNUNET_SECRETSHARING_DecryptionHandle;
77 */ 117 */
78struct GNUNET_SECRETSHARING_PublicKey 118struct GNUNET_SECRETSHARING_PublicKey
79{ 119{
80 uint32_t bits[GNUNET_SECRETSHARING_KEY_BITS / 8 / sizeof (uint32_t)]; 120 uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)];
81}; 121};
82 122
83 123
@@ -86,21 +126,23 @@ struct GNUNET_SECRETSHARING_PublicKey
86 */ 126 */
87struct GNUNET_SECRETSHARING_Ciphertext 127struct GNUNET_SECRETSHARING_Ciphertext
88{ 128{
89 uint32_t c1_bits[GNUNET_SECRETSHARING_KEY_BITS / 8 / sizeof (uint32_t)]; 129 uint32_t c1_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)];
90 uint32_t c2_bits[GNUNET_SECRETSHARING_KEY_BITS / 8 / sizeof (uint32_t)]; 130 uint32_t c2_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)];
91}; 131};
92 132
93 133
94/** 134/**
95 * Plain, unencrypted message that can be encrypted with 135 * Plain, unencrypted message that can be encrypted with
96 * a group public key. 136 * a group public key.
137 * Note that we are not operating in GF(2^n), thus not every
138 * bit pattern is a valid plain text.
97 */ 139 */
98struct GNUNET_SECRETSHARING_Message 140struct GNUNET_SECRETSHARING_Plaintext
99{ 141{
100 /** 142 /**
101 * Value of the message. 143 * Value of the message.
102 */ 144 */
103 uint32_t bits[GNUNET_SECRETSHARING_KEY_BITS / 8 / sizeof (uint32_t)]; 145 uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)];
104}; 146};
105 147
106 148
@@ -113,6 +155,8 @@ struct GNUNET_SECRETSHARING_Message
113 * 155 *
114 * If the secret sharing failed, num_ready_peers is 0 and my_share and public_key is NULL. 156 * If the secret sharing failed, num_ready_peers is 0 and my_share and public_key is NULL.
115 * 157 *
158 * After this callback has been called, the secretsharing session will be invalid.
159 *
116 * @param cls closure 160 * @param cls closure
117 * @param my_share the share of this peer 161 * @param my_share the share of this peer
118 * @param public_key public key of the session 162 * @param public_key public key of the session
@@ -121,10 +165,10 @@ struct GNUNET_SECRETSHARING_Message
121 * the shared secret 165 * the shared secret
122 */ 166 */
123typedef void (*GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls, 167typedef void (*GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls,
124 const struct GNUNET_SECRETSHARING_Share *my_share, 168 struct GNUNET_SECRETSHARING_Share *my_share,
125 const struct GNUNET_SECRETSHARING_PublicKey *public_key, 169 struct GNUNET_SECRETSHARING_PublicKey *public_key,
126 unsigned int num_ready_peers, 170 unsigned int num_ready_peers,
127 const struct GNUNET_PeerIdentity *ready_peers); 171 struct GNUNET_PeerIdentity *ready_peers);
128 172
129 173
130/** 174/**
@@ -135,8 +179,7 @@ typedef void (*GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls,
135 * @param data_size number of bytes in @a data 179 * @param data_size number of bytes in @a data
136 */ 180 */
137typedef void (*GNUNET_SECRETSHARING_DecryptCallback) (void *cls, 181typedef void (*GNUNET_SECRETSHARING_DecryptCallback) (void *cls,
138 const void *data, 182 const struct GNUNET_SECRETSHARING_Plaintext *plaintext);
139 size_t data_size);
140 183
141 184
142/** 185/**
@@ -165,21 +208,13 @@ GNUNET_SECRETSHARING_create_session (const struct GNUNET_CONFIGURATION_Handle *c
165 208
166 209
167/** 210/**
168 * Destroy a secret share.
169 *
170 * @param share secret share to destroy
171 */
172void
173GNUNET_SECRETSHARING_share_destroy (const struct GNUNET_SECRETSHARING_Share *share);
174
175
176/**
177 * Destroy a secret sharing session. 211 * Destroy a secret sharing session.
212 * The secret ready callback will not be called.
178 * 213 *
179 * @param session session to destroy 214 * @param session session to destroy
180 */ 215 */
181void 216void
182GNUNET_SECRETSHARING_destroy_session (struct GNUNET_SECRETSHARING_Session *session); 217GNUNET_SECRETSHARING_session_destroy (struct GNUNET_SECRETSHARING_Session *session);
183 218
184 219
185/** 220/**
@@ -196,9 +231,8 @@ GNUNET_SECRETSHARING_destroy_session (struct GNUNET_SECRETSHARING_Session *sessi
196 * @return #GNUNET_YES on succes, #GNUNET_SYSERR if the message is invalid (invalid range) 231 * @return #GNUNET_YES on succes, #GNUNET_SYSERR if the message is invalid (invalid range)
197 */ 232 */
198int 233int
199GNUNET_SECRETSHARING_encrypt (struct GNUNET_SECRETSHARING_PublicKey *public_key, 234GNUNET_SECRETSHARING_encrypt (const struct GNUNET_SECRETSHARING_PublicKey *public_key,
200 const void *message, 235 const struct GNUNET_SECRETSHARING_Plaintext *plaintext,
201 size_t message_size,
202 struct GNUNET_SECRETSHARING_Ciphertext *result_ciphertext); 236 struct GNUNET_SECRETSHARING_Ciphertext *result_ciphertext);
203 237
204 238
@@ -218,9 +252,9 @@ GNUNET_SECRETSHARING_encrypt (struct GNUNET_SECRETSHARING_PublicKey *public_key,
218 * @return handle to cancel the operation 252 * @return handle to cancel the operation
219 */ 253 */
220struct GNUNET_SECRETSHARING_DecryptionHandle * 254struct GNUNET_SECRETSHARING_DecryptionHandle *
221GNUNET_SECRETSHARING_decrypt (struct GNUNET_CONFIGURATION_Handle *cfg, 255GNUNET_SECRETSHARING_decrypt (const struct GNUNET_CONFIGURATION_Handle *cfg,
222 struct GNUNET_SECRETSHARING_Share *share, 256 struct GNUNET_SECRETSHARING_Share *share,
223 struct GNUNET_SECRETSHARING_Ciphertext *ciphertext, 257 const struct GNUNET_SECRETSHARING_Ciphertext *ciphertext,
224 struct GNUNET_TIME_Absolute deadline, 258 struct GNUNET_TIME_Absolute deadline,
225 GNUNET_SECRETSHARING_DecryptCallback decrypt_cb, 259 GNUNET_SECRETSHARING_DecryptCallback decrypt_cb,
226 void *decrypt_cb_cls); 260 void *decrypt_cb_cls);
@@ -267,6 +301,20 @@ GNUNET_SECRETSHARING_share_write (const struct GNUNET_SECRETSHARING_Share *share
267 void *buf, size_t buflen, size_t *writelen); 301 void *buf, size_t buflen, size_t *writelen);
268 302
269 303
304void
305GNUNET_SECRETSHARING_share_destroy (struct GNUNET_SECRETSHARING_Share *share);
306
307
308int
309GNUNET_SECRETSHARING_plaintext_generate (struct GNUNET_SECRETSHARING_Plaintext *plaintext,
310 gcry_mpi_t exponent);
311
312int
313GNUNET_SECRETSHARING_plaintext_generate_i (struct GNUNET_SECRETSHARING_Plaintext *plaintext,
314 int64_t exponent);
315
316
317
270 318
271#if 0 /* keep Emacsens' auto-indent happy */ 319#if 0 /* keep Emacsens' auto-indent happy */
272{ 320{