Verifiable additive secret sharing and cooperative decryption. More...
Data Structures | |
struct | GNUNET_SECRETSHARING_PublicKey |
Public key of a group sharing a secret. More... | |
struct | GNUNET_SECRETSHARING_Ciphertext |
Encrypted field element. More... | |
struct | GNUNET_SECRETSHARING_Plaintext |
Plain, unencrypted message that can be encrypted with a group public key. More... | |
Macros | |
#define | GNUNET_SECRETSHARING_ELGAMAL_BITS 1024 |
Number of bits for secretsharing elements. More... | |
#define | GNUNET_SECRETSHARING_ELGAMAL_P_HEX |
The q-parameter for ElGamal encryption, a 1024-bit safe prime. More... | |
#define | GNUNET_SECRETSHARING_ELGAMAL_Q_HEX |
The q-parameter for ElGamal encryption, a 1023-bit Sophie Germain prime, q = (p-1)/2. More... | |
#define | GNUNET_SECRETSHARING_ELGAMAL_G_HEX |
The g-parameter for ElGamal encryption, a generator of the unique size q subgroup of Z_p^*. More... | |
Typedefs | |
typedef void(* | GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls, struct GNUNET_SECRETSHARING_Share *my_share, struct GNUNET_SECRETSHARING_PublicKey *public_key, unsigned int num_ready_peers, const struct GNUNET_PeerIdentity *ready_peers) |
Called once the secret has been established with all peers, or the deadline is due. More... | |
typedef void(* | GNUNET_SECRETSHARING_DecryptCallback) (void *cls, const struct GNUNET_SECRETSHARING_Plaintext *plaintext) |
Called when a decryption has succeeded. More... | |
Verifiable additive secret sharing and cooperative decryption.
#define GNUNET_SECRETSHARING_ELGAMAL_BITS 1024 |
Number of bits for secretsharing elements.
Must be smaller than the Pallier key size used internally by the secretsharing service. When changing this value, other internal parameters must also be adjusted.
Definition at line 57 of file gnunet_secretsharing_service.h.
#define GNUNET_SECRETSHARING_ELGAMAL_P_HEX |
The q-parameter for ElGamal encryption, a 1024-bit safe prime.
Definition at line 63 of file gnunet_secretsharing_service.h.
#define GNUNET_SECRETSHARING_ELGAMAL_Q_HEX |
The q-parameter for ElGamal encryption, a 1023-bit Sophie Germain prime, q = (p-1)/2.
Definition at line 76 of file gnunet_secretsharing_service.h.
#define GNUNET_SECRETSHARING_ELGAMAL_G_HEX |
The g-parameter for ElGamal encryption, a generator of the unique size q subgroup of Z_p^*.
Definition at line 89 of file gnunet_secretsharing_service.h.
typedef void(* GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls, struct GNUNET_SECRETSHARING_Share *my_share, struct GNUNET_SECRETSHARING_PublicKey *public_key, unsigned int num_ready_peers, const struct GNUNET_PeerIdentity *ready_peers) |
Called once the secret has been established with all peers, or the deadline is due.
Note that the number of peers can be smaller than 'k' (this threshold parameter), which makes the threshold crypto system useless. However, in this case one can still determine which peers were able to participate in the secret sharing successfully.
If the secret sharing failed, num_ready_peers is 0 and my_share and public_key is NULL.
After this callback has been called, the secretsharing session will be invalid.
cls | closure |
my_share | the share of this peer |
public_key | public key of the session |
num_ready_peers | number of peers in ready_peers |
ready_peers | peers that successfully participated in establishing the shared secret |
Definition at line 171 of file gnunet_secretsharing_service.h.
typedef void(* GNUNET_SECRETSHARING_DecryptCallback) (void *cls, const struct GNUNET_SECRETSHARING_Plaintext *plaintext) |
Called when a decryption has succeeded.
cls | closure |
data | decrypted value |
data_size | number of bytes in data |
Definition at line 190 of file gnunet_secretsharing_service.h.
struct GNUNET_SECRETSHARING_Session * GNUNET_SECRETSHARING_create_session | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
unsigned int | num_peers, | ||
const struct GNUNET_PeerIdentity * | peers, | ||
const struct GNUNET_HashCode * | session_id, | ||
struct GNUNET_TIME_Absolute | start, | ||
struct GNUNET_TIME_Absolute | deadline, | ||
unsigned int | threshold, | ||
GNUNET_SECRETSHARING_SecretReadyCallback | cb, | ||
void * | cls | ||
) |
Create a session that will eventually establish a shared secret with the other peers.
cfg | configuration to use |
num_peers | number of peers in peers |
peers | array of peers that we will share secrets with, can optionally contain the local peer |
session_id | unique session id |
start | When should all peers be available for sharing the secret? Random number generation can take place before the start time. |
deadline | point in time where the session must be established; taken as hint by underlying consensus sessions |
threshold | minimum number of peers that must cooperate to decrypt a value |
cb | called when the secret has been established |
cls | closure for cb |
Definition at line 244 of file secretsharing_api.c.
References cfg, GNUNET_SECRETSHARING_CreateMessage::deadline, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_GENERATE, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_TIME_absolute_hton(), handle_session_client_error(), LOG, GNUNET_SECRETSHARING_Session::mq, msg, num_peers, peers, GNUNET_SECRETSHARING_Session::secret_ready_cb, GNUNET_SECRETSHARING_Session::secret_ready_cls, GNUNET_SECRETSHARING_CreateMessage::session_id, start, and GNUNET_SECRETSHARING_CreateMessage::threshold.
void GNUNET_SECRETSHARING_session_destroy | ( | struct GNUNET_SECRETSHARING_Session * | s | ) |
Destroy a secret sharing session.
The secret ready callback will not be called.
s | session to destroy |
Definition at line 219 of file secretsharing_api.c.
References GNUNET_free, GNUNET_MQ_destroy(), and GNUNET_SECRETSHARING_Session::mq.
Referenced by handle_secret_ready(), and handle_session_client_error().
int GNUNET_SECRETSHARING_encrypt | ( | const struct GNUNET_SECRETSHARING_PublicKey * | public_key, |
const struct GNUNET_SECRETSHARING_Plaintext * | plaintext, | ||
struct GNUNET_SECRETSHARING_Ciphertext * | result_ciphertext | ||
) |
Encrypt a value.
This operation is executed locally, no communication is necessary.
This is a helper function, encryption can be done solely with a session's public key and the crypto system parameters.
public_key | public key to use for decryption |
message | message to encrypt |
message_size | number of bytes in message |
result_ciphertext | pointer to store the resulting ciphertext |
Definition at line 422 of file secretsharing_api.c.
References GNUNET_SECRETSHARING_Ciphertext::c1_bits, GNUNET_SECRETSHARING_Ciphertext::c2_bits, elgamal_g, elgamal_p, elgamal_q, ensure_elgamal_initialized(), GNUNET_assert, GNUNET_CRYPTO_mpi_print_unsigned(), GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_OK, GNUNET_SECRETSHARING_ELGAMAL_BITS, h, and m.
struct GNUNET_SECRETSHARING_DecryptionHandle * GNUNET_SECRETSHARING_decrypt | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
struct GNUNET_SECRETSHARING_Share * | share, | ||
const struct GNUNET_SECRETSHARING_Ciphertext * | ciphertext, | ||
struct GNUNET_TIME_Absolute | start, | ||
struct GNUNET_TIME_Absolute | deadline, | ||
GNUNET_SECRETSHARING_DecryptCallback | decrypt_cb, | ||
void * | decrypt_cb_cls | ||
) |
Publish the given ciphertext for decryption.
Once a sufficient (>=k) number of peers has published the same value, it will be decrypted.
When the operation is canceled, the decrypt_cb is not called anymore, but the calling peer may already have irrevocably contributed its share for the decryption of the value.
cfg | configuration to use |
share | our secret share to use for decryption |
ciphertext | ciphertext to publish in order to decrypt it (if enough peers agree) |
decrypt_cb | callback called once the decryption succeeded |
start | By when should the cooperation for decryption start? |
deadline | By when should the decryption be finished? |
decrypt_cb_cls | closure for decrypt_cb |
Definition at line 320 of file secretsharing_api.c.
References cfg, GNUNET_SECRETSHARING_DecryptRequestMessage::ciphertext, GNUNET_SECRETSHARING_DecryptRequestMessage::deadline, GNUNET_SECRETSHARING_DecryptionHandle::decrypt_cb, GNUNET_SECRETSHARING_DecryptionHandle::decrypt_cls, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT, GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_DONE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_SECRETSHARING_share_write(), GNUNET_TIME_absolute_hton(), handle_decrypt_client_error(), LOG, GNUNET_SECRETSHARING_DecryptionHandle::mq, msg, and start.
void GNUNET_SECRETSHARING_decrypt_cancel | ( | struct GNUNET_SECRETSHARING_DecryptionHandle * | dh | ) |
Cancel a decryption.
The decrypt_cb is not called anymore, but the calling peer may already have irrevocably contributed its share for the decryption of the value.
dh | to cancel |
Definition at line 483 of file secretsharing_api.c.
References GNUNET_free, GNUNET_MQ_destroy(), and GNUNET_SECRETSHARING_DecryptionHandle::mq.
Referenced by handle_decrypt_client_error(), and handle_decrypt_done().
struct GNUNET_SECRETSHARING_Share * GNUNET_SECRETSHARING_share_read | ( | const void * | data, |
size_t | len, | ||
size_t * | readlen | ||
) |
Read a share from its binary representation.
data | Binary representation of the share. | |
len | Length of data. | |
[out] | readlen | Number of bytes read, ignored if NULL. |
Definition at line 34 of file secretsharing_common.c.
References data, GNUNET_memcpy, GNUNET_new, GNUNET_new_array, GNUNET_SECRETSHARING_Share::my_peer, GNUNET_SECRETSHARING_Share::my_share, GNUNET_SECRETSHARING_Share::num_peers, GNUNET_SECRETSHARING_Share::original_indices, p, GNUNET_SECRETSHARING_Share::peers, GNUNET_SECRETSHARING_Share::public_key, sh, GNUNET_SECRETSHARING_Share::sigmas, and GNUNET_SECRETSHARING_Share::threshold.
Referenced by handle_client_decrypt(), and handle_secret_ready().
int GNUNET_SECRETSHARING_share_write | ( | const struct GNUNET_SECRETSHARING_Share * | share, |
void * | buf, | ||
size_t | buflen, | ||
size_t * | writelen | ||
) |
Convert a share to its binary representation.
Can be called with a NULL buf to get the size of the share.
share | Share to write. | |
buf | Buffer to write to. | |
buflen | Number of writable bytes in buf. | |
[out] | writelen | Pointer to store number of bytes written, ignored if NULL. |
Definition at line 96 of file secretsharing_common.c.
References GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, GNUNET_SECRETSHARING_Share::my_peer, GNUNET_SECRETSHARING_Share::my_share, GNUNET_SECRETSHARING_Share::num_peers, GNUNET_SECRETSHARING_Share::original_indices, p, GNUNET_SECRETSHARING_Share::peers, GNUNET_SECRETSHARING_Share::public_key, sh, GNUNET_SECRETSHARING_Share::sigmas, and GNUNET_SECRETSHARING_Share::threshold.
Referenced by GNUNET_SECRETSHARING_decrypt(), and keygen_round2_conclude().
void GNUNET_SECRETSHARING_share_destroy | ( | struct GNUNET_SECRETSHARING_Share * | share | ) |
Definition at line 150 of file secretsharing_common.c.
References GNUNET_free, GNUNET_SECRETSHARING_Share::original_indices, GNUNET_SECRETSHARING_Share::peers, and GNUNET_SECRETSHARING_Share::sigmas.
Referenced by decrypt_session_destroy(), and keygen_round2_conclude().
int GNUNET_SECRETSHARING_plaintext_generate | ( | struct GNUNET_SECRETSHARING_Plaintext * | plaintext, |
gcry_mpi_t | exponent | ||
) |
int GNUNET_SECRETSHARING_plaintext_generate_i | ( | struct GNUNET_SECRETSHARING_Plaintext * | plaintext, |
int64_t | exponent | ||
) |
Definition at line 381 of file secretsharing_api.c.
References elgamal_g, elgamal_p, ensure_elgamal_initialized(), GNUNET_assert, GNUNET_CRYPTO_mpi_print_unsigned(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, and res.