1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

pow-testgiver support

This commit is contained in:
ton 2020-07-06 17:07:20 +03:00
parent dbde9c1c40
commit f064b1047a
257 changed files with 6665 additions and 2608 deletions

View file

@ -28,6 +28,8 @@ char disable_linker_warning_about_empty_file_bignum_cpp TD_UNUSED;
#include <openssl/bn.h>
#include <openssl/crypto.h>
#include <algorithm>
namespace td {
class BigNumContext::Impl {
@ -103,8 +105,9 @@ BigNum BigNum::from_le_binary(Slice str) {
#elif OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
return BigNum(make_unique<Impl>(BN_lebin2bn(str.ubegin(), narrow_cast<int>(str.size()), nullptr)));
#else
LOG(FATAL) << "Unsupported from_le_binary";
return BigNum();
string str_copy = str.str();
std::reverse(str_copy.begin(), str_copy.end());
return from_binary(str_copy);
#endif
}
@ -133,14 +136,6 @@ BigNum BigNum::from_raw(void *openssl_big_num) {
BigNum::BigNum(unique_ptr<Impl> &&impl) : impl_(std::move(impl)) {
}
void BigNum::ensure_const_time() {
#if !defined(OPENSSL_IS_BORINGSSL)
BN_set_flags(impl_->big_num, BN_FLG_CONSTTIME);
#else
LOG(FATAL) << "Unsupported BN_FLG_CONSTTIME";
#endif
}
int BigNum::get_num_bits() const {
return BN_num_bits(impl_->big_num);
}
@ -238,8 +233,9 @@ string BigNum::to_le_binary(int exact_size) const {
#endif
return res;
#else
LOG(FATAL) << "Unsupported to_le_binary";
return "";
string result = to_binary(exact_size);
std::reverse(result.begin(), result.end());
return result;
#endif
}