mirror of
https://github.com/danog/ton.git
synced 2024-12-02 09:28:02 +01:00
bce33f588a
updated lite-client and configuration smartcontract updated tonlib code
61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
/*
|
|
This file is part of TON Blockchain Library.
|
|
|
|
TON Blockchain Library is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
TON Blockchain Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
Copyright 2017-2019 Telegram Systems LLP
|
|
*/
|
|
#pragma once
|
|
|
|
#include "td/utils/common.h"
|
|
#include "td/utils/Slice.h"
|
|
|
|
namespace td {
|
|
|
|
class Random {
|
|
public:
|
|
#if TD_HAVE_OPENSSL
|
|
static void secure_bytes(MutableSlice dest);
|
|
static void secure_bytes(unsigned char *ptr, size_t size);
|
|
static int32 secure_int32();
|
|
static int64 secure_int64();
|
|
static uint32 secure_uint32();
|
|
static uint64 secure_uint64();
|
|
|
|
// works only for current thread
|
|
static void add_seed(Slice bytes, double entropy = 0);
|
|
static void secure_cleanup();
|
|
#endif
|
|
|
|
static uint32 fast_uint32();
|
|
static uint64 fast_uint64();
|
|
|
|
// distribution is not uniform, min and max are included
|
|
static int fast(int min, int max);
|
|
static double fast(double min, double max);
|
|
|
|
class Xorshift128plus {
|
|
public:
|
|
explicit Xorshift128plus(uint64 seed);
|
|
Xorshift128plus(uint64 seed_a, uint64 seed_b);
|
|
uint64 operator()();
|
|
int fast(int min, int max);
|
|
|
|
private:
|
|
uint64 seed_[2];
|
|
};
|
|
};
|
|
|
|
} // namespace td
|