barretenberg
Loading...
Searching...
No Matches
crs_factory.hpp
1#pragma once
2#include "barretenberg/common/mem.hpp"
3#include "barretenberg/ecc/curves/bn254/bn254.hpp"
4#include "barretenberg/ecc/curves/bn254/g1.hpp"
5#include "barretenberg/ecc/curves/bn254/g2.hpp"
6#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp"
7#include <cstddef>
8
9namespace barretenberg::pairing {
10struct miller_lines;
11} // namespace barretenberg::pairing
12
13namespace barretenberg::srs::factories {
14
18template <typename Curve> class ProverCrs {
19 public:
20 virtual ~ProverCrs() = default;
21 ;
22
26 virtual typename Curve::AffineElement* get_monomial_points() = 0;
27 virtual size_t get_monomial_size() const = 0;
28};
29
30template <typename Curve> class VerifierCrs {
31 public:
32 virtual ~VerifierCrs() = default;
33};
34template <> class VerifierCrs<curve::BN254> {
35 using Curve = curve::BN254;
36
37 public:
38 virtual Curve::G2AffineElement get_g2x() const = 0;
48 virtual Curve::AffineElement get_first_g1() const = 0;
49};
50
51template <> class VerifierCrs<curve::Grumpkin> {
52 using Curve = curve::Grumpkin;
53
54 public:
59 virtual Curve::AffineElement* get_monomial_points() const = 0;
60 virtual size_t get_monomial_size() const = 0;
65 virtual Curve::AffineElement get_first_g1() const = 0;
66};
67
72template <typename Curve> class CrsFactory {
73 public:
74 CrsFactory() = default;
75 CrsFactory(CrsFactory&& other) = default;
76 virtual ~CrsFactory() = default;
77 virtual std::shared_ptr<barretenberg::srs::factories::ProverCrs<Curve>> get_prover_crs(size_t) { return nullptr; }
78 virtual std::shared_ptr<barretenberg::srs::factories::VerifierCrs<Curve>> get_verifier_crs(
79 [[maybe_unused]] size_t degree = 0)
80 {
81 return nullptr;
82 }
83};
84
85} // namespace barretenberg::srs::factories
Definition: crs_factory.hpp:72
Definition: crs_factory.hpp:18
virtual Curve::AffineElement * get_monomial_points()=0
Returns the monomial points in a form to be consumed by scalar_multiplication pippenger algorithm.
virtual Curve::AffineElement get_first_g1() const =0
Returns the first G_1 element from the CRS, used by the Shplonk verifier to compute the final commtim...
virtual barretenberg::pairing::miller_lines const * get_precomputed_g2_lines() const =0
As the G_2 element of the CRS is fixed, we can precompute the operations performed on it during the p...
virtual Curve::AffineElement * get_monomial_points() const =0
Returns the G_1 elements in the CRS after the pippenger point table has been applied on them.
virtual Curve::AffineElement get_first_g1() const =0
Returns the first G_1 element from the CRS, used by the Shplonk verifier to compute the final commtim...
Definition: crs_factory.hpp:30
Definition: bn254.hpp:10
Definition: grumpkin.hpp:36
Definition: pairing.hpp:27