Complete nothing at stake solution, waiting for confirm of masks
This commit is contained in:
@@ -9,7 +9,7 @@ include_HEADERS = include/cryptoconditions.h
|
||||
libcryptoconditions_la_SOURCES = include/cryptoconditions.h
|
||||
libcryptoconditions_la_LIBADD = $(CRYPTOCONDITIONS_CORE) $(LIBSECP256K1)
|
||||
|
||||
AM_CFLAGS = -I$(top_srcdir)/src/asn -I$(top_srcdir)/include -I$(top_srcdir)/src/include \
|
||||
AM_CFLAGS = -I$(top_srcdir)/src/asn -I./cryptoconditions/src/asn -I$(top_srcdir)/include -I$(top_srcdir)/src/include \
|
||||
-Wall -Wno-pointer-sign -Wno-discarded-qualifiers
|
||||
|
||||
LIBSECP256K1=src/include/secp256k1/libsecp256k1.la
|
||||
|
||||
@@ -56,8 +56,6 @@ typedef struct CC {
|
||||
};
|
||||
} CC;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Crypto Condition Visitor
|
||||
*/
|
||||
@@ -87,6 +85,7 @@ struct CC* cc_conditionFromJSON(cJSON *params, char *err);
|
||||
struct CC* cc_conditionFromJSONString(const char *json, char *err);
|
||||
struct CC* cc_readConditionBinary(const uint8_t *cond_bin, size_t cond_bin_len);
|
||||
struct CC* cc_readFulfillmentBinary(const uint8_t *ffill_bin, size_t ffill_bin_len);
|
||||
int cc_readFulfillmentBinaryExt(const unsigned char *ffill_bin, size_t ffill_bin_len, CC **ppcc);
|
||||
struct CC* cc_new(int typeId);
|
||||
struct cJSON* cc_conditionToJSON(const CC *cond);
|
||||
char* cc_conditionToJSONString(const CC *cond);
|
||||
|
||||
@@ -55,7 +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);
|
||||
//fprintf(stderr,"anon fingerprint %p %p\n",out,cond->fingerprint);
|
||||
memcpy(out, cond->fingerprint, 32);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef ASN1_CONSTRAINTS_VALIDATOR_H
|
||||
#define ASN1_CONSTRAINTS_VALIDATOR_H
|
||||
|
||||
#include <asn_system.h> /* Platform-dependent types */
|
||||
#include "asn_system.h" /* Platform-dependent types */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifndef _PER_SUPPORT_H_
|
||||
#define _PER_SUPPORT_H_
|
||||
|
||||
#include <asn_system.h> /* Platform-specific types */
|
||||
#include "asn_system.h" /* Platform-specific types */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -216,6 +216,35 @@ end:
|
||||
return cond;
|
||||
}
|
||||
|
||||
int cc_readFulfillmentBinaryExt(const unsigned char *ffill_bin, size_t ffill_bin_len, CC **ppcc) {
|
||||
|
||||
int error = 0;
|
||||
unsigned char *buf = calloc(1,ffill_bin_len);
|
||||
Fulfillment_t *ffill = 0;
|
||||
asn_dec_rval_t rval = ber_decode(0, &asn_DEF_Fulfillment, (void **)&ffill, ffill_bin, ffill_bin_len);
|
||||
if (rval.code != RC_OK) {
|
||||
error = rval.code;
|
||||
goto end;
|
||||
}
|
||||
// Do malleability check
|
||||
asn_enc_rval_t rc = der_encode_to_buffer(&asn_DEF_Fulfillment, ffill, buf, ffill_bin_len);
|
||||
if (rc.encoded == -1) {
|
||||
fprintf(stderr, "FULFILLMENT NOT ENCODED\n");
|
||||
error = -1;
|
||||
goto end;
|
||||
}
|
||||
if (rc.encoded != ffill_bin_len || 0 != memcmp(ffill_bin, buf, rc.encoded)) {
|
||||
error = (rc.encoded == ffill_bin_len) ? -3 : -2;
|
||||
goto end;
|
||||
}
|
||||
|
||||
*ppcc = fulfillmentToCC(ffill);
|
||||
end:
|
||||
free(buf);
|
||||
if (ffill) ASN_STRUCT_FREE(asn_DEF_Fulfillment, ffill);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
int cc_visit(CC *cond, CCVisitor visitor) {
|
||||
int out = visitor.visit(cond, visitor);
|
||||
@@ -225,7 +254,6 @@ int cc_visit(CC *cond, CCVisitor visitor) {
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
int cc_verify(const struct CC *cond, const unsigned char *msg, size_t msgLength, int doHashMsg,
|
||||
const unsigned char *condBin, size_t condBinLength,
|
||||
VerifyEval verifyEval, void *evalContext) {
|
||||
|
||||
Reference in New Issue
Block a user