8 #include <libp2p/multi/multibase_codec/codecs/base58.hpp> 16 case E::INVALID_LENGTH:
17 return "Invalid SS58 address length; Only 35 byte addresses are " 19 case E::INVALID_CHECKSUM:
20 return "Invalid SS58 checksum";
22 return "Unknown SS58 codec error";
28 gsl::span<uint8_t, kSs58Length - kSs58ChecksumLength> ss58_address,
30 constexpr
auto PREFIX =
"SS58PRE";
37 outcome::result<AccountId>
decodeSs58(std::string_view account_address,
41 OUTCOME_TRY(ss58_account_id,
42 libp2p::multi::detail::decodeBase58(account_address));
53 auto checksum = gsl::make_span<const uint8_t>(
56 if (gsl::span<const uint8_t>(calculated_checksum) != checksum) {
60 std::copy_n(ss58_account_id.begin() + 1,
61 primitives::AccountId::size(),
74 ss58_bytes.
put(checksum);
76 return libp2p::multi::detail::encodeBase58(ss58_bytes.
asVector());
Class represents arbitrary (including empty) byte buffer.
const std::vector< uint8_t > & asVector() const
getter for vector of bytes
virtual Hash512 blake2b_512(gsl::span< const uint8_t > buffer) const =0
blake2b_512 function calculates 64-byte blake2b hash
static common::Buffer calculateChecksum(gsl::span< uint8_t, kSs58Length-kSs58ChecksumLength > ss58_address, const crypto::Hasher &hasher)
constexpr size_t kSs58Length
gsl::span< const uint8_t > make_span(const rocksdb::Slice &s)
SLBuffer & put(std::string_view view)
Put a string into byte buffer.
OUTCOME_CPP_DEFINE_CATEGORY(kagome::primitives, Ss58Error, e)
SLBuffer & reserve(size_t size)
outcome::result< AccountId > decodeSs58(std::string_view account_address, const crypto::Hasher &hasher) noexcept
SLBuffer & putUint8(uint8_t n)
Put a 8-bit {.
crypto::Sr25519PublicKey AccountId
std::string encodeSs58(uint8_t account_type, const AccountId &id, const crypto::Hasher &hasher) noexcept
constexpr size_t kSs58ChecksumLength