Skip to content

Commit

Permalink
Reinstate CBOR encoding/decoding for unsound pure KES
Browse files Browse the repository at this point in the history
  • Loading branch information
tdammers committed Apr 17, 2024
1 parent e45b28a commit 0126bb2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cardano-crypto-class/src/Cardano/Crypto/KES/Class.hs
Expand Up @@ -61,6 +61,8 @@ module Cardano.Crypto.KES.Class

, UnsoundPureKESAlgorithm (..)
, unsoundPureSignedKES
, encodeUnsoundPureSignKeyKES
, decodeUnsoundPureSignKeyKES

-- * Utility functions
-- These are used between multiple KES implementations. User code will
Expand Down Expand Up @@ -407,6 +409,9 @@ instance ( TypeError ('Text "Ord not supported for verification keys, use the ha
encodeVerKeyKES :: KESAlgorithm v => VerKeyKES v -> Encoding
encodeVerKeyKES = encodeBytes . rawSerialiseVerKeyKES

encodeUnsoundPureSignKeyKES :: UnsoundPureKESAlgorithm v => UnsoundPureSignKeyKES v -> Encoding
encodeUnsoundPureSignKeyKES = encodeBytes . rawSerialiseUnsoundPureSignKeyKES

encodeSigKES :: KESAlgorithm v => SigKES v -> Encoding
encodeSigKES = encodeBytes . rawSerialiseSigKES

Expand All @@ -424,6 +429,14 @@ decodeVerKeyKES = do
Nothing -> failSizeCheck "decodeVerKeyKES" "key" bs (sizeVerKeyKES (Proxy :: Proxy v))
{-# INLINE decodeVerKeyKES #-}

decodeUnsoundPureSignKeyKES :: forall v s. UnsoundPureKESAlgorithm v => Decoder s (UnsoundPureSignKeyKES v)
decodeUnsoundPureSignKeyKES = do
bs <- decodeBytes
case rawDeserialiseUnsoundPureSignKeyKES bs of
Just vk -> return vk
Nothing -> failSizeCheck "decodeUnsoundPureSignKeyKES" "key" bs (sizeSignKeyKES (Proxy :: Proxy v))
{-# INLINE decodeUnsoundPureSignKeyKES #-}

decodeSigKES :: forall v s. KESAlgorithm v => Decoder s (SigKES v)
decodeSigKES = do
bs <- decodeBytes
Expand Down

0 comments on commit 0126bb2

Please sign in to comment.