4 #ifndef TOR_SHARED_RANDOM_H
5 #define TOR_SHARED_RANDOM_H
18 #define SR_PROTO_VERSION 1
20 #define SR_DIGEST_ALG DIGEST_SHA3_256
22 #define SR_SRV_TOKEN "shared-random"
24 #define SR_SRV_TOKEN_LEN (sizeof(SR_SRV_TOKEN) - 1)
27 #define SR_RANDOM_NUMBER_LEN 32
30 #define SR_COMMIT_LEN (sizeof(uint64_t) + DIGEST256_LEN)
33 #define SR_REVEAL_LEN (sizeof(uint64_t) + DIGEST256_LEN)
36 #define SR_SRV_MSG_LEN \
37 (SR_SRV_TOKEN_LEN + sizeof(uint64_t) + sizeof(uint32_t) + DIGEST256_LEN)
41 #define SR_COMMIT_BASE64_LEN (BASE64_LEN(SR_COMMIT_LEN))
44 #define SR_REVEAL_BASE64_LEN (BASE64_LEN(SR_REVEAL_LEN))
48 #define SR_SRV_VALUE_BASE64_LEN (BASE64_LEN(DIGEST256_LEN))
51 #define ASSERT_COMMIT_VALID(c) tor_assert((c)->valid)
109 #ifdef HAVE_MODULE_DIRAUTH
145 int32_t num_srv_agreements);
147 #define sr_commit_free(sr) FREE_AND_NULL(sr_commit_t, sr_commit_free_, (sr))
151 const char *sr_commit_get_rsa_fpr(
const sr_commit_t *commit)
153 return commit->rsa_identity_hex;
161 #ifdef SHARED_RANDOM_PRIVATE
181 const char *voter_key);
183 const char *voter_key,
189 #ifdef TOR_UNIT_TESTS
191 void set_num_srv_agreements(int32_t value);
Master header file for Tor-specific functionality.
STATIC void save_commit_during_reveal_phase(const sr_commit_t *commit)
STATIC int reveal_encode(const sr_commit_t *commit, char *dst, size_t len)
void sr_save_and_cleanup(void)
STATIC int should_keep_commit(const sr_commit_t *commit, const char *voter_key, sr_phase_t phase)
int sr_init(int save_to_disk)
STATIC int commit_is_authoritative(const sr_commit_t *commit, const char *voter_key)
void sr_act_post_consensus(const networkstatus_t *consensus)
STATIC void save_commit_to_state(sr_commit_t *commit)
STATIC int commit_has_reveal_value(const sr_commit_t *commit)
STATIC int reveal_decode(const char *encoded, sr_commit_t *commit)
STATIC int commit_encode(const sr_commit_t *commit, char *dst, size_t len)
STATIC int commitments_are_the_same(const sr_commit_t *commit_one, const sr_commit_t *commit_two)
STATIC int verify_commit_and_reveal(const sr_commit_t *commit)
STATIC int commit_decode(const char *encoded, sr_commit_t *commit)
STATIC sr_srv_t * get_majority_srv_from_votes(const smartlist_t *votes, int current)
char * sr_get_string_for_consensus(const smartlist_t *votes, int32_t num_srv_agreements)
sr_commit_t * sr_generate_our_commit(time_t timestamp, const authority_cert_t *my_rsa_cert)
sr_commit_t * sr_parse_commit(const smartlist_t *args)
#define SR_REVEAL_BASE64_LEN
sr_srv_t * sr_srv_dup(const sr_srv_t *orig)
void sr_handle_received_commits(smartlist_t *commits, crypto_pk_t *voter_key)
char * sr_get_string_for_vote(void)
void sr_compute_srv(void)
#define SR_COMMIT_BASE64_LEN
#define SR_RANDOM_NUMBER_LEN
void sr_commit_free_(sr_commit_t *commit)
char rsa_identity[DIGEST_LEN]
char encoded_reveal[SR_REVEAL_BASE64_LEN+1]
uint8_t random_number[SR_RANDOM_NUMBER_LEN]
uint8_t value[DIGEST256_LEN]