Skip to content

Commit

Permalink
bench: improvement
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
  • Loading branch information
jsign committed Oct 4, 2023
1 parent 0a90155 commit 71bf0fb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/bandersnatch/points/extended.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Fp = Bandersnatch.Fp;
const Fr = Bandersnatch.Fr;
const AffinePoint = Bandersnatch.AffinePoint;

// TODO: explore if it's worth changin the API style to use receivers for outputs.
// TODO: explore if it's worth changing the API style to use receivers for outputs.

pub const ExtendedPointMSM = struct {
x: Fp,
Expand Down
2 changes: 0 additions & 2 deletions src/banderwagon/banderwagon.zig
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ pub const Element = struct {
};

// msm computes the multi-scalar multiplication of scalars and points.
// TODO: change to Pippenger calls, and make everything use this.
pub fn msm(points: []const Element, scalars: []const Fr) Element {
std.debug.assert(scalars.len == points.len);

Expand Down Expand Up @@ -260,7 +259,6 @@ pub const ElementMSM = struct {
return ElementMSM{ .point = ExtendedPointMSM.neg(self.point) };
}

// TODO: move this.
pub fn fromElements(result: []ElementMSM, points: []const Element) void {
var accumulator = Fp.one();

Expand Down
9 changes: 8 additions & 1 deletion src/bench.zig
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,19 @@ fn benchMultiproofs() !void {
accum_proving += std.time.milliTimestamp() - start;

// Verifying.
var copied_cs = try allocator.alloc(banderwagon.Element, vec_openings.len);
defer allocator.free(copied_cs);
for (0..vec_openings.len) |i| copied_cs[i] = vec_openings[i].C;
var cs_msms = try allocator.alloc(banderwagon.ElementMSM, vec_openings.len);
defer allocator.free(cs_msms);
banderwagon.ElementMSM.fromElements(cs_msms, copied_cs);

var verifier_transcript = Transcript.init("test");
var verifier_queries = try allocator.alloc(multiproof.VerifierQuery, num_openings);
defer allocator.free(verifier_queries);
for (0..num_openings) |i| {
verifier_queries[i] = multiproof.VerifierQuery{
.C = banderwagon.ElementMSM.fromElement(vec_openings[i].C),
.C = cs_msms[i],
.z = vec_openings[i].z,
.y = vec_openings[i].poly_evaluations[vec_openings[i].z],
};
Expand Down

0 comments on commit 71bf0fb

Please sign in to comment.