22template <
typename Curve_>
class KZG {
42 template <
typename Transcript>
45 const std::shared_ptr<Transcript>& prover_trancript)
53 quotient_commitment = Commitment::infinity();
55 quotient.
at(0) = quotient[0] - pair.evaluation;
58 quotient_commitment =
ck.commit(quotient);
64 prover_trancript->send_to_verifier(
"KZG:W", quotient_commitment);
68 prover_trancript->template get_challenge<Fr>(
"KZG:masking_challenge");
81 template <
typename Transcript>
83 const std::shared_ptr<Transcript>& verifier_transcript)
85 auto quotient_commitment = verifier_transcript->template receive_from_prover<Commitment>(
"KZG:W");
93 auto builder = quotient_commitment.get_context();
99 P_0 = GroupElement::batch_mul(commitments, scalars);
103 P_0 += quotient_commitment * claim.
opening_pair.challenge;
104 P_0 -= GroupElement::one() * claim.
opening_pair.evaluation;
107 auto P_1 = -quotient_commitment;
130 template <
typename Transcript>
132 const std::shared_ptr<Transcript>& transcript,
133 const size_t expected_final_msm_size = 0)
135 auto quotient_commitment = transcript->template receive_from_prover<Commitment>(
"KZG:W");
138 const Fr masking_challenge = transcript->template get_challenge<Fr>(
"KZG:masking_challenge");
144 batch_opening_claim.commitments.emplace_back(quotient_commitment);
146 batch_opening_claim.scalars.emplace_back(batch_opening_claim.evaluation_point);
149 if (expected_final_msm_size != 0) {
150 BB_ASSERT_EQ(batch_opening_claim.commitments.size(), expected_final_msm_size);
155 P_0 = GroupElement::batch_mul(batch_opening_claim.commitments,
156 batch_opening_claim.scalars,
161 P_0 = batch_mul_native<Curve>(batch_opening_claim.commitments, batch_opening_claim.scalars);
163 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
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.