veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
secp256k1.hpp
1// Copyright (c) 2019-2022 Xenios SEZC
2// https://www.veriblock.org
3// Distributed under the MIT software license, see the accompanying
4// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef __SIGNUTIL__HPP__
7#define __SIGNUTIL__HPP__
8
9#include <cstddef>
10#include <cstdint>
11#include <stdexcept>
12#include <vector>
13#include <veriblock/pop/blob.hpp>
14#include <veriblock/pop/slice.hpp>
15
16namespace altintegration {
17template <class ElementType>
18struct Slice;
19
20namespace secp256k1 {
21
22static const size_t PRIVATE_KEY_SIZE = 32;
23static const size_t PUBLIC_KEY_COMPRESSED_SIZE = 33;
24static const size_t PUBLIC_KEY_UNCOMPRESSED_SIZE = 65;
25
26using PrivateKey = Blob<PRIVATE_KEY_SIZE>;
27using PublicKey = Blob<PUBLIC_KEY_UNCOMPRESSED_SIZE>;
28using Signature = std::vector<uint8_t>;
29
30// VBK encoded keys are plain byte arrays
31using PrivateKeyVbk = std::vector<uint8_t>;
32using PublicKeyVbk = std::vector<uint8_t>;
33
40PrivateKey privateKeyFromVbk(PrivateKeyVbk key);
41
48PublicKey publicKeyFromVbk(PublicKeyVbk key);
49
56PublicKeyVbk publicKeyToVbk(PublicKey key);
57
64PublicKey derivePublicKey(PrivateKey privateKey);
65
75Signature sign(Slice<const uint8_t> message, PrivateKey privateKey);
76
90bool verify(Slice<const uint8_t> message,
91 Signature signature,
92 PublicKey publicKey);
93
94} // namespace secp256k1
95} // namespace altintegration
96
97#endif //__SIGNUTIL__HPP__
Defines logging helpers.
Definition: block.hpp:14