]> Git Repo - VerusCoin.git/blame - src/random.h
Remove references to X11 licence
[VerusCoin.git] / src / random.h
CommitLineData
6354935c
PK
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2014 The Bitcoin developers
78253fcb 3// Distributed under the MIT software license, see the accompanying
6354935c
PK
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef BITCOIN_RANDOM_H
7#define BITCOIN_RANDOM_H
8
9#include "uint256.h"
10
11#include <stdint.h>
12
13/**
14 * Seed OpenSSL PRNG with additional entropy data
15 */
16void RandAddSeed();
17void RandAddSeedPerfmon();
18
19/**
20 * Functions to gather random data via the OpenSSL PRNG
21 */
65e3a1e7 22void GetRandBytes(unsigned char* buf, int num);
6354935c
PK
23uint64_t GetRand(uint64_t nMax);
24int GetRandInt(int nMax);
25uint256 GetRandHash();
26
27/**
28 * Seed insecure_rand using the random pool.
3a05ba1b 29 * @param Deterministic Use a deterministic seed
6354935c
PK
30 */
31void seed_insecure_rand(bool fDeterministic = false);
32
33/**
34 * MWC RNG of George Marsaglia
35 * This is intended to be fast. It has a period of 2^59.3, though the
36 * least significant 16 bits only have a period of about 2^30.1.
37 *
38 * @return random value
39 */
40extern uint32_t insecure_rand_Rz;
41extern uint32_t insecure_rand_Rw;
42static inline uint32_t insecure_rand(void)
43{
44 insecure_rand_Rz = 36969 * (insecure_rand_Rz & 65535) + (insecure_rand_Rz >> 16);
45 insecure_rand_Rw = 18000 * (insecure_rand_Rw & 65535) + (insecure_rand_Rw >> 16);
46 return (insecure_rand_Rw << 16) + insecure_rand_Rz;
47}
48
49#endif // BITCOIN_RANDOM_H
This page took 0.039638 seconds and 4 git commands to generate.