emp-toolkit / emp-ag2pc

Authenticated Garbling and Efficient Maliciously Secure Two-Party Computation
Other
23 stars 19 forks source link

Alice is party 2 in the circuit? #8

Open bl4ck5un opened 5 years ago

bl4ck5un commented 5 years ago

When using Bristol circuits, Alice's input actually corresponds to the 2nd party while Bob the first. This flip of order is really confusing. If it's intended, it better be clearly stated in the README.

E.g., Here https://github.com/emp-toolkit/emp-ag2pc/blob/163985c8a1637f64a1d1cfc5f75214d6d8ef06da/emp-ag2pc/2pc.h#L320-L324, Alice reads n2 bits from the input. The tests didn't catch this because they use the same input from both parties.

wangxiao1254 commented 5 years ago

This is definitely not intentional :) It is now on the schedule to be fixed.

ghost commented 5 years ago

I just edited that code section into this:

        if(party == ALICE) { 
            for(int i = 0; i < cf->n1; i++) {
                mask_input[i] = logic_xor(input[i], value[exec_times][i]);
                mask_input[i] = logic_xor(mask_input[i], mask[exec_times][i]);
            }
            io->recv_data(mask_input+cf->n1, cf->n2);
            io->send_data(mask_input, cf->n1);
            for(int i = 0; i < cf->n1 + cf->n2; i++) {
                tmp = labels[exec_times][i];
                if(mask_input[i]) tmp = xorBlocks(tmp, fpre->Delta);
                io->send_block(&tmp, 1);
            }
            //send output mask data
            send_partial_block<SSP>(io, mac[exec_times]+cf->num_wire - cf->n3, cf->n3);
        } else { 
            for(int i = cf->n1; i < cf->n1+cf->n2; i++) {
                mask_input[i] = logic_xor(input[i-cf->n1], value[exec_times][i]);
                mask_input[i] = logic_xor(mask_input[i], mask[exec_times][i]);
            }
            io->send_data(mask_input+cf->n1, cf->n2);
            io->recv_data(mask_input, cf->n1);
            io->recv_block(labels[exec_times], cf->n1 + cf->n2);
        }

That reflects my naive understanding of how the code should be at that position. However, the code crashes and/or I get a lot of "no match GT"s.

Any idea?

wangxiao1254 commented 5 years ago

Would it work for you to just swap the role of ALICE and BOB?

ghost commented 5 years ago

Yes! It's a brain twist, but I will get used to it. :smile:

wangxiao1254 commented 5 years ago

We will put a new version with greatly improved performance; this will definitely be fixed by then.

Xiao

On Thu, Sep 19, 2019 at 11:31 AM GitHubKilla notifications@github.com wrote:

Yes! It's a brain twist, but I will get used to it. 😄

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/emp-toolkit/emp-ag2pc/issues/8?email_source=notifications&email_token=AARKGCU2KXFXXMQ65RZWXHLQKOSPHA5CNFSM4HR7S6M2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7ECJCI#issuecomment-533210249, or mute the thread https://github.com/notifications/unsubscribe-auth/AARKGCS7JOXP3RFE3N4VXKTQKOSPHANCNFSM4HR7S6MQ .

xfap commented 4 years ago

Yes,brain twist. Did it fix?…confusing...

wangxiao1254 commented 4 years ago

you might need to keep it twisted for a few more months and we will release a completely new version :)