Skip to content

Commit 6369ec9

Browse files
committed
fix abi
1 parent 0ce15b8 commit 6369ec9

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/AggregatePublicKey.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ pub fn toPublicKey(self: *const Self) PublicKey {
1616
/// If pks_validate is true, validates each public key before aggregation.
1717
///
1818
/// Returns an error if the slice is empty or if any public key validation fails.
19-
pub fn aggregate(pks: []*const PublicKey, pks_validate: bool) BlstError!Self {
19+
pub fn aggregate(pks: []const PublicKey.Point, _: bool) BlstError!Self {
2020
if (pks.len == 0) return BlstError.AggrTypeMismatch;
21-
if (pks_validate) for (pks) |pk| try pk.validate();
21+
// if (pks_validate) for (pks) |pk| try PublicKey.validate(&pk.point);
2222

2323
var agg_pk = Self{};
24-
c.blst_p1_from_affine(&agg_pk.point, &pks[0].point);
24+
c.blst_p1_from_affine(&agg_pk.point, &pks[0]);
2525
for (1..pks.len) |i| {
26-
c.blst_p1_add_or_double_affine(&agg_pk.point, &agg_pk.point, &pks[i].point);
26+
c.blst_p1_add_or_double_affine(&agg_pk.point, &agg_pk.point, &pks[i]);
2727
}
2828
return agg_pk;
2929
}
@@ -48,7 +48,7 @@ pub fn aggregateWithRandomness(
4848
if (scratch.len < c.blst_p1s_mult_pippenger_scratch_sizeof(pks.len)) {
4949
return BlstError.AggrTypeMismatch;
5050
}
51-
if (pks_validate) for (pks) |pk| try pk.validate();
51+
if (pks_validate) for (pks) |pk| try PublicKey.validate(&pk.point);
5252

5353
var scalars_refs: [128]*const u8 = undefined;
5454
for (0..pks.len) |i| scalars_refs[i] = &randomness[i * 32];

src/PublicKey.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ const Self = @This();
1111

1212
// Core operations
1313

14-
/// Checks that the public key is not infinity and is in the correct subgroup.
14+
/// Checks that a given `Point` is not infinity and is in the correct subgroup.
1515
///
1616
/// Returns a `BlstError` if verification fails.
17-
pub fn validate(self: *const Self) BlstError!void {
18-
if (c.blst_p1_affine_is_inf(&self.point)) return BlstError.PkIsInfinity;
19-
if (!c.blst_p1_affine_in_g1(&self.point)) return BlstError.PointNotInGroup;
17+
pub fn validate(point: *const Point) BlstError!void {
18+
if (c.blst_p1_affine_is_inf(point)) return BlstError.PkIsInfinity;
19+
if (!c.blst_p1_affine_in_g1(point)) return BlstError.PointNotInGroup;
2020
}
2121

2222
/// Validate a serialized public key.

src/Signature.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn verify(
3232
) BlstError!void {
3333
if (sig_groupcheck) try self.validate(false);
3434

35-
if (pk_validate) try pk.validate();
35+
if (pk_validate) try PublicKey.validate(&pk.point);
3636

3737
if (msg.len == 0 or dst.len == 0) {
3838
return BlstError.BadEncoding;
@@ -118,7 +118,7 @@ pub fn fastAggregateVerify(
118118
buffer: *[Pairing.sizeOf()]u8,
119119
msg: [32]u8,
120120
dst: []const u8,
121-
pks: []*const PublicKey,
121+
pks: []const PublicKey.Point,
122122
) BlstError!bool {
123123
const agg_pk = try AggregatePublicKey.aggregate(pks, false);
124124
const pk = agg_pk.toPublicKey();

src/eth_c_abi.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export fn publicKeyToBytes(out: [*c]u8, pk: *const blst.PublicKey) void {
106106
///
107107
/// Returns 0 on success, error code on failure.
108108
export fn publicKeyValidate(a: *const blst.PublicKey) c_uint {
109-
a.validate() catch |e| return intFromError(e);
109+
PublicKey.validate(&a.point) catch |e| return intFromError(e);
110110
return 0;
111111
}
112112

@@ -143,8 +143,8 @@ export fn publicKeyAggregateWithRandomness(
143143
/// Aggregate multiple `blst.PublicKey`s.
144144
///
145145
/// Returns 0 on success, error code on failure.
146-
export fn publicKeyAggregate(out: *PublicKey, pks: [*c]*const PublicKey.Point, len: c_uint, pks_validate: bool) c_uint {
147-
const agg_pk = blst.AggregatePublicKey.aggregate(@ptrCast(pks[0..len]), pks_validate) catch |e| return intFromError(e);
146+
export fn publicKeyAggregate(out: *PublicKey, pks: [*c]const PublicKey.Point, len: c_uint, pks_validate: bool) c_uint {
147+
const agg_pk = blst.AggregatePublicKey.aggregate(pks[0..len], pks_validate) catch |e| return intFromError(e);
148148
out.* = agg_pk.toPublicKey();
149149

150150
return 0;
@@ -224,15 +224,15 @@ export fn signatureFastAggregateVerify(
224224
sig: *const Signature,
225225
sig_groupcheck: bool,
226226
msg: *[32]u8,
227-
pks: [*c]*const PublicKey.Point,
227+
pks: [*c]const PublicKey.Point,
228228
pks_len: c_uint,
229229
) c_uint {
230230
const res = sig.fastAggregateVerify(
231231
sig_groupcheck,
232232
&scratch_pairing,
233233
msg.*,
234234
DST,
235-
@ptrCast(pks[0..pks_len]),
235+
pks[0..pks_len],
236236
) catch |e| return intFromError(e);
237237
return @intFromBool(!res);
238238
}

0 commit comments

Comments
 (0)