LCOV - code coverage report
Current view: top level - shared_model/cryptography/crypto_provider - crypto_model_signer.hpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 7 7 100.0 %
Date: 2019-03-07 14:46:43 Functions: 9 10 90.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #ifndef IROHA_CRYPTO_MODEL_SIGNER_HPP_
       7             : #define IROHA_CRYPTO_MODEL_SIGNER_HPP_
       8             : 
       9             : #include "cryptography/crypto_provider/abstract_crypto_model_signer.hpp"
      10             : #include "cryptography/crypto_provider/crypto_signer.hpp"
      11             : 
      12             : #include "interfaces/iroha_internal/block.hpp"
      13             : 
      14             : namespace shared_model {
      15             : 
      16             :   namespace crypto {
      17             :     template <typename Algorithm = CryptoSigner<>>
      18             :     class CryptoModelSigner
      19             :         : public AbstractCryptoModelSigner<interface::Block> {
      20             :      public:
      21         258 :       explicit CryptoModelSigner(const shared_model::crypto::Keypair &keypair);
      22             : 
      23             :       virtual ~CryptoModelSigner() = default;
      24             : 
      25             :       template <typename T>
      26             :       inline void sign(T &signable) const noexcept {
      27         723 :         auto signedBlob = Algorithm::sign(signable.payload(), keypair_);
      28         723 :         signable.addSignature(signedBlob, keypair_.publicKey());
      29         723 :       }
      30             : 
      31             :       void sign(interface::Block &m) const override {
      32         721 :         sign<interface::Block>(m);
      33         721 :       }
      34             : 
      35             :      private:
      36             :       shared_model::crypto::Keypair keypair_;
      37             :     };
      38             : 
      39             :     template <typename Algorithm>
      40             :     CryptoModelSigner<Algorithm>::CryptoModelSigner(
      41             :         const shared_model::crypto::Keypair &keypair)
      42         258 :         : keypair_(keypair) {}
      43             : 
      44             :   }  // namespace crypto
      45             : }  // namespace shared_model
      46             : 
      47             : #endif  //  IROHA_CRYPTO_MODEL_SIGNER_HPP_

Generated by: LCOV version 1.13