osu-crypto / libOTe

A fast, portable, and easy to use Oblivious Transfer Library
Other
428 stars 107 forks source link

iknp testing protblem #102

Closed JasonGaos closed 1 year ago

JasonGaos commented 1 year ago

Hello Professor,

I am trying to test the iknp OT function but the message can not be send correctly.

The code and the running result are looking like this. Could you help to see what is the problem here?

Thanks.

image image

ladnir commented 1 year ago

The library is coroutine based. recv.receive(...) and sender.send(...) by themselves do nothing. Instead, these functions return a task<> that can be awaited to actually run the protocol. To fix your code you can do

macoro::sync_wait(macoro::when_all_ready(
    recv.receive(choices, recvMsg, prng0, sockets[0]),
    sender.send(sendMsg, prng1, sockets[1])
);

When this means in that you want to run both coroutines and then synchronously wait for both to finish. For more about coroutines, you can see https://github.com/Visa-Research/coproto and https://www.youtube.com/watch?v=1Wy5sq3s2rg