summaryrefslogtreecommitdiff
path: root/src/Crypto/Tox.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-10-21 22:01:16 -0400
committerjoe <joe@jerkface.net>2017-10-21 22:01:16 -0400
commit7ab09c43f0bb6f8f42c0156644869dfe78aa0b89 (patch)
tree760fb412fe55e7de11e5011a1f54f1f4ee5afefb /src/Crypto/Tox.hs
parentcbdcc6500d6bda9948268312fc0bfb17955e53c5 (diff)
Renamed Assym -> Asymm (short for asymmetric).
Diffstat (limited to 'src/Crypto/Tox.hs')
-rw-r--r--src/Crypto/Tox.hs38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/Crypto/Tox.hs b/src/Crypto/Tox.hs
index 645ca53e..ed8ec59e 100644
--- a/src/Crypto/Tox.hs
+++ b/src/Crypto/Tox.hs
@@ -20,11 +20,11 @@ module Crypto.Tox
20 , Encrypted 20 , Encrypted
21 , Encrypted8(..) 21 , Encrypted8(..)
22 , type (∘)(..) 22 , type (∘)(..)
23 , Assym(..) 23 , Asymm(..)
24 , getAssym 24 , getAsymm
25 , getAliasedAssym 25 , getAliasedAsymm
26 , putAssym 26 , putAsymm
27 , putAliasedAssym 27 , putAliasedAsymm
28 , Plain 28 , Plain
29 , encodePlain 29 , encodePlain
30 , decodePlain 30 , decodePlain
@@ -326,34 +326,34 @@ zeros24 = BA.take 24 zs where Nonce32 zs = zeros32
326-- | `32` | sender's DHT public key | 326-- | `32` | sender's DHT public key |
327-- | `24` | nonce | 327-- | `24` | nonce |
328-- | `?` | encrypted message | 328-- | `?` | encrypted message |
329data Assym a = Assym 329data Asymm a = Asymm
330 { senderKey :: PublicKey 330 { senderKey :: PublicKey
331 , assymNonce :: Nonce24 331 , asymmNonce :: Nonce24
332 , assymData :: a 332 , asymmData :: a
333 } 333 }
334 deriving (Functor,Foldable,Traversable, Show) 334 deriving (Functor,Foldable,Traversable, Show)
335 335
336instance Sized a => Sized (Assym a) where 336instance Sized a => Sized (Asymm a) where
337 size = case size of 337 size = case size of
338 ConstSize a -> ConstSize $ a + 24 + 32 338 ConstSize a -> ConstSize $ a + 24 + 32
339 VarSize f -> VarSize $ \Assym { assymData = x } -> f x + 24 + 32 339 VarSize f -> VarSize $ \Asymm { asymmData = x } -> f x + 24 + 32
340 340
341-- | Field order: senderKey, then nonce This is the format used by 341-- | Field order: senderKey, then nonce This is the format used by
342-- Ping/Pong/GetNodes/SendNodes. 342-- Ping/Pong/GetNodes/SendNodes.
343-- 343--
344-- See 'getAliasedAssym' if the nonce precedes the key. 344-- See 'getAliasedAsymm' if the nonce precedes the key.
345getAssym :: Serialize a => Get (Assym a) 345getAsymm :: Serialize a => Get (Asymm a)
346getAssym = Assym <$> getPublicKey <*> get <*> get 346getAsymm = Asymm <$> getPublicKey <*> get <*> get
347 347
348putAssym :: Serialize a => Assym a -> Put 348putAsymm :: Serialize a => Asymm a -> Put
349putAssym (Assym key nonce dta) = putPublicKey key >> put nonce >> put dta 349putAsymm (Asymm key nonce dta) = putPublicKey key >> put nonce >> put dta
350 350
351-- | Field order: nonce, and then senderKey. 351-- | Field order: nonce, and then senderKey.
352getAliasedAssym :: Serialize a => Get (Assym a) 352getAliasedAsymm :: Serialize a => Get (Asymm a)
353getAliasedAssym = flip Assym <$> get <*> getPublicKey <*> get 353getAliasedAsymm = flip Asymm <$> get <*> getPublicKey <*> get
354 354
355putAliasedAssym :: Serialize a => Assym a -> Put 355putAliasedAsymm :: Serialize a => Asymm a -> Put
356putAliasedAssym (Assym key nonce dta) = put nonce >> putPublicKey key >> put dta 356putAliasedAsymm (Asymm key nonce dta) = put nonce >> putPublicKey key >> put dta
357 357
358newtype SymmetricKey = SymmetricKey ByteString 358newtype SymmetricKey = SymmetricKey ByteString
359 359