From 3992565dea412ae2a4c48af89b84a1dd02387f0b Mon Sep 17 00:00:00 2001 From: Scott Nadal Date: Mon, 25 Jun 2012 16:09:58 +0100 Subject: [PATCH] PPCoin: Checkpoint master key as class constant --- src/checkpoints.cpp | 18 ++++++++++++++++++ src/checkpoints.h | 17 +++-------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 26cc698..c8ffdf7 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -319,6 +319,24 @@ namespace Checkpoints } } +// ppcoin: sync-checkpoint master key +const std::string CSyncCheckpoint::strMasterPubKey = "0424f20205e5da98ba632bbd278a11a6499585f62bfb2c782377ef59f0251daab8085fc31471bcb8180bc75ed0fa41bb50c7c084511d54015a3a5241d645c7268a"; + +// ppcoin: verify signature of sync-checkpoint message +bool CSyncCheckpoint::CheckSignature() +{ + CKey key; + if (!key.SetPubKey(ParseHex(CSyncCheckpoint::strMasterPubKey))) + return error("CSyncCheckpoint::CheckSignature() : SetPubKey failed"); + if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig)) + return error("CSyncCheckpoint::CheckSignature() : verify signature failed"); + + // Now unserialize the data + CDataStream sMsg(vchMsg); + sMsg >> *(CUnsignedSyncCheckpoint*)this; + return true; +} + // ppcoin: process synchronized checkpoint bool CSyncCheckpoint::ProcessSyncCheckpoint(CNode* pfrom) { diff --git a/src/checkpoints.h b/src/checkpoints.h index 672e5fc..3fc62c7 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -56,6 +56,8 @@ public: class CSyncCheckpoint : public CUnsignedSyncCheckpoint { public: + static const std::string strMasterPubKey; + std::vector vchMsg; std::vector vchSig; @@ -99,20 +101,7 @@ public: return false; } - bool CheckSignature() - { - CKey key; - if (!key.SetPubKey(ParseHex("04ea21daea8c15559870b5e93750ddc2f0c16bd0cb16636ba88c0746cfac07912ec7ad14111cc4aedda12c2687c920c7b7b62fd67ca14eed53f2d1704ec72362ce"))) - return error("CSyncCheckpoint::CheckSignature() : SetPubKey failed"); - if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig)) - return error("CSyncCheckpoint::CheckSignature() : verify signature failed"); - - // Now unserialize the data - CDataStream sMsg(vchMsg); - sMsg >> *(CUnsignedSyncCheckpoint*)this; - return true; - } - + bool CheckSignature(); bool ProcessSyncCheckpoint(CNode* pfrom); }; -- 1.7.1