Skip to content

Commit

Permalink
bench: fix IPA eval point should be outside domain
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 Sep 21, 2023
1 parent bf51871 commit 0e69b07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/bench.zig
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn benchPedersenHash() !void {
for (0..N) |i| {
_ = xcrs.commit(vecs[i]);
}
std.debug.print(" naive takes {}µs", .{@divTrunc((std.time.microTimestamp() - start), (N))});
std.debug.print("naive takes {}µs", .{@divTrunc((std.time.microTimestamp() - start), (N))});

start = std.time.microTimestamp();
for (0..N) |i| {
Expand Down Expand Up @@ -107,12 +107,14 @@ fn benchIPAs() !void {
var allocator = gpa.allocator();

var prover_queries: []IPA.ProverQuery = try allocator.alloc(IPA.ProverQuery, 16);
defer allocator.free(prover_queries);
const z256 = Fr.fromInteger(256);
for (0..prover_queries.len) |i| {
for (0..prover_queries[i].A.len) |j| {
prover_queries[i].A[j] = Fr.fromInteger(i + j + 0x424242);
}
prover_queries[i].commitment = xcrs.commit(prover_queries[i].A);
prover_queries[i].eval_point = Fr.fromInteger((i + 0x414039) % 256);
prover_queries[i].eval_point = Fr.fromInteger(i + 0x414039).add(z256);
prover_queries[i].B = weights.barycentricFormulaConstants(prover_queries[i].eval_point);
}

Expand Down
2 changes: 2 additions & 0 deletions src/polynomial/precomputed_weights.zig
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ pub fn PrecomputedWeights(
// b_i = A(z) / A'(DOMAIN[i]) * 1 / (z - DOMAIN[i])
// The caller is responsible for freeing the returned slice.
pub fn barycentricFormulaConstants(self: Self, z: Fr) [DomainSize]Fr {
std.debug.assert(z.toInteger() >= DomainSize);

const Az = self.A.evaluate(z);

var zSubXInvs: [DomainSize]Fr = undefined;
Expand Down

0 comments on commit 0e69b07

Please sign in to comment.