Skip to content

Commit

Permalink
Prevent from generating Segwit address with uncompreesed key
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanLucPons committed May 20, 2019
1 parent 9e4ea64 commit b4bbeac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions SECP256K1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ void Secp256K1::Check() {
printf("Check Calc PubKey (full) %s :",GetAddress(P2PKH, false,pub).c_str());
PrintResult(EC(pub));

// 1Gp7rQ4GdooysEAEJAS2o4Ktjvf1tZCihp
pub.x.SetBase16(/*02*/"2b70d6a249aeb187d6f079ecc0fb34d075056ca985384240166a2080c7d2beb5");
pub.y = GetY(pub.x,true);
printf("Check Calc PubKey (even) %s:",GetAddress(P2PKH, true, pub).c_str());
// 385cR5DM96n1HvBDMzLHPYcw89fZAXULJP
pub.x.SetBase16(/*03*/"c931af9f331b7a9eb2737667880dacb91428906fbffad0173819a873172d21c4");
pub.y = GetY(pub.x,false);
printf("Check Calc PubKey (even) %s:",GetAddress(P2SH, true, pub).c_str());
PrintResult(EC(pub));

// 18aPiLmTow7Xgu96msrDYvSSWweCvB9oBA
Expand Down Expand Up @@ -748,6 +748,9 @@ std::string Secp256K1::GetAddress(int type, bool compressed, Point &pubKey) {

case BECH32:
{
if (!compressed) {
return " BECH32: Only compressed key ";
}
char output[128];
uint8_t h160[20];
GetHash160(type, compressed, pubKey, h160);
Expand All @@ -757,6 +760,9 @@ std::string Secp256K1::GetAddress(int type, bool compressed, Point &pubKey) {
break;

case P2SH:
if (!compressed) {
return " P2SH: Only compressed key ";
}
address[0] = 0x05;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "hash/sha512.h"
#include "hash/sha256.h"

#define RELEASE "1.14"
#define RELEASE "1.15"

using namespace std;

Expand Down

0 comments on commit b4bbeac

Please sign in to comment.