WIP: currently the hosts are not generic and don't support different targets
57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
#include "../lib_cored.h"
|
|
#include <stdio.h>
|
|
|
|
void init_outputs(plain_t x_c, plain_t y_c, plain_t z_c);
|
|
int wasm_module(void);
|
|
enc_t get_cored_res(void);
|
|
|
|
void fail_marker_detected(void) {}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
init_outputs(100, 142, 100);
|
|
sign_t static_sig = wasm_module();
|
|
|
|
sign_t vote_result_sig;
|
|
switch (static_sig) {
|
|
case SIG_s_XYZ:
|
|
case SIG_s_XY:
|
|
case SIG_s_XZ:
|
|
vote_result_sig = SIG_X;
|
|
break;
|
|
case SIG_s_YZ:
|
|
vote_result_sig = SIG_Y;
|
|
break;
|
|
default:
|
|
// printf("ERROR: Unknown static_sig %d\n", static_sig);
|
|
break;
|
|
}
|
|
|
|
// Inversely apply constant program flow signature.
|
|
enc_t cored_res = get_cored_res();
|
|
printf("Inversely apply: cored_res=%d static_sig=%d\n", cored_res,
|
|
static_sig);
|
|
cored_res -= static_sig;
|
|
|
|
/* Validate Vote result */
|
|
printf(
|
|
"Validating vote result: cored_res=%d THE_A=%d vote_result_sig = % d\n ",
|
|
cored_res, THE_A, vote_result_sig);
|
|
if (!check(cored_res, THE_A, vote_result_sig)) {
|
|
printf("Validation failed :(\n");
|
|
// fail_marker_detected();
|
|
return 1;
|
|
}
|
|
|
|
plain_t res = decode(cored_res, THE_A, vote_result_sig);
|
|
// printf("Decoded result: %d (%f)\n", res, q_to_float(res));
|
|
if (res == 100) {
|
|
// fail_marker_positive();
|
|
printf("Marker Positive\n");
|
|
return 0;
|
|
} else {
|
|
printf("Marker Negative\n");
|
|
// fail_marker_negative();
|
|
return 1;
|
|
}
|
|
}
|