mirror of
https://github.com/eosswedenorg/libantelope
synced 2026-06-16 03:34:56 +02:00
Change namespace and header guards from libeosio to libantelope
This commit is contained in:
parent
0cfd459c71
commit
6824a2f49e
32 changed files with 176 additions and 176 deletions
|
|
@ -21,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef LIBEOSIO_WIF_H
|
||||
#define LIBEOSIO_WIF_H
|
||||
#ifndef LIBANTELOPE_WIF_H
|
||||
#define LIBANTELOPE_WIF_H
|
||||
|
||||
#include <string>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
/**
|
||||
* Key prefixes. (strings that is not equal to these prefixes are treated as legacy format.)
|
||||
|
|
@ -94,6 +94,6 @@ std::string wif_sig_encode(const ec_signature_t& sig);
|
|||
*/
|
||||
bool wif_sig_decode(ec_signature_t& sig, const std::string& data);
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
||||
#endif /* LIBEOSIO_WIF_H */
|
||||
#endif /* LIBANTELOPE_WIF_H */
|
||||
|
|
@ -21,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef LIBEOSIO_BASE58_H
|
||||
#define LIBEOSIO_BASE58_H
|
||||
#ifndef LIBANTELOPE_BASE58_H
|
||||
#define LIBANTELOPE_BASE58_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
/**
|
||||
* Base58 Encoding functions.
|
||||
|
|
@ -61,6 +61,6 @@ size_t is_base58(const std::string& str);
|
|||
*/
|
||||
std::string& base58_strip(std::string& str);
|
||||
|
||||
} //namespace libeosio
|
||||
} //namespace libantelope
|
||||
|
||||
#endif /* LIBEOSIO_BASE58_H */
|
||||
#endif /* LIBANTELOPE_BASE58_H */
|
||||
|
|
@ -21,14 +21,14 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef LIBEOSIO_CHECKSUM_H
|
||||
#define LIBEOSIO_CHECKSUM_H
|
||||
#ifndef LIBANTELOPE_CHECKSUM_H
|
||||
#define LIBANTELOPE_CHECKSUM_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <libeosio/hash.hpp>
|
||||
#include <libantelope/hash.hpp>
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
/**
|
||||
* Checksum size (in bytes)
|
||||
|
|
@ -68,6 +68,6 @@ inline bool checksum_validate(const unsigned char* data, std::size_t len) {
|
|||
#define checksum_sha256d checksum<sha256_t, sha256d>
|
||||
#define checksum_ripemd160 checksum<ripemd160_t, ripemd160>
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
||||
#endif /* LIBEOSIO_CHECKSUM_H */
|
||||
#endif /* LIBANTELOPE_CHECKSUM_H */
|
||||
|
|
@ -21,14 +21,14 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef LIBEOSIO_EC_H
|
||||
#define LIBEOSIO_EC_H
|
||||
#ifndef LIBANTELOPE_EC_H
|
||||
#define LIBANTELOPE_EC_H
|
||||
|
||||
#include <libeosio/hash.hpp>
|
||||
#include <libantelope/hash.hpp>
|
||||
#include <iostream>
|
||||
#include <array>
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
/**
|
||||
* Elliptic curve private key size (in bytes)
|
||||
|
|
@ -128,13 +128,13 @@ int ecdsa_recover(const sha256_t* digest, const ec_signature_t& sig, ec_pubkey_t
|
|||
*/
|
||||
void ec_shutdown();
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
||||
|
||||
// Stream operators
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const libeosio::ec_privkey_t& pk);
|
||||
std::ostream& operator<<(std::ostream& os, const libantelope::ec_privkey_t& pk);
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const libeosio::ec_pubkey_t& pk);
|
||||
std::ostream& operator<<(std::ostream& os, const libantelope::ec_pubkey_t& pk);
|
||||
|
||||
#endif /* LIBEOSIO_EC_H */
|
||||
#endif /* LIBANTELOPE_EC_H */
|
||||
|
|
@ -21,12 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef LIBEOSIO_HASH_H
|
||||
#define LIBEOSIO_HASH_H
|
||||
#ifndef LIBANTELOPE_HASH_H
|
||||
#define LIBANTELOPE_HASH_H
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
/**
|
||||
* Hashes
|
||||
|
|
@ -55,6 +55,6 @@ sha256_t* sha256d(const unsigned char *data, std::size_t len, sha256_t* out);
|
|||
*/
|
||||
ripemd160_t* ripemd160(const unsigned char *data, std::size_t len, ripemd160_t* out);
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
||||
#endif /* LIBEOSIO_HASH_H */
|
||||
#endif /* LIBANTELOPE_HASH_H */
|
||||
10
src/WIF.cpp
10
src/WIF.cpp
|
|
@ -23,12 +23,12 @@
|
|||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <libeosio/base58.hpp>
|
||||
#include <libeosio/checksum.hpp>
|
||||
#include <libeosio/WIF.hpp>
|
||||
#include <libantelope/base58.hpp>
|
||||
#include <libantelope/checksum.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include "wif/codec.hpp"
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
const std::string WIF_PUB_LEG = "EOS";
|
||||
const std::string WIF_PUB_K1 = "PUB_K1_";
|
||||
|
|
@ -154,4 +154,4 @@ std::string wif_sig_encode(const ec_signature_t& sig) {
|
|||
return WIF_SIG_K1 + base58_encode(buf, buf + sizeof(buf));
|
||||
}
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@
|
|||
#include <cstddef>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <libeosio/base58.hpp>
|
||||
#include <libantelope/base58.hpp>
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
static const char charmap[59] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
||||
static const int8_t table[256] = {
|
||||
|
|
@ -190,4 +190,4 @@ std::string& base58_strip(std::string &str) {
|
|||
return str;
|
||||
}
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
|
||||
std::ostream& _hex(std::ostream& os, const unsigned char *b, std::size_t sz) {
|
||||
os << "[ " << std::hex;
|
||||
|
|
@ -38,10 +38,10 @@ std::ostream& _hex(std::ostream& os, const unsigned char *b, std::size_t sz) {
|
|||
return os << std::oct << " ]";
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const libeosio::ec_privkey_t& k) {
|
||||
std::ostream& operator<<(std::ostream& os, const libantelope::ec_privkey_t& k) {
|
||||
return _hex(os, k.data(), k.size());
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const libeosio::ec_pubkey_t& k) {
|
||||
std::ostream& operator<<(std::ostream& os, const libantelope::ec_pubkey_t& k) {
|
||||
return _hex(os, k.data(), k.size());
|
||||
}
|
||||
|
|
@ -23,10 +23,10 @@
|
|||
*/
|
||||
#include <secp256k1.h>
|
||||
#include <secp256k1_ecdh.h>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include "rng.h"
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
secp256k1_context* ctx;
|
||||
|
||||
|
|
@ -90,4 +90,4 @@ int ec_generate_key(struct ec_keypair *pair) {
|
|||
return ec_get_publickey(&pair->secret, &pair->pub);
|
||||
}
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@
|
|||
*/
|
||||
#include <secp256k1.h>
|
||||
#include <secp256k1_recovery.h>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include "rng.h"
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
extern secp256k1_context* ctx;
|
||||
|
||||
|
|
@ -115,4 +115,4 @@ int ecdsa_recover(const sha256_t* digest, const ec_signature_t& sig, ec_pubkey_t
|
|||
return len != EC_PUBKEY_SIZE ? -1 : 0;
|
||||
}
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@
|
|||
#include <openssl/ec.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include "internal.h"
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
BN_CTX *ctx = NULL;
|
||||
EC_KEY *k = NULL;
|
||||
|
|
@ -121,4 +121,4 @@ int ec_generate_key(struct ec_keypair *pair) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@
|
|||
#include <openssl/ec.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/ecdsa.h>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include "internal.h"
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
extern BN_CTX *ctx;
|
||||
|
||||
|
|
@ -182,4 +182,4 @@ err2: EC_KEY_free(ec_key);
|
|||
err1: return ret;
|
||||
}
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
|
@ -23,9 +23,9 @@
|
|||
*/
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/ripemd.h>
|
||||
#include <libeosio/hash.hpp>
|
||||
#include <libantelope/hash.hpp>
|
||||
|
||||
namespace libeosio {
|
||||
namespace libantelope {
|
||||
|
||||
sha256_t* sha256(const unsigned char *data, std::size_t len, sha256_t* out) {
|
||||
return (sha256_t *) SHA256(data, len, (unsigned char*) out);
|
||||
|
|
@ -40,4 +40,4 @@ ripemd160_t* ripemd160(const unsigned char *data, std::size_t len, ripemd160_t*
|
|||
return (ripemd160_t *) RIPEMD160(data, len, (unsigned char*) out);
|
||||
}
|
||||
|
||||
} // namespace libeosio
|
||||
} // namespace libantelope
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@
|
|||
#include <openssl/ec.h>
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
#ifndef LIBEOSIO_OPENSSL_INTERNAL_H
|
||||
#define LIBEOSIO_OPENSSL_INTERNAL_H
|
||||
#ifndef LIBANTELOPE_OPENSSL_INTERNAL_H
|
||||
#define LIBANTELOPE_OPENSSL_INTERNAL_H
|
||||
|
||||
#define EC_KEY_new_secp256k1() (EC_KEY_new_by_curve_name( NID_secp256k1 ))
|
||||
|
||||
|
|
@ -62,4 +62,4 @@ int ECDSA_SIG_unserialize_rs(const unsigned char *sig, BIGNUM **r, BIGNUM **s, i
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBEOSIO_OPENSSL_INTERNAL_H */
|
||||
#endif /* LIBANTELOPE_OPENSSL_INTERNAL_H */
|
||||
|
|
@ -21,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef LIBEOSIO_CODEC_H
|
||||
#define LIBEOSIO_CODEC_H
|
||||
#ifndef LIBANTELOPE_CODEC_H
|
||||
#define LIBANTELOPE_CODEC_H
|
||||
|
||||
#include <libeosio/WIF.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace libeosio { namespace internal {
|
||||
namespace libantelope { namespace internal {
|
||||
|
||||
/**
|
||||
* Public-key encoders
|
||||
|
|
@ -79,6 +79,6 @@ typedef bool (*sig_decoder_t)(const std::vector<unsigned char>& buf, ec_signatur
|
|||
|
||||
bool sig_decoder_k1(const std::vector<unsigned char>& buf, ec_signature_t& sig);
|
||||
|
||||
}} // namespace libeosio::internal
|
||||
}} // namespace libantelope::internal
|
||||
|
||||
#endif /* LIBEOSIO_CODEC_H */
|
||||
#endif /* LIBANTELOPE_CODEC_H */
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <libeosio/checksum.hpp>
|
||||
#include <libantelope/checksum.hpp>
|
||||
#include <vector>
|
||||
#include "codec.hpp"
|
||||
|
||||
namespace libeosio { namespace internal {
|
||||
namespace libantelope { namespace internal {
|
||||
|
||||
// Just to make it "harder" the calculated checksum for a signature (k1) and pub/priv keys in k1/r1 format.
|
||||
// has a suffix that is not present in the WIF encoded string.
|
||||
|
|
@ -125,4 +125,4 @@ bool sig_decoder_k1(const std::vector<unsigned char>& buf, ec_signature_t& sig)
|
|||
}
|
||||
|
||||
|
||||
}} // namespace libeosio::internal
|
||||
}} // namespace libantelope::internal
|
||||
|
|
@ -22,10 +22,10 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <libeosio/checksum.hpp>
|
||||
#include <libantelope/checksum.hpp>
|
||||
#include "codec.hpp"
|
||||
|
||||
namespace libeosio { namespace internal {
|
||||
namespace libantelope { namespace internal {
|
||||
|
||||
#define PRIV_KEY_PREFIX 0x80 /* 0x80 for "Bitcoin mainnet". Always used by EOS. */
|
||||
|
||||
|
|
@ -77,4 +77,4 @@ bool priv_decoder_legacy(const std::vector<unsigned char>& buf, ec_privkey_t& pr
|
|||
return true;
|
||||
}
|
||||
|
||||
}} // namespace libeosio::internal
|
||||
}} // namespace libantelope::internal
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#include <libeosio/WIF.hpp>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
|
@ -8,7 +8,7 @@ TEST_CASE("WIF::wif_priv_decode [legacy]") {
|
|||
struct testcase {
|
||||
std::string name;
|
||||
std::string key;
|
||||
libeosio::ec_privkey_t expected;
|
||||
libantelope::ec_privkey_t expected;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -22,9 +22,9 @@ TEST_CASE("WIF::wif_priv_decode [legacy]") {
|
|||
|
||||
SUBCASE(it->name.c_str()) {
|
||||
|
||||
libeosio::ec_privkey_t result;
|
||||
libantelope::ec_privkey_t result;
|
||||
|
||||
CHECK( libeosio::wif_priv_decode(result, it->key) );
|
||||
CHECK( libantelope::wif_priv_decode(result, it->key) );
|
||||
CHECK( result == it->expected );
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ TEST_CASE("WIF::wif_priv_decode [K1]") {
|
|||
struct testcase {
|
||||
std::string name;
|
||||
std::string key;
|
||||
libeosio::ec_privkey_t expected;
|
||||
libantelope::ec_privkey_t expected;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -49,9 +49,9 @@ TEST_CASE("WIF::wif_priv_decode [K1]") {
|
|||
|
||||
SUBCASE(it->name.c_str()) {
|
||||
|
||||
libeosio::ec_privkey_t result;
|
||||
libantelope::ec_privkey_t result;
|
||||
|
||||
CHECK( libeosio::wif_priv_decode(result, it->key) );
|
||||
CHECK( libantelope::wif_priv_decode(result, it->key) );
|
||||
CHECK( result == it->expected );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <libeosio/WIF.hpp>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
|
@ -9,20 +9,20 @@ TEST_CASE("WIF::wif_priv_encode [Legacy]") {
|
|||
struct testcase {
|
||||
std::string name;
|
||||
const std::string prefix;
|
||||
libeosio::ec_privkey_t key;
|
||||
libantelope::ec_privkey_t key;
|
||||
std::string expected;
|
||||
};
|
||||
|
||||
std::vector<struct testcase> tests {
|
||||
{ "one", libeosio::WIF_PVT_LEG, { 0x0C, 0x28, 0xFC, 0xA3, 0x86, 0xC7, 0xA2, 0x27, 0x60, 0x0B, 0x2F, 0xE5, 0x0B, 0x7C, 0xAE, 0x11, 0xEC, 0x86, 0xD3, 0xBF, 0x1F, 0xBE, 0x47, 0x1B, 0xE8, 0x98, 0x27, 0xE1, 0x9D,0x72,0xAA,0x1D}, "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ" },
|
||||
{ "two", libeosio::WIF_PVT_LEG, { 0x9F, 0xE3, 0xE3, 0x2B, 0x3C, 0x4B, 0x6B, 0x91, 0x6E, 0x20, 0x6C, 0xB0, 0x91, 0xDF, 0x1F, 0x5E, 0x34, 0x32, 0x88, 0x0B, 0x41, 0x33, 0x86, 0xBD, 0xF2, 0x92, 0xFF, 0x23, 0x06, 0x43, 0xF2, 0x8C}, "5K2hm8apqz281ANDQdtVzifpxcXFTqG5E7Fc6Q5V2ssqPRQ3urJ" },
|
||||
{ "three", libeosio::WIF_PVT_LEG, { 0x59, 0x3A, 0x51, 0xB5, 0x5D, 0x56, 0xAA, 0xF0, 0x5B, 0xD9, 0xD1, 0x0E, 0x6B, 0x88, 0x6D, 0xF9, 0xC4, 0x37, 0x09, 0xB2, 0x4C, 0xEC, 0xBB, 0x63, 0x68, 0x92, 0xC2, 0x94, 0x31, 0x48, 0x71, 0x8C}, "5JVanYq9HPvuKgr2FjATYB9NvTsJ4a3CAj5oPYKbr1Ja5MRLsZX" }
|
||||
{ "one", libantelope::WIF_PVT_LEG, { 0x0C, 0x28, 0xFC, 0xA3, 0x86, 0xC7, 0xA2, 0x27, 0x60, 0x0B, 0x2F, 0xE5, 0x0B, 0x7C, 0xAE, 0x11, 0xEC, 0x86, 0xD3, 0xBF, 0x1F, 0xBE, 0x47, 0x1B, 0xE8, 0x98, 0x27, 0xE1, 0x9D,0x72,0xAA,0x1D}, "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ" },
|
||||
{ "two", libantelope::WIF_PVT_LEG, { 0x9F, 0xE3, 0xE3, 0x2B, 0x3C, 0x4B, 0x6B, 0x91, 0x6E, 0x20, 0x6C, 0xB0, 0x91, 0xDF, 0x1F, 0x5E, 0x34, 0x32, 0x88, 0x0B, 0x41, 0x33, 0x86, 0xBD, 0xF2, 0x92, 0xFF, 0x23, 0x06, 0x43, 0xF2, 0x8C}, "5K2hm8apqz281ANDQdtVzifpxcXFTqG5E7Fc6Q5V2ssqPRQ3urJ" },
|
||||
{ "three", libantelope::WIF_PVT_LEG, { 0x59, 0x3A, 0x51, 0xB5, 0x5D, 0x56, 0xAA, 0xF0, 0x5B, 0xD9, 0xD1, 0x0E, 0x6B, 0x88, 0x6D, 0xF9, 0xC4, 0x37, 0x09, 0xB2, 0x4C, 0xEC, 0xBB, 0x63, 0x68, 0x92, 0xC2, 0x94, 0x31, 0x48, 0x71, 0x8C}, "5JVanYq9HPvuKgr2FjATYB9NvTsJ4a3CAj5oPYKbr1Ja5MRLsZX" }
|
||||
};
|
||||
|
||||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
|
||||
SUBCASE(it->name.c_str()) {
|
||||
CHECK( libeosio::wif_priv_encode(it->key, it->prefix) == it->expected );
|
||||
CHECK( libantelope::wif_priv_encode(it->key, it->prefix) == it->expected );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,20 +32,20 @@ TEST_CASE("WIF::wif_priv_encode [K1]") {
|
|||
struct testcase {
|
||||
std::string name;
|
||||
const std::string prefix;
|
||||
libeosio::ec_privkey_t key;
|
||||
libantelope::ec_privkey_t key;
|
||||
std::string expected;
|
||||
};
|
||||
|
||||
std::vector<struct testcase> tests {
|
||||
{ "one", libeosio::WIF_PVT_K1, { 0x0C, 0x28, 0xFC, 0xA3, 0x86, 0xC7, 0xA2, 0x27, 0x60, 0x0B, 0x2F, 0xE5, 0x0B, 0x7C, 0xAE, 0x11, 0xEC, 0x86, 0xD3, 0xBF, 0x1F, 0xBE, 0x47, 0x1B, 0xE8, 0x98, 0x27, 0xE1, 0x9D,0x72,0xAA,0x1D}, "PVT_K1_6Mcb23muAxyXaSMhmB6B1mqkvLdWhtuFZmnZsxDczHRvQdp32" },
|
||||
{ "two", libeosio::WIF_PVT_K1, { 0x9F, 0xE3, 0xE3, 0x2B, 0x3C, 0x4B, 0x6B, 0x91, 0x6E, 0x20, 0x6C, 0xB0, 0x91, 0xDF, 0x1F, 0x5E, 0x34, 0x32, 0x88, 0x0B, 0x41, 0x33, 0x86, 0xBD, 0xF2, 0x92, 0xFF, 0x23, 0x06, 0x43, 0xF2, 0x8C}, "PVT_K1_2DRBT8jmXT8k9ywNSSbufvhk1hLFhPzWJBpsE2jo12CDoFhcc1" },
|
||||
{ "three", libeosio::WIF_PVT_K1, { 0x59, 0x3A, 0x51, 0xB5, 0x5D, 0x56, 0xAA, 0xF0, 0x5B, 0xD9, 0xD1, 0x0E, 0x6B, 0x88, 0x6D, 0xF9, 0xC4, 0x37, 0x09, 0xB2, 0x4C, 0xEC, 0xBB, 0x63, 0x68, 0x92, 0xC2, 0x94, 0x31, 0x48, 0x71, 0x8C}, "PVT_K1_gJCsP4CwMv4gTkDXiZT8QFhs3NrSB7Sv22ANGrc8Svun9uC9C" }
|
||||
{ "one", libantelope::WIF_PVT_K1, { 0x0C, 0x28, 0xFC, 0xA3, 0x86, 0xC7, 0xA2, 0x27, 0x60, 0x0B, 0x2F, 0xE5, 0x0B, 0x7C, 0xAE, 0x11, 0xEC, 0x86, 0xD3, 0xBF, 0x1F, 0xBE, 0x47, 0x1B, 0xE8, 0x98, 0x27, 0xE1, 0x9D,0x72,0xAA,0x1D}, "PVT_K1_6Mcb23muAxyXaSMhmB6B1mqkvLdWhtuFZmnZsxDczHRvQdp32" },
|
||||
{ "two", libantelope::WIF_PVT_K1, { 0x9F, 0xE3, 0xE3, 0x2B, 0x3C, 0x4B, 0x6B, 0x91, 0x6E, 0x20, 0x6C, 0xB0, 0x91, 0xDF, 0x1F, 0x5E, 0x34, 0x32, 0x88, 0x0B, 0x41, 0x33, 0x86, 0xBD, 0xF2, 0x92, 0xFF, 0x23, 0x06, 0x43, 0xF2, 0x8C}, "PVT_K1_2DRBT8jmXT8k9ywNSSbufvhk1hLFhPzWJBpsE2jo12CDoFhcc1" },
|
||||
{ "three", libantelope::WIF_PVT_K1, { 0x59, 0x3A, 0x51, 0xB5, 0x5D, 0x56, 0xAA, 0xF0, 0x5B, 0xD9, 0xD1, 0x0E, 0x6B, 0x88, 0x6D, 0xF9, 0xC4, 0x37, 0x09, 0xB2, 0x4C, 0xEC, 0xBB, 0x63, 0x68, 0x92, 0xC2, 0x94, 0x31, 0x48, 0x71, 0x8C}, "PVT_K1_gJCsP4CwMv4gTkDXiZT8QFhs3NrSB7Sv22ANGrc8Svun9uC9C" }
|
||||
};
|
||||
|
||||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
|
||||
SUBCASE(it->name.c_str()) {
|
||||
CHECK( libeosio::wif_priv_encode(it->key, it->prefix) == it->expected );
|
||||
CHECK( libantelope::wif_priv_encode(it->key, it->prefix) == it->expected );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <libeosio/WIF.hpp>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
|
@ -8,7 +8,7 @@ TEST_CASE("WIF::wif_pub_decode [legacy]") {
|
|||
struct testcase {
|
||||
const char* name;
|
||||
std::string key;
|
||||
libeosio::ec_pubkey_t expected;
|
||||
libantelope::ec_pubkey_t expected;
|
||||
bool expectedRet;
|
||||
};
|
||||
|
||||
|
|
@ -24,9 +24,9 @@ TEST_CASE("WIF::wif_pub_decode [legacy]") {
|
|||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
|
||||
SUBCASE(it->name) {
|
||||
libeosio::ec_pubkey_t result = { 0x0 };
|
||||
libantelope::ec_pubkey_t result = { 0x0 };
|
||||
|
||||
CHECK( libeosio::wif_pub_decode(result, it->key) == it->expectedRet );
|
||||
CHECK( libantelope::wif_pub_decode(result, it->key) == it->expectedRet );
|
||||
CHECK( result == it->expected );
|
||||
}
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ TEST_CASE("WIF::wif_pub_decode [k1]") {
|
|||
struct testcase {
|
||||
const char* name;
|
||||
std::string key;
|
||||
libeosio::ec_pubkey_t expected;
|
||||
libantelope::ec_pubkey_t expected;
|
||||
bool expectedRet;
|
||||
};
|
||||
|
||||
|
|
@ -52,9 +52,9 @@ TEST_CASE("WIF::wif_pub_decode [k1]") {
|
|||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
|
||||
SUBCASE(it->name) {
|
||||
libeosio::ec_pubkey_t result = { 0x0 };
|
||||
libantelope::ec_pubkey_t result = { 0x0 };
|
||||
|
||||
CHECK( libeosio::wif_pub_decode(result, it->key) == it->expectedRet );
|
||||
CHECK( libantelope::wif_pub_decode(result, it->key) == it->expectedRet );
|
||||
CHECK( result == it->expected );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <libeosio/WIF.hpp>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
|
@ -8,20 +8,20 @@ TEST_CASE("WIF::wif_pub_encode [legacy]") {
|
|||
struct testcase {
|
||||
std::string name;
|
||||
const std::string prefix;
|
||||
libeosio::ec_pubkey_t key;
|
||||
libantelope::ec_pubkey_t key;
|
||||
std::string expected;
|
||||
};
|
||||
|
||||
std::vector<struct testcase> tests {
|
||||
{ "one", libeosio::WIF_PUB_LEG, { 0x03, 0x7a, 0x0e, 0x6b, 0xfd, 0xe4, 0xf1, 0xad, 0x36, 0x3f, 0x3a, 0xf9, 0xe0, 0x93, 0x63, 0x5a, 0xa9, 0x99, 0x21, 0x15, 0xbc, 0x23, 0x35, 0x75, 0x13, 0x69, 0x55, 0xee, 0x3f, 0xf8, 0xfd, 0x97, 0xec }, "EOS7kzJ5iFBmQWWT1LiWgAiocESD7TTNuuPCdYREUQysruq8VeFKy" },
|
||||
{ "two", libeosio::WIF_PUB_LEG, { 0x02, 0x5e, 0x94, 0xa5, 0xe7, 0x9f, 0x66, 0x37, 0x55, 0x7e, 0xc2, 0x28, 0x30, 0x40, 0x82, 0x9a, 0x38, 0x72, 0x10, 0x96, 0x6e, 0x15, 0xb7, 0xa5, 0x8a, 0x27, 0x9a, 0x71, 0x06, 0xa7, 0x64, 0x23, 0x30 }, "EOS5c9HkNCJLDebe2Wvapp8bpB38Pf1QWNpkrsFy3mshg7DZfPNeA" },
|
||||
{ "three", libeosio::WIF_PUB_LEG, { 0x03, 0xd4, 0xc6, 0x2a, 0xdc, 0x11, 0x1c, 0x65, 0x7a, 0x9f, 0x5b, 0xba, 0x96, 0x3f, 0xbb, 0x2a, 0x69, 0x2e, 0xc5, 0x4a, 0x48, 0x3b, 0xa3, 0x5f, 0x2a, 0x37, 0x6c, 0x59, 0x95, 0xb1, 0x95, 0x1c, 0xc9 }, "EOS8SwZMY8DChbbmRKS3wdHCAbv1VWgTRmQEDSaLyJk8pG4wm8BJF" }
|
||||
{ "one", libantelope::WIF_PUB_LEG, { 0x03, 0x7a, 0x0e, 0x6b, 0xfd, 0xe4, 0xf1, 0xad, 0x36, 0x3f, 0x3a, 0xf9, 0xe0, 0x93, 0x63, 0x5a, 0xa9, 0x99, 0x21, 0x15, 0xbc, 0x23, 0x35, 0x75, 0x13, 0x69, 0x55, 0xee, 0x3f, 0xf8, 0xfd, 0x97, 0xec }, "EOS7kzJ5iFBmQWWT1LiWgAiocESD7TTNuuPCdYREUQysruq8VeFKy" },
|
||||
{ "two", libantelope::WIF_PUB_LEG, { 0x02, 0x5e, 0x94, 0xa5, 0xe7, 0x9f, 0x66, 0x37, 0x55, 0x7e, 0xc2, 0x28, 0x30, 0x40, 0x82, 0x9a, 0x38, 0x72, 0x10, 0x96, 0x6e, 0x15, 0xb7, 0xa5, 0x8a, 0x27, 0x9a, 0x71, 0x06, 0xa7, 0x64, 0x23, 0x30 }, "EOS5c9HkNCJLDebe2Wvapp8bpB38Pf1QWNpkrsFy3mshg7DZfPNeA" },
|
||||
{ "three", libantelope::WIF_PUB_LEG, { 0x03, 0xd4, 0xc6, 0x2a, 0xdc, 0x11, 0x1c, 0x65, 0x7a, 0x9f, 0x5b, 0xba, 0x96, 0x3f, 0xbb, 0x2a, 0x69, 0x2e, 0xc5, 0x4a, 0x48, 0x3b, 0xa3, 0x5f, 0x2a, 0x37, 0x6c, 0x59, 0x95, 0xb1, 0x95, 0x1c, 0xc9 }, "EOS8SwZMY8DChbbmRKS3wdHCAbv1VWgTRmQEDSaLyJk8pG4wm8BJF" }
|
||||
};
|
||||
|
||||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
|
||||
SUBCASE(it->name.c_str()) {
|
||||
CHECK( libeosio::wif_pub_encode(it->key, it->prefix) == it->expected );
|
||||
CHECK( libantelope::wif_pub_encode(it->key, it->prefix) == it->expected );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ TEST_CASE("WIF::wif_pub_encode [custom prefix]") {
|
|||
|
||||
struct testcase {
|
||||
std::string name;
|
||||
libeosio::ec_pubkey_t key;
|
||||
libantelope::ec_pubkey_t key;
|
||||
std::string expected;
|
||||
};
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ TEST_CASE("WIF::wif_pub_encode [custom prefix]") {
|
|||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
|
||||
SUBCASE(it->name.c_str()) {
|
||||
CHECK( libeosio::wif_pub_encode(it->key, "ZYX") == it->expected );
|
||||
CHECK( libantelope::wif_pub_encode(it->key, "ZYX") == it->expected );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -52,20 +52,20 @@ TEST_CASE("WIF::wif_pub_encode [k1]") {
|
|||
struct testcase {
|
||||
std::string name;
|
||||
const std::string prefix;
|
||||
libeosio::ec_pubkey_t key;
|
||||
libantelope::ec_pubkey_t key;
|
||||
std::string expected;
|
||||
};
|
||||
|
||||
std::vector<struct testcase> tests {
|
||||
{ "one", libeosio::WIF_PUB_K1, { 0x03, 0x7a, 0x0e, 0x6b, 0xfd, 0xe4, 0xf1, 0xad, 0x36, 0x3f, 0x3a, 0xf9, 0xe0, 0x93, 0x63, 0x5a, 0xa9, 0x99, 0x21, 0x15, 0xbc, 0x23, 0x35, 0x75, 0x13, 0x69, 0x55, 0xee, 0x3f, 0xf8, 0xfd, 0x97, 0xec }, "PUB_K1_7kzJ5iFBmQWWT1LiWgAiocESD7TTNuuPCdYREUQysruq7AxzWu" },
|
||||
{ "two", libeosio::WIF_PUB_K1, { 0x02, 0x5e, 0x94, 0xa5, 0xe7, 0x9f, 0x66, 0x37, 0x55, 0x7e, 0xc2, 0x28, 0x30, 0x40, 0x82, 0x9a, 0x38, 0x72, 0x10, 0x96, 0x6e, 0x15, 0xb7, 0xa5, 0x8a, 0x27, 0x9a, 0x71, 0x06, 0xa7, 0x64, 0x23, 0x30 }, "PUB_K1_5c9HkNCJLDebe2Wvapp8bpB38Pf1QWNpkrsFy3mshg7DViSUUa" },
|
||||
{ "three", libeosio::WIF_PUB_K1, { 0x03, 0xd4, 0xc6, 0x2a, 0xdc, 0x11, 0x1c, 0x65, 0x7a, 0x9f, 0x5b, 0xba, 0x96, 0x3f, 0xbb, 0x2a, 0x69, 0x2e, 0xc5, 0x4a, 0x48, 0x3b, 0xa3, 0x5f, 0x2a, 0x37, 0x6c, 0x59, 0x95, 0xb1, 0x95, 0x1c, 0xc9 }, "PUB_K1_8SwZMY8DChbbmRKS3wdHCAbv1VWgTRmQEDSaLyJk8pG4wKBXpw" }
|
||||
{ "one", libantelope::WIF_PUB_K1, { 0x03, 0x7a, 0x0e, 0x6b, 0xfd, 0xe4, 0xf1, 0xad, 0x36, 0x3f, 0x3a, 0xf9, 0xe0, 0x93, 0x63, 0x5a, 0xa9, 0x99, 0x21, 0x15, 0xbc, 0x23, 0x35, 0x75, 0x13, 0x69, 0x55, 0xee, 0x3f, 0xf8, 0xfd, 0x97, 0xec }, "PUB_K1_7kzJ5iFBmQWWT1LiWgAiocESD7TTNuuPCdYREUQysruq7AxzWu" },
|
||||
{ "two", libantelope::WIF_PUB_K1, { 0x02, 0x5e, 0x94, 0xa5, 0xe7, 0x9f, 0x66, 0x37, 0x55, 0x7e, 0xc2, 0x28, 0x30, 0x40, 0x82, 0x9a, 0x38, 0x72, 0x10, 0x96, 0x6e, 0x15, 0xb7, 0xa5, 0x8a, 0x27, 0x9a, 0x71, 0x06, 0xa7, 0x64, 0x23, 0x30 }, "PUB_K1_5c9HkNCJLDebe2Wvapp8bpB38Pf1QWNpkrsFy3mshg7DViSUUa" },
|
||||
{ "three", libantelope::WIF_PUB_K1, { 0x03, 0xd4, 0xc6, 0x2a, 0xdc, 0x11, 0x1c, 0x65, 0x7a, 0x9f, 0x5b, 0xba, 0x96, 0x3f, 0xbb, 0x2a, 0x69, 0x2e, 0xc5, 0x4a, 0x48, 0x3b, 0xa3, 0x5f, 0x2a, 0x37, 0x6c, 0x59, 0x95, 0xb1, 0x95, 0x1c, 0xc9 }, "PUB_K1_8SwZMY8DChbbmRKS3wdHCAbv1VWgTRmQEDSaLyJk8pG4wKBXpw" }
|
||||
};
|
||||
|
||||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
|
||||
SUBCASE(it->name.c_str()) {
|
||||
CHECK( libeosio::wif_pub_encode(it->key, it->prefix) == it->expected );
|
||||
CHECK( libantelope::wif_pub_encode(it->key, it->prefix) == it->expected );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#include <libeosio/WIF.hpp>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ TEST_CASE("WIF::wif_sig_decode") {
|
|||
struct testcase {
|
||||
const char *name;
|
||||
std::string input;
|
||||
libeosio::ec_signature_t expected;
|
||||
libantelope::ec_signature_t expected;
|
||||
bool expectedRet;
|
||||
};
|
||||
|
||||
|
|
@ -87,9 +87,9 @@ TEST_CASE("WIF::wif_sig_decode") {
|
|||
|
||||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
SUBCASE(it->name) {
|
||||
libeosio::ec_signature_t result;
|
||||
libantelope::ec_signature_t result;
|
||||
|
||||
CHECK( libeosio::wif_sig_decode(result, it->input) == it->expectedRet );
|
||||
CHECK( libantelope::wif_sig_decode(result, it->input) == it->expectedRet );
|
||||
|
||||
if (it->expectedRet == true) {
|
||||
CHECK( result == it->expected );
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <libeosio/WIF.hpp>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ TEST_CASE("WIF::wif_sig_encode") {
|
|||
|
||||
struct testcase {
|
||||
const char *name;
|
||||
libeosio::ec_signature_t sig;
|
||||
libantelope::ec_signature_t sig;
|
||||
std::string expected;
|
||||
|
||||
};
|
||||
|
|
@ -47,7 +47,7 @@ TEST_CASE("WIF::wif_sig_encode") {
|
|||
|
||||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
SUBCASE(it->name) {
|
||||
CHECK( libeosio::wif_sig_encode(it->sig) == it->expected );
|
||||
CHECK( libantelope::wif_sig_encode(it->sig) == it->expected );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include <libeosio/base58.hpp>
|
||||
#include <libantelope/base58.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
|
@ -41,7 +41,7 @@ TEST_CASE("base58_decode") {
|
|||
|
||||
std::vector<unsigned char> expectedOut(it->expectedOut.begin(), it->expectedOut.end());
|
||||
|
||||
CHECK( libeosio::base58_decode(it->in, result) == it->expectedReturn );
|
||||
CHECK( libantelope::base58_decode(it->in, result) == it->expectedReturn );
|
||||
CHECK( result == expectedOut );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include <libeosio/base58.hpp>
|
||||
#include <libantelope/base58.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
|
@ -28,7 +28,7 @@ TEST_CASE("base58::base58_encode") {
|
|||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
|
||||
SUBCASE(it->name) {
|
||||
CHECK( libeosio::base58_encode(it->in) == it->expected );
|
||||
CHECK( libantelope::base58_encode(it->in) == it->expected );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include <libeosio/base58.hpp>
|
||||
#include <libantelope/base58.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
|
@ -23,7 +23,7 @@ TEST_CASE("base58::is_base58 [string]") {
|
|||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
|
||||
SUBCASE(it->name) {
|
||||
CHECK(libeosio::is_base58(it->input) == it->expected);
|
||||
CHECK(libantelope::is_base58(it->input) == it->expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ TEST_CASE("base58::is_base58 [char]") {
|
|||
for(int i = 0; i < valid_alphabet.length(); i++) {
|
||||
char ch = valid_alphabet[i];
|
||||
|
||||
CHECK(libeosio::is_base58(ch));
|
||||
CHECK(libantelope::is_base58(ch));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ TEST_CASE("base58::is_base58 [char]") {
|
|||
for(int i = 0; i < invalid_alphabet.length(); i++) {
|
||||
char ch = invalid_alphabet[i];
|
||||
|
||||
CHECK_FALSE(libeosio::is_base58(ch));
|
||||
CHECK_FALSE(libantelope::is_base58(ch));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,15 +22,15 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
#include <chrono>
|
||||
#include <libeosio/ec.hpp>
|
||||
#include <libeosio/WIF.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
|
||||
|
||||
std::chrono::duration<float> _run(size_t num_keys) {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
for(size_t i = 0; i < num_keys; i++) {
|
||||
struct libeosio::ec_keypair k;
|
||||
libeosio::ec_generate_key(&k);
|
||||
struct libantelope::ec_keypair k;
|
||||
libantelope::ec_generate_key(&k);
|
||||
}
|
||||
return std::chrono::steady_clock::now() - start;
|
||||
}
|
||||
|
|
@ -48,13 +48,13 @@ void test(size_t num_keys) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
libeosio::ec_init();
|
||||
libantelope::ec_init();
|
||||
|
||||
test(1000);
|
||||
test(10000);
|
||||
test(100000);
|
||||
|
||||
libeosio::ec_shutdown();
|
||||
libantelope::ec_shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ TEST_CASE("ec::ecdsa_recover") {
|
|||
|
||||
struct testcase {
|
||||
const char *name;
|
||||
libeosio::sha256_t dgst;
|
||||
libeosio::ec_signature_t sig;
|
||||
libeosio::ec_pubkey_t expected;
|
||||
libantelope::sha256_t dgst;
|
||||
libantelope::ec_signature_t sig;
|
||||
libantelope::ec_pubkey_t expected;
|
||||
int expectedRet;
|
||||
};
|
||||
|
||||
|
|
@ -85,19 +85,19 @@ TEST_CASE("ec::ecdsa_recover") {
|
|||
},
|
||||
};
|
||||
|
||||
libeosio::ec_init();
|
||||
libantelope::ec_init();
|
||||
|
||||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
SUBCASE(it->name) {
|
||||
libeosio::ec_pubkey_t result;
|
||||
libantelope::ec_pubkey_t result;
|
||||
|
||||
CHECK( libeosio::ecdsa_recover(&it->dgst, it->sig, result) == it->expectedRet );
|
||||
CHECK( libantelope::ecdsa_recover(&it->dgst, it->sig, result) == it->expectedRet );
|
||||
|
||||
if (it->expectedRet == 0) {
|
||||
CHECK( result == it->expected );
|
||||
}
|
||||
}
|
||||
}
|
||||
libeosio::ec_shutdown();
|
||||
libantelope::ec_shutdown();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ TEST_CASE("ec::ecdsa_sign") {
|
|||
|
||||
struct testcase {
|
||||
const char *name;
|
||||
libeosio::ec_privkey_t key;
|
||||
libeosio::ec_pubkey_t pub;
|
||||
libeosio::sha256_t dgst;
|
||||
libantelope::ec_privkey_t key;
|
||||
libantelope::ec_pubkey_t pub;
|
||||
libantelope::sha256_t dgst;
|
||||
};
|
||||
|
||||
std::vector<testcase> tests = {
|
||||
|
|
@ -92,24 +92,24 @@ TEST_CASE("ec::ecdsa_sign") {
|
|||
},
|
||||
};
|
||||
|
||||
libeosio::ec_init();
|
||||
libantelope::ec_init();
|
||||
|
||||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
SUBCASE(it->name) {
|
||||
libeosio::ec_signature_t result;
|
||||
libantelope::ec_signature_t result;
|
||||
|
||||
CHECK( libeosio::ecdsa_sign(it->key, &it->dgst, result) == 0 );
|
||||
CHECK( libantelope::ecdsa_sign(it->key, &it->dgst, result) == 0 );
|
||||
|
||||
// Need to use verify here as different implemententations produces different signatures.
|
||||
// (i have tested eosjs, eos-go and ofc libeosio)
|
||||
// (i have tested eosjs, eos-go and ofc libantelope)
|
||||
// However, the signatures are correct and can be validated by all implementations.
|
||||
//
|
||||
// Now, how do we know that ecdsa_verify is correct?
|
||||
// well, in escdsa_verify.cpp there are tests that checks hardcoded signatures generated by different implementations and should be fine.
|
||||
|
||||
CHECK( libeosio::ecdsa_verify(&it->dgst, result, it->pub) == 0);
|
||||
CHECK( libantelope::ecdsa_verify(&it->dgst, result, it->pub) == 0);
|
||||
}
|
||||
}
|
||||
libeosio::ec_shutdown();
|
||||
libantelope::ec_shutdown();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ TEST_CASE("ec::ecdsa_verify") {
|
|||
|
||||
struct testcase {
|
||||
const char *name;
|
||||
libeosio::sha256_t dgst;
|
||||
libeosio::ec_pubkey_t pubkey;
|
||||
libeosio::ec_signature_t sig;
|
||||
libantelope::sha256_t dgst;
|
||||
libantelope::ec_pubkey_t pubkey;
|
||||
libantelope::ec_signature_t sig;
|
||||
int expected;
|
||||
};
|
||||
|
||||
|
|
@ -176,14 +176,14 @@ TEST_CASE("ec::ecdsa_verify") {
|
|||
},
|
||||
};
|
||||
|
||||
libeosio::ec_init();
|
||||
libantelope::ec_init();
|
||||
|
||||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
SUBCASE(it->name) {
|
||||
CHECK( libeosio::ecdsa_verify(&it->dgst, it->sig, it->pubkey) == it->expected );
|
||||
CHECK( libantelope::ecdsa_verify(&it->dgst, it->sig, it->pubkey) == it->expected );
|
||||
}
|
||||
}
|
||||
|
||||
libeosio::ec_shutdown();
|
||||
libantelope::ec_shutdown();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
#include <libeosio/ec.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <doctest.h>
|
||||
|
||||
TEST_CASE("ec::generate") {
|
||||
|
||||
libeosio::ec_init();
|
||||
libantelope::ec_init();
|
||||
|
||||
libeosio::ec_pubkey_t result;
|
||||
libeosio::ec_keypair pair;
|
||||
CHECK(libeosio::ec_generate_key(&pair) == 0);
|
||||
libantelope::ec_pubkey_t result;
|
||||
libantelope::ec_keypair pair;
|
||||
CHECK(libantelope::ec_generate_key(&pair) == 0);
|
||||
|
||||
// Can't test much because... well the private key should be random :)
|
||||
// But alteast verify that the public key belongs to the private key.
|
||||
CHECK(libeosio::ec_get_publickey(&pair.secret, &result) == 0);
|
||||
CHECK(libantelope::ec_get_publickey(&pair.secret, &result) == 0);
|
||||
CHECK( result == pair.pub );
|
||||
|
||||
libeosio::ec_shutdown();
|
||||
libantelope::ec_shutdown();
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#include <libeosio/ec.hpp>
|
||||
#include <libeosio/WIF.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <vector>
|
||||
#include <doctest.h>
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ TEST_CASE("ec::pubkey") {
|
|||
|
||||
struct testcase {
|
||||
std::string name;
|
||||
libeosio::ec_privkey_t priv;
|
||||
libeosio::ec_pubkey_t expected;
|
||||
libantelope::ec_privkey_t priv;
|
||||
libantelope::ec_pubkey_t expected;
|
||||
};
|
||||
|
||||
std::vector<struct testcase> tests {
|
||||
|
|
@ -125,16 +125,16 @@ TEST_CASE("ec::pubkey") {
|
|||
}
|
||||
};
|
||||
|
||||
libeosio::ec_init();
|
||||
libantelope::ec_init();
|
||||
|
||||
for(auto it = tests.begin(); it != tests.end(); it++) {
|
||||
|
||||
SUBCASE(it->name.c_str()) {
|
||||
libeosio::ec_pubkey_t result;
|
||||
CHECK( libeosio::ec_get_publickey(&it->priv, &result) == 0 );
|
||||
libantelope::ec_pubkey_t result;
|
||||
CHECK( libantelope::ec_get_publickey(&it->priv, &result) == 0 );
|
||||
CHECK( result == it->expected );
|
||||
}
|
||||
}
|
||||
|
||||
libeosio::ec_shutdown();
|
||||
libantelope::ec_shutdown();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue