mirror of
https://github.com/monero-project/monero.git
synced 2025-07-28 11:34:11 -04:00
Bulletproofs: verification speedup
This commit is contained in:
parent
7c74e1919e
commit
4ed60b626a
6 changed files with 36 additions and 8 deletions
|
@ -905,7 +905,7 @@ bool bulletproof_VERIFY(const std::vector<const Bulletproof*> &proofs)
|
|||
rct::key m_y0 = rct::zero(), y1 = rct::zero();
|
||||
int proof_data_index = 0;
|
||||
rct::keyV w_cache;
|
||||
rct::keyV proof8_V, proof8_L, proof8_R;
|
||||
std::vector<ge_p3> proof8_V, proof8_L, proof8_R;
|
||||
for (const Bulletproof *p: proofs)
|
||||
{
|
||||
const Bulletproof &proof = *p;
|
||||
|
@ -918,13 +918,17 @@ bool bulletproof_VERIFY(const std::vector<const Bulletproof*> &proofs)
|
|||
const rct::key weight_z = rct::skGen();
|
||||
|
||||
// pre-multiply some points by 8
|
||||
proof8_V.resize(proof.V.size()); for (size_t i = 0; i < proof.V.size(); ++i) proof8_V[i] = rct::scalarmult8(proof.V[i]);
|
||||
proof8_L.resize(proof.L.size()); for (size_t i = 0; i < proof.L.size(); ++i) proof8_L[i] = rct::scalarmult8(proof.L[i]);
|
||||
proof8_R.resize(proof.R.size()); for (size_t i = 0; i < proof.R.size(); ++i) proof8_R[i] = rct::scalarmult8(proof.R[i]);
|
||||
rct::key proof8_T1 = rct::scalarmult8(proof.T1);
|
||||
rct::key proof8_T2 = rct::scalarmult8(proof.T2);
|
||||
rct::key proof8_S = rct::scalarmult8(proof.S);
|
||||
rct::key proof8_A = rct::scalarmult8(proof.A);
|
||||
proof8_V.resize(proof.V.size()); for (size_t i = 0; i < proof.V.size(); ++i) rct::scalarmult8(proof8_V[i], proof.V[i]);
|
||||
proof8_L.resize(proof.L.size()); for (size_t i = 0; i < proof.L.size(); ++i) rct::scalarmult8(proof8_L[i], proof.L[i]);
|
||||
proof8_R.resize(proof.R.size()); for (size_t i = 0; i < proof.R.size(); ++i) rct::scalarmult8(proof8_R[i], proof.R[i]);
|
||||
ge_p3 proof8_T1;
|
||||
ge_p3 proof8_T2;
|
||||
ge_p3 proof8_S;
|
||||
ge_p3 proof8_A;
|
||||
rct::scalarmult8(proof8_T1, proof.T1);
|
||||
rct::scalarmult8(proof8_T2, proof.T2);
|
||||
rct::scalarmult8(proof8_S, proof.S);
|
||||
rct::scalarmult8(proof8_A, proof.A);
|
||||
|
||||
PERF_TIMER_START_BP(VERIFY_line_61);
|
||||
sc_mulsub(m_y0.bytes, proof.taux.bytes, weight_y.bytes, m_y0.bytes);
|
||||
|
|
|
@ -408,6 +408,18 @@ namespace rct {
|
|||
return res;
|
||||
}
|
||||
|
||||
//Computes 8P without byte conversion
|
||||
void scalarmult8(ge_p3 &res, const key &P)
|
||||
{
|
||||
ge_p3 p3;
|
||||
CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&p3, P.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
|
||||
ge_p2 p2;
|
||||
ge_p3_to_p2(&p2, &p3);
|
||||
ge_p1p1 p1;
|
||||
ge_mul8(&p1, &p2);
|
||||
ge_p1p1_to_p3(&res, &p1);
|
||||
}
|
||||
|
||||
//Computes lA where l is the curve order
|
||||
bool isInMainSubgroup(const key & A) {
|
||||
ge_p3 p3;
|
||||
|
|
|
@ -124,6 +124,7 @@ namespace rct {
|
|||
key scalarmultH(const key & a);
|
||||
// multiplies a point by 8
|
||||
key scalarmult8(const key & P);
|
||||
void scalarmult8(ge_p3 &res, const key & P);
|
||||
// checks a is in the main subgroup (ie, not a small one)
|
||||
bool isInMainSubgroup(const key & a);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue