Safe Haskell | None |
---|---|
Language | Haskell2010 |
Verifiable Random Function (VRF) implemented as FFI wrappers around the implementation in https://github.com/input-output-hk/libsodium
Synopsis
- data PraosVRF
- certSizeVRF ∷ Int
- signKeySizeVRF ∷ Int
- verKeySizeVRF ∷ Int
- vrfKeySizeVRF ∷ Int
- data Seed
- genSeed ∷ IO Seed
- keypairFromSeed ∷ Seed → (VerKey, SignKey)
- outputBytes ∷ Output → ByteString
- proofBytes ∷ Proof → ByteString
- skBytes ∷ SignKey → ByteString
- vkBytes ∷ VerKey → ByteString
- skToVerKey ∷ SignKey → VerKey
- skToSeed ∷ SignKey → Seed
- proofFromBytes ∷ MonadFail m ⇒ ByteString → m Proof
- skFromBytes ∷ MonadFail m ⇒ ByteString → m SignKey
- vkFromBytes ∷ MonadFail m ⇒ ByteString → m VerKey
- vkToBatchCompat ∷ VerKeyVRF PraosVRF → VerKeyVRF PraosBatchCompatVRF
- skToBatchCompat ∷ SignKeyVRF PraosVRF → SignKeyVRF PraosBatchCompatVRF
- outputToBatchCompat ∷ OutputVRF PraosVRF → OutputVRF PraosBatchCompatVRF
- prove ∷ SignKey → ByteString → Maybe Proof
- verify ∷ VerKey → Proof → ByteString → Maybe Output
- data family SignKeyVRF v
- data family VerKeyVRF v
- data family CertVRF v
- data Proof
- data SignKey
- data VerKey
- data Output
VRFAlgorithm API
Instances
Key sizes
Seed and key generation
A random seed, used to derive a key pair.
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.
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.
proofFromBytes ∷ MonadFail m ⇒ ByteString → m Proof Source #
skFromBytes ∷ MonadFail m ⇒ ByteString → m SignKey Source #
vkFromBytes ∷ MonadFail m ⇒ ByteString → m VerKey Source #
vkToBatchCompat ∷ VerKeyVRF PraosVRF → VerKeyVRF PraosBatchCompatVRF Source #
Construct a BatchCompat vkey from praos, non-batchcompat
skToBatchCompat ∷ SignKeyVRF PraosVRF → SignKeyVRF PraosBatchCompatVRF Source #
Construct a BatchCompat skey from praos, non-batchcompat
outputToBatchCompat ∷ OutputVRF PraosVRF → OutputVRF PraosBatchCompatVRF Source #
Construct a BatchCompat output from praos, non-batchcompat
Core VRF operations
data family SignKeyVRF v Source #
Instances
data family VerKeyVRF v Source #
Instances
data family CertVRF v Source #
Instances
Internal types
A proof, as constructed by the prove
function.
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.
Verification key.