-
Notifications
You must be signed in to change notification settings - Fork 551
Add Scalar::halve()
#804
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
Add Scalar::halve()
#804
Conversation
It seems like you could implement a much more efficient divide-by-two operation using a right shift over the limbs of the unsaturated 52-bit representation used by |
I originally did exactly that, but that doesn't have the same output and doesn't seem to work; the test will fail. |
@daxpedda I think it might need the same trick that the |
#805 should be close, I think |
I see! Seems to work great! |
@@ -1867,6 +1867,35 @@ mod test { | |||
} | |||
} | |||
|
|||
#[test] | |||
#[cfg(all(feature = "alloc", feature = "rand_core", feature = "group"))] | |||
fn multiply_double_and_compress_1024_random_points() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really get proptest
set up, this is fine for now though.
cc @rozbb
25b424a
into
dalek-cryptography:scalar-div-by-2
This adds a new method
Scalar::halve()
which halves the givenScalar
.This can facilitate batch encoding the result of scalar-point multiplications by halving the
Scalar
and then usingRistrettoPoint::double_and_compress_batch()
. I've added a test for this.