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// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], commit: dd03c4a23ab067274b4964cacb36d1545f73fb14}
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
20#include <array>
21#include <cstdint>
22#include <vector>
23
24namespace bb::bbapi {
25
31 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Poseidon2Hash";
32
33 struct Response {
34 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Poseidon2HashResponse";
37 bool operator==(const Response&) const = default;
38 };
39
40 std::vector<fr> inputs;
41 Response execute(BBApiRequest& request) &&;
43 bool operator==(const Poseidon2Hash&) const = default;
44};
45
51 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Poseidon2Permutation";
52
53 struct Response {
54 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Poseidon2PermutationResponse";
57 bool operator==(const Response&) const = default;
58 };
59
61 Response execute(BBApiRequest& request) &&;
63 bool operator==(const Poseidon2Permutation&) const = default;
64};
65
71 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenCommit";
72
73 struct Response {
74 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenCommitResponse";
77 bool operator==(const Response&) const = default;
78 };
79
81 uint32_t hash_index;
82 Response execute(BBApiRequest& request) &&;
84 bool operator==(const PedersenCommit&) const = default;
85};
86
92 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHash";
93
94 struct Response {
95 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHashResponse";
98 bool operator==(const Response&) const = default;
99 };
100
102 uint32_t hash_index;
103 Response execute(BBApiRequest& request) &&;
105 bool operator==(const PedersenHash&) const = default;
106};
107
113 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHashBuffer";
114
115 struct Response {
116 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHashBufferResponse";
119 bool operator==(const Response&) const = default;
120 };
121
122 std::vector<uint8_t> input;
123 uint32_t hash_index;
124 Response execute(BBApiRequest& request) &&;
126 bool operator==(const PedersenHashBuffer&) const = default;
127};
128
133struct Blake2s {
134 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2s";
135
136 struct Response {
137 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2sResponse";
138 std::array<uint8_t, 32> hash;
140 bool operator==(const Response&) const = default;
141 };
142
143 std::vector<uint8_t> data;
144 Response execute(BBApiRequest& request) &&;
146 bool operator==(const Blake2s&) const = default;
147};
148
154 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2sToField";
155
156 struct Response {
157 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2sToFieldResponse";
160 bool operator==(const Response&) const = default;
161 };
162
163 std::vector<uint8_t> data;
164 Response execute(BBApiRequest& request) &&;
166 bool operator==(const Blake2sToField&) const = default;
167};
168
174 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesEncrypt";
175
176 struct Response {
177 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesEncryptResponse";
178 std::vector<uint8_t> ciphertext;
180 bool operator==(const Response&) const = default;
181 };
182
183 std::vector<uint8_t> plaintext;
184 std::array<uint8_t, 16> iv;
185 std::array<uint8_t, 16> key;
186 uint32_t length;
187 Response execute(BBApiRequest& request) &&;
189 bool operator==(const AesEncrypt&) const = default;
190};
191
197 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesDecrypt";
198
199 struct Response {
200 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesDecryptResponse";
201 std::vector<uint8_t> plaintext;
203 bool operator==(const Response&) const = default;
204 };
205
206 std::vector<uint8_t> ciphertext;
207 std::array<uint8_t, 16> iv;
208 std::array<uint8_t, 16> key;
209 uint32_t length;
210 Response execute(BBApiRequest& request) &&;
212 bool operator==(const AesDecrypt&) const = default;
213};
214
215} // 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
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[]