23template <
typename Curve_>
class KZG {
43 template <
typename Transcript>
46 const std::shared_ptr<Transcript>& prover_trancript)
55 quotient_commitment = Commitment::infinity();
57 quotient.
at(0) = quotient[0] - pair.evaluation;
60 quotient_commitment =
ck.commit(quotient);
66 prover_trancript->send_to_verifier(
"KZG:W", quotient_commitment);
79 template <
typename Transcript>
81 const std::shared_ptr<Transcript>& verifier_transcript)
83 auto quotient_commitment = verifier_transcript->template receive_from_prover<Commitment>(
"KZG:W");
91 auto builder = quotient_commitment.get_context();
100 P_0 = GroupElement::batch_mul(commitments, scalars, 0,
false);
104 P_0 += quotient_commitment * claim.
opening_pair.challenge;
105 P_0 -= GroupElement::one() * claim.
opening_pair.evaluation;
108 auto P_1 = -quotient_commitment;
131 template <
typename Transcript>
133 const std::shared_ptr<Transcript>& transcript,
134 const size_t expected_final_msm_size = 0)
136 auto quotient_commitment = transcript->template receive_from_prover<Commitment>(
"KZG:W");
146 const auto challenge_tag = batch_opening_claim.
evaluation_point.get_origin_tag();
147 quotient_commitment.set_origin_tag(challenge_tag);
154 batch_opening_claim.
commitments.emplace_back(quotient_commitment);
159 if (expected_final_msm_size != 0) {
160 if (batch_opening_claim.
commitments.size() != expected_final_msm_size) {
169 batch_opening_claim.
scalars.size(),
170 "BatchOpeningClaim: commitments and scalars must have equal length");
171 P_0 = GroupElement::batch_mul(batch_opening_claim.
commitments,
175 auto P_1 = -quotient_commitment;
#define BB_ASSERT_EQ(actual, expected,...)
#define BB_BENCH_NAME(name)
CommitmentKey object over a pairing group 𝔾₁.
typename Curve::AffineElement Commitment
typename Curve::Element GroupElement
static PairingPointsType reduce_verify(const OpeningClaim< Curve > &claim, const std::shared_ptr< Transcript > &verifier_transcript)
Computes the input points for the pairing check needed to verify a KZG opening claim of a single poly...
typename Curve::ScalarField Fr
std::conditional_t< Curve::is_stdlib_type, stdlib::recursion::PairingPoints< Curve >, bb::PairingPoints< Curve > > PairingPointsType
static PairingPointsType reduce_verify_batch_opening_claim(BatchOpeningClaim< Curve > batch_opening_claim, const std::shared_ptr< Transcript > &transcript, const size_t expected_final_msm_size=0)
Computes the input points for the pairing check needed to verify a KZG opening claim obtained from a ...
static void compute_opening_proof(const CK &ck, const ProverOpeningClaim< Curve > &opening_claim, const std::shared_ptr< Transcript > &prover_trancript)
Computes the KZG commitment to an opening proof polynomial at a single evaluation point.
Unverified claim (C,r,v) for some witness polynomial p(X) such that.
OpeningPair< Curve > opening_pair
Opening pair (r,v) for some witness polynomial p(X) such that p(r) = v.
An object storing two EC points that represent the inputs to a pairing check.
Fr & at(size_t index)
Our mutable accessor, unlike operator[]. We abuse precedent a bit to differentiate at() and operator[...
void factor_roots(const Fr &root)
Divides p(X) by (X-r) in-place. Assumes that p(rⱼ)=0 for all j.
Polynomial p and an opening pair (r,v) such that p(r) = v.
OpeningPair< Curve > opening_pair
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
typename Group::element Element
static constexpr bool is_stdlib_type
typename Group::affine_element AffineElement
Entry point for Barretenberg command-line interface.
CommitmentKey< Curve > ck
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
An accumulator consisting of the Shplonk evaluation challenge and vectors of commitments and scalars.
std::vector< Commitment > commitments
std::vector< Scalar > scalars
void throw_or_abort(std::string const &err)