Based on the #1883 branch, this PR takes advantage of the variable-time generator point multiplication function ecmult_gen_var for spend public key tweaking in the output public key calculation $P_k = B_{spend} + t_k \cdot G$ (used both for sending and scanning). Note that $t_k$ is not considered a long-term secret (in contrast to e.g. the scan secret key), so using variable-time functions should be fine. This leads to a ~25% scanning speedup if the number of transaction outputs is small (N <= 10).
Results on my arm64 machine (as per $ ./build/bin/bench silentpayments_scan_nomatch, see also the commit body):
| N | master | PR branch | speedup |
|---|---|---|---|
| 2 | 39.3 us | 30.3 us | 28.85% |
| 5 | 40.4 us | 31.7 us | 27.44% |
| 10 | 43.3 us | 34.6 us | 25.14% |
| 100 | 89.6 us | 81.2 us | 10.34% |
| 1000 | 1259.0 us | 1244.0 us | 1.99% |
This PR is similar to the previous ones #1843, #1844, but it only changes the behavior of the silentpayments module and leaves other API functions unchanged.