diff options
Diffstat (limited to 'src/PubKey.hs')
-rw-r--r-- | src/PubKey.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/PubKey.hs b/src/PubKey.hs index f69d739..5f235eb 100644 --- a/src/PubKey.hs +++ b/src/PubKey.hs @@ -3,6 +3,8 @@ module PubKey ( KeyPair(generateKeys), loadKey, loadKeyMb, Signature(sigKey), Signed, signedData, signedSignature, sign, signAdd, isSignedBy, + fromSigned, + unsafeMapSigned, PublicKexKey, SecretKexKey, dhSecret, @@ -110,6 +112,13 @@ signAdd (SecretKey secret spublic) (Signed val sigs) = do isSignedBy :: Signed a -> Stored PublicKey -> Bool isSignedBy sig key = key `elem` map (sigKey . fromStored) (signedSignature sig) +fromSigned :: Stored (Signed a) -> a +fromSigned = fromStored . signedData . fromStored + +-- |Passed function needs to preserve the object representation to be safe +unsafeMapSigned :: (a -> b) -> Signed a -> Signed b +unsafeMapSigned f signed = signed { signedData_ = unsafeMapStored f (signedData_ signed) } + data PublicKexKey = PublicKexKey CX.PublicKey deriving (Show) |