Skip to content

Commit

Permalink
missing typenames
Browse files Browse the repository at this point in the history
  • Loading branch information
maramihali committed Jan 31, 2024
1 parent 53f8c7e commit 08a065d
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 92 deletions.
1 change: 0 additions & 1 deletion barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ class GoblinUltra {
};

RefVector<DataType> get_witness() { return WitnessEntities<DataType>::get_all(); };

RefVector<DataType> get_to_be_shifted()
{
return { this->table_1, this->table_2, this->table_3, this->table_4, this->w_l, this->w_r,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ template <typename BuilderType> class GoblinUltraRecursive_ {
using FF = typename Curve::ScalarField;
using Commitment = typename Curve::Element;
using CommitmentHandle = typename Curve::Element;
using NativeFlavor = flavor::GoblinUltra;
using NativeFlavor = typename flavor::GoblinUltra;
using NativeVerificationKey = NativeFlavor::VerificationKey;

// Note(luke): Eventually this may not be needed at all
Expand Down
38 changes: 0 additions & 38 deletions barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,44 +417,6 @@ template <typename BuilderType> class UltraRecursive_ {
this->z_lookup = commitments.z_lookup;
}
}

VerifierCommitments(const std::shared_ptr<VerificationKey>& verification_key,
const WitnessCommitments& witness_commitments)
{
this->q_m = verification_key->q_m;
this->q_l = verification_key->q_l;
this->q_r = verification_key->q_r;
this->q_o = verification_key->q_o;
this->q_4 = verification_key->q_4;
this->q_c = verification_key->q_c;
this->q_arith = verification_key->q_arith;
this->q_sort = verification_key->q_sort;
this->q_elliptic = verification_key->q_elliptic;
this->q_aux = verification_key->q_aux;
this->q_lookup = verification_key->q_lookup;
this->sigma_1 = verification_key->sigma_1;
this->sigma_2 = verification_key->sigma_2;
this->sigma_3 = verification_key->sigma_3;
this->sigma_4 = verification_key->sigma_4;
this->id_1 = verification_key->id_1;
this->id_2 = verification_key->id_2;
this->id_3 = verification_key->id_3;
this->id_4 = verification_key->id_4;
this->table_1 = verification_key->table_1;
this->table_2 = verification_key->table_2;
this->table_3 = verification_key->table_3;
this->table_4 = verification_key->table_4;
this->lagrange_first = verification_key->lagrange_first;
this->lagrange_last = verification_key->lagrange_last;

this->w_l = witness_commitments.w_l;
this->w_r = witness_commitments.w_r;
this->w_o = witness_commitments.w_o;
this->sorted_accum = witness_commitments.sorted_accum;
this->w_4 = witness_commitments.w_4;
this->z_perm = witness_commitments.z_perm;
this->z_lookup = witness_commitments.z_lookup;
}
};

using Transcript = bb::stdlib::recursion::honk::Transcript<CircuitBuilder>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ template <typename Flavor> bool DeciderVerifier_<Flavor>::verify_proof(const hon
transcript);

auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]);

return sumcheck_verified.value() && verified;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,22 @@ FoldingResult<typename ProverInstances::Flavor> ProtoGalaxyProver_<ProverInstanc
{
prepare_for_folding();
FF delta = transcript->get_challenge("delta");

auto accumulator = get_accumulator();
auto deltas = compute_round_challenge_pows(accumulator->log_instance_size, delta);

auto perturbator = compute_perturbator(accumulator, deltas);
for (size_t idx = 0; idx <= accumulator->log_instance_size; idx++) {
transcript->send_to_verifier("perturbator_" + std::to_string(idx), perturbator[idx]);
}

auto perturbator_challenge = transcript->get_challenge("perturbator_challenge");
instances.next_gate_challenges =
update_gate_challenges(perturbator_challenge, accumulator->gate_challenges, deltas);
combine_relation_parameters(instances);
combine_alpha(instances);
auto pow_polynomial = PowPolynomial<FF>(instances.next_gate_challenges);
auto combiner = compute_combiner(instances, pow_polynomial);

auto compressed_perturbator = perturbator.evaluate(perturbator_challenge);
auto combiner_quotient = compute_combiner_quotient(compressed_perturbator, combiner);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ void ProtoGalaxyVerifier_<VerifierInstances>::receive_and_finalise_instance(cons
// Get permutation challenges and commitment to permutation and lookup grand products
auto [beta, gamma] = transcript->get_challenges(domain_separator + "_beta", domain_separator + "_gamma");

// If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomial
if constexpr (IsGoblinFlavor<Flavor>) {
// If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomial
witness_commitments.lookup_inverses = transcript->template receive_from_prover<Commitment>(
domain_separator + "_" + commitment_labels.lookup_inverses);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes
return inner_folding_proof.accumulator;
}

/**
*@brief Create inner circuit and call check_circuit on it
*/
static void test_inner_circuit()
{
InnerBuilder builder;
Expand All @@ -157,28 +160,37 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes
EXPECT_EQ(result, true);
};

// static void test_new_evaluate()
// {
// OuterBuilder builder;
// using fr_ct = bn254<OuterBuilder>::ScalarField;
// using fr = bn254<OuterBuilder>::ScalarFieldNative;

// std::vector<fr> coeffs;
// std::vector<fr_ct> coeffs_ct;
// for (size_t idx = 0; idx < 8; idx++) {
// auto el = fr::random_element();
// coeffs.emplace_back(el);
// coeffs_ct.emplace_back(fr_ct(&builder, el));
// }
// Polynomial<fr> poly(coeffs);
// fr point = fr::random_element();
// fr_ct point_ct(fr_ct(&builder, point));
// auto res1 = poly.evaluate(point);

// auto res2 = FoldingRecursiveVerifier::evaluate_perturbator(coeffs_ct, point_ct);
// EXPECT_EQ(res1, res2.get_value());
// };
/**
* @brief Ensure that evaluating the perturbator in the recursive folding verifier returns the same result as
* evaluating in Polynomial class.
*
*/
static void test_new_evaluate()
{
OuterBuilder builder;
using fr_ct = bn254<OuterBuilder>::ScalarField;
using fr = bn254<OuterBuilder>::ScalarFieldNative;

std::vector<fr> coeffs;
std::vector<fr_ct> coeffs_ct;
for (size_t idx = 0; idx < 8; idx++) {
auto el = fr::random_element();
coeffs.emplace_back(el);
coeffs_ct.emplace_back(fr_ct(&builder, el));
}
Polynomial<fr> poly(coeffs);
fr point = fr::random_element();
fr_ct point_ct(fr_ct(&builder, point));
auto res1 = poly.evaluate(point);

auto res2 = FoldingRecursiveVerifier::evaluate_perturbator(coeffs_ct, point_ct);
EXPECT_EQ(res1, res2.get_value());
};

/**
* @brief Tests a simple recursive fold that is valid works as expected.
*
*/
static void test_recursive_folding()
{
// Create two arbitrary circuits for the first round of folding
Expand All @@ -197,6 +209,11 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes
fold_and_verify(instances, inner_composer);
};

/**
* @brief Recursively verify two rounds of folding valid circuits and then recursive verify the final decider proof,
* make sure the verifer circuits pass check_circuit(). Ensure that the algorithm of the recursive and native
* verifiers are identical by checking the manifests
*/
static void test_full_protogalaxy_recursive()
{
// Create two arbitrary circuits for the first round of folding
Expand Down Expand Up @@ -338,38 +355,22 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes
using FlavorTypes = testing::Types<::bb::honk::flavor::GoblinUltraRecursive_<GoblinUltraCircuitBuilder>,
::bb::honk::flavor::UltraRecursive_<GoblinUltraCircuitBuilder>>;
TYPED_TEST_SUITE(ProtoGalaxyRecursiveTests, FlavorTypes);
/**@brief Create inner circuit and call check_circuit on it*/

TYPED_TEST(ProtoGalaxyRecursiveTests, InnerCircuit)
{
TestFixture::test_inner_circuit();
}

/**
* @brief Ensure that evaluating the perturbator in the recursive folding verifier returns the same result as
* evaluating in Polynomial class.
*
*/
// TYPED_TEST(ProtoGalaxyRecursiveTests, NewEvaluate)
// {
// TestFixture::test_new_evaluate();
// }

/**
* @brief Tests a simple recursive fold that is valid works as expected.
*
*/
TYPED_TEST(ProtoGalaxyRecursiveTests, NewEvaluate)
{
TestFixture::test_new_evaluate();
}

TYPED_TEST(ProtoGalaxyRecursiveTests, RecursiveFoldingTest)
{
TestFixture::test_recursive_folding();
}

/**
* @brief Recursively verify two rounds of folding valid circuits and then recursive verify the final decider proof,
* make sure the verifer circuits pass check_circuit(). Ensure that the algorithm of the recursive and native verifiers
* are identical by checking the manifests
*/
TYPED_TEST(ProtoGalaxyRecursiveTests, FullProtogalaxyRecursiveTest)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ auto& engine = numeric::get_debug_randomness();
template <typename Flavor> class ProtoGalaxyTests : public testing::Test {
public:
using Composer = UltraComposer_<Flavor>;
using VerificationKey = Flavor::VerificationKey;
using VerificationKey = typename Flavor::VerificationKey;
using Instance = ProverInstance_<Flavor>;
using Instances = ProverInstances_<Flavor, 2>;
using ProtoGalaxyProver = ProtoGalaxyProver_<Instances>;
using FF = Flavor::FF;
using Affine = Flavor::Commitment;
using Projective = Flavor::GroupElement;
using Builder = Flavor::CircuitBuilder;
using FF = typename Flavor::FF;
using Affine = typename Flavor::Commitment;
using Projective = typename Flavor::GroupElement;
using Builder = typename Flavor::CircuitBuilder;
using Polynomial = typename Flavor::Polynomial;
using ProverPolynomials = Flavor::ProverPolynomials;
using ProverPolynomials = typename Flavor::ProverPolynomials;
using RelationParameters = bb::RelationParameters<FF>;
using WitnessCommitments = typename Flavor::WitnessCommitments;
using CommitmentKey = Flavor::CommitmentKey;
using CommitmentKey = typename Flavor::CommitmentKey;
using PowPolynomial = bb::PowPolynomial<FF>;

static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); }
Expand Down Expand Up @@ -155,7 +155,7 @@ template <typename Flavor> class ProtoGalaxyTests : public testing::Test {

static void test_pertubator_polynomial()
{
using RelationSeparator = Flavor::RelationSeparator;
using RelationSeparator = typename Flavor::RelationSeparator;
const size_t log_instance_size(3);
const size_t instance_size(1 << log_instance_size);
std::array<bb::Polynomial<FF>, Flavor::NUM_ALL_ENTITIES> random_polynomials;
Expand Down

0 comments on commit 08a065d

Please sign in to comment.