From a57cea0bee671a68b2eda52d76d3a71f505d4869 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Aug 2018 02:54:51 -1100 Subject: [PATCH] Fingerprint prints --- src/cryptoconditions/src/anon.c | 1 + src/cryptoconditions/src/cryptoconditions.c | 3 +-- src/cryptoconditions/src/ed25519.c | 1 + src/cryptoconditions/src/eval.c | 1 + src/cryptoconditions/src/prefix.c | 1 + src/cryptoconditions/src/preimage.c | 1 + src/cryptoconditions/src/secp256k1.c | 1 + src/cryptoconditions/src/threshold.c | 1 + 8 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cryptoconditions/src/anon.c b/src/cryptoconditions/src/anon.c index 43e96ae44..8c2b9cea6 100644 --- a/src/cryptoconditions/src/anon.c +++ b/src/cryptoconditions/src/anon.c @@ -55,6 +55,7 @@ static void anonToJSON(const CC *cond, cJSON *params) { static unsigned char *anonFingerprint(const CC *cond) { unsigned char *out = calloc(1, 32); + fprintf(stderr,"anon fingerprint %p %p\n",out,cond->fingerprint); memcpy(out, cond->fingerprint, 32); return out; } diff --git a/src/cryptoconditions/src/cryptoconditions.c b/src/cryptoconditions/src/cryptoconditions.c index c132b4870..fe277904e 100644 --- a/src/cryptoconditions/src/cryptoconditions.c +++ b/src/cryptoconditions/src/cryptoconditions.c @@ -71,8 +71,7 @@ char *cc_conditionUri(const CC *cond) { unsigned char *encoded = base64_encode(fp, 32); unsigned char *out = calloc(1, 1000); - sprintf(out, "ni:///sha-256;%s?fpt=%s&cost=%lu", - encoded, cc_typeName(cond), cc_getCost(cond)); + sprintf(out, "ni:///sha-256;%s?fpt=%s&cost=%lu",encoded, cc_typeName(cond), cc_getCost(cond)); if (cond->type->getSubtypes) { appendUriSubtypes(cond->type->getSubtypes(cond), out); diff --git a/src/cryptoconditions/src/ed25519.c b/src/cryptoconditions/src/ed25519.c index d7ebb085e..8d4046241 100644 --- a/src/cryptoconditions/src/ed25519.c +++ b/src/cryptoconditions/src/ed25519.c @@ -27,6 +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); 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 df0f1af5d..a3e773699 100644 --- a/src/cryptoconditions/src/eval.c +++ b/src/cryptoconditions/src/eval.c @@ -27,6 +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); sha256(cond->code, cond->codeLength, hash); return hash; } diff --git a/src/cryptoconditions/src/prefix.c b/src/cryptoconditions/src/prefix.c index bebebba6e..ec961a939 100644 --- a/src/cryptoconditions/src/prefix.c +++ b/src/cryptoconditions/src/prefix.c @@ -39,6 +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); 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 8902817dd..3b1a1cf2e 100644 --- a/src/cryptoconditions/src/preimage.c +++ b/src/cryptoconditions/src/preimage.c @@ -46,6 +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); sha256(cond->preimage, cond->preimageLength, hash); return hash; } diff --git a/src/cryptoconditions/src/secp256k1.c b/src/cryptoconditions/src/secp256k1.c index 78b9c4e9e..cbf4dfd32 100644 --- a/src/cryptoconditions/src/secp256k1.c +++ b/src/cryptoconditions/src/secp256k1.c @@ -73,6 +73,7 @@ void initVerify() { static unsigned char *secp256k1Fingerprint(const CC *cond) { Secp256k1FingerprintContents_t *fp = calloc(1, sizeof(Secp256k1FingerprintContents_t)); + fprintf(stderr,"secpfinger %p %p\n",fp,cond->publicKey); OCTET_STRING_fromBuf(&fp->publicKey, cond->publicKey, SECP256K1_PK_SIZE); return hashFingerprintContents(&asn_DEF_Secp256k1FingerprintContents, fp); } diff --git a/src/cryptoconditions/src/threshold.c b/src/cryptoconditions/src/threshold.c index 88d4e7f50..0ac2b0dad 100644 --- a/src/cryptoconditions/src/threshold.c +++ b/src/cryptoconditions/src/threshold.c @@ -86,6 +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); fp->threshold = cond->threshold; for (int i=0; isize; i++) { Condition_t *asnCond = asnConditionNew(cond->subconditions[i]);