From 7975df02197ad12b323a0b000434ff794cdc94c2 Mon Sep 17 00:00:00 2001 From: Markus Teich Date: Tue, 28 Jun 2016 22:05:30 +0200 Subject: add outcome determination plus test - also fix bug in smc_sum() --- test_crypto.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'test_crypto.c') diff --git a/test_crypto.c b/test_crypto.c index 7f6430e..c1774e4 100644 --- a/test_crypto.c +++ b/test_crypto.c @@ -317,19 +317,38 @@ test_round3 () } +int +test_outcome () +{ + int32_t ret = -1; + + for (uint16_t i = 0; i < ad->n; i++) + { + if (-1 != smc_determine_outcome (&ad[i])) + { + check (-1 == ret, "multiple winners detected"); + ret = i; + } + } + check (-1 != ret, "no winner detected"); + fputs ("winner detected", stderr); + return 1; +} + + void cleanup_auction_data () { for (uint16_t i = 0; i < bidders; i++) { - for (uint16_t h = 0; h < bidders; h++) - gcry_mpi_point_release (ad[i].y[h]); - gcry_mpi_point_release (ad[i].Y); gcry_mpi_release (ad[i].x); - free (ad[i].y); + smc_free1 (ad[i].y, ad[i].n); smc_free2 (ad[i].alpha, ad[i].n, ad[i].k); smc_free2 (ad[i].beta, ad[i].n, ad[i].k); + smc_free3 (ad[i].gamma, ad[i].n, ad[i].n, ad[i].k); + smc_free3 (ad[i].delta, ad[i].n, ad[i].n, ad[i].k); + smc_free3 (ad[i].phi, ad[i].n, ad[i].n, ad[i].k); } free (ad); } @@ -361,6 +380,7 @@ main (int argc, char *argv[]) run (test_round1); run (test_round2); run (test_round3); + run (test_outcome); cleanup_auction_data (); } -- cgit v1.2.3