From 7808d0e6c96ccdf0431619fa1a688612b8a1f921 Mon Sep 17 00:00:00 2001 From: joe Date: Sun, 9 Jul 2017 01:14:03 -0400 Subject: TOX publickey: switch from decode to ByteArrayAccess. --- src/Network/DatagramServer/Tox.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Network/DatagramServer/Tox.hs b/src/Network/DatagramServer/Tox.hs index 1763e74c..85ee269c 100644 --- a/src/Network/DatagramServer/Tox.hs +++ b/src/Network/DatagramServer/Tox.hs @@ -394,8 +394,13 @@ instance WireFormat ByteString Message where initializeServerState _ _ = do k <- generateSecretKey - let Right nid = S.decode $ convert $ toPublic k - return (nid, ToxCipherContext k) + nid <- withByteArray (toPublic k) $ \p -> do + wlo <- peekElemOff p 0 + wmid <- peekElemOff p 1 + whi <- peekElemOff p 2 + whigest <- peekElemOff p 3 + return $ LargeKey wlo (LargeKey wmid (LargeKey whi whigest)) + return (NodeId nid, ToxCipherContext k) instance Read (NodeId Message) where readsPrec d s = map (\(w,xs) -> (NodeId w, xs)) $ decodeHex s -- cgit v1.2.3