/*
This file is part of GNUnet.
- (C) 2013 Christian Grothoff (and other contributing authors)
+ Copyright (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
#define SECRETSHARING_H
#include "platform.h"
-#include "gnunet_common.h"
+#include "gnunet_util_lib.h"
#include "gnunet_time_lib.h"
+#include "gnunet_common.h"
#include "gnunet_secretsharing_service.h"
GNUNET_NETWORK_STRUCT_BEGIN
+struct GNUNET_SECRETSHARING_FieldElement
+{
+ /**
+ * Value of an element in <elgamal_g>.
+ */
+ unsigned char bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8];
+};
+
struct GNUNET_SECRETSHARING_CreateMessage
{
*/
struct GNUNET_HashCode session_id GNUNET_PACKED;
+ /**
+ * Start time for communication with the other peers.
+ */
+ struct GNUNET_TIME_AbsoluteNBO start;
+
/**
* Deadline for the establishment of the crypto system.
*/
};
-struct GNUNET_SECRETSHARING_SecretReadyMessage
+
+struct GNUNET_SECRETSHARING_ShareHeaderNBO
{
/**
- * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY
+ * Threshold for the key this share belongs to.
*/
- struct GNUNET_MessageHeader header;
+ uint16_t threshold;
/**
- * Secret share in network byte order.
+ * Peers that have the share.
*/
- unsigned char secret[GNUNET_SECRETSHARING_KEY_BITS / 8];
+ uint16_t num_peers;
/**
- * Secret share in network byte order.
+ * Index of our peer in the list.
+ */
+ uint16_t my_peer;
+
+ /**
+ * Public key. Must correspond to the product of
+ * the homomorphic share commitments.
*/
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.
+ * Share of 'my_peer'
*/
- uint16_t num_secret_peers GNUNET_PACKED;
+ struct GNUNET_SECRETSHARING_FieldElement my_share;
+};
+
+
+/**
+ * Notify the client that then threshold secret has been
+ * established.
+ */
+struct GNUNET_SECRETSHARING_SecretReadyMessage
+{
+ /**
+ * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY
+ */
+ struct GNUNET_MessageHeader header;
+
+ /* rest: the serialized share */
- /* struct GNUNET_PeerIdentity[num_peers]; */
};
struct GNUNET_MessageHeader header;
/**
- * Ciphertext to request decryption for.
+ * Until when should the decryption start?
*/
- unsigned char ciphertext[GNUNET_SECRETSHARING_KEY_BITS / 8];
+ struct GNUNET_TIME_AbsoluteNBO start;
/**
- * Number of peers at the end of this message.
- * Includes peers that are part of the established
- * threshold crypto system.
+ * Until when should the decryption be finished?
*/
- uint16_t num_secret_peers GNUNET_PACKED;
+ struct GNUNET_TIME_AbsoluteNBO deadline;
- /* struct GNUNET_PeerIdentity[num_peers]; */
+ /**
+ * Ciphertext we want to decrypt.
+ */
+ struct GNUNET_SECRETSHARING_Ciphertext ciphertext;
+
+ /* the share with payload */
};
struct GNUNET_SECRETSHARING_DecryptResponseMessage
{
/**
- * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_RESPONSE
+ * Type: GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_DONE
*/
struct GNUNET_MessageHeader header;
/**
- * Ciphertext to request decryption for.
+ * Zero if decryption failed, non-zero if decryption succeeded.
+ * If the decryption failed, plaintext is also zero.
+ */
+ uint32_t success;
+
+ /**
+ * Decrypted plaintext.
*/
- unsigned char plaintext[GNUNET_SECRETSHARING_KEY_BITS / 8];
+ struct GNUNET_SECRETSHARING_FieldElement plaintext;
};
GNUNET_NETWORK_STRUCT_END
+
+/**
+ * A share, with all values in in host byte order.
+ */
+struct GNUNET_SECRETSHARING_Share
+{
+ /**
+ * Threshold for the key this share belongs to.
+ */
+ uint16_t threshold;
+
+ /**
+ * Peers that have the share.
+ */
+ uint16_t num_peers;
+
+ /**
+ * Index of our peer in the list.
+ */
+ uint16_t my_peer;
+
+ /**
+ * Public key. Computed from the
+ * exponentiated coefficients.
+ */
+ struct GNUNET_SECRETSHARING_PublicKey public_key;
+
+ /**
+ * Share of 'my_peer'
+ */
+ struct GNUNET_SECRETSHARING_FieldElement my_share;
+
+ /**
+ * Peer identities (includes 'my_peer')
+ */
+ struct GNUNET_PeerIdentity *peers;
+
+ /*
+ * For each peer, store elgamal_g to the peer's
+ * share.
+ */
+ struct GNUNET_SECRETSHARING_FieldElement *sigmas;
+
+ /*
+ * Original indices of peers from the DKG round.
+ */
+ uint16_t *original_indices;
+};
+
+
#endif