Skip to content

Commit

Permalink
chore: Update formatting (#1874)
Browse files Browse the repository at this point in the history
Updating formatting in files touched by a different PR

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [x] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [x] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [x] Every change is related to the PR description.
- [x] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).

Co-authored-by: Innokentii Sennovskii <[email protected]>
  • Loading branch information
Sarkoxed and Rumata888 authored Aug 30, 2023
1 parent c61557a commit fb973ca
Show file tree
Hide file tree
Showing 38 changed files with 331 additions and 337 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barretenberg/common/wasm_export.hpp"
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "blake3s.hpp"

WASM_EXPORT void blake3s_to_field(uint8_t const* data, size_t length, uint8_t* r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "barretenberg/crypto/hashers/hashers.hpp"

#include "barretenberg/common/serialize.hpp"
#include "barretenberg/serialize/msgpack.hpp"
#include "barretenberg/common/streams.hpp"
#include "barretenberg/serialize/msgpack.hpp"

namespace crypto {
namespace schnorr {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sha256.hpp"
#include "barretenberg/common/wasm_export.hpp"
#include "sha256.hpp"

WASM_EXPORT void sha256__hash(uint8_t* in, const size_t length, uint8_t* r)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ void create_recursion_constraints(Builder& builder,
for (size_t i = 0; i < 4; ++i) {
aggregation_elements[i] =
bn254::BaseField(field_ct::from_witness_index(&builder, aggregation_input[4 * i]),
field_ct::from_witness_index(&builder, aggregation_input[4 * i + 1]),
field_ct::from_witness_index(&builder, aggregation_input[4 * i + 2]),
field_ct::from_witness_index(&builder, aggregation_input[4 * i + 3]));
field_ct::from_witness_index(&builder, aggregation_input[4 * i + 1]),
field_ct::from_witness_index(&builder, aggregation_input[4 * i + 2]),
field_ct::from_witness_index(&builder, aggregation_input[4 * i + 3]));
aggregation_elements[i].assert_is_in_field();
}
// If we have a previous aggregation object, assign it to `previous_aggregation` so that it is included
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class StandardGrumpkin {
using PolynomialHandle = std::span<FF>;
using CommitmentKey = pcs::CommitmentKey<Curve>;
using VerifierCommitmentKey = pcs::VerifierCommitmentKey<Curve>;

static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES;
// The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often
// need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "barretenberg/polynomials/polynomial.hpp"
#include "barretenberg/honk/pcs/commitment_key.hpp"
#include "barretenberg/polynomials/polynomial.hpp"

namespace proof_system::honk::pcs {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ template <typename CK> inline std::shared_ptr<CK> CreateCommitmentKey()

template <class VK> inline std::shared_ptr<VK> CreateVerifierCommitmentKey();

template <> inline std::shared_ptr<VerifierCommitmentKey<curve::BN254>> CreateVerifierCommitmentKey<VerifierCommitmentKey<curve::BN254>>()
template <>
inline std::shared_ptr<VerifierCommitmentKey<curve::BN254>> CreateVerifierCommitmentKey<
VerifierCommitmentKey<curve::BN254>>()
{
constexpr size_t n = 4096;
std::shared_ptr<barretenberg::srs::factories::CrsFactory<curve::BN254>> crs_factory(
Expand All @@ -55,7 +57,8 @@ template <> inline std::shared_ptr<VerifierCommitmentKey<curve::BN254>> CreateVe
}
// For IPA
template <>
inline std::shared_ptr<VerifierCommitmentKey<curve::Grumpkin>> CreateVerifierCommitmentKey<VerifierCommitmentKey<curve::Grumpkin>>()
inline std::shared_ptr<VerifierCommitmentKey<curve::Grumpkin>> CreateVerifierCommitmentKey<
VerifierCommitmentKey<curve::Grumpkin>>()
{
constexpr size_t n = 4096;
std::shared_ptr<barretenberg::srs::factories::CrsFactory<curve::Grumpkin>> crs_factory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ namespace proof_system::honk::pcs::gemini {
* @return std::vector<Polynomial>
*/
template <typename Curve>
std::vector<typename barretenberg::Polynomial<typename Curve::ScalarField>> GeminiProver_<Curve>::compute_fold_polynomials(
std::span<const Fr> mle_opening_point, Polynomial&& batched_unshifted, Polynomial&& batched_to_be_shifted)
std::vector<typename barretenberg::Polynomial<typename Curve::ScalarField>> GeminiProver_<
Curve>::compute_fold_polynomials(std::span<const Fr> mle_opening_point,
Polynomial&& batched_unshifted,
Polynomial&& batched_to_be_shifted)
{
const size_t num_variables = mle_opening_point.size(); // m

Expand Down Expand Up @@ -141,9 +143,8 @@ std::vector<typename barretenberg::Polynomial<typename Curve::ScalarField>> Gemi
* @param r_challenge univariate opening challenge
*/
template <typename Curve>
ProverOutput<Curve> GeminiProver_<Curve>::compute_fold_polynomial_evaluations(std::span<const Fr> mle_opening_point,
std::vector<Polynomial>&& fold_polynomials,
const Fr& r_challenge)
ProverOutput<Curve> GeminiProver_<Curve>::compute_fold_polynomial_evaluations(
std::span<const Fr> mle_opening_point, std::vector<Polynomial>&& fold_polynomials, const Fr& r_challenge)
{
const size_t num_variables = mle_opening_point.size(); // m

Expand Down Expand Up @@ -186,7 +187,6 @@ ProverOutput<Curve> GeminiProver_<Curve>::compute_fold_polynomial_evaluations(st
return { fold_poly_opening_pairs, std::move(fold_polynomials) };
};


template class GeminiProver_<curve::BN254>;
template class GeminiProver_<curve::Grumpkin>;
}; // namespace proof_system::honk::pcs::gemini
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ template <class Curve> class GeminiTest : public CommitmentTest<Curve> {
// - 2 partially evaluated Fold polynomial commitments [Fold_{r}^(0)] and [Fold_{-r}^(0)]
// Aggregate: d+1 opening pairs and d+1 Fold poly commitments into verifier claim
auto verifier_claim = GeminiVerifier::reduce_verification(multilinear_evaluation_point,
batched_evaluation,
batched_commitment_unshifted,
batched_commitment_to_be_shifted,
verifier_transcript);
batched_evaluation,
batched_commitment_unshifted,
batched_commitment_to_be_shifted,
verifier_transcript);

// Check equality of the opening pairs computed by prover and verifier
for (size_t i = 0; i < (log_n + 1); ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift)
}

const Fr nu_challenge = prover_transcript.get_challenge("Shplonk:nu");
auto batched_quotient_Q = ShplonkProver::compute_batched_quotient(gemini_opening_pairs, gemini_witnesses, nu_challenge);
auto batched_quotient_Q =
ShplonkProver::compute_batched_quotient(gemini_opening_pairs, gemini_witnesses, nu_challenge);
prover_transcript.send_to_verifier("Shplonk:Q", this->ck()->commit(batched_quotient_Q));

const Fr z_challenge = prover_transcript.get_challenge("Shplonk:z");
Expand All @@ -164,12 +165,13 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift)
auto verifier_transcript = VerifierTranscript<Fr>::init_empty(prover_transcript);

auto gemini_verifier_claim = GeminiVerifier::reduce_verification(mle_opening_point,
batched_evaluation,
batched_commitment_unshifted,
batched_commitment_to_be_shifted,
verifier_transcript);
batched_evaluation,
batched_commitment_unshifted,
batched_commitment_to_be_shifted,
verifier_transcript);

const auto shplonk_verifier_claim = ShplonkVerifier::reduce_verification(this->vk(), gemini_verifier_claim, verifier_transcript);
const auto shplonk_verifier_claim =
ShplonkVerifier::reduce_verification(this->vk(), gemini_verifier_claim, verifier_transcript);
bool verified = IPA::verify(this->vk(), shplonk_verifier_claim, verifier_transcript);

EXPECT_EQ(verified, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift)
// - opening pair: (z_challenge, 0)
// - witness: polynomial Q - Q_z
const Fr nu_challenge = prover_transcript.get_challenge("Shplonk:nu");
auto batched_quotient_Q = ShplonkProver::compute_batched_quotient(gemini_opening_pairs, gemini_witnesses, nu_challenge);
auto batched_quotient_Q =
ShplonkProver::compute_batched_quotient(gemini_opening_pairs, gemini_witnesses, nu_challenge);
prover_transcript.send_to_verifier("Shplonk:Q", this->ck()->commit(batched_quotient_Q));

const Fr z_challenge = prover_transcript.get_challenge("Shplonk:z");
Expand All @@ -158,13 +159,14 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift)
// Gemini verifier output:
// - claim: d+1 commitments to Fold_{r}^(0), Fold_{-r}^(0), Fold^(l), d+1 evaluations a_0_pos, a_l, l = 0:d-1
auto gemini_verifier_claim = GeminiVerifier::reduce_verification(mle_opening_point,
batched_evaluation,
batched_commitment_unshifted,
batched_commitment_to_be_shifted,
verifier_transcript);
batched_evaluation,
batched_commitment_unshifted,
batched_commitment_to_be_shifted,
verifier_transcript);

// Shplonk verifier claim: commitment [Q] - [Q_z], opening point (z_challenge, 0)
const auto shplonk_verifier_claim = ShplonkVerifier::reduce_verification(this->vk(), gemini_verifier_claim, verifier_transcript);
const auto shplonk_verifier_claim =
ShplonkVerifier::reduce_verification(this->vk(), gemini_verifier_claim, verifier_transcript);

// KZG verifier:
// aggregates inputs [Q] - [Q_z] and [W] into an 'accumulator' (can perform pairing check on result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ TYPED_TEST(ShplonkTest, ShplonkSimple)
prover_transcript.send_to_verifier("Shplonk:Q", this->ck()->commit(batched_quotient_Q));

const Fr z_challenge = prover_transcript.get_challenge("Shplonk:z");
const auto [prover_opening_pair, shplonk_prover_witness] = ShplonkProver::compute_partially_evaluated_batched_quotient(
opening_pairs, polynomials, std::move(batched_quotient_Q), nu_challenge, z_challenge);
const auto [prover_opening_pair, shplonk_prover_witness] =
ShplonkProver::compute_partially_evaluated_batched_quotient(
opening_pairs, polynomials, std::move(batched_quotient_Q), nu_challenge, z_challenge);

// An intermediate check to confirm the opening of the shplonk prover witness Q
this->verify_opening_pair(prover_opening_pair, shplonk_prover_witness);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ template <class Curve> class VerifierCommitmentKey;

/**
* @brief Specialization for bn254
*
*
* @tparam curve::BN254
*/
template <> class VerifierCommitmentKey<curve::BN254> {
Expand All @@ -44,7 +44,7 @@ template <> class VerifierCommitmentKey<curve::BN254> {
* @param srs verifier G2 point
*/
VerifierCommitmentKey([[maybe_unused]] size_t num_points,
std::shared_ptr<barretenberg::srs::factories::CrsFactory<Curve>> crs_factory)
std::shared_ptr<barretenberg::srs::factories::CrsFactory<Curve>> crs_factory)
: srs(crs_factory->get_verifier_crs())
{}

Expand All @@ -70,7 +70,7 @@ template <> class VerifierCommitmentKey<curve::BN254> {

/**
* @brief Specialization for Grumpkin
*
*
* @tparam curve::Grumpkin
*/
template <> class VerifierCommitmentKey<curve::Grumpkin> {
Expand All @@ -88,7 +88,8 @@ template <> class VerifierCommitmentKey<curve::Grumpkin> {
* @param num_points specifies the length of the SRS
* @param path is the location to the SRS file
*/
VerifierCommitmentKey(size_t num_points, std::shared_ptr<barretenberg::srs::factories::CrsFactory<Curve>> crs_factory)
VerifierCommitmentKey(size_t num_points,
std::shared_ptr<barretenberg::srs::factories::CrsFactory<Curve>> crs_factory)
: pippenger_runtime_state(num_points)
, srs(crs_factory->get_verifier_crs(num_points))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ template <typename Flavor> bool StandardVerifier_<Flavor>::verify_proof(const pl
// - d+1 commitments [Fold_{r}^(0)], [Fold_{-r}^(0)], and [Fold^(l)], l = 1:d-1
// - d+1 evaluations a_0_pos, and a_l, l = 0:d-1
auto gemini_claim = Gemini::reduce_verification(multivariate_challenge,
batched_evaluation,
batched_commitment_unshifted,
batched_commitment_to_be_shifted,
transcript);
batched_evaluation,
batched_commitment_unshifted,
batched_commitment_to_be_shifted,
transcript);

// Produce a Shplonk claim: commitment [Q] - [Q_z], evaluation zero (at random challenge z)
auto shplonk_claim = Shplonk::reduce_verification(pcs_verification_key, gemini_claim, transcript);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "barycentric_data.hpp"
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barycentric_data.hpp"

#include "barretenberg/numeric/random/engine.hpp"
#include <gtest/gtest.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ template <typename Flavor> class SumcheckProver {
*
* @details
*/
SumcheckOutput<Flavor> prove(
auto full_polynomials, const RelationParameters<FF>& relation_parameters) // pass by value, not by reference
SumcheckOutput<Flavor> prove(auto full_polynomials,
const RelationParameters<FF>& relation_parameters) // pass by value, not by reference
{
auto [alpha, zeta] = transcript.get_challenges("Sumcheck:alpha", "Sumcheck:zeta");

Expand Down Expand Up @@ -176,8 +176,8 @@ template <typename Flavor> class SumcheckVerifier {
* target sum.
*
* @details If verification fails, returns std::nullopt, otherwise returns SumcheckOutput
* @param relation_parameters
* @param transcript
* @param relation_parameters
* @param transcript
*/
std::optional<SumcheckOutput<Flavor>> verify(const RelationParameters<FF>& relation_parameters, auto& transcript)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ template <typename FF> class BaseTranscript {
// TODO(Adrian): Make these tweakable
public:
static constexpr size_t HASH_OUTPUT_SIZE = 32;

private:
static constexpr size_t MIN_BYTES_PER_CHALLENGE = 128 / 8; // 128 bit challenges

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @brief Contains some functions that are shared between the various Plonk composers.
*/
#include "composer_lib.hpp"
#include "barretenberg/srs/factories/crs_factory.hpp"
#include "barretenberg/honk/pcs/commitment_key.hpp"
#include "barretenberg/srs/factories/crs_factory.hpp"

namespace proof_system::plonk {

Expand Down
Loading

0 comments on commit fb973ca

Please sign in to comment.