container: root: macro: add bitcoin plugin support
- Adds support to existing macros for bitcoin's RNG via `dfi`'s `Random` * Currently only supports one of bitcoin's RNG's (`FastRandomContext`)
This commit is contained in:
@@ -105,6 +105,21 @@ using Random = ::dfi::crypto::libsodium::Random;
|
|||||||
auto g_Random = std::make_unique<Random>();
|
auto g_Random = std::make_unique<Random>();
|
||||||
} // namespace crypto::libsodium
|
} // namespace crypto::libsodium
|
||||||
|
|
||||||
|
#ifdef __DFI_PLUGIN_BITCOIN__
|
||||||
|
//! \namespace dfi::macro::common::crypto::bitcoin
|
||||||
|
//! \since docker-finance 1.1.0
|
||||||
|
namespace crypto::bitcoin
|
||||||
|
{
|
||||||
|
//! \brief ROOT's bitcoin Random class
|
||||||
|
//! \ingroup cpp_macro
|
||||||
|
using Random = ::dfi::crypto::bitcoin::Random;
|
||||||
|
|
||||||
|
//! \brief ROOT's bitcoin Random instance
|
||||||
|
//! \ingroup cpp_macro
|
||||||
|
auto g_Random = std::make_unique<Random>();
|
||||||
|
} // namespace crypto::bitcoin
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace common
|
} // namespace common
|
||||||
} // namespace macro
|
} // namespace macro
|
||||||
} // namespace dfi
|
} // namespace dfi
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ namespace common = ::dfi::macro::common;
|
|||||||
namespace libsodium = common::crypto::libsodium;
|
namespace libsodium = common::crypto::libsodium;
|
||||||
namespace cryptopp = common::crypto::cryptopp;
|
namespace cryptopp = common::crypto::cryptopp;
|
||||||
namespace botan = common::crypto::botan;
|
namespace botan = common::crypto::botan;
|
||||||
|
#ifdef __DFI_PLUGIN_BITCOIN__
|
||||||
|
namespace bitcoin = common::crypto::bitcoin;
|
||||||
|
#endif
|
||||||
|
|
||||||
//! \brief CSPRNG macro
|
//! \brief CSPRNG macro
|
||||||
class Random final
|
class Random final
|
||||||
@@ -110,6 +113,24 @@ class Random final
|
|||||||
return rng;
|
return rng;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __DFI_PLUGIN_BITCOIN__
|
||||||
|
//! \brief bitcon RNG
|
||||||
|
//! \return t_rng Random map to print (label, num)
|
||||||
|
static t_rng bitcoin_generate()
|
||||||
|
{
|
||||||
|
t_rng rng;
|
||||||
|
|
||||||
|
rng["int16_t (unsupported)"] = 0;
|
||||||
|
rng["int32_t (unsupported)"] = 0;
|
||||||
|
|
||||||
|
rng["uint16_t (unsupported)"] = 0;
|
||||||
|
rng["uint32_t"] = bitcoin::g_Random->generate<uint32_t>();
|
||||||
|
rng["uint64_t"] = bitcoin::g_Random->generate<uint64_t>();
|
||||||
|
|
||||||
|
return rng;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \brief Print t_rng of CSPRNG numbers in CSV format
|
//! \brief Print t_rng of CSPRNG numbers in CSV format
|
||||||
static void generate()
|
static void generate()
|
||||||
@@ -122,6 +143,9 @@ class Random final
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::cout << "\nimpl,type,num\n";
|
std::cout << "\nimpl,type,num\n";
|
||||||
|
#ifdef __DFI_PLUGIN_BITCOIN__
|
||||||
|
print("bitcoin::Random", Random::bitcoin_generate());
|
||||||
|
#endif
|
||||||
print("botan::Random", Random::botan_generate());
|
print("botan::Random", Random::botan_generate());
|
||||||
print("cryptopp::Random", Random::cryptopp_generate());
|
print("cryptopp::Random", Random::cryptopp_generate());
|
||||||
print("libsodium::Random", Random::libsodium_generate());
|
print("libsodium::Random", Random::libsodium_generate());
|
||||||
|
|||||||
@@ -351,6 +351,15 @@ class Random final
|
|||||||
|
|
||||||
const std::string timestamp{common::make_timestamp()};
|
const std::string timestamp{common::make_timestamp()};
|
||||||
|
|
||||||
|
#ifdef __DFI_PLUGIN_BITCOIN__
|
||||||
|
data.title = "Bitcoin_FastRandomContext_32_RNG_" + timestamp;
|
||||||
|
random(data, []() -> uint32_t {
|
||||||
|
return common::crypto::bitcoin::g_Random->generate();
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO(afiore): uint64_t (requires canvas-related refactor)
|
||||||
|
#endif
|
||||||
|
|
||||||
data.title = "Botan_RNG_" + timestamp;
|
data.title = "Botan_RNG_" + timestamp;
|
||||||
random(data, []() -> uint32_t {
|
random(data, []() -> uint32_t {
|
||||||
return common::crypto::botan::g_Random->generate();
|
return common::crypto::botan::g_Random->generate();
|
||||||
|
|||||||
Reference in New Issue
Block a user