encryptogroup / ABY

ABY - A Framework for Efficient Mixed-protocol Secure Two-party Computation
GNU Lesser General Public License v3.0
460 stars 132 forks source link

Stability problems about fundamental FP Operations #180

Closed fredbjer closed 1 year ago

fredbjer commented 2 years ago

We test the stability of PutFPGate operations like such as ADD, MUL and CMP, using 10 millions float data the results of operations sometimes go wrong. The error rate is about 0.5% with the same data. What's the problem about this?

The main code is is below:

        uint32_t bitlen = 32;
    std::string circuit_dir = "ABY/bin/circ/";
    ABYParty *party = new ABYParty(role, address, port, seclvl, 64, nthreads, mt_alg, 1000000, circuit_dir);

    std::vector<Sharing *> &sharings = party->GetSharings();
    BooleanCircuit *circ = (BooleanCircuit *)sharings[sharing]->GetCircuitBuildRoutine();

    // data is std::vector<float>
    uint32_t avals[nvals];
    for (uint32_t i = 0; i < nvals; i++)
    {
        avals[i] = *(uint32_t *)&data[i + begin];
    }

    share *ain, *bin;
    if (role == SERVER)
    {
        ain = circ->PutSIMDINGate(nvals, avals, bitlen, SERVER);
        bin = circ->PutDummySIMDINGate(nvals, bitlen);
    }
    else
    { //role == CLIENT
        ain = circ->PutDummySIMDINGate(nvals, bitlen);
        bin = circ->PutSIMDINGate(nvals, avals, bitlen, CLIENT);
    }

    // FP addition gate
    share *add = circ->PutFPGate(ain, bin, ADD, bitlen, nvals, no_status);

    // output gate
    share *add_out = circ->PutOUTGate(add, ALL);