6 #include "sodium/crypto_vrf.h"
39 bool verify(
const vrf_pk_t &pk,
const bytes &msg, uint16_t vote_count = 1,
bool strict =
true)
const;
43 virtual std::ostream &
print(std::ostream &strm)
const {
44 strm <<
"\n[VRF SortitionBase] " << std::endl;
45 strm <<
" proof: " <<
proof_ << std::endl;
46 strm <<
" output: " <<
output_ << std::endl;
51 return vrf_sortition.
print(strm);
61 const uint16_t a = 48271;
62 for (uint16_t vote_count_counter = 1; vote_count_counter < vote_count; vote_count_counter++) {
63 threshold_candidate = threshold_candidate * a;
64 if (threshold_candidate < min_threshold) {
65 min_threshold = threshold_candidate;
Definition: vrf_wrapper.hpp:25
static dev::bytes makeVrfInput(taraxa::level_t level, const dev::h256 &period_hash)
Definition: vrf_wrapper.cpp:48
VrfSortitionBase()=default
virtual std::ostream & print(std::ostream &strm) const
Definition: vrf_wrapper.hpp:43
void thresholdFromOutput(uint16_t vote_count) const
Definition: vrf_wrapper.hpp:55
friend std::ostream & operator<<(std::ostream &strm, VrfSortitionBase const &vrf_sortition)
Definition: vrf_wrapper.hpp:50
vrf_output_t output_
Definition: vrf_wrapper.hpp:74
bool operator==(VrfSortitionBase const &other) const
Definition: vrf_wrapper.hpp:41
VrfSortitionBase(vrf_sk_t const &sk, bytes const &msg, uint16_t vote_count=1)
Definition: vrf_wrapper.hpp:29
uint16_t threshold_
Definition: vrf_wrapper.hpp:75
vrf_proof_t proof_
Definition: vrf_wrapper.hpp:73
bool verify(const vrf_pk_t &pk, const bytes &msg, uint16_t vote_count=1, bool strict=true) const
Definition: vrf_wrapper.cpp:55
std::vector<::byte > bytes
Definition: Common.h:46
Definition: vrf_wrapper.hpp:8
std::optional< vrf_output_t > getVrfOutput(vrf_pk_t const &pk, vrf_proof_t const &proof, bytes const &msg, bool strict=true)
Definition: vrf_wrapper.cpp:32
std::pair< vrf_pk_t, vrf_sk_t > getVrfKeyPair()
Definition: vrf_wrapper.cpp:5
bool isValidVrfPublicKey(vrf_pk_t const &pk)
Definition: vrf_wrapper.cpp:18
std::optional< vrf_proof_t > getVrfProof(vrf_sk_t const &pk, bytes const &msg)
Definition: vrf_wrapper.cpp:22
vrf_pk_t getVrfPublicKey(vrf_sk_t const &sk)
Definition: vrf_wrapper.cpp:12
std::vector< byte > bytes
Definition: types.hpp:53
uint64_t level_t
Definition: types.hpp:46