Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup table for calculating amount commitments #245

Closed
Boog900 opened this issue Aug 6, 2024 · 4 comments · Fixed by #323
Closed

Lookup table for calculating amount commitments #245

Boog900 opened this issue Aug 6, 2024 · 4 comments · Fixed by #323
Assignees
Labels
A-storage Related to storage. C-proposal A proposal of some kind, and a request for comments. E-easy Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. I-perf Problems and improvements with respect to performance of code. P-medium Medium priority.

Comments

@Boog900
Copy link
Member

Boog900 commented Aug 6, 2024

What

When retrieving pre-RCT outputs from the DB we need to calculate an amount commitment for use in RCT rings, this is currently done manually:

// FIXME: implement lookup table for common values:
// <https://github.com/monero-project/monero/blob/c8214782fb2a769c57382a999eaf099691c836e7/src/ringct/rctOps.cpp#L322>
let commitment = ED25519_BASEPOINT_POINT + H() * Scalar::from(amount);

Also when adding V2 miner txs:

// Create commitment.
// <https://github.com/Cuprate/cuprate/pull/102#discussion_r1559489302>
// FIXME: implement lookup table for common values:
// <https://github.com/monero-project/monero/blob/c8214782fb2a769c57382a999eaf099691c836e7/src/ringct/rctOps.cpp#L322>
let commitment = (ED25519_BASEPOINT_POINT
+ monero_serai::H() * Scalar::from(amount))
.compress()

This issue is for creating a lookup table for common amounts (the validly decomposed amounts).

Why

Calculating commitments is slower than using a look up table.

How

I did this in our test sync branch:

pub fn compute_zero_commitment(amount: u64) -> EdwardsPoint {
precomputed_commitments()
.get(&amount)
.copied()
.unwrap_or_else(|| {
h_precomp().vartime_multiscalar_mul([Scalar::from(amount), Scalar::from(1_u8)])
})
}

However performance tests should be conducted to see if the slow path (line 60) is actually faster than our current method

@Boog900 Boog900 added C-proposal A proposal of some kind, and a request for comments. A-storage Related to storage. E-easy Easy difficulty. Experience needed to fix: Not much. Good first issue. I-perf Problems and improvements with respect to performance of code. P-medium Medium priority. E-help-wanted Call for participation: Help is requested to fix this issue. labels Aug 6, 2024
@willco-1
Copy link

willco-1 commented Sep 6, 2024

I'd like to take a shot at this if that's okay

@Boog900
Copy link
Member Author

Boog900 commented Sep 6, 2024

We currently have someone working on this sorry, #178 is slightly larger but currently has no one working on it, if that interests you?

@willco-1
Copy link

willco-1 commented Sep 6, 2024 via email

@Boog900
Copy link
Member Author

Boog900 commented Sep 7, 2024

Nice, you will have to comment on the issue for me to assign it. You are welcome to join our matrix server: https://matrix.to/#/#cuprate:monero.social, out of the 4 tasks listed in #178 Persist banned peers would probably be the easiest to start on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-storage Related to storage. C-proposal A proposal of some kind, and a request for comments. E-easy Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. I-perf Problems and improvements with respect to performance of code. P-medium Medium priority.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants