Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bbapi_crypto.hpp
Go to the documentation of this file.
1#pragma once
14#include <array>
15#include <cstdint>
16#include <vector>
17
18namespace bb::bbapi {
19
25 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Poseidon2Hash";
26
27 struct Response {
28 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Poseidon2HashResponse";
31 bool operator==(const Response&) const = default;
32 };
33
34 std::vector<fr> inputs;
35 Response execute(BBApiRequest& request) &&;
37 bool operator==(const Poseidon2Hash&) const = default;
38};
39
45 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Poseidon2Permutation";
46
47 struct Response {
48 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Poseidon2PermutationResponse";
51 bool operator==(const Response&) const = default;
52 };
53
55 Response execute(BBApiRequest& request) &&;
57 bool operator==(const Poseidon2Permutation&) const = default;
58};
59
65 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Poseidon2HashAccumulate";
66
67 struct Response {
68 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Poseidon2HashAccumulateResponse";
71 bool operator==(const Response&) const = default;
72 };
73
74 std::vector<fr> inputs;
75 Response execute(BBApiRequest& request) &&;
77 bool operator==(const Poseidon2HashAccumulate&) const = default;
78};
79
85 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenCommit";
86
87 struct Response {
88 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenCommitResponse";
91 bool operator==(const Response&) const = default;
92 };
93
95 uint32_t hash_index;
96 Response execute(BBApiRequest& request) &&;
98 bool operator==(const PedersenCommit&) const = default;
99};
100
106 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHash";
107
108 struct Response {
109 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHashResponse";
112 bool operator==(const Response&) const = default;
113 };
114
116 uint32_t hash_index;
117 Response execute(BBApiRequest& request) &&;
119 bool operator==(const PedersenHash&) const = default;
120};
121
127 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHashBuffer";
128
129 struct Response {
130 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHashBufferResponse";
133 bool operator==(const Response&) const = default;
134 };
135
136 std::vector<uint8_t> input;
137 uint32_t hash_index;
138 Response execute(BBApiRequest& request) &&;
140 bool operator==(const PedersenHashBuffer&) const = default;
141};
142
147struct Blake2s {
148 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2s";
149
150 struct Response {
151 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2sResponse";
152 std::array<uint8_t, 32> hash;
154 bool operator==(const Response&) const = default;
155 };
156
157 std::vector<uint8_t> data;
158 Response execute(BBApiRequest& request) &&;
160 bool operator==(const Blake2s&) const = default;
161};
162
168 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2sToField";
169
170 struct Response {
171 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2sToFieldResponse";
174 bool operator==(const Response&) const = default;
175 };
176
177 std::vector<uint8_t> data;
178 Response execute(BBApiRequest& request) &&;
180 bool operator==(const Blake2sToField&) const = default;
181};
182
188 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesEncrypt";
189
190 struct Response {
191 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesEncryptResponse";
192 std::vector<uint8_t> ciphertext;
194 bool operator==(const Response&) const = default;
195 };
196
197 std::vector<uint8_t> plaintext;
198 std::array<uint8_t, 16> iv;
199 std::array<uint8_t, 16> key;
200 uint32_t length;
201 Response execute(BBApiRequest& request) &&;
203 bool operator==(const AesEncrypt&) const = default;
204};
205
211 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesDecrypt";
212
213 struct Response {
214 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesDecryptResponse";
215 std::vector<uint8_t> plaintext;
217 bool operator==(const Response&) const = default;
218 };
219
220 std::vector<uint8_t> ciphertext;
221 std::array<uint8_t, 16> iv;
222 std::array<uint8_t, 16> key;
223 uint32_t length;
224 Response execute(BBApiRequest& request) &&;
226 bool operator==(const AesDecrypt&) const = default;
227};
228
229} // namespace bb::bbapi
Shared type definitions for the Barretenberg RPC API.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::vector< uint8_t > plaintext
bool operator==(const Response &) const =default
AES-128 CBC decryption.
bool operator==(const AesDecrypt &) const =default
MSGPACK_FIELDS(ciphertext, iv, key, length)
std::array< uint8_t, 16 > iv
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::array< uint8_t, 16 > key
std::vector< uint8_t > ciphertext
Response execute(BBApiRequest &request) &&
bool operator==(const Response &) const =default
std::vector< uint8_t > ciphertext
static constexpr const char MSGPACK_SCHEMA_NAME[]
AES-128 CBC encryption.
std::array< uint8_t, 16 > iv
MSGPACK_FIELDS(plaintext, iv, key, length)
std::vector< uint8_t > plaintext
bool operator==(const AesEncrypt &) const =default
Response execute(BBApiRequest &request) &&
std::array< uint8_t, 16 > key
static constexpr const char MSGPACK_SCHEMA_NAME[]
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
std::array< uint8_t, 32 > hash
Compute Blake2s hash.
std::vector< uint8_t > data
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Blake2s &) const =default
Response execute(BBApiRequest &request) &&
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Compute Blake2s hash and convert to field element.
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Blake2sToField &) const =default
std::vector< uint8_t > data
Response execute(BBApiRequest &request) &&
bool operator==(const Response &) const =default
grumpkin::g1::affine_element point
static constexpr const char MSGPACK_SCHEMA_NAME[]
Compute Pedersen commitment to field elements.
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const PedersenCommit &) const =default
MSGPACK_FIELDS(inputs, hash_index)
Response execute(BBApiRequest &request) &&
std::vector< grumpkin::fq > inputs
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
Compute Pedersen hash of raw buffer.
bool operator==(const PedersenHashBuffer &) const =default
Response execute(BBApiRequest &request) &&
static constexpr const char MSGPACK_SCHEMA_NAME[]
MSGPACK_FIELDS(input, hash_index)
std::vector< uint8_t > input
Compute Pedersen hash of field elements.
bool operator==(const PedersenHash &) const =default
Response execute(BBApiRequest &request) &&
MSGPACK_FIELDS(inputs, hash_index)
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::vector< grumpkin::fq > inputs
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
Compute accumulated Poseidon2 hash.
bool operator==(const Poseidon2HashAccumulate &) const =default
Response execute(BBApiRequest &request) &&
static constexpr const char MSGPACK_SCHEMA_NAME[]
Compute Poseidon2 hash of input field elements.
std::vector< fr > inputs
Response execute(BBApiRequest &request) &&
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Poseidon2Hash &) const =default
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Compute Poseidon2 permutation on state (4 field elements)
bool operator==(const Poseidon2Permutation &) const =default
Response execute(BBApiRequest &request) &&
static constexpr const char MSGPACK_SCHEMA_NAME[]