diff options
Diffstat (limited to 'src/State.hs')
-rw-r--r-- | src/State.hs | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/State.hs b/src/State.hs index 8e9e320..55c55e1 100644 --- a/src/State.hs +++ b/src/State.hs @@ -90,32 +90,19 @@ loadLocalStateHead st = loadHeads st >>= \case hFlush stdout devName <- T.getLine - (owner, secret) <- if - | T.null name -> return (Nothing, Nothing) - | otherwise -> do - (secret, public) <- generateKeys st - (_secretMsg, publicMsg) <- generateKeys st - - return . (, Just secret) . Just =<< wrappedStore st =<< sign secret =<< - wrappedStore st (emptyIdentityData public) - { iddName = Just name, iddKeyMessage = Just publicMsg } - - (devSecret, devPublic) <- generateKeys st - (_devSecretMsg, devPublicMsg) <- generateKeys st - - identity <- wrappedStore st =<< maybe return signAdd secret =<< sign devSecret =<< wrappedStore st (emptyIdentityData devPublic) - { iddName = if T.null devName then Nothing else Just devName - , iddOwner = owner - , iddKeyMessage = Just devPublicMsg - } + owner <- if + | T.null name -> return Nothing + | otherwise -> Just <$> createIdentity st (Just name) Nothing + + identity <- createIdentity st (if T.null devName then Nothing else Just devName) owner shared <- wrappedStore st $ SharedState { ssPrev = [] , ssType = Just $ sharedTypeID @(Signed IdentityData) Proxy - , ssValue = [storedRef $ fromMaybe identity owner] + , ssValue = [storedRef $ idData $ fromMaybe identity owner] } storeHead st $ LocalState - { lsIdentity = identity + { lsIdentity = idData identity , lsShared = [shared] } |