plug bulletproofs plus into consensus
This commit is contained in:
+74
-17
@@ -196,6 +196,7 @@ namespace rct {
|
||||
case RCTTypeBulletproof:
|
||||
case RCTTypeBulletproof2:
|
||||
case RCTTypeCLSAG:
|
||||
case RCTTypeBulletproofPlus:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -215,6 +216,17 @@ namespace rct {
|
||||
}
|
||||
}
|
||||
|
||||
bool is_rct_bulletproof_plus(int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RCTTypeBulletproofPlus:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_rct_borromean(int type)
|
||||
{
|
||||
switch (type)
|
||||
@@ -227,19 +239,34 @@ namespace rct {
|
||||
}
|
||||
}
|
||||
|
||||
size_t n_bulletproof_amounts(const Bulletproof &proof)
|
||||
bool is_rct_clsag(int type)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(proof.L.size() >= 6, 0, "Invalid bulletproof L size");
|
||||
CHECK_AND_ASSERT_MES(proof.L.size() == proof.R.size(), 0, "Mismatched bulletproof L/R size");
|
||||
static const size_t extra_bits = 4;
|
||||
static_assert((1 << extra_bits) == BULLETPROOF_MAX_OUTPUTS, "log2(BULLETPROOF_MAX_OUTPUTS) is out of date");
|
||||
CHECK_AND_ASSERT_MES(proof.L.size() <= 6 + extra_bits, 0, "Invalid bulletproof L size");
|
||||
CHECK_AND_ASSERT_MES(proof.V.size() <= (1u<<(proof.L.size()-6)), 0, "Invalid bulletproof V/L");
|
||||
CHECK_AND_ASSERT_MES(proof.V.size() * 2 > (1u<<(proof.L.size()-6)), 0, "Invalid bulletproof V/L");
|
||||
CHECK_AND_ASSERT_MES(proof.V.size() > 0, 0, "Empty bulletproof");
|
||||
return proof.V.size();
|
||||
switch (type)
|
||||
{
|
||||
case RCTTypeCLSAG:
|
||||
case RCTTypeBulletproofPlus:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t n_bulletproof_amounts_base(const size_t L_size, const size_t R_size, const size_t V_size, const size_t max_outputs)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(L_size >= 6, 0, "Invalid bulletproof L size");
|
||||
CHECK_AND_ASSERT_MES(L_size == R_size, 0, "Mismatched bulletproof L/R size");
|
||||
static const size_t extra_bits = 4;
|
||||
CHECK_AND_ASSERT_MES((1 << extra_bits) == max_outputs, 0, "log2(max_outputs) is out of date");
|
||||
CHECK_AND_ASSERT_MES(L_size <= 6 + extra_bits, 0, "Invalid bulletproof L size");
|
||||
CHECK_AND_ASSERT_MES(V_size <= (1u<<(L_size-6)), 0, "Invalid bulletproof V/L");
|
||||
CHECK_AND_ASSERT_MES(V_size * 2 > (1u<<(L_size-6)), 0, "Invalid bulletproof V/L");
|
||||
CHECK_AND_ASSERT_MES(V_size > 0, 0, "Empty bulletproof");
|
||||
return V_size;
|
||||
}
|
||||
|
||||
size_t n_bulletproof_amounts(const Bulletproof &proof) { return n_bulletproof_amounts_base(proof.L.size(), proof.R.size(), proof.V.size(), BULLETPROOF_MAX_OUTPUTS); }
|
||||
size_t n_bulletproof_plus_amounts(const BulletproofPlus &proof) { return n_bulletproof_amounts_base(proof.L.size(), proof.R.size(), proof.V.size(), BULLETPROOF_PLUS_MAX_OUTPUTS); }
|
||||
|
||||
size_t n_bulletproof_amounts(const std::vector<Bulletproof> &proofs)
|
||||
{
|
||||
size_t n = 0;
|
||||
@@ -254,16 +281,32 @@ namespace rct {
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t n_bulletproof_max_amounts(const Bulletproof &proof)
|
||||
size_t n_bulletproof_plus_amounts(const std::vector<BulletproofPlus> &proofs)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(proof.L.size() >= 6, 0, "Invalid bulletproof L size");
|
||||
CHECK_AND_ASSERT_MES(proof.L.size() == proof.R.size(), 0, "Mismatched bulletproof L/R size");
|
||||
static const size_t extra_bits = 4;
|
||||
static_assert((1 << extra_bits) == BULLETPROOF_MAX_OUTPUTS, "log2(BULLETPROOF_MAX_OUTPUTS) is out of date");
|
||||
CHECK_AND_ASSERT_MES(proof.L.size() <= 6 + extra_bits, 0, "Invalid bulletproof L size");
|
||||
return 1 << (proof.L.size() - 6);
|
||||
size_t n = 0;
|
||||
for (const BulletproofPlus &proof: proofs)
|
||||
{
|
||||
size_t n2 = n_bulletproof_plus_amounts(proof);
|
||||
CHECK_AND_ASSERT_MES(n2 < std::numeric_limits<uint32_t>::max() - n, 0, "Invalid number of bulletproofs");
|
||||
if (n2 == 0)
|
||||
return 0;
|
||||
n += n2;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static size_t n_bulletproof_max_amounts_base(size_t L_size, size_t R_size, size_t max_outputs)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(L_size >= 6, 0, "Invalid bulletproof L size");
|
||||
CHECK_AND_ASSERT_MES(L_size == R_size, 0, "Mismatched bulletproof L/R size");
|
||||
static const size_t extra_bits = 4;
|
||||
CHECK_AND_ASSERT_MES((1 << extra_bits) == max_outputs, 0, "log2(max_outputs) is out of date");
|
||||
CHECK_AND_ASSERT_MES(L_size <= 6 + extra_bits, 0, "Invalid bulletproof L size");
|
||||
return 1 << (L_size - 6);
|
||||
}
|
||||
size_t n_bulletproof_max_amounts(const Bulletproof &proof) { return n_bulletproof_max_amounts_base(proof.L.size(), proof.R.size(), BULLETPROOF_MAX_OUTPUTS); }
|
||||
size_t n_bulletproof_plus_max_amounts(const BulletproofPlus &proof) { return n_bulletproof_max_amounts_base(proof.L.size(), proof.R.size(), BULLETPROOF_PLUS_MAX_OUTPUTS); }
|
||||
|
||||
size_t n_bulletproof_max_amounts(const std::vector<Bulletproof> &proofs)
|
||||
{
|
||||
size_t n = 0;
|
||||
@@ -278,4 +321,18 @@ namespace rct {
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t n_bulletproof_plus_max_amounts(const std::vector<BulletproofPlus> &proofs)
|
||||
{
|
||||
size_t n = 0;
|
||||
for (const BulletproofPlus &proof: proofs)
|
||||
{
|
||||
size_t n2 = n_bulletproof_plus_max_amounts(proof);
|
||||
CHECK_AND_ASSERT_MES(n2 < std::numeric_limits<uint32_t>::max() - n, 0, "Invalid number of bulletproofs");
|
||||
if (n2 == 0)
|
||||
return 0;
|
||||
n += n2;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user