ringct: encode 8 byte amount, saving 24 bytes per output

Found by knaccc
This commit is contained in:
moneromooo-monero 2019-01-06 19:49:52 +00:00
parent 77f8f45459
commit 6ba3a11637
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
14 changed files with 93 additions and 34 deletions

View file

@ -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);

View file

@ -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);