cardano-crypto-class-2.0.0.0.1: Type classes abstracting over cryptography primitives for Cardano
Safe Haskell None
Language Haskell2010

Cardano.Crypto.Seed

Description

Seeds for key generation.

Synopsis

Documentation

Constructing seeds

mkSeedFromBytes :: ByteString -> Seed Source #

Construct a Seed deterministically from a number of bytes.

getSeedBytes :: Seed -> ByteString Source #

Extract the full bytes from a seed. Note that this function does not guarantee that the result is sufficiently long for the desired seed size!

readSeedFromSystemEntropy :: Word -> IO Seed Source #

Obtain a Seed by reading n bytes of entropy from the operating system.

splitSeed :: Word -> Seed -> Maybe ( Seed , Seed ) Source #

Split a seed into two smaller seeds, the first of which is the given number of bytes large, and the second is the remaining. This will fail if not enough bytes are available. This can be chained multiple times provided the seed is big enough to cover each use.

expandSeed :: HashAlgorithm h => proxy h -> Seed -> ( Seed , Seed ) Source #

Expand a seed into a pair of seeds using a cryptographic hash function (in the role of a crypto PRNG). The whole input seed is consumed. The output seeds are the size of the hash output.

Using seeds

getBytesFromSeed :: Word -> Seed -> Maybe ( ByteString , Seed ) Source #

Get a number of bytes from the seed. This will fail if not enough bytes are available. This can be chained multiple times provided the seed is big enough to cover each use.

runMonadRandomWithSeed :: Seed -> ( forall m. MonadRandom m => m a) -> a Source #

Run an action in MonadRandom deterministically using a seed as a finite source of randomness. Note that this is not a PRNG, so like with getBytesFromSeed it will fail if more bytes are requested than are available.

So this is only really suitable for key generation where there is a known upper bound on the amount of entropy that will be requested.