Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
claim.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Complete, auditors: [Khashayar], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8
12
13namespace bb {
19template <typename Curve> class OpeningPair {
20 using Fr = typename Curve::ScalarField;
21
22 public:
24 Fr evaluation; // v = p(r)
25
26 bool operator==(const OpeningPair& other) const = default;
27};
28
34template <typename Curve> class ProverOpeningClaim {
35 using Fr = typename Curve::ScalarField;
37
38 public:
40 OpeningPair<Curve> opening_pair; // (challenge r, evaluation v = p(r))
41 // Gemini Folds have to be opened at `challenge` and -`challenge`. Instead of copying a polynomial into 2 claims, we
42 // raise the flag that turns on relevant claim processing logic in Shplonk.
43 bool gemini_fold = false;
44};
45
53template <typename Curve> class OpeningClaim {
56 using Fr = typename Curve::ScalarField;
57
58 public:
59 using Builder =
61 // (challenge r, evaluation v = p(r))
63 // commitment to univariate polynomial p(X)
65
66 static constexpr bool IS_GRUMPKIN =
68 // Size of public inputs representation of an opening claim over Grumpkin: 2 * 4 + 2 = 10
69 static constexpr size_t PUBLIC_INPUTS_SIZE = IS_GRUMPKIN ? GRUMPKIN_OPENING_CLAIM_SIZE : INVALID_PUBLIC_INPUTS_SIZE;
70
76 uint32_t set_public()
78 {
79 uint32_t start_idx = opening_pair.challenge.set_public();
80 opening_pair.evaluation.set_public();
81 commitment.set_public();
82
83 return start_idx;
84 }
85
92 const std::span<const stdlib::field_t<Builder>, PUBLIC_INPUTS_SIZE>& limbs)
94 {
95 const size_t FIELD_SIZE = Fr::PUBLIC_INPUTS_SIZE;
96 const size_t COMMITMENT_SIZE = Commitment::PUBLIC_INPUTS_SIZE;
97 std::span<const stdlib::field_t<Builder>, FIELD_SIZE> challenge_limbs{ limbs.data(), FIELD_SIZE };
98 std::span<const stdlib::field_t<Builder>, FIELD_SIZE> evaluation_limbs{ limbs.data() + FIELD_SIZE, FIELD_SIZE };
99 std::span<const stdlib::field_t<Builder>, COMMITMENT_SIZE> commitment_limbs{ limbs.data() + 2 * FIELD_SIZE,
100 COMMITMENT_SIZE };
101 auto challenge = Fr::reconstruct_from_public(challenge_limbs);
102 auto evaluation = Fr::reconstruct_from_public(evaluation_limbs);
103 auto commitment = Commitment::reconstruct_from_public(commitment_limbs);
104
105 return OpeningClaim<Curve>{ { challenge, evaluation }, commitment };
106 }
107
115 {
116 const size_t FIELD_SIZE = Fr::PUBLIC_INPUTS_SIZE;
117 const size_t COMMITMENT_SIZE = Commitment::PUBLIC_INPUTS_SIZE;
118 std::span<const bb::fr, FIELD_SIZE> challenge_limbs{ limbs.data(), FIELD_SIZE };
119 std::span<const bb::fr, FIELD_SIZE> evaluation_limbs{ limbs.data() + FIELD_SIZE, FIELD_SIZE };
120 std::span<const bb::fr, COMMITMENT_SIZE> commitment_limbs{ limbs.data() + 2 * FIELD_SIZE, COMMITMENT_SIZE };
121
122 Fr challenge = Fr::reconstruct_from_public(challenge_limbs);
123 Fr evaluation = Fr::reconstruct_from_public(evaluation_limbs);
124 Commitment commitment = Commitment::reconstruct_from_public(commitment_limbs);
125
126 return OpeningClaim<Curve>{ { challenge, evaluation }, commitment };
127 }
128
130 requires(Curve::is_stdlib_type)
131 {
133 { static_cast<typename Curve::NativeCurve::ScalarField>(opening_pair.challenge.get_value()),
134 static_cast<typename Curve::NativeCurve::ScalarField>(opening_pair.evaluation.get_value()) },
135 commitment.get_value()
136 };
137 }
138
139 bool operator==(const OpeningClaim& other) const = default;
140};
141
151template <typename Curve> struct BatchOpeningClaim {
152
154 using Scalar = typename Curve::ScalarField;
155
156 std::vector<Commitment> commitments;
157 std::vector<Scalar> scalars;
159};
160} // namespace bb
CommitmentKey object over a pairing group 𝔾₁.
Unverified claim (C,r,v) for some witness polynomial p(X) such that.
Definition claim.hpp:53
static OpeningClaim< Curve > reconstruct_from_public(const std::span< const stdlib::field_t< Builder >, PUBLIC_INPUTS_SIZE > &limbs)
Reconstruct an opening claim from limbs stored on the public inputs.
Definition claim.hpp:91
static OpeningClaim< Curve > reconstruct_from_public(const std::span< const bb::fr, PUBLIC_INPUTS_SIZE > &limbs)
Reconstruct a native opening claim from native field elements.
Definition claim.hpp:113
OpeningPair< Curve > opening_pair
Definition claim.hpp:62
std::conditional_t< std::is_same_v< Curve, stdlib::grumpkin< UltraCircuitBuilder > >, UltraCircuitBuilder, void > Builder
Definition claim.hpp:60
auto get_native_opening_claim() const
Definition claim.hpp:129
static constexpr bool IS_GRUMPKIN
Definition claim.hpp:66
static constexpr size_t PUBLIC_INPUTS_SIZE
Definition claim.hpp:69
Commitment commitment
Definition claim.hpp:64
bool operator==(const OpeningClaim &other) const =default
uint32_t set_public()
Set the witness indices for the opening claim to public.
Definition claim.hpp:76
typename Curve::AffineElement Commitment
Definition claim.hpp:55
typename Curve::ScalarField Fr
Definition claim.hpp:56
Opening pair (r,v) for some witness polynomial p(X) such that p(r) = v.
Definition claim.hpp:19
typename Curve::ScalarField Fr
Definition claim.hpp:20
bool operator==(const OpeningPair &other) const =default
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
Polynomial p and an opening pair (r,v) such that p(r) = v.
Definition claim.hpp:34
Polynomial polynomial
Definition claim.hpp:39
OpeningPair< Curve > opening_pair
Definition claim.hpp:40
typename Curve::ScalarField Fr
Definition claim.hpp:35
typename Group::affine_element AffineElement
Definition grumpkin.hpp:63
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
An accumulator consisting of the Shplonk evaluation challenge and vectors of commitments and scalars.
Definition claim.hpp:151
typename Curve::ScalarField Scalar
Definition claim.hpp:154
std::vector< Commitment > commitments
Definition claim.hpp:156
std::vector< Scalar > scalars
Definition claim.hpp:157
typename Curve::AffineElement Commitment
Definition claim.hpp:153
static constexpr size_t PUBLIC_INPUTS_SIZE
static field reconstruct_from_public(const std::span< const field< V >, PUBLIC_INPUTS_SIZE > &limbs)