diff options
Diffstat (limited to 'src/PubKey.hs')
-rw-r--r-- | src/PubKey.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/PubKey.hs b/src/PubKey.hs index d7134c8..8f39bf1 100644 --- a/src/PubKey.hs +++ b/src/PubKey.hs @@ -48,7 +48,11 @@ signedSignature = signedSignature_ instance KeyPair SecretKey PublicKey where keyGetPublic (SecretKey _ pub) = pub keyGetData (SecretKey sec _) = convert sec - keyFromData kdata spub = SecretKey <$> maybeCryptoError (ED.secretKey kdata) <*> pure spub + keyFromData kdata spub = do + skey <- maybeCryptoError $ ED.secretKey kdata + let PublicKey pkey = fromStored spub + guard $ ED.toPublic skey == pkey + return $ SecretKey skey spub generateKeys st = do secret <- ED.generateSecretKey public <- wrappedStore st $ PublicKey $ ED.toPublic secret @@ -115,7 +119,11 @@ data SecretKexKey = SecretKexKey CX.SecretKey (Stored PublicKexKey) instance KeyPair SecretKexKey PublicKexKey where keyGetPublic (SecretKexKey _ pub) = pub keyGetData (SecretKexKey sec _) = convert sec - keyFromData kdata spub = SecretKexKey <$> maybeCryptoError (CX.secretKey kdata) <*> pure spub + keyFromData kdata spub = do + skey <- maybeCryptoError $ CX.secretKey kdata + let PublicKexKey pkey = fromStored spub + guard $ CX.toPublic skey == pkey + return $ SecretKexKey skey spub generateKeys st = do secret <- CX.generateSecretKey public <- wrappedStore st $ PublicKexKey $ CX.toPublic secret |