diff options
Diffstat (limited to 'crypto.h')
-rw-r--r-- | crypto.h | 141 |
1 files changed, 119 insertions, 22 deletions
@@ -113,44 +113,141 @@ int smc_zkp_0og_check (const gcry_mpi_point_t y, const gcry_mpi_point_t beta, const struct proof_0og *proof); + /* --- Protocol implementation --- */ unsigned char *smc_gen_keyshare (struct BRANDT_Auction *ad, size_t *buflen); int smc_recv_keyshare (struct BRANDT_Auction *ad, - const unsigned char *buf, - size_t buflen, - uint16_t sender_index); + const unsigned char *buf, + size_t buflen, + uint16_t sender_index); unsigned char *smc_encrypt_bid (struct BRANDT_Auction *ad, size_t *buflen); int smc_recv_encrypted_bid (struct BRANDT_Auction *ad, - const unsigned char *buf, - size_t buflen, - uint16_t sender_index); + const unsigned char *buf, + size_t buflen, + uint16_t sender_index); -unsigned char *fp_priv_compute_outcome (struct BRANDT_Auction *ad, size_t *buflen); +unsigned char *fp_priv_compute_outcome (struct BRANDT_Auction *ad, + size_t *buflen); int fp_priv_recv_outcome (struct BRANDT_Auction *ad, - const unsigned char *buf, - size_t buflen, - uint16_t sender); + const unsigned char *buf, + size_t buflen, + uint16_t sender); -unsigned char *fp_priv_decrypt_outcome (struct BRANDT_Auction *ad, size_t *buflen); +unsigned char *fp_priv_decrypt_outcome (struct BRANDT_Auction *ad, + size_t *buflen); int fp_priv_recv_decryption (struct BRANDT_Auction *ad, - const unsigned char *buf, - size_t buflen, - uint16_t sender); + const unsigned char *buf, + size_t buflen, + uint16_t sender); -unsigned char *fp_pub_compute_outcome (struct BRANDT_Auction *ad, size_t *buflen); +unsigned char *fp_pub_compute_outcome (struct BRANDT_Auction *ad, + size_t *buflen); int fp_pub_recv_outcome (struct BRANDT_Auction *ad, - const unsigned char *buf, - size_t buflen, - uint16_t sender); + const unsigned char *buf, + size_t buflen, + uint16_t sender); -unsigned char *fp_pub_decrypt_outcome (struct BRANDT_Auction *ad, size_t *buflen); +unsigned char *fp_pub_decrypt_outcome (struct BRANDT_Auction *ad, + size_t *buflen); int fp_pub_recv_decryption (struct BRANDT_Auction *ad, - const unsigned char *buf, - size_t buflen, - uint16_t sender); + const unsigned char *buf, + size_t buflen, + uint16_t sender); int32_t fp_priv_determine_outcome (struct BRANDT_Auction *ad); + +/* --- Round dictionaries --- */ + +typedef int +(*msg_in)(struct BRANDT_Auction *ad, + const unsigned char *buf, + size_t buflen, + uint16_t sender); + + +typedef unsigned char * +(*msg_out)(struct BRANDT_Auction *ad, + size_t *buflen); + + +/** + * stores the function pointers to receive functions for each state. + * + * The first index denotes if a first price auction or a M+1st price auction is + * used. If it is 0, it is a first price auction, if it is 1, it is a M+1st + * price auction. + * + * The second index denotes if the outcome should be public or private. A value + * of 0 means a private outcome, while a value of 1 means public outcome. + */ +static const msg_in handler_in[auction_last][outcome_last][msg_last] = { + [auction_firstPrice] = { + [outcome_private] = { + [msg_init] = &smc_recv_keyshare, + [msg_bid] = &smc_recv_encrypted_bid, + [msg_outcome] = &fp_priv_recv_outcome, + [msg_decrypt] = &fp_priv_recv_decryption, + }, + [outcome_public] = { + [msg_init] = &smc_recv_keyshare, + [msg_bid] = &smc_recv_encrypted_bid, + [msg_outcome] = &fp_pub_recv_outcome, + [msg_decrypt] = &fp_pub_recv_decryption, + }, + }, + [auction_mPlusFirstPrice] = { + [outcome_private] = { + [msg_init] = &smc_recv_keyshare, + [msg_bid] = &smc_recv_encrypted_bid, + }, + [outcome_public] = { + [msg_init] = &smc_recv_keyshare, + [msg_bid] = &smc_recv_encrypted_bid, + }, + }, +}; + + +/** + * stores the function pointers to message buffer creating functions for each + * state. + * + * The first index denotes if a first price auction or a M+1st price auction is + * used. If it is 0, it is a first price auction, if it is 1, it is a M+1st + * price auction. + * + * The second index denotes if the outcome should be public or private. A value + * of 0 means a private outcome, while a value of 1 means public outcome. + */ +static const msg_out handler_out[auction_last][outcome_last][msg_last] = { + [auction_firstPrice] = { + [outcome_private] = { + [msg_init] = &smc_gen_keyshare, + [msg_bid] = &smc_encrypt_bid, + [msg_outcome] = &fp_priv_compute_outcome, + [msg_decrypt] = &fp_priv_decrypt_outcome, + }, + [outcome_public] = { + [msg_init] = &smc_gen_keyshare, + [msg_bid] = &smc_encrypt_bid, + [msg_outcome] = &fp_pub_compute_outcome, + [msg_decrypt] = &fp_pub_decrypt_outcome, + }, + }, + [auction_mPlusFirstPrice] = { + [outcome_private] = { + [msg_init] = &smc_gen_keyshare, + [msg_bid] = &smc_encrypt_bid, + }, + [outcome_public] = { + [msg_init] = &smc_gen_keyshare, + [msg_bid] = &smc_encrypt_bid, + }, + }, +}; + + #endif /* ifndef _BRANDT_CRYPTO_H */ |