-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
I am not much familiar with MOTION so facing lots of issues. I want to Xor two inputs but the results generated is 0, while it should be 102. may be i am not retrieving result in a correct manner. Can any body guide me whats wrong in the code.
CODE:
// abbreviate namespace
namespace mo = encrypto::motion;
using namespace std;
void EvaluateProtocol(encrypto::motion::PartyPointer& party) {
// Define 32-bit values representing shares of 1 and 0
std::uint32_t value1 = 0b10101010; // Example binary value (170 in decimal)
std::uint32_t value2 = 0b11001100; // Example binary value (204 in decimal)
std::cout << "Value1: " << value1 << " | Value2: " << value2 << std::endl;
// Create Boolean GMW shares
mo::ShareWrapper share1 = party->In<mo::MpcProtocol::kBooleanGmw>(mo::ToInput(value1), 0);
mo::ShareWrapper share2 = party->In<mo::MpcProtocol::kBooleanGmw>(mo::ToInput(value2), 0);
// Use Boolean GMW's built-in XOR operation
mo::ShareWrapper xor_result = share1 ^ share2;
// Retrieve the output
xor_result = xor_result.Out();
// Run the protocol
party->Run();
party->Finish();
// Extract the Boolean GMW result
std::vector<encrypto::motion::BitVector<>> reconstructed_value =
xor_result.As<std::vector<encrypto::motion::BitVector<>>>();
// Fix: Convert BitVector<> to Integer manually
std::uint32_t final_value = 0;
const auto& bit_vector_data = reconstructed_value[0].GetData(); // Get raw bits
cout << "bit_vector_data size" << reconstructed_value[0].GetData().size() << endl;
// Convert bit vector data into an integer
for (std::size_t i = 0; i < bit_vector_data.size(); ++i) {
final_value |= static_cast<std::uint32_t>(bit_vector_data[i]) << i;
}
std::cout << "XOR Result: " << final_value << std::endl;
}
Value1: 170 | Value2: 204
bit_vector_data size1
XOR Result: 0
Metadata
Metadata
Assignees
Labels
No labels