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 ///////////////////////////////////////////////////////////////////////////////
41 * Maximum count of elements we can put into a multipart message
43 #define MULTIPART_ELEMENT_CAPACITY ((GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct GNUNET_SCALARPRODUCT_multipart_message)) / sizeof (struct GNUNET_CRYPTO_PaillierCiphertext))
46 * Log an error message at log-level 'level' that indicates
47 * a failure of the command 'cmd' with the message given
48 * by gcry_strerror(rc).
50 #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)
52 ///////////////////////////////////////////////////////////////////////////////
53 // Scalar Product Message Types
54 ///////////////////////////////////////////////////////////////////////////////
57 * Message type passed from client to service
58 * to initiate a request or responder role
60 struct GNUNET_SCALARPRODUCT_client_request
63 * GNUNET message header
65 struct GNUNET_MessageHeader header;
68 * how many elements the vector in payload contains
70 uint32_t element_count GNUNET_PACKED;
73 * how many bytes the mask has
75 uint32_t mask_length GNUNET_PACKED;
78 * the transaction/session key used to identify a session
80 struct GNUNET_HashCode key;
83 * the identity of a remote peer we want to communicate with
85 struct GNUNET_PeerIdentity peer;
88 * followed by long vector[element_count] | [unsigned char mask[mask_bytes]]
93 * Message type passed from requesting service Alice to responding service Bob
94 * to initiate a request and make bob participate in our protocol
96 struct GNUNET_SCALARPRODUCT_service_request {
98 * GNUNET message header
100 struct GNUNET_MessageHeader header;
103 * how many elements the total message including all multipart msgs contains
105 uint32_t total_element_count GNUNET_PACKED;
108 * how many elements are actually included after the mask was applied.
110 uint32_t contained_element_count GNUNET_PACKED;
113 * how many bytes the mask has
115 uint32_t mask_length GNUNET_PACKED;
118 * the transaction/session key used to identify a session
120 struct GNUNET_HashCode key;
123 * how many elements the vector in payload contains
125 uint32_t element_count GNUNET_PACKED;
128 * followed by mask | public_key | vector[used_element_count]
133 * Multipart Message type passed between to supply additional elements for the peer
135 struct GNUNET_SCALARPRODUCT_multipart_message {
137 * GNUNET message header
139 struct GNUNET_MessageHeader header;
142 * how many elements we supply within this message
144 uint32_t multipart_element_count GNUNET_PACKED;
146 // followed by vector[multipart_element_count] or k[i][perm]
150 * Message type passed from responding service Bob to responding service Alice
151 * to complete a request and allow Alice to compute the result
153 struct GNUNET_SCALARPRODUCT_service_response {
155 * GNUNET message header
157 struct GNUNET_MessageHeader header;
160 * how many elements the session input had
162 uint32_t total_element_count GNUNET_PACKED;
165 * how many elements were included after the mask was applied including all multipart msgs.
167 uint32_t used_element_count GNUNET_PACKED;
170 * how many elements this individual message delivers
172 uint32_t contained_element_count GNUNET_PACKED;
175 * the transaction/session key used to identify a session
177 struct GNUNET_HashCode key;
180 * followed by s | s' | k[i][perm]
185 * Message type passed from service client
186 * to finalize a session as requester or responder
188 struct GNUNET_SCALARPRODUCT_client_response
191 * GNUNET message header
193 struct GNUNET_MessageHeader header;
196 * 0 if no product attached
198 uint32_t product_length GNUNET_PACKED;
201 * the transaction/session key used to identify a session
203 struct GNUNET_HashCode key;
206 * the identity of a remote peer we want to communicate with
208 struct GNUNET_PeerIdentity peer;
211 * Workaround for libgcrypt: -1 if negative, 0 if zero, else 1
216 * followed by product of length product_length (or nothing)
224 #endif /* SCALARPRODUCT_H */