aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct/gnunet-service-scalarproduct.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-06 22:41:30 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-06 22:41:30 +0000
commit9d487bb2fe029b369f362bdbe4697005061a4e5e (patch)
tree5c2eb6849a5dd7a813a07e29a7f2be60af9b9792 /src/scalarproduct/gnunet-service-scalarproduct.h
parent6cd1fc3aa29926ce0326d07ba684e1b65a1a0db7 (diff)
downloadgnunet-9d487bb2fe029b369f362bdbe4697005061a4e5e.tar.gz
gnunet-9d487bb2fe029b369f362bdbe4697005061a4e5e.zip
massive rework of scalarproduct service, splitting into Alice and Bob
Diffstat (limited to 'src/scalarproduct/gnunet-service-scalarproduct.h')
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct.h165
1 files changed, 165 insertions, 0 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.h b/src/scalarproduct/gnunet-service-scalarproduct.h
new file mode 100644
index 000000000..9a5008628
--- /dev/null
+++ b/src/scalarproduct/gnunet-service-scalarproduct.h
@@ -0,0 +1,165 @@
1/*
2 This file is part of GNUnet.
3 (C) 2013, 2014 Christian Grothoff (and other contributing authors)
4
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.
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 General Public License for more details.
14
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.
19 */
20/**
21 * @file scalarproduct/gnunet-service-scalarproduct.h
22 * @brief scalarproduct service P2P messages
23 * @author Christian M. Fuchs
24 * @author Christian Grothoff
25 */
26#ifndef GNUNET_SERVICE_SCALARPRODUCT_H
27#define GNUNET_SERVICE_SCALARPRODUCT_H
28
29/**
30 * Maximum count of elements we can put into a multipart message
31 */
32#define MULTIPART_ELEMENT_CAPACITY ((GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct MultipartMessage)) / sizeof (struct GNUNET_CRYPTO_PaillierCiphertext))
33
34
35GNUNET_NETWORK_STRUCT_BEGIN
36
37/**
38 * Message type passed from requesting service Alice to responding
39 * service Bob to initiate a request and make Bob participate in our
40 * protocol. Afterwards, Bob is expected to perform the set
41 * intersection with Alice. Once that has succeeded, Alice will
42 * send a `struct AliceCryptodataMessage *`. Bob is not expected
43 * to respond via CADET in the meantime.
44 */
45struct ServiceRequestMessage
46{
47 /**
48 * Type is #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_SESSION_INITIALIZATION
49 */
50 struct GNUNET_MessageHeader header;
51
52 /**
53 * For alignment. Always zero.
54 */
55 uint32_t reserved;
56
57 /**
58 * The transaction/session key used to identify a session
59 */
60 struct GNUNET_HashCode session_id;
61
62 /**
63 * Alice's public key
64 */
65 struct GNUNET_CRYPTO_PaillierPublicKey public_key;
66
67};
68
69
70/**
71 * Vector of Pallier-encrypted values sent by Alice to Bob
72 * (after set intersection). Alice may send messages of this
73 * type repeatedly to transmit all values.
74 */
75struct AliceCryptodataMessage
76{
77 /**
78 * Type is #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_CRYPTODATA
79 */
80 struct GNUNET_MessageHeader header;
81
82 /**
83 * How many elements we appended to this message? In NBO.
84 */
85 uint32_t contained_element_count GNUNET_PACKED;
86
87 /**
88 * struct GNUNET_CRYPTO_PaillierCiphertext[contained_element_count]
89 */
90};
91
92
93/**
94 * Message type passed from responding service Bob to responding
95 * service Alice to complete a request and allow Alice to compute the
96 * result. If Bob's reply does not fit into this one message, the
97 * conversation may be continued with `struct MultipartMessage`
98 * messages afterwards.
99 */
100struct ServiceResponseMessage
101{
102 /**
103 * GNUNET message header with type
104 * #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA.
105 */
106 struct GNUNET_MessageHeader header;
107
108 /**
109 * How many elements the session input had (in NBO).
110 */
111 uint32_t total_element_count GNUNET_PACKED;
112
113 /**
114 * How many elements were included after the mask was applied
115 * including all multipart msgs (in NBO).
116 */
117 uint32_t used_element_count GNUNET_PACKED;
118
119 /**
120 * How many elements this individual message delivers (in NBO).
121 */
122 uint32_t contained_element_count GNUNET_PACKED;
123
124 /**
125 * The transaction/session key used to identify a session.
126 * FIXME: needed? CADET should already identify sessions!
127 */
128 struct GNUNET_HashCode key;
129
130 /**
131 * followed by s | s' | k[i][perm]
132 */
133};
134
135
136/**
137 * Multipart Message type passed between to supply additional elements
138 * for the peer. Send from Bob to Alice with additional elements
139 * of k[i][perm] after his `struct ServiceResponseMessage *`.
140 * Once all k-values have been transmitted, Bob is finished and
141 * Alice can transmit the final result to the client.
142 */
143struct MultipartMessage
144{
145 /**
146 * GNUNET message header
147 */
148 struct GNUNET_MessageHeader header;
149
150 /**
151 * How many elements we supply within this message? In NBO.
152 */
153 uint32_t contained_element_count GNUNET_PACKED;
154
155 /**
156 * struct GNUNET_CRYPTO_PaillierCiphertext[multipart_element_count]
157 */
158};
159
160
161
162GNUNET_NETWORK_STRUCT_END
163
164
165#endif