2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011, 2012, 2013 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file scalarproduct.h
23 * @brief Scalar Product Message Types
24 * @author Christian M. Fuchs
26 * Created on September 2, 2013, 3:43 PM
29 #ifndef SCALARPRODUCT_H
30 #define SCALARPRODUCT_H
36 ///////////////////////////////////////////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////////////
40 * Length of the key used for encryption
45 * When performing our crypto, we may add two encrypted values with each
46 * a maximal length of GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH.
47 * thus we can receive a slightly longer element (+1 byte)
49 #define PAILLIER_ELEMENT_LENGTH (2*KEYBITS/8 +1)
52 * Log an error message at log-level 'level' that indicates
53 * a failure of the command 'cmd' with the message given
54 * by gcry_strerror(rc).
56 #define LOG_GCRY(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0)
58 ///////////////////////////////////////////////////////////////////////////////
59 // Scalar Product Message Types
60 ///////////////////////////////////////////////////////////////////////////////
63 * Message type passed from client to service
64 * to initiate a request or responder role
66 struct GNUNET_SCALARPRODUCT_client_request
69 * GNUNET message header
71 struct GNUNET_MessageHeader header;
74 * how many elements the vector in payload contains
76 uint32_t element_count GNUNET_PACKED;
79 * how many bytes the mask has
81 uint32_t mask_length GNUNET_PACKED;
84 * the transaction/session key used to identify a session
86 struct GNUNET_HashCode key;
89 * the identity of a remote peer we want to communicate with
91 struct GNUNET_PeerIdentity peer;
94 * followed by long vector[element_count] | [unsigned char mask[mask_bytes]]
99 * Message type passed from requesting service Alice to responding service Bob
100 * to initiate a request and make bob participate in our protocol
102 struct GNUNET_SCALARPRODUCT_service_request {
104 * GNUNET message header
106 struct GNUNET_MessageHeader header;
109 * how many elements the total message including all multipart msgs contains
111 uint32_t total_element_count GNUNET_PACKED;
114 * how many elements are actually included after the mask was applied.
116 uint32_t contained_element_count GNUNET_PACKED;
119 * how many bytes the mask has
121 uint32_t mask_length GNUNET_PACKED;
124 * the length of the publickey contained within this message
126 uint32_t pk_length GNUNET_PACKED;
129 * the transaction/session key used to identify a session
131 struct GNUNET_HashCode key;
134 * how many elements the vector in payload contains
136 uint32_t element_count GNUNET_PACKED;
139 * followed by mask | public_key | vector[used_element_count]
144 * Multipart Message type passed between to supply additional elements for the peer
146 struct GNUNET_SCALARPRODUCT_multipart_message {
148 * GNUNET message header
150 struct GNUNET_MessageHeader header;
153 * how many elements we supply within this message
155 uint32_t multipart_element_count GNUNET_PACKED;
157 // followed by vector[multipart_element_count] or k[i][perm]
161 * Message type passed from responding service Bob to responding service Alice
162 * to complete a request and allow Alice to compute the result
164 struct GNUNET_SCALARPRODUCT_service_response {
166 * GNUNET message header
168 struct GNUNET_MessageHeader header;
171 * how many elements the session input had
173 uint32_t total_element_count GNUNET_PACKED;
176 * how many elements were included after the mask was applied including all multipart msgs.
178 uint32_t used_element_count GNUNET_PACKED;
181 * how many elements this individual message delivers
183 uint32_t contained_element_count GNUNET_PACKED;
186 * the transaction/session key used to identify a session
188 struct GNUNET_HashCode key;
191 * followed by s | s' | k[i][perm]
196 * Message type passed from service client
197 * to finalize a session as requester or responder
199 struct GNUNET_SCALARPRODUCT_client_response
202 * GNUNET message header
204 struct GNUNET_MessageHeader header;
207 * 0 if no product attached
209 uint32_t product_length GNUNET_PACKED;
212 * the transaction/session key used to identify a session
214 struct GNUNET_HashCode key;
217 * the identity of a remote peer we want to communicate with
219 struct GNUNET_PeerIdentity peer;
222 * Workaround for libgcrypt: -1 if negative, 0 if zero, else 1
227 * followed by product of length product_length (or nothing)
235 #endif /* SCALARPRODUCT_H */