Skip to content

Commit dc64a27

Browse files
authored
fix(bls): size pairing buffers for 32-bit targets (#531)
## Summary - compute the 384-bit BLST field size independently of pointer width - keep pointer-width sizing only for the `DST` and `DST_len` fields ## Why `Pairing.sizeOf()` divided a 384-bit field width by `@sizeOf(usize)`. This happened to produce the correct 48-byte field size on 64-bit targets, but produced 96 bytes on 32-bit targets. BLST represents the field as either six 64-bit limbs or twelve 32-bit limbs, so its size remains 48 bytes. The old calculation therefore reserved a 6352-byte pairing context on 32-bit targets instead of BLST's 3184 bytes. This was safe but doubled every pairing buffer, including the worker pool's buffer array. This was identified while discussing 32-bit capacity handling in #522 (comment).
1 parent a83741a commit dc64a27

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/bls/Pairing.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn init(buffer: *align(buf_align) [Self.sizeOf()]u8, hash_or_encode: bool, d
2626
///
2727
/// This is safe because blst is statically linked to this binding.
2828
pub fn sizeOf() usize {
29-
const vec384_size = 384 / @sizeOf(usize);
29+
const vec384_size = 384 / std.mem.byte_size_in_bits;
3030
const vec384fp12_size = vec384_size * 12;
3131

3232
const point_e1_affine_size = vec384_size * 2;

0 commit comments

Comments
 (0)