Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bbapi_ecc.hpp
Go to the documentation of this file.
1#pragma once
16#include <array>
17#include <cstdint>
18#include <vector>
19
20namespace bb::bbapi {
21
27 static constexpr const char MSGPACK_SCHEMA_NAME[] = "GrumpkinMul";
28
29 struct Response {
30 static constexpr const char MSGPACK_SCHEMA_NAME[] = "GrumpkinMulResponse";
33 bool operator==(const Response&) const = default;
34 };
35
38 Response execute(BBApiRequest& request) &&;
40 bool operator==(const GrumpkinMul&) const = default;
41};
42
48 static constexpr const char MSGPACK_SCHEMA_NAME[] = "GrumpkinAdd";
49
50 struct Response {
51 static constexpr const char MSGPACK_SCHEMA_NAME[] = "GrumpkinAddResponse";
54 bool operator==(const Response&) const = default;
55 };
56
59 Response execute(BBApiRequest& request) &&;
61 bool operator==(const GrumpkinAdd&) const = default;
62};
63
69 static constexpr const char MSGPACK_SCHEMA_NAME[] = "GrumpkinBatchMul";
70
71 struct Response {
72 static constexpr const char MSGPACK_SCHEMA_NAME[] = "GrumpkinBatchMulResponse";
75 bool operator==(const Response&) const = default;
76 };
77
80 Response execute(BBApiRequest& request) &&;
82 bool operator==(const GrumpkinBatchMul&) const = default;
83};
84
90 static constexpr const char MSGPACK_SCHEMA_NAME[] = "GrumpkinGetRandomFr";
91
92 struct Response {
93 static constexpr const char MSGPACK_SCHEMA_NAME[] = "GrumpkinGetRandomFrResponse";
96 bool operator==(const Response&) const = default;
97 };
98
99 // Empty struct for commands with no input - use a dummy field for msgpack
100 uint8_t dummy = 0;
101 Response execute(BBApiRequest& request) &&;
103 bool operator==(const GrumpkinGetRandomFr&) const = default;
104};
105
111 static constexpr const char MSGPACK_SCHEMA_NAME[] = "GrumpkinReduce512";
112
113 struct Response {
114 static constexpr const char MSGPACK_SCHEMA_NAME[] = "GrumpkinReduce512Response";
117 bool operator==(const Response&) const = default;
118 };
119
120 std::array<uint8_t, 64> input;
121 Response execute(BBApiRequest& request) &&;
123 bool operator==(const GrumpkinReduce512&) const = default;
124};
125
131 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Secp256k1Mul";
132
133 struct Response {
134 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Secp256k1MulResponse";
137 bool operator==(const Response&) const = default;
138 };
139
142 Response execute(BBApiRequest& request) &&;
144 bool operator==(const Secp256k1Mul&) const = default;
145};
146
152 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Secp256k1GetRandomFr";
153
154 struct Response {
155 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Secp256k1GetRandomFrResponse";
158 bool operator==(const Response&) const = default;
159 };
160
161 // Empty struct for commands with no input - use a dummy field for msgpack
162 uint8_t dummy = 0;
163 Response execute(BBApiRequest& request) &&;
165 bool operator==(const Secp256k1GetRandomFr&) const = default;
166};
167
173 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Secp256k1Reduce512";
174
175 struct Response {
176 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Secp256k1Reduce512Response";
179 bool operator==(const Response&) const = default;
180 };
181
182 std::array<uint8_t, 64> input;
183 Response execute(BBApiRequest& request) &&;
185 bool operator==(const Secp256k1Reduce512&) const = default;
186};
187
193 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254FrSqrt";
194
195 struct Response {
196 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254FrSqrtResponse";
200 bool operator==(const Response&) const = default;
201 };
202
204 Response execute(BBApiRequest& request) &&;
206 bool operator==(const Bn254FrSqrt&) const = default;
207};
208
214 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254FqSqrt";
215
216 struct Response {
217 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254FqSqrtResponse";
221 bool operator==(const Response&) const = default;
222 };
223
225 Response execute(BBApiRequest& request) &&;
227 bool operator==(const Bn254FqSqrt&) const = default;
228};
229
235 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254G1Mul";
236
237 struct Response {
238 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254G1MulResponse";
241 bool operator==(const Response&) const = default;
242 };
243
246 Response execute(BBApiRequest& request) &&;
248 bool operator==(const Bn254G1Mul&) const = default;
249};
250
256 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254G2Mul";
257
258 struct Response {
259 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254G2MulResponse";
262 bool operator==(const Response&) const = default;
263 };
264
267 Response execute(BBApiRequest& request) &&;
269 bool operator==(const Bn254G2Mul&) const = default;
270};
271
277 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254G1IsOnCurve";
278
279 struct Response {
280 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254G1IsOnCurveResponse";
283 bool operator==(const Response&) const = default;
284 };
285
287 Response execute(BBApiRequest& request) &&;
289 bool operator==(const Bn254G1IsOnCurve&) const = default;
290};
291
297 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254G1FromCompressed";
298
299 struct Response {
300 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Bn254G1FromCompressedResponse";
303 bool operator==(const Response&) const = default;
304 };
305
306 std::array<uint8_t, 32> compressed = {};
307 Response execute(BBApiRequest& request) &&;
309 bool operator==(const Bn254G1FromCompressed&) const = default;
310};
311
312} // namespace bb::bbapi
Shared type definitions for the Barretenberg RPC API.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
MSGPACK_FIELDS(is_square_root, value)
Compute square root of a BN254 Fq (base field) element.
bool operator==(const Bn254FqSqrt &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:79
MSGPACK_FIELDS(is_square_root, value)
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Compute square root of a BN254 Fr (scalar field) element.
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Bn254FrSqrt &) const =default
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:73
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
Decompress a BN254 G1 point from compressed form.
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::array< uint8_t, 32 > compressed
bool operator==(const Bn254G1FromCompressed &) const =default
Response execute(BBApiRequest &request) &&
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
Check if a BN254 G1 point is on the curve.
Response execute(BBApiRequest &request) &&
bool operator==(const Bn254G1IsOnCurve &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
bb::g1::affine_element point
bb::g1::affine_element point
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
Multiply a BN254 G1 point by a scalar.
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:85
MSGPACK_FIELDS(point, scalar)
bb::g1::affine_element point
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Bn254G1Mul &) const =default
bb::g2::affine_element point
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Multiply a BN254 G2 point by a scalar.
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Bn254G2Mul &) const =default
MSGPACK_FIELDS(point, scalar)
bb::g2::affine_element point
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:97
static constexpr const char MSGPACK_SCHEMA_NAME[]
Definition bbapi_ecc.hpp:51
bool operator==(const Response &) const =default
grumpkin::g1::affine_element point
Definition bbapi_ecc.hpp:52
Add two Grumpkin points.
Definition bbapi_ecc.hpp:47
grumpkin::g1::affine_element point_a
Definition bbapi_ecc.hpp:57
static constexpr const char MSGPACK_SCHEMA_NAME[]
Definition bbapi_ecc.hpp:48
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:17
MSGPACK_FIELDS(point_a, point_b)
bool operator==(const GrumpkinAdd &) const =default
grumpkin::g1::affine_element point_b
Definition bbapi_ecc.hpp:58
std::vector< grumpkin::g1::affine_element > points
Definition bbapi_ecc.hpp:73
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Definition bbapi_ecc.hpp:72
Multiply multiple Grumpkin points by a single scalar.
Definition bbapi_ecc.hpp:68
std::vector< grumpkin::g1::affine_element > points
Definition bbapi_ecc.hpp:78
bool operator==(const GrumpkinBatchMul &) const =default
MSGPACK_FIELDS(points, scalar)
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:28
static constexpr const char MSGPACK_SCHEMA_NAME[]
Definition bbapi_ecc.hpp:69
static constexpr const char MSGPACK_SCHEMA_NAME[]
Definition bbapi_ecc.hpp:93
bool operator==(const Response &) const =default
Get a random Grumpkin field element (BN254 Fr)
Definition bbapi_ecc.hpp:89
static constexpr const char MSGPACK_SCHEMA_NAME[]
Definition bbapi_ecc.hpp:90
bool operator==(const GrumpkinGetRandomFr &) const =default
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:39
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Definition bbapi_ecc.hpp:30
grumpkin::g1::affine_element point
Definition bbapi_ecc.hpp:31
Multiply a Grumpkin point by a scalar.
Definition bbapi_ecc.hpp:26
grumpkin::g1::affine_element point
Definition bbapi_ecc.hpp:36
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:9
MSGPACK_FIELDS(point, scalar)
bool operator==(const GrumpkinMul &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Definition bbapi_ecc.hpp:27
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Reduce a 512-bit value modulo Grumpkin scalar field (BN254 Fr)
std::array< uint8_t, 64 > input
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:44
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const GrumpkinReduce512 &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
Get a random Secp256k1 field element.
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:60
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Secp256k1GetRandomFr &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
secp256k1::g1::affine_element point
bool operator==(const Response &) const =default
Multiply a Secp256k1 point by a scalar.
static constexpr const char MSGPACK_SCHEMA_NAME[]
MSGPACK_FIELDS(point, scalar)
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:52
bool operator==(const Secp256k1Mul &) const =default
secp256k1::g1::affine_element point
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Reduce a 512-bit value modulo Secp256k1 scalar field.
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Secp256k1Reduce512 &) const =default
std::array< uint8_t, 64 > input
Response execute(BBApiRequest &request) &&
Definition bbapi_ecc.cpp:65