diff options
Diffstat (limited to 'test_crypto.c')
-rw-r--r-- | test_crypto.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/test_crypto.c b/test_crypto.c index c1774e4..b039011 100644 --- a/test_crypto.c +++ b/test_crypto.c @@ -20,6 +20,8 @@ * @author Markus Teich */ +#include "brandt_config.h" + /* For testing static functions and variables we include the whole source */ #include "crypto.c" @@ -30,7 +32,7 @@ static uint16_t bidders; static uint16_t prizes; -static struct AuctionData *ad; +static struct BRANDT_Auction *ad; int test_smc_2d_array () @@ -79,8 +81,8 @@ test_serialization () { gcry_mpi_point_t oldp = gcry_mpi_point_new (0); gcry_mpi_point_t newp = gcry_mpi_point_new (0); - gcry_mpi_t oldi = gcry_mpi_new (0); - gcry_mpi_t newi = gcry_mpi_new (0); + gcry_mpi_t oldi = gcry_mpi_new (256); + gcry_mpi_t newi = gcry_mpi_new (256); struct ec_mpi serp; struct ec_mpi seri; @@ -111,7 +113,7 @@ int test_smc_zkp_dl () { struct proof_dl proof; - gcry_mpi_t x = gcry_mpi_new (0); + gcry_mpi_t x = gcry_mpi_new (256); gcry_mpi_point_t v = gcry_mpi_point_new (0); ec_skey_create (x); @@ -130,7 +132,7 @@ int test_smc_zkp_2dle () { struct proof_2dle proof; - gcry_mpi_t x = gcry_mpi_new (0); + gcry_mpi_t x = gcry_mpi_new (256); gcry_mpi_point_t g1 = gcry_mpi_point_new (0); gcry_mpi_point_t g2 = gcry_mpi_point_new (0); gcry_mpi_point_t v = gcry_mpi_point_new (0); @@ -184,7 +186,7 @@ test_setup_auction_data () { uint16_t i; - ad = calloc (bidders, sizeof (struct AuctionData)); + ad = calloc (bidders, sizeof (struct BRANDT_Auction)); for (i = 0; i < bidders; i++) { @@ -266,7 +268,7 @@ test_round2 () for (i = 0; i < bidders; i++) { - bufs[i] = smc_compute_outcome (&ad[i], &lens[i]); + bufs[i] = fp_priv_compute_outcome (&ad[i], &lens[i]); check (bufs[i], "failed to compute outcome"); } @@ -276,7 +278,7 @@ test_round2 () { if (s == i) continue; - check (smc_recv_outcome (&ad[i], bufs[s], lens[s], s), + check (fp_priv_recv_outcome (&ad[i], bufs[s], lens[s], s), "failed checking outcome"); } } @@ -296,7 +298,7 @@ test_round3 () for (i = 0; i < bidders; i++) { - bufs[i] = smc_decrypt_outcome (&ad[i], &lens[i]); + bufs[i] = fp_priv_decrypt_outcome (&ad[i], &lens[i]); check (bufs[i], "failed to decrypt outcome"); } @@ -306,7 +308,7 @@ test_round3 () { if (s == i) continue; - check (smc_recv_decryption (&ad[i], bufs[s], lens[s], s), + check (fp_priv_recv_decryption (&ad[i], bufs[s], lens[s], s), "failed checking decrypted outcome"); } } @@ -324,7 +326,7 @@ test_outcome () for (uint16_t i = 0; i < ad->n; i++) { - if (-1 != smc_determine_outcome (&ad[i])) + if (-1 != fp_priv_determine_outcome (&ad[i])) { check (-1 == ret, "multiple winners detected"); ret = i; @@ -346,9 +348,14 @@ cleanup_auction_data () 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); + smc_free2 (ad[i].gamma2, ad[i].n, ad[i].k); + smc_free2 (ad[i].delta2, ad[i].n, ad[i].k); + smc_free2 (ad[i].phi2, ad[i].n, ad[i].k); + smc_free3 (ad[i].gamma3, ad[i].n, ad[i].n, ad[i].k); + smc_free3 (ad[i].delta3, ad[i].n, ad[i].n, ad[i].k); + smc_free3 (ad[i].phi3, ad[i].n, ad[i].n, ad[i].k); + smc_free1 (ad[i].tmpa1, ad[i].k); + smc_free1 (ad[i].tmpb1, ad[i].k); } free (ad); } @@ -358,11 +365,13 @@ int main (int argc, char *argv[]) { int repeat = 8; + struct GNUNET_CRYPTO_EccDlogContext *edc; bidders = 2; prizes = 2 * bidders; - BRANDT_init (); + edc = GNUNET_CRYPTO_ecc_dlog_prepare (1024 * 1024, 1024); + BRANDT_init (edc); /* tests that need to run only once */ run (test_smc_2d_array); @@ -384,5 +393,6 @@ main (int argc, char *argv[]) cleanup_auction_data (); } + GNUNET_CRYPTO_ecc_dlog_release (edc); return ret; } |