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 (GNUNET_OS_project_data_gnunet(), "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 ds, GNUNET_memcmp, and DecryptPeerInfo::peer.
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 end, GNUNET_assert, result, and start.
Referenced by keygen_round1_conclude().
|
static |
Compare two peer identities.
Intended 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 d, elgamal_q, and GNUNET_assert.
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 ds, GNUNET_CONSENSUS_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and GNUNET_SECRETSHARING_share_destroy().
Referenced by client_disconnect_cb().
|
static |
Definition at line 577 of file gnunet-service-secretsharing.c.
References info.
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 |
Definition at line 658 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 670 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 704 of file gnunet-service-secretsharing.c.
References d, 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, info, 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 779 of file gnunet-service-secretsharing.c.
References m.
Referenced by insert_round2_element().
|
static |
Definition at line 795 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, my_peer, GNUNET_SECRETSHARING_Share::my_peer, KeygenSession::my_share, GNUNET_SECRETSHARING_Share::my_share, KeygenSession::num_peers, GNUNET_SECRETSHARING_Share::num_peers, GNUNET_SECRETSHARING_Share::original_indices, KeygenPeerInfo::peer, GNUNET_SECRETSHARING_Share::peers, KeygenSession::public_key, GNUNET_SECRETSHARING_Share::public_key, KeygenPeerInfo::round2_valid, KeygenPeerInfo::sigma, and GNUNET_SECRETSHARING_Share::sigmas.
Referenced by keygen_round1_conclude().
|
static |
Definition at line 886 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 999 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 1032 of file gnunet-service-secretsharing.c.
References GNUNET_CRYPTO_PaillierCiphertext::bits, GNUNET_SECRETSHARING_FairEncryption::c, cleanup(), 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 1132 of file gnunet-service-secretsharing.c.
References GNUNET_CRYPTO_PaillierCiphertext::bits, GNUNET_SECRETSHARING_FairEncryption::c, 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, u, 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 1258 of file gnunet-service-secretsharing.c.
References KeygenSession::consensus, d, GNUNET_SET_Element::data, 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, my_peer_private_key, KeygenSession::num_peers, KeygenPeerInfo::paillier_public_key, KeygenSession::presecret_polynomial, KeygenPeerInfo::round1_valid, GNUNET_SET_Element::size, and KeygenSession::threshold.
Referenced by keygen_round1_conclude().
|
static |
Definition at line 1356 of file gnunet-service-secretsharing.c.
References d, GNUNET_assert, GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_SECRETSHARING_ELGAMAL_BITS, and KeygenSession::num_peers.
Referenced by keygen_round2_new_element().
|
static |
Definition at line 1379 of file gnunet-service-secretsharing.c.
References d, GNUNET_assert, and num_peers.
Referenced by keygen_reveal_get_exp_preshare(), and keygen_round2_new_element().
|
static |
Definition at line 1396 of file gnunet-service-secretsharing.c.
References d, 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 1413 of file gnunet-service-secretsharing.c.
References GNUNET_SECRETSHARING_FairEncryption::c, d, 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, info, 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, KeygenSession::public_key, GNUNET_SECRETSHARING_KeygenRevealData::purpose, restore_fair(), KeygenPeerInfo::sigma, 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 1628 of file gnunet-service-secretsharing.c.
References cfg, 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 1656 of file gnunet-service-secretsharing.c.
References KeygenSession::consensus, d, 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, my_peer_private_key, KeygenPeerInfo::paillier_public_key, KeygenSession::presecret_polynomial, GNUNET_SECRETSHARING_KeygenCommitData::purpose, 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 1708 of file gnunet-service-secretsharing.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, msg, 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 1731 of file gnunet-service-secretsharing.c.
References cfg, ClientState::client, KeygenSession::consensus, KeygenSession::cs, 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, msg, normalize_peers(), KeygenSession::num_peers, KeygenSession::paillier_private_key, KeygenPeerInfo::paillier_public_key, KeygenPeerInfo::peer, KeygenSession::peers, and KeygenSession::threshold.
|
static |
Called when the partial decryption consensus concludes.
Definition at line 1807 of file gnunet-service-secretsharing.c.
References compute_lagrange_coefficient(), 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, m, and msg.
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 1897 of file gnunet-service-secretsharing.c.
References GNUNET_assert.
Referenced by decrypt_new_element(), and insert_decrypt_element().
|
static |
Called when a new partial decryption arrives.
Definition at line 1910 of file gnunet-service-secretsharing.c.
References GNUNET_SECRETSHARING_Ciphertext::c1_bits, DecryptSession::ciphertext, cleanup(), d, 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, info, DecryptSession::info, mpi_to_str(), GNUNET_SECRETSHARING_Share::my_peer, DecryptSession::share, GNUNET_SECRETSHARING_Share::sigmas, and GNUNET_SET_Element::size.
Referenced by handle_client_decrypt().
|
static |
Definition at line 2082 of file gnunet-service-secretsharing.c.
References beta, GNUNET_SECRETSHARING_DecryptData::ciphertext, d, GNUNET_SET_Element::data, ds, 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(), my_peer, my_peer_private_key, GNUNET_SECRETSHARING_DecryptData::nizk_response, GNUNET_SECRETSHARING_DecryptData::purpose, 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 2218 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 2235 of file gnunet-service-secretsharing.c.
References cfg, ClientState::client, 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(), insert_decrypt_element(), msg, and GNUNET_MessageHeader::size.
|
static |
Definition at line 2300 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 2322 of file gnunet-service-secretsharing.c.
References cfg, 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(), my_peer, and my_peer_private_key.
|
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 2361 of file gnunet-service-secretsharing.c.
References ClientState::client, GNUNET_new, mq, and ClientState::mq.
|
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 2381 of file gnunet-service-secretsharing.c.
References ClientState::decrypt_session, decrypt_session_destroy(), GNUNET_free, ClientState::keygen_session, and keygen_session_destroy().
GNUNET_SERVICE_MAIN | ( | GNUNET_OS_project_data_gnunet() | , |
"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.
|
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.
Referenced by insert_decrypt_element(), insert_round1_element(), insert_round2_element(), and run().
|
static |
Configuration of this service.
Definition at line 314 of file gnunet-service-secretsharing.c.
Referenced by handle_client_decrypt(), handle_client_keygen(), keygen_round1_conclude(), and run().