update hosts for cored target

WIP: currently the hosts are not generic and don't support different
targets
This commit is contained in:
2026-04-07 20:22:12 +02:00
parent 39d2e1c51f
commit 28a3c37d41
8 changed files with 350 additions and 80 deletions

View File

@ -1,4 +1,5 @@
#include "../lib.h"
#include "../lib_cored.h"
void fail_start_trace(void) {}
void fail_stop_trace(void) {}
@ -6,18 +7,47 @@ void fail_marker_positive(void) {}
void fail_marker_negative(void) {}
void fail_marker_detected(void) {}
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);
MAIN() {
int result;
void os_main(void) {
init_outputs(100, 142, 100);
fail_start_trace();
result = wasm_module();
sign_t static_sig = wasm_module();
fail_stop_trace();
if (result == 100) {
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:
break;
}
// Inversely apply constant program flow signature.
enc_t cored_res = get_cored_res();
cored_res -= static_sig;
/* Validate Vote result */
if (!check(cored_res, THE_A, vote_result_sig)) {
fail_marker_detected();
return;
}
plain_t res = decode(cored_res, THE_A, vote_result_sig);
if (res == 100) {
fail_marker_positive();
return;
} else {
fail_marker_negative();
return;
}
}

View File

@ -1,15 +1,56 @@
#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[]) {
int result = wasm_module();
init_outputs(100, 142, 100);
sign_t static_sig = wasm_module();
if (result == 100) {
printf("OK Marker\n");
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("FAIL Marker\n");
printf("Marker Negative\n");
// fail_marker_negative();
return 1;
}
}