GNUnet  0.10.x
gnunet_secretsharing_service.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
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/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
32 #ifndef GNUNET_SECRETSHARING_SERVICE_H
33 #define GNUNET_SECRETSHARING_SERVICE_H
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #if 0 /* keep Emacsens' auto-indent happy */
39 }
40 #endif
41 #endif
42 
43 #include "gnunet_common.h"
44 #include "gnunet_time_lib.h"
46 #include <gcrypt.h>
47 
48 
56 #define GNUNET_SECRETSHARING_ELGAMAL_BITS 1024
57 
58 
62 #define GNUNET_SECRETSHARING_ELGAMAL_P_HEX \
63  "0x08a347d3d69e8b2dd7d1b12a08dfbccbebf4ca" \
64  "6f4269a0814e158a34312964d946b3ef22882317" \
65  "2bcf30fc08f772774cb404f9bc002a6f66b09a79" \
66  "d810d67c4f8cb3bedc6060e3c8ef874b1b64df71" \
67  "6c7d2b002da880e269438d5a776e6b5f253c8df5" \
68  "6a16b1c7ce58def07c03db48238aadfc52a354a2" \
69  "7ed285b0c1675cad3f3"
70 
75 #define GNUNET_SECRETSHARING_ELGAMAL_Q_HEX \
76  "0x0451a3e9eb4f4596ebe8d895046fde65f5fa65" \
77  "37a134d040a70ac51a1894b26ca359f79144118b" \
78  "95e7987e047bb93ba65a027cde001537b3584d3c" \
79  "ec086b3e27c659df6e303071e477c3a58db26fb8" \
80  "b63e958016d4407134a1c6ad3bb735af929e46fa" \
81  "b50b58e3e72c6f783e01eda411c556fe2951aa51" \
82  "3f6942d860b3ae569f9"
83 
88 #define GNUNET_SECRETSHARING_ELGAMAL_G_HEX \
89  "0x05c00c36d2e822950087ef09d8252994adc4e4" \
90  "8fe3ec70269f035b46063aff0c99b633fd64df43" \
91  "02442e1914c829a41505a275438871f365e91c12" \
92  "3d5303ef9e90f4b8cb89bf86cc9b513e74a72634" \
93  "9cfd9f953674fab5d511e1c078fc72d72b34086f" \
94  "c82b4b951989eb85325cb203ff98df76bc366bba" \
95  "1d7024c3650f60d0da"
96 
97 
98 
104 
111 
112 
117 
118 
123 {
124  uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)];
125 };
126 
127 
132 {
133  uint32_t c1_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)];
134  uint32_t c2_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)];
135 };
136 
137 
145 {
149  uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)];
150 };
151 
152 
171 typedef void
174  struct GNUNET_SECRETSHARING_PublicKey *public_key,
175  unsigned int num_ready_peers,
176  const struct GNUNET_PeerIdentity *ready_peers);
177 
178 
186 typedef void
188  const struct GNUNET_SECRETSHARING_Plaintext *plaintext);
189 
190 
209  unsigned int num_peers,
210  const struct GNUNET_PeerIdentity *peers,
211  const struct GNUNET_HashCode *session_id,
214  unsigned int threshold,
216  void *cls);
217 
218 
225 void
227 
228 
242 int
244  const struct GNUNET_SECRETSHARING_Plaintext *plaintext,
245  struct GNUNET_SECRETSHARING_Ciphertext *result_ciphertext);
246 
247 
266  struct GNUNET_SECRETSHARING_Share *share,
271  void *decrypt_cb_cls);
272 
273 
282 void
284 
285 
296 GNUNET_SECRETSHARING_share_read (const void *data, size_t len, size_t *readlen);
297 
298 
310 int
312  void *buf, size_t buflen, size_t *writelen);
313 
314 
315 void
317 
318 
319 int
321  gcry_mpi_t exponent);
322 
323 int
325  int64_t exponent);
326 
327 
328 #if 0 /* keep Emacsens' auto-indent happy */
329 {
330 #endif
331 #ifdef __cplusplus
332 }
333 #endif
334 
335 #endif
336  /* end of group */
static unsigned int threshold
What should the threshold for then key be?
struct GNUNET_SECRETSHARING_Share * GNUNET_SECRETSHARING_share_read(const void *data, size_t len, size_t *readlen)
Read a share from its binary representation.
struct GNUNET_SECRETSHARING_FieldElement my_share
Share of &#39;my_peer&#39;.
void GNUNET_SECRETSHARING_share_destroy(struct GNUNET_SECRETSHARING_Share *share)
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
int GNUNET_SECRETSHARING_plaintext_generate(struct GNUNET_SECRETSHARING_Plaintext *plaintext, gcry_mpi_t exponent)
A share, with all values in in host byte order.
static struct GNUNET_HashCode session_id
struct GNUNET_SECRETSHARING_DecryptionHandle * GNUNET_SECRETSHARING_decrypt(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SECRETSHARING_Share *share, const struct GNUNET_SECRETSHARING_Ciphertext *ciphertext, struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute deadline, GNUNET_SECRETSHARING_DecryptCallback decrypt_cb, void *decrypt_cb_cls)
Publish the given ciphertext for decryption.
Public key of a group sharing a secret.
void GNUNET_SECRETSHARING_session_destroy(struct GNUNET_SECRETSHARING_Session *s)
Destroy a secret sharing session.
int GNUNET_SECRETSHARING_plaintext_generate_i(struct GNUNET_SECRETSHARING_Plaintext *plaintext, int64_t exponent)
struct GNUNET_SECRETSHARING_Session * GNUNET_SECRETSHARING_create_session(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int num_peers, const struct GNUNET_PeerIdentity *peers, const struct GNUNET_HashCode *session_id, struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute deadline, unsigned int threshold, GNUNET_SECRETSHARING_SecretReadyCallback cb, void *cls)
Create a session that will eventually establish a shared secret with the other peers.
void GNUNET_SECRETSHARING_decrypt_cancel(struct GNUNET_SECRETSHARING_DecryptionHandle *dh)
Cancel a decryption.
static char buf[2048]
int GNUNET_SECRETSHARING_share_write(const struct GNUNET_SECRETSHARING_Share *share, void *buf, size_t buflen, size_t *writelen)
Convert a share to its binary representation.
static struct GNUNET_SECRETSHARING_Ciphertext ciphertext
A 512-bit hashcode.
Session that will eventually establish a shared secred between the involved peers and allow encryptio...
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
int GNUNET_SECRETSHARING_encrypt(const struct GNUNET_SECRETSHARING_PublicKey *public_key, const struct GNUNET_SECRETSHARING_Plaintext *plaintext, struct GNUNET_SECRETSHARING_Ciphertext *result_ciphertext)
Encrypt a value.
Handle to cancel a cooperative decryption operation.
static unsigned int num_peers
The identity of the host (wraps the signing key of the peer).
configuration data
Definition: configuration.c:85
static struct CadetPeer * peers
Operation to get peer ids.
Plain, unencrypted message that can be encrypted with a group public key.
uint32_t bits[1024/8/sizeof(uint32_t)]
static struct GNUNET_TIME_Absolute deadline
Deadline for all consensuses.
Time for absolute times used by GNUnet, in microseconds.
static void decrypt_cb(void *cls, const struct GNUNET_SECRETSHARING_Plaintext *plaintext)
Called when a decryption has succeeded.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
void(* GNUNET_SECRETSHARING_DecryptCallback)(void *cls, const struct GNUNET_SECRETSHARING_Plaintext *plaintext)
Called when a decryption has succeeded.
uint32_t data
The data value.
void(* GNUNET_SECRETSHARING_SecretReadyCallback)(void *cls, struct GNUNET_SECRETSHARING_Share *my_share, struct GNUNET_SECRETSHARING_PublicKey *public_key, unsigned int num_ready_peers, const struct GNUNET_PeerIdentity *ready_peers)
Called once the secret has been established with all peers, or the deadline is due.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
#define GNUNET_SECRETSHARING_ELGAMAL_BITS
Number of bits for secretsharing elements.