feat: Add is_small_order_point, is_prime_subgroup_point #188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
In a nutshell, this offers an opt-in way of performing some public key checks relating to small order components, without having to pay an additional point decompression.
In detail
Since 8dbaf9a, the
PublicKey
type is the performant way to carry public key material, with an eager check that the point is on curve.However, some applications which may like eager point decompression also need to check whether the point is small order, or even torsion-free:
verify_strict
was introduced to offer an opt-in approach to some of this sort of scrutiny at the time the key is used for signing, but cannot be performed eagerly, e.g. as soon as deserializing a public key.OTOH, rejecting small order keys (or worse non-torsion-free) keys by default on deserialization would have a significant performance impact.
However, it's still desirable to have the option to seek for small-order or torsion-free-ness, long before the key is ever used for any actual cryptographic purpose (e.g. signature verification). In order to perform this sort of check, some code bases have taken to re-implementing it from the bytes representation of the key, which involves an additional decompression.
The added functions of this PR allow the checks to be performed without additional decompression.