Skip to content

Add an optional reusable G2 preparation hook - #146

Open
str4d wants to merge 2 commits into
maint/0.24.xfrom
reusable-g2
Open

str4d wants to merge 2 commits into
maint/0.24.xfrom
reusable-g2

Conversation

@str4d

@str4d str4d commented Oct 6, 2026

Copy link
Copy Markdown
Member

Ported from zakura-pairing 2.1.0.

This changes a trait, but does not require an RFC, because it is an addition (due to having a default impl) that:

  • strictly improves objective, numerical quality criteria (speedup).
  • is only likely to be noticed by other developers-of-zkcrypto-crates, invisible to users-of-zkcrypto-crates.

str4d added 2 commits October 6, 2026 16:56
Existing engines retain ordinary preparation; engines can override the
method for repeated public G2 terms without changing the prepared type.

Source: https://github.com/zakura-core/common/blob/v2.1.0/crates/pairing/src/lib.rs
License: MIT OR Apache-2.0
Comment thread src/lib.rs
/// Implementations may be variable time in `q`. This API should only be used with
/// public points, such as those in Groth16 verifying keys. For all other points,
/// use `Self::G2Prepared::from(q)` instead.
fn prepare_reusable_g2(q: Self::G2Affine) -> Self::G2Prepared {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I considered giving this a _vartime suffix, but it felt partially duplicative of the _reusable part of the name, and as I expect the usage of this particular API to be relatively constrained (both by way of this only applying to pairings, and also being part of the optimised pathway that crates like groth16 will use), I think the clear Guarantees section is sufficient in this case.

@dannywillems dannywillems left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK 51101cd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants