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
14
15namespace bb {
21template <typename Curve> class OpeningPair {
22 using Fr = typename Curve::ScalarField;
23
24 public:
26 Fr evaluation; // v = p(r)
27
28 bool operator==(const OpeningPair& other) const = default;
29};
30
36template <typename Curve> class ProverOpeningClaim {
37 using Fr = typename Curve::ScalarField;
39
40 public:
42 OpeningPair<Curve> opening_pair; // (challenge r, evaluation v = p(r))
43 // Gemini Folds have to be opened at `challenge` and -`challenge`. Instead of copying a polynomial into 2 claims, we
44 // raise the flag that turns on relevant claim processing logic in Shplonk.
45 bool gemini_fold = false;
46};
47
55template <typename Curve> class OpeningClaim {
58 using Fr = typename Curve::ScalarField;
59
60 public:
61 using Builder =
63 // (challenge r, evaluation v = p(r))
65 // commitment to univariate polynomial p(X)
67
68 static constexpr bool IS_GRUMPKIN =
70 // Size of public inputs representation of an opening claim over Grumpkin: 2 * 4 + 2 = 10
71 static constexpr size_t PUBLIC_INPUTS_SIZE = IS_GRUMPKIN ? GRUMPKIN_OPENING_CLAIM_SIZE : INVALID_PUBLIC_INPUTS_SIZE;
72
78 uint32_t set_public()
80 {
81 uint32_t start_idx = opening_pair.challenge.set_public();
82 opening_pair.evaluation.set_public();
83 commitment.set_public();
84
85 return start_idx;
86 }
87
94 const std::span<const stdlib::field_t<Builder>, PUBLIC_INPUTS_SIZE>& limbs)
96 {
99 const size_t FIELD_SIZE = Fr::PUBLIC_INPUTS_SIZE;
100 const size_t COMMITMENT_SIZE = Commitment::PUBLIC_INPUTS_SIZE;
101 std::span<const field_ct, FIELD_SIZE> challenge_limbs{ limbs.data(), FIELD_SIZE };
102 std::span<const field_ct, FIELD_SIZE> evaluation_limbs{ limbs.data() + FIELD_SIZE, FIELD_SIZE };
103 std::span<const field_ct, COMMITMENT_SIZE> commitment_limbs{ limbs.data() + 2 * FIELD_SIZE, COMMITMENT_SIZE };
104 auto challenge = Codec::template deserialize_from_fields<Fr>(challenge_limbs);
105 auto evaluation = Codec::template deserialize_from_fields<Fr>(evaluation_limbs);
106 auto commitment = Codec::template deserialize_from_fields<Commitment>(commitment_limbs);
107
108 return OpeningClaim<Curve>{ { challenge, evaluation }, commitment };
109 }
110
118 {
119 using Codec = FrCodec;
120 const size_t FIELD_SIZE = Fr::PUBLIC_INPUTS_SIZE;
121 const size_t COMMITMENT_SIZE = Commitment::PUBLIC_INPUTS_SIZE;
122 std::span<const bb::fr, FIELD_SIZE> challenge_limbs{ limbs.data(), FIELD_SIZE };
123 std::span<const bb::fr, FIELD_SIZE> evaluation_limbs{ limbs.data() + FIELD_SIZE, FIELD_SIZE };
124 std::span<const bb::fr, COMMITMENT_SIZE> commitment_limbs{ limbs.data() + 2 * FIELD_SIZE, COMMITMENT_SIZE };
125
126 Fr challenge = Codec::deserialize_from_fields<Fr>(challenge_limbs);
127 Fr evaluation = Codec::deserialize_from_fields<Fr>(evaluation_limbs);
128 Commitment commitment = Codec::deserialize_from_fields<Commitment>(commitment_limbs);
129
130 return OpeningClaim<Curve>{ { challenge, evaluation }, commitment };
131 }
132
134 requires(Curve::is_stdlib_type)
135 {
137 { static_cast<typename Curve::NativeCurve::ScalarField>(opening_pair.challenge.get_value()),
138 static_cast<typename Curve::NativeCurve::ScalarField>(opening_pair.evaluation.get_value()) },
139 commitment.get_value()
140 };
141 }
142
143 bool operator==(const OpeningClaim& other) const = default;
144};
145
155template <typename Curve> struct BatchOpeningClaim {
156
158 using Scalar = typename Curve::ScalarField;
159
160 std::vector<Commitment> commitments;
161 std::vector<Scalar> scalars;
163};
164} // namespace bb
CommitmentKey object over a pairing group 𝔾₁.
Unverified claim (C,r,v) for some witness polynomial p(X) such that.
Definition claim.hpp:55
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:93
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:116
OpeningPair< Curve > opening_pair
Definition claim.hpp:64
std::conditional_t< std::is_same_v< Curve, stdlib::grumpkin< UltraCircuitBuilder > >, UltraCircuitBuilder, void > Builder
Definition claim.hpp:62
auto get_native_opening_claim() const
Definition claim.hpp:133
static constexpr bool IS_GRUMPKIN
Definition claim.hpp:68
static constexpr size_t PUBLIC_INPUTS_SIZE
Definition claim.hpp:71
Commitment commitment
Definition claim.hpp:66
bool operator==(const OpeningClaim &other) const =default
uint32_t set_public()
Set the witness indices for the opening claim to public.
Definition claim.hpp:78
typename Curve::AffineElement Commitment
Definition claim.hpp:57
typename Curve::ScalarField Fr
Definition claim.hpp:58
Opening pair (r,v) for some witness polynomial p(X) such that p(r) = v.
Definition claim.hpp:21
typename Curve::ScalarField Fr
Definition claim.hpp:22
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:36
Polynomial polynomial
Definition claim.hpp:41
OpeningPair< Curve > opening_pair
Definition claim.hpp:42
typename Curve::ScalarField Fr
Definition claim.hpp:37
typename Group::affine_element AffineElement
Definition grumpkin.hpp:65
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
StdlibCodec for in-circuit (recursive) verification transcript handling.
An accumulator consisting of the Shplonk evaluation challenge and vectors of commitments and scalars.
Definition claim.hpp:155
typename Curve::ScalarField Scalar
Definition claim.hpp:158
std::vector< Commitment > commitments
Definition claim.hpp:160
std::vector< Scalar > scalars
Definition claim.hpp:161
typename Curve::AffineElement Commitment
Definition claim.hpp:157
static constexpr size_t PUBLIC_INPUTS_SIZE