{-# LANGUAGE ScopedTypeVariables #-}

module Cardano.Ledger.Binary.Crypto (
  -- * DSIGN
  encodeVerKeyDSIGN,
  decodeVerKeyDSIGN,
  encodeSignKeyDSIGN,
  decodeSignKeyDSIGN,
  encodeSigDSIGN,
  decodeSigDSIGN,
  encodeSignedDSIGN,
  decodeSignedDSIGN,

  -- * KES
  encodeVerKeyKES,
  decodeVerKeyKES,
  encodeSigKES,
  decodeSigKES,
  encodeSignedKES,
  decodeSignedKES,

  -- * VRF
  encodeVerKeyVRF,
  decodeVerKeyVRF,
  encodeSignKeyVRF,
  decodeSignKeyVRF,
  encodeCertVRF,
  decodeCertVRF,
)
where

import qualified Cardano.Crypto.DSIGN.Class as C
import qualified Cardano.Crypto.KES.Class as C
import qualified Cardano.Crypto.VRF.Class as C
import Cardano.Ledger.Binary.Decoding.Decoder (Decoder, fromPlainDecoder)
import Cardano.Ledger.Binary.Encoding.Encoder (Encoding, fromPlainEncoding)

--------------------------------------------------------------------------------
-- DSIGN
--------------------------------------------------------------------------------

encodeVerKeyDSIGN :: C.DSIGNAlgorithm v => C.VerKeyDSIGN v -> Encoding
encodeVerKeyDSIGN :: forall v. DSIGNAlgorithm v => VerKeyDSIGN v -> Encoding
encodeVerKeyDSIGN = Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v. DSIGNAlgorithm v => VerKeyDSIGN v -> Encoding
C.encodeVerKeyDSIGN
{-# INLINE encodeVerKeyDSIGN #-}

decodeVerKeyDSIGN :: C.DSIGNAlgorithm v => Decoder s (C.VerKeyDSIGN v)
decodeVerKeyDSIGN :: forall v s. DSIGNAlgorithm v => Decoder s (VerKeyDSIGN v)
decodeVerKeyDSIGN = forall s a. Decoder s a -> Decoder s a
fromPlainDecoder forall v s. DSIGNAlgorithm v => Decoder s (VerKeyDSIGN v)
C.decodeVerKeyDSIGN
{-# INLINE decodeVerKeyDSIGN #-}

encodeSignKeyDSIGN :: C.DSIGNAlgorithm v => C.SignKeyDSIGN v -> Encoding
encodeSignKeyDSIGN :: forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> Encoding
encodeSignKeyDSIGN = Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> Encoding
C.encodeSignKeyDSIGN
{-# INLINE encodeSignKeyDSIGN #-}

decodeSignKeyDSIGN :: C.DSIGNAlgorithm v => Decoder s (C.SignKeyDSIGN v)
decodeSignKeyDSIGN :: forall v s. DSIGNAlgorithm v => Decoder s (SignKeyDSIGN v)
decodeSignKeyDSIGN = forall s a. Decoder s a -> Decoder s a
fromPlainDecoder forall v s. DSIGNAlgorithm v => Decoder s (SignKeyDSIGN v)
C.decodeSignKeyDSIGN
{-# INLINE decodeSignKeyDSIGN #-}

encodeSigDSIGN :: C.DSIGNAlgorithm v => C.SigDSIGN v -> Encoding
encodeSigDSIGN :: forall v. DSIGNAlgorithm v => SigDSIGN v -> Encoding
encodeSigDSIGN = Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v. DSIGNAlgorithm v => SigDSIGN v -> Encoding
C.encodeSigDSIGN
{-# INLINE encodeSigDSIGN #-}

decodeSigDSIGN :: C.DSIGNAlgorithm v => Decoder s (C.SigDSIGN v)
decodeSigDSIGN :: forall v s. DSIGNAlgorithm v => Decoder s (SigDSIGN v)
decodeSigDSIGN = forall s a. Decoder s a -> Decoder s a
fromPlainDecoder forall v s. DSIGNAlgorithm v => Decoder s (SigDSIGN v)
C.decodeSigDSIGN
{-# INLINE decodeSigDSIGN #-}

encodeSignedDSIGN :: C.DSIGNAlgorithm v => C.SignedDSIGN v a -> Encoding
encodeSignedDSIGN :: forall v a. DSIGNAlgorithm v => SignedDSIGN v a -> Encoding
encodeSignedDSIGN = Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v a. DSIGNAlgorithm v => SignedDSIGN v a -> Encoding
C.encodeSignedDSIGN
{-# INLINE encodeSignedDSIGN #-}

decodeSignedDSIGN :: C.DSIGNAlgorithm v => Decoder s (C.SignedDSIGN v a)
decodeSignedDSIGN :: forall v s a. DSIGNAlgorithm v => Decoder s (SignedDSIGN v a)
decodeSignedDSIGN = forall s a. Decoder s a -> Decoder s a
fromPlainDecoder forall v s a. DSIGNAlgorithm v => Decoder s (SignedDSIGN v a)
C.decodeSignedDSIGN
{-# INLINE decodeSignedDSIGN #-}

--------------------------------------------------------------------------------
-- KES
--------------------------------------------------------------------------------

encodeVerKeyKES :: C.KESAlgorithm v => C.VerKeyKES v -> Encoding
encodeVerKeyKES :: forall v. KESAlgorithm v => VerKeyKES v -> Encoding
encodeVerKeyKES = Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v. KESAlgorithm v => VerKeyKES v -> Encoding
C.encodeVerKeyKES
{-# INLINE encodeVerKeyKES #-}

decodeVerKeyKES :: C.KESAlgorithm v => Decoder s (C.VerKeyKES v)
decodeVerKeyKES :: forall v s. KESAlgorithm v => Decoder s (VerKeyKES v)
decodeVerKeyKES = forall s a. Decoder s a -> Decoder s a
fromPlainDecoder forall v s. KESAlgorithm v => Decoder s (VerKeyKES v)
C.decodeVerKeyKES
{-# INLINE decodeVerKeyKES #-}

encodeSigKES :: C.KESAlgorithm v => C.SigKES v -> Encoding
encodeSigKES :: forall v. KESAlgorithm v => SigKES v -> Encoding
encodeSigKES = Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v. KESAlgorithm v => SigKES v -> Encoding
C.encodeSigKES
{-# INLINE encodeSigKES #-}

decodeSigKES :: C.KESAlgorithm v => Decoder s (C.SigKES v)
decodeSigKES :: forall v s. KESAlgorithm v => Decoder s (SigKES v)
decodeSigKES = forall s a. Decoder s a -> Decoder s a
fromPlainDecoder forall v s. KESAlgorithm v => Decoder s (SigKES v)
C.decodeSigKES
{-# INLINE decodeSigKES #-}

encodeSignedKES :: C.KESAlgorithm v => C.SignedKES v a -> Encoding
encodeSignedKES :: forall v a. KESAlgorithm v => SignedKES v a -> Encoding
encodeSignedKES = Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v a. KESAlgorithm v => SignedKES v a -> Encoding
C.encodeSignedKES
{-# INLINE encodeSignedKES #-}

decodeSignedKES :: C.KESAlgorithm v => Decoder s (C.SignedKES v a)
decodeSignedKES :: forall v s a. KESAlgorithm v => Decoder s (SignedKES v a)
decodeSignedKES = forall s a. Decoder s a -> Decoder s a
fromPlainDecoder forall v s a. KESAlgorithm v => Decoder s (SignedKES v a)
C.decodeSignedKES
{-# INLINE decodeSignedKES #-}

--------------------------------------------------------------------------------
-- VRF
--------------------------------------------------------------------------------

encodeVerKeyVRF :: C.VRFAlgorithm v => C.VerKeyVRF v -> Encoding
encodeVerKeyVRF :: forall v. VRFAlgorithm v => VerKeyVRF v -> Encoding
encodeVerKeyVRF = Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v. VRFAlgorithm v => VerKeyVRF v -> Encoding
C.encodeVerKeyVRF
{-# INLINE encodeVerKeyVRF #-}

decodeVerKeyVRF :: C.VRFAlgorithm v => Decoder s (C.VerKeyVRF v)
decodeVerKeyVRF :: forall v s. VRFAlgorithm v => Decoder s (VerKeyVRF v)
decodeVerKeyVRF = forall s a. Decoder s a -> Decoder s a
fromPlainDecoder forall v s. VRFAlgorithm v => Decoder s (VerKeyVRF v)
C.decodeVerKeyVRF
{-# INLINE decodeVerKeyVRF #-}

encodeSignKeyVRF :: C.VRFAlgorithm v => C.SignKeyVRF v -> Encoding
encodeSignKeyVRF :: forall v. VRFAlgorithm v => SignKeyVRF v -> Encoding
encodeSignKeyVRF = Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v. VRFAlgorithm v => SignKeyVRF v -> Encoding
C.encodeSignKeyVRF
{-# INLINE encodeSignKeyVRF #-}

decodeSignKeyVRF :: C.VRFAlgorithm v => Decoder s (C.SignKeyVRF v)
decodeSignKeyVRF :: forall v s. VRFAlgorithm v => Decoder s (SignKeyVRF v)
decodeSignKeyVRF = forall s a. Decoder s a -> Decoder s a
fromPlainDecoder forall v s. VRFAlgorithm v => Decoder s (SignKeyVRF v)
C.decodeSignKeyVRF
{-# INLINE decodeSignKeyVRF #-}

encodeCertVRF :: C.VRFAlgorithm v => C.CertVRF v -> Encoding
encodeCertVRF :: forall v. VRFAlgorithm v => CertVRF v -> Encoding
encodeCertVRF = Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v. VRFAlgorithm v => CertVRF v -> Encoding
C.encodeCertVRF
{-# INLINE encodeCertVRF #-}

decodeCertVRF :: C.VRFAlgorithm v => Decoder s (C.CertVRF v)
decodeCertVRF :: forall v s. VRFAlgorithm v => Decoder s (CertVRF v)
decodeCertVRF = forall s a. Decoder s a -> Decoder s a
fromPlainDecoder forall v s. VRFAlgorithm v => Decoder s (CertVRF v)
C.decodeCertVRF
{-# INLINE decodeCertVRF #-}