cardano-crypto-praos-2.1.0.0: Crypto primitives from libsodium
Safe Haskell None
Language Haskell2010

Cardano.Crypto.VRF.Praos

Description

Verifiable Random Function (VRF) implemented as FFI wrappers around the implementation in https://github.com/input-output-hk/libsodium

Synopsis

VRFAlgorithm API

data PraosVRF Source #

Instances

Instances details
VRFAlgorithm PraosVRF Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Eq ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Eq ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Eq ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Show ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Show ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Show ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Generic ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Generic ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Generic ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

ToCBOR ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

ToCBOR ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

ToCBOR ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

FromCBOR ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

FromCBOR ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

FromCBOR ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NFData ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NFData ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NFData ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NoThunks ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NoThunks ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NoThunks ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Signable PraosVRF Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type ContextVRF PraosVRF Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

newtype CertVRF PraosVRF Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

newtype SignKeyVRF PraosVRF Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

newtype VerKeyVRF PraosVRF Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep ( CertVRF PraosVRF ) = D1 (' MetaData "CertVRF" "Cardano.Crypto.VRF.Praos" "cardano-crypto-praos-2.1.0.0-8RyEQjtDErEBX6y5WsfiKH" ' True ) ( C1 (' MetaCons "CertPraosVRF" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Proof )))
type Rep ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep ( SignKeyVRF PraosVRF ) = D1 (' MetaData "SignKeyVRF" "Cardano.Crypto.VRF.Praos" "cardano-crypto-praos-2.1.0.0-8RyEQjtDErEBX6y5WsfiKH" ' True ) ( C1 (' MetaCons "SignKeyPraosVRF" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 SignKey )))
type Rep ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep ( VerKeyVRF PraosVRF ) = D1 (' MetaData "VerKeyVRF" "Cardano.Crypto.VRF.Praos" "cardano-crypto-praos-2.1.0.0-8RyEQjtDErEBX6y5WsfiKH" ' True ) ( C1 (' MetaCons "VerKeyPraosVRF" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 VerKey )))

Key sizes

Seed and key generation

genSeed :: IO Seed Source #

Generate a random seed. Uses randombytes_buf to create random data.

This function provides an alternative way of generating seeds specifically for the PraosVRF algorithm. Unlike the genKeyPairVRF method, which uses a ByteString -based Seed , 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 Seed type itself takes care of zeroing out its memory upon finalization.

keypairFromSeed :: Seed -> ( VerKey , SignKey ) Source #

Derive a key pair (Sign + Verify) from a seed.

Conversions

outputBytes :: Output -> ByteString Source #

Convert a proof verification output hash into a ByteString that we can inspect.

proofBytes :: Proof -> ByteString Source #

Convert a proof into a ByteString that we can inspect.

skBytes :: SignKey -> ByteString Source #

Convert a signing key into a ByteString that we can inspect.

vkBytes :: VerKey -> ByteString Source #

Convert a verification key into a ByteString that we can inspect.

skToVerKey :: SignKey -> VerKey Source #

Derive a Verification Key from a Signing Key.

skToSeed :: SignKey -> Seed Source #

Get the seed used to generate a given Signing Key

Core VRF operations

prove :: SignKey -> ByteString -> Maybe Proof Source #

Construct a proof from a Signing Key and a message. Returns Just the proof on success, Nothing if the signing key could not be decoded.

verify :: VerKey -> Proof -> ByteString -> Maybe Output Source #

Verify a VRF proof and validate the Verification Key. Returns Just a hash of the verification result on success, Nothing if the verification did not succeed.

For a given verification key and message, there are many possible proofs but only one possible output hash.

data family SignKeyVRF v Source #

Instances

Instances details
Eq ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

( TypeError (' Text "Ord not supported for signing keys, use the hash instead") :: Constraint , Eq ( SignKeyVRF v)) => Ord ( SignKeyVRF v)
Instance details

Defined in Cardano.Crypto.VRF.Class

Show ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Generic ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

ToCBOR ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

FromCBOR ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NFData ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NoThunks ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

newtype SignKeyVRF PraosVRF Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep ( SignKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep ( SignKeyVRF PraosVRF ) = D1 (' MetaData "SignKeyVRF" "Cardano.Crypto.VRF.Praos" "cardano-crypto-praos-2.1.0.0-8RyEQjtDErEBX6y5WsfiKH" ' True ) ( C1 (' MetaCons "SignKeyPraosVRF" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 SignKey )))

data family VerKeyVRF v Source #

Instances

Instances details
Eq ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

( TypeError (' Text "Ord not supported for verification keys, use the hash instead") :: Constraint , Eq ( VerKeyVRF v)) => Ord ( VerKeyVRF v)
Instance details

Defined in Cardano.Crypto.VRF.Class

Show ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Generic ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

ToCBOR ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

FromCBOR ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NFData ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NoThunks ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

newtype VerKeyVRF PraosVRF Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep ( VerKeyVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep ( VerKeyVRF PraosVRF ) = D1 (' MetaData "VerKeyVRF" "Cardano.Crypto.VRF.Praos" "cardano-crypto-praos-2.1.0.0-8RyEQjtDErEBX6y5WsfiKH" ' True ) ( C1 (' MetaCons "VerKeyPraosVRF" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 VerKey )))

data family CertVRF v Source #

Instances

Instances details
Eq ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Show ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Generic ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

ToCBOR ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

FromCBOR ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NFData ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NoThunks ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

newtype CertVRF PraosVRF Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep ( CertVRF PraosVRF ) Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep ( CertVRF PraosVRF ) = D1 (' MetaData "CertVRF" "Cardano.Crypto.VRF.Praos" "cardano-crypto-praos-2.1.0.0-8RyEQjtDErEBX6y5WsfiKH" ' True ) ( C1 (' MetaCons "CertPraosVRF" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Proof )))

Internal types

data Proof Source #

A proof, as constructed by the prove function.

Instances

Instances details
Eq Proof Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Show Proof Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Generic Proof Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

ToCBOR Proof Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

FromCBOR Proof Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NFData Proof Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NoThunks Proof Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep Proof Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

data SignKey Source #

Signing key. In this implementation, the signing key is actually a 64-byte value that contains both the 32-byte signing key and the corresponding 32-byte verification key.

Instances

Instances details
Eq SignKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Show SignKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Generic SignKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

ToCBOR SignKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

FromCBOR SignKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NFData SignKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NoThunks SignKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep SignKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

data VerKey Source #

Verification key.

Instances

Instances details
Eq VerKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Show VerKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

Generic VerKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

ToCBOR VerKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

FromCBOR VerKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NFData VerKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

NoThunks VerKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos

type Rep VerKey Source #
Instance details

Defined in Cardano.Crypto.VRF.Praos