aboutsummaryrefslogtreecommitdiff
path: root/src/secretsharing/secretsharing.h
blob: 8bd1b05b5dab3dee7b51ed85d3ac1f15d9cd26b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
     This file is part of GNUnet.
     (C) 2013 Christian Grothoff (and other contributing authors)

     GNUnet is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published
     by the Free Software Foundation; either version 3, or (at your
     option) any later version.

     GNUnet is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with GNUnet; see the file COPYING.  If not, write to the
     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.
*/

/**
 * @author Florian Dold
 * @file secretsharing/secretsharing.h
 * @brief messages used for the secretsharing api
 */
#ifndef SECRETSHARING_H
#define SECRETSHARING_H

#include "platform.h"
#include "gnunet_common.h"
#include "gnunet_time_lib.h"
#include "gnunet_secretsharing_service.h"


GNUNET_NETWORK_STRUCT_BEGIN


struct GNUNET_SECRETSHARING_CreateMessage
{
  /**
   * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_GENERATE
   */
  struct GNUNET_MessageHeader header;

  /**
   * Session ID, will be used for consensus.
   */
  struct GNUNET_HashCode session_id GNUNET_PACKED;

  /**
   * Deadline for the establishment of the crypto system.
   */
  struct GNUNET_TIME_AbsoluteNBO deadline;

  /**
   * Mininum number of cooperating peers to decrypt a 
   * value.
   */
  uint16_t threshold GNUNET_PACKED;

  /**
   * Number of peers at the end of this message.
   */
  uint16_t num_peers GNUNET_PACKED;

  /* struct GNUNET_PeerIdentity[num_peers]; */
};


struct GNUNET_SECRETSHARING_SecretReadyMessage
{
  /**
   * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY
   */
  struct GNUNET_MessageHeader header;

  /**
   * Secret share in network byte order.
   */
  unsigned char secret[GNUNET_SECRETSHARING_KEY_BITS / 8];

  /**
   * Secret share in network byte order.
   */
  struct GNUNET_SECRETSHARING_PublicKey public_key;

  /**
   * Number of peers at the end of this message.
   * Includes peers that are part of the established
   * threshold crypto system.
   */
  uint16_t num_secret_peers GNUNET_PACKED;

  /* struct GNUNET_PeerIdentity[num_peers]; */
};


struct GNUNET_SECRETSHARING_DecryptRequestMessage
{
  /**
   * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_REQUEST
   */
  struct GNUNET_MessageHeader header;

  /**
   * Ciphertext to request decryption for.
   */
  unsigned char ciphertext[GNUNET_SECRETSHARING_KEY_BITS / 8];

  /**
   * Number of peers at the end of this message.
   * Includes peers that are part of the established
   * threshold crypto system.
   */
  uint16_t num_secret_peers GNUNET_PACKED;

  /* struct GNUNET_PeerIdentity[num_peers]; */
};


struct GNUNET_SECRETSHARING_DecryptResponseMessage
{
  /**
   * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_RESPONSE
   */
  struct GNUNET_MessageHeader header;

  /**
   * Ciphertext to request decryption for.
   */
  unsigned char plaintext[GNUNET_SECRETSHARING_KEY_BITS / 8];
};


GNUNET_NETWORK_STRUCT_END

#endif