Skip to content

Commit c71f981

Browse files
wangxiao1254claude
andcommitted
docs/test: fix stale ctx_t names, label the quiet flag
README used the retired SH2PCSession::DirectCtx / direct_ctx() (code settled on ctx_t / ctx()) and the pre-migration two-machine invocation (positional 12345); both corrected. test_repeat labels NetIO::listen(port, /*quiet=*/true). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent dfe3ea1 commit c71f981

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Header-only semi-honest 2PC built on top of [emp-tool](https://github.com/emp-to
2121
## Usage
2222

2323
The public handle is one session, `SH2PCSession`: it owns the IO channel and all
24-
protocol state, and `sess.direct_ctx()` is the gate context your values are built over.
24+
protocol state, and `sess.ctx()` is the gate context your values are built over.
2525

2626
```cpp
2727
#include <emp-sh2pc/emp-sh2pc.h>
@@ -31,11 +31,11 @@ int party = parse_party(argv); // argv[1]; port/IP come from $EMP_PORT / $EMP_
3131
NetIO io(party == ALICE ? nullptr : peer_ip(), peer_port());
3232
SH2PCSession sess(&io, party);
3333

34-
using Ctx = SH2PCSession::DirectCtx; // the gate context values are built over
34+
using Ctx = SH2PCSession::ctx_t; // the gate context values are built over
3535
using UInt32 = UInt_T<Ctx, 32>;
3636
auto a = sess.input<UInt32>(ALICE, av); // each party owns its input
3737
auto b = sess.input<UInt32>(BOB, bv);
38-
auto c = a + b; // eager half-gate over sess.direct_ctx()
38+
auto c = a + b; // eager half-gate over sess.ctx()
3939
uint32_t out = sess.reveal(c, PUBLIC).value(); // open the result to both parties
4040
```
4141
@@ -45,9 +45,9 @@ both parties (each its own secret-share) for `reveal(v, XOR)` — and `std::null
4545
on a party that does not. The session names no value family — circuit values are
4646
emp-tool's context-bound types (`UInt_T<Ctx,N>`, `Int_T<Ctx,N>`, `Float_T<Ctx,W>`,
4747
`BitVec_T<Ctx,N>`, `Bit_T<Ctx>`), and `input`/`reveal` are generic over any `WireValue`.
48-
Public constants use `UInt32::constant(sess.direct_ctx(), 1)`. A reusable circuit is
48+
Public constants use `UInt32::constant(sess.ctx(), 1)`. A reusable circuit is
4949
compiled once with the emp-tool frontend and replayed over the session's context with
50-
`frontend::run(sess.direct_ctx(), circuit, args...)`. There is no global backend — the
50+
`frontend::run(sess.ctx(), circuit, args...)`. There is no global backend — the
5151
session is explicit.
5252
5353
## Requirements
@@ -109,15 +109,16 @@ wrapper script.
109109
e.g. `./run ./build/test_bit` or
110110
`./run ./build/test_example 123`.
111111

112-
* Two machines (IP addresses hardcoded in the test source):
112+
* Two machines: the shared port is `$EMP_PORT` (default 12345) and party 2
113+
dials `$EMP_PEER_IP`; only the party id is a positional arg:
113114

114-
`./build/[binary] 1 12345 [more opts]` on one machine and
115-
`./build/[binary] 2 12345 [more opts]` on the other.
115+
`./build/[binary] 1 [more opts]` on one machine and
116+
`EMP_PEER_IP=<party-1-ip> ./build/[binary] 2 [more opts]` on the other.
116117

117118
* `test_example` takes a per-party integer; the two parties must use
118119
different numbers:
119120

120-
`./build/test_example 1 12345 123 & ./build/test_example 2 12345 124`
121+
`./build/test_example 1 123 & EMP_PEER_IP=<party-1-ip> ./build/test_example 2 124`
121122

122123
`ctest --test-dir build --output-on-failure` runs the entire suite.
123124

test/test_repeat.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ static int test_int_reveal(int party, int port, int number) {
1313
// Brief pause so the previous iteration's listener has fully released the
1414
// port before this one re-binds it (same-port sequential reconnects).
1515
usleep(100);
16-
auto netio = (party == ALICE) ? NetIO::listen(port, true) : NetIO::connect(peer_ip(), port, true);
16+
auto netio = (party == ALICE) ? NetIO::listen(port, /*quiet=*/true)
17+
: NetIO::connect(peer_ip(), port, /*quiet=*/true);
1718
SH2PCSession sess(netio.get(), party, 1024);
1819

1920
SI a = sess.input<SI>(ALICE, (int64_t)number);

0 commit comments

Comments
 (0)