- htons => htonl
[oweals/gnunet.git] / src / secretsharing / secretsharing_protocol.h
1 /*
2       This file is part of GNUnet
3       (C) 2012 Christian Grothoff (and other contributing authors)
4
5       GNUnet is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published
7       by the Free Software Foundation; either version 3, or (at your
8       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       General Public License for more details.
14
15       You should have received a copy of the GNU General Public License
16       along with GNUnet; see the file COPYING.  If not, write to the
17       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18       Boston, MA 02111-1307, USA.
19 */
20
21
22 /**
23  * @file secretsharing/secretsharing_protocol.h
24  * @brief p2p message definitions for secretsharing
25  * @author Florian Dold
26  */
27
28 #ifndef GNUNET_SECRETSHARING_PROTOCOL_H
29 #define GNUNET_SECRETSHARING_PROTOCOL_H
30
31 #include "platform.h"
32 #include "gnunet_common.h"
33 #include "gnunet_protocols.h"
34 #include "secretsharing.h"
35
36 /**
37  * Bit length used for the Paillier crypto system.
38  */
39 #define PAILLIER_BITS 2048
40
41 GNUNET_NETWORK_STRUCT_BEGIN
42
43
44 /**
45  * Public key for the Paillier crypto system.
46  */
47 struct PaillierPublicKey
48 {
49   /**
50    * Network order representation of the
51    * g-component.
52    */
53   uint32_t g[PAILLIER_BITS / 8 / sizeof (uint32_t)];
54
55   /**
56    * Network order representation of the
57    * n-component.
58    */
59   uint32_t n[PAILLIER_BITS / 8 / sizeof (uint32_t)];
60 };
61
62
63 /**
64  * Consensus element data used in the first round of key generation.
65  */
66 struct GNUNET_SECRETSHARING_KeygenCommitData
67 {
68   /**
69    * Signature over the rest of the message.
70    */
71   struct GNUNET_CRYPTO_EddsaSignature signature;
72   /**
73    * Signature purpose for signing the keygen commit data.
74    */
75   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
76   /**
77    * Peer that inserts this element.
78    */
79   struct GNUNET_PeerIdentity peer;
80   /**
81    * Ephemeral paillier public key used by 'peer' for
82    * this session.
83    */
84   struct PaillierPublicKey pubkey GNUNET_PACKED;
85   /**
86    * Commitment of 'peer' to his presecret.
87    */
88   struct GNUNET_HashCode commitment GNUNET_PACKED;
89 };
90
91
92 struct GNUNET_SECRETSHARING_KeygenRevealData
93 {
94   /**
95    * Signature over rest of the message.
96    */
97   struct GNUNET_CRYPTO_EddsaSignature signature;
98   /*
99    * Signature purpose for signing the keygen commit data.
100    */
101   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
102   /**
103    * Peer that inserts this element.
104    */
105   struct GNUNET_PeerIdentity peer;
106
107   /* values follow */
108 };
109
110
111 /**
112  * Data of then element put in consensus
113  * for decrypting a value.
114  */
115 struct GNUNET_SECRETSHARING_DecryptData
116 {
117   /*
118    * Signature over rest of the message.
119    */
120   struct GNUNET_CRYPTO_EddsaSignature signature;
121   /*
122    * Signature purpose for signing the keygen commit data.
123    */
124   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
125   /**
126    * Ciphertext we want to decrypt.
127    */
128   struct GNUNET_SECRETSHARING_Ciphertext ciphertext;
129   /**
130    * Peer that inserts this element.
131    */
132   struct GNUNET_PeerIdentity peer;
133   /**
134    * Partial decryption, computed as c_1^{s_i}
135    */
136   struct GNUNET_SECRETSHARING_FieldElement partial_decryption;
137   /**
138    * Commitment for the non-interactive zero knowledge proof.
139    * g^\beta, with \beta < q
140    */
141   struct GNUNET_SECRETSHARING_FieldElement nizk_commit1;
142   /**
143    * Commitment for the non-interactive zero knowledge proof.
144    * c_1^\beta, with \beta < q
145    */
146   struct GNUNET_SECRETSHARING_FieldElement nizk_commit2;
147   /**
148    * Reponse to the challenge computed from the protocol transcript.
149    * r = \beta + challenge \cdot share_i
150    */
151   struct GNUNET_SECRETSHARING_FieldElement nizk_response;
152 };
153
154 GNUNET_NETWORK_STRUCT_END
155
156 #endif