Inspiration

Cryptographic master keys face two failure modes: single point of failure (SPoF) in storage, physical side-channel leakage (DPA, CPA, timing) in execution. Standard secret sharing (Shamir) leaves shares unmasked in memory, lacks tamper detection, exposes timing side channels during reconstruction. Traditional wrapping relies on off-the-shelf symmetric ciphers (AES-KW) with shared secrets.

Goal for Mathematics for Systems Security Hackathon (Cryptographer Track): design novel, information-theoretically secure threshold key wrapper from first-principles finite field algebra. Zero pre-made ciphers. Provable side-channel resistance. 100% tamper detection.

What it does

TCW-Mask wraps and reconstructs 256-bit cryptographic secrets across distributed nodes:

  • $(k, n)$-Threshold Sharing: Splits master secret $M \in \mathbb{F}{2^{255}-19}$ into $n$ polynomial shares. Any $k$ reconstruct. $<k$ reveals 0 information ($H(M \mid \mathcal{S}{<k}) = H(M)$).
  • Vandermonde Algebraic Masking: Embeds raw share $s_i$ into 4D vector with 3 random scalars $b_1, b_2, b_3 \in \mathbb{F}p$. Multiplies by $4 \times 4$ Vandermonde matrix $\mathbf{V}_i$. Adds scalar shift $r_i \mathbf{1}$. Decorrelates power consumption ($\text{Cov}(\mathcal{HW}(m{i,j}), s_i) = 0$).
  • Pedersen Vector Commitments: Computes $C_{i,j} = m_{i,j}G + r_i H \in \mathbb{G}$ on prime-order Ristretto255 group. Unconditionally hiding, computationally binding under Discrete Logarithm. Detects 1-bit share tampering ($p \ge 1 - 2^{-252}$).
  • Replay & Epoch Control: Binds shares to 128-bit cryptographic session_id. Proactive secret sharing refresh re-randomizes shares via zero-polynomial without changing master key.
  • Constant-Time Verification: Eliminates secret-dependent branches, cache-timing side channels. Certified via TVLA Welch's $t$-test.

How we built it

  • Core Engine: Pure Rust (2021 edition), zero-dependency cryptographic core using only subtle, zeroize, curve25519-dalek.
  • Field Arithmetic (src/field.rs): Constant-time arithmetic over $\mathbb{F}_{2^{255}-19}$ using five 64-bit limbs. Multiplications, additions, subtractions, Fermat Little Theorem inversions branchless via conditional select.
  • Matrix Masking (src/masking.rs): $4 \times 4$ Vandermonde matrix generation with random node evaluation. Inversion implemented via closed-form Lagrange basis polynomial expansion.
  • Commitments (src/commitment.rs): Multi-limb vector commitments on Ristretto255 group with SHA3-512 domain-separated generator $H$.
  • Memory Security (src/zeroize_ext.rs): Secret wrapper enforcing compiler zeroization on drop across all intermediate buffers.
  • Verification Stack:
    • 17 unit tests + property-based fuzz tests (proptest).
    • 1,000-cycle randomized correctness integration harness (tests/correctness.rs).
    • Active tamper, insufficient share, replay attack simulator (src/attack.rs).
    • CPA power trace leakage simulator (src/cpa.rs).
    • TVLA Welch's $t$-test benchmark engine (src/bench.rs).
  • Documentation & Media: 15-page IEEE academic report with formal proofs (docs/report.pdf), automated headless 1080p video demo (video/tcw_mask_demo.mp4).

Challenges we ran into

  • Constant-Time Matrix Inversion: Standard Gaussian elimination introduces conditional row swaps and branching on pivot elements. Solved: derived closed-form Lagrange polynomial coefficients over finite field $\mathbb{F}{2^{255}-19}$ to construct $(\mathbf{V}^{-1}){k,j} = c_{k,j}$ branchless.
  • LLVM Dead-Store Elimination: Compiler optimizes away zeroization passes for dropped stack buffers. Solved: wrapped memory buffers in zeroize::ZeroizeOnDrop combined with volatile memory fences via core::sync::atomic::compiler_fence.
  • Timing Leakage on Field Reductions: Subtractions modulo $2^{255}-19$ leak condition flags through conditional branches. Solved: implemented bit-masking arithmetic using subtle::Choice and ConditionalSelectable.
  • TVLA Noise Mitigation: User-space timing benchmarks suffer jitter from OS thread preemption. Solved: implemented interleaved alternating measurements (low vs high Hamming weight inputs) over thousands of iterations to ensure statistically valid Welch's $t$-distribution.

Accomplishments that we're proud of

  • Zero Off-the-Shelf Cipher Black-Boxes: Constructed entire wrapping mechanism purely from algebraic structures (polynomial rings, linear transformations, discrete log groups).
  • Certified TVLA Metric: Measured Welch's $t$-score $|t| = 0.5196$, well below NIST/ISO side-channel leakage limit ($|t| < 4.50, p > 0.05$).
  • 100% Active Tamper Rejection: Evaluated against 1-bit mutations, coefficient shifts, share replay; 100% rejected prior to reconstruction.
  • Publication-Grade Report: Authored formal academic paper (docs/report.pdf) containing Shannon secrecy proofs, discrete log binding reductions, full CPA covariance derivations.
  • Automated Delivery Pipeline: Complete CLI with generation, splitting, verification, reconstruction, attack simulation, and CPA evaluation commands.

What we learned

  • Duality between Vandermonde matrix inversion and Lagrange interpolation basis polynomials provides fast, closed-form, branchless linear transformations over finite fields.
  • 1st-order DPA/CPA masking requires multiplicative matrix mixing plus additive scalar blinding to completely decorrelate power leakage from raw share values.
  • Microsecond timing variations disappear when arithmetic structures guarantee branchless constant-time execution down to the limb level.

What's next for TCW-Mask

  • WebAssembly / HSM Integration: Compile core into zero-dependency WASM bundle for WebAuthn client-side key wrapping; target FIDO2 hardware tokens.
  • Post-Quantum Vector Commitments: Replace discrete-log Ristretto255 commitments with lattice-based homomorphic commitments (ML-DSA / Kyber compatible).
  • Physical Oscilloscope Validation: Execute hardware trace acquisition on FPGA (ChipWhisperer testbed) to confirm simulated CPA results against electromagnetic emissions.
  • MPC Threshold Signatures: Extend algebraic shares to direct Ed25519 threshold signing without reconstructing master private key.

Built With

  • cli
  • constant-time
  • cpa-defense
  • criterion
  • cryptography
  • curve25519
  • discrete-logarithm
  • dpa-masking
  • finite-fields
  • information-theory
  • latex
  • mathematics
  • pedersen-commitments
  • proptest
  • ristretto255
  • rust
  • security
  • shamir-secret-sharing
  • side-channel-attacks
  • subtle
  • threshold-cryptography
  • tvla
  • vandermonde-matrix
  • zeroize
Share this project:

Updates

Submission history