summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Taaki <genjix@riseup.net>2014-05-08 17:03:46 (GMT)
committer Amir Taaki <genjix@riseup.net>2014-05-08 17:04:22 (GMT)
commitfa0d63b155c95656a969e6e469016b553fe84b78 (patch)
tree5ca344be1bdc05f95d3ecddaf3acab81ddaaa98c
parent3d49d0e6092c6f4a16a267ea55d8aa24cd12fa27 (diff)
add ec-tweak-add subcommand.
-rw-r--r--src/Makefile.am6
-rw-r--r--src/ec-tweak-add.cpp34
-rwxr-xr-xsrc/sx.py8
3 files changed, 41 insertions, 7 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index a474911..4fb2924 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,7 +10,7 @@ corebin_PROGRAMS = \
sx-ripemd-hash sx-initchain sx-secret-to-wif sx-wif-to-secret \
sx-hd-seed sx-hd-priv sx-hd-pub sx-hd-to-address sx-hd-to-wif \
sx-stealth-addr sx-stealth-show-addr \
- sx-ec-multiply sx-ec-add
+ sx-ec-multiply sx-ec-tweak-add
corebin_SCRIPTS = sx-qrcode sx-watchtx sx-btc sx-satoshi sx-bci-history \
sx-get-utxo sx-bci-fetch-last-height sx-sendtx-bci sx-base58check-encode \
sx-base58check-decode sx-embed-addr sx-blke-fetch-transaction \
@@ -48,8 +48,8 @@ corebin_PROGRAMS += \
AM_CPPFLAGS += ${libobelisk_CFLAGS} -DSYSCONFDIR=\"${sysconfdir}\"
endif
-sx_ec_add_SOURCES = ec-add.cpp
-sx_ec_add_LDADD = ${libbitcoin_LIBS} ${libwallet_LIBS}
+sx_ec_tweak_add_SOURCES = ec-tweak-add.cpp
+sx_ec_tweak_add_LDADD = ${libbitcoin_LIBS} ${libwallet_LIBS}
sx_ec_multiply_SOURCES = ec-multiply.cpp
sx_ec_multiply_LDADD = ${libbitcoin_LIBS} ${libwallet_LIBS}
diff --git a/src/ec-tweak-add.cpp b/src/ec-tweak-add.cpp
new file mode 100644
index 0000000..7d7b658
--- /dev/null
+++ b/src/ec-tweak-add.cpp
@@ -0,0 +1,34 @@
+#include "ec_util.hpp"
+
+int main(int argc, char** argv)
+{
+ if (argc != 3)
+ {
+ std::cerr << "Usage: sx ec-multiply INTEGER POINT" << std::endl;
+ return -1;
+ }
+ ec_secret int_part = null_hash;
+ ec_point point_part;
+ for (size_t i = 1; i < argc; ++i)
+ {
+ const auto arg = argv[i];
+ if (set_ec_secret(int_part, arg))
+ continue;
+ if (set_ec_point(point_part, arg))
+ continue;
+ }
+ if (int_part == null_hash || point_part.empty())
+ {
+ std::cerr << "sx: Unable to read input values." << std::endl;
+ return -1;
+ }
+ bool success = (point_part += int_part);
+ if (!success)
+ {
+ std::cerr << "sx: Out of range." << std::endl;
+ return -1;
+ }
+ std::cout << point_part << std::endl;
+ return 0;
+}
+
diff --git a/src/sx.py b/src/sx.py
index 017beb1..4a70376 100755
--- a/src/sx.py
+++ b/src/sx.py
@@ -896,14 +896,14 @@ Multiply an integer and a point together.\
"""
),
-"ec-add": (
+"ec-tweak-add": (
"EC MATH",
-"Add two points together.",
+"Calculate the result of POINT + INTEGER * G.",
"""\
-Usage: sx ec-add POINT POINT
+Usage: sx ec-tweak-add INTEGER POINT
-Add two points together.\
+Calculate the result of POINT + INTEGER * G.\
"""
),