diff options
author | Determinant <[email protected]> | 2018-07-16 04:13:57 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2018-07-16 04:13:57 -0400 |
commit | efd49718dfbb6c1f329e72026770b07a67348168 (patch) | |
tree | 4f29a41480c6ad42ad0fcf2b861c7acc7368b937 /test/test_secp256k1.cpp |
init
Diffstat (limited to 'test/test_secp256k1.cpp')
-rw-r--r-- | test/test_secp256k1.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
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)); +} |