da1454ec08fb7f950acd4f89c65266296000fbbd
[oweals/gnunet.git] / src / secretsharing / secretsharing_protocol.h
1 /*
2       This file is part of GNUnet
3       Copyright (C) 2012 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
19
20 /**
21  * @file secretsharing/secretsharing_protocol.h
22  * @brief p2p message definitions for secretsharing
23  * @author Florian Dold
24  */
25
26 #ifndef GNUNET_SECRETSHARING_PROTOCOL_H
27 #define GNUNET_SECRETSHARING_PROTOCOL_H
28
29 #include "platform.h"
30 #include "gnunet_common.h"
31 #include "gnunet_protocols.h"
32 #include "secretsharing.h"
33
34
35 GNUNET_NETWORK_STRUCT_BEGIN
36
37
38 /**
39  * Consensus element data used in the first round of key generation.
40  */
41 struct GNUNET_SECRETSHARING_KeygenCommitData
42 {
43   /**
44    * Signature over the rest of the message.
45    */
46   struct GNUNET_CRYPTO_EddsaSignature signature;
47   /**
48    * Signature purpose for signing the keygen commit data.
49    */
50   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
51   /**
52    * Peer that inserts this element.
53    */
54   struct GNUNET_PeerIdentity peer;
55   /**
56    * Ephemeral paillier public key used by 'peer' for
57    * this session.
58    */
59   struct GNUNET_CRYPTO_PaillierPublicKey pubkey;
60   /**
61    * Commitment of 'peer' to its presecret.
62    */
63   struct GNUNET_HashCode commitment GNUNET_PACKED;
64 };
65
66
67 struct GNUNET_SECRETSHARING_KeygenRevealData
68 {
69   /**
70    * Signature over rest of the message.
71    */
72   struct GNUNET_CRYPTO_EddsaSignature signature;
73   /*
74    * Signature purpose for signing the keygen commit data.
75    */
76   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
77   /**
78    * Peer that inserts this element.
79    */
80   struct GNUNET_PeerIdentity peer;
81
82   /* values follow */
83 };
84
85
86 /**
87  * Data of then element put in consensus
88  * for decrypting a value.
89  */
90 struct GNUNET_SECRETSHARING_DecryptData
91 {
92   /*
93    * Signature over rest of the message.
94    */
95   struct GNUNET_CRYPTO_EddsaSignature signature;
96   /*
97    * Signature purpose for signing the keygen commit data.
98    */
99   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
100   /**
101    * Ciphertext we want to decrypt.
102    */
103   struct GNUNET_SECRETSHARING_Ciphertext ciphertext;
104   /**
105    * Peer that inserts this element.
106    */
107   struct GNUNET_PeerIdentity peer;
108   /**
109    * Partial decryption, computed as c_1^{s_i}
110    */
111   struct GNUNET_SECRETSHARING_FieldElement partial_decryption;
112   /**
113    * Commitment for the non-interactive zero knowledge proof.
114    * g^\beta, with \beta < q
115    */
116   struct GNUNET_SECRETSHARING_FieldElement nizk_commit1;
117   /**
118    * Commitment for the non-interactive zero knowledge proof.
119    * c_1^\beta, with \beta < q
120    */
121   struct GNUNET_SECRETSHARING_FieldElement nizk_commit2;
122   /**
123    * Reponse to the challenge computed from the protocol transcript.
124    * r = \beta + challenge \cdot share_i
125    */
126   struct GNUNET_SECRETSHARING_FieldElement nizk_response;
127 };
128
129
130 struct GNUNET_SECRETSHARING_FairEncryption
131 {
132   struct GNUNET_CRYPTO_PaillierCiphertext c;
133   /**
134    * h = g^x, where x is the fairly encrypte secret.
135    */
136   char h[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8];
137   char t1[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8];
138   char t2[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
139   char z[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8];
140   char w[GNUNET_CRYPTO_PAILLIER_BITS / 8];
141 };
142
143 GNUNET_NETWORK_STRUCT_END
144
145 #endif