gnunet-service-scalarproduct.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2013, 2014 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/gnunet-service-scalarproduct.h
  18. * @brief scalarproduct service P2P messages
  19. * @author Christian M. Fuchs
  20. * @author Christian Grothoff
  21. */
  22. #ifndef GNUNET_SERVICE_SCALARPRODUCT_H
  23. #define GNUNET_SERVICE_SCALARPRODUCT_H
  24. GNUNET_NETWORK_STRUCT_BEGIN
  25. /**
  26. * Message type passed from requesting service Alice to responding
  27. * service Bob to initiate a request and make Bob participate in our
  28. * protocol. Afterwards, Bob is expected to perform the set
  29. * intersection with Alice. Once that has succeeded, Alice will
  30. * send a `struct AliceCryptodataMessage *`. Bob is not expected
  31. * to respond via CADET in the meantime.
  32. */
  33. struct ServiceRequestMessage
  34. {
  35. /**
  36. * Type is #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_SESSION_INITIALIZATION
  37. */
  38. struct GNUNET_MessageHeader header;
  39. /**
  40. * For alignment. Always zero.
  41. */
  42. uint32_t reserved;
  43. /**
  44. * The transaction/session key used to identify a session
  45. */
  46. struct GNUNET_HashCode session_id;
  47. /**
  48. * Alice's public key
  49. */
  50. struct GNUNET_CRYPTO_PaillierPublicKey public_key;
  51. };
  52. /**
  53. * Vector of Pallier-encrypted values sent by Alice to Bob
  54. * (after set intersection). Alice may send messages of this
  55. * type repeatedly to transmit all values.
  56. */
  57. struct AliceCryptodataMessage
  58. {
  59. /**
  60. * Type is #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_CRYPTODATA
  61. */
  62. struct GNUNET_MessageHeader header;
  63. /**
  64. * How many elements we appended to this message? In NBO.
  65. */
  66. uint32_t contained_element_count GNUNET_PACKED;
  67. /**
  68. * struct GNUNET_CRYPTO_PaillierCiphertext[contained_element_count]
  69. */
  70. };
  71. /**
  72. * Message type passed from responding service Bob to responding
  73. * service Alice to complete a request and allow Alice to compute the
  74. * result. If Bob's reply does not fit into this one message, the
  75. * conversation may be continued with `struct BobCryptodataMultipartMessage`
  76. * messages afterwards.
  77. */
  78. struct BobCryptodataMessage
  79. {
  80. /**
  81. * GNUNET message header with type
  82. * #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA.
  83. */
  84. struct GNUNET_MessageHeader header;
  85. /**
  86. * How many elements this individual message delivers (in NBO).
  87. */
  88. uint32_t contained_element_count GNUNET_PACKED;
  89. /**
  90. * followed by s | s' | k[i][perm]
  91. */
  92. };
  93. /**
  94. * Multipart Message type passed between to supply additional elements
  95. * for the peer. Send from Bob to Alice with additional elements
  96. * of k[i][perm] after his `struct BobCryptodataMessage *`.
  97. * Once all k-values have been transmitted, Bob is finished and
  98. * Alice can transmit the final result to the client.
  99. */
  100. struct BobCryptodataMultipartMessage
  101. {
  102. /**
  103. * GNUNET message header
  104. */
  105. struct GNUNET_MessageHeader header;
  106. /**
  107. * How many elements we supply within this message? In NBO.
  108. */
  109. uint32_t contained_element_count GNUNET_PACKED;
  110. /**
  111. * Followed by `struct
  112. * GNUNET_CRYPTO_PaillierCiphertext[contained_element_count]`
  113. */
  114. };
  115. GNUNET_NETWORK_STRUCT_END
  116. #endif