forked from facebookresearch/fbpcf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMillionaireGame.h
36 lines (30 loc) · 936 Bytes
/
MillionaireGame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <memory>
#include "fbpcf/mpc/EmpGame.h"
#include "folly/logging/xlog.h"
namespace fbpcf {
// define the classic millionaire game
template <class IOChannel>
class MillionaireGame : public EmpGame<IOChannel, int, bool> {
public:
MillionaireGame(std::unique_ptr<IOChannel> io, Party party)
: EmpGame<IOChannel, int, bool>(std::move(io), party) {}
bool play(const int& number) override {
emp::Integer a{64, number, emp::ALICE};
emp::Integer b{64, number, emp::BOB};
XLOGF(INFO, "I have money: {}", number);
auto result = (a > b).reveal<bool>();
if (result) {
XLOG(INFO) << "Alice is richer!";
} else {
XLOG(INFO) << "Bob is richer!";
}
return result;
}
};
} // namespace fbpcf