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>();
47 verifier_transcript->load_proof(prover_transcript->export_proof());
48 verifier_transcript->template receive_from_prover<Fq>("init");
49 auto verification_key = std::make_shared<TranslatorFlavor::VerificationKey>(proving_key->proving_key);
50 TranslatorVerifier verifier(verification_key, verifier_transcript);
51 bool verified = verifier.verify_proof(proof, x, translation_batching_challenge);
52 (void)checked;
53 (void)verified;
54 return 0;
55}
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.
bool verify_proof(const HonkProof &proof, const uint256_t &evaluation_input_x, const BF &batching_challenge_v)
This function verifies a TranslatorFlavor Honk proof for given program settings.
const std::vector< FF > 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 ***)