From efd49718dfbb6c1f329e72026770b07a67348168 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 16 Jul 2018 04:13:57 -0400 Subject: init --- test/CMakeLists.txt | 4 ++++ test/test_secp256k1.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/CMakeLists.txt create mode 100644 test/test_secp256k1.cpp (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..60ffdc3 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,4 @@ +include_directories(../src/ + ../salticidae/include/) +add_executable(test_secp256k1 test_secp256k1.cpp) +target_link_libraries(test_secp256k1 hotstuff) diff --git a/test/test_secp256k1.cpp b/test/test_secp256k1.cpp new file mode 100644 index 0000000..0991b6e --- /dev/null +++ b/test/test_secp256k1.cpp @@ -0,0 +1,33 @@ +#include "crypto.h" + +using namespace hotstuff; + +int main() { + PrivKeySecp256k1 p; + p.from_hex("4aede145d13021fb43c938bced67511a7740c05786d3e0b94ffbdaa7f15afc57"); + pubkey_bt pub = p.get_pubkey(); + printf("%s\n", get_hex(*pub).c_str()); + DataStream s; + s << *pub; + PubKeySecp256k1 pub2; + s >> pub2; + printf("%s\n", get_hex(pub2).c_str()); + SigSecp256k1 sig; + sig.sign(bytearray_t(32), p); + printf("%s\n", get_hex(sig).c_str()); + s << sig; + SigSecp256k1 sig2(secp256k1_default_verify_ctx); + s >> sig2; + bytearray_t msg = bytearray_t(32); + msg[0] = 1; + printf("%d %d\n", sig2.verify(bytearray_t(32), pub2), + sig2.verify(msg, pub2)); + p.from_rand(); + printf("%s\n", get_hex(p).c_str()); + sig.sign(msg, p); + printf("%s\n", get_hex(sig).c_str()); + s << sig; + s >> sig2; + printf("%d %d\n", sig2.verify(msg, PubKeySecp256k1(p)), + sig2.verify(msg, pub2)); +} -- cgit v1.2.3