-
Notifications
You must be signed in to change notification settings - Fork 191
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
Bitwise operations for scalars #995
Comments
The problem with bitwise operations on scalars (or more generally, odd prime-order fields elements) is what to do when the result is not a valid scalar. This occurs in non-intuitive places, because the "bit width" of a scalar covers a superset of the valid range of scalars (unlike unsigned integers like
Other binary operators like The end result is that the only bitwise operator that can safely be implemented for prime-order fields is
|
Those are all good points, but that being said they could be a disclaimer to a functionality that would let users choose whether to use it, rather than prohibit it from the get go. There are use-cases where this is desirable, and if we have edge cases in which the results are invalid, we can return This feature is optional for me and so I won't push any further, I was curious for the reason and you gave a good explanation, I gave an alternative and it's fine to disagree with it or accept it, as you wish. Thanks for the explanation |
One option would be to have a |
exactly |
Would be good to get a trait for that into |
can i take on this ? |
I'm curious as to why
Shr
is the only bitwise operator implemented for scalars? I'm interested ink256
specifically, but I think this is a more generalized question.Why not have
Shl
,And
, etc. etc.?The text was updated successfully, but these errors were encountered: