Skip to content

Commit

Permalink
fix test + cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
maramihali committed Jul 18, 2024
1 parent 269da29 commit 5304c7e
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 51 deletions.
4 changes: 0 additions & 4 deletions barretenberg/barretenberg.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,4 @@
"console": "internalConsole",
}
},
"launch": {
"version": "0.2.0",
"configurations": []
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ void ExecutionTrace_<Flavor>::add_wires_and_selectors_to_proving_key(TraceData&
}
proving_key.pub_inputs_offset = trace_data.pub_inputs_offset;
} else if constexpr (IsPlonkFlavor<Flavor>) {
// Maybe, ignore the last two selectors here, would this work :-?
for (size_t idx = 0; idx < trace_data.wires.size(); ++idx) {
std::string wire_tag = "w_" + std::to_string(idx + 1) + "_lagrange";
proving_key.polynomial_store.put(wire_tag, std::move(trace_data.wires[idx]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,15 @@ template <typename FF_> class MegaArith {
* conventional Ultra arithmetization
*
*/
void pad_additional()
{
q_busread().emplace_back(0);
// q_poseidon2_external().emplace_back(0);
// q_poseidon2_internal().emplace_back(0);
};
void pad_additional() { q_busread().emplace_back(0); };

/**
* @brief Resizes all selectors which are not part of the conventional Ultra arithmetization
* @details Facilitates reuse of Ultra gate construction functions in arithmetizations which extend the
* conventional Ultra arithmetization
* @param new_size
*/
void resize_additional(size_t new_size)
{
q_busread().resize(new_size);
// WORKTODO: with this in ultra prolly we can delete these
// q_poseidon2_external().resize(new_size);
// q_poseidon2_internal().resize(new_size);
};
void resize_additional(size_t new_size) { q_busread().resize(new_size); };
};

struct TraceBlocks : public MegaTraceBlocks<MegaTraceBlock> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ template <typename FF_> class UltraArith {
info("lookups :\t", this->lookup.size());
info("poseidon ext :\t", this->poseidon_external.size());
info("poseidon int :\t", this->poseidon_internal.size());
info("");
}

size_t get_total_structured_size()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ template <typename Builder> class StdlibPoseidon2 : public testing::Test {
}
};

using CircuitTypes = testing::Types<bb::MegaCircuitBuilder, bb::UltraCircuitBuilder>;
using CircuitTypes = testing::Types<bb::MegaCircuitBuilder, bb::UltraCircuitBuilder, bb::CircuitSimulatorBN254>;

TYPED_TEST_SUITE(StdlibPoseidon2, CircuitTypes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,6 @@ template <typename Builder> struct StdlibTranscriptParams {

Builder* builder = data[0].get_context();
return stdlib::poseidon2<Builder>::hash(*builder, data);
// } else {
// // TODO(https://github.com/AztecProtocol/barretenberg/issues/1035): Add constraints for hashing in Ultra
// using NativeFr = bb::fr;
// ASSERT(!data.empty() && data[0].get_context() != nullptr);
// Builder* builder = data[0].get_context();

// // call the native hash on the data
// std::vector<NativeFr> native_data;
// native_data.reserve(data.size());
// for (const auto& fr : data) {
// native_data.push_back(fr.get_value());
// }
// NativeFr hash_value = crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams>::hash(native_data);

// Fr hash_field_ct = Fr::from_witness(builder, hash_value);
// return hash_field_ct;
// }
}

template <typename T> static inline T convert_challenge(const Fr& challenge)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ TEST_F(ClientIVCRecursionTests, Basic)

EXPECT_TRUE(CircuitChecker::check(*builder));

// Print the number of gates post finalisation
info("Recursive Verifier: num gates = ", builder->num_gates);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,14 @@ std::array<typename Flavor::GroupElement, 2> UltraRecursiveVerifier_<Flavor>::ve

// Execute Sumcheck Verifier and extract multivariate opening point u = (u_0, ..., u_{d-1}) and purported
// multivariate evaluations at u
const size_t log_circuit_size = numeric::get_msb(static_cast<uint32_t>(key->circuit_size));
auto sumcheck = Sumcheck(log_circuit_size, transcript);
auto sumcheck = Sumcheck(CONST_PROOF_SIZE_LOG_N, transcript);
RelationSeparator alpha;
for (size_t idx = 0; idx < alpha.size(); idx++) {
alpha[idx] = transcript->template get_challenge<FF>("alpha_" + std::to_string(idx));
}

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1041): Once hashing produces constraints for Ultra in
// the transcript, a fixed number of gate_challenges must be generated by the prover/verifier in order to achieve a
// verification circuit that is independent of proof size.
auto gate_challenges = std::vector<FF>(log_circuit_size);
for (size_t idx = 0; idx < log_circuit_size; idx++) {
auto gate_challenges = std::vector<FF>(CONST_PROOF_SIZE_LOG_N);
for (size_t idx = 0; idx < CONST_PROOF_SIZE_LOG_N; idx++) {
gate_challenges[idx] = transcript->template get_challenge<FF>("Sumcheck:gate_challenge_" + std::to_string(idx));
}
auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,10 @@ template <typename RecursiveFlavor> class RecursiveVerifierTest : public testing

bool broke(false);
auto check_eq = [&broke](auto& p1, auto& p2) {
EXPECT_TRUE(p1.size() == p2.size());
for (size_t idx = 0; idx < p1.size(); idx++) {
if (p1[idx] != p2[idx]) {
info("bad values p1: ", p1[idx], "p2: ", p2[idx]);
broke = true;
info("discrepancy at value index: ", idx);
break;
}
}
Expand All @@ -168,6 +167,7 @@ template <typename RecursiveFlavor> class RecursiveVerifierTest : public testing
}
block_idx++;
}

EXPECT_FALSE(broke);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ void UltraCircuitBuilder_<Arithmetization>::add_gates_to_ensure_all_polys_are_no
blocks.elliptic.q_aux().emplace_back(0);
blocks.elliptic.q_poseidon2_external().emplace_back(0);
blocks.elliptic.q_poseidon2_internal().emplace_back(0);

if constexpr (HasAdditionalSelectors<Arithmetization>) {
blocks.elliptic.pad_additional();
}
Expand All @@ -145,7 +144,6 @@ void UltraCircuitBuilder_<Arithmetization>::add_gates_to_ensure_all_polys_are_no
blocks.aux.q_aux().emplace_back(1);
blocks.aux.q_poseidon2_external().emplace_back(0);
blocks.aux.q_poseidon2_internal().emplace_back(0);

if constexpr (HasAdditionalSelectors<Arithmetization>) {
blocks.aux.pad_additional();
}
Expand Down Expand Up @@ -755,7 +753,6 @@ plookup::ReadData<uint32_t> UltraCircuitBuilder_<Arithmetization>::create_gates_
blocks.lookup.q_aux().emplace_back(0);
blocks.lookup.q_poseidon2_external().emplace_back(0);
blocks.lookup.q_poseidon2_internal().emplace_back(0);

if constexpr (HasAdditionalSelectors<Arithmetization>) {
blocks.lookup.pad_additional();
}
Expand Down Expand Up @@ -1068,7 +1065,6 @@ void UltraCircuitBuilder_<Arithmetization>::create_sort_constraint(const std::ve
blocks.delta_range.q_aux().emplace_back(0);
blocks.delta_range.q_poseidon2_external().emplace_back(0);
blocks.delta_range.q_poseidon2_internal().emplace_back(0);

if constexpr (HasAdditionalSelectors<Arithmetization>) {
blocks.delta_range.pad_additional();
}
Expand Down Expand Up @@ -1734,7 +1730,6 @@ std::array<uint32_t, 2> UltraCircuitBuilder_<Arithmetization>::evaluate_non_nati
blocks.aux.q_aux().emplace_back(0);
blocks.aux.q_poseidon2_external().emplace_back(0);
blocks.aux.q_poseidon2_internal().emplace_back(0);

if constexpr (HasAdditionalSelectors<Arithmetization>) {
blocks.aux.pad_additional();
}
Expand Down

0 comments on commit 5304c7e

Please sign in to comment.