diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-04-27 15:26:50 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-04-27 15:55:39 -0400 |
commit | 686dcc8b172b77e3e612ba4badbb88879d0f5599 (patch) | |
tree | 5dd568eb15fe1a64a0c77adda8901509396ebd73 /Types.hs | |
parent | f6a9cd9c705850a19e2677150c1168bea1a7a9c7 (diff) | |
download | debug-me-686dcc8b172b77e3e612ba4badbb88879d0f5599.tar.gz |
Leave the prevMessage out of Activity serialization to save BW.
Do include it in the data that gets signed, so it can be recovered
by trying each likely (recently seen) Activity as the prevMessage, and
checking the signature.
The UserState and DeveloperState already had the necessary state about
recently seen hashes, so this does not impact data use.
One tricky bit is that relayFromSocket needs to wait for the TMChan
to be empty before calling restorePrevActivityHash. Otherwise, the
hashes of items in the channel that have not been processed yet won't be
tried. The TMChan is not really being used as a channel since only 1
item can be in it. It could be converted to a TMVar, but closeTMChan is
used so I left it as a channel.
Note that the server does not restore hashes of messages that pass
through it; it's just a dumb relay.
Sending a single key press now only needs 94 bytes of data to be sent,
down from 169!
---
Also switched to SHA512, since hashes are no longer being sent over
the wire and so the larger size does not matter. SHA512 is slightly
faster and more secure.
This commit was sponsored by Ewen McNeill.
Diffstat (limited to 'Types.hs')
-rw-r--r-- | Types.hs | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -55,7 +55,7 @@ instance DataSize a => DataSize (Message a) where -- -- The Signature is over both the data in the activity, and its pointer. -- --- Note that the Signature is included in the Hash of an Activity, +-- The Signature is included in the Hash of an Activity, -- which is why it's part of the Activity. data Activity a = Activity { activity :: a @@ -107,12 +107,12 @@ data Hash = Hash deriving (Show, Generic, Eq) instance DataSize Hash where - dataSize (Hash { hashMethod = SHA256 }) = 64 + dataSize (Hash { hashMethod = SHA512 }) = 128 dataSize (Hash { hashMethod = SHA3 }) = 56 --- | We use SHA256. (SHA3 is included to future proof, and because it +-- | We use SHA512. (SHA3 is included to future proof, and because it -- improves the generated JSON.) -data HashMethod = SHA256 | SHA3 +data HashMethod = SHA512 | SHA3 deriving (Show, Generic, Eq) data Signature |