2016-06-07 15:49:22 +02:00
|
|
|
/* This file is part of libbrandt.
|
|
|
|
* Copyright (C) 2016 GNUnet e.V.
|
|
|
|
*
|
|
|
|
* libbrandt is free software: you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* libbrandt is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* libbrandt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file internals.h
|
|
|
|
* @brief This header contains library internal structs.
|
2016-06-22 23:18:46 +02:00
|
|
|
* @author Markus Teich
|
2016-06-07 15:49:22 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BRANDT_INTERNALS_H
|
|
|
|
#define _BRANDT_INTERNALS_H
|
|
|
|
|
2016-06-17 15:34:46 +02:00
|
|
|
#include <gcrypt.h>
|
2016-06-07 15:49:22 +02:00
|
|
|
|
2016-07-06 14:56:14 +02:00
|
|
|
#include "brandt.h"
|
|
|
|
|
|
|
|
|
|
|
|
enum rounds {
|
2016-08-23 12:56:44 +02:00
|
|
|
msg_init = 0,
|
|
|
|
msg_bid = 1,
|
|
|
|
msg_outcome = 2,
|
|
|
|
msg_decrypt = 3,
|
|
|
|
msg_last = 4
|
2016-07-06 14:56:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-08-03 01:28:51 +02:00
|
|
|
enum auction_type {
|
2016-08-17 17:37:56 +02:00
|
|
|
auction_firstPrice = 0,
|
|
|
|
auction_mPlusFirstPrice = 1,
|
|
|
|
auction_last = 2
|
2016-08-03 01:28:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum outcome_type {
|
2016-08-17 17:37:56 +02:00
|
|
|
outcome_private = 0,
|
|
|
|
outcome_public = 1,
|
|
|
|
outcome_last = 2
|
2016-08-03 01:28:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-08-10 14:53:31 +02:00
|
|
|
GNUNET_NETWORK_STRUCT_BEGIN
|
|
|
|
|
2016-08-17 17:37:56 +02:00
|
|
|
struct msg_head {
|
|
|
|
uint32_t prot_version GNUNET_PACKED;
|
|
|
|
uint32_t msg_type GNUNET_PACKED;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-07-06 14:56:14 +02:00
|
|
|
/**
|
2016-11-23 23:20:25 +01:00
|
|
|
* This struct describes the parameters of an auction. All fields are stored in
|
2016-08-12 14:38:10 +02:00
|
|
|
* network byte order.
|
2016-11-23 23:20:25 +01:00
|
|
|
*/
|
2016-08-03 01:28:51 +02:00
|
|
|
struct BRANDT_DescrP {
|
2016-08-10 14:53:31 +02:00
|
|
|
/** Starting time of the auction. Bidders have to join the auction via
|
|
|
|
* BRANDT_join until this time */
|
|
|
|
struct GNUNET_TIME_AbsoluteNBO time_start;
|
|
|
|
|
|
|
|
/** The maximum duration the participants have to complete each round. */
|
|
|
|
struct GNUNET_TIME_RelativeNBO time_round;
|
|
|
|
|
|
|
|
/** The amount of possible prices */
|
|
|
|
uint16_t k GNUNET_PACKED;
|
2016-07-06 14:56:14 +02:00
|
|
|
|
|
|
|
/** Auction type. 0 means first price Auction, >= 0 means M+1st price
|
|
|
|
* auction with an amount of m items being sold. */
|
2016-08-10 14:53:31 +02:00
|
|
|
uint16_t m GNUNET_PACKED;
|
2016-07-06 14:56:14 +02:00
|
|
|
|
|
|
|
/** Outcome type. 0 means private outcome, everything else means public
|
|
|
|
* outcome. */
|
2016-08-10 14:53:31 +02:00
|
|
|
uint16_t outcome_public GNUNET_PACKED;
|
2016-08-12 14:38:10 +02:00
|
|
|
|
2016-08-16 13:25:03 +02:00
|
|
|
/** reserved for future use. Must be zeroed out. */
|
2016-11-23 23:20:25 +01:00
|
|
|
uint16_t reserved GNUNET_PACKED;
|
2016-07-06 14:56:14 +02:00
|
|
|
};
|
|
|
|
|
2016-08-10 14:53:31 +02:00
|
|
|
GNUNET_NETWORK_STRUCT_END
|
|
|
|
|
2016-07-06 14:56:14 +02:00
|
|
|
|
|
|
|
struct BRANDT_Auction {
|
2016-08-10 14:53:31 +02:00
|
|
|
/** Starting time of the auction. Bidders have to join the auction via
|
|
|
|
* BRANDT_join until this time */
|
|
|
|
struct GNUNET_TIME_Absolute time_start;
|
|
|
|
|
|
|
|
/** The maximum duration the participants have to complete each round. */
|
|
|
|
struct GNUNET_TIME_Relative time_round;
|
|
|
|
|
|
|
|
/** Auction type. 0 means first price Auction, >= 0 means M+1st price
|
|
|
|
* auction with an amount of m items being sold. */
|
|
|
|
uint16_t m;
|
|
|
|
|
|
|
|
/** Outcome type. 0 means private outcome, everything else means public
|
|
|
|
* outcome. */
|
|
|
|
uint16_t outcome_public;
|
2016-07-06 14:56:14 +02:00
|
|
|
|
2016-08-12 14:38:10 +02:00
|
|
|
/** Link to the next delayed task (auction start trigger, round trigger) */
|
|
|
|
struct GNUNET_SCHEDULER_Task *task;
|
|
|
|
|
2016-08-03 14:07:21 +02:00
|
|
|
void *closure; /** auction closure given by the user */
|
|
|
|
|
2016-12-02 11:45:05 +01:00
|
|
|
BRANDT_CbResult result; /** result reporting callback */
|
|
|
|
BRANDT_CbDeliver bcast; /** broadcast callback */
|
|
|
|
BRANDT_CbDeliver ucast; /** unicast callback */
|
|
|
|
BRANDT_CbStart start; /** start callback */
|
2016-07-06 14:56:14 +02:00
|
|
|
|
|
|
|
int seller_mode; /** If 0 we are bidding, selling otherwise */
|
|
|
|
enum rounds cur_round; /** The round we expect messages from */
|
|
|
|
gcry_mpi_t round_progress; /** Stores which round messages were received */
|
|
|
|
|
|
|
|
uint16_t n; /** The amount of bidders/agents */
|
|
|
|
uint16_t k; /** The amount of possible prices */
|
|
|
|
uint16_t i; /** Own agents index, only used when bidding */
|
|
|
|
uint16_t b; /** Own bid */
|
|
|
|
|
|
|
|
gcry_mpi_t x; /** Own private additive key share */
|
|
|
|
gcry_mpi_point_t *y; /** public multiplicative key shares, size: n */
|
|
|
|
gcry_mpi_point_t Y; /** Shared public key */
|
|
|
|
|
|
|
|
gcry_mpi_point_t **alpha; /** alphas, size: n*k */
|
|
|
|
gcry_mpi_point_t **beta; /** betas, size: n*k */
|
|
|
|
|
2016-09-29 10:22:00 +02:00
|
|
|
gcry_mpi_point_t **gamma2; /** gamma2, for public outcome, size: n*k */
|
|
|
|
gcry_mpi_point_t ***gamma3; /** gamma3, for private outcome, size: n*n*k */
|
|
|
|
gcry_mpi_point_t **delta2; /** delta2, for public outcome, size: n*k */
|
|
|
|
gcry_mpi_point_t ***delta3; /** delta3, for private outcome, size: n*n*k */
|
|
|
|
gcry_mpi_point_t **phi2; /** phi2, for public outcome, size: n*k */
|
|
|
|
gcry_mpi_point_t ***phi3; /** phi3, for private outcome, size: n*n*k */
|
|
|
|
|
|
|
|
/** proofs for the correctnes of the phi values, size: n*k */
|
|
|
|
struct proof_2dle ***phiproofs2;
|
|
|
|
|
|
|
|
/** proofs for the correctnes of the phi values, size: n*n*k */
|
|
|
|
struct proof_2dle ***phiproofs3;
|
2016-09-08 19:17:15 +02:00
|
|
|
|
2016-07-06 14:56:14 +02:00
|
|
|
gcry_mpi_point_t *tmpa1; /** used for temporary storage, size: k */
|
|
|
|
gcry_mpi_point_t *tmpb1; /** used for temporary storage, size: k */
|
2016-12-02 12:53:54 +01:00
|
|
|
|
|
|
|
/** only needed in M+1st price auctions to determine winners */
|
|
|
|
struct GNUNET_CRYPTO_EccDlogContext *dlogctx;
|
2016-06-07 15:49:22 +02:00
|
|
|
};
|
|
|
|
|
2016-12-02 12:53:54 +01:00
|
|
|
extern gcry_ctx_t ec_ctx;
|
|
|
|
extern gcry_mpi_point_t ec_gen;
|
|
|
|
extern gcry_mpi_point_t ec_zero;
|
|
|
|
extern gcry_mpi_t ec_n;
|
2016-09-29 18:22:21 +02:00
|
|
|
|
2016-06-17 15:34:46 +02:00
|
|
|
#endif /* ifndef _BRANDT_INTERNALS_H */
|