Skip to content

Commit

Permalink
All compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Oct 31, 2024
1 parent fc6a563 commit cd58e1d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ module Test.Cardano.Ledger.Binary.Arbitrary (
where

import Cardano.Crypto.DSIGN.Class hiding (Signable)
import qualified Cardano.Crypto.KES.Class as KES
import Cardano.Crypto.Util
import Cardano.Crypto.VRF.Class
import Cardano.Crypto.KES.Class
import Cardano.Ledger.Binary.Version
import Cardano.Slotting.Block (BlockNo (..))
import Cardano.Slotting.Slot (EpochSize (..), WithOrigin (..))
Expand All @@ -31,7 +31,9 @@ import Codec.CBOR.ByteArray.Sliced (SlicedByteArray (..))
import Codec.CBOR.Term
import qualified Data.ByteString as BS (ByteString, pack, unpack)
import qualified Data.ByteString.Lazy as BSL (ByteString, fromChunks, fromStrict, toChunks)
import GHC.TypeLits (natVal)
import Numeric.Half
import Test.Crypto.Util (arbitrarySeedOfSize)
#if MIN_VERSION_bytestring(0,11,1)
import qualified Data.ByteString.Short as SBS
#else
Expand Down Expand Up @@ -239,27 +241,21 @@ genByteArray n = do
case sbs of
SBS.SBS ba -> pure (Prim.ByteArray ba)

instance KESAlgorithm v => Arbitrary (VerKeyKES v) where
instance KES.KESAlgorithm v => Arbitrary (KES.VerKeyKES v) where
arbitrary = do
bs <- genByteString (fromInteger (natVal (Proxy @(SizeVerKeyKES v))))
case rawDeserialiseVerKeyKES bs of
bs <- genByteString (fromInteger (natVal (Proxy @(KES.SizeVerKeyKES v))))
case KES.rawDeserialiseVerKeyKES bs of
Nothing -> error "Impossible: the size of VerKeyKES is specified statically"
Just vk -> pure vk


instance KESAlgorithm v => Arbitrary (SigKES v) where
instance KES.KESAlgorithm v => Arbitrary (KES.SigKES v) where
arbitrary = do
bs <- genByteString (fromInteger (natVal (Proxy @(SizeSigKES v))))
case rawDeserialiseSigKES bs of
bs <- genByteString (fromInteger (natVal (Proxy @(KES.SizeSigKES v))))
case KES.rawDeserialiseSigKES bs of
Nothing -> error "Impossible: the size of VerKeyKES is specified statically"
Just vk -> pure vk

-- instance
-- (KESAlgorithm v, ContextKES v ~ (), Signable v ~ SignableRepresentation) =>
-- Arbitrary (SigKES v)
-- where
-- arbitrary = do
-- a <- arbitrary :: Gen Message
-- sk <- arbitrary
-- let sig = signKES () 0 a sk
-- return sig
instance KES.UnsoundPureKESAlgorithm v => Arbitrary (KES.UnsoundPureSignKeyKES v) where
arbitrary = KES.unsoundPureGenKeyKES <$> arbitrarySeedOfSize seedSize
where
seedSize = KES.seedSizeKES (Proxy :: Proxy v)
3 changes: 0 additions & 3 deletions libs/cardano-ledger-core/src/Cardano/Ledger/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,3 @@ instance HS.HashAlgorithm h => Default (Hash h b) where
UnsafeHash $
Short.pack $
replicate (fromIntegral (Hash.sizeHash (Proxy :: Proxy h))) 0

instance Default Bool where
def = False
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ module Test.Cardano.Protocol.Crypto.KES (

import qualified Cardano.Crypto.KES.Class as KES
import Cardano.Ledger.Crypto
import Cardano.Ledger.Keys (UnsoundPureSignKeyKES, VerKeyKES)
import Cardano.Ledger.Keys (VerKeyKES)

data KESKeyPair c = KESKeyPair
{ kesSignKey :: !(UnsoundPureSignKeyKES c)
{ kesSignKey :: !(KES.UnsoundPureSignKeyKES (KES c))
, kesVerKey :: !(VerKeyKES c)
}

Expand Down

0 comments on commit cd58e1d

Please sign in to comment.