Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
global_crs.cpp
Go to the documentation of this file.
1#include "global_crs.hpp"
6
7namespace {
10} // namespace
11
12namespace bb::srs {
13
14std::filesystem::path bb_crs_path()
15{
16 char* crs_path = std::getenv("CRS_PATH");
17 if (crs_path != nullptr) {
18 return std::filesystem::path(crs_path);
19 }
20 // Detect home directory for default CRS path
21 char* home = std::getenv("HOME");
22 std::filesystem::path base = home != nullptr ? std::filesystem::path(home) : "./";
23 return base / ".bb-crs";
24}
25
27{
28 bn254_crs_factory = std::make_shared<factories::MemBn254CrsFactory>(points, g2_point);
29}
30
35
36// Initializes the crs using the memory buffers
37void init_bn254_net_crs_factory(const std::filesystem::path& path)
38{
39 if (bn254_crs_factory != nullptr) {
40 return;
41 }
43}
44
45// Initializes crs from a file path this we use in the entire codebase
46void init_bn254_file_crs_factory(const std::filesystem::path& path)
47{
48 if (bn254_crs_factory != nullptr) {
49 return;
50 }
51 bn254_crs_factory = std::make_shared<factories::NativeBn254CrsFactory>(path, /* allow download = false */ false);
52}
53
54// Initializes the crs using the memory buffers
55void init_grumpkin_net_crs_factory(const std::filesystem::path& path)
56{
57 if (grumpkin_crs_factory != nullptr) {
58 return;
59 }
61}
62
63void init_grumpkin_file_crs_factory(const std::filesystem::path& path)
64{
65 if (grumpkin_crs_factory != nullptr) {
66 return;
67 }
68 grumpkin_crs_factory =
69 std::make_shared<factories::NativeGrumpkinCrsFactory>(path, /* allow download = false */ false);
70}
71
73{
74 if (!bn254_crs_factory) {
75 throw_or_abort("You need to initialize the global CRS with a call to init_crs_factory(...)!");
76 }
77 return bn254_crs_factory;
78}
79
81{
82 if (!grumpkin_crs_factory) {
83 throw_or_abort("You need to initialize the global CRS with a call to init_grumpkin_crs_factory(...)!");
84 }
85 return grumpkin_crs_factory;
86}
87
92
97
98} // namespace bb::srs
void init_grumpkin_net_crs_factory(const std::filesystem::path &path)
std::shared_ptr< factories::CrsFactory< curve::BN254 > > get_bn254_crs_factory()
void init_grumpkin_file_crs_factory(const std::filesystem::path &path)
std::filesystem::path bb_crs_path()
std::shared_ptr< factories::CrsFactory< curve::BN254 > > get_crs_factory()
std::shared_ptr< factories::CrsFactory< curve::Grumpkin > > get_grumpkin_crs_factory()
void init_grumpkin_mem_crs_factory(std::vector< curve::Grumpkin::AffineElement > const &points)
void init_bn254_net_crs_factory(const std::filesystem::path &path)
void init_bn254_file_crs_factory(const std::filesystem::path &path)
void init_bn254_mem_crs_factory(std::vector< g1::affine_element > const &points, g2::affine_element const &g2_point)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
void throw_or_abort(std::string const &err)