1
0
Fork 0
mirror of https://github.com/eosswedenorg/libantelope synced 2026-06-16 11:44:55 +02:00

src/WIF.cpp: move _calculate_sig_checksum() to top of file, so we dont need to add a function declaration.

This commit is contained in:
Henrik Hautakoski 2023-03-23 14:19:37 +01:00
parent 9ebc1e3aa1
commit 2b68d7ec32

View file

@ -31,6 +31,20 @@ namespace libeosio {
#define PRIV_KEY_PREFIX 0x80 /* 0x80 for "Bitcoin mainnet". Always used by EOS. */
// Just to make it "harder" the calculated checksum for a signature
// has a "K1" suffix that is not present in the WIF encoded string.
// So this function is a quick hack to calculate it.
//
// Should implement and use Init/Update/Finalize hash functions to do it inplace.
checksum_t _calculate_sig_checksum(const unsigned char *in) {
unsigned char buf[EC_SIGNATURE_SIZE + 2];
memcpy(buf, in, EC_SIGNATURE_SIZE);
memcpy(buf + EC_SIGNATURE_SIZE, "K1", 2);
return checksum_ripemd160(buf, EC_SIGNATURE_SIZE + 2);
}
std::string wif_priv_encode(const ec_privkey_t& priv) {
checksum_t check;
@ -112,20 +126,6 @@ void wif_print_key(const struct ec_keypair *key, const std::string& prefix) {
std::cout << "Private: " << wif_priv_encode(key->secret) << std::endl;
}
// Just to make it "harder" the calculated checksum for a signature
// has a "K1" suffix that is not present in the WIF encoded string.
// So this function is a quick hack to calculate it.
//
// Should implement and use Init/Update/Finalize hash functions to do it inplace.
checksum_t _calculate_sig_checksum(const unsigned char *in) {
unsigned char buf[EC_SIGNATURE_SIZE + 2];
memcpy(buf, in, EC_SIGNATURE_SIZE);
memcpy(buf + EC_SIGNATURE_SIZE, "K1", 2);
return checksum_ripemd160(buf, EC_SIGNATURE_SIZE + 2);
}
bool wif_sig_decode(ec_signature_t& sig, const std::string& data) {
checksum_t checksum;