Kagome
Polkadot Runtime Engine in C++17
vrf_provider_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_CONSENSUS_VRF_VRF_HPP
7 #define KAGOME_CORE_CONSENSUS_VRF_VRF_HPP
8 
10 
11 #include <limits>
12 #include <optional>
13 #include "common/buffer.hpp"
15 
16 namespace kagome::crypto {
17 
18  class VRFProviderImpl : public VRFProvider {
19  static constexpr VRFThreshold kMaxThreshold{
20  std::numeric_limits<VRFThreshold>::max()};
21 
22  public:
23  explicit VRFProviderImpl(std::shared_ptr<CSPRNG> generator);
24 
25  ~VRFProviderImpl() override = default;
26 
27  Sr25519Keypair generateKeypair() const override;
28 
29  std::optional<VRFOutput> sign(const common::Buffer &msg,
30  const Sr25519Keypair &keypair,
31  const VRFThreshold &threshold) const override;
32 
34  const VRFOutput &output,
35  const Sr25519PublicKey &public_key,
36  const VRFThreshold &threshold) const override;
37 
38  std::optional<VRFOutput> signTranscript(
39  const primitives::Transcript &msg,
40  const Sr25519Keypair &keypair,
41  const VRFThreshold &threshold) const override;
42 
44  const primitives::Transcript &msg,
45  const VRFOutput &output,
46  const Sr25519PublicKey &public_key,
47  const VRFThreshold &threshold) const override;
48 
49  std::optional<VRFOutput> signTranscript(
50  const primitives::Transcript &msg,
51  const Sr25519Keypair &keypair) const override;
52 
53  private:
54  std::optional<VRFOutput> signTranscriptImpl(
55  const primitives::Transcript &msg,
56  const Sr25519Keypair &keypair,
57  const std::optional<std::reference_wrapper<const VRFThreshold>>
58  threshold) const;
59 
60  std::shared_ptr<CSPRNG> generator_;
61  };
62 } // namespace kagome::crypto
63 
64 #endif // KAGOME_CORE_CONSENSUS_VRF_VRF_HPP
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
std::optional< VRFOutput > signTranscript(const primitives::Transcript &msg, const Sr25519Keypair &keypair, const VRFThreshold &threshold) const override
std::optional< VRFOutput > signTranscriptImpl(const primitives::Transcript &msg, const Sr25519Keypair &keypair, const std::optional< std::reference_wrapper< const VRFThreshold >> threshold) const
VRFVerifyOutput verifyTranscript(const primitives::Transcript &msg, const VRFOutput &output, const Sr25519PublicKey &public_key, const VRFThreshold &threshold) const override
boost::multiprecision::uint128_t VRFThreshold
Sr25519Keypair generateKeypair() const override
std::shared_ptr< CSPRNG > generator_
VRFVerifyOutput verify(const common::Buffer &msg, const VRFOutput &output, const Sr25519PublicKey &public_key, const VRFThreshold &threshold) const override
std::optional< VRFOutput > sign(const common::Buffer &msg, const Sr25519Keypair &keypair, const VRFThreshold &threshold) const override
VRFProviderImpl(std::shared_ptr< CSPRNG > generator)
~VRFProviderImpl() override=default
static constexpr VRFThreshold kMaxThreshold