mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Merge pull request #5052
b6534c40
ringct: remove unused senderPk from ecdhTuple (moneromooo-monero)7d375981
ringct: the commitment mask is now deterministic (moneromooo-monero)99d946e6
ringct: encode 8 byte amount, saving 24 bytes per output (moneromooo-monero)cdc3ccec
ringct: save 3 bytes on bulletproof size (moneromooo-monero)f931e16c
add a bulletproof version, new bulletproof type, and rct config (moneromooo-monero)
This commit is contained in:
commit
0daa00e035
32 changed files with 305 additions and 215 deletions
|
@ -131,7 +131,8 @@ TEST(bulletproofs, multi_splitting)
|
|||
}
|
||||
|
||||
rct::ctkeyV outSk;
|
||||
rct::rctSig s = rct::genRctSimple(rct::zero(), sc, destinations, inamounts, outamounts, available, mixRing, amount_keys, NULL, NULL, index, outSk, rct::RangeProofPaddedBulletproof, hw::get_device("default"));
|
||||
rct::RCTConfig rct_config { rct::RangeProofPaddedBulletproof, 0 };
|
||||
rct::rctSig s = rct::genRctSimple(rct::zero(), sc, destinations, inamounts, outamounts, available, mixRing, amount_keys, NULL, NULL, index, outSk, rct_config, hw::get_device("default"));
|
||||
ASSERT_TRUE(rct::verRctSimple(s));
|
||||
for (size_t i = 0; i < n_outputs; ++i)
|
||||
{
|
||||
|
|
|
@ -114,18 +114,17 @@ TEST(device, ops)
|
|||
ASSERT_EQ(ki0, ki1);
|
||||
}
|
||||
|
||||
TEST(device, ecdh)
|
||||
TEST(device, ecdh32)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace
|
|||
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
|
||||
subaddresses[from.m_account_address.m_spend_public_key] = {0,0};
|
||||
|
||||
if (!cryptonote::construct_tx_and_get_tx_key(from, subaddresses, actual_sources, to, boost::none, {}, tx, 0, tx_key, extra_keys, rct, bulletproof ? rct::RangeProofBulletproof : rct::RangeProofBorromean))
|
||||
if (!cryptonote::construct_tx_and_get_tx_key(from, subaddresses, actual_sources, to, boost::none, {}, tx, 0, tx_key, extra_keys, rct, { bulletproof ? rct::RangeProofBulletproof : rct::RangeProofBorromean, bulletproof ? 2 : 0 }))
|
||||
throw std::runtime_error{"transaction construction error"};
|
||||
|
||||
return tx;
|
||||
|
|
|
@ -171,8 +171,10 @@ TEST(ringct, range_proofs)
|
|||
skpkGen(Sk, Pk);
|
||||
destinations.push_back(Pk);
|
||||
|
||||
const rct::RCTConfig rct_config { RangeProofBorromean, 0 };
|
||||
|
||||
//compute rct data with mixin 500
|
||||
rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
|
||||
rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, rct_config, hw::get_device("default"));
|
||||
|
||||
//verify rct data
|
||||
ASSERT_TRUE(verRct(s));
|
||||
|
@ -189,7 +191,7 @@ TEST(ringct, range_proofs)
|
|||
|
||||
|
||||
//compute rct data with mixin 500
|
||||
s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
|
||||
s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, rct_config, hw::get_device("default"));
|
||||
|
||||
//verify rct data
|
||||
ASSERT_FALSE(verRct(s));
|
||||
|
@ -235,8 +237,10 @@ TEST(ringct, range_proofs_with_fee)
|
|||
skpkGen(Sk, Pk);
|
||||
destinations.push_back(Pk);
|
||||
|
||||
const rct::RCTConfig rct_config { RangeProofBorromean, 0 };
|
||||
|
||||
//compute rct data with mixin 500
|
||||
rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
|
||||
rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, rct_config, hw::get_device("default"));
|
||||
|
||||
//verify rct data
|
||||
ASSERT_TRUE(verRct(s));
|
||||
|
@ -253,7 +257,7 @@ TEST(ringct, range_proofs_with_fee)
|
|||
|
||||
|
||||
//compute rct data with mixin 500
|
||||
s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
|
||||
s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, rct_config, hw::get_device("default"));
|
||||
|
||||
//verify rct data
|
||||
ASSERT_FALSE(verRct(s));
|
||||
|
@ -311,7 +315,8 @@ TEST(ringct, simple)
|
|||
//compute sig with mixin 2
|
||||
xmr_amount txnfee = 1;
|
||||
|
||||
rctSig s = genRctSimple(message, sc, pc, destinations,inamounts, outamounts, amount_keys, NULL, NULL, txnfee, 2, hw::get_device("default"));
|
||||
const rct::RCTConfig rct_config { RangeProofBorromean, 0 };
|
||||
rctSig s = genRctSimple(message, sc, pc, destinations,inamounts, outamounts, amount_keys, NULL, NULL, txnfee, 2, rct_config, hw::get_device("default"));
|
||||
|
||||
//verify ring ct signature
|
||||
ASSERT_TRUE(verRctSimple(s));
|
||||
|
@ -345,7 +350,8 @@ static rct::rctSig make_sample_rct_sig(int n_inputs, const uint64_t input_amount
|
|||
}
|
||||
}
|
||||
|
||||
return genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
|
||||
const rct::RCTConfig rct_config { RangeProofBorromean, 0 };
|
||||
return genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, rct_config, hw::get_device("default"));
|
||||
}
|
||||
|
||||
static rct::rctSig make_sample_simple_rct_sig(int n_inputs, const uint64_t input_amounts[], int n_outputs, const uint64_t output_amounts[], uint64_t fee)
|
||||
|
@ -371,7 +377,8 @@ static rct::rctSig make_sample_simple_rct_sig(int n_inputs, const uint64_t input
|
|||
destinations.push_back(Pk);
|
||||
}
|
||||
|
||||
return genRctSimple(rct::zero(), sc, pc, destinations, inamounts, outamounts, amount_keys, NULL, NULL, fee, 3, hw::get_device("default"));
|
||||
const rct::RCTConfig rct_config { RangeProofBorromean, 0 };
|
||||
return genRctSimple(rct::zero(), sc, pc, destinations, inamounts, outamounts, amount_keys, NULL, NULL, fee, 3, rct_config, hw::get_device("default"));
|
||||
}
|
||||
|
||||
static bool range_proof_test(bool expected_valid,
|
||||
|
@ -824,27 +831,6 @@ TEST(ringct, HPow2)
|
|||
|
||||
static const xmr_amount test_amounts[]={0, 1, 2, 3, 4, 5, 10000, 10000000000000000000ull, 10203040506070809000ull, 123456789123456789};
|
||||
|
||||
TEST(ringct, ecdh_roundtrip)
|
||||
{
|
||||
key k;
|
||||
ecdhTuple t0, t1;
|
||||
|
||||
for (auto amount: test_amounts) {
|
||||
skGen(k);
|
||||
|
||||
t0.mask = skGen();
|
||||
t0.amount = d2h(amount);
|
||||
|
||||
t1 = t0;
|
||||
ecdhEncode(t1, k);
|
||||
ecdhDecode(t1, k);
|
||||
ASSERT_TRUE(t0.mask == t1.mask);
|
||||
ASSERT_TRUE(equalKeys(t0.mask, t1.mask));
|
||||
ASSERT_TRUE(t0.amount == t1.amount);
|
||||
ASSERT_TRUE(equalKeys(t0.amount, t1.amount));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ringct, d2h)
|
||||
{
|
||||
key k, P1;
|
||||
|
|
|
@ -550,12 +550,10 @@ TEST(Serialization, serializes_ringct_types)
|
|||
|
||||
ecdh0.mask = rct::skGen();
|
||||
ecdh0.amount = rct::skGen();
|
||||
ecdh0.senderPk = rct::skGen();
|
||||
ASSERT_TRUE(serialization::dump_binary(ecdh0, blob));
|
||||
ASSERT_TRUE(serialization::parse_binary(blob, ecdh1));
|
||||
ASSERT_TRUE(!memcmp(&ecdh0.mask, &ecdh1.mask, sizeof(ecdh0.mask)));
|
||||
ASSERT_TRUE(!memcmp(&ecdh0.amount, &ecdh1.amount, sizeof(ecdh0.amount)));
|
||||
// senderPk is not serialized
|
||||
|
||||
for (size_t n = 0; n < 64; ++n)
|
||||
{
|
||||
|
@ -591,7 +589,8 @@ TEST(Serialization, serializes_ringct_types)
|
|||
rct::skpkGen(Sk, Pk);
|
||||
destinations.push_back(Pk);
|
||||
//compute rct data with mixin 500
|
||||
s0 = rct::genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
|
||||
const rct::RCTConfig rct_config{ rct::RangeProofPaddedBulletproof, 0 };
|
||||
s0 = rct::genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, rct_config, hw::get_device("default"));
|
||||
|
||||
mg0 = s0.p.MGs[0];
|
||||
ASSERT_TRUE(serialization::dump_binary(mg0, blob));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue