verify.h

The verifier API executes a proof verification. when calling c4_verify_from_bytes, c4_verify needs to be called until the status is either C4_ERROR or C4_SUCCESS.

Example:

 verify_ctx_t ctx = {0};
 for (
     c4_status_t status = c4_verify_from_bytes(&ctx, request_bytes, method, json_parse(args), chain_id);
     status == C4_PENDING;
     status = c4_verify(&ctx))
     curl_fetch_all(&ctx.state);
 if (ctx.success) {
   ssz_dump_to_file_no_quotes(stdout, ctx.data);
   return EXIT_SUCCESS;
 }
 else if (ctx.state.error) {
   fprintf(stderr, "proof is invalid: %s\n", ctx.state.error);
   return EXIT_FAILURE;
 }

verify_flags_t

verifier/verify.harrow-up-right

a bitmask holding flags used during the verification context.

verify_flag_t

verifier/verify.harrow-up-right

a enum as list of flags used during the verification context.

flags

verifier/verify.harrow-up-right

a struct holding the verification context.

method_type_t

verifier/verify.harrow-up-right

a enum as list of method types.

c4_get_request_type

verifier/verify.harrow-up-right

get the request type for a given chain-type. For each chain-type there is one request-type used, the request-type will be specified by the verifier-module.

c4_get_chain_type_from_req

verifier/verify.harrow-up-right

get the chain-type from a given request.

The chain-type is based on the first byte of the request, which corresponds to the chain_type_t enum value.

Parameters

  • request_bytes : the request bytes to analyze

Returns

the chain type, defaults to C4_CHAIN_TYPE_ETHEREUM for invalid requests

c4_get_req_type_from_req

verifier/verify.harrow-up-right

get the request type from a given request.

The request-type is based on the chain type extracted from the request.

Parameters

  • request_bytes : the request bytes to analyze

Returns

the SSZ definition for the request type

c4_verify

verifier/verify.harrow-up-right

the main verification function executing the verifier in the modules.

Parameters

  • ctx : the verification context

Returns

C4_SUCCESS, C4_ERROR, or C4_PENDING

c4_verify_from_bytes

verifier/verify.harrow-up-right

shortcut to verify a request from bytes.

Parameters

  • ctx : the verification context.

  • request_bytes : the request as bytes.

  • method : the method to verify (required, cannot be NULL).

  • args : the arguments for the method as json array.

  • chain_id : the chain-id of the request.

Returns

C4_SUCCESS, C4_ERROR, or C4_PENDING

c4_verify_free_data

verifier/verify.harrow-up-right

free all allocated memory from the verification context. it does not free the verification context itself.

c4_verify_init

verifier/verify.harrow-up-right

initialize the verification context.

Parameters

  • ctx : the verification context (required, cannot be NULL).

  • request_bytes : the request as bytes.

  • method : the method to verify (required, cannot be NULL).

  • args : the arguments for the method as json array.

  • chain_id : the chain-id of the request.

Returns

C4_SUCCESS or C4_ERROR

c4_get_method_type

verifier/verify.harrow-up-right

get the method type for a given chain-id and method.

Last updated