2 This file is part of GNUnet.
3 Copyright (C) 2013, 2014 GNUnet e.V.
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.
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.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @author Christian M. Fuchs
23 * @author Gaurav Kukreja
26 * API to the scalarproduct service
28 * @defgroup scalarproduct Scalar Product service
32 #ifndef GNUNET_SCALARPRODUCT_SERVICE_H
33 #define GNUNET_SCALARPRODUCT_SERVICE_H
34 #define GCRYPT_NO_DEPRECATED
39 #if 0 /* keep Emacsens' auto-indent happy */
45 * Version of the scalarproduct API.
47 #define GNUNET_SCALARPRODUCT_VERSION 0x00000044
50 * Result status values for the computation.
52 enum GNUNET_SCALARPRODUCT_ResponseStatus
55 * Operation is still active (never returned, used internally).
57 GNUNET_SCALARPRODUCT_STATUS_INIT = 0,
60 * Operation is still active (never returned, used internally).
62 GNUNET_SCALARPRODUCT_STATUS_ACTIVE = 1,
65 * The computation was successful.
67 GNUNET_SCALARPRODUCT_STATUS_SUCCESS,
70 * We encountered some error.
72 GNUNET_SCALARPRODUCT_STATUS_FAILURE,
75 * We got an invalid response.
77 GNUNET_SCALARPRODUCT_STATUS_INVALID_RESPONSE,
80 * We got disconnected from the SCALARPRODUCT service.
82 GNUNET_SCALARPRODUCT_STATUS_DISCONNECTED
87 * Opaque declaration of the SP-Handle
89 struct GNUNET_SCALARPRODUCT_Handle;
92 GNUNET_NETWORK_STRUCT_BEGIN
95 * An element key-value pair for scalarproduct
97 struct GNUNET_SCALARPRODUCT_Element
100 * Key used to identify matching pairs of values to multiply.
102 struct GNUNET_HashCode key;
105 * Value to multiply in scalar product, in NBO.
107 int64_t value GNUNET_PACKED;
110 GNUNET_NETWORK_STRUCT_END
114 * Continuation called to notify client about result of the
118 * @param status Status of the request
121 (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
123 GNUNET_SCALARPRODUCT_ResponseStatus
128 * Process a datum that was stored in the scalarproduct.
131 * @param status Status of the request
132 * @param result result of the computation
135 (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
136 enum GNUNET_SCALARPRODUCT_ResponseStatus
142 * Entry in the request queue per client
144 struct GNUNET_SCALARPRODUCT_ComputationHandle;
148 * Request by Alice's client for computing a scalar product
150 * @param cfg the gnunet configuration handle
151 * @param session_key Session key should be unique to the requesting client
152 * @param peer PeerID of the other peer
153 * @param elements Array of elements of the vector
154 * @param element_count Number of elements in the @a elements vector
155 * @param cont Callback function
156 * @param cont_cls Closure for the @a cont callback function
157 * @return a new handle for this computation
159 struct GNUNET_SCALARPRODUCT_ComputationHandle *
160 GNUNET_SCALARPRODUCT_start_computation (const struct
161 GNUNET_CONFIGURATION_Handle *cfg,
163 GNUNET_HashCode *session_key,
164 const struct GNUNET_PeerIdentity *peer,
166 GNUNET_SCALARPRODUCT_Element *elements,
167 uint32_t element_count,
168 GNUNET_SCALARPRODUCT_DatumProcessor cont,
173 * Used by Bob's client to cooperate with Alice,
175 * @param cfg the gnunet configuration handle
176 * @param session_key Session key unique to the requesting client
177 * @param elements Array of elements of the vector
178 * @param element_count Number of elements in the @a elements vector
179 * @param cont Callback function
180 * @param cont_cls Closure for the @a cont callback function
181 * @return a new handle for this computation
183 struct GNUNET_SCALARPRODUCT_ComputationHandle *
184 GNUNET_SCALARPRODUCT_accept_computation (const struct
185 GNUNET_CONFIGURATION_Handle *cfg,
186 const struct GNUNET_HashCode *key,
188 GNUNET_SCALARPRODUCT_Element *elements,
189 uint32_t element_count,
190 GNUNET_SCALARPRODUCT_ContinuationWithStatus
196 * Cancel an ongoing computation or revoke our collaboration offer.
197 * Closes the connection to the service
199 * @param h computation handle to terminate
202 GNUNET_SCALARPRODUCT_cancel (struct GNUNET_SCALARPRODUCT_ComputationHandle *h);
205 #if 0 /* keep Emacsens' auto-indent happy */
214 /** @} */ /* end of group */