scalarproduct.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009, 2010, 2011, 2012, 2013 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file scalarproduct.h
  18. * @brief Scalar Product API Message Types
  19. * @author Christian M. Fuchs
  20. */
  21. #ifndef SCALARPRODUCT_H
  22. #define SCALARPRODUCT_H
  23. GNUNET_NETWORK_STRUCT_BEGIN
  24. /**
  25. * Log an error message at log-level 'level' that indicates
  26. * a failure of the command 'cmd' with the message given
  27. * by gcry_strerror(rc).
  28. */
  29. #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)
  30. /**
  31. * Message type passed from client to service
  32. * to initiate a request or responder role
  33. */
  34. struct AliceComputationMessage
  35. {
  36. /**
  37. * GNUNET message header with type
  38. * #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE
  39. */
  40. struct GNUNET_MessageHeader header;
  41. /**
  42. * how many elements the vector in payload contains
  43. */
  44. uint32_t element_count_total GNUNET_PACKED;
  45. /**
  46. * contained elements the vector in payload contains
  47. */
  48. uint32_t element_count_contained GNUNET_PACKED;
  49. /**
  50. * Always zero.
  51. */
  52. uint32_t reserved GNUNET_PACKED;
  53. /**
  54. * the transaction/session key used to identify a session
  55. */
  56. struct GNUNET_HashCode session_key;
  57. /**
  58. * the identity of a remote peer we want to communicate with
  59. */
  60. struct GNUNET_PeerIdentity peer;
  61. /**
  62. * followed by struct GNUNET_SCALARPRODUCT_Element[]
  63. */
  64. };
  65. /**
  66. * Message type passed from client to service
  67. * to initiate a request or responder role
  68. */
  69. struct BobComputationMessage
  70. {
  71. /**
  72. * GNUNET message header with type
  73. * #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB
  74. */
  75. struct GNUNET_MessageHeader header;
  76. /**
  77. * how many elements the vector in payload contains
  78. */
  79. uint32_t element_count_total GNUNET_PACKED;
  80. /**
  81. * contained elements the vector in payload contains
  82. */
  83. uint32_t element_count_contained GNUNET_PACKED;
  84. /**
  85. * Always zero.
  86. */
  87. uint32_t reserved GNUNET_PACKED;
  88. /**
  89. * the transaction/session key used to identify a session
  90. */
  91. struct GNUNET_HashCode session_key;
  92. /**
  93. * followed by struct GNUNET_SCALARPRODUCT_Element[]
  94. */
  95. };
  96. /**
  97. * multipart messages following `struct ComputationMessage`
  98. */
  99. struct ComputationBobCryptodataMultipartMessage
  100. {
  101. /**
  102. * GNUNET message header
  103. */
  104. struct GNUNET_MessageHeader header;
  105. /**
  106. * contained elements the vector in payload contains
  107. */
  108. uint32_t element_count_contained GNUNET_PACKED;
  109. /**
  110. * followed by struct GNUNET_SCALARPRODUCT_Element[]
  111. */
  112. };
  113. /**
  114. * Message type passed from service client
  115. * to finalize a session as requester or responder
  116. */
  117. struct ClientResponseMessage
  118. {
  119. /**
  120. * GNUNET message header
  121. */
  122. struct GNUNET_MessageHeader header;
  123. /**
  124. * 0 if no product attached
  125. */
  126. uint32_t product_length GNUNET_PACKED;
  127. /**
  128. * Status information about the outcome of this session,
  129. * An `enum GNUNET_SCALARPRODUCT_ResponseStatus` (in NBO).
  130. */
  131. uint32_t status GNUNET_PACKED;
  132. /**
  133. * Workaround for libgcrypt: -1 if negative, 0 if zero, else 1
  134. */
  135. int32_t range GNUNET_PACKED;
  136. /**
  137. * followed by product of length product_length (or nothing)
  138. */
  139. };
  140. GNUNET_NETWORK_STRUCT_END
  141. #endif /* SCALARPRODUCT_H */