secretsharing.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 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. * @author Florian Dold
  18. * @file secretsharing/secretsharing.h
  19. * @brief messages used for the secretsharing api
  20. */
  21. #ifndef SECRETSHARING_H
  22. #define SECRETSHARING_H
  23. #include "platform.h"
  24. #include "gnunet_util_lib.h"
  25. #include "gnunet_time_lib.h"
  26. #include "gnunet_common.h"
  27. #include "gnunet_secretsharing_service.h"
  28. GNUNET_NETWORK_STRUCT_BEGIN
  29. struct GNUNET_SECRETSHARING_FieldElement
  30. {
  31. /**
  32. * Value of an element in &lt;elgamal_g&gt;.
  33. */
  34. unsigned char bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8];
  35. };
  36. struct GNUNET_SECRETSHARING_CreateMessage
  37. {
  38. /**
  39. * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_GENERATE
  40. */
  41. struct GNUNET_MessageHeader header;
  42. /**
  43. * Session ID, will be used for consensus.
  44. */
  45. struct GNUNET_HashCode session_id GNUNET_PACKED;
  46. /**
  47. * Start time for communication with the other peers.
  48. */
  49. struct GNUNET_TIME_AbsoluteNBO start;
  50. /**
  51. * Deadline for the establishment of the crypto system.
  52. */
  53. struct GNUNET_TIME_AbsoluteNBO deadline;
  54. /**
  55. * Minimum number of cooperating peers to decrypt a
  56. * value.
  57. */
  58. uint16_t threshold GNUNET_PACKED;
  59. /**
  60. * Number of peers at the end of this message.
  61. */
  62. uint16_t num_peers GNUNET_PACKED;
  63. /* struct GNUNET_PeerIdentity[num_peers]; */
  64. };
  65. struct GNUNET_SECRETSHARING_ShareHeaderNBO
  66. {
  67. /**
  68. * Threshold for the key this share belongs to.
  69. */
  70. uint16_t threshold;
  71. /**
  72. * Peers that have the share.
  73. */
  74. uint16_t num_peers;
  75. /**
  76. * Index of our peer in the list.
  77. */
  78. uint16_t my_peer;
  79. /**
  80. * Public key. Must correspond to the product of
  81. * the homomorphic share commitments.
  82. */
  83. struct GNUNET_SECRETSHARING_PublicKey public_key;
  84. /**
  85. * Share of 'my_peer'
  86. */
  87. struct GNUNET_SECRETSHARING_FieldElement my_share;
  88. };
  89. /**
  90. * Notify the client that then threshold secret has been
  91. * established.
  92. */
  93. struct GNUNET_SECRETSHARING_SecretReadyMessage
  94. {
  95. /**
  96. * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY
  97. */
  98. struct GNUNET_MessageHeader header;
  99. /* rest: the serialized share */
  100. };
  101. struct GNUNET_SECRETSHARING_DecryptRequestMessage
  102. {
  103. /**
  104. * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_REQUEST
  105. */
  106. struct GNUNET_MessageHeader header;
  107. /**
  108. * Until when should the decryption start?
  109. */
  110. struct GNUNET_TIME_AbsoluteNBO start;
  111. /**
  112. * Until when should the decryption be finished?
  113. */
  114. struct GNUNET_TIME_AbsoluteNBO deadline;
  115. /**
  116. * Ciphertext we want to decrypt.
  117. */
  118. struct GNUNET_SECRETSHARING_Ciphertext ciphertext;
  119. /* the share with payload */
  120. };
  121. struct GNUNET_SECRETSHARING_DecryptResponseMessage
  122. {
  123. /**
  124. * Type: #GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_DONE
  125. */
  126. struct GNUNET_MessageHeader header;
  127. /**
  128. * Zero if decryption failed, non-zero if decryption succeeded.
  129. * If the decryption failed, plaintext is also zero.
  130. */
  131. uint32_t success GNUNET_PACKED;
  132. /**
  133. * Decrypted plaintext.
  134. */
  135. struct GNUNET_SECRETSHARING_FieldElement plaintext;
  136. };
  137. GNUNET_NETWORK_STRUCT_END
  138. /**
  139. * A share, with all values in in host byte order.
  140. */
  141. struct GNUNET_SECRETSHARING_Share
  142. {
  143. /**
  144. * Threshold for the key this share belongs to.
  145. */
  146. uint16_t threshold;
  147. /**
  148. * Peers that have the share.
  149. */
  150. uint16_t num_peers;
  151. /**
  152. * Index of our peer in the list.
  153. */
  154. uint16_t my_peer;
  155. /**
  156. * Public key. Computed from the
  157. * exponentiated coefficients.
  158. */
  159. struct GNUNET_SECRETSHARING_PublicKey public_key;
  160. /**
  161. * Share of 'my_peer'
  162. */
  163. struct GNUNET_SECRETSHARING_FieldElement my_share;
  164. /**
  165. * Peer identities (includes 'my_peer')
  166. */
  167. struct GNUNET_PeerIdentity *peers;
  168. /*
  169. * For each peer, store elgamal_g to the peer's
  170. * share.
  171. */
  172. struct GNUNET_SECRETSHARING_FieldElement *sigmas;
  173. /*
  174. * Original indices of peers from the DKG round.
  175. */
  176. uint16_t *original_indices;
  177. };
  178. #endif