-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Crypto primitives from libsodium
--   
--   VRF (and KES, tba) primitives from libsodium.
@package cardano-crypto-praos
@version 2.0.0


-- | Verifiable Random Function (VRF) implemented as FFI wrappers around
--   the implementation in
--   <a>https://github.com/input-output-hk/libsodium</a>
module Cardano.Crypto.VRF.Praos
data PraosVRF
crypto_vrf_proofbytes :: CSize
crypto_vrf_publickeybytes :: CSize
crypto_vrf_secretkeybytes :: CSize
crypto_vrf_seedbytes :: CSize
crypto_vrf_outputbytes :: CSize
certSizeVRF :: Int
signKeySizeVRF :: Int
verKeySizeVRF :: Int
vrfKeySizeVRF :: Int

-- | A random seed, used to derive a key pair.
data Seed

-- | Generate a random seed. Uses <a>randombytes_buf</a> to create random
--   data.
--   
--   This function provides an alternative way of generating seeds
--   specifically for the <a>PraosVRF</a> algorithm. Unlike the
--   <a>genKeyPairVRF</a> method, which uses a <a>ByteString</a>-based
--   <a>Seed</a>, this seed generation method bypasses the GHC heap,
--   keeping the seed in C-allocated memory instead.
--   
--   This provides two advantages: 1. It avoids the overhead of unnecessary
--   GHC-side heap allocations. 2. It avoids leaking the seed via the GHC
--   heap; the <a>Seed</a> type itself takes care of zeroing out its memory
--   upon finalization.
genSeed :: IO Seed

-- | Derive a key pair (Sign + Verify) from a seed.
keypairFromSeed :: Seed -> (VerKey, SignKey)

-- | Convert an opaque <a>Seed</a> into a <a>ByteString</a> that we can
--   inspect. Note that this will copy the seed into RTS-managed memory;
--   this is not currently a problem, but if at any point we decide that we
--   want to make sure the seed is properly mlocked, then this function
--   will leak such a secured seed into non-locked (swappable) memory.
unsafeRawSeed :: Seed -> IO ByteString

-- | Convert a proof verification output hash into a <a>ByteString</a> that
--   we can inspect.
outputBytes :: Output -> ByteString

-- | Convert a proof into a <a>ByteString</a> that we can inspect.
proofBytes :: Proof -> ByteString

-- | Convert a signing key into a <a>ByteString</a> that we can inspect.
skBytes :: SignKey -> ByteString

-- | Convert a verification key into a <a>ByteString</a> that we can
--   inspect.
vkBytes :: VerKey -> ByteString

-- | Derive a Verification Key from a Signing Key.
skToVerKey :: SignKey -> VerKey

-- | Get the seed used to generate a given Signing Key
skToSeed :: SignKey -> Seed

-- | Construct a proof from a Signing Key and a message. Returns
--   <a>Just</a> the proof on success, <a>Nothing</a> if the signing key
--   could not be decoded.
prove :: SignKey -> ByteString -> Maybe Proof

-- | Verify a VRF proof and validate the Verification Key. Returns
--   <a>Just</a> a hash of the verification result on success,
--   <a>Nothing</a> if the verification did not succeed.
--   
--   For a given verification key and message, there are many possible
--   proofs but only one possible output hash.
verify :: VerKey -> Proof -> ByteString -> Maybe Output
data family SignKeyVRF v
data family VerKeyVRF v
data family CertVRF v
instance NoThunks.Class.NoThunks Cardano.Crypto.VRF.Praos.Seed
instance NoThunks.Class.NoThunks Cardano.Crypto.VRF.Praos.SignKey
instance GHC.Generics.Generic Cardano.Crypto.VRF.Praos.SignKey
instance NoThunks.Class.NoThunks Cardano.Crypto.VRF.Praos.VerKey
instance GHC.Generics.Generic Cardano.Crypto.VRF.Praos.VerKey
instance NoThunks.Class.NoThunks Cardano.Crypto.VRF.Praos.Proof
instance GHC.Generics.Generic Cardano.Crypto.VRF.Praos.Proof
instance NoThunks.Class.NoThunks Cardano.Crypto.VRF.Praos.Output
instance GHC.Generics.Generic Cardano.Crypto.VRF.Praos.Output
instance Control.DeepSeq.NFData (Cardano.Crypto.VRF.Class.CertVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance NoThunks.Class.NoThunks (Cardano.Crypto.VRF.Class.CertVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance Cardano.Binary.FromCBOR.FromCBOR (Cardano.Crypto.VRF.Class.CertVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance Cardano.Binary.ToCBOR.ToCBOR (Cardano.Crypto.VRF.Class.CertVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance GHC.Generics.Generic (Cardano.Crypto.VRF.Class.CertVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance GHC.Classes.Eq (Cardano.Crypto.VRF.Class.CertVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance GHC.Show.Show (Cardano.Crypto.VRF.Class.CertVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance Control.DeepSeq.NFData (Cardano.Crypto.VRF.Class.SignKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance NoThunks.Class.NoThunks (Cardano.Crypto.VRF.Class.SignKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance Cardano.Binary.FromCBOR.FromCBOR (Cardano.Crypto.VRF.Class.SignKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance Cardano.Binary.ToCBOR.ToCBOR (Cardano.Crypto.VRF.Class.SignKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance GHC.Generics.Generic (Cardano.Crypto.VRF.Class.SignKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance GHC.Classes.Eq (Cardano.Crypto.VRF.Class.SignKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance GHC.Show.Show (Cardano.Crypto.VRF.Class.SignKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance Control.DeepSeq.NFData (Cardano.Crypto.VRF.Class.VerKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance NoThunks.Class.NoThunks (Cardano.Crypto.VRF.Class.VerKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance Cardano.Binary.FromCBOR.FromCBOR (Cardano.Crypto.VRF.Class.VerKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance Cardano.Binary.ToCBOR.ToCBOR (Cardano.Crypto.VRF.Class.VerKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance GHC.Generics.Generic (Cardano.Crypto.VRF.Class.VerKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance GHC.Classes.Eq (Cardano.Crypto.VRF.Class.VerKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance GHC.Show.Show (Cardano.Crypto.VRF.Class.VerKeyVRF Cardano.Crypto.VRF.Praos.PraosVRF)
instance Cardano.Crypto.VRF.Class.VRFAlgorithm Cardano.Crypto.VRF.Praos.PraosVRF
instance Control.DeepSeq.NFData Cardano.Crypto.VRF.Praos.Proof
instance GHC.Show.Show Cardano.Crypto.VRF.Praos.Proof
instance GHC.Classes.Eq Cardano.Crypto.VRF.Praos.Proof
instance Cardano.Binary.ToCBOR.ToCBOR Cardano.Crypto.VRF.Praos.Proof
instance Cardano.Binary.FromCBOR.FromCBOR Cardano.Crypto.VRF.Praos.Proof
instance Control.DeepSeq.NFData Cardano.Crypto.VRF.Praos.VerKey
instance GHC.Show.Show Cardano.Crypto.VRF.Praos.VerKey
instance GHC.Classes.Eq Cardano.Crypto.VRF.Praos.VerKey
instance Cardano.Binary.ToCBOR.ToCBOR Cardano.Crypto.VRF.Praos.VerKey
instance Cardano.Binary.FromCBOR.FromCBOR Cardano.Crypto.VRF.Praos.VerKey
instance Control.DeepSeq.NFData Cardano.Crypto.VRF.Praos.SignKey
instance GHC.Show.Show Cardano.Crypto.VRF.Praos.SignKey
instance GHC.Classes.Eq Cardano.Crypto.VRF.Praos.SignKey
instance Cardano.Binary.ToCBOR.ToCBOR Cardano.Crypto.VRF.Praos.SignKey
instance Cardano.Binary.FromCBOR.FromCBOR Cardano.Crypto.VRF.Praos.SignKey
