Compare commits

...

4 Commits

Author SHA1 Message Date
Mayeul@Zama
560c9cb3b2 f 2023-09-13 19:41:29 +02:00
Mayeul@Zama
28ea89ac42 f 2023-09-13 19:40:02 +02:00
Mayeul@Zama
5b8529e6d8 f 2023-09-13 19:35:52 +02:00
Mayeul@Zama
aefe2dd806 chore(make): replace Makefile by justfile 2023-09-13 19:22:13 +02:00
21 changed files with 753 additions and 689 deletions

View File

@@ -65,50 +65,54 @@ jobs:
with:
toolchain: stable
default: true
- name: Install just
run: |
cargo install just
- name: Run concrete-csprng tests
run: |
make test_concrete_csprng
just test_concrete_csprng
- name: Run core tests
run: |
AVX512_SUPPORT=ON make test_core_crypto
AVX512_SUPPORT=ON just test_core_crypto
- name: Run boolean tests
run: |
make test_boolean
just test_boolean
- name: Run user docs tests
run: |
make test_user_doc
just test_user_doc
- name: Run js on wasm API tests
run: |
make test_nodejs_wasm_api_in_docker
just test_nodejs_wasm_api_in_docker
- name: Gen Keys if required
run: |
make gen_key_cache
just gen_key_cache
- name: Run shortint tests
run: |
BIG_TESTS_INSTANCE=TRUE FAST_TESTS=TRUE make test_shortint_ci
BIG_TESTS_INSTANCE=TRUE FAST_TESTS=TRUE just test_shortint_ci
- name: Run integer tests
run: |
BIG_TESTS_INSTANCE=TRUE FAST_TESTS=TRUE make test_integer_ci
BIG_TESTS_INSTANCE=TRUE FAST_TESTS=TRUE just test_integer_ci
- name: Run shortint multi-bit tests
run: |
BIG_TESTS_INSTANCE=TRUE FAST_TESTS=TRUE make test_shortint_multi_bit_ci
BIG_TESTS_INSTANCE=TRUE FAST_TESTS=TRUE just test_shortint_multi_bit_ci
- name: Run integer multi-bit tests
run: |
BIG_TESTS_INSTANCE=TRUE FAST_TESTS=TRUE make test_integer_multi_bit_ci
BIG_TESTS_INSTANCE=TRUE FAST_TESTS=TRUE just test_integer_multi_bit_ci
- name: Run high-level API tests
run: |
make test_high_level_api
just test_high_level_api
- name: Slack Notification
if: ${{ always() }}

View File

@@ -64,14 +64,18 @@ jobs:
with:
toolchain: stable
default: true
- name: Install just
run: |
cargo install just
- name: Gen Keys if required
run: |
make gen_key_cache
just gen_key_cache
- name: Run integer tests
run: |
BIG_TESTS_INSTANCE=TRUE make test_integer_ci
BIG_TESTS_INSTANCE=TRUE just test_integer_ci
- name: Slack Notification
if: ${{ always() }}

View File

@@ -64,18 +64,22 @@ jobs:
with:
toolchain: stable
default: true
- name: Install just
run: |
cargo install just
- name: Gen Keys if required
run: |
make GEN_KEY_CACHE_MULTI_BIT_ONLY=TRUE gen_key_cache
just GEN_KEY_CACHE_MULTI_BIT_ONLY=TRUE gen_key_cache
- name: Run shortint multi-bit tests
run: |
make test_shortint_multi_bit_ci
just test_shortint_multi_bit_ci
- name: Run integer multi-bit tests
run: |
make test_integer_multi_bit_ci
just test_integer_multi_bit_ci
- name: Slack Notification
if: ${{ always() }}

View File

@@ -65,41 +65,46 @@ jobs:
toolchain: stable
default: true
- name: Install just
run: |
cargo install just
- name: Run concrete-csprng tests
run: |
make test_concrete_csprng
just test_concrete_csprng
- name: Run core tests
run: |
AVX512_SUPPORT=ON make test_core_crypto
AVX512_SUPPORT=ON just test_core_crypto
- name: Run boolean tests
run: |
make test_boolean
just test_boolean
- name: Run C API tests
run: |
make test_c_api
just test_c_api
- name: Run user docs tests
run: |
make test_user_doc
just test_user_doc
- name: Gen Keys if required
run: |
make gen_key_cache
just gen_key_cache
- name: Run shortint tests
run: |
BIG_TESTS_INSTANCE=TRUE make test_shortint_ci
BIG_TESTS_INSTANCE=TRUE just test_shortint_ci
- name: Run high-level API tests
run: |
BIG_TESTS_INSTANCE=TRUE make test_high_level_api
BIG_TESTS_INSTANCE=TRUE just test_high_level_api
- name: Run example tests
run: |
make test_examples
just test_examples
- name: Slack Notification
if: ${{ always() }}

View File

@@ -64,15 +64,19 @@ jobs:
with:
toolchain: stable
default: true
- name: Install just
run: |
cargo install just
- name: Run js on wasm API tests
run: |
make test_nodejs_wasm_api_in_docker
just test_nodejs_wasm_api_in_docker
- name: Run parallel wasm tests
run: |
make install_node
make ci_test_web_js_api_parallel
just install_node
just ci_test_web_js_api_parallel
- name: Slack Notification
if: ${{ always() }}

View File

@@ -57,10 +57,14 @@ jobs:
with:
toolchain: nightly
override: true
- name: Install just
run: |
cargo install just
- name: Run benchmarks with AVX512
run: |
make AVX512_SUPPORT=ON bench_boolean
just AVX512_SUPPORT=ON bench_boolean
- name: Parse results
run: |
@@ -79,7 +83,7 @@ jobs:
- name: Measure key sizes
run: |
make measure_boolean_key_sizes
just measure_boolean_key_sizes
- name: Parse key sizes results
run: |

View File

@@ -23,38 +23,43 @@ jobs:
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
- name: Install just
run: |
cargo install just
- name: Run pcc checks
run: |
make pcc
just pcc
- name: Build concrete-csprng
run: |
make build_concrete_csprng
just build_concrete_csprng
- name: Build Release core
run: |
make build_core AVX512_SUPPORT=ON
make build_core_experimental AVX512_SUPPORT=ON
just build_core AVX512_SUPPORT=ON
just build_core_experimental AVX512_SUPPORT=ON
- name: Build Release boolean
run: |
make build_boolean
just build_boolean
- name: Build Release shortint
run: |
make build_shortint
just build_shortint
- name: Build Release integer
run: |
make build_integer
just build_integer
- name: Build Release tfhe full
run: |
make build_tfhe_full
just build_tfhe_full
- name: Build Release c_api
run: |
make build_c_api
just build_c_api
# The wasm build check is a bit annoying to set-up here and is done during the tests in
# aws_tfhe_tests.yml

View File

@@ -17,14 +17,18 @@ jobs:
steps:
- name: Checkout tfhe-rs
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Install just
run: |
cargo install just
- name: Gen Keys if required
run: |
make GEN_KEY_CACHE_COVERAGE_ONLY=TRUE gen_key_cache
just GEN_KEY_CACHE_COVERAGE_ONLY=TRUE gen_key_cache
- name: Run shortint coverage
run: |
make test_shortint_cov
just test_shortint_cov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d

View File

@@ -56,10 +56,14 @@ jobs:
with:
toolchain: stable
default: true
- name: Install just
run: |
cargo install just
- name: Dieharder randomness test suite
run: |
make dieharder_csprng
just dieharder_csprng
- name: Slack Notification
if: ${{ failure() }}

View File

@@ -58,14 +58,18 @@ jobs:
with:
toolchain: nightly
override: true
- name: Install just
run: |
cargo install just
- name: Run benchmarks with AVX512
run: |
make AVX512_SUPPORT=ON FAST_BENCH=TRUE bench_integer
just AVX512_SUPPORT=ON FAST_BENCH=TRUE bench_integer
- name: Parse benchmarks to csv
run: |
make PARSE_INTEGER_BENCH_CSV_FILE=${{ env.PARSE_INTEGER_BENCH_CSV_FILE }} \
just PARSE_INTEGER_BENCH_CSV_FILE=${{ env.PARSE_INTEGER_BENCH_CSV_FILE }} \
parse_integer_benches
- name: Upload csv results artifact

View File

@@ -72,10 +72,14 @@ jobs:
repository: zama-ai/slab
path: slab
token: ${{ secrets.CONCRETE_ACTIONS_TOKEN }}
- name: Install just
run: |
cargo install just
- name: Run benchmarks with AVX512
run: |
make AVX512_SUPPORT=ON BENCH_OP_FLAVOR=${{ matrix.op_flavor }} bench_${{ matrix.command }}
just AVX512_SUPPORT=ON BENCH_OP_FLAVOR=${{ matrix.op_flavor }} bench_${{ matrix.command }}
- name: Parse results
run: |

View File

@@ -59,13 +59,18 @@ jobs:
toolchain: nightly
override: true
- name: Install just
run: |
cargo install just
- name: Run multi-bit benchmarks with AVX512
run: |
make AVX512_SUPPORT=ON FAST_BENCH=TRUE bench_integer_multi_bit
just AVX512_SUPPORT=ON FAST_BENCH=TRUE bench_integer_multi_bit
- name: Parse benchmarks to csv
run: |
make PARSE_INTEGER_BENCH_CSV_FILE=${{ env.PARSE_INTEGER_BENCH_CSV_FILE }} \
just PARSE_INTEGER_BENCH_CSV_FILE=${{ env.PARSE_INTEGER_BENCH_CSV_FILE }} \
parse_integer_benches
- name: Upload csv results artifact

View File

@@ -35,86 +35,90 @@ jobs:
with:
toolchain: stable
default: true
- name: Install just
run: |
cargo install just
- name: Run pcc checks
run: |
make pcc
just pcc
- name: Build concrete-csprng
run: |
make build_concrete_csprng
just build_concrete_csprng
- name: Build Release core
run: |
make build_core
just build_core
- name: Build Release boolean
run: |
make build_boolean
just build_boolean
- name: Build Release shortint
run: |
make build_shortint
just build_shortint
- name: Build Release integer
run: |
make build_integer
just build_integer
- name: Build Release tfhe full
run: |
make build_tfhe_full
just build_tfhe_full
- name: Build Release c_api
run: |
make build_c_api
just build_c_api
- name: Run concrete-csprng tests
run: |
make test_concrete_csprng
just test_concrete_csprng
- name: Run core tests
run: |
make test_core_crypto
just test_core_crypto
- name: Run boolean tests
run: |
make test_boolean
just test_boolean
- name: Run C API tests
run: |
make test_c_api
just test_c_api
- name: Run user docs tests
run: |
make test_user_doc
just test_user_doc
# JS tests are more easily launched in docker, we won't test that on M1 as docker is pretty
# slow on Apple machines due to the virtualization layer.
- name: Gen Keys if required
run: |
make gen_key_cache
just gen_key_cache
- name: Run shortint tests
run: |
make test_shortint_ci
just test_shortint_ci
- name: Run integer tests
run: |
make test_integer_ci
just test_integer_ci
- name: Gen Keys if required
run: |
make GEN_KEY_CACHE_MULTI_BIT_ONLY=TRUE gen_key_cache
just GEN_KEY_CACHE_MULTI_BIT_ONLY=TRUE gen_key_cache
- name: Run shortint multi bit tests
run: |
make test_shortint_multi_bit_ci
just test_shortint_multi_bit_ci
# # These multi bit integer tests are too slow on M1 with low core count and low RAM
# - name: Run integer multi bit tests
# run: |
# make test_integer_multi_bit_ci
# just test_integer_multi_bit_ci
remove_label:
name: Remove m1_test label

View File

@@ -42,10 +42,15 @@ jobs:
run: |
cargo publish -p tfhe --token ${{ env.CRATES_TOKEN }} ${{ env.DRY_RUN }}
- name: Install just
run: |
cargo install just
- name: Build web package
if: ${{ inputs.push_web_package }}
run: |
make build_web_js_api
just build_web_js_api
- name: Publish web package
if: ${{ inputs.push_web_package }}
@@ -54,13 +59,17 @@ jobs:
token: ${{ secrets.NPM_TOKEN }}
package: tfhe/pkg/package.json
dry-run: ${{ inputs.dry_run }}
- name: Install just
run: |
cargo install just
- name: Build Node package
if: ${{ inputs.push_node_package }}
run: |
rm -rf tfhe/pkg
make build_node_js_api
just build_node_js_api
sed -i 's/"tfhe"/"node-tfhe"/g' tfhe/pkg/package.json
- name: Publish Node package

View File

@@ -30,9 +30,14 @@ jobs:
sudo apt update
sudo apt install -y sagemath
- name: Install just
run: |
cargo install just
- name: Collect parameters
run: |
make write_params_to_file
just write_params_to_file
- name: Perform security check
run: |

View File

@@ -57,10 +57,14 @@ jobs:
with:
toolchain: nightly
override: true
- name: Install just
run: |
cargo install just
- name: Run benchmarks with AVX512
run: |
make AVX512_SUPPORT=ON bench_pbs
just AVX512_SUPPORT=ON bench_pbs
- name: Parse results
run: |

View File

@@ -58,9 +58,14 @@ jobs:
toolchain: nightly
override: true
- name: Install just
run: |
cargo install just
- name: Run benchmarks with AVX512
run: |
make AVX512_SUPPORT=ON bench_shortint
just AVX512_SUPPORT=ON bench_shortint
- name: Parse results
run: |
@@ -79,7 +84,7 @@ jobs:
- name: Measure key sizes
run: |
make measure_shortint_key_sizes
just measure_shortint_key_sizes
- name: Parse key sizes results
run: |

View File

@@ -70,10 +70,14 @@ jobs:
repository: zama-ai/slab
path: slab
token: ${{ secrets.CONCRETE_ACTIONS_TOKEN }}
- name: Install just
run: |
cargo install just
- name: Run benchmarks with AVX512
run: |
make AVX512_SUPPORT=ON BENCH_OP_FLAVOR=${{ matrix.op_flavor }} bench_shortint
just AVX512_SUPPORT=ON BENCH_OP_FLAVOR=${{ matrix.op_flavor }} bench_shortint
- name: Parse results
run: |
@@ -94,7 +98,7 @@ jobs:
- name: Measure key sizes
if: matrix.op_flavor == 'default'
run: |
make measure_shortint_key_sizes
just measure_shortint_key_sizes
- name: Parse key sizes results
if: matrix.op_flavor == 'default'

View File

@@ -57,15 +57,19 @@ jobs:
with:
toolchain: nightly
override: true
- name: Install just
run: |
cargo install just
- name: Run benchmarks
run: |
make install_node
make ci_bench_web_js_api_parallel
just install_node
just ci_bench_web_js_api_parallel
- name: Parse results
run: |
make parse_wasm_benchmarks
just parse_wasm_benchmarks
COMMIT_DATE="$(git --no-pager show -s --format=%cd --date=iso8601-strict ${{ github.sha }})"
COMMIT_HASH="$(git describe --tags --dirty)"
@@ -80,7 +84,7 @@ jobs:
- name: Measure public key and ciphertext sizes in HL Api
run: |
make measure_hlapi_compact_pk_ct_sizes
just measure_hlapi_compact_pk_ct_sizes
- name: Parse key and ciphertext sizes results
run: |

600
Makefile
View File

@@ -1,600 +0,0 @@
SHELL:=$(shell /usr/bin/env which bash)
OS:=$(shell uname)
RS_CHECK_TOOLCHAIN:=$(shell cat toolchain.txt | tr -d '\n')
CARGO_RS_CHECK_TOOLCHAIN:=+$(RS_CHECK_TOOLCHAIN)
TARGET_ARCH_FEATURE:=$(shell ./scripts/get_arch_feature.sh)
RS_BUILD_TOOLCHAIN:=stable
CARGO_RS_BUILD_TOOLCHAIN:=+$(RS_BUILD_TOOLCHAIN)
CARGO_PROFILE?=release
MIN_RUST_VERSION:=$(shell grep rust-version tfhe/Cargo.toml | cut -d '=' -f 2 | xargs)
AVX512_SUPPORT?=OFF
WASM_RUSTFLAGS:=
BIG_TESTS_INSTANCE?=FALSE
GEN_KEY_CACHE_MULTI_BIT_ONLY?=FALSE
GEN_KEY_CACHE_COVERAGE_ONLY?=FALSE
PARSE_INTEGER_BENCH_CSV_FILE?=tfhe_rs_integer_benches.csv
FAST_TESTS?=FALSE
FAST_BENCH?=FALSE
BENCH_OP_FLAVOR?=DEFAULT
# This is done to avoid forgetting it, we still precise the RUSTFLAGS in the commands to be able to
# copy paste the command in the terminal and change them if required without forgetting the flags
export RUSTFLAGS?=-C target-cpu=native
ifeq ($(AVX512_SUPPORT),ON)
AVX512_FEATURE=nightly-avx512
else
AVX512_FEATURE=
endif
ifeq ($(GEN_KEY_CACHE_MULTI_BIT_ONLY),TRUE)
MULTI_BIT_ONLY=--multi-bit-only
else
MULTI_BIT_ONLY=
endif
ifeq ($(GEN_KEY_CACHE_COVERAGE_ONLY),TRUE)
COVERAGE_ONLY=--coverage-only
else
COVERAGE_ONLY=
endif
# Variables used only for regex_engine example
REGEX_STRING?=''
REGEX_PATTERN?=''
.PHONY: rs_check_toolchain # Echo the rust toolchain used for checks
rs_check_toolchain:
@echo $(RS_CHECK_TOOLCHAIN)
.PHONY: rs_build_toolchain # Echo the rust toolchain used for builds
rs_build_toolchain:
@echo $(RS_BUILD_TOOLCHAIN)
.PHONY: install_rs_check_toolchain # Install the toolchain used for checks
install_rs_check_toolchain:
@rustup toolchain list | grep -q "$(RS_CHECK_TOOLCHAIN)" || \
rustup toolchain install --profile default "$(RS_CHECK_TOOLCHAIN)" || \
( echo "Unable to install $(RS_CHECK_TOOLCHAIN) toolchain, check your rustup installation. \
Rustup can be downloaded at https://rustup.rs/" && exit 1 )
.PHONY: install_rs_build_toolchain # Install the toolchain used for builds
install_rs_build_toolchain:
@( rustup toolchain list | grep -q "$(RS_BUILD_TOOLCHAIN)" && \
./scripts/check_cargo_min_ver.sh \
--rust-toolchain "$(CARGO_RS_BUILD_TOOLCHAIN)" \
--min-rust-version "$(MIN_RUST_VERSION)" ) || \
rustup toolchain install --profile default "$(RS_BUILD_TOOLCHAIN)" || \
( echo "Unable to install $(RS_BUILD_TOOLCHAIN) toolchain, check your rustup installation. \
Rustup can be downloaded at https://rustup.rs/" && exit 1 )
.PHONY: install_cargo_nextest # Install cargo nextest used for shortint tests
install_cargo_nextest: install_rs_build_toolchain
@cargo nextest --version > /dev/null 2>&1 || \
cargo $(CARGO_RS_BUILD_TOOLCHAIN) install cargo-nextest --locked || \
( echo "Unable to install cargo nextest, unknown error." && exit 1 )
.PHONY: install_wasm_pack # Install wasm-pack to build JS packages
install_wasm_pack: install_rs_build_toolchain
@wasm-pack --version > /dev/null 2>&1 || \
cargo $(CARGO_RS_BUILD_TOOLCHAIN) install wasm-pack || \
( echo "Unable to install cargo wasm-pack, unknown error." && exit 1 )
.PHONY: install_node # Install last version of NodeJS via nvm
install_node:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | $(SHELL)
source ~/.bashrc
$(SHELL) -i -c 'nvm install node' || \
( echo "Unable to install node, unknown error." && exit 1 )
.PHONY: install_dieharder # Install dieharder for apt distributions or macOS
install_dieharder:
@dieharder -h > /dev/null 2>&1 || \
if [[ "$(OS)" == "Linux" ]]; then \
sudo apt update && sudo apt install -y dieharder; \
elif [[ "$(OS)" == "Darwin" ]]; then\
brew install dieharder; \
fi || ( echo "Unable to install dieharder, unknown error." && exit 1 )
.PHONY: install_tarpaulin # Install tarpaulin to perform code coverage
install_tarpaulin: install_rs_build_toolchain
@cargo tarpaulin --version > /dev/null 2>&1 || \
cargo $(CARGO_RS_BUILD_TOOLCHAIN) install cargo-tarpaulin --locked || \
( echo "Unable to install cargo tarpaulin, unknown error." && exit 1 )
.PHONY: fmt # Format rust code
fmt: install_rs_check_toolchain
cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" fmt
.PHONT: check_fmt # Check rust code format
check_fmt: install_rs_check_toolchain
cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" fmt --check
.PHONY: clippy_core # Run clippy lints on core_crypto with and without experimental features
clippy_core: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
--features=$(TARGET_ARCH_FEATURE) \
-p tfhe -- --no-deps -D warnings
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
--features=$(TARGET_ARCH_FEATURE),experimental \
-p tfhe -- --no-deps -D warnings
.PHONY: clippy_boolean # Run clippy lints enabling the boolean features
clippy_boolean: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
--features=$(TARGET_ARCH_FEATURE),boolean \
-p tfhe -- --no-deps -D warnings
.PHONY: clippy_shortint # Run clippy lints enabling the shortint features
clippy_shortint: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
--features=$(TARGET_ARCH_FEATURE),shortint \
-p tfhe -- --no-deps -D warnings
.PHONY: clippy_integer # Run clippy lints enabling the integer features
clippy_integer: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
--features=$(TARGET_ARCH_FEATURE),integer \
-p tfhe -- --no-deps -D warnings
.PHONY: clippy # Run clippy lints enabling the boolean, shortint, integer
clippy: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy --all-targets \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer \
-p tfhe -- --no-deps -D warnings
.PHONY: clippy_c_api # Run clippy lints enabling the boolean, shortint and the C API
clippy_c_api: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
--features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api \
-p tfhe -- --no-deps -D warnings
.PHONY: clippy_js_wasm_api # Run clippy lints enabling the boolean, shortint, integer and the js wasm API
clippy_js_wasm_api: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
--features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api \
-p tfhe -- --no-deps -D warnings
.PHONY: clippy_tasks # Run clippy lints on helper tasks crate.
clippy_tasks:
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
-p tasks -- --no-deps -D warnings
.PHONY: clippy_trivium # Run clippy lints on Trivium app
clippy_trivium: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy -p tfhe-trivium \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer \
-p tfhe -- --no-deps -D warnings
.PHONY: clippy_all_targets # Run clippy lints on all targets (benches, examples, etc.)
clippy_all_targets:
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy --all-targets \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache \
-p tfhe -- --no-deps -D warnings
.PHONY: clippy_concrete_csprng # Run clippy lints on concrete-csprng
clippy_concrete_csprng:
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy --all-targets \
--features=$(TARGET_ARCH_FEATURE) \
-p concrete-csprng -- --no-deps -D warnings
.PHONY: clippy_all # Run all clippy targets
clippy_all: clippy clippy_boolean clippy_shortint clippy_integer clippy_all_targets clippy_c_api \
clippy_js_wasm_api clippy_tasks clippy_core clippy_concrete_csprng clippy_trivium
.PHONY: clippy_fast # Run main clippy targets
clippy_fast: clippy clippy_all_targets clippy_c_api clippy_js_wasm_api clippy_tasks clippy_core \
clippy_concrete_csprng
.PHONY: gen_key_cache # Run the script to generate keys and cache them for shortint tests
gen_key_cache: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) run --profile $(CARGO_PROFILE) \
--example generates_test_keys \
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache -p tfhe -- \
$(MULTI_BIT_ONLY) $(COVERAGE_ONLY)
.PHONY: build_core # Build core_crypto without experimental features
build_core: install_rs_build_toolchain install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE) -p tfhe
@if [[ "$(AVX512_SUPPORT)" == "ON" ]]; then \
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),$(AVX512_FEATURE) -p tfhe; \
fi
.PHONY: build_core_experimental # Build core_crypto with experimental features
build_core_experimental: install_rs_build_toolchain install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),experimental -p tfhe
@if [[ "$(AVX512_SUPPORT)" == "ON" ]]; then \
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),experimental,$(AVX512_FEATURE) -p tfhe; \
fi
.PHONY: build_boolean # Build with boolean enabled
build_boolean: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),boolean -p tfhe --all-targets
.PHONY: build_shortint # Build with shortint enabled
build_shortint: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),shortint -p tfhe --all-targets
.PHONY: build_integer # Build with integer enabled
build_integer: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),integer -p tfhe --all-targets
.PHONY: build_tfhe_full # Build with boolean, shortint and integer enabled
build_tfhe_full: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer -p tfhe --all-targets
.PHONY: build_c_api # Build the C API for boolean, shortint and integer
build_c_api: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api, \
-p tfhe
.PHONY: build_c_api_experimental_deterministic_fft # Build the C API for boolean, shortint and integer with experimental deterministic FFT
build_c_api_experimental_deterministic_fft: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api,experimental-force_fft_algo_dif4 \
-p tfhe
.PHONY: build_web_js_api # Build the js API targeting the web browser
build_web_js_api: install_rs_build_toolchain install_wasm_pack
cd tfhe && \
RUSTFLAGS="$(WASM_RUSTFLAGS)" rustup run "$(RS_BUILD_TOOLCHAIN)" \
wasm-pack build --release --target=web \
-- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api
.PHONY: build_web_js_api_parallel # Build the js API targeting the web browser with parallelism support
build_web_js_api_parallel: install_rs_check_toolchain install_wasm_pack
cd tfhe && \
rustup component add rust-src --toolchain $(RS_CHECK_TOOLCHAIN) && \
RUSTFLAGS="$(WASM_RUSTFLAGS) -C target-feature=+atomics,+bulk-memory,+mutable-globals" rustup run $(RS_CHECK_TOOLCHAIN) \
wasm-pack build --release --target=web \
-- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,parallel-wasm-api \
-Z build-std=panic_abort,std
.PHONY: build_node_js_api # Build the js API targeting nodejs
build_node_js_api: install_rs_build_toolchain install_wasm_pack
cd tfhe && \
RUSTFLAGS="$(WASM_RUSTFLAGS)" rustup run "$(RS_BUILD_TOOLCHAIN)" \
wasm-pack build --release --target=nodejs \
-- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api
.PHONY: build_concrete_csprng # Build concrete_csprng
build_concrete_csprng: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE) -p concrete-csprng --all-targets
.PHONY: test_core_crypto # Run the tests of the core_crypto module including experimental ones
test_core_crypto: install_rs_build_toolchain install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),experimental -p tfhe -- core_crypto::
@if [[ "$(AVX512_SUPPORT)" == "ON" ]]; then \
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),experimental,$(AVX512_FEATURE) -p tfhe -- core_crypto::; \
fi
.PHONY: test_boolean # Run the tests of the boolean module
test_boolean: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),boolean -p tfhe -- boolean::
.PHONY: test_c_api_rs # Run the rust tests for the C API
test_c_api_rs: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api \
-p tfhe \
c_api
.PHONY: test_c_api_c # Run the C tests for the C API
test_c_api_c: build_c_api
./scripts/c_api_tests.sh
.PHONY: test_c_api # Run all the tests for the C API
test_c_api: test_c_api_rs test_c_api_c
.PHONY: test_shortint_ci # Run the tests for shortint ci
test_shortint_ci: install_rs_build_toolchain install_cargo_nextest
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
FAST_TESTS="$(FAST_TESTS)" \
./scripts/shortint-tests.sh --rust-toolchain $(CARGO_RS_BUILD_TOOLCHAIN) \
--cargo-profile "$(CARGO_PROFILE)"
.PHONY: test_shortint_multi_bit_ci # Run the tests for shortint ci running only multibit tests
test_shortint_multi_bit_ci: install_rs_build_toolchain install_cargo_nextest
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
FAST_TESTS="$(FAST_TESTS)" \
./scripts/shortint-tests.sh --rust-toolchain $(CARGO_RS_BUILD_TOOLCHAIN) \
--cargo-profile "$(CARGO_PROFILE)" --multi-bit
.PHONY: test_shortint # Run all the tests for shortint
test_shortint: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache -p tfhe -- shortint::
.PHONY: test_shortint_cov # Run the tests of the shortint module with code coverage
test_shortint_cov: install_rs_check_toolchain install_tarpaulin
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) tarpaulin --profile $(CARGO_PROFILE) \
--out Xml --output-dir coverage/shortint --line --engine Llvm --timeout 500 \
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache,__coverage -p tfhe -- shortint::
.PHONY: test_integer_ci # Run the tests for integer ci
test_integer_ci: install_rs_build_toolchain install_cargo_nextest
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
FAST_TESTS="$(FAST_TESTS)" \
./scripts/integer-tests.sh --rust-toolchain $(CARGO_RS_BUILD_TOOLCHAIN) \
--cargo-profile "$(CARGO_PROFILE)"
.PHONY: test_integer_multi_bit_ci # Run the tests for integer ci running only multibit tests
test_integer_multi_bit_ci: install_rs_build_toolchain install_cargo_nextest
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
FAST_TESTS="$(FAST_TESTS)" \
./scripts/integer-tests.sh --rust-toolchain $(CARGO_RS_BUILD_TOOLCHAIN) \
--cargo-profile "$(CARGO_PROFILE)" --multi-bit
.PHONY: test_integer # Run all the tests for integer
test_integer: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache -p tfhe -- integer::
.PHONY: test_high_level_api # Run all the tests for high_level_api
test_high_level_api: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache -p tfhe \
-- high_level_api::
.PHONY: test_user_doc # Run tests from the .md documentation
test_user_doc: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) --doc \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache -p tfhe \
-- test_user_docs::
.PHONY: test_regex_engine # Run tests for regex_engine example
test_regex_engine: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
--example regex_engine \
--features=$(TARGET_ARCH_FEATURE),integer
.PHONY: test_sha256_bool # Run tests for sha256_bool example
test_sha256_bool: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
--example sha256_bool \
--features=$(TARGET_ARCH_FEATURE),boolean
.PHONY: test_examples # Run tests for examples
test_examples: test_sha256_bool test_regex_engine
.PHONY: test_trivium # Run tests for trivium
test_trivium: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
-p tfhe-trivium -- --test-threads=1 trivium::
.PHONY: test_kreyvium # Run tests for kreyvium
test_kreyvium: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
-p tfhe-trivium -- --test-threads=1 kreyvium::
.PHONY: test_concrete_csprng # Run concrete-csprng tests
test_concrete_csprng:
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
--features=$(TARGET_ARCH_FEATURE) -p concrete-csprng
.PHONY: doc # Build rust doc
doc: install_rs_check_toolchain
RUSTDOCFLAGS="--html-in-header katex-header.html" \
cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" doc \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer --no-deps
.PHONY: docs # Build rust doc alias for doc
docs: doc
.PHONY: lint_doc # Build rust doc with linting enabled
lint_doc: install_rs_check_toolchain
RUSTDOCFLAGS="--html-in-header katex-header.html -Dwarnings" \
cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" doc \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer --no-deps
.PHONY: lint_docs # Build rust doc with linting enabled alias for lint_doc
lint_docs: lint_doc
.PHONY: format_doc_latex # Format the documentation latex equations to avoid broken rendering.
format_doc_latex:
cargo xtask format_latex_doc
@"$(MAKE)" --no-print-directory fmt
@printf "\n===============================\n\n"
@printf "Please manually inspect changes made by format_latex_doc, rustfmt can break equations \
if the line length is exceeded\n"
@printf "\n===============================\n"
.PHONY: check_compile_tests # Build tests in debug without running them
check_compile_tests:
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --no-run \
--features=$(TARGET_ARCH_FEATURE),experimental,boolean,shortint,integer,internal-keycache \
-p tfhe
@if [[ "$(OS)" == "Linux" || "$(OS)" == "Darwin" ]]; then \
"$(MAKE)" build_c_api; \
./scripts/c_api_tests.sh --build-only; \
fi
.PHONY: build_nodejs_test_docker # Build a docker image with tools to run nodejs tests for wasm API
build_nodejs_test_docker:
DOCKER_BUILDKIT=1 docker build --build-arg RUST_TOOLCHAIN="$(RS_BUILD_TOOLCHAIN)" \
-f docker/Dockerfile.wasm_tests -t tfhe-wasm-tests .
.PHONY: test_nodejs_wasm_api_in_docker # Run tests for the nodejs on wasm API in a docker container
test_nodejs_wasm_api_in_docker: build_nodejs_test_docker
if [[ -t 1 ]]; then RUN_FLAGS="-it"; else RUN_FLAGS="-i"; fi && \
docker run --rm "$${RUN_FLAGS}" \
-v "$$(pwd)":/tfhe-wasm-tests/tfhe-rs \
-v tfhe-rs-root-target-cache:/root/tfhe-rs-target \
-v tfhe-rs-pkg-cache:/tfhe-wasm-tests/tfhe-rs/tfhe/pkg \
-v tfhe-rs-root-cargo-registry-cache:/root/.cargo/registry \
-v tfhe-rs-root-cache:/root/.cache \
tfhe-wasm-tests /bin/bash -i -c 'make test_nodejs_wasm_api'
.PHONY: test_nodejs_wasm_api # Run tests for the nodejs on wasm API
test_nodejs_wasm_api: build_node_js_api
cd tfhe && node --test js_on_wasm_tests
.PHONY: test_web_js_api_parallel # Run tests for the web wasm api
test_web_js_api_parallel: build_web_js_api_parallel
$(MAKE) -C tfhe/web_wasm_parallel_tests test
.PHONY: ci_test_web_js_api_parallel # Run tests for the web wasm api
ci_test_web_js_api_parallel: build_web_js_api_parallel
source ~/.nvm/nvm.sh && \
nvm use node && \
$(MAKE) -C tfhe/web_wasm_parallel_tests test-ci
.PHONY: no_tfhe_typo # Check we did not invert the h and f in tfhe
no_tfhe_typo:
@./scripts/no_tfhe_typo.sh
.PHONY: no_dbg_log # Check we did not leave dbg macro calls in the rust code
no_dbg_log:
@./scripts/no_dbg_calls.sh
.PHONY: dieharder_csprng # Run the dieharder test suite on our CSPRNG implementation
dieharder_csprng: install_dieharder build_concrete_csprng
./scripts/dieharder_test.sh
#
# Benchmarks
#
.PHONY: bench_integer # Run benchmarks for integer
bench_integer: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" __TFHE_RS_BENCH_OP_FLAVOR=$(BENCH_OP_FLAVOR) __TFHE_RS_FAST_BENCH=$(FAST_BENCH) \
cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
--bench integer-bench \
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache,$(AVX512_FEATURE) -p tfhe --
.PHONY: bench_integer_multi_bit # Run benchmarks for integer using multi-bit parameters
bench_integer_multi_bit: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" __TFHE_RS_BENCH_TYPE=MULTI_BIT \
__TFHE_RS_BENCH_OP_FLAVOR=$(BENCH_OP_FLAVOR) __TFHE_RS_FAST_BENCH=$(FAST_BENCH) \
cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
--bench integer-bench \
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache,$(AVX512_FEATURE) -p tfhe --
.PHONY: bench_shortint # Run benchmarks for shortint
bench_shortint: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" __TFHE_RS_BENCH_OP_FLAVOR=$(BENCH_OP_FLAVOR) \
cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
--bench shortint-bench \
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache,$(AVX512_FEATURE) -p tfhe
.PHONY: bench_shortint_multi_bit # Run benchmarks for shortint using multi-bit parameters
bench_shortint_multi_bit: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" __TFHE_RS_BENCH_TYPE=MULTI_BIT \
__TFHE_RS_BENCH_OP_FLAVOR=$(BENCH_OP_FLAVOR) \
cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
--bench shortint-bench \
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache,$(AVX512_FEATURE) -p tfhe --
.PHONY: bench_boolean # Run benchmarks for boolean
bench_boolean: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
--bench boolean-bench \
--features=$(TARGET_ARCH_FEATURE),boolean,internal-keycache,$(AVX512_FEATURE) -p tfhe
.PHONY: bench_pbs # Run benchmarks for PBS
bench_pbs: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
--bench pbs-bench \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,internal-keycache,$(AVX512_FEATURE) -p tfhe
.PHONY: bench_web_js_api_parallel # Run benchmarks for the web wasm api
bench_web_js_api_parallel: build_web_js_api_parallel
$(MAKE) -C tfhe/web_wasm_parallel_tests bench
.PHONY: ci_bench_web_js_api_parallel # Run benchmarks for the web wasm api
ci_bench_web_js_api_parallel: build_web_js_api_parallel
source ~/.nvm/nvm.sh && \
nvm use node && \
$(MAKE) -C tfhe/web_wasm_parallel_tests bench-ci
#
# Utility tools
#
.PHONY: measure_hlapi_compact_pk_ct_sizes # Measure sizes of public keys and ciphertext for high-level API
measure_hlapi_compact_pk_ct_sizes: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) run --profile $(CARGO_PROFILE) \
--example hlapi_compact_pk_ct_sizes \
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache
.PHONY: measure_shortint_key_sizes # Measure sizes of bootstrapping and key switching keys for shortint
measure_shortint_key_sizes: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) run --profile $(CARGO_PROFILE) \
--example shortint_key_sizes \
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache
.PHONY: measure_boolean_key_sizes # Measure sizes of bootstrapping and key switching keys for boolean
measure_boolean_key_sizes: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) run --profile $(CARGO_PROFILE) \
--example boolean_key_sizes \
--features=$(TARGET_ARCH_FEATURE),boolean,internal-keycache
.PHONY: parse_integer_benches # Run python parser to output a csv containing integer benches data
parse_integer_benches:
python3 ./ci/parse_integer_benches_to_csv.py \
--criterion-dir target/criterion \
--output-file "$(PARSE_INTEGER_BENCH_CSV_FILE)"
.PHONY: parse_wasm_benchmarks # Parse benchmarks performed with WASM web client into a CSV file
parse_wasm_benchmarks: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) run --profile $(CARGO_PROFILE) \
--example wasm_benchmarks_parser \
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache \
-- web_wasm_parallel_tests/test/benchmark_results
.PHONY: write_params_to_file # Gather all crypto parameters into a file with a Sage readable format.
write_params_to_file: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) run --profile $(CARGO_PROFILE) \
--example write_params_to_file \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,internal-keycache
#
# Real use case examples
#
.PHONY: regex_engine # Run regex_engine example
regex_engine: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) run --profile $(CARGO_PROFILE) \
--example regex_engine \
--features=$(TARGET_ARCH_FEATURE),integer \
-- $(REGEX_STRING) $(REGEX_PATTERN)
.PHONY: dark_market # Run dark market example
dark_market: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) run --profile $(CARGO_PROFILE) \
--example dark_market \
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache \
-- fhe-modified fhe-parallel plain fhe
.PHONY: sha256_bool # Run sha256_bool example
sha256_bool: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) run --profile $(CARGO_PROFILE) \
--example sha256_bool \
--features=$(TARGET_ARCH_FEATURE),boolean
.PHONY: pcc # pcc stands for pre commit checks
pcc: no_tfhe_typo no_dbg_log check_fmt lint_doc clippy_all check_compile_tests
.PHONY: fpcc # pcc stands for pre commit checks, the f stands for fast
fpcc: no_tfhe_typo no_dbg_log check_fmt lint_doc clippy_fast check_compile_tests
.PHONY: conformance # Automatically fix problems that can be fixed
conformance: fmt
.PHONY: help # Generate list of targets with descriptions
help:
@grep '^\.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1\t\2/' | expand -t30 | sort

578
justfile Normal file
View File

@@ -0,0 +1,578 @@
SHELL := `/usr/bin/env which bash`
set shell := ["bash", "-c"]
default:
@just --list
OS := `uname`
RS_CHECK_TOOLCHAIN := `cat toolchain.txt | tr -d '\n'`
CARGO_RS_CHECK_TOOLCHAIN := "+" + RS_CHECK_TOOLCHAIN
TARGET_ARCH_FEATURE:=`./scripts/get_arch_feature.sh`
RS_BUILD_TOOLCHAIN := "stable"
CARGO_PROFILE := "release"
MIN_RUST_VERSION := `grep rust-version tfhe/Cargo.toml | cut -d '=' -f 2 | xargs`
AVX512_SUPPORT := "OFF"
WASM_RUSTFLAGS := ""
BIG_TESTS_INSTANCE := "FALSE"
GEN_KEY_CACHE_MULTI_BIT_ONLY := "FALSE"
PARSE_INTEGER_BENCH_CSV_FILE := "tfhe_rs_integer_benches.csv"
export FAST_TESTS := "FALSE"
export __TFHE_RS_FAST_BENCH := "FALSE"
export __TFHE_RS_BENCH_OP_FLAVOR := "DEFAULT"
# This is done to avoid forgetting it, we still precise the RUSTFLAGS in the commands to be able to
# copy paste the command in the terminal and change them if required without forgetting the flags
export RUSTFLAGS := "-C target-cpu=native"
CARGO := "cargo +" + RS_CHECK_TOOLCHAIN
CARGO_BUILD := CARGO + " build --profile " + CARGO_PROFILE + " "
CARGO_TEST := CARGO + " test --profile " + CARGO_PROFILE + " "
CARGO_RUN := CARGO + " run --profile " + CARGO_PROFILE + " "
CARGO_CHECK := CARGO + " check "
CARGO_CLIPPY := CARGO + " clippy "
CARGO_DOC := CARGO + " doc "
CARGO_FMT := CARGO + " fmt "
CARGO_BENCH := CARGO + " bench "
AVX512_FEATURE := if AVX512_SUPPORT == "ON" {
"nightly-avx512"
} else {
""
}
FEATURES := "--features=" + TARGET_ARCH_FEATURE + "," + AVX512_FEATURE + ","
MULTI_BIT_ONLY := if GEN_KEY_CACHE_MULTI_BIT_ONLY == "TRUE" {
"--multi-bit-only"
} else {
""
}
# Variables used only for regex_engine example
REGEX_STRING := ''
REGEX_PATTERN := ''
rs_check_toolchain:
@echo {{RS_CHECK_TOOLCHAIN}}
rs_build_toolchain:
@echo {{RS_BUILD_TOOLCHAIN}}
install_rs_check_toolchain:
@rustup toolchain list | grep -q "{{RS_CHECK_TOOLCHAIN}}" || \
rustup toolchain install --profile default "{{RS_CHECK_TOOLCHAIN}}" || \
( echo "Unable to install {{RS_CHECK_TOOLCHAIN}} toolchain, check your rustup installation. \
Rustup can be downloaded at https://rustup.rs/" && exit 1 )
install_rs_build_toolchain:
@( rustup toolchain list | grep -q "{{RS_BUILD_TOOLCHAIN}}" && \
./scripts/check_cargo_min_ver.sh \
--rust-toolchain "{{RS_BUILD_TOOLCHAIN}}" \
--min-rust-version "{{MIN_RUST_VERSION}}" ) || \
rustup toolchain install --profile default "{{RS_BUILD_TOOLCHAIN}}" || \
( echo "Unable to install {{RS_BUILD_TOOLCHAIN}} toolchain, check your rustup installation. \
Rustup can be downloaded at https://rustup.rs/" && exit 1 )
install_cargo_nextest: install_rs_build_toolchain
@cargo nextest --version > /dev/null 2>&1 || \
{{CARGO}} install cargo-nextest --locked || \
( echo "Unable to install cargo nextest, unknown error." && exit 1 )
install_wasm_pack: install_rs_build_toolchain
@wasm-pack --version > /dev/null 2>&1 || \
{{CARGO}} install wasm-pack || \
( echo "Unable to install cargo wasm-pack, unknown error." && exit 1 )
install_node:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | {{SHELL}}
source ~/.bashrc
{{SHELL}} -i -c 'nvm install node' || \
( echo "Unable to install node, unknown error." && exit 1 )
install_dieharder:
@dieharder -h > /dev/null 2>&1 || \
if [[ "{{OS}}" == "Linux" ]]; then \
sudo apt update && sudo apt install -y dieharder; \
elif [[ "{{OS}}" == "Darwin" ]]; then\
brew install dieharder; \
fi || ( echo "Unable to install dieharder, unknown error." && exit 1 )
fmt: install_rs_check_toolchain
{{CARGO_FMT}}
check_fmt:
{{CARGO_FMT}} --check
clippy_core: install_rs_check_toolchain
{{CARGO_CLIPPY}} {{FEATURES}} -p tfhe -- --no-deps -D warnings
{{CARGO_CLIPPY}} {{FEATURES}},experimental -p tfhe -- --no-deps -D warnings
clippy_boolean: install_rs_check_toolchain
{{CARGO_CLIPPY}} {{FEATURES}},boolean -p tfhe -- --no-deps -D warnings
clippy_shortint: install_rs_check_toolchain
{{CARGO_CLIPPY}} {{FEATURES}},shortint \
-p tfhe -- --no-deps -D warnings
clippy_integer: install_rs_check_toolchain
{{CARGO_CLIPPY}} {{FEATURES}},integer \
-p tfhe -- --no-deps -D warnings
clippy: install_rs_check_toolchain
{{CARGO_CLIPPY}} --all-targets \
{{FEATURES}},boolean,shortint,integer \
-p tfhe -- --no-deps -D warnings
clippy_c_api: install_rs_check_toolchain
{{CARGO_CLIPPY}} {{FEATURES}},boolean-c-api,shortint-c-api \
-p tfhe -- --no-deps -D warnings
clippy_js_wasm_api: install_rs_check_toolchain
{{CARGO_CLIPPY}} --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api \
-p tfhe -- --no-deps -D warnings
clippy_tasks:
{{CARGO_CLIPPY}} \
-p tasks -- --no-deps -D warnings
clippy_trivium: install_rs_check_toolchain
{{CARGO_CLIPPY}} -p tfhe-trivium \
{{FEATURES}},boolean,shortint,integer \
-p tfhe -- --no-deps -D warnings
clippy_all_targets:
{{CARGO_CLIPPY}} --all-targets \
{{FEATURES}},boolean,shortint,integer \
-p tfhe -- --no-deps -D warnings
clippy_concrete_csprng:
{{CARGO_CLIPPY}} --all-targets \
{{FEATURES}} \
-p concrete-csprng -- --no-deps -D warnings
clippy_all: clippy clippy_boolean clippy_shortint clippy_integer clippy_all_targets clippy_c_api clippy_js_wasm_api clippy_tasks clippy_core clippy_concrete_csprng clippy_trivium
clippy_fast: clippy clippy_all_targets clippy_c_api clippy_js_wasm_api clippy_tasks clippy_core clippy_concrete_csprng
gen_key_cache: install_rs_build_toolchain
{{CARGO_RUN}} \
--example generates_test_keys \
{{FEATURES}},shortint,internal-keycache -p tfhe -- \
{{MULTI_BIT_ONLY}}
build_core: install_rs_build_toolchain install_rs_check_toolchain
{{CARGO_BUILD}} \
{{FEATURES}} -p tfhe
@if [[ "{{AVX512_SUPPORT}}" == "ON" ]]; then \
{{CARGO_BUILD}} \
{{FEATURES}},{{AVX512_FEATURE}} -p tfhe; \
fi
build_core_experimental: install_rs_build_toolchain install_rs_check_toolchain
{{CARGO_BUILD}} \
{{FEATURES}},experimental -p tfhe
@if [[ "{{AVX512_SUPPORT}}" == "ON" ]]; then \
{{CARGO_BUILD}} \
{{FEATURES}},experimental,{{AVX512_FEATURE}} -p tfhe; \
fi
build_boolean: install_rs_build_toolchain
{{CARGO_BUILD}} \
{{FEATURES}},boolean -p tfhe --all-targets
build_shortint: install_rs_build_toolchain
{{CARGO_BUILD}} \
{{FEATURES}},shortint -p tfhe --all-targets
build_integer: install_rs_build_toolchain
{{CARGO_BUILD}} \
{{FEATURES}},integer -p tfhe --all-targets
build_tfhe_full: install_rs_build_toolchain
{{CARGO_BUILD}} \
{{FEATURES}},boolean,shortint,integer -p tfhe --all-targets
build_c_api: install_rs_check_toolchain
{{CARGO_BUILD}} \
{{FEATURES}},boolean-c-api,shortint-c-api,high-level-c-api, \
-p tfhe
build_c_api_experimental_deterministic_fft: install_rs_check_toolchain
{{CARGO_BUILD}} \
{{FEATURES}},boolean-c-api,shortint-c-api,high-level-c-api,experimental-force_fft_algo_dif4 \
-p tfhe
build_web_js_api: install_rs_build_toolchain install_wasm_pack
cd tfhe && \
RUSTFLAGS="{{WASM_RUSTFLAGS}}" rustup run "{{RS_BUILD_TOOLCHAIN}}" \
wasm-pack build --release --target=web \
-- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api
build_web_js_api_parallel: install_rs_check_toolchain install_wasm_pack
cd tfhe && \
rustup component add rust-src --toolchain {{RS_CHECK_TOOLCHAIN}} && \
RUSTFLAGS="{{WASM_RUSTFLAGS}} -C target-feature=+atomics,+bulk-memory,+mutable-globals" rustup run {{RS_CHECK_TOOLCHAIN}} \
wasm-pack build --release --target=web \
-- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,parallel-wasm-api \
-Z build-std=panic_abort,std
build_node_js_api: install_rs_build_toolchain install_wasm_pack
cd tfhe && \
RUSTFLAGS="{{WASM_RUSTFLAGS}}" rustup run "{{RS_BUILD_TOOLCHAIN}}" \
wasm-pack build --release --target=nodejs \
-- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api
build_concrete_csprng: install_rs_build_toolchain
{{CARGO_BUILD}} \
{{FEATURES}} -p concrete-csprng --all-targets
test_core_crypto: install_rs_build_toolchain install_rs_check_toolchain
{{CARGO_TEST}} \
{{FEATURES}},experimental -p tfhe -- core_crypto::
@if [[ "{{AVX512_SUPPORT}}" == "ON" ]]; then \
{{CARGO_TEST}} \
{{FEATURES}},experimental,{{AVX512_FEATURE}} -p tfhe -- core_crypto::; \
fi
test_boolean: install_rs_build_toolchain
{{CARGO_TEST}} \
{{FEATURES}},boolean -p tfhe -- boolean::
test_c_api_rs: install_rs_check_toolchain
{{CARGO_TEST}} \
{{FEATURES}},boolean-c-api,shortint-c-api,high-level-c-api \
-p tfhe \
c_api
test_c_api_c: build_c_api
./scripts/c_api_tests.sh
test_c_api: test_c_api_rs test_c_api_c
test_shortint_ci: install_rs_build_toolchain install_cargo_nextest
BIG_TESTS_INSTANCE="{{BIG_TESTS_INSTANCE}}" \
./scripts/shortint-tests.sh --rust-toolchain {{RS_BUILD_TOOLCHAIN}} \
--cargo-profile "{{CARGO_PROFILE}}"
test_shortint_multi_bit_ci: install_rs_build_toolchain install_cargo_nextest
BIG_TESTS_INSTANCE="{{BIG_TESTS_INSTANCE}}" \
./scripts/shortint-tests.sh --rust-toolchain {{RS_BUILD_TOOLCHAIN}} \
--cargo-profile "{{CARGO_PROFILE}}" --multi-bit
test_shortint: install_rs_build_toolchain
{{CARGO_TEST}} \
{{FEATURES}},shortint,internal-keycache -p tfhe -- shortint::
test_integer_ci: install_rs_build_toolchain install_cargo_nextest
BIG_TESTS_INSTANCE="{{BIG_TESTS_INSTANCE}}" \
./scripts/integer-tests.sh --rust-toolchain {{RS_BUILD_TOOLCHAIN}} \
--cargo-profile "{{CARGO_PROFILE}}"
test_integer_multi_bit_ci: install_rs_build_toolchain install_cargo_nextest
BIG_TESTS_INSTANCE="{{BIG_TESTS_INSTANCE}}" \
./scripts/integer-tests.sh --rust-toolchain {{RS_BUILD_TOOLCHAIN}} \
--cargo-profile "{{CARGO_PROFILE}}" --multi-bit
test_integer: install_rs_build_toolchain
{{CARGO_TEST}} \
{{FEATURES}},integer,internal-keycache -p tfhe -- integer::
test_high_level_api: install_rs_build_toolchain
{{CARGO_TEST}} \
{{FEATURES}},boolean,shortint,integer,internal-keycache -p tfhe \
-- high_level_api::
test_user_doc: install_rs_build_toolchain
{{CARGO_TEST}} --doc \
{{FEATURES}},boolean,shortint,integer,internal-keycache -p tfhe \
-- test_user_docs::
test_regex_engine: install_rs_build_toolchain
{{CARGO_TEST}} \
--example regex_engine \
{{FEATURES}},integer
test_sha256_bool: install_rs_build_toolchain
{{CARGO_TEST}} \
--example sha256_bool \
{{FEATURES}},boolean
test_examples: test_sha256_bool test_regex_engine
test_trivium: install_rs_build_toolchain
{{CARGO_TEST}} \
trivium {{FEATURES}},boolean,shortint,integer \
-- --test-threads=1
test_kreyvium: install_rs_build_toolchain
{{CARGO_TEST}} \
kreyvium {{FEATURES}},boolean,shortint,integer \
-- --test-threads=1
test_concrete_csprng:
{{CARGO_TEST}} \
{{FEATURES}} -p concrete-csprng
doc: install_rs_check_toolchain
RUSTDOCFLAGS="--html-in-header katex-header.html" \
{{CARGO_DOC}} \
{{FEATURES}},boolean,shortint,integer --no-deps
docs: doc
lint_doc: install_rs_check_toolchain
RUSTDOCFLAGS="--html-in-header katex-header.html -Dwarnings" \
{{CARGO_DOC}} \
{{FEATURES}},boolean,shortint,integer --no-deps
lint_docs: lint_doc
format_doc_latex:
cargo xtask format_latex_doc
@just --no-print-directory fmt
@printf "\n===============================\n\n"
@printf "Please manually inspect changes made by format_latex_doc, rustfmt can break equations \
if the line length is exceeded\n"
@printf "\n===============================\n"
check_compile_tests:
{{CARGO}} test --no-run \
{{FEATURES}},experimental,boolean,shortint,integer,internal-keycache \
-p tfhe
@if [[ "{{OS}}" == "Linux" || "{{OS}}" == "Darwin" ]]; then \
just build_c_api; \
./scripts/c_api_tests.sh --build-only; \
fi
build_nodejs_test_docker:
DOCKER_BUILDKIT=1 docker build --build-arg RUST_TOOLCHAIN="{{RS_BUILD_TOOLCHAIN}}" \
-f docker/Dockerfile.wasm_tests -t tfhe-wasm-tests .
test_nodejs_wasm_api_in_docker: build_nodejs_test_docker
if [[ -t 1 ]]; then RUN_FLAGS="-it"; else RUN_FLAGS="-i"; fi && \
docker run --rm "$${RUN_FLAGS}" \
-v "$$(pwd)":/tfhe-wasm-tests/tfhe-rs \
-v tfhe-rs-root-target-cache:/root/tfhe-rs-target \
-v tfhe-rs-pkg-cache:/tfhe-wasm-tests/tfhe-rs/tfhe/pkg \
-v tfhe-rs-root-cargo-registry-cache:/root/.cargo/registry \
-v tfhe-rs-root-cache:/root/.cache \
tfhe-wasm-tests /bin/bash -i -c 'make test_nodejs_wasm_api'
test_nodejs_wasm_api: build_node_js_api
cd tfhe && node --test js_on_wasm_tests
test_web_js_api_parallel: build_web_js_api_parallel
just -C tfhe/web_wasm_parallel_tests test
ci_test_web_js_api_parallel: build_web_js_api_parallel
source ~/.nvm/nvm.sh && \
nvm use node && \
just -C tfhe/web_wasm_parallel_tests test-ci
no_tfhe_typo:
@./scripts/no_tfhe_typo.sh
no_dbg_log:
@./scripts/no_dbg_calls.sh
dieharder_csprng: install_dieharder build_concrete_csprng
./scripts/dieharder_test.sh
#
# Benchmarks
#
bench_integer: install_rs_check_toolchain
{{CARGO_BENCH}} \
--bench integer-bench \
{{FEATURES}},integer,internal-keycache,{{AVX512_FEATURE}} -p tfhe --
bench_integer_multi_bit: install_rs_check_toolchain
__TFHE_RS_BENCH_TYPE=MULTI_BIT \
{{CARGO_BENCH}} \
--bench integer-bench \
{{FEATURES}},integer,internal-keycache,{{AVX512_FEATURE}} -p tfhe --
bench_shortint: install_rs_check_toolchain
{{CARGO_BENCH}} \
--bench shortint-bench \
{{FEATURES}},shortint,internal-keycache,{{AVX512_FEATURE}} -p tfhe
bench_shortint_multi_bit: install_rs_check_toolchain
__TFHE_RS_BENCH_TYPE=MULTI_BIT \
{{CARGO_BENCH}} \
--bench shortint-bench \
{{FEATURES}},shortint,internal-keycache,{{AVX512_FEATURE}} -p tfhe --
bench_boolean: install_rs_check_toolchain
{{CARGO_BENCH}} \
--bench boolean-bench \
{{FEATURES}},boolean,internal-keycache,{{AVX512_FEATURE}} -p tfhe
bench_pbs: install_rs_check_toolchain
{{CARGO_BENCH}} \
--bench pbs-bench \
{{FEATURES}},boolean,shortint,internal-keycache,{{AVX512_FEATURE}} -p tfhe
bench_web_js_api_parallel: build_web_js_api_parallel
just -C tfhe/web_wasm_parallel_tests bench
ci_bench_web_js_api_parallel: build_web_js_api_parallel
source ~/.nvm/nvm.sh && \
nvm use node && \
just -C tfhe/web_wasm_parallel_tests bench-ci
#
# Utility tools
#
measure_hlapi_compact_pk_ct_sizes: install_rs_check_toolchain
{{CARGO_RUN}} \
--example hlapi_compact_pk_ct_sizes \
{{FEATURES}},integer,internal-keycache
measure_shortint_key_sizes: install_rs_check_toolchain
{{CARGO_RUN}} \
--example shortint_key_sizes \
{{FEATURES}},shortint,internal-keycache
measure_boolean_key_sizes: install_rs_check_toolchain
{{CARGO_RUN}} \
--example boolean_key_sizes \
{{FEATURES}},boolean,internal-keycache
parse_integer_benches:
python3 ./ci/parse_integer_benches_to_csv.py \
--criterion-dir target/criterion \
--output-file "{{PARSE_INTEGER_BENCH_CSV_FILE}}"
parse_wasm_benchmarks: install_rs_check_toolchain
{{CARGO_RUN}} \
--example wasm_benchmarks_parser \
{{FEATURES}},shortint,internal-keycache \
-- web_wasm_parallel_tests/test/benchmark_results
write_params_to_file: install_rs_check_toolchain
{{CARGO_RUN}} \
--example write_params_to_file \
{{FEATURES}},boolean,shortint,internal-keycache
#
# Real use case examples
#
regex_engine: install_rs_check_toolchain
{{CARGO_RUN}} \
--example regex_engine \
{{FEATURES}},integer \
-- {{REGEX_STRING}} {{REGEX_PATTERN}}
dark_market: install_rs_check_toolchain
{{CARGO_RUN}} \
--example dark_market \
{{FEATURES}},integer,internal-keycache \
-- fhe-modified fhe-parallel plain fhe
sha256_bool: install_rs_check_toolchain
{{CARGO_RUN}} \
--example sha256_bool \
{{FEATURES}},boolean
pcc: no_tfhe_typo no_dbg_log check_fmt lint_doc clippy_all check_compile_tests
fpcc: no_tfhe_typo no_dbg_log check_fmt lint_doc clippy_fast check_compile_tests
conformance: fmt