aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-03-09 12:29:41 +0100
committerChristian Grothoff <christian@grothoff.org>2015-03-09 12:29:41 +0100
commit579f465c9b2ed1cd4602ee102073d633fda60cb9 (patch)
tree99b546c629bfa876ccbe4f829a68c3fe8d80624a /src/util
parent7b0ae9c1d0a3c3165a8cef8cc12d04d207a49ce2 (diff)
implementing #3632: generate proof of insufficient funds by converting transaction history to JSON
Diffstat (limited to 'src/util')
-rw-r--r--src/util/json.c50
1 files changed, 47 insertions, 3 deletions
diff --git a/src/util/json.c b/src/util/json.c
index 02591d7bf..38f459200 100644
--- a/src/util/json.c
+++ b/src/util/json.c
@@ -90,8 +90,8 @@ TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp)
* @return the JSON reporesentation of the signature with purpose
*/
json_t *
-TALER_JSON_from_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
- const struct GNUNET_CRYPTO_EddsaSignature *signature)
+TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EddsaSignature *signature)
{
json_t *root;
json_t *el;
@@ -106,7 +106,37 @@ TALER_JSON_from_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
el = TALER_JSON_from_data (signature,
sizeof (struct GNUNET_CRYPTO_EddsaSignature));
- json_object_set_new (root, "sig", el);
+ json_object_set_new (root, "eddsa-sig", el);
+
+ return root;
+}
+
+
+/**
+ * Convert a signature (with purpose) to a JSON object representation.
+ *
+ * @param purpose purpose of the signature
+ * @param signature the signature
+ * @return the JSON reporesentation of the signature with purpose
+ */
+json_t *
+TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EcdsaSignature *signature)
+{
+ json_t *root;
+ json_t *el;
+
+ root = json_object ();
+
+ el = json_integer ((json_int_t) ntohl (purpose->size));
+ json_object_set_new (root, "size", el);
+
+ el = json_integer ((json_int_t) ntohl (purpose->purpose));
+ json_object_set_new (root, "purpose", el);
+
+ el = TALER_JSON_from_data (signature,
+ sizeof (struct GNUNET_CRYPTO_EddsaSignature));
+ json_object_set_new (root, "ecdsa-sig", el);
return root;
}
@@ -134,6 +164,20 @@ TALER_JSON_from_data (const void *data, size_t size)
/**
+ * Convert binary hash to a JSON string with the base32crockford
+ * encoding.
+ *
+ * @param hc binary data
+ * @return json string that encodes @a hc
+ */
+json_t *
+TALER_JSON_from_hash (const struct GNUNET_HashCode *hc)
+{
+ return TALER_JSON_from_data (hc, sizeof (struct GNUNET_HashCode));
+}
+
+
+/**
* Parse given JSON object to Amount
*
* @param json the json object representing Amount