Hello, sorry for disturbing you.
When I using B2A and A2B gates to perform conversions between arithmetic and Boolean, I observed a strange behavior. After a value from PutGTGate in the Boolean circuit is converted to arithmetic and converted back to the Boolean, though its value keeps the same, its inversion is changed.
Here is an example.
int32_t test(e_role role, const std::string& address, uint16_t port, seclvl seclvl,
uint32_t numbers, uint32_t bitlen, uint32_t nthreads, e_mt_gen_alg mt_alg,
e_sharing sharing) {
ABYParty* party = new ABYParty(role, address, port, seclvl, bitlen, nthreads, mt_alg);
std::vector<Sharing*>& sharings = party->GetSharings();
BooleanCircuit* circ = (BooleanCircuit*) sharings[sharing]->GetCircuitBuildRoutine();
BooleanCircuit* Ycirc = (BooleanCircuit*) sharings[S_YAO]->GetCircuitBuildRoutine();
ArithmeticCircuit* Acirc = (ArithmeticCircuit*) sharings[S_ARITH]->GetCircuitBuildRoutine();
share *var1, *var2, *result, *result_inv, *out, *out_inv;
uint32_t var1_c = 61;
uint32_t var2_c = 18;
var1 = circ -> PutINGate(var1_c, 32, SERVER);
var2 = circ -> PutINGate(var2_c, 32, CLIENT);
result = circ -> PutGTGate(var1 , var2);
circ -> PutPrintValueGate(result, "result");
result = Acirc -> PutB2AGate(result);
result = circ -> PutA2BGate(result, Ycirc);
result_inv = circ -> PutINVGate(result);
circ -> PutPrintValueGate(result_inv, "result_inv");
out = circ->PutOUTGate(result_inv, ALL);
out_inv = circ->PutOUTGate(result, ALL);
party->ExecCircuit();
delete var1;
delete var2;
delete result;
delete result_inv;
delete party;
return 0;
}
In the code, I compare two variables and get the result correctly. After I convert the result from Boolean to arithmetic and convert it back, though the result keeps the same, the result_inv is different.
The output is shown below.
result: 1
result_inv: 65534
If two lines that perform the conversion "result = Acirc -> PutB2AGate(result);result = circ -> PutA2BGate(result, Ycirc);" is deleted, the output is shown below.
I cannot find the reason behind this behavior. Could you help me to explain this?
Hello, sorry for disturbing you.
When I using B2A and A2B gates to perform conversions between arithmetic and Boolean, I observed a strange behavior. After a value from PutGTGate in the Boolean circuit is converted to arithmetic and converted back to the Boolean, though its value keeps the same, its inversion is changed.
Here is an example.
In the code, I compare two variables and get the result correctly. After I convert the result from Boolean to arithmetic and convert it back, though the result keeps the same, the result_inv is different.
The output is shown below.
If two lines that perform the conversion "result = Acirc -> PutB2AGate(result);result = circ -> PutA2BGate(result, Ycirc);" is deleted, the output is shown below.
I cannot find the reason behind this behavior. Could you help me to explain this?