21template <
typename Curve_>
class KZG {
41 template <
typename Transcript>
44 const std::shared_ptr<Transcript>& prover_trancript)
52 quotient_commitment = Commitment::infinity();
54 quotient.
at(0) = quotient[0] - pair.evaluation;
57 quotient_commitment =
ck.commit(quotient);
63 prover_trancript->send_to_verifier(
"KZG:W", quotient_commitment);
67 prover_trancript->template get_challenge<Fr>(
"KZG:masking_challenge");
80 template <
typename Transcript>
82 const std::shared_ptr<Transcript>& verifier_transcript)
84 auto quotient_commitment = verifier_transcript->template receive_from_prover<Commitment>(
"KZG:W");
92 auto builder = quotient_commitment.get_context();
98 P_0 = GroupElement::batch_mul(commitments, scalars);
102 P_0 += quotient_commitment * claim.
opening_pair.challenge;
103 P_0 -= GroupElement::one() * claim.
opening_pair.evaluation;
106 auto P_1 = -quotient_commitment;
129 template <
typename Transcript>
131 const std::shared_ptr<Transcript>& transcript,
132 const size_t expected_final_msm_size = 0)
134 auto quotient_commitment = transcript->template receive_from_prover<Commitment>(
"KZG:W");
137 const Fr masking_challenge = transcript->template get_challenge<Fr>(
"KZG:masking_challenge");
143 batch_opening_claim.commitments.emplace_back(quotient_commitment);
145 batch_opening_claim.scalars.emplace_back(batch_opening_claim.evaluation_point);
148 if (expected_final_msm_size != 0) {
149 BB_ASSERT_EQ(batch_opening_claim.commitments.size(), expected_final_msm_size);
153 P_0 = GroupElement::batch_mul(batch_opening_claim.commitments,
154 batch_opening_claim.scalars,
158 auto P_1 = -quotient_commitment;
#define BB_ASSERT_EQ(actual, expected,...)
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...
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 ...
typename Curve::ScalarField Fr
std::conditional_t< Curve::is_stdlib_type, stdlib::recursion::PairingPoints< Curve >, bb::PairingPoints< Curve > > PairingPointsType
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.
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
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
An accumulator consisting of the Shplonk evaluation challenge and vectors of commitments and scalars.