![]() |
GNUnet
0.11.x
|
secret sharing service More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_time_lib.h"
#include "gnunet_signatures.h"
#include "gnunet_consensus_service.h"
#include "secretsharing.h"
#include "secretsharing_protocol.h"
#include <gcrypt.h>
Go to the source code of this file.
Data Structures | |
struct | KeygenPeerInfo |
Info about a peer in a key generation session. More... | |
struct | DecryptPeerInfo |
Information about a peer in a decrypt session. More... | |
struct | KeygenSession |
Session to establish a threshold-shared secret. More... | |
struct | DecryptSession |
Session to cooperatively decrypt a value. More... | |
struct | ClientState |
State we keep per client. More... | |
Macros | |
#define | EXTRA_CHECKS 1 |
Functions | |
static struct KeygenPeerInfo * | get_keygen_peer_info (const struct KeygenSession *ks, const struct GNUNET_PeerIdentity *peer) |
Get the peer info belonging to a peer identity in a keygen session. More... | |
static struct DecryptPeerInfo * | get_decrypt_peer_info (const struct DecryptSession *ds, const struct GNUNET_PeerIdentity *peer) |
Get the peer info belonging to a peer identity in a decrypt session. More... | |
static struct GNUNET_TIME_Absolute | time_between (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end, int num, int denum) |
Interpolate between two points in time. More... | |
static int | peer_id_cmp (const void *p1, const void *p2) |
Compare two peer identities. More... | |
static int | peer_find (const struct GNUNET_PeerIdentity *haystack, unsigned int n, const struct GNUNET_PeerIdentity *needle) |
Get the index of a peer in an array of peers. More... | |
static struct GNUNET_PeerIdentity * | normalize_peers (struct GNUNET_PeerIdentity *listed, unsigned int num_listed, unsigned int *num_normalized, unsigned int *my_peer_idx) |
Normalize the given list of peers, by including the local peer (if it is missing) and sorting the peers by their identity. More... | |
static void | compute_lagrange_coefficient (gcry_mpi_t coeff, unsigned int j, unsigned int *indices, unsigned int num) |
Get a the j-th lagrange coefficient for a set of indices. More... | |
static void | decrypt_session_destroy (struct DecryptSession *ds) |
Destroy a decrypt session, removing it from the linked list of decrypt sessions. More... | |
static void | keygen_info_destroy (struct KeygenPeerInfo *info) |
static void | keygen_session_destroy (struct KeygenSession *ks) |
static void | cleanup_task (void *cls) |
Task run during shutdown. More... | |
static void | generate_presecret_polynomial (struct KeygenSession *ks) |
Generate the random coefficients of our pre-secret polynomial. More... | |
static void | keygen_round1_new_element (void *cls, const struct GNUNET_SET_Element *element) |
Consensus element handler for round one. More... | |
static void | horner_eval (gcry_mpi_t z, gcry_mpi_t *coeff, unsigned int num_coeff, gcry_mpi_t x, gcry_mpi_t m) |
Evaluate the polynomial with coefficients coeff at x. More... | |
static void | keygen_round2_conclude (void *cls) |
static void | restore_fair (const struct GNUNET_CRYPTO_PaillierPublicKey *ppub, const struct GNUNET_SECRETSHARING_FairEncryption *fe, gcry_mpi_t x, gcry_mpi_t xres) |
static void | get_fair_encryption_challenge (const struct GNUNET_SECRETSHARING_FairEncryption *fe, gcry_mpi_t *e) |
static int | verify_fair (const struct GNUNET_CRYPTO_PaillierPublicKey *ppub, const struct GNUNET_SECRETSHARING_FairEncryption *fe) |
static void | encrypt_fair (gcry_mpi_t v, const struct GNUNET_CRYPTO_PaillierPublicKey *ppub, struct GNUNET_SECRETSHARING_FairEncryption *fe) |
Create a fair Paillier encryption of then given ciphertext. More... | |
static void | insert_round2_element (struct KeygenSession *ks) |
Insert round 2 element in the consensus, consisting of (1) The exponentiated pre-share polynomial coefficients A_{i,l}=g^{a_{i,l}} (2) The exponentiated pre-shares y_{i,j}=g^{s_{i,j}} (3) The encrypted pre-shares Y_{i,j} (4) The zero knowledge proof for fairness of the encryption. More... | |
static gcry_mpi_t | keygen_reveal_get_exp_coeff (struct KeygenSession *ks, const struct GNUNET_SECRETSHARING_KeygenRevealData *d, unsigned int idx) |
static struct GNUNET_SECRETSHARING_FairEncryption * | keygen_reveal_get_enc_preshare (struct KeygenSession *ks, const struct GNUNET_SECRETSHARING_KeygenRevealData *d, unsigned int idx) |
static gcry_mpi_t | keygen_reveal_get_exp_preshare (struct KeygenSession *ks, const struct GNUNET_SECRETSHARING_KeygenRevealData *d, unsigned int idx) |
static void | keygen_round2_new_element (void *cls, const struct GNUNET_SET_Element *element) |
static void | keygen_round1_conclude (void *cls) |
Called when the first consensus round has concluded. More... | |
static void | insert_round1_element (struct KeygenSession *ks) |
Insert the ephemeral key and the presecret commitment of this peer in the consensus of the given session. More... | |
static int | check_client_keygen (void *cls, const struct GNUNET_SECRETSHARING_CreateMessage *msg) |
Check that msg is well-formed. More... | |
static void | handle_client_keygen (void *cls, const struct GNUNET_SECRETSHARING_CreateMessage *msg) |
Functions with this signature are called whenever a message is received. More... | |
static void | decrypt_conclude (void *cls) |
Called when the partial decryption consensus concludes. More... | |
static char * | mpi_to_str (gcry_mpi_t mpi) |
Get a string representation of an MPI. More... | |
static void | decrypt_new_element (void *cls, const struct GNUNET_SET_Element *element) |
Called when a new partial decryption arrives. More... | |
static void | insert_decrypt_element (struct DecryptSession *ds) |
static int | check_client_decrypt (void *cls, const struct GNUNET_SECRETSHARING_DecryptRequestMessage *msg) |
Check that msg is well-formed. More... | |
static void | handle_client_decrypt (void *cls, const struct GNUNET_SECRETSHARING_DecryptRequestMessage *msg) |
Functions with this signature are called whenever a message is received. More... | |
static void | init_crypto_constants (void) |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service) |
Initialize secretsharing service. More... | |
static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq) |
Callback called when a client connects to the service. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls) |
Callback called when a client disconnected from the service. More... | |
GNUNET_SERVICE_MAIN ("secretsharing", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(client_keygen, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_GENERATE, struct GNUNET_SECRETSHARING_CreateMessage, NULL), GNUNET_MQ_hd_var_size(client_decrypt, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT, struct GNUNET_SECRETSHARING_DecryptRequestMessage, NULL), GNUNET_MQ_handler_end()) | |
Define "main" method using service macro. More... | |
Variables | |
static gcry_mpi_t | elgamal_q |
The ElGamal prime field order as libgcrypt mpi. More... | |
static gcry_mpi_t | elgamal_p |
Modulus of the prime field used for ElGamal. More... | |
static gcry_mpi_t | elgamal_g |
Generator for prime field of order 'elgamal_q'. More... | |
static struct GNUNET_PeerIdentity | my_peer |
Peer that runs this service. More... | |
static struct GNUNET_CRYPTO_EddsaPrivateKey * | my_peer_private_key |
Peer that runs this service. More... | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Configuration of this service. More... | |
secret sharing service
Definition in file gnunet-service-secretsharing.c.
#define EXTRA_CHECKS 1 |
Definition at line 36 of file gnunet-service-secretsharing.c.
|
static |
Get the peer info belonging to a peer identity in a keygen session.
ks | The keygen session. |
peer | The peer identity. |
Definition at line 325 of file gnunet-service-secretsharing.c.
References GNUNET_memcmp, KeygenSession::info, KeygenSession::num_peers, and KeygenPeerInfo::peer.
Referenced by keygen_round1_new_element(), and keygen_round2_new_element().
|
static |
Get the peer info belonging to a peer identity in a decrypt session.
ds | The decrypt session. |
peer | The peer identity. |
Definition at line 345 of file gnunet-service-secretsharing.c.
References GNUNET_memcmp, DecryptSession::info, GNUNET_SECRETSHARING_Share::num_peers, DecryptPeerInfo::peer, and DecryptSession::share.
Referenced by decrypt_new_element().
|
static |
Interpolate between two points in time.
start | start time |
end | end time |
num | numerator of the scale factor |
denum | denumerator of the scale factor |
Definition at line 366 of file gnunet-service-secretsharing.c.
References GNUNET_TIME_Absolute::abs_value_us, end, GNUNET_assert, result, and start.
Referenced by keygen_round1_conclude().
|
static |
Compare two peer identities.
Indended to be used with qsort or bsearch.
p1 | Some peer identity. |
p2 | Some peer identity. |
Definition at line 389 of file gnunet-service-secretsharing.c.
Referenced by normalize_peers().
|
static |
Get the index of a peer in an array of peers.
haystack | Array of peers. |
n | Size of haystack. |
needle | Peer to find |
Definition at line 407 of file gnunet-service-secretsharing.c.
References GNUNET_memcmp.
Referenced by normalize_peers().
|
static |
Normalize the given list of peers, by including the local peer (if it is missing) and sorting the peers by their identity.
listed | Peers in the unnormalized list. | |
num_listed | Peers in the un-normalized list. | |
[out] | num_normalized | Number of peers in the normalized list. |
[out] | my_peer_idx | Index of the local peer in the normalized list. |
Definition at line 431 of file gnunet-service-secretsharing.c.
References GNUNET_memcpy, GNUNET_new_array, GNUNET_NO, GNUNET_YES, my_peer, peer_find(), and peer_id_cmp().
Referenced by handle_client_keygen().
|
static |
Get a the j-th lagrange coefficient for a set of indices.
[out] | coeff | the lagrange coefficient |
j | lagrange coefficient we want to compute | |
indices | indices | |
num | number of indices in indices |
Definition at line 481 of file gnunet-service-secretsharing.c.
References elgamal_q, GNUNET_assert, and l.
Referenced by decrypt_conclude().
|
static |
Destroy a decrypt session, removing it from the linked list of decrypt sessions.
ds | decrypt session to destroy |
Definition at line 538 of file gnunet-service-secretsharing.c.
References DecryptSession::consensus, DecryptSession::cs, ClientState::decrypt_session, GNUNET_CONSENSUS_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SECRETSHARING_share_destroy(), DecryptSession::info, GNUNET_SECRETSHARING_Share::num_peers, DecryptPeerInfo::partial_decryption, and DecryptSession::share.
Referenced by client_disconnect_cb().
|
static |
Definition at line 577 of file gnunet-service-secretsharing.c.
References KeygenPeerInfo::presecret_commitment, KeygenPeerInfo::preshare_commitment, and KeygenPeerInfo::sigma.
Referenced by keygen_session_destroy().
|
static |
Definition at line 598 of file gnunet-service-secretsharing.c.
References KeygenSession::consensus, KeygenSession::cs, GNUNET_assert, GNUNET_CONSENSUS_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, KeygenSession::info, keygen_info_destroy(), ClientState::keygen_session, KeygenSession::my_share, KeygenSession::num_peers, KeygenSession::peers, KeygenSession::presecret_polynomial, KeygenSession::public_key, and KeygenSession::threshold.
Referenced by client_disconnect_cb().
|
static |
Task run during shutdown.
cls | unused |
tc | unused |
Definition at line 659 of file gnunet-service-secretsharing.c.
Referenced by run().
|
static |
Generate the random coefficients of our pre-secret polynomial.
ks | the session |
Definition at line 671 of file gnunet-service-secretsharing.c.
References elgamal_q, GNUNET_assert, GNUNET_new_array, GNUNET_SECRETSHARING_ELGAMAL_BITS, KeygenSession::presecret_polynomial, and KeygenSession::threshold.
Referenced by handle_client_keygen().
|
static |
Consensus element handler for round one.
We should get one ephemeral key for each peer.
cls | Closure (keygen session). |
element | The element from consensus, or NULL if consensus failed. |
Definition at line 705 of file gnunet-service-secretsharing.c.
References GNUNET_SECRETSHARING_KeygenCommitData::commitment, GNUNET_SET_Element::data, get_keygen_peer_info(), GNUNET_CRYPTO_eddsa_verify_(), GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG1, GNUNET_YES, KeygenPeerInfo::paillier_public_key, GNUNET_SECRETSHARING_KeygenCommitData::peer, KeygenPeerInfo::presecret_commitment, GNUNET_SECRETSHARING_KeygenCommitData::pubkey, GNUNET_PeerIdentity::public_key, GNUNET_SECRETSHARING_KeygenCommitData::purpose, KeygenPeerInfo::round1_valid, GNUNET_SECRETSHARING_KeygenCommitData::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, and GNUNET_SET_Element::size.
Referenced by handle_client_keygen().
|
static |
Evaluate the polynomial with coefficients coeff at x.
The i-th element in coeff corresponds to the coefficient of x^i.
[out] | z | result of the evaluation |
coeff | array of coefficients | |
num_coeff | number of coefficients | |
x | where to evaluate the polynomial | |
m | what group are we operating in? |
Definition at line 780 of file gnunet-service-secretsharing.c.
Referenced by insert_round2_element().
|
static |
Definition at line 796 of file gnunet-service-secretsharing.c.
References KeygenSession::consensus, KeygenSession::cs, GNUNET_assert, GNUNET_CONSENSUS_destroy(), GNUNET_CRYPTO_mpi_print_unsigned(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_memcmp, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_new_array, GNUNET_OK, GNUNET_SECRETSHARING_ELGAMAL_BITS, GNUNET_SECRETSHARING_share_destroy(), GNUNET_SECRETSHARING_share_write(), GNUNET_YES, KeygenSession::info, KeygenSession::local_peer_idx, m, ClientState::mq, GNUNET_SECRETSHARING_Share::my_peer, my_peer, GNUNET_SECRETSHARING_Share::my_share, KeygenSession::my_share, KeygenSession::num_peers, GNUNET_SECRETSHARING_Share::num_peers, GNUNET_SECRETSHARING_Share::original_indices, KeygenPeerInfo::peer, GNUNET_SECRETSHARING_Share::peers, GNUNET_SECRETSHARING_Share::public_key, KeygenSession::public_key, KeygenPeerInfo::round2_valid, KeygenPeerInfo::sigma, and GNUNET_SECRETSHARING_Share::sigmas.
Referenced by keygen_round1_conclude().
|
static |
Definition at line 887 of file gnunet-service-secretsharing.c.
References elgamal_q, GNUNET_assert, GNUNET_CRYPTO_mpi_scan_unsigned(), and t.
Referenced by keygen_round2_new_element().
|
static |
Definition at line 1000 of file gnunet-service-secretsharing.c.
References GNUNET_SECRETSHARING_FairEncryption::c, elgamal_q, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_CRYPTO_PAILLIER_BITS, GNUNET_memcpy, GNUNET_SECRETSHARING_ELGAMAL_BITS, h, GNUNET_SECRETSHARING_FairEncryption::h, GNUNET_SECRETSHARING_FairEncryption::t1, and GNUNET_SECRETSHARING_FairEncryption::t2.
Referenced by encrypt_fair(), and verify_fair().
|
static |
Definition at line 1033 of file gnunet-service-secretsharing.c.
References GNUNET_CRYPTO_PaillierCiphertext::bits, GNUNET_SECRETSHARING_FairEncryption::c, cleanup(), e, elgamal_g, elgamal_p, get_fair_encryption_challenge(), GNUNET_assert, GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_CRYPTO_PAILLIER_BITS, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, GNUNET_SECRETSHARING_ELGAMAL_BITS, GNUNET_YES, GNUNET_SECRETSHARING_FairEncryption::h, res, GNUNET_SECRETSHARING_FairEncryption::t1, GNUNET_SECRETSHARING_FairEncryption::t2, GNUNET_SECRETSHARING_FairEncryption::w, and GNUNET_SECRETSHARING_FairEncryption::z.
Referenced by keygen_round2_new_element().
|
static |
Create a fair Paillier encryption of then given ciphertext.
v | the ciphertext | |
[out] | fe | the fair encryption |
Definition at line 1133 of file gnunet-service-secretsharing.c.
References GNUNET_CRYPTO_PaillierCiphertext::bits, GNUNET_SECRETSHARING_FairEncryption::c, e, elgamal_g, elgamal_p, elgamal_q, get_fair_encryption_challenge(), GNUNET_assert, GNUNET_CRYPTO_mpi_print_unsigned(), GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_CRYPTO_PAILLIER_BITS, GNUNET_SECRETSHARING_ELGAMAL_BITS, h, GNUNET_SECRETSHARING_FairEncryption::h, GNUNET_SECRETSHARING_FairEncryption::t1, GNUNET_SECRETSHARING_FairEncryption::t2, GNUNET_SECRETSHARING_FairEncryption::w, and GNUNET_SECRETSHARING_FairEncryption::z.
Referenced by insert_round2_element().
|
static |
Insert round 2 element in the consensus, consisting of (1) The exponentiated pre-share polynomial coefficients A_{i,l}=g^{a_{i,l}} (2) The exponentiated pre-shares y_{i,j}=g^{s_{i,j}} (3) The encrypted pre-shares Y_{i,j} (4) The zero knowledge proof for fairness of the encryption.
ks | session to use |
Definition at line 1259 of file gnunet-service-secretsharing.c.
References KeygenSession::consensus, GNUNET_SET_Element::data, element_size, elgamal_g, elgamal_p, elgamal_q, encrypt_fair(), GNUNET_assert, GNUNET_CONSENSUS_insert(), GNUNET_CRYPTO_eddsa_sign_(), GNUNET_CRYPTO_mpi_print_unsigned(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_OK, GNUNET_SECRETSHARING_ELGAMAL_BITS, GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG2, GNUNET_YES, horner_eval(), KeygenSession::info, KeygenSession::local_peer_idx, my_peer, KeygenSession::num_peers, KeygenPeerInfo::paillier_public_key, GNUNET_SECRETSHARING_KeygenRevealData::peer, KeygenSession::presecret_polynomial, GNUNET_SECRETSHARING_KeygenRevealData::purpose, GNUNET_CRYPTO_EccSignaturePurpose::purpose, KeygenPeerInfo::round1_valid, GNUNET_SECRETSHARING_KeygenRevealData::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, GNUNET_SET_Element::size, and KeygenSession::threshold.
Referenced by keygen_round1_conclude().
|
static |
Definition at line 1357 of file gnunet-service-secretsharing.c.
References GNUNET_assert, GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_SECRETSHARING_ELGAMAL_BITS, KeygenSession::num_peers, and threshold.
Referenced by keygen_round2_new_element().
|
static |
Definition at line 1380 of file gnunet-service-secretsharing.c.
References GNUNET_assert, and num_peers.
Referenced by keygen_reveal_get_exp_preshare(), and keygen_round2_new_element().
|
static |
Definition at line 1397 of file gnunet-service-secretsharing.c.
References GNUNET_assert, GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_SECRETSHARING_ELGAMAL_BITS, GNUNET_SECRETSHARING_FairEncryption::h, keygen_reveal_get_enc_preshare(), and num_peers.
Referenced by keygen_round2_new_element().
|
static |
Definition at line 1414 of file gnunet-service-secretsharing.c.
References GNUNET_SECRETSHARING_FairEncryption::c, GNUNET_SET_Element::data, elgamal_g, elgamal_p, elgamal_q, get_keygen_peer_info(), GNUNET_assert, GNUNET_CRYPTO_eddsa_verify_(), GNUNET_CRYPTO_paillier_decrypt(), GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SECRETSHARING_ELGAMAL_BITS, GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG2, GNUNET_YES, KeygenSession::info, keygen_reveal_get_enc_preshare(), keygen_reveal_get_exp_coeff(), keygen_reveal_get_exp_preshare(), KeygenSession::local_peer_idx, KeygenSession::my_share, KeygenSession::num_peers, KeygenSession::paillier_private_key, KeygenPeerInfo::paillier_public_key, GNUNET_SECRETSHARING_KeygenRevealData::peer, KeygenPeerInfo::preshare_commitment, KeygenSession::public_key, GNUNET_PeerIdentity::public_key, GNUNET_SECRETSHARING_KeygenRevealData::purpose, restore_fair(), KeygenPeerInfo::round1_valid, KeygenPeerInfo::round2_valid, KeygenPeerInfo::sigma, GNUNET_SECRETSHARING_KeygenRevealData::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, GNUNET_SET_Element::size, KeygenSession::threshold, and verify_fair().
Referenced by keygen_round1_conclude().
|
static |
Called when the first consensus round has concluded.
Will initiate the second round.
cls | closure |
Definition at line 1629 of file gnunet-service-secretsharing.c.
References KeygenSession::consensus, KeygenSession::deadline, GNUNET_CONSENSUS_conclude(), GNUNET_CONSENSUS_create(), GNUNET_CONSENSUS_destroy(), insert_round2_element(), keygen_round2_conclude(), keygen_round2_new_element(), KeygenSession::num_peers, KeygenSession::peers, KeygenSession::session_id, KeygenSession::start_time, and time_between().
Referenced by handle_client_keygen().
|
static |
Insert the ephemeral key and the presecret commitment of this peer in the consensus of the given session.
ks | session to use |
Definition at line 1657 of file gnunet-service-secretsharing.c.
References GNUNET_SECRETSHARING_KeygenCommitData::commitment, KeygenSession::consensus, GNUNET_SET_Element::data, elgamal_g, elgamal_p, GNUNET_assert, GNUNET_CONSENSUS_insert(), GNUNET_CRYPTO_eddsa_sign_(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_mpi_print_unsigned(), GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_SECRETSHARING_ELGAMAL_BITS, GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG1, KeygenSession::info, KeygenSession::local_peer_idx, my_peer, KeygenPeerInfo::paillier_public_key, GNUNET_SECRETSHARING_KeygenCommitData::peer, KeygenSession::presecret_polynomial, GNUNET_SECRETSHARING_KeygenCommitData::pubkey, GNUNET_SECRETSHARING_KeygenCommitData::purpose, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_SECRETSHARING_KeygenCommitData::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, and GNUNET_SET_Element::size.
Referenced by handle_client_keygen().
|
static |
Check that msg is well-formed.
cls | identification of the client |
msg | the actual message |
Definition at line 1709 of file gnunet-service-secretsharing.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_SECRETSHARING_CreateMessage::header, num_peers, GNUNET_SECRETSHARING_CreateMessage::num_peers, and GNUNET_MessageHeader::size.
|
static |
Functions with this signature are called whenever a message is received.
cls | identification of the client |
msg | the actual message |
Definition at line 1732 of file gnunet-service-secretsharing.c.
References ClientState::client, KeygenSession::consensus, KeygenSession::cs, GNUNET_SECRETSHARING_CreateMessage::deadline, KeygenSession::deadline, generate_presecret_polynomial(), GNUNET_break, GNUNET_CONSENSUS_conclude(), GNUNET_CONSENSUS_create(), GNUNET_CRYPTO_paillier_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_new_array, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TIME_absolute_ntoh(), KeygenSession::info, insert_round1_element(), keygen_round1_conclude(), keygen_round1_new_element(), ClientState::keygen_session, KeygenSession::local_peer_idx, normalize_peers(), GNUNET_SECRETSHARING_CreateMessage::num_peers, KeygenSession::num_peers, KeygenSession::paillier_private_key, KeygenPeerInfo::paillier_public_key, KeygenPeerInfo::peer, KeygenSession::peers, GNUNET_SECRETSHARING_CreateMessage::threshold, and KeygenSession::threshold.
|
static |
Called when the partial decryption consensus concludes.
Definition at line 1808 of file gnunet-service-secretsharing.c.
References GNUNET_SECRETSHARING_Ciphertext::c2_bits, DecryptSession::ciphertext, compute_lagrange_coefficient(), DecryptSession::consensus, DecryptSession::cs, ds, elgamal_p, GNUNET_assert, GNUNET_CONSENSUS_destroy(), GNUNET_CRYPTO_mpi_print_unsigned(), GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_DONE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new_array, GNUNET_SECRETSHARING_ELGAMAL_BITS, DecryptSession::info, m, ClientState::mq, msg, GNUNET_SECRETSHARING_Share::my_peer, GNUNET_SECRETSHARING_Share::num_peers, DecryptPeerInfo::original_index, DecryptPeerInfo::partial_decryption, GNUNET_SECRETSHARING_DecryptResponseMessage::plaintext, DecryptSession::share, and GNUNET_SECRETSHARING_DecryptResponseMessage::success.
Referenced by handle_client_decrypt().
|
static |
Get a string representation of an MPI.
The caller must free the returned string.
mpi | mpi to convert to a string |
Definition at line 1898 of file gnunet-service-secretsharing.c.
References buf, and GNUNET_assert.
Referenced by decrypt_new_element(), and insert_decrypt_element().
|
static |
Called when a new partial decryption arrives.
Definition at line 1911 of file gnunet-service-secretsharing.c.
References GNUNET_SECRETSHARING_Ciphertext::c1_bits, ciphertext, GNUNET_SECRETSHARING_DecryptData::ciphertext, DecryptSession::ciphertext, cleanup(), GNUNET_SET_Element::data, elgamal_g, elgamal_p, get_decrypt_peer_info(), GNUNET_assert, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_memcmp, GNUNET_SECRETSHARING_ELGAMAL_BITS, DecryptSession::info, mpi_to_str(), GNUNET_SECRETSHARING_Share::my_peer, DecryptPeerInfo::partial_decryption, GNUNET_SECRETSHARING_DecryptData::peer, DecryptSession::share, KeygenPeerInfo::sigma, GNUNET_SECRETSHARING_Share::sigmas, and GNUNET_SET_Element::size.
Referenced by handle_client_decrypt().
|
static |
Definition at line 2083 of file gnunet-service-secretsharing.c.
References beta, GNUNET_SECRETSHARING_Ciphertext::c1_bits, ciphertext, GNUNET_SECRETSHARING_DecryptData::ciphertext, DecryptSession::ciphertext, DecryptSession::consensus, GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, elgamal_g, elgamal_p, elgamal_q, GNUNET_assert, GNUNET_CONSENSUS_insert(), GNUNET_CRYPTO_eddsa_sign_(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_mpi_print_unsigned(), GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_SECRETSHARING_ELGAMAL_BITS, GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DECRYPTION, mpi_to_str(), GNUNET_SECRETSHARING_Share::my_peer, my_peer, GNUNET_SECRETSHARING_Share::my_share, GNUNET_SECRETSHARING_DecryptData::nizk_commit1, GNUNET_SECRETSHARING_DecryptData::nizk_commit2, GNUNET_SECRETSHARING_DecryptData::nizk_response, GNUNET_SECRETSHARING_Share::num_peers, GNUNET_SECRETSHARING_DecryptData::partial_decryption, GNUNET_SECRETSHARING_DecryptData::peer, GNUNET_SECRETSHARING_DecryptData::purpose, DecryptSession::share, KeygenPeerInfo::sigma, GNUNET_SECRETSHARING_Share::sigmas, and GNUNET_SET_Element::size.
Referenced by handle_client_decrypt().
|
static |
Check that msg is well-formed.
cls | identification of the client |
msg | the actual message |
Definition at line 2219 of file gnunet-service-secretsharing.c.
References GNUNET_OK.
|
static |
Functions with this signature are called whenever a message is received.
cls | identification of the client |
msg | the actual message |
Definition at line 2236 of file gnunet-service-secretsharing.c.
References GNUNET_SECRETSHARING_DecryptRequestMessage::ciphertext, DecryptSession::ciphertext, ClientState::client, DecryptSession::consensus, DecryptSession::cs, GNUNET_SECRETSHARING_DecryptRequestMessage::deadline, DecryptSession::deadline, decrypt_conclude(), decrypt_new_element(), ClientState::decrypt_session, ds, GNUNET_break, GNUNET_CONSENSUS_conclude(), GNUNET_CONSENSUS_create(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_new_array, GNUNET_SECRETSHARING_share_read(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TIME_absolute_ntoh(), GNUNET_SECRETSHARING_DecryptRequestMessage::header, DecryptSession::info, insert_decrypt_element(), GNUNET_SECRETSHARING_Share::num_peers, DecryptPeerInfo::original_index, GNUNET_SECRETSHARING_Share::original_indices, DecryptPeerInfo::peer, GNUNET_SECRETSHARING_Share::peers, DecryptSession::share, GNUNET_MessageHeader::size, GNUNET_SECRETSHARING_DecryptRequestMessage::start, and DecryptSession::start.
|
static |
Definition at line 2301 of file gnunet-service-secretsharing.c.
References elgamal_g, elgamal_p, elgamal_q, GNUNET_assert, GNUNET_SECRETSHARING_ELGAMAL_G_HEX, GNUNET_SECRETSHARING_ELGAMAL_P_HEX, and GNUNET_SECRETSHARING_ELGAMAL_Q_HEX.
Referenced by run().
|
static |
Initialize secretsharing service.
cls | closure |
c | configuration to use |
service | the initialized service |
Definition at line 2323 of file gnunet-service-secretsharing.c.
References cleanup_task(), GNUNET_break, GNUNET_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_CRYPTO_get_peer_identity(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), init_crypto_constants(), and my_peer.
Referenced by client_disconnect_cb().
|
static |
Callback called when a client connects to the service.
cls | closure for the service |
c | the new client that connected to the service |
mq | the message queue used to send messages to the client |
Definition at line 2362 of file gnunet-service-secretsharing.c.
References ClientState::client, GNUNET_new, mq, and ClientState::mq.
Referenced by client_disconnect_cb().
|
static |
Callback called when a client disconnected from the service.
cls | closure for the service |
c | the client that disconnected |
internal_cls | should be equal to c |
Definition at line 2382 of file gnunet-service-secretsharing.c.
References client_connect_cb(), ClientState::decrypt_session, decrypt_session_destroy(), GNUNET_free, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_GENERATE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, ClientState::keygen_session, keygen_session_destroy(), and run().
GNUNET_SERVICE_MAIN | ( | "secretsharing" | , |
GNUNET_SERVICE_OPTION_NONE | , | ||
& | run, | ||
& | client_connect_cb, | ||
& | client_disconnect_cb, | ||
NULL | , | ||
GNUNET_MQ_hd_var_size(client_keygen, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_GENERATE, struct GNUNET_SECRETSHARING_CreateMessage, NULL) | , | ||
GNUNET_MQ_hd_var_size(client_decrypt, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT, struct GNUNET_SECRETSHARING_DecryptRequestMessage, NULL) | , | ||
GNUNET_MQ_handler_end() | |||
) |
Define "main" method using service macro.
Referenced by client_disconnect_cb().
|
static |
The ElGamal prime field order as libgcrypt mpi.
Initialized in init_crypto_constants.
Definition at line 287 of file gnunet-service-secretsharing.c.
Referenced by compute_lagrange_coefficient(), encrypt_fair(), generate_presecret_polynomial(), get_fair_encryption_challenge(), init_crypto_constants(), insert_decrypt_element(), insert_round2_element(), keygen_round2_new_element(), and restore_fair().
|
static |
Modulus of the prime field used for ElGamal.
Initialized in init_crypto_constants.
Definition at line 293 of file gnunet-service-secretsharing.c.
Referenced by decrypt_conclude(), decrypt_new_element(), encrypt_fair(), init_crypto_constants(), insert_decrypt_element(), insert_round1_element(), insert_round2_element(), keygen_round2_new_element(), and verify_fair().
|
static |
Generator for prime field of order 'elgamal_q'.
Initialized in init_crypto_constants.
Definition at line 299 of file gnunet-service-secretsharing.c.
Referenced by decrypt_new_element(), encrypt_fair(), init_crypto_constants(), insert_decrypt_element(), insert_round1_element(), insert_round2_element(), keygen_round2_new_element(), and verify_fair().
|
static |
Peer that runs this service.
Definition at line 304 of file gnunet-service-secretsharing.c.
Referenced by insert_decrypt_element(), insert_round1_element(), insert_round2_element(), keygen_round2_conclude(), normalize_peers(), and run().
|
static |
Peer that runs this service.
Definition at line 309 of file gnunet-service-secretsharing.c.
|
static |
Configuration of this service.
Definition at line 314 of file gnunet-service-secretsharing.c.