-- Instances.hs: OpenPGP (RFC4880) additional types for transferable keys -- Copyright © 2012-2014 Clint Adams -- This software is released under the terms of the Expat license. -- (See the LICENSE file). module Data.Conduit.OpenPGP.Keyring.Instances ( ) where import Data.IxSet (Proxy(..), Indexable(..), ixSet, ixGen, ixFun) import Codec.Encryption.OpenPGP.Fingerprint (eightOctetKeyID, fingerprint) import Codec.Encryption.OpenPGP.Types import Control.Lens ((^.), (^..), _1, folded) import Data.Data.Lens (biplate) instance Indexable TK where empty = ixSet [ ixGen (Proxy :: Proxy PKPayload) , ixFun getEOKIs , ixFun getTOFs , ixFun getUIDs ] getEOKIs :: TK -> [EightOctetKeyId] getEOKIs tk = map eightOctetKeyID (tk ^.. biplate :: [PKPayload]) getTOFs :: TK -> [TwentyOctetFingerprint] getTOFs tk = map fingerprint (tk ^.. biplate :: [PKPayload]) getUIDs :: TK -> [String] getUIDs tk = (tk^.tkUIDs)^..folded._1