mirror of
https://github.com/monero-project/monero.git
synced 2025-01-08 09:37:54 -05:00
fcmp++: proof len from inputs *AND merkle tree depth
This commit is contained in:
parent
ee19361ea0
commit
47d47bdd20
@ -357,7 +357,10 @@ namespace boost
|
|||||||
if (ver >= 1u)
|
if (ver >= 1u)
|
||||||
a & x.CLSAGs;
|
a & x.CLSAGs;
|
||||||
if (ver >= 3u)
|
if (ver >= 3u)
|
||||||
|
{
|
||||||
|
a & x.curve_trees_tree_depth;
|
||||||
a & x.fcmp_pp;
|
a & x.fcmp_pp;
|
||||||
|
}
|
||||||
if (x.rangeSigs.empty())
|
if (x.rangeSigs.empty())
|
||||||
a & x.pseudoOuts;
|
a & x.pseudoOuts;
|
||||||
}
|
}
|
||||||
@ -391,7 +394,10 @@ namespace boost
|
|||||||
if (ver >= 1u)
|
if (ver >= 1u)
|
||||||
a & x.p.CLSAGs;
|
a & x.p.CLSAGs;
|
||||||
if (ver >= 3u)
|
if (ver >= 3u)
|
||||||
|
{
|
||||||
|
a & x.p.curve_trees_tree_depth;
|
||||||
a & x.p.fcmp_pp;
|
a & x.p.fcmp_pp;
|
||||||
|
}
|
||||||
if (x.type == rct::RCTTypeBulletproof || x.type == rct::RCTTypeBulletproof2 || x.type == rct::RCTTypeCLSAG || x.type == rct::RCTTypeBulletproofPlus || x.type == rct::RCTTypeFcmpPlusPlus)
|
if (x.type == rct::RCTTypeBulletproof || x.type == rct::RCTTypeBulletproof2 || x.type == rct::RCTTypeCLSAG || x.type == rct::RCTTypeBulletproofPlus || x.type == rct::RCTTypeFcmpPlusPlus)
|
||||||
a & x.p.pseudoOuts;
|
a & x.p.pseudoOuts;
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,11 @@ namespace fcmp_pp
|
|||||||
// Byte buffer containing the fcmp++ proof
|
// Byte buffer containing the fcmp++ proof
|
||||||
using FcmpPpProof = std::vector<uint8_t>;
|
using FcmpPpProof = std::vector<uint8_t>;
|
||||||
|
|
||||||
static inline std::size_t proof_len(const std::size_t n_inputs)
|
static inline std::size_t proof_len(const std::size_t n_inputs, const uint8_t curve_trees_tree_depth)
|
||||||
{
|
{
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
return n_inputs * 4;
|
static_assert(sizeof(std::size_t) >= sizeof(uint8_t), "unexpected size of size_t");
|
||||||
|
return n_inputs * (std::size_t)curve_trees_tree_depth * 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//namespace fcmp_pp
|
}//namespace fcmp_pp
|
||||||
|
@ -426,6 +426,7 @@ namespace rct {
|
|||||||
std::vector<mgSig> MGs; // simple rct has N, full has 1
|
std::vector<mgSig> MGs; // simple rct has N, full has 1
|
||||||
std::vector<clsag> CLSAGs;
|
std::vector<clsag> CLSAGs;
|
||||||
keyV pseudoOuts; //C - for simple rct
|
keyV pseudoOuts; //C - for simple rct
|
||||||
|
uint8_t curve_trees_tree_depth; // for fcmp++
|
||||||
fcmp_pp::FcmpPpProof fcmp_pp;
|
fcmp_pp::FcmpPpProof fcmp_pp;
|
||||||
|
|
||||||
// when changing this function, update cryptonote::get_pruned_transaction_weight
|
// when changing this function, update cryptonote::get_pruned_transaction_weight
|
||||||
@ -501,9 +502,10 @@ namespace rct {
|
|||||||
|
|
||||||
if (type == RCTTypeFcmpPlusPlus)
|
if (type == RCTTypeFcmpPlusPlus)
|
||||||
{
|
{
|
||||||
|
FIELD(curve_trees_tree_depth)
|
||||||
ar.tag("fcmp_pp");
|
ar.tag("fcmp_pp");
|
||||||
ar.begin_object();
|
ar.begin_object();
|
||||||
const std::size_t proof_len = fcmp_pp::proof_len(inputs);
|
const std::size_t proof_len = fcmp_pp::proof_len(inputs, curve_trees_tree_depth);
|
||||||
if (!typename Archive<W>::is_saving())
|
if (!typename Archive<W>::is_saving())
|
||||||
fcmp_pp.resize(proof_len);
|
fcmp_pp.resize(proof_len);
|
||||||
if (fcmp_pp.size() != proof_len)
|
if (fcmp_pp.size() != proof_len)
|
||||||
@ -628,6 +630,7 @@ namespace rct {
|
|||||||
FIELD(bulletproofs_plus)
|
FIELD(bulletproofs_plus)
|
||||||
FIELD(MGs)
|
FIELD(MGs)
|
||||||
FIELD(CLSAGs)
|
FIELD(CLSAGs)
|
||||||
|
FIELD(curve_trees_tree_depth)
|
||||||
FIELD(fcmp_pp)
|
FIELD(fcmp_pp)
|
||||||
FIELD(pseudoOuts)
|
FIELD(pseudoOuts)
|
||||||
END_SERIALIZE()
|
END_SERIALIZE()
|
||||||
|
@ -1311,8 +1311,11 @@ TEST(Serialization, tx_fcmp_pp)
|
|||||||
|
|
||||||
const std::size_t n_inputs = 2;
|
const std::size_t n_inputs = 2;
|
||||||
const std::size_t n_outputs = 3;
|
const std::size_t n_outputs = 3;
|
||||||
|
const uint8_t curve_trees_tree_depth = 3;
|
||||||
|
|
||||||
const auto make_dummy_fcmp_pp_tx = []() -> transaction
|
const std::size_t proof_len = fcmp_pp::proof_len(n_inputs, curve_trees_tree_depth);
|
||||||
|
|
||||||
|
const auto make_dummy_fcmp_pp_tx = [curve_trees_tree_depth, proof_len]() -> transaction
|
||||||
{
|
{
|
||||||
transaction tx;
|
transaction tx;
|
||||||
|
|
||||||
@ -1369,9 +1372,11 @@ TEST(Serialization, tx_fcmp_pp)
|
|||||||
const crypto::hash referenceBlock{0x01};
|
const crypto::hash referenceBlock{0x01};
|
||||||
tx.rct_signatures.referenceBlock = referenceBlock;
|
tx.rct_signatures.referenceBlock = referenceBlock;
|
||||||
|
|
||||||
|
// Set the curve trees merkle tree depth
|
||||||
|
tx.rct_signatures.p.curve_trees_tree_depth = curve_trees_tree_depth;
|
||||||
|
|
||||||
// 1 fcmp++ proof
|
// 1 fcmp++ proof
|
||||||
fcmp_pp::FcmpPpProof fcmp_pp;
|
fcmp_pp::FcmpPpProof fcmp_pp;
|
||||||
const std::size_t proof_len = fcmp_pp::proof_len(n_inputs);
|
|
||||||
fcmp_pp.reserve(proof_len);
|
fcmp_pp.reserve(proof_len);
|
||||||
for (std::size_t i = 0; i < proof_len; ++i)
|
for (std::size_t i = 0; i < proof_len; ++i)
|
||||||
fcmp_pp.push_back(i);
|
fcmp_pp.push_back(i);
|
||||||
@ -1399,7 +1404,7 @@ TEST(Serialization, tx_fcmp_pp)
|
|||||||
transaction tx = make_dummy_fcmp_pp_tx();
|
transaction tx = make_dummy_fcmp_pp_tx();
|
||||||
|
|
||||||
// Extend fcmp++ proof
|
// Extend fcmp++ proof
|
||||||
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == fcmp_pp::proof_len(n_inputs));
|
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == proof_len);
|
||||||
tx.rct_signatures.p.fcmp_pp.push_back(0x01);
|
tx.rct_signatures.p.fcmp_pp.push_back(0x01);
|
||||||
|
|
||||||
string blob;
|
string blob;
|
||||||
@ -1411,7 +1416,7 @@ TEST(Serialization, tx_fcmp_pp)
|
|||||||
transaction tx = make_dummy_fcmp_pp_tx();
|
transaction tx = make_dummy_fcmp_pp_tx();
|
||||||
|
|
||||||
// Shorten the fcmp++ proof
|
// Shorten the fcmp++ proof
|
||||||
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == fcmp_pp::proof_len(n_inputs));
|
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == proof_len);
|
||||||
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() > 1);
|
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() > 1);
|
||||||
tx.rct_signatures.p.fcmp_pp.pop_back();
|
tx.rct_signatures.p.fcmp_pp.pop_back();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user