diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2019-06-04 21:55:21 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2019-06-04 21:55:21 +0200 |
commit | c64e059fca7377d67baecb2724e3be2e1cc9ff0d (patch) | |
tree | 6929bbdda9410902675f7f93251c12502b6eee2d /src/Channel.hs | |
parent | 394d35d586fba3db55217e1e9f1e88e8bc8a0719 (diff) |
Ephemeral storage of channels
Diffstat (limited to 'src/Channel.hs')
-rw-r--r-- | src/Channel.hs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Channel.hs b/src/Channel.hs index ee10e89..9be4405 100644 --- a/src/Channel.hs +++ b/src/Channel.hs @@ -89,9 +89,8 @@ instance Storable ChannelAcceptData where <*> loadRef "key" -createChannelRequest :: Stored Identity -> Stored Identity -> IO (Stored ChannelRequest) -createChannelRequest self peer = do - let st = storedStorage self +createChannelRequest :: Storage -> Stored Identity -> Stored Identity -> IO (Stored ChannelRequest) +createChannelRequest st self peer = do (_, xpublic) <- generateKeys st Just skey <- loadKey $ idKeyMessage $ fromStored $ signedData $ fromStored self wrappedStore st =<< sign skey =<< wrappedStore st ChannelRequest { crPeers = sort [self, peer], crKey = xpublic } @@ -101,7 +100,7 @@ acceptChannelRequest self peer req = do guard $ (crPeers $ fromStored $ signedData $ fromStored req) == sort [self, peer] guard $ (idKeyMessage $ fromStored $ signedData $ fromStored peer) `elem` (map (sigKey . fromStored) $ signedSignature $ fromStored req) - let st = storedStorage self + let st = storedStorage req KeySizeFixed ksize = cipherKeySize (undefined :: AES128) liftIO $ do (xsecret, xpublic) <- generateKeys st @@ -116,7 +115,7 @@ acceptChannelRequest self peer req = do acceptedChannel :: Stored Identity -> Stored Identity -> Stored ChannelAccept -> ExceptT [String] IO (Stored Channel) acceptedChannel self peer acc = do - let st = storedStorage self + let st = storedStorage acc req = caRequest $ fromStored $ signedData $ fromStored acc KeySizeFixed ksize = cipherKeySize (undefined :: AES128) |