Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Barretenberg can generate a smart contract that verifies proofs in Solidity (i.e
First, prove the valid execution of your Noir program and export the verification key:

```bash
bb prove --sceme ultra_honk -b ./target/hello_world.json -w ./target/witness-name.gz -o ./target/proof
bb prove --scheme ultra_honk -b ./target/hello_world.json -w ./target/witness-name.gz -o ./target/proof
bb write_vk --scheme ultra_honk -b ./target/hello_world.json -o ./target/vk
```

Expand Down
2 changes: 1 addition & 1 deletion cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@
"configurePreset": "wasm-threads",
"inheritConfigureEnvironment": true,
"jobs": 0,
"targets": ["barretenberg.wasm", "barretenberg.wasm.gz", "bb_cli_bench"]
"targets": ["barretenberg.wasm", "barretenberg.wasm.gz"]
},
{
"name": "xray",
Expand Down
15 changes: 11 additions & 4 deletions cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ function build_wasm {
function build_wasm_threads {
set -eu
if ! cache_download barretenberg-wasm-threads-$hash.zst; then
build_preset wasm-threads
if [ "$(arch)" == "amd64" ] && [ "$CI" -eq 1 ]; then
# We only want to sanity check that we haven't broken wasm ecc ops in merge queue.
build_preset wasm-threads --target barretenberg.wasm barretenberg.wasm.gz ecc_tests
else
build_preset wasm-threads
fi
cache_upload barretenberg-wasm-threads-$hash.zst build-wasm-threads/bin
fi
}
Expand Down Expand Up @@ -199,7 +204,9 @@ function test_cmds {
echo -e "$prefix barretenberg/cpp/scripts/run_test.sh $bin_name $test"
done || (echo "Failed to list tests in $bin" && exit 1)
done
if [ "$(arch)" == "amd64" ] && [ "$CI" -eq 1 ]; then
if [ "$(arch)" == "amd64" ] && [ "$CI_FULL" -eq 1 ]; then
# We only want to sanity check that we haven't broken wasm ecc in merge queue.
echo "$hash barretenberg/cpp/scripts/wasmtime.sh barretenberg/cpp/build-wasm-threads/bin/ecc_tests"
# If in amd64 CI, iterate asan_tests, creating a gtest invocation for each.
for bin_name in "${!asan_tests[@]}"; do
local filter=${asan_tests[$bin_name]}
Expand Down Expand Up @@ -296,8 +303,8 @@ case "$cmd" in
fi

# Recreation of logic from bench.
../../yarn-project/end-to-end/bootstrap.sh generate_example_app_ivc_inputs
../../barretenberg/cpp/scripts/ci_benchmark_ivc_flows.sh $(pwd)/../../yarn-project/end-to-end/example-app-ivc-inputs-out $(pwd)/bench-out
../../yarn-project/end-to-end/bootstrap.sh build_bench
../../yarn-project/end-to-end/bootstrap.sh bench_cmds | grep barretenberg/cpp/scripts/ci_benchmark_ivc_flows.sh | STRICT_SCHEDULING=1 parallelise
;;
"hash")
echo $hash
Expand Down
1 change: 0 additions & 1 deletion cpp/cmake/module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ function(barretenberg_module MODULE_NAME)
PRIVATE
${TRACY_LIBS}
GTest::gtest
GTest::gtest_main
GTest::gmock_main
${TBB_IMPORTED_TARGETS}
)
Expand Down
2 changes: 1 addition & 1 deletion cpp/scripts/ci_benchmark_ivc_flows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function client_ivc_flow {
mkdir -p "$output"
export MEMUSAGE_OUT="$output/peak-memory-mb.txt"

run_bb_cli_bench "$runtime" "$output" "prove -o $output --ivc_inputs_path $flow_folder/ivc-inputs.msgpack --scheme client_ivc"
run_bb_cli_bench "$runtime" "$output" "prove -o $output --ivc_inputs_path $flow_folder/ivc-inputs.msgpack --scheme client_ivc -v"

local end=$(date +%s%N)
local elapsed_ns=$(( end - start ))
Expand Down
2 changes: 1 addition & 1 deletion cpp/scripts/test_civc_standalone_vks_havent_changed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cd ..
# IF A VK CHANGE IS EXPECTED - we need to redo this:
# - Generate inputs: $root/yarn-project/end-to-end/bootstrap.sh generate_example_app_ivc_inputs
# - Upload the compressed results: aws s3 cp bb-civc-inputs-[version].tar.gz s3://aztec-ci-artifacts/protocol/bb-civc-inputs-[version].tar.gz
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-v7.tar.gz"
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-7f48a235.tar.gz"

export inputs_tmp_dir=$(mktemp -d)
trap 'rm -rf "$inputs_tmp_dir"' EXIT SIGINT
Expand Down
5 changes: 2 additions & 3 deletions cpp/scripts/wasmtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# Helper for passing environment variables to wasm and common config.
# Allows accessing ~/.bb-crs and ./ (more can be added as parameters to this script).
set -eu

export WASMTIME_BACKTRACE_DETAILS=1
exec wasmtime run \
-Wthreads=y \
-Sthreads=y \
--env HARDWARE_CONCURRENCY \
--env WASM_BACKTRACE_DETAILS=1 \
${HARDWARE_CONCURRENCY:+--env HARDWARE_CONCURRENCY} \
--env HOME \
${MAIN_ARGS:+--env MAIN_ARGS} \
--dir=$HOME/.bb-crs \
Expand Down
52 changes: 5 additions & 47 deletions cpp/src/barretenberg/api/api_avm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,7 @@ void print_avm_stats()

} // namespace

void avm_check_circuit(const std::filesystem::path&, const std::filesystem::path&)
{
info("!!! VM1 is deprecated. Quitting !!!");
}

void avm_prove(const std::filesystem::path&, const std::filesystem::path&, const std::filesystem::path& output_path)
{
info("!!! VM1 is deprecated. Sleeping 60s and generating fake outputs !!!");

bb::HonkProof proof(AVM_PROOF_LENGTH_IN_FIELDS);
std::fill(proof.begin(), proof.end(), fr::zero());
sleep(60);

std::vector<fr> vk_as_fields(AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS);
std::fill(vk_as_fields.begin(), vk_as_fields.end(), fr::zero());

vinfo("vk fields size: ", vk_as_fields.size());
vinfo("circuit size: ", static_cast<uint64_t>(vk_as_fields[0]));
vinfo("num of pub inputs: ", static_cast<uint64_t>(vk_as_fields[1]));

const auto to_json = [](const std::vector<bb::fr>& data) {
return format("[", join(transform::map(data, [](auto fr) { return format("\"", fr, "\""); })), "]");
};
std::string vk_json = to_json(vk_as_fields);
const auto proof_path = output_path / "proof";
const auto vk_path = output_path / "vk";
const auto vk_fields_path = output_path / "vk_fields.json";

write_file(proof_path, to_buffer(proof));
vinfo("proof written to: ", proof_path);
write_file(vk_path, to_buffer(vk_as_fields));
vinfo("vk written to: ", vk_path);
write_file(vk_fields_path, { vk_json.begin(), vk_json.end() });
vinfo("vk as fields written to: ", vk_fields_path);
}

void avm2_prove(const std::filesystem::path& inputs_path, const std::filesystem::path& output_path)
void avm_prove(const std::filesystem::path& inputs_path, const std::filesystem::path& output_path)
{
avm2::AvmAPI avm;
auto inputs = avm2::AvmAPI::ProvingInputs::from(read_file(inputs_path));
Expand All @@ -83,7 +47,7 @@ void avm2_prove(const std::filesystem::path& inputs_path, const std::filesystem:
}
}

void avm2_check_circuit(const std::filesystem::path& inputs_path)
void avm_check_circuit(const std::filesystem::path& inputs_path)
{
avm2::AvmAPI avm;
auto inputs = avm2::AvmAPI::ProvingInputs::from(read_file(inputs_path));
Expand All @@ -94,16 +58,10 @@ void avm2_check_circuit(const std::filesystem::path& inputs_path)
print_avm_stats();
}

bool avm_verify(const std::filesystem::path&, const std::filesystem::path&)
{
info("!!! VM1 is deprecated. Saying yes !!!");
return true;
}

// NOTE: The proof should NOT include the public inputs.
bool avm2_verify(const std::filesystem::path& proof_path,
const std::filesystem::path& public_inputs_path,
const std::filesystem::path& vk_path)
bool avm_verify(const std::filesystem::path& proof_path,
const std::filesystem::path& public_inputs_path,
const std::filesystem::path& vk_path)
{
const auto proof = many_from_buffer<fr>(read_file(proof_path));
std::vector<uint8_t> vk_bytes = read_file(vk_path);
Expand Down
29 changes: 7 additions & 22 deletions cpp/src/barretenberg/api/api_avm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,18 @@

namespace bb {

/**
* @brief Performs "check circuit" on the AVM circuit for the given public inputs and hints.
*
* @param public_inputs_path Path to the file containing the serialised avm public inputs
* @param hints_path Path to the file containing the serialised avm circuit hints
*/
void avm_check_circuit(const std::filesystem::path& public_inputs_path, const std::filesystem::path& hints_path);

/**
* @brief Writes an avm proof and corresponding (incomplete) verification key to files.
*
* Communication:
* - Filesystem: The proof and vk are written to the paths output_path/proof and output_path/{vk, vk_fields.json}
* - Filesystem: The proof and vk are written to the paths output_path/proof and output_path/vk
*
* @param public_inputs_path Path to the file containing the serialised avm public inputs
* @param hints_path Path to the file containing the serialised avm circuit hints
* @param inputs_path Path to the file containing the serialised avm public inputs and hints
* @param output_path Path (directory) to write the output proof and verification keys
*/
void avm_prove(const std::filesystem::path& public_inputs_path,
const std::filesystem::path& hints_path,
const std::filesystem::path& output_path);

void avm2_prove(const std::filesystem::path& inputs_path, const std::filesystem::path& output_path);
void avm_prove(const std::filesystem::path& inputs_path, const std::filesystem::path& output_path);

void avm2_check_circuit(const std::filesystem::path& inputs_path);
void avm_check_circuit(const std::filesystem::path& inputs_path);

/**
* @brief Verifies an avm proof and writes the result to stdout
Expand All @@ -41,11 +28,9 @@ void avm2_check_circuit(const std::filesystem::path& inputs_path);
* @return true If the proof is valid
* @return false If the proof is invalid
*/
bool avm_verify(const std::filesystem::path& proof_path, const std::filesystem::path& vk_path);

// NOTE: The proof should NOT include the public inputs.
bool avm2_verify(const std::filesystem::path& proof_path,
const std::filesystem::path& public_inputs_path,
const std::filesystem::path& vk_path);
bool avm_verify(const std::filesystem::path& proof_path,
const std::filesystem::path& public_inputs_path,
const std::filesystem::path& vk_path);
} // namespace bb
#endif
71 changes: 14 additions & 57 deletions cpp/src/barretenberg/bb/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,38 +494,16 @@ int parse_and_run_cli_command(int argc, char* argv[])
};

/***************************************************************************************************************
* Subcommand: avm2_prove
***************************************************************************************************************/
CLI::App* avm2_prove_command = app.add_subcommand("avm2_prove", "");
avm2_prove_command->group(""); // hide from list of subcommands
add_verbose_flag(avm2_prove_command);
add_debug_flag(avm2_prove_command);
add_crs_path_option(avm2_prove_command);
std::filesystem::path avm2_prove_output_path{ "./proofs" };
add_output_path_option(avm2_prove_command, avm2_prove_output_path);
add_avm_inputs_option(avm2_prove_command);

/***************************************************************************************************************
* Subcommand: avm2_check_circuit
***************************************************************************************************************/
CLI::App* avm2_check_circuit_command = app.add_subcommand("avm2_check_circuit", "");
avm2_check_circuit_command->group(""); // hide from list of subcommands
add_verbose_flag(avm2_check_circuit_command);
add_debug_flag(avm2_check_circuit_command);
add_crs_path_option(avm2_check_circuit_command);
add_avm_inputs_option(avm2_check_circuit_command);

/***************************************************************************************************************
* Subcommand: avm2_verify
* Subcommand: avm_prove
***************************************************************************************************************/
CLI::App* avm2_verify_command = app.add_subcommand("avm2_verify", "");
avm2_verify_command->group(""); // hide from list of subcommands
add_verbose_flag(avm2_verify_command);
add_debug_flag(avm2_verify_command);
add_crs_path_option(avm2_verify_command);
add_avm_public_inputs_option(avm2_verify_command);
add_proof_path_option(avm2_verify_command);
add_vk_path_option(avm2_verify_command);
CLI::App* avm_prove_command = app.add_subcommand("avm_prove", "");
avm_prove_command->group(""); // hide from list of subcommands
add_verbose_flag(avm_prove_command);
add_debug_flag(avm_prove_command);
add_crs_path_option(avm_prove_command);
std::filesystem::path avm_prove_output_path{ "./proofs" };
add_output_path_option(avm_prove_command, avm_prove_output_path);
add_avm_inputs_option(avm_prove_command);

/***************************************************************************************************************
* Subcommand: avm_check_circuit
Expand All @@ -535,20 +513,7 @@ int parse_and_run_cli_command(int argc, char* argv[])
add_verbose_flag(avm_check_circuit_command);
add_debug_flag(avm_check_circuit_command);
add_crs_path_option(avm_check_circuit_command);
add_avm_public_inputs_option(avm_check_circuit_command);
add_output_path_option(avm_check_circuit_command, output_path);

/***************************************************************************************************************
* Subcommand: avm_prove
***************************************************************************************************************/
CLI::App* avm_prove_command = app.add_subcommand("avm_prove", "");
avm_prove_command->group(""); // hide from list of subcommands
add_verbose_flag(avm_prove_command);
add_debug_flag(avm_prove_command);
add_crs_path_option(avm_prove_command);
std::filesystem::path avm_prove_output_path{ "./proofs" };
add_avm_public_inputs_option(avm_prove_command);
add_output_path_option(avm_prove_command, avm_prove_output_path);
add_avm_inputs_option(avm_check_circuit_command);

/***************************************************************************************************************
* Subcommand: avm_verify
Expand All @@ -559,7 +524,6 @@ int parse_and_run_cli_command(int argc, char* argv[])
add_debug_flag(avm_verify_command);
add_crs_path_option(avm_verify_command);
add_avm_public_inputs_option(avm_verify_command);
add_output_path_option(avm_verify_command, output_path);
add_proof_path_option(avm_verify_command);
add_vk_path_option(avm_verify_command);
#endif
Expand Down Expand Up @@ -655,20 +619,13 @@ int parse_and_run_cli_command(int argc, char* argv[])
}
// AVM
#ifndef DISABLE_AZTEC_VM
else if (avm2_prove_command->parsed()) {
else if (avm_prove_command->parsed()) {
// This outputs both files: proof and vk, under the given directory.
avm2_prove(avm_inputs_path, avm2_prove_output_path);
} else if (avm2_check_circuit_command->parsed()) {
avm2_check_circuit(avm_inputs_path);
} else if (avm2_verify_command->parsed()) {
return avm2_verify(proof_path, avm_public_inputs_path, vk_path) ? 0 : 1;
avm_prove(avm_inputs_path, avm_prove_output_path);
} else if (avm_check_circuit_command->parsed()) {
avm_check_circuit(avm_public_inputs_path, "ignored");
} else if (avm_prove_command->parsed()) {
// This outputs both files: proof and vk, under the given directory.
avm_prove(avm_public_inputs_path, "ignored", avm_prove_output_path);
avm_check_circuit(avm_inputs_path);
} else if (avm_verify_command->parsed()) {
return avm_verify(proof_path, vk_path) ? 0 : 1;
return avm_verify(proof_path, avm_public_inputs_path, vk_path) ? 0 : 1;
}
#endif
// CLIENT IVC EXTRA COMMAND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ BENCHMARK_DEFINE_F(ClientIVCBench, Full)(benchmark::State& state)
ivc.prove();
}
}

/**
* @brief Benchmark the prover work for the full PG-Goblin IVC protocol
* @details Processes "dense" circuits of size 2^17 in a size 2^20 structured trace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Builder generate_trace(size_t target_num_gates)
using G1 = typename Flavor::CycleGroup;
using Fr = typename G1::Fr;

auto generators = G1::derive_generators("test generators", 2);
auto generators = get_precomputed_generators<G1, "test generators", 2>();

typename G1::element a = generators[0];
typename G1::element b = generators[1];
Expand Down
3 changes: 0 additions & 3 deletions cpp/src/barretenberg/benchmark/ultra_bench/mock_circuits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ namespace bb::mock_circuits {
*/
template <typename Builder> void generate_basic_arithmetic_circuit(Builder& builder, size_t log2_num_gates)
{
// Add default pairing points as its required, but this causes gates to be created...
// TODO(https://github.com/AztecProtocol/barretenberg/issues/984): Get rid of gates when creating default
// pairing points.
stdlib::recursion::PairingPoints<Builder>::add_default_to_public_inputs(builder);

stdlib::field_t a(stdlib::witness_t(&builder, fr::random_element()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using witness_ct = bn254::witness_ct;
*/
void fix_bigfield_element(const fq_ct& element)
{
for (int i = 0; i < 4; i++) {
for (size_t i = 0; i < 4; i++) {
element.binary_basis_limbs[i].element.fix_witness();
}
element.prime_basis_limb.fix_witness();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ bool TranslatorCircuitChecker::check(const Builder& circuit)
//
// We also limit computation on limbs of op, z_1 and z_2, since we know that op has only the lowest
// limb and z_1 and z_2 have only the two lowest limbs
const std::array<Fr, 5> NEGATIVE_MODULUS_LIMBS = Builder::NEGATIVE_MODULUS_LIMBS;
constexpr std::array<Fr, 5> NEGATIVE_MODULUS_LIMBS = Builder::NEGATIVE_MODULUS_LIMBS;
const uint256_t SHIFT_1 = Builder::SHIFT_1;
const uint256_t SHIFT_2 = Builder::SHIFT_2;
const uint256_t SHIFT_3 = Builder::SHIFT_3;
Expand Down Expand Up @@ -470,4 +470,4 @@ bool TranslatorCircuitChecker::check(const Builder& circuit)
}
return true;
};
}; // namespace bb
}; // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ TEST(UltraCircuitBuilder, CreateGatesFromPlookupAccumulators)
{
const auto mask = plookup::fixed_base::table::MAX_TABLE_SIZE - 1;

grumpkin::g1::affine_element base_point = plookup::fixed_base::table::LHS_GENERATOR_POINT;
grumpkin::g1::affine_element base_point = plookup::fixed_base::table::lhs_generator_point();
std::vector<uint8_t> input_buf;
write(input_buf, base_point);
const auto offset_generators =
Expand Down
1 change: 0 additions & 1 deletion cpp/src/barretenberg/client_ivc/client_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ HonkProof ClientIVC::decider_prove() const
vinfo("prove decider...");
fold_output.accumulator->proving_key.commitment_key = bn254_commitment_key;
MegaDeciderProver decider_prover(fold_output.accumulator);
vinfo("finished decider proving.");
return decider_prover.construct_proof();
}

Expand Down
Loading