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
6
7namespace bb::bbapi {
8
13
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
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
Schnorr signature command definitions for the Barretenberg RPC API.
static constexpr element one
Definition group.hpp:46
#define BB_UNUSED
void secure_erase_bytes(void *ptr, size_t size)
Definition hmac.hpp:18
Response execute(BBApiRequest &request) &&
Response execute(BBApiRequest &request) &&
Response execute(BBApiRequest &request) &&