Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
translator_composer.fuzzer.cpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
11extern "C" void LLVMFuzzerInitialize(int*, char***)
12{
14}
22extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size)
23{
24 // Parse challenges and opqueue from data
25 auto parsing_result = parse_and_construct_opqueue(data, size);
26 if (!parsing_result.has_value()) {
27 return 0;
28 }
29 auto [batching_challenge_init, x, op_queue] = parsing_result.value();
31 prover_transcript->send_to_verifier("init", batching_challenge_init);
32 prover_transcript->export_proof();
33 Fq translation_batching_challenge = prover_transcript->template get_challenge<Fq>("Translation:batching_challenge");
34
35 // Construct circuit
36 auto circuit_builder = TranslatorCircuitBuilder(translation_batching_challenge, x, op_queue);
37
38 // Check that the circuit passes
39 bool checked = TranslatorCircuitChecker::check(circuit_builder);
40 // Construct proof
41 auto proving_key = std::make_shared<TranslatorProvingKey>(circuit_builder);
42 TranslatorProver prover(proving_key, prover_transcript);
43 auto proof = prover.construct_proof();
44
45 // Verify proof
46 auto verifier_transcript = std::make_shared<bb::TranslatorFlavor::Transcript>(prover_transcript->export_proof());
47 verifier_transcript->template receive_from_prover<Fq>("init");
48 auto verification_key = std::make_shared<TranslatorFlavor::VerificationKey>(proving_key->proving_key);
49 TranslatorVerifier verifier(verification_key, verifier_transcript);
50
51 // Get accumulated_result from prover
52 uint256_t accumulated_result = prover.get_accumulated_result();
53
54 // Commit to op queue wires (normally provided by merge protocol)
56 op_queue_commitments[0] = proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.op);
57 op_queue_commitments[1] =
58 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.x_lo_y_hi);
59 op_queue_commitments[2] =
60 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.x_hi_z_1);
61 op_queue_commitments[3] =
62 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.y_lo_z_2);
63
64 bool verified =
65 verifier.verify_proof(proof, x, translation_batching_challenge, accumulated_result, op_queue_commitments);
66 (void)checked;
67 (void)verified;
68 return 0;
69}
TranslatorCircuitBuilder creates a circuit that evaluates the correctness of the evaluation of EccOpQ...
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
uint256_t get_accumulated_result() const
Extract the accumulated result from the circuit.
bool verify_proof(const HonkProof &proof, const uint256_t &evaluation_input_x, const BF &batching_challenge_v, const uint256_t &accumulated_result, const std::array< Commitment, TranslatorFlavor::NUM_OP_QUEUE_WIRES > &op_queue_wire_commitments)
This function verifies a TranslatorFlavor Honk proof for given program settings.
const std::vector< MemoryValue > data
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Contains common procedures used by the circuit builder fuzzer and the composer fuzzer.
std::optional< std::tuple< Fq, Fq, std::shared_ptr< ECCOpQueue > > > parse_and_construct_opqueue(const unsigned char *data, size_t size)
Try to parse out the batching and evaluating challenges and then the ECCOpQueue from the data.
int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size)
A very primitive fuzzer for the composer.
void LLVMFuzzerInitialize(int *, char ***)