mirror of
https://codeberg.org/nahuhh/wownero
synced 2026-10-24 06:48:36 +02:00
plug bulletproofs plus into consensus
This commit is contained in:
committed by
wowario
parent
47d7d0751e
commit
fa3856fedf
@@ -197,6 +197,7 @@ namespace rct {
|
||||
case RCTTypeBulletproof:
|
||||
case RCTTypeBulletproof2:
|
||||
case RCTTypeCLSAG:
|
||||
case RCTTypeBulletproofPlus:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -235,6 +236,17 @@ namespace rct {
|
||||
return is_rct_bulletproof(type) && !is_rct_old_bulletproof(type);
|
||||
}
|
||||
|
||||
bool is_rct_bulletproof_plus(int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RCTTypeBulletproofPlus:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_rct_borromean(int type)
|
||||
{
|
||||
switch (type)
|
||||
@@ -266,6 +278,19 @@ namespace rct {
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
bool is_rct_clsag(int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RCTTypeCLSAG:
|
||||
case RCTTypeBulletproofPlus:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
size_t n_bulletproof_amounts(const Bulletproof &proof)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(proof.L.size() >= 6, 0, "Invalid bulletproof L size");
|
||||
@@ -317,4 +342,55 @@ namespace rct {
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t n_bulletproof_plus_amounts(const BulletproofPlus &proof)
|
||||
{
|
||||
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_PLUS_MAX_OUTPUTS, "log2(BULLETPROOF_PLUS_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();
|
||||
}
|
||||
|
||||
size_t n_bulletproof_plus_amounts(const std::vector<BulletproofPlus> &proofs)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
size_t n_bulletproof_plus_max_amounts(const BulletproofPlus &proof)
|
||||
{
|
||||
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_PLUS_MAX_OUTPUTS, "log2(BULLETPROOF_PLUS_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_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