1
// Copyright © 2017-2020 Trust Wallet.
2
//
3
// This file is part of Trust. The full Trust copyright notice, including
4
// terms governing use, modification, and redistribution, is contained in the
5
// file LICENSE at the root of the source code distribution tree.
6

7
#pragma once
8

9
#include "Transaction.h"
10
#include "../Data.h"
11
#include "../Hash.h"
12
#include "../PrivateKey.h"
13
#include "../proto/Nimiq.pb.h"
14

15
namespace TW::Nimiq {
16

17
/// Helper class that performs Nimiq transaction signing.
18
class Signer {
19
  public:
20
    /// Signs a Proto::SigningInput transaction
21
    static Proto::SigningOutput sign(const Proto::SigningInput& input) noexcept;
22
  public:
23
    /// Signs the given transaction.
24
    void sign(const PrivateKey& privateKey, Transaction& transaction) const noexcept;
25

26
    template <typename T>
27 1
    static PublicKey publicKeyFromBytes(const T& data) {
28 1
        assert(data.size() == 32);
29 1
        std::vector<uint8_t> pubkeyInternal;
30 1
        pubkeyInternal.push_back(0x01); // Code for Ed25519
31 1
        pubkeyInternal.insert(pubkeyInternal.end(), data.begin(), data.end());
32 1
        return PublicKey(std::move(pubkeyInternal), TWPublicKeyTypeED25519);
33
    }
34
};
35

36
} // namespace TW::Nimiq

Read our documentation on viewing source code .

Loading