From b5d5f86a88c8dbd1cee9e28a659bfe1c26f38eaa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 14 Apr 2017 10:05:13 -0400 Subject: improve JSON Most of the time, ByteStrings will be able to be encoded as utf8, so avoid base64 when not needed. Adjusted some of the types in order to generate more usual JSON. In particular, removed StartActivity. The JSON now looks like this (with the signature still not populated): {"signature":{"v":""},"prevActivity":{"hashValue":{"v":"3b1abe614dd43bdb2d9a56777884e2d0f3bac9796e2d25c1ad52bb689c117286"},"hashMethod":"SHA256"},"activity":{"echoData":{"v":""},"enteredData":{"v":"l"}}} 203 bytes to send a single keystroke is not great when there's really only 1+64(hash) bytes of unique data. So, may end up adding a wire encoding on top of this. But, JSON is good to have for storage of the proofs, etc. Also, it does compress well. Two such JSON objects gzip -9 to 219 bytes, and three to 265 bytes. So, 37 bytes per keystroke. This is *exactly* as efficient as gzip -9 of $c$hash formatted data. This commit was sponsored by Jack Hill on Patreon. --- Hash.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Hash.hs') diff --git a/Hash.hs b/Hash.hs index 4174d5f..f2b8d75 100644 --- a/Hash.hs +++ b/Hash.hs @@ -26,8 +26,8 @@ instance Hashable [HashPointer] where hash = hash . B.concat . map (val . hashValue) instance Hashable a => Hashable (Activity a) where - hash (Activity a p s) = hash [hash a, p, hash s] - hash (StartActivity a s) = hash [hash a, hash s] + hash (Activity a (Just p) s) = hash [hash a, p, hash s] + hash (Activity a Nothing s) = hash [hash a, hash s] instance Hashable Entered where hash v = hash [hash (enteredData v), hash (echoData v)] -- cgit v1.2.3