From b4795ed684e6cff5ada8bada1b40f3ab750d766d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Aug 2018 03:07:53 -1100 Subject: [PATCH] -prints --- src/cc/CCutils.cpp | 2 +- src/cc/eval.cpp | 2 +- src/cryptoconditions/src/cryptoconditions.c | 17 +---------------- src/cryptoconditions/src/ed25519.c | 2 +- src/cryptoconditions/src/eval.c | 2 +- src/cryptoconditions/src/prefix.c | 2 +- src/cryptoconditions/src/preimage.c | 2 +- src/cryptoconditions/src/secp256k1.c | 3 +-- src/cryptoconditions/src/threshold.c | 2 +- src/script/interpreter.cpp | 12 ++++++------ 10 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 785e9d952..8cb06ab25 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -260,7 +260,7 @@ bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector param //txid = ctx.GetHash(); //if ( txid == cp->prevtxid ) // return(true); - fprintf(stderr,"process CC %02x\n",cp->evalcode); + //fprintf(stderr,"process CC %02x\n",cp->evalcode); if ( paramsNull.size() != 0 ) // Don't expect params return eval->Invalid("Cannot have params"); else if ( ctx.vout.size() == 0 ) diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index 949728be4..b6fcf57dd 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -38,7 +38,7 @@ bool RunCCEval(const CC *cond, const CTransaction &tx, unsigned int nIn) pthread_mutex_lock(&KOMODO_CC_mutex); bool out = eval->Dispatch(cond, tx, nIn); pthread_mutex_unlock(&KOMODO_CC_mutex); - fprintf(stderr,"out %d vs %d isValid\n",(int32_t)out,(int32_t)eval->state.IsValid()); + //fprintf(stderr,"out %d vs %d isValid\n",(int32_t)out,(int32_t)eval->state.IsValid()); assert(eval->state.IsValid() == out); if (eval->state.IsValid()) return true; diff --git a/src/cryptoconditions/src/cryptoconditions.c b/src/cryptoconditions/src/cryptoconditions.c index fe277904e..c9a4b27df 100644 --- a/src/cryptoconditions/src/cryptoconditions.c +++ b/src/cryptoconditions/src/cryptoconditions.c @@ -116,20 +116,14 @@ uint32_t fromAsnSubtypes(const ConditionTypes_t types) { size_t cc_conditionBinary(const CC *cond, unsigned char *buf) { - fprintf(stderr,"inside cc_conditionBinary\n"); Condition_t *asn = calloc(1, sizeof(Condition_t)); - fprintf(stderr,"asn.%p\n",asn); asnCondition(cond, asn); - fprintf(stderr,"call derencode\n"); asn_enc_rval_t rc = der_encode_to_buffer(&asn_DEF_Condition, asn, buf, 1000); - fprintf(stderr,"back from derencode\n"); if (rc.encoded == -1) { fprintf(stderr, "CONDITION NOT ENCODED\n"); return 0; } - fprintf(stderr,"call ASN_STRUCT_FREE\n"); ASN_STRUCT_FREE(asn_DEF_Condition, asn); - fprintf(stderr,"return rc.encoded %d\n",(int32_t)rc.encoded); return rc.encoded; } @@ -152,15 +146,11 @@ void asnCondition(const CC *cond, Condition_t *asn) { // This may look a little weird - we dont have a reference here to the correct // union choice for the condition type, so we just assign everything to the threshold // type. This works out nicely since the union choices have the same binary interface. - fprintf(stderr,"asnCondition type.%p\n",cond->type); CompoundSha256Condition_t *choice = &asn->choice.thresholdSha256; choice->cost = cc_getCost(cond); - fprintf(stderr,"after cost\n"); choice->fingerprint.buf = cond->type->fingerprint(cond); choice->fingerprint.size = 32; - fprintf(stderr,"after fingerprint\n"); choice->subtypes = asnSubtypes(cond->type->getSubtypes(cond)); - fprintf(stderr,"after asnSubtypes\n"); } @@ -240,35 +230,30 @@ int cc_verify(const struct CC *cond, const unsigned char *msg, size_t msgLength, const unsigned char *condBin, size_t condBinLength, VerifyEval verifyEval, void *evalContext) { unsigned char targetBinary[1000]; - fprintf(stderr,"in cc_verify cond.%p msg.%p[%d] dohash.%d condbin.%p[%d]\n",cond,msg,(int32_t)msgLength,doHashMsg,condBin,(int32_t)condBinLength); + //fprintf(stderr,"in cc_verify cond.%p msg.%p[%d] dohash.%d condbin.%p[%d]\n",cond,msg,(int32_t)msgLength,doHashMsg,condBin,(int32_t)condBinLength); const size_t binLength = cc_conditionBinary(cond, targetBinary); if (0 != memcmp(condBin, targetBinary, binLength)) { fprintf(stderr,"cc_verify error A\n"); return 0; } - fprintf(stderr,"after memcmp\n"); if (!cc_ed25519VerifyTree(cond, msg, msgLength)) { fprintf(stderr,"cc_verify error B\n"); return 0; } - fprintf(stderr,"after cc_ed25519VerifyTree\n"); unsigned char msgHash[32]; if (doHashMsg) sha256(msg, msgLength, msgHash); else memcpy(msgHash, msg, 32); - fprintf(stderr,"after memcpy/sha256\n"); if (!cc_secp256k1VerifyTreeMsg32(cond, msgHash)) { fprintf(stderr,"cc_verify error C\n"); return 0; } - fprintf(stderr,"after cc_secp256k1VerifyTreeMsg32\n"); if (!cc_verifyEval(cond, verifyEval, evalContext)) { fprintf(stderr,"cc_verify error D\n"); return 0; } - fprintf(stderr,"return 1\n"); return 1; } diff --git a/src/cryptoconditions/src/ed25519.c b/src/cryptoconditions/src/ed25519.c index 8d4046241..4fb3bbb8d 100644 --- a/src/cryptoconditions/src/ed25519.c +++ b/src/cryptoconditions/src/ed25519.c @@ -27,7 +27,7 @@ struct CCType CC_Ed25519Type; static unsigned char *ed25519Fingerprint(const CC *cond) { Ed25519FingerprintContents_t *fp = calloc(1, sizeof(Ed25519FingerprintContents_t)); - fprintf(stderr,"ed25519 fingerprint %p %p\n",fp,cond->publicKey); + //fprintf(stderr,"ed25519 fingerprint %p %p\n",fp,cond->publicKey); OCTET_STRING_fromBuf(&fp->publicKey, cond->publicKey, 32); return hashFingerprintContents(&asn_DEF_Ed25519FingerprintContents, fp); } diff --git a/src/cryptoconditions/src/eval.c b/src/cryptoconditions/src/eval.c index a3e773699..544f6dd54 100644 --- a/src/cryptoconditions/src/eval.c +++ b/src/cryptoconditions/src/eval.c @@ -27,7 +27,7 @@ struct CCType CC_EvalType; static unsigned char *evalFingerprint(const CC *cond) { unsigned char *hash = calloc(1, 32); - fprintf(stderr,"evalfingerprint %p %p\n",hash,cond->code); + //fprintf(stderr,"evalfingerprint %p %p\n",hash,cond->code); sha256(cond->code, cond->codeLength, hash); return hash; } diff --git a/src/cryptoconditions/src/prefix.c b/src/cryptoconditions/src/prefix.c index ec961a939..626fc5992 100644 --- a/src/cryptoconditions/src/prefix.c +++ b/src/cryptoconditions/src/prefix.c @@ -39,7 +39,7 @@ static int prefixVisitChildren(CC *cond, CCVisitor visitor) { static unsigned char *prefixFingerprint(const CC *cond) { PrefixFingerprintContents_t *fp = calloc(1, sizeof(PrefixFingerprintContents_t)); - fprintf(stderr,"prefixfinger %p %p\n",fp,cond->prefix); + //fprintf(stderr,"prefixfinger %p %p\n",fp,cond->prefix); asnCondition(cond->subcondition, &fp->subcondition); // TODO: check asnCondition for safety fp->maxMessageLength = cond->maxMessageLength; OCTET_STRING_fromBuf(&fp->prefix, cond->prefix, cond->prefixLength); diff --git a/src/cryptoconditions/src/preimage.c b/src/cryptoconditions/src/preimage.c index 3b1a1cf2e..7c8e56996 100644 --- a/src/cryptoconditions/src/preimage.c +++ b/src/cryptoconditions/src/preimage.c @@ -46,7 +46,7 @@ static unsigned long preimageCost(const CC *cond) { static unsigned char *preimageFingerprint(const CC *cond) { unsigned char *hash = calloc(1, 32); - fprintf(stderr,"preimage %p %p\n",hash,cond->preimage); + //fprintf(stderr,"preimage %p %p\n",hash,cond->preimage); sha256(cond->preimage, cond->preimageLength, hash); return hash; } diff --git a/src/cryptoconditions/src/secp256k1.c b/src/cryptoconditions/src/secp256k1.c index 75d7f2690..c1eb82765 100644 --- a/src/cryptoconditions/src/secp256k1.c +++ b/src/cryptoconditions/src/secp256k1.c @@ -73,9 +73,8 @@ void initVerify() { static unsigned char *secp256k1Fingerprint(const CC *cond) { Secp256k1FingerprintContents_t *fp = calloc(1, sizeof(Secp256k1FingerprintContents_t)); - fprintf(stderr,"secpfinger %p %p size %d vs %d\n",fp,cond->publicKey,(int32_t)sizeof(Secp256k1FingerprintContents_t),(int32_t)SECP256K1_PK_SIZE); + //fprintf(stderr,"secpfinger %p %p size %d vs %d\n",fp,cond->publicKey,(int32_t)sizeof(Secp256k1FingerprintContents_t),(int32_t)SECP256K1_PK_SIZE); OCTET_STRING_fromBuf(&fp->publicKey, cond->publicKey, SECP256K1_PK_SIZE); - fprintf(stderr,"got octet\n"); return hashFingerprintContents(&asn_DEF_Secp256k1FingerprintContents, fp); } diff --git a/src/cryptoconditions/src/threshold.c b/src/cryptoconditions/src/threshold.c index 0ac2b0dad..13c3fdab3 100644 --- a/src/cryptoconditions/src/threshold.c +++ b/src/cryptoconditions/src/threshold.c @@ -86,7 +86,7 @@ static int cmpConditionBin(const void *a, const void *b) { static unsigned char *thresholdFingerprint(const CC *cond) { /* Create fingerprint */ ThresholdFingerprintContents_t *fp = calloc(1, sizeof(ThresholdFingerprintContents_t)); - fprintf(stderr,"thresholdfinger %p\n",fp); + //fprintf(stderr,"thresholdfinger %p\n",fp); fp->threshold = cond->threshold; for (int i=0; isize; i++) { Condition_t *asnCond = asnConditionNew(cond->subconditions[i]); diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index c9bf1b1ab..c2e02ad25 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -952,7 +952,7 @@ bool EvalScript( if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); -fprintf(stderr,"check cryptocondition\n"); +//fprintf(stderr,"check cryptocondition\n"); int fResult = checker.CheckCryptoCondition(stacktop(-1), stacktop(-2), script, consensusBranchId); if (fResult == -1) { return set_error(serror, SCRIPT_ERR_CRYPTOCONDITION_INVALID_FULFILLMENT); @@ -1313,7 +1313,7 @@ int TransactionSignatureChecker::CheckCryptoCondition( } catch (logic_error ex) { return 0; } - int32_t z; uint8_t *ptr; + /*int32_t z; uint8_t *ptr; ptr = (uint8_t *)scriptCode.data(); for (z=0; zCheckEvalCondition(cond); }; - fprintf(stderr,"non-checker path\n"); + //fprintf(stderr,"non-checker path\n"); int out = cc_verify(cond, (const unsigned char*)&sighash, 32, 0, condBin.data(), condBin.size(), eval, (void*)this); - fprintf(stderr,"out.%d from cc_verify\n",(int32_t)out); + //fprintf(stderr,"out.%d from cc_verify\n",(int32_t)out); cc_free(cond); return out; }