Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bbapi_schnorr.cpp
Go to the documentation of this file.
1
5
#include "
barretenberg/bbapi/bbapi_schnorr.hpp
"
6
7
namespace
bb::bbapi
{
8
9
SchnorrComputePublicKey::Response
SchnorrComputePublicKey::execute
(
BB_UNUSED
BBApiRequest
& request) &&
10
{
11
return
{
grumpkin::g1::one
* private_key };
12
}
13
14
SchnorrConstructSignature::Response
SchnorrConstructSignature::execute
(
BB_UNUSED
BBApiRequest
& request) &&
15
{
16
grumpkin::g1::affine_element
pub_key =
grumpkin::g1::one
* private_key;
17
crypto::schnorr_key_pair<grumpkin::fr, grumpkin::g1>
key_pair = { private_key, pub_key };
18
19
std::string message_str(
reinterpret_cast<
const
char
*
>
(message.data()), message.size());
20
auto
sig = crypto::schnorr_construct_signature<crypto::Blake2sHasher, grumpkin::fq>(message_str, key_pair);
21
crypto::secure_erase_bytes
(&key_pair.
private_key
,
sizeof
(key_pair.
private_key
));
22
23
return
{ sig.s, sig.e };
24
}
25
26
SchnorrVerifySignature::Response
SchnorrVerifySignature::execute
(
BB_UNUSED
BBApiRequest
& request) &&
27
{
28
std::string message_str(
reinterpret_cast<
const
char
*
>
(message.data()), message.size());
29
crypto::schnorr_signature
sig = { s, e };
30
31
bool
result = crypto::schnorr_verify_signature<crypto::Blake2sHasher, grumpkin::fq, grumpkin::fr, grumpkin::g1>(
32
message_str, public_key, sig);
33
34
return
{ result };
35
}
36
37
}
// namespace bb::bbapi
bbapi_schnorr.hpp
Schnorr signature command definitions for the Barretenberg RPC API.
bb::group_elements::affine_element
Definition
affine_element.hpp:27
bb::group::one
static constexpr element one
Definition
group.hpp:46
BB_UNUSED
#define BB_UNUSED
Definition
compiler_hints.hpp:30
bb::bbapi
Definition
bbapi_chonk.cpp:16
bb::crypto::secure_erase_bytes
void secure_erase_bytes(void *ptr, size_t size)
Definition
hmac.hpp:18
bb::bbapi::BBApiRequest
Definition
bbapi_shared.hpp:173
bb::bbapi::SchnorrComputePublicKey::Response
Definition
bbapi_schnorr.hpp:27
bb::bbapi::SchnorrComputePublicKey::execute
Response execute(BBApiRequest &request) &&
Definition
bbapi_schnorr.cpp:9
bb::bbapi::SchnorrConstructSignature::Response
Definition
bbapi_schnorr.hpp:47
bb::bbapi::SchnorrConstructSignature::execute
Response execute(BBApiRequest &request) &&
Definition
bbapi_schnorr.cpp:14
bb::bbapi::SchnorrVerifySignature::Response
Definition
bbapi_schnorr.hpp:69
bb::bbapi::SchnorrVerifySignature::execute
Response execute(BBApiRequest &request) &&
Definition
bbapi_schnorr.cpp:26
bb::crypto::schnorr_key_pair
Definition
schnorr.hpp:16
bb::crypto::schnorr_key_pair::private_key
Fr private_key
Definition
schnorr.hpp:17
bb::crypto::schnorr_signature
Definition
schnorr.hpp:24
src
barretenberg
bbapi
bbapi_schnorr.cpp
Generated by
1.9.8