Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
native_crs_factory.hpp
Go to the documentation of this file.
1#pragma once
6#include <filesystem>
7#include <memory>
8
9namespace bb::srs::factories {
10
25MemBn254CrsFactory init_bn254_crs(const std::filesystem::path& path,
26 size_t dyadic_circuit_size,
27 bool allow_download = true);
28MemGrumpkinCrsFactory init_grumpkin_crs(const std::filesystem::path& path,
29 size_t eccvm_dyadic_circuit_size,
30 bool allow_download = true);
31
35class NativeBn254CrsFactory : public CrsFactory<curve::BN254> {
36 public:
37 NativeBn254CrsFactory(const std::filesystem::path& path, bool allow_download = true)
38 : path_(path)
39 , allow_download_(allow_download)
40 {}
42 {
43 if (degree > last_degree_ || mem_crs_ == nullptr) {
45 last_degree_ = degree;
46 }
47 return mem_crs_->get_crs(degree);
48 }
49
50 private:
51 std::filesystem::path path_;
52 bool allow_download_ = true;
53 size_t last_degree_ = 0;
55};
56
57class NativeGrumpkinCrsFactory : public CrsFactory<curve::Grumpkin> {
58 public:
59 NativeGrumpkinCrsFactory(const std::filesystem::path& path, bool allow_download = true)
60 : path_(path)
61 , allow_download_(allow_download)
62 {}
63
65 {
66 if (degree > last_degree_ || mem_crs_ == nullptr) {
68 last_degree_ = degree;
69 }
70 return mem_crs_->get_crs(degree);
71 }
72
73 private:
74 std::filesystem::path path_;
75 bool allow_download_ = true;
76 size_t last_degree_ = 0;
78};
79
80} // namespace bb::srs::factories
NativeBn254CrsFactory(const std::filesystem::path &path, bool allow_download=true)
std::shared_ptr< MemBn254CrsFactory > mem_crs_
std::shared_ptr< Crs< curve::BN254 > > get_crs(size_t degree) override
std::shared_ptr< Crs< curve::Grumpkin > > get_crs(size_t degree) override
NativeGrumpkinCrsFactory(const std::filesystem::path &path, bool allow_download=true)
std::unique_ptr< MemGrumpkinCrsFactory > mem_crs_
MemBn254CrsFactory init_bn254_crs(const std::filesystem::path &path, size_t dyadic_circuit_size, bool allow_download)
Initialize a memory crs factory for bn254 based on a known dyadic circuit size.
MemGrumpkinCrsFactory init_grumpkin_crs(const std::filesystem::path &path, size_t eccvm_dyadic_circuit_size, bool allow_download)
Initialize a memory crs factory for grumpkin based on a known dyadic circuit size.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13