prepare_payload_and_sign(struct tang_keys_info* tki)
{
    if (!tki) {
        return 0;
    }

    size_t idx;
    json_t* jwk;
    json_array_foreach(tki->m_keys, idx, jwk) {
        if (jwk_valid_for_signing_and_verifying(jwk)) {
            if (json_array_append(tki->m_sign, jwk) == -1) {
                continue;
            }
            if (json_array_append(tki->m_payload, jwk) == -1) {
                continue;
            }
        } else if (jwk_valid_for_deriving_keys(jwk)) {
            if (json_array_append(tki->m_payload, jwk) == -1) {
                continue;
            }
        }
    }
    if (json_array_size(tki->m_sign) == 0 || json_array_size(tki->m_payload) == 0) {
        return 0;
    }
    return 1;
}
prepare_payload_and_sign(struct tang_keys_info* tki)
{
    if (!tki) {
        return 0;
    }

    size_t idx;
    json_t* jwk;
    json_array_foreach(tki->m_keys, idx, jwk) {
        if (jwk_valid_for_signing_and_verifying(jwk)) {
            if (json_array_append(tki->m_sign, jwk) == -1) {
                continue;
            }
            if (json_array_append(tki->m_payload, jwk) == -1) {
                continue;
            }
        } else if (jwk_valid_for_deriving_keys(jwk)) {
            if (json_array_append(tki->m_payload, jwk) == -1) {
                continue;
            }
        }
    }
    if (json_array_size(tki->m_sign) == 0 || json_array_size(tki->m_payload) == 0) {
        return 0;
    }
    return 1;
}