mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-22 22:38:53 +00:00
rct: avoid repeated unnecessary conversions when accummulating
This commit is contained in:
parent
11dbfbc5b3
commit
607301bf6d
@ -252,6 +252,25 @@ namespace rct {
|
||||
return k;
|
||||
}
|
||||
|
||||
rct::key addKeys(const keyV &A) {
|
||||
if (A.empty())
|
||||
return rct::identity();
|
||||
ge_p3 p3, tmp;
|
||||
CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&p3, A[0].bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
|
||||
for (size_t i = 1; i < A.size(); ++i)
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&tmp, A[i].bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
|
||||
ge_cached p2;
|
||||
ge_p3_to_cached(&p2, &tmp);
|
||||
ge_p1p1 p1;
|
||||
ge_add(&p1, &p3, &p2);
|
||||
ge_p1p1_to_p3(&p3, &p1);
|
||||
}
|
||||
rct::key res;
|
||||
ge_p3_tobytes(res.bytes, &p3);
|
||||
return res;
|
||||
}
|
||||
|
||||
//addKeys1
|
||||
//aGB = aG + B where a is a scalar, G is the basepoint, and B is a point
|
||||
void addKeys1(key &aGB, const key &a, const key & B) {
|
||||
|
@ -132,6 +132,7 @@ namespace rct {
|
||||
//for curve points: AB = A + B
|
||||
void addKeys(key &AB, const key &A, const key &B);
|
||||
rct::key addKeys(const key &A, const key &B);
|
||||
rct::key addKeys(const keyV &A);
|
||||
//aGB = aG + B where a is a scalar, G is the basepoint, and B is a point
|
||||
void addKeys1(key &aGB, const key &a, const key & B);
|
||||
//aGbB = aG + bB where a, b are scalars, G is the basepoint and B is a point
|
||||
|
@ -963,18 +963,16 @@ namespace rct {
|
||||
const bool bulletproof = is_rct_bulletproof(rv.type);
|
||||
const keyV &pseudoOuts = bulletproof ? rv.p.pseudoOuts : rv.pseudoOuts;
|
||||
|
||||
key sumOutpks = identity();
|
||||
rct::keyV masks(rv.outPk.size());
|
||||
for (size_t i = 0; i < rv.outPk.size(); i++) {
|
||||
addKeys(sumOutpks, sumOutpks, rv.outPk[i].mask);
|
||||
masks[i] = rv.outPk[i].mask;
|
||||
}
|
||||
key sumOutpks = addKeys(masks);
|
||||
DP(sumOutpks);
|
||||
key txnFeeKey = scalarmultH(d2h(rv.txnFee));
|
||||
const key txnFeeKey = scalarmultH(d2h(rv.txnFee));
|
||||
addKeys(sumOutpks, txnFeeKey, sumOutpks);
|
||||
|
||||
key sumPseudoOuts = identity();
|
||||
for (size_t i = 0 ; i < pseudoOuts.size() ; i++) {
|
||||
addKeys(sumPseudoOuts, sumPseudoOuts, pseudoOuts[i]);
|
||||
}
|
||||
key sumPseudoOuts = addKeys(pseudoOuts);
|
||||
DP(sumPseudoOuts);
|
||||
|
||||
//check pseudoOuts vs Outs..
|
||||
|
Loading…
Reference in New Issue
Block a user