aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-07-10 16:34:01 +0200
committerChristian Grothoff <christian@grothoff.org>2023-07-10 16:34:01 +0200
commit6a483b51ec6b857982a45d5215834c99a827066f (patch)
treee73657ce26e140a1b18925e8f7335a0432908329 /src/util/crypto.c
parent66f9a5b5e5431b6a24352e8ce95e30c8b00a6d92 (diff)
downloadexchange-6a483b51ec6b857982a45d5215834c99a827066f.tar.xz
fix alignment issue, ensure we hash over packed structure to avoid non-determinism
Diffstat (limited to 'src/util/crypto.c')
-rw-r--r--src/util/crypto.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/util/crypto.c b/src/util/crypto.c
index bb14b6cdc..8699035c8 100644
--- a/src/util/crypto.c
+++ b/src/util/crypto.c
@@ -461,4 +461,54 @@ TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet,
}
+GNUNET_NETWORK_STRUCT_BEGIN
+/**
+ * Structure we hash to compute the group key for
+ * a denomination group.
+ */
+struct DenominationGroupP
+{
+ /**
+ * Value of coins in this denomination group.
+ */
+ struct TALER_AmountNBO value;
+
+ /**
+ * Fee structure for all coins in the group.
+ */
+ struct TALER_DenomFeeSetNBOP fees;
+
+ /**
+ * Age mask for the denomiation, in NBO.
+ */
+ uint32_t age_mask GNUNET_PACKED;
+
+ /**
+ * Cipher used for the denomination, in NBO.
+ */
+ uint32_t cipher GNUNET_PACKED;
+};
+GNUNET_NETWORK_STRUCT_END
+
+
+void
+TALER_denomination_group_get_key (
+ const struct TALER_DenominationGroup *dg,
+ struct GNUNET_HashCode *key)
+{
+ struct DenominationGroupP dgp = {
+ .age_mask = htonl (dg->age_mask.bits),
+ .cipher = htonl (dg->cipher)
+ };
+
+ TALER_amount_hton (&dgp.value,
+ &dg->value);
+ TALER_denom_fee_set_hton (&dgp.fees,
+ &dg->fees);
+ GNUNET_CRYPTO_hash (&dgp,
+ sizeof (dgp),
+ key);
+}
+
+
/* end of crypto.c */