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

NonZeroScalar for mul_tweak #568

Open
Kixunil opened this issue Dec 20, 2022 · 2 comments
Open

NonZeroScalar for mul_tweak #568

Kixunil opened this issue Dec 20, 2022 · 2 comments

Comments

@Kixunil
Copy link
Collaborator

Kixunil commented Dec 20, 2022

We can statically rule out invalid tweaks by having NonZeroScalar and have it constructible from ThirtyTwoBitHash. Unfortunately we can't do layout optimizations but even if we could we would have to drop ThirtyTwoBitHash or make it unsafe.

See also LLFourn/secp256kfun#144

@apoelstra
Copy link
Member

It is not just zero that we have to avoid tweaking by -- it is also scalars that exceed the group order. We have a type that encodes these invariants -- SecretKey -- which we could use for tweak_add and tweak_mul, but that still wouldn't get rid of the error return, because for tweak_add we also require that the tweak not be the additive inverse of the original key.

@Kixunil
Copy link
Collaborator Author

Kixunil commented Dec 22, 2022

Scalar already guarantees being within curve order so presumable NonZeroScalar would guarantee it as well.

SecretKey

Yeah, it is the same when it comes to allowed values but it also indicates it's secret while scalars may not be.

tweak_add

That one stays as-is unfortunately.

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