aboutsummaryrefslogtreecommitdiff
path: root/crypto.h
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2016-08-31 14:37:22 +0200
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-08-31 14:37:22 +0200
commit9f0e72f1e8615c9c03222372b2c579471bcce602 (patch)
treea7fd357b79a9f939de5d5f67de1a030b59ff4418 /crypto.h
parent0d3b32b24881cb9ce89d0b6689ada53f88d0008e (diff)
temporary dump for discussion
Diffstat (limited to 'crypto.h')
-rw-r--r--crypto.h87
1 files changed, 81 insertions, 6 deletions
diff --git a/crypto.h b/crypto.h
index 2f40ed3..b3520d0 100644
--- a/crypto.h
+++ b/crypto.h
@@ -116,12 +116,14 @@ int smc_zkp_0og_check (const gcry_mpi_point_t y,
/* --- Protocol implementation --- */
+void smc_prep_keyshare (struct BRANDT_Auction *ad);
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);
+void smc_prep_bid (struct BRANDT_Auction *ad);
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,
@@ -142,8 +144,10 @@ int fp_priv_recv_decryption (struct BRANDT_Auction *ad,
size_t buflen,
uint16_t sender);
-int32_t fp_priv_determine_outcome (struct BRANDT_Auction *ad);
+struct BRANDT_Result *fp_priv_determine_outcome (struct BRANDT_Auction *ad,
+ uint16_t *len);
+void fp_pub_prep_outcome (struct BRANDT_Auction *ad);
unsigned char *fp_pub_compute_outcome (struct BRANDT_Auction *ad,
size_t *buflen);
int fp_pub_recv_outcome (struct BRANDT_Auction *ad,
@@ -151,6 +155,7 @@ int fp_pub_recv_outcome (struct BRANDT_Auction *ad,
size_t buflen,
uint16_t sender);
+void fp_pub_prep_decryption (struct BRANDT_Auction *ad);
unsigned char *fp_pub_decrypt_outcome (struct BRANDT_Auction *ad,
size_t *buflen);
int fp_pub_recv_decryption (struct BRANDT_Auction *ad,
@@ -158,24 +163,71 @@ int fp_pub_recv_decryption (struct BRANDT_Auction *ad,
size_t buflen,
uint16_t sender);
-int32_t fp_pub_determine_outcome (struct BRANDT_Auction *ad, uint16_t *winner);
+struct BRANDT_Result *fp_pub_determine_outcome (struct BRANDT_Auction *ad,
+ uint16_t *len);
/* --- Round dictionaries --- */
+typedef void
+(*RoundPrep)(struct BRANDT_Auction *ad);
+
typedef int
-(*msg_in)(struct BRANDT_Auction *ad,
+(*MsgIn)(struct BRANDT_Auction *ad,
const unsigned char *buf,
size_t buflen,
uint16_t sender);
typedef unsigned char *
-(*msg_out)(struct BRANDT_Auction *ad,
+(*MsgOut)(struct BRANDT_Auction *ad,
size_t *buflen);
/**
+ * Functions of this type determine the outcome of an auction.
+ *
+ * \todo: export *proof* of erroneous behaviour / outcome.
+ *
+ * @param[in] ad Pointer to the auction data struct.
+ * @param[out] len Amount of items in @a results.
+ * @return An array of results for one or more bidders. Each bidder
+ * will only be listed once.
+ */
+typedef struct BRANDT_Result *
+(*Result)(struct BRANDT_Auction *ad,
+ uint16_t *len);
+
+
+static const RoundPrep handler_prep[auction_last][outcome_last][msg_last] = {
+ [auction_firstPrice] = {
+ [outcome_private] = {
+ [msg_init] = &smc_prep_keyshare,
+ [msg_bid] = &smc_prep_bid,
+// [msg_outcome] = &fp_priv_prep_outcome,
+// [msg_decrypt] = &fp_priv_prep_decryption,
+ },
+ [outcome_public] = {
+ [msg_init] = &smc_prep_keyshare,
+ [msg_bid] = &smc_prep_bid,
+ [msg_outcome] = &fp_pub_prep_outcome,
+ [msg_decrypt] = &fp_pub_prep_decryption,
+ },
+ },
+ [auction_mPlusFirstPrice] = {
+ [outcome_private] = {
+ [msg_init] = &smc_prep_keyshare,
+ [msg_bid] = &smc_prep_bid,
+ },
+ [outcome_public] = {
+ [msg_init] = &smc_prep_keyshare,
+ [msg_bid] = &smc_prep_bid,
+ },
+ },
+};
+
+
+/**
* 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
@@ -185,7 +237,7 @@ typedef unsigned char *
* 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] = {
+static const MsgIn handler_in[auction_last][outcome_last][msg_last] = {
[auction_firstPrice] = {
[outcome_private] = {
[msg_init] = &smc_recv_keyshare,
@@ -224,7 +276,7 @@ static const msg_in handler_in[auction_last][outcome_last][msg_last] = {
* 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] = {
+static const MsgOut handler_out[auction_last][outcome_last][msg_last] = {
[auction_firstPrice] = {
[outcome_private] = {
[msg_init] = &smc_gen_keyshare,
@@ -251,5 +303,28 @@ static const msg_out handler_out[auction_last][outcome_last][msg_last] = {
},
};
+/**
+ * stores the function pointers to outcome determination functions for each
+ * auction mode.
+ *
+ * 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 Result handler_res[auction_last][outcome_last] = {
+ [auction_firstPrice] = {
+ [outcome_private] = &fp_priv_determine_outcome,
+ [outcome_public] = &fp_pub_determine_outcome,
+ },
+// [auction_mPlusFirstPrice] = {
+// [outcome_private] = ,
+// [outcome_public] = ,
+// },
+};
+
+
#endif /* ifndef _BRANDT_CRYPTO_H */