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

Use prepared Groth16 keys for non-batch Sapling validation #3079

Merged
merged 1 commit into from
Nov 23, 2021

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Nov 19, 2021

Motivation

Zebra's Sapling proof validation prepares the validation key every time we do non-batch validation. But the parameter loader also creates a prepared copy of the key.

I think we can verify slightly faster if we re-use the prepared key.

This is related to #322, but it's not required.

Solution

  • Stop preparing the same key for every non-batch Sapling proof

This PR is based on PR #3091 to avoid unrelated test failures.

Review

I need a cryptographer to review this change.

@conradoplg if you're not sure, let's wait and ask Deirdre next week?

Reviewer Checklist

  • Code change is correct
  • Existing tests pass

@teor2345 teor2345 added C-enhancement Category: This is an improvement P-Low I-slow Problems with performance or responsiveness labels Nov 19, 2021
@teor2345 teor2345 added this to the 2021 Sprint 23 milestone Nov 19, 2021
@teor2345 teor2345 self-assigned this Nov 19, 2021
@teor2345 teor2345 changed the base branch from main to download-zcash-params November 19, 2021 05:29
conradoplg
conradoplg previously approved these changes Nov 19, 2021
Copy link
Collaborator

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, the new values must be the same as the previous ones since they're computed the exact same way.

It would be good for @dconnolly to double check but it looks fine.

// Prepare verifying keys
let spend_prepared_verifying_key = groth16::prepare_verifying_key(&spend.vk);
let output_prepared_verifying_key = groth16::prepare_verifying_key(&output.vk);
Ok(Self {
spend,
spend_prepared_verifying_key,
output,
output_prepared_verifying_key,
})

Base automatically changed from download-zcash-params to main November 19, 2021 23:02
@teor2345 teor2345 marked this pull request as ready for review November 21, 2021 22:01
@teor2345
Copy link
Contributor Author

teor2345 commented Nov 22, 2021

CI failed with a listener conflict in a test with a race condition.

If it happens again, we could:

  • increase LAUNCH_DELAY
  • disable some acceptance tests in coverage CI

We might also need to:

  • reduce the number of proptests using the standard env var
  • increase the coverage workflow timeout

dconnolly
dconnolly previously approved these changes Nov 23, 2021
Copy link
Contributor

@dconnolly dconnolly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I also reviewed the updated groth16/params changes in this context 💃

@dconnolly dconnolly enabled auto-merge (squash) November 23, 2021 03:30
@teor2345 teor2345 changed the base branch from main to startup-slow-services-last November 23, 2021 04:26
@dconnolly dconnolly merged commit 2c28de9 into startup-slow-services-last Nov 23, 2021
@dconnolly dconnolly deleted the prepared-groth-keys branch November 23, 2021 04:26
@teor2345 teor2345 restored the prepared-groth-keys branch November 23, 2021 04:27
@teor2345
Copy link
Contributor Author

Oops, I auto-merged this into the wrong branch. I'll admin-merge it to main instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: This is an improvement I-slow Problems with performance or responsiveness
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants