-
Notifications
You must be signed in to change notification settings - Fork 37
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
support 32bit and expand CI #30
Conversation
Codecov Report
@@ Coverage Diff @@
## master #30 +/- ##
==========================================
+ Coverage 86.81% 86.82% +0.01%
==========================================
Files 14 14
Lines 6788 6794 +6
==========================================
+ Hits 5893 5899 +6
Misses 895 895
Continue to review full report at Codecov.
|
@dot-asm if you have a moment to sanity check this, I would appreciate it! |
impl PrimeFieldBits for Scalar { | ||
// Representation in non-Montgomery form. | ||
type ReprBits = [u64; 4]; |
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.
What prevents you from type ReprBits = [u8; 32];
and then
impl PrimeFieldBits for Scalar {
// Representation in non-Montgomery form.
type ReprBits = [u8; 32];
fn to_le_bits(&self) -> FieldBits<Self::ReprBits> {
let mut scalar = blst_scalar::default();
unsafe { blst_scalar_from_fr(&mut scalar, &self.0) };
FieldBits::new(scalar.b)
}
fn char_le_bits() -> FieldBits<Self::ReprBits> {
FieldBits::new(MODULUS_REPR)
}
}
In other words without dependency on target_pointer_width
.
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.
Not exactly related to this, but I've spotted
/// Converts an element of `Scalar` into a byte representation in
/// little-endian byte order.
#[inline]
pub fn to_bytes_le(&self) -> [u8; 32] {
let mut out = [0u64; 4];
unsafe { blst_uint64_from_fr(out.as_mut_ptr(), &self.0) };
out.as_byte_slice().try_into().unwrap()
}
This can also be rewritten using blst_scalar_from_fr. This way you'll remove dependency on [target platform's] endiannes. [At least in this case of course. [Not that I looked for other cases.]]
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.
What prevents you from type ReprBits = [u8; 32]; and then
The point of this representation is to be u64
or u32
s due to how it is used
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.
The FieldBits
accepts a range of types, u8
included, and blst_scalar
is in right byte order. Note that cargo test
passes...
b84ddb0
to
1d37b87
Compare
Docs failure is because of |
Closes #29