13 template<
typename BLSKey>
18 if (!key.IsValid())
return "";
19 std::vector<unsigned char> vec{key.ToByteVector()};
20 std::vector<unsigned char> data;
21 data.reserve((vec.size() * 8 + 4) / 5);
22 ConvertBits<8, 5, true>([&](
unsigned char c) { data.push_back(c); }, vec.begin(), vec.end());
29 template<
typename BLSKey>
31 const std::string& keyStr,
35 if (keyStr.empty())
return nullopt;
37 if (bech.first == params.
Bech32HRP(type) && bech.second.size() == keySize) {
38 std::vector<unsigned char> data;
39 data.reserve((bech.second.size() * 5) / 8);
40 if (ConvertBits<5, 8, false>([&](
unsigned char c) { data.push_back(c); }, bech.second.begin(), bech.second.end())) {
44 if (key.IsValid())
return {key};
#define BLS_CURVE_SECKEY_SIZE
#define BLS_CURVE_PUBKEY_SIZE
CChainParams defines various tweakable parameters of a given instance of the PIVX system.
const std::string & Bech32HRP(Bech32Type type) const
void memory_cleanse(void *ptr, size_t len)
std::pair< std::string, data > Decode(const std::string &str)
Decode a Bech32 string.
std::string Encode(const std::string &hrp, const data &values)
Encode a Bech32 string.
const size_t ConvertedBlsPkSize
const size_t ConvertedBlsSkSize
Optional< CBLSSecretKey > DecodeSecret(const CChainParams ¶ms, const std::string &keyStr)
std::string EncodeSecret(const CChainParams ¶ms, const CBLSSecretKey &key)
Optional< CBLSPublicKey > DecodePublic(const CChainParams ¶ms, const std::string &keyStr)
std::string EncodePublic(const CChainParams ¶ms, const CBLSPublicKey &pk)
boost::optional< T > Optional
Substitute for C++17 std::optional.