Skip to content

Commit

Permalink
Merge pull request #7 from GemHQ/secp256k1-update
Browse files Browse the repository at this point in the history
reflect (interim?) updated secp256k1 API
  • Loading branch information
apoelstra committed Oct 22, 2015
2 parents c0b58c9 + b3e2a78 commit 2afb8b5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions contracthashtool.c
Expand Up @@ -170,7 +170,7 @@ int main(int argc, char* argv[]) {
if (mode == 0x2 && !priv_key_str)
USAGEEXIT("No private key specified\n");

secp256k1_context_t *secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
secp256k1_context *secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);

// GLOBALCONV
unsigned char p2sh_bytes[20];
Expand Down Expand Up @@ -242,15 +242,15 @@ int main(int argc, char* argv[]) {
for (i = 0; i < key_count; i++) {
unsigned char res[32];
hmac_sha256(res, keys_work[i], data, 4 + 16 + (ascii_contract ? strlen(ascii_contract) : 20));
secp256k1_pubkey_t pubkey;
secp256k1_pubkey pubkey;
if (!secp256k1_ec_pubkey_parse(secp256k1_ctx, &pubkey, keys_work[i], 33))
ERROREXIT("INVALID PUBLIC KEY IN SCRIPT");
if (secp256k1_ec_pubkey_tweak_add(secp256k1_ctx, &pubkey, res) == 0) {
if (nonce_hex)
ERROREXIT("YOU BROKE SHA256, PLEASE SEND THE EXACT DATA USED IN A BUG REPORT\n");
break; // if tweak > order
}
int len = 33;
size_t len = 33;
secp256k1_ec_pubkey_serialize(secp256k1_ctx, keys_work[i], &len, &pubkey, 1);
assert(len == 33);
}
Expand Down Expand Up @@ -279,7 +279,7 @@ int main(int argc, char* argv[]) {
printf("\nModified redeem script as P2SH address: %s\n", p2sh_res);
} else if (mode == 0x2) {
unsigned char priv[33], pub[33];
secp256k1_pubkey_t pubkey;
secp256k1_pubkey pubkey;
if (!privkey_str_to_bytes(priv_key_str, priv))
ERROREXIT("Private key is invalid (or not used as compressed)\n");

Expand All @@ -292,7 +292,7 @@ int main(int argc, char* argv[]) {
else
memcpy(data + 4 + sizeof(nonce), p2sh_bytes, sizeof(p2sh_bytes));

int len = 0;
size_t len = 0;
if (secp256k1_ec_pubkey_create(secp256k1_ctx, &pubkey, priv) != 1)
ERROREXIT("Private key was invalid\n");
secp256k1_ec_pubkey_serialize(secp256k1_ctx, pub, &len, &pubkey, 1);
Expand Down

0 comments on commit 2afb8b5

Please sign in to comment.