Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
prover_instance_inspector.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
8
14
16
17// Helper for extracting a native Flavor from either a native or recursive flavor.
18template <typename Flavor, bool = IsRecursiveFlavor<Flavor>> struct NativeFlavorHelper {
19 using type = Flavor;
20};
21template <typename Flavor> struct NativeFlavorHelper<Flavor, true> {
22 using type = typename Flavor::NativeFlavor;
23};
24
33template <typename Flavor, typename Builder>
36{
37 using NativeFlavor = typename NativeFlavorHelper<Flavor>::type;
39 using VerificationKey = NativeFlavor::VerificationKey;
40
41 Builder circuit = circuit_in; // Copy the circuit to avoid modifying the original
42
43 ProverInstance prover_instance{ circuit };
44 VerificationKey verification_key{ prover_instance.get_precomputed() };
45
46 return verification_key.hash();
47}
48
49// A catch-all for Flavor/Builder combinations where the VK hash is not implemented.
50template <typename Flavor, typename Builder>
53{
54 info("compute_vk_hash: Not implemented for this Flavor/Builder, returning 0.");
55 return 0;
56}
57
58// Determine whether a polynomial has at least one non-zero coefficient
59bool is_non_zero(auto& polynomial)
60{
61 for (auto& coeff : polynomial) {
62 if (!coeff.is_zero()) {
63 return true;
64 }
65 }
66 return false;
67}
68
74void inspect_prover_instance(auto& prover_instance)
75{
76 auto& prover_polys = prover_instance->prover_polynomials;
77 std::vector<std::string> zero_polys;
78 for (auto [label, poly] : zip_view(prover_polys.get_labels(), prover_polys.get_all())) {
79 if (!is_non_zero(poly)) {
80 zero_polys.emplace_back(label);
81 }
82 }
83 if (zero_polys.empty()) {
84 info("\nProving Key Inspector: All prover polynomials are non-zero.");
85 } else {
86 info("\nProving Key Inspector: The following prover polynomials are identically zero: ");
87 for (const std::string& label : zero_polys) {
88 info("\t", label);
89 }
90 }
91 info();
92}
93
94} // namespace bb::prover_instance_inspector
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
void info(Args... args)
Definition log.hpp:75
ECCVMFlavor Flavor
Base class templates for structures that contain data parameterized by the fundamental polynomials of...
UltraKeccakFlavor::VerificationKey VerificationKey
void inspect_prover_instance(auto &prover_instance)
Utility for indicating which polynomials in a decider proving key are identically zero.
uint256_t compute_vk_hash(const Builder &circuit_in)
Compute the hash of the verification key that results from constructing a proving key from the given ...