Skip to content

Commit

Permalink
Security fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lulworm committed May 26, 2017
1 parent 7214e05 commit 3cd457b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/CryptoNoteConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ __attribute__((unused))
// You may add here other checkpoints using the following format:
// {<block height>, "<block hash>"},
const std::initializer_list<CheckpointData> CHECKPOINTS = {

{ 100000, "0454f789f0867bf65cfc8f27ab227a68c2d4cd579a2de6d2352a3abec4a236e5" },
{ 103200, "05ebc16209bcdb97005c5cd284f2d4d669a0bf981fb4161a020247d2ce28bf64" },
{ 105301, "63ad1e3e08eeb3c3f05d073a4413463393014297dcc42ad39a3ee012ffd986f3" },

};

} // CryptoNote
Expand Down
6 changes: 6 additions & 0 deletions src/CryptoNoteCore/Blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,12 @@ bool Blockchain::check_tx_input(const KeyInput& txin, const Crypto::Hash& tx_pre
if (m_is_in_checkpoint_zone) {
return true;
}

static const Crypto::KeyImage I = { {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
static const Crypto::KeyImage L = { {0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 } };
if (m_blocks.size() > 385000 && !(scalarmultKey(txin.keyImage, L) == I)) {
return false;
}

return Crypto::check_ring_signature(tx_prefix_hash, txin.keyImage, output_keys, sig.data());
}
Expand Down
11 changes: 11 additions & 0 deletions src/crypto/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,17 @@ namespace Crypto {
ge_mul8(&point2, &point);
ge_p1p1_to_p3(&res, &point2);
}

KeyImage crypto_ops::scalarmultKey(const KeyImage & P, const KeyImage & a) {
ge_p3 A;
ge_p2 R;
// maybe use assert instead?
ge_frombytes_vartime(&A, reinterpret_cast<const unsigned char*>(&P));
ge_scalarmult(&R, reinterpret_cast<const unsigned char*>(&a), &A);
KeyImage aP;
ge_tobytes(reinterpret_cast<unsigned char*>(&aP), &R);
return aP;
}

void crypto_ops::hash_data_to_ec(const uint8_t* data, std::size_t len, PublicKey& key) {
Hash h;
Expand Down
6 changes: 6 additions & 0 deletions src/crypto/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ struct EllipticCurveScalar {
friend bool check_signature(const Hash &, const PublicKey &, const Signature &);
static void generate_key_image(const PublicKey &, const SecretKey &, KeyImage &);
friend void generate_key_image(const PublicKey &, const SecretKey &, KeyImage &);
static KeyImage scalarmultKey(const KeyImage & P, const KeyImage & a);
friend KeyImage scalarmultKey(const KeyImage & P, const KeyImage & a);
static void hash_data_to_ec(const uint8_t*, std::size_t, PublicKey&);
friend void hash_data_to_ec(const uint8_t*, std::size_t, PublicKey&);
static void generate_ring_signature(const Hash &, const KeyImage &,
Expand Down Expand Up @@ -207,6 +209,10 @@ struct EllipticCurveScalar {
crypto_ops::generate_key_image(pub, sec, image);
}

inline KeyImage scalarmultKey(const KeyImage & P, const KeyImage & a) {
return crypto_ops::scalarmultKey(P, a);
}

inline void hash_data_to_ec(const uint8_t* data, std::size_t len, PublicKey& key) {
crypto_ops::hash_data_to_ec(data, len, key);
}
Expand Down
4 changes: 2 additions & 2 deletions src/version.h.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define BUILD_COMMIT_ID "@VERSION@"
#define PROJECT_VERSION "0.1.0"
#define PROJECT_VERSION_BUILD_NO "cedi0001"
#define PROJECT_VERSION "0.1.1"
#define PROJECT_VERSION_BUILD_NO "cedi0010"
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO "(" BUILD_COMMIT_ID ")"

0 comments on commit 3cd457b

Please sign in to comment.