8#include "gtest/gtest.h"
22 using Builder = RecursiveFlavor::CircuitBuilder;
65 constexpr size_t frs_per_G = FrCodec::calc_num_fields<curve::BN254::AffineElement>();
66 constexpr size_t NUM_GEMINI_FOLDS = NativeFlavor::VIRTUAL_LOG_N - 1;
67 constexpr size_t NUM_GEMINI_EVALS = NativeFlavor::VIRTUAL_LOG_N;
70 constexpr size_t LAST_FOLDING_ROUND = 47;
76 for (
size_t i = 1; i <= NUM_GEMINI_FOLDS; ++i) {
82 for (
size_t i = 1; i <= NUM_GEMINI_EVALS; ++i) {
88 manifest.
add_entry(LAST_FOLDING_ROUND + 3,
"Shplonk:Q", frs_per_G);
92 manifest.
add_entry(LAST_FOLDING_ROUND + 4,
"KZG:W", frs_per_G);
93 manifest.
add_challenge(LAST_FOLDING_ROUND + 4,
"KZG:masking_challenge");
114 for (
size_t idx = 0;
auto [challenge_lhs, challenge_rhs] :
zip_view(lhs.
challenge, rhs.challenge)) {
115 if (challenge_lhs != challenge_rhs) {
116 info(
"Mismatch in the challenges at index ", idx);
121 info(
"Mismatch in the unshifted commitments");
125 info(
"Mismatch in the shifted commitments");
129 info(
"Mismatch in the unshifted evaluations");
133 info(
"Mismatch in the shifted evaluations");
146 using FF = RecursiveFlavor::FF;
147 using Commitment = RecursiveFlavor::Commitment;
149 using VKAndHash = RecursiveFlavor::VKAndHash;
154 FF::from_witness(
builder, native_instance->get_vk()->hash()));
160 recursive_instance->alpha = FF::from_witness(
builder, native_instance->alpha);
163 auto native_comms = native_instance->witness_commitments.get_all();
164 for (
auto [native_comm, recursive_comm] :
165 zip_view(native_comms, recursive_instance->witness_commitments.get_all())) {
166 recursive_comm = Commitment::from_witness(
builder, native_comm);
170 recursive_instance->gate_challenges = std::vector<FF>(native_instance->gate_challenges.size());
171 for (
auto [native_challenge, recursive_challenge] :
172 zip_view(native_instance->gate_challenges, recursive_instance->gate_challenges)) {
173 recursive_challenge = FF::from_witness(
builder, native_challenge);
177 recursive_instance->relation_parameters.eta =
178 FF::from_witness(
builder, native_instance->relation_parameters.eta);
179 recursive_instance->relation_parameters.eta_two =
180 FF::from_witness(
builder, native_instance->relation_parameters.eta_two);
181 recursive_instance->relation_parameters.eta_three =
182 FF::from_witness(
builder, native_instance->relation_parameters.eta_three);
183 recursive_instance->relation_parameters.beta =
184 FF::from_witness(
builder, native_instance->relation_parameters.beta);
185 recursive_instance->relation_parameters.gamma =
186 FF::from_witness(
builder, native_instance->relation_parameters.gamma);
187 recursive_instance->relation_parameters.public_input_delta =
188 FF::from_witness(
builder, native_instance->relation_parameters.public_input_delta);
191 if constexpr (NativeFlavor::HasZK) {
192 recursive_instance->gemini_masking_commitment =
193 Commitment::from_witness(
builder, native_instance->gemini_masking_commitment);
196 return recursive_instance;
208 accumulator.
challenge[0] = NativeFF::random_element();
228 instance->polynomials.w_l.at(1) = NativeFF::random_element();
248 auto incoming_verifier_instance =
253 auto [folding_proof, folded_accumulator] = folding_prover.
fold(
std::move(accumulator), incoming_instance);
258 auto decider_proof = decider_prover.
construct_proof(folded_accumulator);
263 auto [first_sumcheck_native, second_sumcheck_native, folded_verifier_accumulator_native] =
267 native_transcript->enable_manifest();
271 auto native_pairing_points = decider_verifier.
verify_proof(folded_verifier_accumulator_native, decider_proof);
272 bool native_verified = native_pairing_points.check();
281 auto [first_sumcheck_recursive, second_sumcheck_recursive, folded_verifier_accumulator] =
287 auto recursive_pairing_points =
288 recursive_decider_verifier.
verify_proof(folded_verifier_accumulator, stdlib_proof);
291 auto recursive_verified = recursive_pairing_points.check();
299 EXPECT_EQ(recursive_verified, native_verified);
302 EXPECT_EQ(first_sumcheck_recursive, first_sumcheck_native);
305 EXPECT_EQ(second_sumcheck_recursive, second_sumcheck_native);
310 auto verifier_manifest = native_transcript->get_manifest();
311 EXPECT_EQ(verifier_manifest, expected_manifest);
318 test_decider(TamperingMode::None);
324 test_decider(TamperingMode::Accumulator);
330 test_decider(TamperingMode::Instance);
335 test_decider(TamperingMode::FoldedAccumulator);
#define BB_DISABLE_ASSERTS()
std::shared_ptr< Napi::ThreadSafeFunction > instance
NativeHypernovaDeciderVerifier::Flavor NativeFlavor
static std::shared_ptr< RecursiveVerifierInstance > create_recursive_verifier_instance(Builder *builder, const std::shared_ptr< NativeVerifierInstance > &native_instance)
Test helper to create a recursive verifier instance from a native one.
static std::shared_ptr< ProverInstance > generate_new_instance(size_t log_num_gates=4)
static void SetUpTestSuite()
RecursiveHypernovaDeciderVerifier::Proof RecursiveProof
NativeFlavor::VerificationKey NativeVerificationKey
static void tamper_with_accumulator(NativeProverAccumulator &accumulator, const TamperingMode &mode)
RecursiveFlavor::CircuitBuilder Builder
static bool compare_prover_verifier_accumulators(const NativeProverAccumulator &lhs, const NativeVerifierAccumulator &rhs)
NativeFlavor::FF NativeFF
NativeFlavor::CommitmentKey CommitmentKey
static void test_decider(const TamperingMode &mode)
RecursiveHypernovaDeciderVerifier::Flavor RecursiveFlavor
static TranscriptManifest build_expected_decider_manifest()
Build the expected transcript manifest for HyperNova decider.
static void tamper_with_instance(std::shared_ptr< ProverInstance > &instance, const TamperingMode &mode)
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
HyperNova decider prover. Produces final opening proof for the accumulated claim.
HonkProof construct_proof(Accumulator &accumulator)
HyperNova decider verifier (native + recursive). Verifies final opening proof.
HypernovaFoldingVerifier< Flavor >::Accumulator Accumulator
PairingPoints verify_proof(Accumulator &accumulator, const Proof &proof)
Flavor::Transcript Transcript
HypernovaFoldingVerifier< Flavor >::Proof Proof
HyperNova folding prover. Folds circuit instances into accumulators, deferring PCS verification.
MultilinearBatchingProverClaim Accumulator
ProverInstance_< Flavor > ProverInstance
Accumulator instance_to_accumulator(const std::shared_ptr< ProverInstance > &instance, const std::shared_ptr< VerificationKey > &honk_vk=nullptr)
Turn an instance into an accumulator by running Sumcheck.
std::pair< HonkProof, Accumulator > fold(Accumulator &&accumulator, const std::shared_ptr< ProverInstance > &instance, const std::shared_ptr< VerificationKey > &honk_vk=nullptr)
Fold an instance into an accumulator.
HyperNova folding verifier (native + recursive). Verifies folding proofs and maintains accumulators.
std::tuple< bool, bool, Accumulator > verify_folding_proof(const std::shared_ptr< typename HypernovaFoldingVerifier::VerifierInstance > &instance, const Proof &proof)
Verify folding proof. Return the new accumulator and the results of the two sumchecks.
VerifierInstance_< Flavor > VerifierInstance
static void add_arithmetic_gates_with_public_inputs(Builder &builder, const size_t num_gates=4)
Add a specified number of arithmetic gates (with public inputs) to the provided circuit.
static void add_lookup_gates(Builder &builder, size_t num_iterations=1)
Add lookup gates using the uint32 XOR lookup table (table size 4096)
static void add_arithmetic_gates(Builder &builder, const size_t num_gates=4)
Add a specified number of arithmetic gates to the provided circuit.
Base Native verification key class.
Contains all the information required by a Honk prover to create a proof, constructed from a finalize...
void add_entry(size_t round, const std::string &element_label, size_t element_size)
void add_challenge(size_t round, const std::string &label)
Add a single challenge label to the manifest for the given round.
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
The VerifierInstance encapsulates all the necessary information for a Honk Verifier to verify a proof...
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
TEST_F(IPATest, ChallengesAreZero)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
Prover's claim for multilinear batching - contains polynomials and their evaluation claims.
Commitment non_shifted_commitment
std::vector< FF > challenge
FF non_shifted_evaluation
Commitment shifted_commitment
Verifier's claim for multilinear batching - contains commitments and evaluation claims.