add secp256k1 condition type to cryptoconditions

This commit is contained in:
Scott Sadler
2018-02-24 19:43:37 -03:00
parent 46d1bcc607
commit 7d937f290e
7 changed files with 81 additions and 14 deletions

View File

@@ -3,8 +3,8 @@
#include "script/interpreter.h"
int TransactionSignatureChecker::CheckAuxCondition(const CC *cond) const {
int TransactionSignatureChecker::CheckAuxCondition(const CC *cond) const
{
// Check that condition is equal to fulfillment
if (0 == strcmp((const char*)cond->method, "equals")) {
return (cond->conditionAuxLength == cond->fulfillmentAuxLength) &&

View File

@@ -1164,7 +1164,7 @@ static int komodoCCAux(CC *cond, void *checker) {
bool TransactionSignatureChecker::CheckCryptoCondition(const CC *cond, const std::vector<unsigned char>& condBin, const CScript& scriptCode) const
{
uint256 message = SignatureHash(scriptCode, *txTo, nIn, SIGHASH_ALL);
return cc_verify(cond, (const unsigned char*)&message, 32,
return cc_verify(cond, (const unsigned char*)&message, 32, 0,
condBin.data(), condBin.size(), komodoCCAux, (void*)this);
}

View File

@@ -47,12 +47,20 @@ static const secp256k1_fe_t secp256k1_ecdsa_const_p_minus_order = SECP256K1_FE_C
);
static int secp256k1_ecdsa_sig_parse(secp256k1_ecdsa_sig_t *r, const unsigned char *sig, int size) {
/* libscott had to add this to get this version of the library to read compact sigs */
int overflow = 0;
if (size == 64) {
secp256k1_scalar_set_b32(&r->r, sig, &overflow);
secp256k1_scalar_set_b32(&r->s, sig+32, &overflow);
return 1;
}
unsigned char ra[32] = {0}, sa[32] = {0};
const unsigned char *rp;
const unsigned char *sp;
int lenr;
int lens;
int overflow;
if (sig[0] != 0x30) {
return 0;
}