change Eval data structure to single code blob

This commit is contained in:
Scott Sadler
2018-04-07 18:07:52 -03:00
parent 4729632250
commit 39c9911e9c
37 changed files with 239 additions and 768 deletions

View File

@@ -40,18 +40,18 @@ typedef struct CC {
struct CCType *type;
union {
// public key types
struct { unsigned char *publicKey, *signature; };
struct { uint8_t *publicKey, *signature; };
// preimage
struct { unsigned char *preimage; uint16_t preimageLength; };
struct { uint8_t *preimage; size_t preimageLength; };
// threshold
struct { long threshold; uint8_t size; struct CC **subconditions; };
// prefix
struct { unsigned char *prefix; uint16_t prefixLength; struct CC *subcondition;
uint16_t maxMessageLength; };
struct { uint8_t *prefix; size_t prefixLength; struct CC *subcondition;
size_t maxMessageLength; };
// eval
struct { char method[64]; unsigned char *paramsBin; uint16_t paramsBinLength; };
struct { uint8_t *code; size_t codeLength; };
// anon
struct { unsigned char fingerprint[32]; uint32_t subtypes; unsigned long cost;
struct { uint8_t fingerprint[32]; uint32_t subtypes; unsigned long cost;
struct CCType *conditionType; };
};
} CC;
@@ -63,7 +63,7 @@ typedef struct CC {
*/
typedef struct CCVisitor {
int (*visit)(CC *cond, struct CCVisitor visitor);
const unsigned char *msg;
const uint8_t *msg;
size_t msgLength;
void *context;
} CCVisitor;
@@ -73,20 +73,20 @@ typedef struct CCVisitor {
* Public methods
*/
int cc_isFulfilled(const CC *cond);
int cc_verify(const struct CC *cond, const unsigned char *msg, size_t msgLength,
int doHashMessage, const unsigned char *condBin, size_t condBinLength,
int cc_verify(const struct CC *cond, const uint8_t *msg, size_t msgLength,
int doHashMessage, const uint8_t *condBin, size_t condBinLength,
VerifyEval verifyEval, void *evalContext);
int cc_visit(CC *cond, struct CCVisitor visitor);
int cc_signTreeEd25519(CC *cond, const unsigned char *privateKey,
const unsigned char *msg, uint16_t msgLength);
int cc_signTreeSecp256k1Msg32(CC *cond, const unsigned char *privateKey, const unsigned char *msg32);
size_t cc_conditionBinary(const CC *cond, unsigned char *buf);
size_t cc_fulfillmentBinary(const CC *cond, unsigned char *buf, size_t bufLength);
static int cc_secp256k1VerifyTreeMsg32(const CC *cond, const unsigned char *msg32);
int cc_signTreeEd25519(CC *cond, const uint8_t *privateKey, const uint8_t *msg,
const size_t msgLength);
int cc_signTreeSecp256k1Msg32(CC *cond, const uint8_t *privateKey, const uint8_t *msg32);
int cc_secp256k1VerifyTreeMsg32(const CC *cond, const uint8_t *msg32);
size_t cc_conditionBinary(const CC *cond, uint8_t *buf);
size_t cc_fulfillmentBinary(const CC *cond, uint8_t *buf, size_t bufLength);
struct CC* cc_conditionFromJSON(cJSON *params, char *err);
struct CC* cc_conditionFromJSONString(const char *json, char *err);
struct CC* cc_readConditionBinary(const unsigned char *cond_bin, size_t cond_bin_len);
struct CC* cc_readFulfillmentBinary(const unsigned char *ffill_bin, size_t ffill_bin_len);
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);
struct CC* cc_new(int typeId);
struct cJSON* cc_conditionToJSON(const CC *cond);
char* cc_conditionToJSONString(const CC *cond);