From 231cdaf4f777165c3858d737f0b7b799d39758ce Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 13 Nov 2022 21:45:43 +0100 Subject: add test for batch CS derive/sign logic --- src/util/test_helper_cs.c | 238 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 234 insertions(+), 4 deletions(-) (limited to 'src/util/test_helper_cs.c') diff --git a/src/util/test_helper_cs.c b/src/util/test_helper_cs.c index 7c57d50cf..fdfc5c362 100644 --- a/src/util/test_helper_cs.c +++ b/src/util/test_helper_cs.c @@ -439,8 +439,6 @@ test_signing (struct TALER_CRYPTO_CsDenominationHelper *dh) }; pd.blinded_planchet.cipher = TALER_DENOMINATION_CS; - // keys[i].denom_pub.cipher = TALER_DENOMINATION_CS; - TALER_cs_withdraw_nonce_derive (&ps, &pd.blinded_planchet.details. cs_blinded_planchet.nonce); @@ -592,6 +590,209 @@ test_signing (struct TALER_CRYPTO_CsDenominationHelper *dh) } +/** + * Test batch signing logic. + * + * @param dh handle to the helper + * @param batch_size how large should the batch be + * @param check_sigs also check unknown key and signatures + * @return 0 on success + */ +static int +test_batch_signing (struct TALER_CRYPTO_CsDenominationHelper *dh, + unsigned int batch_size, + bool check_sigs) +{ + struct TALER_BlindedDenominationSignature ds[batch_size]; + enum TALER_ErrorCode ec; + bool success = false; + struct TALER_PlanchetMasterSecretP ps[batch_size]; + struct TALER_CoinSpendPrivateKeyP coin_priv[batch_size]; + union TALER_DenominationBlindingKeyP bks[batch_size]; + struct TALER_CoinPubHashP c_hash[batch_size]; + struct TALER_ExchangeWithdrawValues alg_values[batch_size]; + + for (unsigned int i = 0; i, + GNUNET_TIME_UNIT_SECONDS)) + { + /* key worked too early */ + GNUNET_break (0); + return 4; + } + if (GNUNET_TIME_relative_cmp (GNUNET_TIME_absolute_get_duration ( + keys[k].start_time.abs_time), + >, + keys[k].validity_duration)) + { + /* key worked too later */ + GNUNET_break (0); + return 5; + } + if (check_sigs) + { + for (unsigned int i = 0; i