Encrypted Parity

L4 · Application Components
parity · 2 specifications · 1 implementation · 2 benchmarks
WHAT IT ISx mod 2 for every element of a secret vector — one exact bit out of an approximate scheme.
FHEBITWISECHALLENGE
SIGNATURE
kernel parity<type T: Integer, N: u32>(
%xs: secret<tensor<N x T>>,
) -> %p: secret<tensor<N x T>>
Sizes and element types are left open here. A specification fixes them; an implementation says over which of them it works.
SPECIFICATIONS2all publishedIMPLEMENTATIONS11 measured
BENCHMARKS2across 1 machine
FASTEST236 msN4096 on fairmath-general-runner
CHALLENGES1open
DESCRIPTION

Definition

Parity is the least significant bit of an integer, taken element by element over a secret vector:

pi=ximod2,0i<N.p_i = x_i \bmod 2, \qquad 0 \le i < N.

For a non-negative integer xix_i, the result pip_i is 11 when xix_i is odd and 00 when it is even — the single bit that decides oddness, and the bit every wider bit-operation reaches for first.

Mathematical Domain

Parity is defined over the integers, but how it is computed depends entirely on the scheme that holds the ciphertext. An exact-integer scheme (BGV/BFV) can read a residue modulo 22 directly; an arithmetic, approximate scheme (CKKS) has no notion of a bit at all and must build a smooth function that agrees with xmod2x \bmod 2 on every admissible integer. The discrete bit has an exact continuous stand-in,

xmod2=12(1cos(πx))for integer x,x \bmod 2 = \tfrac{1}{2}\bigl(1 - \cos(\pi x)\bigr) \quad\text{for integer } x,

so the same trigonometric machinery that drives the modular reduction inside CKKS bootstrapping also answers parity. The kernel fixes neither the scheme, the element width, nor the recovery rule — those come from a specification.

Parameters Defined by Specifications

A specification narrows the general operation into a concrete problem by pinning:

  • the scheme and correctness regime — exact bit recovery, or an approximation scored by closeness;
  • the element domain and width (for example u8, values in [0,255][0, 255]);
  • the vector length NN;
  • the packing and layout of the input and output (often the answer's to choose);
  • what is measured versus what runs untimed.

Applications

Parity is the atom of bit manipulation. Comparisons, range checks, bit masks, and modular reductions all decompose into operations on individual bits, and bit extraction begins with the last one. Under CKKS the parity circuit is the same cosine-based modular-reduction primitive that appears inside bootstrapping, so a fast, shallow parity is of interest well beyond the operation itself. In private computation it shows up wherever encrypted integers must be inspected bit by bit without being revealed.

MAINTAINER
FM
fairmathreviews specifications · resolves disputes
USED BY · 0 KERNELS
Kernels above this one. If this kernel is wrong, or slow, they are wrong or slow with it.Nothing depends on this kernel yet.
BUILDS ON · 0 KERNELS
Kernels this one is stated in terms of. Not a call graph — a statement of dependence between problems.Nothing. This kernel sits at the bottom of the graph.
RECENT ACTIVITYNothing yet.