Skip to content

session: let the caller choose the OT extension - #45

Merged
wangxiao1254 merged 1 commit into
mainfrom
feat/select-ot
Nov 10, 2026
Merged

wangxiao1254 merged 1 commit into
mainfrom
feat/select-ot

Conversation

@wangxiao1254

Copy link
Copy Markdown
Member

Summary

SH2PCSessionT<OTExt> takes any emp-ot OT extension for the correlated OTs behind BOB's private input bits, the only inputs that use OT. SH2PCSession is SH2PCSessionT<IKNP>, so existing code compiles unchanged:

SH2PCSessionT<SoftSpoken<4>> sess(io.get(), party);   // or SH2PCSessionT<Ferret>

The session calls only set_sid(), set_delta() and rcot(), which every OTExtension provides, and every extension puts BOB's choice bit in the low bit of his block, which is where the session reads it. Both parties must choose the same extension.

Each session also sets a fresh session id (one block from ALICE) on its OT extension before it starts, so the hash inputs of the extension and its base OTs are separate from every other session's. The handshake gains that one block, so both parties need this version.

Closes #35.

Cost

Loopback on an Apple Silicon laptop, BOB input of n bits; Alice's bytes sent plus received, and wall time for the whole session:

n IKNP SoftSpoken<4> Ferret
128 275 KB, 11 ms 79 KB, 9 ms 393 KB, 33 ms
64K 1.3 MB, 10 ms 341 KB, 10 ms 431 KB, 41 ms
1M 17 MB, 19 ms 4.3 MB, 20 ms 600 KB, 58 ms
4M 67 MB, 49 ms 16.8 MB, 50 ms 1.1 MB, 114 ms

SoftSpoken<4> moves a quarter of IKNP's bytes in the same time. Ferret has a fixed setup of about 0.4 MB and takes 2-4x the time on loopback, so it wins only when BOB's inputs are large and bandwidth is the bottleneck. The 128-bit row is mostly the session's first 16K-OT refill. The default stays IKNP.

Tests

  • New test_ot: under IKNP, SoftSpoken<4> and Ferret, BOB inputs served from the refill buffer, straddling a refill, and larger than the batch must come back unchanged, and a 32-bit dot product must decode.
  • test_session_concepts_sh2pc checks that every extension gives the same session surface over the same gate context.
  • macOS, against emp-tool main (9e85ef0) and emp-ot main (5072bda): no warnings, 10/10 tests pass.

🤖 Generated with Claude Code

SH2PCSession always ran IKNP for the correlated OTs behind BOB's private
input bits. SH2PCSessionT<OTExt> takes any emp-ot OT extension (IKNP,
SoftSpoken<k>, Ferret): the session calls only set_sid(), set_delta()
and rcot(), which every OTExtension provides, and every extension puts
BOB's choice bit in the low bit of his block, which is where the session
reads it. SH2PCSession is SH2PCSessionT<IKNP>, so existing code compiles
unchanged; both parties must choose the same extension.

Each session also sets a fresh session id, sent by ALICE, on its OT
extension before it starts, so the hash inputs of the extension and its
base OTs are separate from every other session's. The handshake gains
that one block.

test_ot checks BOB inputs that take each refill path (from the buffer,
across a refill, larger than the batch) and a dot product under IKNP,
SoftSpoken<4> and Ferret; the concept test checks that every extension
gives the same session surface over the same gate context.

On loopback, a 1M-bit BOB input moves 17 MB under IKNP, 4.3 MB under
SoftSpoken<4> and 0.6 MB under Ferret, whose fixed setup is about
0.4 MB; Ferret takes 2-4x the time on loopback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wangxiao1254
wangxiao1254 merged commit 54efe23 into main Nov 10, 2026
14 checks passed
@wangxiao1254
wangxiao1254 deleted the feat/select-ot branch November 11, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changes for using Ferret with sh2pc

1 participant