From 48c5a030cd56713533e06c0bcef49d68a33149e7 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Sat, 4 Mar 2017 16:00:43 +0300 Subject: [PATCH] Add validation of signatures definitions --- core/validation/transaction_validator.cpp | 24 ++++++++++++++++------- core/validation/transaction_validator.hpp | 2 -- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/core/validation/transaction_validator.cpp b/core/validation/transaction_validator.cpp index f4461e2be1..5d4e4829c4 100644 --- a/core/validation/transaction_validator.cpp +++ b/core/validation/transaction_validator.cpp @@ -13,21 +13,31 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ + +#include #include +#include #include "transaction_validator.hpp" namespace transaction_validator { using Api::ConsensusEvent; + using Api::Transaction; template<> - bool isValid( - const std::unique_ptr& tx - ){ - // Write domain logic - return true; + bool signaturesAreValid(const std::unique_ptr& tx){ + return tx->eventsignatures().end() != std::find_if(tx->eventsignatures().begin(), tx->eventsignatures().end(), + [&tx](const auto &sig) { + return !signature::verify(sig.signature(), tx->transaction().hash(), sig.publickey()); + }); } + template<> + bool signaturesAreValid(const std::unique_ptr& tx){ + return tx->txsignatures().end() != std::find_if(tx->txsignatures().begin(), tx->txsignatures().end(), + [&tx](const auto &sig) { + return !signature::verify(sig.signature(), tx->hash(), sig.publickey()); + }); + } - -}; \ No newline at end of file +}; diff --git a/core/validation/transaction_validator.hpp b/core/validation/transaction_validator.hpp index b25ec38271..3ed395e745 100644 --- a/core/validation/transaction_validator.hpp +++ b/core/validation/transaction_validator.hpp @@ -25,8 +25,6 @@ limitations under the License. namespace transaction_validator { - using Api::ConsensusEvent; - template bool isValid(const std::unique_ptr& tx);