mirror of
https://github.com/eosswedenorg/libantelope
synced 2026-06-16 03:34:56 +02:00
include/libeosio/WIF.hpp: Adding WIF_SIG_K1 constant.
This commit is contained in:
parent
1aa6906ba2
commit
171db63de4
2 changed files with 4 additions and 8 deletions
|
|
@ -36,7 +36,7 @@ const std::string WIF_PUB_LEG = "EOS";
|
|||
const std::string WIF_PUB_K1 = "PUB_K1_";
|
||||
const std::string WIF_PVT_LEG = "";
|
||||
const std::string WIF_PVT_K1 = "PVT_K1_";
|
||||
|
||||
const std::string WIF_SIG_K1 = "SIG_K1_";
|
||||
|
||||
/**
|
||||
* Encode an EC private key to WIF String.
|
||||
|
|
|
|||
10
src/WIF.cpp
10
src/WIF.cpp
|
|
@ -139,16 +139,12 @@ bool wif_sig_decode(ec_signature_t& sig, const std::string& data) {
|
|||
checksum_t checksum;
|
||||
std::vector<unsigned char> buf;
|
||||
|
||||
if (data.substr(0, 7) != "SIG_K1_") {
|
||||
if (data.substr(0, WIF_SIG_K1.length()) != WIF_SIG_K1) {
|
||||
// Invalid prefix
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!base58_decode(data.c_str() + 7, buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buf.size() != EC_SIGNATURE_SIZE + CHECKSUM_SIZE) {
|
||||
if (!base58_decode(data.c_str() + WIF_SIG_K1.length(), buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +169,7 @@ std::string wif_sig_encode(const ec_signature_t& sig) {
|
|||
memcpy(buf, sig.data(), sig.size());
|
||||
memcpy(buf + EC_SIGNATURE_SIZE, check.data(), check.size());
|
||||
|
||||
return "SIG_K1_" + base58_encode(buf, buf + sizeof(buf));
|
||||
return WIF_SIG_K1_" + base58_encode(buf, buf + sizeof(buf));
|
||||
}
|
||||
|
||||
} // namespace libeosio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue