@@ -26,8 +26,9 @@ import Cardano.Crypto.DSIGN.Class (
2626 SignedDSIGN ,
2727 VerKeyDSIGN ,
2828 )
29- import Cardano.Crypto.Hash.Class (Hash , HashAlgorithm , hashFromBytesShort )
29+ import Cardano.Crypto.Hash.Class (Hash , HashAlgorithm , PackedBytes , hashFromPackedBytes )
3030import Cardano.Crypto.KES.Class (KESAlgorithm , SigKES , VerKeyKES )
31+ import Cardano.Crypto.PackedBytes (packByteString )
3132import Cardano.Crypto.VRF.Class (
3233 CertVRF ,
3334 CertifiedVRF (.. ),
@@ -56,6 +57,7 @@ import Codec.CBOR.Term (Term (..))
5657import Codec.Serialise as Serialise (Serialise (decode ))
5758import qualified Data.ByteString as BS
5859import qualified Data.ByteString.Lazy as BSL
60+ import GHC.TypeLits (KnownNat )
5961#if MIN_VERSION_bytestring(0,11,1)
6062import Data.ByteString.Short (ShortByteString (SBS ))
6163#else
@@ -472,10 +474,12 @@ instance (DSIGNAlgorithm v, Typeable a) => DecCBOR (SignedDSIGN v a) where
472474-- Hash
473475--------------------------------------------------------------------------------
474476
477+ instance KnownNat n => DecCBOR (PackedBytes n ) where
478+ decCBOR = decCBOR >>= packByteString
479+ {-# INLINE decCBOR #-}
480+
475481instance (HashAlgorithm h , Typeable a ) => DecCBOR (Hash h a ) where
476- decCBOR = do
477- sbs <- decCBOR @ ShortByteString
478- maybe (fail " Invalid hash size" ) pure $ hashFromBytesShort sbs
482+ decCBOR = hashFromPackedBytes <$> decCBOR
479483 {-# INLINE decCBOR #-}
480484
481485--------------------------------------------------------------------------------
0 commit comments