Skip to content

Migrate secure join correlations to SPIN and reduce join overhead - #5

Merged
ladnir merged 24 commits into
masterfrom
codex/spin-correlation
Nov 26, 2026
Merged

ladnir merged 24 commits into
masterfrom
codex/spin-correlation

Conversation

@ladnir

@ladnir ladnir commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Current stack and Peach results

The CMake pins select the commits in libOTe #208 and SPIN #1. This update also optimizes packed binary OLE and GF(4) OT, mod-3 sampling and GF(4) choice-bit clearing.

Serial regular joins on Peach used 16,384 rows per party, four workers and real OTs. Relative to the starting binaries for this optimization pass, the native median fell from 872 to 779 ms and AVX2+VAES fell from 1,001.5 to 802 ms. Both builds won all 40 pairs. With the final code, enabling VAES saved a paired 109 ms on native and 210.5 ms on AVX2. Regular used 25,081 bytes per row and stationary used 8,017.59. All 79 enabled SecureJoin tests passed on each of five Peach builds.

Protocol and implementation

Pin libOTe to 047d68e5. This revision includes libOTe PR #207 and the caller-owned full SPIN maps and worker-specific banks from af187653. Silent OT, binary OLE, trit OT and packed GF(4) OT use SPIN. Regular is the default. It samples fresh PPRF noise per batch and shares the immutable full SPIN map for each padded size across the process. Workers own their scratch and transfer the allocated buffers by move.

Stationary mode assigns a distinct bank to each logical worker and padded size. The peers check the mode, roles, batch size and stationary worker count, then derive matching initial code seeds per worker, direction, correlation family and request size. Each round consumes fresh base VOLEs, retains the PPRF stream and advances the active SPIN code. Public banks can be reused across joins. The stationary setup uses SPIN's banked heuristic. Packed GF(4) uses the conservative factor-one partition count in both modes, with uniform nonzero coefficients for regular and uniform GF(4) coefficients for stationary.

Remove a debug validator that sent permutation-correlation masks to the peer during ordinary joins. Sample a fresh public seed after the inputs are fixed when compressing wide join or group-by keys. Size the join aggregation circuit for the payload and flag. Use four-bit radix digits, honor the logical width of the last digit and handle suffix-tree padding correctly.

Pack 16 correlations at a time and allocate one block per 128 output bits. Stream GF(4) PRF corrections one batch at a time so batched preprocessing and online messages can share a transport. Check individual GMW triples in debug mode. The test executable now returns failure on failing tests.

Earlier measurements against merged master (709f57a)

Median of five serial runs, alternating revisions, on an i7-13700H under WSL2 with GCC 15.2 Release. Both builds used the same plaintext-checked join harness, duplicate right keys, 32-bit keys, one correlation worker per party, 65,536 correlations per batch, local sockets and mock base OT. The silent extensions and the online protocol ran on both sides. Wire totals count both directions across the online and preprocessing sockets. Peak RSS includes both parties.

Rows per side Wall time, master → PR Wire bytes per input row, master → PR Peak RSS, master → PR
1,024 920 → 562 ms 28,630 → 17,455 324 → 181 MiB
4,096 3,614 → 2,437 ms 28,522 → 16,960 606 → 320 MiB

The isolated 65,536-output microbenchmarks got slower on this CPU. Silent OT took 3.25 → 5.85 ms/batch and GF(4) VOLE took 3.45 → 4.75 ms/batch. Each invocation ran 20 expansions with supplied base correlations. The OT microbenchmark reconfigures both parties on each iteration. The end-to-end gains include fewer radix passes, a narrower aggregation circuit, reduced allocation and fewer bytes exchanged.

Reproduce the join on the PR with secJoinfrontend -bench -join -nn 10 -b 16 -nt 1 -mock 0 or -nn 12. The harness reconstructs the output and checks every resulting row against the plaintext join outside the timed interval.

Earlier verification (709f57a)

Linux Release passed 78 tests with four skips in the standard suite and with -u -mock 0. The standalone multi-batch permutation test also passed with -debug -mock 0. A scalar fallback check exercised both packed bit planes in every lane.

A separate Linux Release build enabled libsodium and real base OT, with mock OT disabled at compile time. Its suite with -mock 0 passed 78 tests, and its 1,024-row-per-side join matched plaintext. The four skips are the repository’s existing group-by tests. I checked narrow and compressed group keys separately by reconstructing the encoding from both parties’ shares. Ubuntu and Windows CI passed on 709f57a. CI run

Earlier Peach measurements (6246c71)

Release with GCC 15.2 on an AMD Ryzen 9 7950X, pinned to CPUs 0-3. The join used real libsodium/MRR base OT, 4,096 rows per party, 32-bit keys, four-bit radix passes and batches of 65,536. Each measurement is the median of five serial runs after a warm-up, with alternating mode order. Each run verified the reconstructed result against plaintext.

Workers per party Regular Stationary Regular bytes/input row Stationary bytes/input row
1 866 ms 1,053 ms 16,965 52,523
2 478 ms 660 ms 16,965 52,606

On one worker, generating 32 batches of 65,536 random OTs, including real base correlations, took 31 ms regular and 33 ms stationary. With supplied base correlations, the isolated first OT batch took 4.7 ms regular and 9.4 ms stationary. Subsequent batches averaged 0.805 ms regular and 0.800 ms stationary. Join communication includes both directions. At that revision, stationary GF(4) obtained base VOLEs directly for each round.

Run secJoinfrontend -bench -join -nn 12 -nt 2 -b 16 -mock 0 and add -stationary to select stationary mode. All 79 enabled tests passed on Peach with real base OT. Four existing tests were skipped. New checks cover round advancement, equal peer descriptors, distinct worker bank seeds, reuse across joins, GF(4) round interfaces, and mismatched worker counts.

Stationary GF(4) preprocessing (7792e97)

The join now collects fresh per-round GF(4) base VOLE requests before dispatch and fulfills them with one silent chosen-VOLE expansion per active direction. Each stationary worker retains its punctures and bank. Cold PPRF base OTs are batched once per worker, stream geometry and direction. The receiver samples fresh uniform GF(4) coefficients on each round. Stationary peers check the revised transcript version during setup.

On the same Peach workload, the online protocol used 6,721.74 bytes per input row in all four cases. Totals include traffic in both directions and divide by the 8,192 input rows across both parties. Times are medians of five serial fresh-process runs after a warm-up, rotating the two revisions and modes. Every result matched the plaintext join.

Workers per party Mode Preprocessing bytes/input row Total bytes/input row Join time
1 Regular 10,243 16,965 861 ms
1 Stationary 895 7,617 773 ms
2 Regular 10,243 16,965 478 ms
2 Stationary 971 7,692 497 ms

At 16,384 rows per party and two workers, stationary used 7,453 bytes/input row and took 1,685 ms. Regular used 16,966 bytes/input row and took 1,791 ms. Both used 6,757 online bytes/input row. The same five-run procedure and plaintext check applied.

The direct base-VOLE path at 6246c71 accounted for the earlier stationary totals of 52,523 and 52,606 bytes/row. A regression test checks correlation correctness and bounds the complete wire traffic for eight full stationary GF(4) batches plus a tail on two workers. The real-base-OT suite passed all 79 enabled tests on Peach and WSL, with four existing skips.

Stationary binary base correlations (0136157)

Stationary OT, binary OLE, and trit OT now use the common SoftSpoken setup in each active direction. Its hashed OTs seed the worker-local PPRF locations once per worker, type, direction and request size. The same extension then produces raw correlated OTs for the binary noise. Each batch consumes a disjoint slice with fresh receiver choice bits. The binary sender delta is common within a direction, and GF(4) has its own delta. Private PPRF tables and their counters stay with their workers. The stationary handshake version is 3.

The following Peach measurements compare 7792e97 to 0136157. The benchmark ran both parties in one process with real base OT, 32-bit keys and 65,536 correlations per batch. Each entry is the median of five serial fresh-process runs after warm-up, rotating revisions. All joins matched plaintext. Wire totals count both directions per input row. Peak RSS includes both parties.

Rows/party Workers/party Physical cores available Join ms, before → after Wire bytes/input row, before → after Peak MiB, before → after
4,096 1 4 771 → 711 7,617 → 7,578 229 → 247
4,096 2 4 499 → 418 7,692 → 7,647 268 → 275
4,096 4 4 619 → 532 7,844 → 7,784 353 → 358
16,384 2 4 1,698 → 1,545 7,453 → 7,421 521 → 545
4,096 2 8 501 → 420 7,692 → 7,647 271 → 276
4,096 4 8 430 → 364 7,844 → 7,784 350 → 361
16,384 4 8 1,453 → 1,347 7,491 → 7,455 630 → 657

At 4,096 rows and two workers on four cores, preprocessing fell from 971 to 925 bytes/input row. Both revisions used 6,722 online bytes/input row. The regular-mode control measured 480 ms and 16,965 bytes/input row on both revisions. An isolated 32-batch workload of 65,536 random OTs per batch took 33 → 32 ms with one worker and 31 → 33 ms with two.

A separate instrumented run counted live expanded worker PPRF leaf blocks at the end of preprocessing. At 4,096 rows per party, the leaf tables occupied 12.3, 22.3, and 42.3 MiB per party with one, two, and four workers respectively. Keeping one table per type, direction and exact request size would save 10.0 MiB per party at two workers and 30.0 MiB at four. These estimates cover leaf storage alone. The timing runs used the uninstrumented executable.

GF(4) sender output packing (0b630a4)

On targets with VAES, AVX2 and AVX-512F/VL, the GF(4) sender now hashes 16 inputs for each of the four choices and packs their low bits in registers. This kernel can run with cryptoTools' global VAES option off. The existing batch hash handles other targets. A regression check compares every packed bit with the scalar hash on an input aligned to 16 bytes.

On Peach, with real base OT, stationary noise and four-bit radix digits, the isolated sender took 159.5 → 90.8 µs per 32,768 correlations and produced the same output digest. The join medians below compare 0136157 to 0b630a4 in five serial fresh-process runs after warmup, alternating the binaries. Each party had one physical core per worker. Each join checked the revealed result against plaintext.

Rows/party Workers/party Correlations/batch Join ms, before → after Wire bytes/input row, both revisions
4,096 2 32,768 405 → 374 8,187
16,384 4 32,768 972 → 902 8,018
16,384 4 65,536 1,344 → 1,307 7,455

Both the native Peach build and the WSL fallback passed all 79 enabled tests, with four existing skips each.

Combined libOTe pin (c956101)

The new pin merges the upstream receiver fix into the existing SPIN storage branch. The application code is identical in the two builds compared below. Global VAES controls cryptoTools and libOTe. Secure Join's selective GF(4) sender kernel was active in all four Peach binaries.

Rows/party Workers/party Noise Previous pin, VAES off / on New pin, VAES off / on Total wire bytes/input row
4,096 2 Stationary 376 / 434 ms 376 / 429 ms 8,187
16,384 4 Stationary 897 / 1,031 ms 898 / 1,023 ms 8,018
16,384 4 Regular 1,111 / 1,274 ms 1,115 / 1,266 ms 25,081

Real base OT, 32,768 correlations per batch, one physical core per worker per party, five serial fresh-process runs after warmup with rotating build order. All results matched the plaintext join. The wire totals agreed across all four binaries for each workload. The global VAES default stays off for these workloads. Both VAES settings passed all 79 enabled tests on Peach, with four existing skips per build. The WSL build also passed with the new pin.

@ladnir
ladnir marked this pull request as ready for review November 24, 2026 22:50
@ladnir
ladnir merged commit 4c39e57 into master Nov 26, 2026
2 checks passed
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.

1 participant