aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-01-06 19:49:52 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-01-22 23:17:31 +0000
commit99d946e6191056f747225d36a2408085624b516e (patch)
tree9b81751a703e40d188c26d035edb34e945e28422 /tests
parentringct: save 3 bytes on bulletproof size (diff)
downloadmonero-99d946e6191056f747225d36a2408085624b516e.tar.xz
ringct: encode 8 byte amount, saving 24 bytes per output
Found by knaccc
Diffstat (limited to 'tests')
-rw-r--r--tests/core_tests/multisig.cpp2
-rw-r--r--tests/unit_tests/device.cpp22
-rw-r--r--tests/unit_tests/ringct.cpp4
3 files changed, 22 insertions, 6 deletions
diff --git a/tests/core_tests/multisig.cpp b/tests/core_tests/multisig.cpp
index 7dd6a89e2..37fda6643 100644
--- a/tests/core_tests/multisig.cpp
+++ b/tests/core_tests/multisig.cpp
@@ -455,7 +455,7 @@ bool gen_multisig_tx_validation_base::generate_with(std::vector<test_event_entry
crypto::secret_key scalar1;
crypto::derivation_to_scalar(derivation, n, scalar1);
rct::ecdhTuple ecdh_info = tx.rct_signatures.ecdhInfo[n];
- rct::ecdhDecode(ecdh_info, rct::sk2rct(scalar1));
+ rct::ecdhDecode(ecdh_info, rct::sk2rct(scalar1), tx.rct_signatures.type == rct::RCTTypeBulletproof2);
rct::key C = tx.rct_signatures.outPk[n].mask;
rct::addKeys2(Ctmp, ecdh_info.mask, ecdh_info.amount, rct::H);
CHECK_AND_ASSERT_MES(rct::equalKeys(C, Ctmp), false, "Failed to decode amount");
diff --git a/tests/unit_tests/device.cpp b/tests/unit_tests/device.cpp
index 50ccec9fa..3ae748145 100644
--- a/tests/unit_tests/device.cpp
+++ b/tests/unit_tests/device.cpp
@@ -114,7 +114,7 @@ TEST(device, ops)
ASSERT_EQ(ki0, ki1);
}
-TEST(device, ecdh)
+TEST(device, ecdh32)
{
hw::core::device_default dev;
rct::ecdhTuple tuple, tuple2;
@@ -123,8 +123,24 @@ TEST(device, ecdh)
tuple.amount = rct::skGen();
tuple.senderPk = rct::pkGen();
tuple2 = tuple;
- dev.ecdhEncode(tuple, key);
- dev.ecdhDecode(tuple, key);
+ dev.ecdhEncode(tuple, key, false);
+ dev.ecdhDecode(tuple, key, false);
+ ASSERT_EQ(tuple2.mask, tuple.mask);
+ ASSERT_EQ(tuple2.amount, tuple.amount);
+ ASSERT_EQ(tuple2.senderPk, tuple.senderPk);
+}
+
+TEST(device, ecdh8)
+{
+ hw::core::device_default dev;
+ rct::ecdhTuple tuple, tuple2;
+ rct::key key = rct::skGen();
+ tuple.mask = rct::skGen();
+ tuple.amount = rct::skGen();
+ tuple.senderPk = rct::pkGen();
+ tuple2 = tuple;
+ dev.ecdhEncode(tuple, key, true);
+ dev.ecdhDecode(tuple, key, true);
ASSERT_EQ(tuple2.mask, tuple.mask);
ASSERT_EQ(tuple2.amount, tuple.amount);
ASSERT_EQ(tuple2.senderPk, tuple.senderPk);
diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp
index ec704daa1..905b8471a 100644
--- a/tests/unit_tests/ringct.cpp
+++ b/tests/unit_tests/ringct.cpp
@@ -843,8 +843,8 @@ TEST(ringct, ecdh_roundtrip)
t0.amount = d2h(amount);
t1 = t0;
- ecdhEncode(t1, k);
- ecdhDecode(t1, k);
+ ecdhEncode(t1, k, true);
+ ecdhDecode(t1, k, true);
ASSERT_TRUE(t0.mask == t1.mask);
ASSERT_TRUE(equalKeys(t0.mask, t1.mask));
ASSERT_TRUE(t0.amount == t1.amount);