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[] = "PedersenCommit";
66
67 struct Response {
68 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenCommitResponse";
71 bool operator==(const Response&) const = default;
72 };
73
75 uint32_t hash_index;
76 Response execute(BBApiRequest& request) &&;
78 bool operator==(const PedersenCommit&) const = default;
79};
80
86 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHash";
87
88 struct Response {
89 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHashResponse";
92 bool operator==(const Response&) const = default;
93 };
94
96 uint32_t hash_index;
97 Response execute(BBApiRequest& request) &&;
99 bool operator==(const PedersenHash&) const = default;
100};
101
107 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHashBuffer";
108
109 struct Response {
110 static constexpr const char MSGPACK_SCHEMA_NAME[] = "PedersenHashBufferResponse";
113 bool operator==(const Response&) const = default;
114 };
115
116 std::vector<uint8_t> input;
117 uint32_t hash_index;
118 Response execute(BBApiRequest& request) &&;
120 bool operator==(const PedersenHashBuffer&) const = default;
121};
122
127struct Blake2s {
128 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2s";
129
130 struct Response {
131 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2sResponse";
132 std::array<uint8_t, 32> hash;
134 bool operator==(const Response&) const = default;
135 };
136
137 std::vector<uint8_t> data;
138 Response execute(BBApiRequest& request) &&;
140 bool operator==(const Blake2s&) const = default;
141};
142
148 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2sToField";
149
150 struct Response {
151 static constexpr const char MSGPACK_SCHEMA_NAME[] = "Blake2sToFieldResponse";
154 bool operator==(const Response&) const = default;
155 };
156
157 std::vector<uint8_t> data;
158 Response execute(BBApiRequest& request) &&;
160 bool operator==(const Blake2sToField&) const = default;
161};
162
168 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesEncrypt";
169
170 struct Response {
171 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesEncryptResponse";
172 std::vector<uint8_t> ciphertext;
174 bool operator==(const Response&) const = default;
175 };
176
177 std::vector<uint8_t> plaintext;
178 std::array<uint8_t, 16> iv;
179 std::array<uint8_t, 16> key;
180 uint32_t length;
181 Response execute(BBApiRequest& request) &&;
183 bool operator==(const AesEncrypt&) const = default;
184};
185
191 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesDecrypt";
192
193 struct Response {
194 static constexpr const char MSGPACK_SCHEMA_NAME[] = "AesDecryptResponse";
195 std::vector<uint8_t> plaintext;
197 bool operator==(const Response&) const = default;
198 };
199
200 std::vector<uint8_t> ciphertext;
201 std::array<uint8_t, 16> iv;
202 std::array<uint8_t, 16> key;
203 uint32_t length;
204 Response execute(BBApiRequest& request) &&;
206 bool operator==(const AesDecrypt&) const = default;
207};
208
209} // 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[]