-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathbandersnatch_provider.hpp
52 lines (43 loc) · 1.53 KB
/
bandersnatch_provider.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "crypto/bandersnatch_types.hpp"
#include "crypto/bip39/bip39_types.hpp"
namespace kagome::crypto {
class BandersnatchProvider {
public:
using Keypair = BandersnatchKeypair;
using PublicKey = BandersnatchPublicKey;
using PrivateKey = BandersnatchSecretKey;
using Seed = BandersnatchSeed;
using Junctions = std::span<const bip39::RawJunction>;
virtual ~BandersnatchProvider() = default;
/**
* Generate random keypair from seed
*/
virtual outcome::result<BandersnatchKeypair> generateKeypair(
const BandersnatchSeed &seed, Junctions junctions) const = 0;
/**
* Sign message \param msg using \param keypair. If computed value is less
* than \param threshold then return optional containing this value and
* proof. Otherwise none returned
* @param keypair pair of public and secret sr25519 keys
* @param message bytes to be signed
* @return signed message
*/
virtual outcome::result<BandersnatchSignature> sign(
const BandersnatchKeypair &keypair,
common::BufferView message) const = 0;
/**
* Verifies that \param message was derived using \param public_key on
* \param signature
*/
virtual outcome::result<bool> verify(
const BandersnatchSignature &signature,
common::BufferView message,
const BandersnatchPublicKey &public_key) const = 0;
};
} // namespace kagome::crypto