hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
crypto_model_signer.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_CRYPTO_MODEL_SIGNER_HPP_
7 #define IROHA_CRYPTO_MODEL_SIGNER_HPP_
8 
11 #include "cryptography/keypair.hpp"
12 
14 
15 namespace shared_model {
16 
17  namespace crypto {
18  template <typename Algorithm = CryptoSigner>
20  : public AbstractCryptoModelSigner<interface::Block> {
21  public:
22  explicit CryptoModelSigner(const shared_model::crypto::Keypair &keypair);
23 
24  virtual ~CryptoModelSigner() = default;
25 
26  template <typename T>
27  inline void sign(T &signable) const noexcept {
28  auto signature_hex = Algorithm::sign(signable.payload(), keypair_);
29  using namespace shared_model::interface::types;
30  signable.addSignature(SignedHexStringView{signature_hex},
31  PublicKeyHexStringView{keypair_.publicKey()});
32  }
33 
34  void sign(interface::Block &m) const override {
35  sign<interface::Block>(m);
36  }
37 
38  private:
40  };
41 
42  template <typename Algorithm>
44  const shared_model::crypto::Keypair &keypair)
45  : keypair_(keypair) {}
46 
47  } // namespace crypto
48 } // namespace shared_model
49 
50 #endif // IROHA_CRYPTO_MODEL_SIGNER_HPP_
Definition: keypair.hpp:19
void sign(T &signable) const noexcept
Definition: crypto_model_signer.hpp:27
sig_t sign(const uint8_t *msg, size_t msgsize, const pubkey_t &pub, const privkey_t &priv)
Definition: ed25519_impl.cpp:19
Definition: block.hpp:16
void sign(interface::Block &m) const override
Definition: crypto_model_signer.hpp:34
Definition: byte_range.hpp:14
Definition: crypto_model_signer.hpp:19
Definition: command_executor.hpp:12
CryptoModelSigner(const shared_model::crypto::Keypair &keypair)
Definition: crypto_model_signer.hpp:43
Definition: abstract_crypto_model_signer.hpp:16