class
VRFSecretKeyRepresents a VRF secret key.
Derived classes
- class VrfSigningKey
- A VRF signing key used by stake pools to verify leadership selection.
Public static functions
-
static auto fromSeed(std::
span<const uint8_t, VRF_SEED_SIZE> seed) → VRFSecretKey - static auto generate() → VRFSecretKey
-
static auto proofToHash(std::
span<const uint8_t, VRF_PROOF_SIZE> proof) → std:: array<uint8_t, VRF_PROOF_HASH_SIZE> - Convert a VRF proof to a VRF hash.
Constructors, destructors, conversion operators
-
VRFSecretKey(std::
span<const uint8_t, VRF_SECRET_KEY_SIZE> prv) explicit - Construct a key object from a span of key bytes.
Public functions
- auto bytes() const → const VRFKeyByteArray& constexpr
- Return a constant reference to the private key secure byte array.
-
auto constructProof(std::
span<const uint8_t> msg) → std:: array<uint8_t, VRF_PROOF_SIZE> - Construct a VRF proof from an initial message.
-
auto hash(std::
span<const uint8_t> msg) → std:: array<uint8_t, VRF_PROOF_HASH_SIZE> - Compute the VRF hash of a message.
- auto isValid() const → bool
- Ensure the key is a valid ed25519 key.
- auto publicKey() const → VRFPublicKey
- Derive the public key paired with this private key.
-
auto sign(std::
span<const uint8_t> msg) const → std:: array<uint8_t, ed25519:: SIGNATURE_SIZE> - Generate a message signature from the private key.
-
auto verifyProof(std::
span<const uint8_t> msg, std:: span<const uint8_t, VRF_PROOF_SIZE> proof) const → bool - Verify a VRF proof from the associated secret key.
Function documentation
static VRFSecretKey cardano:: VRFSecretKey:: fromSeed(std:: span<const uint8_t, VRF_SEED_SIZE> seed)
Parameters | |
---|---|
seed | 32 byte seed. |
Factory method to create a new VRF secret key from a seed.
static VRFSecretKey cardano:: VRFSecretKey:: generate()
Factory method to create a new VRF secret key from a cryptographically secure random number generator.
static std:: array<uint8_t, VRF_PROOF_HASH_SIZE> cardano:: VRFSecretKey:: proofToHash(std:: span<const uint8_t, VRF_PROOF_SIZE> proof)
Convert a VRF proof to a VRF hash.
Parameters | |
---|---|
proof | The VRF proof. |
Returns | The VRF hash. |
cardano:: VRFSecretKey:: VRFSecretKey(std:: span<const uint8_t, VRF_SECRET_KEY_SIZE> prv) explicit
Construct a key object from a span of key bytes.
Parameters | |
---|---|
prv | A span of 64 bytes that will be copied into the object. The bytes need to consist of the secret key (or seed) and the public key concatenated. |
std:: array<uint8_t, VRF_PROOF_SIZE> cardano:: VRFSecretKey:: constructProof(std:: span<const uint8_t> msg)
Construct a VRF proof from an initial message.
Parameters | |
---|---|
msg | A span of bytes (uint8_t) representing the message. |
Returns | A vector of bytes representing the VRF proof. |
std:: array<uint8_t, VRF_PROOF_HASH_SIZE> cardano:: VRFSecretKey:: hash(std:: span<const uint8_t> msg)
Compute the VRF hash of a message.
Parameters | |
---|---|
msg | The message to hash. |
Returns | The VRF hash. |
std:: array<uint8_t, ed25519:: SIGNATURE_SIZE> cardano:: VRFSecretKey:: sign(std:: span<const uint8_t> msg) const
Generate a message signature from the private key.
Parameters | |
---|---|
msg | A span of bytes (uint8_t) representing the message to sign. |
bool cardano:: VRFSecretKey:: verifyProof(std:: span<const uint8_t> msg,
std:: span<const uint8_t, VRF_PROOF_SIZE> proof) const
Verify a VRF proof from the associated secret key.
Parameters | |
---|---|
msg | The message from which the proof and hash were derived. |
proof | The proof to verify. |
Returns | True if the proof is valid, false otherwise. |