diff --git a/src/bench.zig b/src/bench.zig index 4e180e8..d1c52e9 100644 --- a/src/bench.zig +++ b/src/bench.zig @@ -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| { @@ -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); } diff --git a/src/polynomial/precomputed_weights.zig b/src/polynomial/precomputed_weights.zig index 9bdb65a..119f2bd 100644 --- a/src/polynomial/precomputed_weights.zig +++ b/src/polynomial/precomputed_weights.zig @@ -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;