X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fsecretsharing%2Fsecretsharing.h;h=5936b6ab94701bfd7ad34265c6e32952afad2174;hb=ce9687f34f0e82698f4bb66c01980d8bd6d7be06;hp=8bd1b05b5dab3dee7b51ed85d3ac1f15d9cd26b5;hpb=f3a98e004caf91688887a01b5fe2ad3f11813238;p=oweals%2Fgnunet.git diff --git a/src/secretsharing/secretsharing.h b/src/secretsharing/secretsharing.h index 8bd1b05b5..5936b6ab9 100644 --- a/src/secretsharing/secretsharing.h +++ b/src/secretsharing/secretsharing.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2013 Christian Grothoff (and other contributing authors) + Copyright (C) 2013 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -14,8 +14,8 @@ 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. + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /** @@ -27,13 +27,22 @@ #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 { @@ -47,13 +56,18 @@ 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_TIME_AbsoluteNBO deadline; /** - * Mininum number of cooperating peers to decrypt a + * Mininum number of cooperating peers to decrypt a * value. */ uint16_t threshold GNUNET_PACKED; @@ -67,31 +81,50 @@ struct GNUNET_SECRETSHARING_CreateMessage }; -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]; */ }; @@ -103,35 +136,94 @@ struct GNUNET_SECRETSHARING_DecryptRequestMessage 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 GNUNET_PACKED; + + /** + * 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