add private keys (undsigned) to the transcript
This commit is contained in:
parent
e1d6c8eb3e
commit
09af66c165
134
test_brandt.c
134
test_brandt.c
@ -341,8 +341,8 @@ cb_result (void *auction_closure,
|
||||
{
|
||||
/* save the results of the seller */
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Saving results, len %d\n",
|
||||
results_len);
|
||||
"Saving results, len %d\n",
|
||||
results_len);
|
||||
tcase.res = results;
|
||||
tcase.res_len = results_len;
|
||||
}
|
||||
@ -502,7 +502,8 @@ tr_start (void *auction_closure)
|
||||
}
|
||||
|
||||
|
||||
struct some_sig {
|
||||
struct some_sig
|
||||
{
|
||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||
struct GNUNET_HashCode hc GNUNET_PACKED;
|
||||
};
|
||||
@ -519,7 +520,7 @@ print_transcript (uint32_t highestprice)
|
||||
json_t *transcript;
|
||||
json_t *winners;
|
||||
struct GNUNET_HashCode hc;
|
||||
struct some_sig p = { .purpose.size = htonl(sizeof(struct some_sig)) };
|
||||
struct some_sig p = { .purpose.size = htonl (sizeof(struct some_sig)) };
|
||||
char price[256];
|
||||
|
||||
prices = json_array ();
|
||||
@ -527,20 +528,22 @@ print_transcript (uint32_t highestprice)
|
||||
|
||||
for (size_t p = 0; p < tcase.k; p++)
|
||||
{
|
||||
sprintf(price, "EUR:%d", highestprice--);
|
||||
sprintf (price, "EUR:%d", highestprice--);
|
||||
GNUNET_assert (
|
||||
-1 != json_array_append_new (
|
||||
prices,
|
||||
json_string(price)));
|
||||
json_string (price)));
|
||||
}
|
||||
|
||||
auction = json_pack ("{s:{s:o}, s:{s:o}, s:i, s:b, s:o, s:s, s:s}",
|
||||
"time_start", "t_s", json_integer (ad->time_start.abs_value_us / 1000LL),
|
||||
"time_round", "d_us", json_integer (ad->time_round.rel_value_us),
|
||||
"time_start", "t_s", json_integer (
|
||||
ad->time_start.abs_value_us / 1000LL),
|
||||
"time_round", "d_us", json_integer (
|
||||
ad->time_round.rel_value_us),
|
||||
"type", ad->m,
|
||||
"public", ad->outcome_public == 0 ? json_false () : json_true (),
|
||||
"is_public", ad->outcome_public == 0 ? json_false () : json_true (),
|
||||
"prices", prices,
|
||||
"payto", "payto://some/iban",
|
||||
"payto_uri", "payto://some/iban",
|
||||
"pubkey", GNUNET_CRYPTO_eddsa_public_key_to_string (
|
||||
&tcase.pub[tcase.n]));
|
||||
GNUNET_assert (auction);
|
||||
@ -560,24 +563,24 @@ print_transcript (uint32_t highestprice)
|
||||
sigs = json_array ();
|
||||
GNUNET_assert (sigs);
|
||||
{
|
||||
char *auc_js = json_dumps(auction, JSON_COMPACT);
|
||||
GNUNET_CRYPTO_hash(auc_js,
|
||||
strlen(auc_js),
|
||||
&hc);
|
||||
char *auc_js = json_dumps (auction, JSON_COMPACT);
|
||||
GNUNET_CRYPTO_hash (auc_js,
|
||||
strlen (auc_js),
|
||||
&hc);
|
||||
|
||||
p.purpose.purpose = htonl(23);
|
||||
p.purpose.purpose = htonl (23);
|
||||
p.hc = hc;
|
||||
|
||||
for (size_t b = 0; b < tcase.n; b++)
|
||||
{
|
||||
struct GNUNET_CRYPTO_EddsaSignature sig;
|
||||
GNUNET_CRYPTO_eddsa_sign(&tcase.prv[b],
|
||||
&p,
|
||||
&sig);
|
||||
GNUNET_CRYPTO_eddsa_sign (&tcase.prv[b],
|
||||
&p,
|
||||
&sig);
|
||||
GNUNET_assert (-1 !=
|
||||
json_array_append_new (
|
||||
sigs,
|
||||
GNUNET_JSON_from_data_auto(&sig)));
|
||||
GNUNET_JSON_from_data_auto (&sig)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -592,16 +595,16 @@ print_transcript (uint32_t highestprice)
|
||||
|
||||
if (NULL == msg)
|
||||
{
|
||||
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
|
||||
"skipping NULL msg[%ld]\n", i);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"skipping NULL msg[%ld]\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
GNUNET_assert (msg);
|
||||
|
||||
GNUNET_CRYPTO_hash(msg->buf, msg->buf_len, &hc);
|
||||
GNUNET_CRYPTO_hash (msg->buf, msg->buf_len, &hc);
|
||||
|
||||
p.purpose.purpose = htonl(42);
|
||||
p.purpose.purpose = htonl (42);
|
||||
p.hc = hc;
|
||||
|
||||
GNUNET_CRYPTO_eddsa_sign (
|
||||
@ -613,7 +616,7 @@ print_transcript (uint32_t highestprice)
|
||||
entry = json_pack ("{s:i, s:o, s:o}",
|
||||
"bidder", msg->sender,
|
||||
"msg", GNUNET_JSON_from_data (msg->buf, msg->buf_len),
|
||||
"sig", GNUNET_JSON_from_data_auto(&sig));
|
||||
"sig", GNUNET_JSON_from_data_auto (&sig));
|
||||
|
||||
GNUNET_assert (entry);
|
||||
GNUNET_assert (-1 !=
|
||||
@ -622,23 +625,23 @@ print_transcript (uint32_t highestprice)
|
||||
|
||||
}
|
||||
|
||||
winners = json_array();
|
||||
winners = json_array ();
|
||||
GNUNET_assert (winners);
|
||||
|
||||
// add the winner(s)
|
||||
{
|
||||
for (uint16_t i = 0; i < tcase.res_len ; i++)
|
||||
for (uint16_t i = 0; i < tcase.res_len; i++)
|
||||
{
|
||||
json_t *res = json_pack("{s:i, s:i, s:o*}",
|
||||
"bidder",
|
||||
tcase.res[i].bidder,
|
||||
"price_idx",
|
||||
tcase.res[i].price,
|
||||
"price",
|
||||
json_array_get(prices, tcase.res[i].price));
|
||||
GNUNET_assert(res);
|
||||
GNUNET_assert(-1 !=
|
||||
json_array_append_new(winners, res));
|
||||
json_t *res = json_pack ("{s:i, s:i, s:o*}",
|
||||
"bidder",
|
||||
tcase.res[i].bidder,
|
||||
"price_idx",
|
||||
tcase.res[i].price,
|
||||
"price",
|
||||
json_array_get (prices, tcase.res[i].price));
|
||||
GNUNET_assert (res);
|
||||
GNUNET_assert (-1 !=
|
||||
json_array_append_new (winners, res));
|
||||
|
||||
}
|
||||
}
|
||||
@ -649,39 +652,60 @@ print_transcript (uint32_t highestprice)
|
||||
"bidders", bidders,
|
||||
"signatures", sigs,
|
||||
"transcript", transcript,
|
||||
"winners", winners);
|
||||
"winners", winners);
|
||||
|
||||
GNUNET_assert (root);
|
||||
|
||||
// Add signature of seller to H(auction, bidders, signatures, transscript, result)
|
||||
// Add signature of seller to H(auction, bidders, signatures, transcript, result)
|
||||
{
|
||||
struct GNUNET_CRYPTO_EddsaSignature sig;
|
||||
char *root_js = json_dumps(root, JSON_COMPACT|JSON_SORT_KEYS);
|
||||
char *root_js = json_dumps (root, JSON_COMPACT | JSON_SORT_KEYS);
|
||||
|
||||
GNUNET_CRYPTO_hash(root_js,
|
||||
strlen(root_js),
|
||||
&hc);
|
||||
GNUNET_CRYPTO_hash (root_js,
|
||||
strlen (root_js),
|
||||
&hc);
|
||||
|
||||
p.purpose.purpose = htonl(815);
|
||||
p.purpose.purpose = htonl (815);
|
||||
p.hc = hc;
|
||||
|
||||
GNUNET_CRYPTO_eddsa_sign(&tcase.prv[tcase.n],
|
||||
&p,
|
||||
&sig);
|
||||
GNUNET_assert ( -1 !=
|
||||
json_object_set_new (
|
||||
root,
|
||||
"sig",
|
||||
GNUNET_JSON_from_data_auto(&sig)));
|
||||
GNUNET_CRYPTO_eddsa_sign (&tcase.prv[tcase.n],
|
||||
&p,
|
||||
&sig);
|
||||
GNUNET_assert (-1 !=
|
||||
json_object_set_new (
|
||||
root,
|
||||
"sig",
|
||||
GNUNET_JSON_from_data_auto (&sig)));
|
||||
|
||||
free(root_js);
|
||||
free (root_js);
|
||||
}
|
||||
|
||||
printf ("%s\n", json_dumps (root, JSON_INDENT (2)));
|
||||
// After signing the transcript, add private key material, too, so it
|
||||
// can be used in integration tests.
|
||||
{
|
||||
json_t *keys = json_array ();
|
||||
GNUNET_assert (keys);
|
||||
|
||||
for (size_t b = 0; b <= /* = is important */ tcase.n; b++)
|
||||
{
|
||||
char *ps = GNUNET_CRYPTO_eddsa_private_key_to_string (&tcase.prv[b]);
|
||||
GNUNET_assert (-1 !=
|
||||
json_array_append_new (keys,
|
||||
json_string (ps)));
|
||||
}
|
||||
|
||||
json_object_set_new (
|
||||
root,
|
||||
"NOTSIGNED_keys",
|
||||
keys);
|
||||
}
|
||||
|
||||
printf ("\n%s\n", json_dumps (root, JSON_INDENT (2)));
|
||||
json_decref (root);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
replay_transcript (void *arg)
|
||||
{
|
||||
@ -689,7 +713,7 @@ replay_transcript (void *arg)
|
||||
size_t desc_len;
|
||||
static struct GNUNET_CRYPTO_EccDlogContext *redc;
|
||||
|
||||
print_transcript(96);
|
||||
print_transcript (96);
|
||||
redc = GNUNET_CRYPTO_ecc_dlog_prepare (1024, 16);
|
||||
|
||||
dprintf (2,"REPLAY, calling BRANDT_new...\n");
|
||||
@ -713,8 +737,6 @@ replay_transcript (void *arg)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test a specific auction setup.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user