2 This file is part of GNUnet.
3 Copyright (C) 2013 GNUnet e.V.
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.
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.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @author Florian Dold
23 * @file secretsharing/secretsharing.h
24 * @brief messages used for the secretsharing api
26 #ifndef SECRETSHARING_H
27 #define SECRETSHARING_H
30 #include "gnunet_util_lib.h"
31 #include "gnunet_time_lib.h"
32 #include "gnunet_common.h"
33 #include "gnunet_secretsharing_service.h"
36 GNUNET_NETWORK_STRUCT_BEGIN
38 struct GNUNET_SECRETSHARING_FieldElement
41 * Value of an element in <elgamal_g>.
43 unsigned char bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8];
47 struct GNUNET_SECRETSHARING_CreateMessage
50 * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_GENERATE
52 struct GNUNET_MessageHeader header;
55 * Session ID, will be used for consensus.
57 struct GNUNET_HashCode session_id GNUNET_PACKED;
60 * Start time for communication with the other peers.
62 struct GNUNET_TIME_AbsoluteNBO start;
65 * Deadline for the establishment of the crypto system.
67 struct GNUNET_TIME_AbsoluteNBO deadline;
70 * Mininum number of cooperating peers to decrypt a
73 uint16_t threshold GNUNET_PACKED;
76 * Number of peers at the end of this message.
78 uint16_t num_peers GNUNET_PACKED;
80 /* struct GNUNET_PeerIdentity[num_peers]; */
84 struct GNUNET_SECRETSHARING_ShareHeaderNBO
87 * Threshold for the key this share belongs to.
92 * Peers that have the share.
97 * Index of our peer in the list.
102 * Public key. Must correspond to the product of
103 * the homomorphic share commitments.
105 struct GNUNET_SECRETSHARING_PublicKey public_key;
110 struct GNUNET_SECRETSHARING_FieldElement my_share;
115 * Notify the client that then threshold secret has been
118 struct GNUNET_SECRETSHARING_SecretReadyMessage
121 * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY
123 struct GNUNET_MessageHeader header;
125 /* rest: the serialized share */
129 struct GNUNET_SECRETSHARING_DecryptRequestMessage
132 * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_REQUEST
134 struct GNUNET_MessageHeader header;
137 * Until when should the decryption start?
139 struct GNUNET_TIME_AbsoluteNBO start;
142 * Until when should the decryption be finished?
144 struct GNUNET_TIME_AbsoluteNBO deadline;
147 * Ciphertext we want to decrypt.
149 struct GNUNET_SECRETSHARING_Ciphertext ciphertext;
151 /* the share with payload */
155 struct GNUNET_SECRETSHARING_DecryptResponseMessage
158 * Type: #GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_DONE
160 struct GNUNET_MessageHeader header;
163 * Zero if decryption failed, non-zero if decryption succeeded.
164 * If the decryption failed, plaintext is also zero.
166 uint32_t success GNUNET_PACKED;
169 * Decrypted plaintext.
171 struct GNUNET_SECRETSHARING_FieldElement plaintext;
175 GNUNET_NETWORK_STRUCT_END
179 * A share, with all values in in host byte order.
181 struct GNUNET_SECRETSHARING_Share
184 * Threshold for the key this share belongs to.
189 * Peers that have the share.
194 * Index of our peer in the list.
199 * Public key. Computed from the
200 * exponentiated coefficients.
202 struct GNUNET_SECRETSHARING_PublicKey public_key;
207 struct GNUNET_SECRETSHARING_FieldElement my_share;
210 * Peer identities (includes 'my_peer')
212 struct GNUNET_PeerIdentity *peers;
215 * For each peer, store elgamal_g to the peer's
218 struct GNUNET_SECRETSHARING_FieldElement *sigmas;
221 * Original indices of peers from the DKG round.
223 uint16_t *original_indices;