diff --git a/cardano-crypto-class/CHANGELOG.md b/cardano-crypto-class/CHANGELOG.md index 86d957236..b812ce035 100644 --- a/cardano-crypto-class/CHANGELOG.md +++ b/cardano-crypto-class/CHANGELOG.md @@ -2,6 +2,8 @@ ## 2.5.0.0 +* Add `NFData` superclass constraints for the `VerKeyVRF`, `SignKeyVRF`, + and `CertVRF` associated types in `VRFAlgorithm`. * Remove constructors of `BLS12381SignContext` from export; use `minSigPoPDST` or `minVerKeyPoPDST` for the standard PoP ciphersuites. ## 2.4.0.0 diff --git a/cardano-crypto-class/src/Cardano/Crypto/VRF/Class.hs b/cardano-crypto-class/src/Cardano/Crypto/VRF/Class.hs index b091e91b7..449e673fc 100644 --- a/cardano-crypto-class/src/Cardano/Crypto/VRF/Class.hs +++ b/cardano-crypto-class/src/Cardano/Crypto/VRF/Class.hs @@ -80,9 +80,12 @@ class ( Typeable v , Show (VerKeyVRF v) , Eq (VerKeyVRF v) + , NFData (VerKeyVRF v) , Show (SignKeyVRF v) + , NFData (SignKeyVRF v) , Show (CertVRF v) , Eq (CertVRF v) + , NFData (CertVRF v) , NoThunks (CertVRF v) , NoThunks (VerKeyVRF v) , NoThunks (SignKeyVRF v) diff --git a/cardano-crypto-class/src/Cardano/Crypto/VRF/Mock.hs b/cardano-crypto-class/src/Cardano/Crypto/VRF/Mock.hs index 03eafd794..a5509a545 100644 --- a/cardano-crypto-class/src/Cardano/Crypto/VRF/Mock.hs +++ b/cardano-crypto-class/src/Cardano/Crypto/VRF/Mock.hs @@ -12,6 +12,7 @@ module Cardano.Crypto.VRF.Mock ( ) where +import Control.DeepSeq (NFData) import Data.Proxy (Proxy (..)) import Data.Word (Word64) import GHC.Generics (Generic) @@ -33,13 +34,13 @@ instance VRFAlgorithm MockVRF where -- newtype VerKeyVRF MockVRF = VerKeyMockVRF Word64 - deriving (Show, Eq, Ord, Generic, NoThunks) + deriving (Show, Eq, Ord, Generic, NoThunks, NFData) newtype SignKeyVRF MockVRF = SignKeyMockVRF Word64 - deriving (Show, Eq, Ord, Generic, NoThunks) + deriving (Show, Eq, Ord, Generic, NoThunks, NFData) newtype CertVRF MockVRF = CertMockVRF Word64 - deriving (Show, Eq, Ord, Generic, NoThunks) + deriving (Show, Eq, Ord, Generic, NoThunks, NFData) -- -- Metadata and basic key operations diff --git a/cardano-crypto-class/src/Cardano/Crypto/VRF/NeverUsed.hs b/cardano-crypto-class/src/Cardano/Crypto/VRF/NeverUsed.hs index daf288c94..f9fbcdaae 100644 --- a/cardano-crypto-class/src/Cardano/Crypto/VRF/NeverUsed.hs +++ b/cardano-crypto-class/src/Cardano/Crypto/VRF/NeverUsed.hs @@ -11,6 +11,7 @@ module Cardano.Crypto.VRF.NeverUsed ( ) where +import Control.DeepSeq (NFData (..)) import GHC.Generics (Generic) import NoThunks.Class (NoThunks) @@ -22,6 +23,15 @@ import Cardano.Crypto.VRF.Class -- trying to sign or verify something a runtime exception will be thrown. data NeverVRF +instance NFData (VerKeyVRF NeverVRF) where + rnf x = x `seq` () + +instance NFData (SignKeyVRF NeverVRF) where + rnf x = x `seq` () + +instance NFData (CertVRF NeverVRF) where + rnf x = x `seq` () + instance VRFAlgorithm NeverVRF where data VerKeyVRF NeverVRF = NeverUsedVerKeyVRF deriving (Show, Eq, Generic, NoThunks) diff --git a/cardano-crypto-praos/bench/Bench/Crypto/VRF.hs b/cardano-crypto-praos/bench/Bench/Crypto/VRF.hs index 96ee0e8bb..028fdabfc 100644 --- a/cardano-crypto-praos/bench/Bench/Crypto/VRF.hs +++ b/cardano-crypto-praos/bench/Bench/Crypto/VRF.hs @@ -11,8 +11,6 @@ module Bench.Crypto.VRF ( import Data.ByteString (ByteString) import Data.Proxy -import Control.DeepSeq - import Cardano.Crypto.VRF.Class import Cardano.Crypto.VRF.Praos hiding (Seed) import Cardano.Crypto.VRF.Simple @@ -34,9 +32,6 @@ benchVRF :: ( VRFAlgorithm v , ContextVRF v ~ () , Signable v ByteString - , NFData (CertVRF v) - , NFData (SignKeyVRF v) - , NFData (VerKeyVRF v) ) => proxy v -> [Char] -> diff --git a/cardano-crypto-praos/cardano-crypto-praos.cabal b/cardano-crypto-praos/cardano-crypto-praos.cabal index b413ad184..29a226c22 100644 --- a/cardano-crypto-praos/cardano-crypto-praos.cabal +++ b/cardano-crypto-praos/cardano-crypto-praos.cabal @@ -153,6 +153,5 @@ benchmark bench cardano-crypto-class:{cardano-crypto-class, benchlib}, cardano-crypto-praos, criterion, - deepseq, ghc-options: -threaded