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

Perf: KZG verification in a single point #386

Merged
merged 1 commit into from
Apr 24, 2023
Merged

Conversation

yelhousni
Copy link
Collaborator

@yelhousni yelhousni commented Apr 22, 2023

This PR tradeoffs a scalar multiplication in G2 for a scalar multiplication in G1 in the case of KZG opening in a single point (Verify method). Kudos to @Tabaie for this observation.

-       // e([f(α) - f(a)]G₁, G₂).e([-H(α)]G₁, [α-a]G₂) ==? 1
+       // e([f(α)-f(a)+aH(α)]G₁], G₂).e([-H(α)]G₁, [α]G₂) == 1

We actually use KZG opening in multiple points (BatchVerifyMultiPoints) for PlonK. So this does not impact the PlonK verification time but only the public Verify method, which could be of independent interest. On AWS z1d.large:

benchmark                       old ns/op     new ns/op     delta
BenchmarkKZGVerify-2            708830        653944        -7.74%
BenchmarkKZGBatchVerify10-2     1084355       1035049       -4.55%

Copy link
Contributor

@Tabaie Tabaie left a comment

Choose a reason for hiding this comment

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

LGTM! Is there anything further to be gained from changing e([f(α)-f(a)+aH(α)]G₁], G₂).e([-H(α)]G₁, [α]G₂) == 1 to e([f(α)-f(a)+aH(α)]G₁], G₂) == e([H(α)]G₁, [α]G₂) and avoiding a GT multiplication or is that relatively trivial?

@yelhousni
Copy link
Collaborator Author

LGTM! Is there anything further to be gained from changing e([f(α)-f(a)+aH(α)]G₁], G₂).e([-H(α)]G₁, [α]G₂) == 1 to e([f(α)-f(a)+aH(α)]G₁], G₂) == e([H(α)]G₁, [α]G₂) and avoiding a GT multiplication or is that relatively trivial?

Writing it as e(_,_).e(_,_), allows for some computations to be shared between the two pairings (e.g. final exp and squares in the Miller loops).

@yelhousni yelhousni merged commit 70133f1 into develop Apr 24, 2023
5 checks passed
@yelhousni yelhousni deleted the perf/kzg-verify branch April 24, 2023 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants