# Compute with encrypted integers.

> Use Binary FHE for Boolean gates, lookup tables, and word-level arithmetic on encrypted unsigned integers.

- Canonical page: https://www.poulpy.dev/docs/binary-fhe/
- Poulpy version: 0.9.0
- Source revision: [`7dd13e6aa9808982f5355fb6acb70ca434de4e35`](https://github.com/poulpy-fhe/poulpy/tree/7dd13e6aa9808982f5355fb6acb70ca434de4e35)
- Documentation reviewed: 2026-10-08
- Audience: For developers starting integer computation

## Run the integer example

First complete the [source and toolchain setup](https://www.poulpy.dev/docs/quickstart/#1-get-the-source). From the Poulpy repository directory, run:

```sh
cargo run --locked --release -p poulpy-cpu-portable --features enable-bin-fhe --example bdd_arithmetic
```

The [`bdd_arithmetic.rs` example](https://github.com/poulpy-fhe/poulpy/blob/7dd13e6aa9808982f5355fb6acb70ca434de4e35/poulpy-cpu-portable/examples/bdd_arithmetic.rs) encrypts integers, performs arithmetic and selection, then decrypts and compares each result with the corresponding ordinary computation. Its `Result:` lines print the decrypted and expected values side by side.

This example uses the portable backend. It may take longer than the small CKKS quickstart because it performs bootstrapping as part of the computation.

## Read the result

The first computation evaluates `(a + b) XOR a` with `a = 255` and `b = 30`. Its decrypted result should match the expected value:

```text
Result: 482 == 482
```

Later comparisons use randomly generated inputs, so their values vary between runs. Each line should show matching values. The source is the reference for supported widths and signedness.

Before changing a circuit, check its overflow and comparison semantics and the evaluation-key requirements. These are discrete computations, but valid parameters and noise bounds still determine correctness. The [concept guide](https://www.poulpy.dev/docs/concepts/) explains the roles of bootstrapping and evaluation keys.

## Follow the building blocks

The [`poulpy-bin-fhe` crate](https://github.com/poulpy-fhe/poulpy/tree/7dd13e6aa9808982f5355fb6acb70ca434de4e35/poulpy-bin-fhe) builds integer operations on three layers:

1. **Blind rotation** evaluates a programmable lookup table on encrypted input.
2. **Circuit bootstrapping** prepares encrypted bits for use as selectors.
3. **BDD arithmetic** combines these selectors to evaluate integer circuits.

See the [codebase overview](https://www.poulpy.dev/docs/getting-started/#poulpy-bin-fhe) for how these layers fit together, or open the [`poulpy-bin-fhe` API reference](https://docs.rs/poulpy-bin-fhe/0.9.0/poulpy_bin_fhe/) for types and operations.

## Try it in a browser

[Squid’s interactive demo](https://squid.cedoor.dev/) lets you explore encrypted integer arithmetic through a wrapper around Poulpy. Its [source repository](https://github.com/cedoor/squid) includes Rust, WebAssembly, and Node bindings.

## Go further

- Read the [circuit bootstrapping example](https://github.com/poulpy-fhe/poulpy/blob/7dd13e6aa9808982f5355fb6acb70ca434de4e35/poulpy-cpu-portable/examples/circuit_bootstrapping.rs).
- Choose an accelerated implementation with the [backend guide](https://www.poulpy.dev/docs/backends/).
- Use the [measurement guide](https://www.poulpy.dev/docs/measurement/) for real workload timings; Binary FHE results are not yet available in the benchmark explorer.
