summaryrefslogtreecommitdiff
path: root/src/PubKey.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-09-19 20:49:58 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-10-19 21:37:01 +0200
commit61808c8cd7b30ceaf9915e72d734c4d095ff67d6 (patch)
tree7897848d5e61747c5ccf4136bc77c9d9490d1c52 /src/PubKey.hs
parent967cb4587c1af9fb53bfd1a30d007877d16e03fa (diff)
Identity extension data
Diffstat (limited to 'src/PubKey.hs')
-rw-r--r--src/PubKey.hs9
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)