hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
permutation_generator.hpp
Go to the documentation of this file.
1 
6 #include <random>
7 #include <vector>
8 
9 namespace iroha {
10 
11  using RandomEngine = std::mt19937_64;
12 
13  RandomEngine makeSeededPrng(const char *seed_start, size_t seed_length);
14 
15  RandomEngine makeSeededPrng(const unsigned char *seed_start,
16  size_t seed_length);
17 
19  class Seeder {
20  public:
21  using ValueType = RandomEngine::result_type;
22 
23  Seeder();
24 
25  RandomEngine makePrng() const;
26 
27  Seeder &feed(const char *seed_start, size_t seed_length);
28 
29  Seeder &feed(ValueType value);
30 
31  protected:
33  };
34 
42  void generatePermutation(std::vector<size_t> &permutation,
43  RandomEngine prng,
44  size_t size);
45 } // namespace iroha
Helper class to seed a PRNG. For not crypto-related use only.
Definition: permutation_generator.hpp:19
RandomEngine makePrng() const
Definition: permutation_generator.cpp:31
RandomEngine makeSeededPrng(const char *seed_start, size_t seed_length)
Definition: permutation_generator.cpp:18
Definition: block_query.hpp:15
void generatePermutation(std::vector< size_t > &permutation, RandomEngine prng, size_t size)
Definition: permutation_generator.cpp:64
std::mt19937_64 RandomEngine
Definition: permutation_generator.hpp:11
Seeder & feed(const char *seed_start, size_t seed_length)
Definition: permutation_generator.cpp:35
RandomEngine::result_type ValueType
Definition: permutation_generator.hpp:21
Seeder()
Definition: permutation_generator.cpp:29
ValueType current_seed_
Definition: permutation_generator.hpp:32