barretenberg
Loading...
Searching...
No Matches
user_context.hpp
1#pragma once
2#include "barretenberg/crypto/schnorr/schnorr.hpp"
3#include "barretenberg/ecc/curves/bn254/fr.hpp"
4#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp"
5
6namespace join_split_example {
7namespace fixtures {
8
10
12 barretenberg::fr note_secret;
14 grumpkin_key_pair signing_keys[2];
15 barretenberg::fr alias_hash;
16};
17
18inline barretenberg::fr generate_alias_hash(std::string const& alias)
19{
20 std::vector<uint8_t> inputv(alias.begin(), alias.end());
21 auto output = blake2::blake2s(inputv);
22 return barretenberg::fr(uint256_t(from_buffer<barretenberg::fr>(output.data())) >> 32);
23}
24
25inline grumpkin_key_pair create_key_pair(numeric::random::Engine* engine)
26{
27 grumpkin::fr priv_key = grumpkin::fr::random_element(engine);
28 grumpkin::g1::affine_element pub_key = grumpkin::g1::one * priv_key;
29 return { priv_key, pub_key };
30}
31
32inline user_context create_user_context(numeric::random::Engine* engine = nullptr)
33{
34 uint8_t vk[] = { 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11,
35 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11 };
36 barretenberg::fr note_secret = barretenberg::fr::serialize_from_buffer(vk);
37 auto alias_hash = generate_alias_hash("pebble");
38 return { note_secret, create_key_pair(engine), { create_key_pair(engine), create_key_pair(engine) }, alias_hash };
39}
40
41} // namespace fixtures
42} // namespace join_split_example
Definition: affine_element.hpp:11
Definition: engine.hpp:10
Definition: uint256.hpp:25
Definition: schnorr.hpp:17
Definition: user_context.hpp:11