mirror of
https://github.com/monero-project/monero.git
synced 2026-01-26 06:14:29 +01:00
ringct: remove unused range proof types and fix serialization bug
This commit is contained in:
@@ -413,8 +413,6 @@ namespace tx {
|
||||
static unsigned get_rsig_type(const rct::RCTConfig &rct_config, size_t num_outputs){
|
||||
if (rct_config.range_proof_type == rct::RangeProofBorromean){
|
||||
return rct::RangeProofBorromean;
|
||||
} else if (num_outputs > BULLETPROOF_MAX_OUTPUTS){
|
||||
return rct::RangeProofMultiOutputBulletproof;
|
||||
} else {
|
||||
return rct::RangeProofPaddedBulletproof;
|
||||
}
|
||||
@@ -424,7 +422,7 @@ namespace tx {
|
||||
size_t amount_batched = 0;
|
||||
|
||||
while(amount_batched < num_outputs){
|
||||
if (rsig_type == rct::RangeProofBorromean || rsig_type == rct::RangeProofBulletproof) {
|
||||
if (rsig_type == rct::RangeProofBorromean) {
|
||||
batches.push_back(1);
|
||||
amount_batched += 1;
|
||||
|
||||
@@ -435,15 +433,6 @@ namespace tx {
|
||||
batches.push_back(num_outputs);
|
||||
amount_batched += num_outputs;
|
||||
|
||||
} else if (rsig_type == rct::RangeProofMultiOutputBulletproof){
|
||||
size_t batch_size = 1;
|
||||
while (batch_size * 2 + amount_batched <= num_outputs && batch_size * 2 <= BULLETPROOF_MAX_OUTPUTS){
|
||||
batch_size *= 2;
|
||||
}
|
||||
batch_size = std::min(batch_size, num_outputs - amount_batched);
|
||||
batches.push_back(batch_size);
|
||||
amount_batched += batch_size;
|
||||
|
||||
} else {
|
||||
throw std::invalid_argument("Unknown rsig type");
|
||||
}
|
||||
|
||||
@@ -1166,9 +1166,8 @@ namespace rct {
|
||||
if (bulletproof_or_plus)
|
||||
{
|
||||
const bool plus = is_rct_bulletproof_plus(rv.type);
|
||||
size_t n_amounts = outamounts.size();
|
||||
size_t amounts_proved = 0;
|
||||
if (rct_config.range_proof_type == RangeProofPaddedBulletproof)
|
||||
CHECK_AND_ASSERT_THROW_MES(rct_config.range_proof_type == rct::RangeProofPaddedBulletproof,
|
||||
"Unsupported range proof type: " << rct_config.range_proof_type);
|
||||
{
|
||||
rct::keyV C, masks;
|
||||
if (hwdev.get_mode() == hw::device::TRANSACTION_CREATE_FAKE)
|
||||
@@ -1199,45 +1198,6 @@ namespace rct {
|
||||
outSk[i].mask = masks[i];
|
||||
}
|
||||
}
|
||||
else while (amounts_proved < n_amounts)
|
||||
{
|
||||
size_t batch_size = 1;
|
||||
if (rct_config.range_proof_type == RangeProofMultiOutputBulletproof)
|
||||
while (batch_size * 2 + amounts_proved <= n_amounts && batch_size * 2 <= (plus ? BULLETPROOF_PLUS_MAX_OUTPUTS : BULLETPROOF_MAX_OUTPUTS))
|
||||
batch_size *= 2;
|
||||
rct::keyV C, masks;
|
||||
std::vector<uint64_t> batch_amounts(batch_size);
|
||||
for (i = 0; i < batch_size; ++i)
|
||||
batch_amounts[i] = outamounts[i + amounts_proved];
|
||||
if (hwdev.get_mode() == hw::device::TRANSACTION_CREATE_FAKE)
|
||||
{
|
||||
// use a fake bulletproof for speed
|
||||
if (plus)
|
||||
rv.p.bulletproofs_plus.push_back(make_dummy_bulletproof_plus(batch_amounts, C, masks));
|
||||
else
|
||||
rv.p.bulletproofs.push_back(make_dummy_bulletproof(batch_amounts, C, masks));
|
||||
}
|
||||
else
|
||||
{
|
||||
const epee::span<const key> keys{&amount_keys[amounts_proved], batch_size};
|
||||
if (plus)
|
||||
rv.p.bulletproofs_plus.push_back(proveRangeBulletproofPlus(C, masks, batch_amounts, keys, hwdev));
|
||||
else
|
||||
rv.p.bulletproofs.push_back(proveRangeBulletproof(C, masks, batch_amounts, keys, hwdev));
|
||||
#ifdef DBG
|
||||
if (plus)
|
||||
CHECK_AND_ASSERT_THROW_MES(verBulletproofPlus(rv.p.bulletproofs_plus.back()), "verBulletproofPlus failed on newly created proof");
|
||||
else
|
||||
CHECK_AND_ASSERT_THROW_MES(verBulletproof(rv.p.bulletproofs.back()), "verBulletproof failed on newly created proof");
|
||||
#endif
|
||||
}
|
||||
for (i = 0; i < batch_size; ++i)
|
||||
{
|
||||
rv.outPk[i + amounts_proved].mask = rct::scalarmult8(C[i]);
|
||||
outSk[i + amounts_proved].mask = masks[i];
|
||||
}
|
||||
amounts_proved += batch_size;
|
||||
}
|
||||
}
|
||||
|
||||
key sumout = zero();
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace rct {
|
||||
RCTTypeCLSAG = 5,
|
||||
RCTTypeBulletproofPlus = 6,
|
||||
};
|
||||
enum RangeProofType { RangeProofBorromean, RangeProofBulletproof, RangeProofMultiOutputBulletproof, RangeProofPaddedBulletproof };
|
||||
enum RangeProofType { RangeProofBorromean, RangeProofPaddedBulletproof };
|
||||
struct RCTConfig {
|
||||
RangeProofType range_proof_type;
|
||||
int bp_version;
|
||||
|
||||
@@ -2509,7 +2509,7 @@ namespace boost
|
||||
bool use_bulletproofs = x.rct_config.range_proof_type != rct::RangeProofBorromean;
|
||||
a & use_bulletproofs;
|
||||
if (!typename Archive::is_saving())
|
||||
x.rct_config = { use_bulletproofs ? rct::RangeProofBulletproof : rct::RangeProofBorromean, 0 };
|
||||
x.rct_config = { use_bulletproofs ? rct::RangeProofPaddedBulletproof : rct::RangeProofBorromean, 0 };
|
||||
return;
|
||||
}
|
||||
a & x.rct_config;
|
||||
|
||||
Reference in New Issue
Block a user