Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bbapi_crypto.cpp
Go to the documentation of this file.
1
13
14namespace bb::bbapi {
15
20
22{
24
25 // inputs is already std::array<fr, 4>, direct use
26 return { Permutation::permutation(inputs) };
27}
28
35
37{
39 ctx.offset = static_cast<size_t>(hash_index);
40 return { crypto::pedersen_hash::hash(inputs, ctx) };
41}
42
49
54
56{
57 auto hash_result = crypto::blake2s(data);
58 return { fr::serialize_from_buffer(hash_result.data()) };
59}
60
62{
63 // Copy plaintext as AES encrypts in-place
64 std::vector<uint8_t> result = plaintext;
65 result.resize(length);
66
67 crypto::aes128_encrypt_buffer_cbc(result.data(), iv.data(), key.data(), length);
68
69 return { std::move(result) };
70}
71
73{
74 // Copy ciphertext as AES decrypts in-place
75 std::vector<uint8_t> result = ciphertext;
76 result.resize(length);
77
78 crypto::aes128_decrypt_buffer_cbc(result.data(), iv.data(), key.data(), length);
79
80 return { std::move(result) };
81}
82
83} // namespace bb::bbapi
Cryptographic primitives command definitions for the Barretenberg RPC API.
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
Applies the Poseidon2 permutation function from https://eprint.iacr.org/2023/323.
static AffineElement commit_native(const std::vector< Fq > &inputs, GeneratorContext context={})
Given a vector of fields, generate a pedersen commitment using the indexed generators.
Definition pedersen.cpp:24
static Fq hash_buffer(const std::vector< uint8_t > &input, GeneratorContext context={})
Given an arbitrary length of bytes, convert them to fields and hash the result using the default gene...
Definition pedersen.cpp:88
static Fq hash(const std::vector< Fq > &inputs, GeneratorContext context={})
Given a vector of fields, generate a pedersen hash using generators from context.
Definition pedersen.cpp:78
#define BB_UNUSED
const std::vector< MemoryValue > data
uint8_t const size_t length
Definition data_store.hpp:9
stdlib::Poseidon2Permutation< Builder > Permutation
AvmProvingInputs inputs
void aes128_decrypt_buffer_cbc(uint8_t *buffer, uint8_t *iv, const uint8_t *key, const size_t length)
Definition aes128.cpp:253
std::array< uint8_t, BLAKE2S_OUTBYTES > blake2s(std::vector< uint8_t > const &input)
Definition blake2s.cpp:232
void aes128_encrypt_buffer_cbc(uint8_t *buffer, uint8_t *iv, const uint8_t *key, const size_t length)
Definition aes128.cpp:233
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Response execute(BBApiRequest &request) &&
Response execute(BBApiRequest &request) &&
Response execute(BBApiRequest &request) &&
Response execute(BBApiRequest &request) &&
Response execute(BBApiRequest &request) &&
Response execute(BBApiRequest &request) &&
Response execute(BBApiRequest &request) &&
Response execute(BBApiRequest &request) &&
Response execute(BBApiRequest &request) &&
static field serialize_from_buffer(const uint8_t *buffer)