secretflow/yacl

Problems in common.h

maths644311798 opened this issue · 2 comments

In yacl/crypto/tools/common.h,

uint128_t inline SyncSeedSend(const std::shared_ptr<link::Context>& ctx) {
  uint128_t seed = SecureRandSeed();
  ctx->SendAsync(ctx->NextRank(), SerializeUint128(seed), "SyncSeed");
  return seed;
}

uint128_t inline SyncSeedRecv(const std::shared_ptr<link::Context>& ctx) {
  auto buf = ctx->Recv(ctx->NextRank(), "SyncSeed");
  return DeserializeUint128(buf);
}

In which scenario do these two function work? One party or every party generates a seed?
The parameters used in SendAsync and Recv are both NextRank(). Why? I doubt if Recv should use PrevRank.

Hi, those two functions are used to generated a synchronized, and public random seed, which is used in our two-party protocols. Since most of the protocol implementations in yacl focuses on the two-party scenario, so there is not much difference between NextRank() and PrevRank().

And if you are planing to synchronize a seed over multiple parties, the sender should broadcast the seed, and the API should be designed different as it is now.

Anyway, you're right that our implementation only works in two-party scenarios, and there's still some work to be done to make it a proper seed-sync function. Feel free to open a PR for this. :)

Thanks. These functions are far away from multi-party scenario. Since I do not have a good idea about a multi-party version, I will not open a PR.