11std::vector<uint8_t> download_bn254_g1_data(
size_t num_points)
23 auto first_element = from_buffer<bb::g1::affine_element>(
data, 0);
25 throw_or_abort(
"Downloaded BN254 G1 CRS first element does not match expected point.");
32 throw_or_abort(
"Downloaded BN254 G1 CRS second element does not match expected point.");
45 std::filesystem::create_directories(path);
47 auto g1_path = path /
"bn254_g1.dat";
48 auto lock_path = path /
"crs.lock";
54 if (g1_downloaded_points >= num_points) {
55 vinfo(
"using cached bn254 crs with num points ",
std::to_string(g1_downloaded_points),
" at ", g1_path);
58 for (
size_t i = 0; i < num_points; ++i) {
64 if (!allow_download && g1_downloaded_points == 0) {
65 throw_or_abort(
"bn254 g1 data not found and download not allowed in this context");
66 }
else if (!allow_download) {
71 " were requested but download not allowed in this context"));
76 if (g1_downloaded_points >= num_points) {
77 vinfo(
"using cached bn254 crs with num points ",
std::to_string(g1_downloaded_points),
" at ", g1_path);
80 for (
size_t i = 0; i < num_points; ++i) {
86 vinfo(
"downloading bn254 crs...");
87 auto data = download_bn254_g1_data(num_points);
91 for (
size_t i = 0; i < num_points; ++i) {
group_elements::affine_element< Fq, Fr, Params > affine_element
std::string format(Args... args)
const std::vector< FF > data
std::vector< uint8_t > http_download(const std::string &url, size_t start_byte=0, size_t end_byte=0)
Download data from a URL with optional Range header support.
constexpr g1::affine_element BN254_G1_FIRST_ELEMENT
Expected first G1 element from BN254 CRS.
g1::affine_element get_bn254_g1_second_element()
Expected second G1 element from BN254 CRS.
Entry point for Barretenberg command-line interface.
std::vector< uint8_t > read_file(const std::string &filename, size_t bytes=0)
std::vector< g1::affine_element > get_bn254_g1_data(const std::filesystem::path &path, size_t num_points, bool allow_download)
void write_file(const std::string &filename, std::vector< uint8_t > const &data)
size_t get_file_size(std::string const &filename)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
void throw_or_abort(std::string const &err)