2 This file is part of GNUnet.
3 (C) 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 2, 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 vectorproduct/gnunet_vectorproduct.h
23 * @brief API to the vectorproduct service
24 * @author Christian M. Fuchs
27 #ifndef GNUNET_VECTORPRODUCT_H
28 #define GNUNET_VECTORPRODUCT_H
30 ///////////////////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////////////////
33 #define DISABLE_CRYPTO
36 * Length of the key used for encryption
41 * When performing our crypto, we may add two encrypted values with each
42 * a maximal length of GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH.
43 * thus we can receive a slightly longer element (+1 byte)
45 #define PAILLIER_ELEMENT_LENGTH (2*KEYBITS/8 +1)
52 ///////////////////////////////////////////////////////////////////////////////
53 // Service Structure Definitions
54 ///////////////////////////////////////////////////////////////////////////////
57 * Message type passed from requesting service Alice to responding service Bob
58 * to initiate a request and make bob participate in our protocol
60 struct GNUNET_VECTORPRODUCT_service_request {
62 * GNUNET message header
64 struct GNUNET_MessageHeader header;
67 * how many bytes the mask has
69 uint16_t mask_length GNUNET_PACKED;
72 * the length of the publickey contained within this message
74 uint16_t pk_length GNUNET_PACKED;
77 * the transaction/session key used to identify a session
79 struct GNUNET_HashCode key;
82 * how many elements the vector in payload contains
84 uint16_t element_count GNUNET_PACKED;
87 * how many elements are actually included after the mask was applied.
89 uint16_t used_element_count GNUNET_PACKED;
92 * followed by mask | public_key | vector[used_element_count]
97 * Message type passed from responding service Bob to responding service Alice
98 * to complete a request and allow Alice to compute the result
100 struct GNUNET_VECTORPRODUCT_service_response {
102 * GNUNET message header
104 struct GNUNET_MessageHeader header;
107 * how many elements the vector in payload contains
109 uint16_t element_count GNUNET_PACKED;
112 * how many elements are actually included after the mask was applied.
114 uint16_t used_element_count GNUNET_PACKED;
117 * the transaction/session key used to identify a session
119 struct GNUNET_HashCode key;
122 * followed by s | s' | kp[] | kq[]
126 ///////////////////////////////////////////////////////////////////////////////
127 // Service Structure Definitions
128 ///////////////////////////////////////////////////////////////////////////////
131 * state a session can be in
135 WAITING_FOR_BOBS_CONNECT,
136 MESSAGE_FROM_RESPONDING_CLIENT_RECEIVED,
137 WAITING_FOR_RESPONSE_FROM_SERVICE,
138 REQUEST_FROM_SERVICE_RECEIVED,
143 * role a peer in a session can assume
151 * A vectorproduct session which tracks:
153 * a request form the client to our final response.
155 * a request from a service to us(service).
157 struct ServiceSession
160 * the role this peer has
165 * session information is kept in a DLL
167 struct ServiceSession *next;
170 * session information is kept in a DLL
172 struct ServiceSession *prev;
175 * (hopefully) unique transaction ID
177 struct GNUNET_HashCode key;
180 * state of the session
182 enum SessionState state;
185 * Alice or Bob's peerID
187 struct GNUNET_PeerIdentity peer;
190 * the client this request is related to
192 struct GNUNET_SERVER_Client * client;
195 * how many elements we were supplied with from the client
197 uint16_t element_count;
200 * how many elements actually are used after applying the mask
202 uint16_t used_element_count;
205 * how many bytes the mask is long.
206 * just for convenience so we don't have to re-re-re calculate it each time
208 uint16_t mask_length;
211 * all the vector elements we received
216 * mask of which elements to check
218 unsigned char * mask;
221 * Public key of the remote service, only used by bob
223 gcry_sexp_t remote_pubkey;
226 * E(ai)(Bob) or ai(Alice) after applying the mask
231 * The computed scalar
236 * My transmit handle for the current message to a alice/bob
238 struct GNUNET_MESH_TransmitHandle * service_transmit_handle;
241 * My transmit handle for the current message to the client
243 struct GNUNET_SERVER_TransmitHandle * client_transmit_handle;
246 * tunnel-handle associated with our mesh handle
248 struct GNUNET_MESH_Tunnel * tunnel;
253 * We need to do a minimum of bookkeeping to maintain track of our transmit handles.
254 * each msg is associated with a session and handle. using this information we can determine which msg was sent.
259 * The handle used to transmit with this request
261 void ** transmit_handle;
264 * The message to send
266 struct GNUNET_MessageHeader * msg;
273 #endif /* GNUNET_VECTORPRODUCT_H */