Skip to content

Commit 50f294d

Browse files
committed
return BlstError!bool for mergeAndVerify
1 parent 42e86fc commit 50f294d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/ThreadPool.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ pub fn aggregateVerify(
343343
/// Merges all of `pool`'s `pairing_bufs` and execute `finalVerify` on the accumulated `acc`.
344344
///
345345
/// Perform final verification of `gtsig`, returning `false` if verification fails.
346-
fn mergeAndVerify(pool: *ThreadPool, n_active: usize, gtsig: ?*const c.blst_fp12) bool {
346+
fn mergeAndVerify(pool: *ThreadPool, n_active: usize, gtsig: ?*const c.blst_fp12) BlstError!bool {
347347
var acc_idx: ?usize = null;
348348
for (0..n_active) |i| {
349349
if (pool.has_work[i]) {
@@ -352,13 +352,13 @@ fn mergeAndVerify(pool: *ThreadPool, n_active: usize, gtsig: ?*const c.blst_fp12
352352
}
353353
}
354354

355-
const first = acc_idx orelse return false;
355+
const first = acc_idx orelse return BlstError.MergeError;
356356
var acc = Pairing{ .ctx = @ptrCast(&pool.pairing_bufs[first].data) };
357357

358358
for (first + 1..n_active) |i| {
359359
if (pool.has_work[i]) {
360360
const other = Pairing{ .ctx = @ptrCast(&pool.pairing_bufs[i].data) };
361-
acc.merge(&other) catch return false;
361+
try acc.merge(&other);
362362
}
363363
}
364364

src/error.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub const BlstError = error{
1010
VerifyFail,
1111
PkIsInfinity,
1212
BadScalar,
13+
MergeError,
1314
};
1415

1516
pub fn intFromError(e: BlstError) c_uint {
@@ -21,6 +22,7 @@ pub fn intFromError(e: BlstError) c_uint {
2122
BlstError.VerifyFail => c.BLST_VERIFY_FAIL,
2223
BlstError.PkIsInfinity => c.BLST_PK_IS_INFINITY,
2324
BlstError.BadScalar => c.BLST_BAD_SCALAR,
25+
BlstError.MergeError => c.BLST_BAD_SCALAR + 1,
2426
};
2527
}
2628

0 commit comments

Comments
 (0)