aboutsummaryrefslogtreecommitdiff
path: root/src/contrib/service/scalarproduct/scalarproduct.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/contrib/service/scalarproduct/scalarproduct.h')
-rw-r--r--src/contrib/service/scalarproduct/scalarproduct.h177
1 files changed, 177 insertions, 0 deletions
diff --git a/src/contrib/service/scalarproduct/scalarproduct.h b/src/contrib/service/scalarproduct/scalarproduct.h
new file mode 100644
index 000000000..f2311cda0
--- /dev/null
+++ b/src/contrib/service/scalarproduct/scalarproduct.h
@@ -0,0 +1,177 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010, 2011, 2012, 2013 GNUnet e.V.
4
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.
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 Affero General Public License for more details.
14
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/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file scalarproduct.h
22 * @brief Scalar Product API Message Types
23 * @author Christian M. Fuchs
24 */
25#ifndef SCALARPRODUCT_H
26#define SCALARPRODUCT_H
27
28GNUNET_NETWORK_STRUCT_BEGIN
29
30/**
31 * Log an error message at log-level 'level' that indicates
32 * a failure of the command 'cmd' with the message given
33 * by gcry_strerror(rc).
34 */
35#define LOG_GCRY(level, cmd, rc) do { LOG (level, _ ( \
36 "`%s' failed at %s:%d with error: %s\n"), \
37 cmd, __FILE__, __LINE__, \
38 gcry_strerror (rc)); } while (0)
39
40
41/**
42 * Message type passed from client to service
43 * to initiate a request or responder role
44 */
45struct AliceComputationMessage
46{
47 /**
48 * GNUNET message header with type
49 * #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE
50 */
51 struct GNUNET_MessageHeader header;
52
53 /**
54 * how many elements the vector in payload contains
55 */
56 uint32_t element_count_total GNUNET_PACKED;
57
58 /**
59 * contained elements the vector in payload contains
60 */
61 uint32_t element_count_contained GNUNET_PACKED;
62
63 /**
64 * Always zero.
65 */
66 uint32_t reserved GNUNET_PACKED;
67
68 /**
69 * the transaction/session key used to identify a session
70 */
71 struct GNUNET_HashCode session_key;
72
73 /**
74 * the identity of a remote peer we want to communicate with
75 */
76 struct GNUNET_PeerIdentity peer;
77
78 /**
79 * followed by struct GNUNET_SCALARPRODUCT_Element[]
80 */
81};
82
83
84/**
85 * Message type passed from client to service
86 * to initiate a request or responder role
87 */
88struct BobComputationMessage
89{
90 /**
91 * GNUNET message header with type
92 * #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB
93 */
94 struct GNUNET_MessageHeader header;
95
96 /**
97 * how many elements the vector in payload contains
98 */
99 uint32_t element_count_total GNUNET_PACKED;
100
101 /**
102 * contained elements the vector in payload contains
103 */
104 uint32_t element_count_contained GNUNET_PACKED;
105
106 /**
107 * Always zero.
108 */
109 uint32_t reserved GNUNET_PACKED;
110
111 /**
112 * the transaction/session key used to identify a session
113 */
114 struct GNUNET_HashCode session_key;
115
116 /**
117 * followed by struct GNUNET_SCALARPRODUCT_Element[]
118 */
119};
120
121
122/**
123 * multipart messages following `struct ComputationMessage`
124 */
125struct ComputationBobCryptodataMultipartMessage
126{
127 /**
128 * GNUNET message header
129 */
130 struct GNUNET_MessageHeader header;
131
132 /**
133 * contained elements the vector in payload contains
134 */
135 uint32_t element_count_contained GNUNET_PACKED;
136
137 /**
138 * followed by struct GNUNET_SCALARPRODUCT_Element[]
139 */
140};
141
142
143/**
144 * Message type passed from service client
145 * to finalize a session as requester or responder
146 */
147struct ClientResponseMessage
148{
149 /**
150 * GNUNET message header
151 */
152 struct GNUNET_MessageHeader header;
153
154 /**
155 * 0 if no product attached
156 */
157 uint32_t product_length GNUNET_PACKED;
158
159 /**
160 * Status information about the outcome of this session,
161 * An `enum GNUNET_SCALARPRODUCT_ResponseStatus` (in NBO).
162 */
163 uint32_t status GNUNET_PACKED;
164
165 /**
166 * Workaround for libgcrypt: -1 if negative, 0 if zero, else 1
167 */
168 int32_t range GNUNET_PACKED;
169
170 /**
171 * followed by product of length product_length (or nothing)
172 */
173};
174
175GNUNET_NETWORK_STRUCT_END
176
177#endif /* SCALARPRODUCT_H */