-
Notifications
You must be signed in to change notification settings - Fork 148
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
Compression/Decompression of G2 Points for BLS12_381 #909
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #909 +/- ##
==========================================
+ Coverage 72.66% 72.81% +0.15%
==========================================
Files 150 150
Lines 34057 34151 +94
==========================================
+ Hits 24746 24866 +120
+ Misses 9311 9285 -26 ☔ View full report in Codecov by Sentry. |
|
||
// Set the 3rd bit based on y value. | ||
let y_neg = -y; | ||
if y.value()[0].representative() > y_neg.value()[0].representative() |
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.
This condition should be y.value()[0].representative() > y_neg.value()[0].representative() || (y.value()[0].representative() == y_neg.value()[0].representative() && y.value()[1].representative() > y_neg.value()[1].representative()).
Perhaps a more efficient strategy is
y_is_greater_or_equal = y.value()[0].representative() >= y_neg.value()[0].representative().
if y_is_greater_or_equal || (y_is_greater_or_equal && y.value()[1].representative() > y_neg.value()[1].representative()
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.
Done!
…mbdaworks into fix_bls12_381_compression
x_bytes[0] |= 1 << 7; | ||
x_bytes[0] |= 1 << 6; |
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.
x_bytes[0] |= 1 << 7; | |
x_bytes[0] |= 1 << 6; | |
x_bytes[0] |= 0b11 << 6; |
@@ -106,7 +102,48 @@ impl Compress for BLS12381Curve { | |||
.ok_or(ByteConversionError::PointNotInSubgroup) | |||
} | |||
|
|||
#[allow(unused)] | |||
#[cfg(feature = "alloc")] | |||
fn compress_g2_point(point: &Self::G2Point) -> alloc::vec::Vec<u8> { |
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.
Do we really need a Vec
here or is it constant size?
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.
Traits get in the way, but we can try to solve this if we expose more things
Compression/Decompression of G2 Points for BLS12_381
This PR fixes a bug in the function responsible for decompressing points on the BLS12_381 curve, where the 3rd bit was not being properly accounted for.
It also adds functionality for compressing points on this curve.
Type of change
Checklist