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

How to check a VerifyingKey point is within the prime order subgroup #623

Closed
randombit opened this issue Feb 9, 2024 · 3 comments
Closed

Comments

@randombit
Copy link
Contributor

randombit commented Feb 9, 2024

Given a VerifyingKey that I've created from bytes sent to me by another party, how can I check that the point is within the prime order subgroup?

IIUC, I can check if it is contained entirely within the torsion subgroup using is_weak(), but to check that it is within the subgroup mod \ell the best I can find is

pk.to_montgomery().to_edwards(0).unwrap().is_torsion_free()

which seems quite contorted, not to mention pointlessly expensive.

Am I missing something that would make this easier/cheaper?

@tarcieri
Copy link
Contributor

tarcieri commented Feb 9, 2024

I guess one of the immediate concerns here is there is no From<VerifyingKey> for EdwardsPoint impl, or a to_edwards method, to get the EdwardsPoint out of a VerifyingKey, which seems like an oversight.

I believe this would be checked if we implemented NIST's "D.1.3.2. Full Public Key Validation": see #380 (comment). Namely step 3:

  1. Verify that nQ = (0,1). Output REJECT if verification fails.

randombit added a commit to randombit/curve25519-dalek that referenced this issue Feb 12, 2024
@randombit
Copy link
Contributor Author

Opened a patch proposal in #624

randombit added a commit to randombit/curve25519-dalek that referenced this issue Feb 12, 2024
rozbb pushed a commit that referenced this issue Feb 12, 2024
…#624)

Adds VerifyingKey::to_edwards and a From conversion

See #623
@randombit
Copy link
Contributor Author

Thank you for the fast review!

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

No branches or pull requests

2 participants