Skip to content

Silent OT: Turbo SPIN 0.4.2, VAES GGM expansion and hash, bit-vector choice transpose - #205

Merged
ladnir merged 8 commits into
masterfrom
codex/spin-ot-speed
Nov 24, 2026
Merged

ladnir merged 8 commits into
masterfrom
codex/spin-ot-speed

Conversation

@ladnir

@ladnir ladnir commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Moves Silent OT's SPIN profile to Turbo SPIN (SPIN 0.4.2), consolidates libOTe's SPIN glue into one header, and speeds up the sender's GGM expansion and hash.

Changes

  • Turbo SPIN. Silent OT uses spin::Parameters::PacketRs8T64. thirdparty/getSpin.cmake pins spin_codes 34a03e96 (SPIN 0.4.2), and find_package/find_dependency require 0.4.2. The code size is no longer tied to the certified lengths: K is the request rounded up to a multiple of 128, with a floor of 8192 so the noise configuration has room for its partitions.

  • Platforms. SPIN 0.4.2 runs on every little-endian CPU: AVX-512, AVX2+GFNI or AVX2 kernels on x86-64, NEON on AArch64 (including Apple silicon), and a portable C++ kernel elsewhere, all computing the same map. SPIN_PORTABLE=ON builds SPIN with no intrinsics at all. SPIN also builds with MSVC now. The SPIN tests no longer skip without AVX2.

  • One header, libOTe/Tools/Spin/SpinCode.h. SpinOt.h/SpinOt.cpp are removed. SpinCode provides:

    • messageSize(requested);
    • a constructor that builds the encoder (full setup for regular noise, banked refresh for stationary noise);
    • prepare(std::optional<SpinCode>&, ...), which reseeds in place when the size and noise match and rebuilds otherwise;
    • block and choice-byte transposes, and encoder().

    SpinConfigure lives in ConfigureCode.cpp next to the other codes, because SpinCode.h includes ConfigureCode.h. The sender and receiver hold std::optional<SpinCode> mSpin, which can be emplaced after configure() to take preparation off the critical path.

  • GGM expansion (RegularPprf.h). VAES kernels for master's per-tree expansion:

    • The internal levels and the leaf level (both leaf keys interleaved) now use 256-bit VAES, and 512-bit VAES when ENABLE_AVX512 is on.
    • The kernels use the same 8-lane layout as expandGgm8/hashGgmLeaves8. Each kernel keeps per-lane sums and XOR-folds them into the tree's level sum.
    • The scalar code stays in place for builds without VAES.
  • Sender hash. Each (r, r ^ Delta) pair is built in one YMM register, hashed, and stored straight to the output, with no stack batch or copy.

  • Correlated-OT choice bits. Choice bits go through SPIN's bit-vector transpose_bits instead of being widened to blocks for the record transpose. Choice bytes must be 0 or 1. Packing uses a portable multiply, so it needs no BMI2. The bit workspace is created on first use, so the sender never builds it.

  • Benchmark. -spinOtBench -check prints a fixed-seed output digest, so two builds can be compared bit for bit.

  • Consumer check. The installed-package test checks that the block and choice-byte transposes agree in both noise modes across reseeds.

The GGM and hash changes don't change any output. The PPRF tree, the leaf hash and the OT hash compute the same values.

Validation

Ryzen 9 7950X, Linux, GCC 15. Fresh clone of this branch, with SPIN fetched from the pinned GitHub commit. There are three builds of the same source:

  • full: VAES + AVX-512;
  • ENABLE_AVX512=OFF: the 256-bit kernels;
  • ENABLE_VAES=OFF: master's scalar GGM and hash.

In all three builds, the -u Spin, -u SilentOt and -u Pprf tests pass. -spinOtBench -check output digests are identical across all three builds at logN 13 and 18, for both regular and stationary noise. After the SpinCode consolidation, the full build passes the tests and the consumer check, and its digests and sender timing are unchanged.

SPIN 0.4.2 test suite. Passes on:

  • x86-64 with GCC, default and SPIN_PORTABLE;
  • x86-64 with MSVC, default and SPIN_PORTABLE;
  • AArch64 under QEMU: GCC with NEON, GCC with SPIN_PORTABLE, and Clang 18 with NEON;
  • Zen 4 with AVX-512.

Not tested on real Apple hardware, MSVC ARM64 or 32-bit targets.

Sender at K = 2^18, regular noise, non-temporal stores, one core. The baseline is master plus Turbo SPIN only, with VAES on in both builds:

expansion compress hash total
baseline 0.994 ms 0.455 ms 0.414 ms 1.865 ms
this PR 0.517 ms 0.462 ms 0.342 ms 1.31-1.34 ms

Correlated-OT choice bits at K = 2^18: 0.653 → 0.213 ms (the old block-widening path against transpose_bits), with outputs equal.

Notes

  • VAES is off by default. A fresh configure of master leaves ENABLE_VAES OFF, and then none of the VAES code runs. Pass -DENABLE_VAES=ON on VAES hardware.
  • ARM choice bits. On ARM, SPIN's choice-bit transpose uses the portable kernel. The record transpose uses NEON.
  • Receiver hash. The receiver's hash still uses the existing code.

🤖 Generated with Claude Code

ladnir and others added 8 commits November 20, 2026 22:44
Silent OT's SPIN profile is now Turbo SPIN (spin::Parameters::PacketRs8T64),
pinned to spin_codes main 584a7fb6 (SPIN 0.3). Under uniform setup its minimum
distance exceeds N/10 at K=2^14, 2^16, ..., 2^26 (Lean-certified). Requests up
to 2^14 use K=2^14; larger requests round up to a multiple of 128. Stationary
noise keeps the banked heuristic refresh, now over a Turbo bank.

Turbo has no generic-element transpose. Separate choice bytes therefore travel
in the low byte of a block through the native transpose (exact: the binary map
acts on each bit lane independently); packed choice bits are unchanged.
SpinCode rejects non-128-bit element types.

Tests: Spin_Integration_Test (native GF2/GF128 agreement, lifted choice bytes
in both noise modes, generic-type rejection, sizes) and the OtExt_Silent tests
pass on Peach; -spinOtBench -check passes for regular and stationary noise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Turbo runs at every natural size (a positive multiple of 128). Requests
round up to the next one, with the previous 8192 floor so the noise
configuration has room for its partitions; the floor is not related to the
distance certificates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SPIN 0.4 drops the generic coefficient transpose, so SpinCode accepts only
native 128-bit block records and rejects other element types. The package
lookups and docs ask for 0.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Sender hash: build each (r, r^Delta) pair in one YMM register and store the
  hashed pair straight to the output; no stack batch or copy.
- RegularPprf: VAES helpers for internal levels (YMM, sums in registers) and
  the leaf level (both keys interleaved, 8 AES chains in flight), used by
  sender and receiver. Non-VAES builds keep the scalar loops.
- spinOtBench -check prints a fixed-seed output digest so builds can be
  compared bit for bit.

Digests match the previous code at logN 13/18/20, regular and stationary.
K=2^18 sender on a Ryzen 9 7950X core: 1.651 -> 1.373 ms with -nt,
2.152 -> 1.483 ms with cached stores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With ENABLE_AVX512 the internal and leaf levels run on ZMM, two parents per
step: the same AES work in half the instructions, leaving the scheduler room
for the stores, sums and feed-forward. AVX2-only VAES builds keep the 256-bit
path. Output digests match at logN 13/18/20, regular and stationary; tests
pass. K=2^18 sender expansion 0.560 -> 0.502 ms (Ryzen 9 7950X core).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The correlated-OT receiver's choice bytes now go through SPIN 0.4.1's
transpose_bits instead of widening each byte to a block for a second full
record transpose. Each byte is eight bit lanes of the binary map; only the
bit planes present are transposed (one for 0/1 choices), packed with
pext/pdep where BMI2 is available. Outputs are unchanged.

Requires SPIN 0.4.1 (pinned to spin_codes cf75e9ec). spinOtBench -choices
times both paths in one binary: K=2^18 0.645 -> 0.214 ms, K=2^20
4.35 -> 0.87 ms. Spin, SilentOt and Pprf tests pass; random-OT digests match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ilds

- SpinCode is the only SPIN glue: messageSize, prepare (reseed or rebuild),
  block and choice-byte transposes, encoder(). SpinOt.h/.cpp removed.
- SpinConfigure moves to ConfigureCode.cpp (avoids an include cycle).
- mSpin is std::optional<SpinCode>; the choice-bit workspace is lazy.
- Choice bytes must be 0/1; portable multiply packing (no BMI2).
- Drop -spinOtBench -choices; fix the installed-package consumer check;
  remove the AVX2 test skips and cover stationary noise.
- Require and pin SPIN 0.4.2 (34a03e96): AArch64 NEON, portable fallback,
  MSVC. Docs: K >= 8192, platforms, ENABLE_VAES.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ladnir ladnir changed the title Silent OT: Turbo SPIN 0.4.1, VAES GGM expansion and hash, bit-vector choice transpose Silent OT: Turbo SPIN 0.4.2, VAES GGM expansion and hash, bit-vector choice transpose Nov 22, 2026
@ladnir
ladnir merged commit e0c1c98 into master Nov 24, 2026
5 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