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#pragma once
2
8
10
11// Helper for extracting a native Flavor from either a native or recursive flavor.
12template <typename Flavor, bool = IsRecursiveFlavor<Flavor>> struct NativeFlavorHelper {
13 using type = Flavor;
14};
15template <typename Flavor> struct NativeFlavorHelper<Flavor, true> {
16 using type = typename Flavor::NativeFlavor;
17};
18
27template <typename Flavor, typename Builder>
30{
31 using NativeFlavor = typename NativeFlavorHelper<Flavor>::type;
33 using VerificationKey = NativeFlavor::VerificationKey;
34
35 Builder circuit = circuit_in; // Copy the circuit to avoid modifying the original
36
37 ProverInstance prover_instance{ circuit };
38 VerificationKey verification_key{ prover_instance.get_precomputed() };
39
40 return verification_key.hash();
41}
42
43// A catch-all for Flavor/Builder combinations where the VK hash is not implemented.
44template <typename Flavor, typename Builder>
47{
48 info("compute_vk_hash: Not implemented for this Flavor/Builder, returning 0.");
49 return 0;
50}
51
52// Determine whether a polynomial has at least one non-zero coefficient
53bool is_non_zero(auto& polynomial)
54{
55 for (auto& coeff : polynomial) {
56 if (!coeff.is_zero()) {
57 return true;
58 }
59 }
60 return false;
61}
62
68void inspect_prover_instance(auto& prover_instance)
69{
70 auto& prover_polys = prover_instance->prover_polynomials;
71 std::vector<std::string> zero_polys;
72 for (auto [label, poly] : zip_view(prover_polys.get_labels(), prover_polys.get_all())) {
73 if (!is_non_zero(poly)) {
74 zero_polys.emplace_back(label);
75 }
76 }
77 if (zero_polys.empty()) {
78 info("\nProving Key Inspector: All prover polynomials are non-zero.");
79 } else {
80 info("\nProving Key Inspector: The following prover polynomials are identically zero: ");
81 for (const std::string& label : zero_polys) {
82 info("\t", label);
83 }
84 }
85 info();
86}
87
88} // namespace bb::prover_instance_inspector
Base Native verification key class.
Definition flavor.hpp:141
fr hash() const
Compute VK hash.
Definition flavor.hpp:284
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
void info(Args... args)
Definition log.hpp:89
ECCVMFlavor Flavor
Base class templates for structures that contain data parameterized by the fundamental polynomials of...
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 ...