-prints
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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; i<cond->size; i++) {
|
||||
Condition_t *asnCond = asnConditionNew(cond->subconditions[i]);
|
||||
|
||||
Reference in New Issue
Block a user