Safe Haskell  None 

Language  Haskell2010 
Seeds for key generation.
Synopsis
 data Seed
 mkSeedFromBytes :: ByteString > Seed
 getSeedBytes :: Seed > ByteString
 readSeedFromSystemEntropy :: Word > IO Seed
 splitSeed :: Word > Seed > Maybe ( Seed , Seed )
 expandSeed :: HashAlgorithm h => proxy h > Seed > ( Seed , Seed )
 getBytesFromSeed :: Word > Seed > Maybe ( ByteString , Seed )
 getBytesFromSeedT :: Word > Seed > ( ByteString , Seed )
 runMonadRandomWithSeed :: Seed > ( forall m. MonadRandom m => m a) > a
 newtype SeedBytesExhausted = SeedBytesExhausted { }
Documentation
A seed contains a finite number of bytes, and is used for seeding cryptographic algorithms including key generation.
This is not itself a PRNG, but can be used to seed a PRNG.
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.
getBytesFromSeedT :: Word > Seed > ( ByteString , Seed ) Source #
A flavor of
getBytesFromSeed
that throws
SeedBytesExhausted
instead of
returning
Nothing
.
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.
newtype SeedBytesExhausted Source #
Instances
Show SeedBytesExhausted Source #  
Defined in Cardano.Crypto.Seed 

Exception SeedBytesExhausted Source #  
Defined in Cardano.Crypto.Seed 