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>
35 const TraceSettings& trace_settings = TraceSettings{ AZTEC_TRACE_STRUCTURE })
37{
38 using NativeFlavor = typename NativeFlavorHelper<Flavor>::type;
40 using VerificationKey = NativeFlavor::VerificationKey;
41
42 Builder circuit = circuit_in; // Copy the circuit to avoid modifying the original
43
44 ProverInstance prover_instance{ circuit, trace_settings };
45 VerificationKey verification_key{ prover_instance.get_precomputed() };
46
47 return verification_key.hash();
48}
49
50// A catch-all for Flavor/Builder combinations where the VK hash is not implemented.
51template <typename Flavor, typename Builder>
52uint256_t compute_vk_hash(const Builder&, const TraceSettings& = TraceSettings{ AZTEC_TRACE_STRUCTURE })
54{
55 info("compute_vk_hash: Not implemented for this Flavor/Builder, returning 0.");
56 return 0;
57}
58
59// Determine whether a polynomial has at least one non-zero coefficient
60bool is_non_zero(auto& polynomial)
61{
62 for (auto& coeff : polynomial) {
63 if (!coeff.is_zero()) {
64 return true;
65 }
66 }
67 return false;
68}
69
75void inspect_prover_instance(auto& prover_instance)
76{
77 auto& prover_polys = prover_instance->prover_polynomials;
78 std::vector<std::string> zero_polys;
79 for (auto [label, poly] : zip_view(prover_polys.get_labels(), prover_polys.get_all())) {
80 if (!is_non_zero(poly)) {
81 zero_polys.emplace_back(label);
82 }
83 }
84 if (zero_polys.empty()) {
85 info("\nProving Key Inspector: All prover polynomials are non-zero.");
86 } else {
87 info("\nProving Key Inspector: The following prover polynomials are identically zero: ");
88 for (const std::string& label : zero_polys) {
89 info("\t", label);
90 }
91 }
92 info();
93}
94
95} // 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:74
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, const TraceSettings &trace_settings=TraceSettings{ AZTEC_TRACE_STRUCTURE })
Compute the hash of the verification key that results from constructing a proving key from the given ...
MegaFlavor Flavor