mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-11 15:48:20 -05:00
Compare commits
97 Commits
tmp_ccs
...
mz/refacto
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e6adab801 | ||
|
|
6df31476e9 | ||
|
|
40205d46e1 | ||
|
|
a1cea9496a | ||
|
|
abd4274b09 | ||
|
|
55775b8e02 | ||
|
|
523d561de6 | ||
|
|
61a50d0bcc | ||
|
|
ee57f5658b | ||
|
|
9362965f50 | ||
|
|
00fb60451d | ||
|
|
18b9fd4464 | ||
|
|
eace0bfb85 | ||
|
|
af1be5ebca | ||
|
|
916bd8a09f | ||
|
|
20cb0642ce | ||
|
|
151f9f6d82 | ||
|
|
8db8cb49e4 | ||
|
|
b4583976a2 | ||
|
|
b450375da1 | ||
|
|
f02f1fb297 | ||
|
|
17642fa703 | ||
|
|
23fa9b24bd | ||
|
|
0453b9bd60 | ||
|
|
9b2cf67911 | ||
|
|
36a7656048 | ||
|
|
61c8eadd58 | ||
|
|
fdd4d9d1cc | ||
|
|
62700ab853 | ||
|
|
27445645e7 | ||
|
|
ea0cd26c0b | ||
|
|
ff48582679 | ||
|
|
a77c87ff12 | ||
|
|
6d143f1edc | ||
|
|
216e6b443a | ||
|
|
1400ae946c | ||
|
|
c332902a05 | ||
|
|
cf7a7f132d | ||
|
|
6e0a3b9ad7 | ||
|
|
1f825dde08 | ||
|
|
f9222de47c | ||
|
|
5732e8dd7a | ||
|
|
9db35c5474 | ||
|
|
b69f73e8e6 | ||
|
|
90bdf75147 | ||
|
|
233ea17adf | ||
|
|
df6ee79841 | ||
|
|
6497fb9a15 | ||
|
|
d8894e3b69 | ||
|
|
42636bab13 | ||
|
|
ec27d3dc6f | ||
|
|
5272c95de4 | ||
|
|
27d7ace3ef | ||
|
|
d80ab231a8 | ||
|
|
fe3fa531f9 | ||
|
|
5c1573c266 | ||
|
|
7772e8112d | ||
|
|
5e92cb1475 | ||
|
|
f51e19b071 | ||
|
|
aeb00ae584 | ||
|
|
ce5e9c1bdb | ||
|
|
4d4e124e94 | ||
|
|
ca6d37e06f | ||
|
|
e3143315f3 | ||
|
|
f8636fe814 | ||
|
|
7e72400321 | ||
|
|
728b409256 | ||
|
|
d91404e567 | ||
|
|
e11c3d7b7c | ||
|
|
6f8eeb043c | ||
|
|
00d55182b4 | ||
|
|
6f6ce106c3 | ||
|
|
68fcbb5280 | ||
|
|
3f46389cc8 | ||
|
|
9e8dd01cb9 | ||
|
|
0085ceb97b | ||
|
|
be9a4d2d9c | ||
|
|
87421e8307 | ||
|
|
0c3919628f | ||
|
|
f1c21888a7 | ||
|
|
2624beb7fa | ||
|
|
e44c38a102 | ||
|
|
4535230874 | ||
|
|
a7b2d9b228 | ||
|
|
ab923a3ebc | ||
|
|
a0e85fb355 | ||
|
|
ecee305340 | ||
|
|
f08ea8cf85 | ||
|
|
096e320b97 | ||
|
|
95aac64c1c | ||
|
|
76aaa56691 | ||
|
|
a40489bdd2 | ||
|
|
4bf617eb10 | ||
|
|
070073d229 | ||
|
|
6c1ca8e32b | ||
|
|
6523610ca4 | ||
|
|
41c20e22f5 |
4
.github/workflows/aws_tfhe_fast_tests.yml
vendored
4
.github/workflows/aws_tfhe_fast_tests.yml
vendored
@@ -51,7 +51,7 @@ jobs:
|
||||
echo "Fork git sha: ${{ inputs.fork_git_sha }}"
|
||||
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: ${{ inputs.fork_repo }}
|
||||
ref: ${{ inputs.fork_git_sha }}
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
|
||||
- name: Run user docs tests
|
||||
run: |
|
||||
make test_user_doc
|
||||
CARGO_PROFILE=release_lto_off make test_user_doc
|
||||
|
||||
- name: Run js on wasm API tests
|
||||
run: |
|
||||
|
||||
22
.github/workflows/aws_tfhe_integer_tests.yml
vendored
22
.github/workflows/aws_tfhe_integer_tests.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: AWS Integer Tests on CPU
|
||||
name: AWS Unsigned Integer Tests on CPU
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
@@ -23,13 +23,13 @@ on:
|
||||
description: "Action runner name"
|
||||
type: string
|
||||
request_id:
|
||||
description: 'Slab request ID'
|
||||
description: "Slab request ID"
|
||||
type: string
|
||||
fork_repo:
|
||||
description: 'Name of forked repo as user/repo'
|
||||
description: "Name of forked repo as user/repo"
|
||||
type: string
|
||||
fork_git_sha:
|
||||
description: 'Git SHA to checkout from fork'
|
||||
description: "Git SHA to checkout from fork"
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
echo "Fork git sha: ${{ inputs.fork_git_sha }}"
|
||||
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: ${{ inputs.fork_repo }}
|
||||
ref: ${{ inputs.fork_git_sha }}
|
||||
@@ -65,13 +65,21 @@ jobs:
|
||||
toolchain: stable
|
||||
default: true
|
||||
|
||||
- name: Gen Keys if required
|
||||
run: |
|
||||
make GEN_KEY_CACHE_MULTI_BIT_ONLY=TRUE gen_key_cache
|
||||
|
||||
- name: Run unsigned integer multi-bit tests
|
||||
run: |
|
||||
AVX512_SUPPORT=ON make test_unsigned_integer_multi_bit_ci
|
||||
|
||||
- name: Gen Keys if required
|
||||
run: |
|
||||
make gen_key_cache
|
||||
|
||||
- name: Run integer tests
|
||||
- name: Run unsigned integer tests
|
||||
run: |
|
||||
BIG_TESTS_INSTANCE=TRUE make test_integer_ci
|
||||
AVX512_SUPPORT=ON BIG_TESTS_INSTANCE=TRUE make test_unsigned_integer_ci
|
||||
|
||||
- name: Slack Notification
|
||||
if: ${{ always() }}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: AWS Multi Bit Tests on CPU
|
||||
name: AWS Signed Integer Tests on CPU
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
@@ -23,13 +23,13 @@ on:
|
||||
description: "Action runner name"
|
||||
type: string
|
||||
request_id:
|
||||
description: 'Slab request ID'
|
||||
description: "Slab request ID"
|
||||
type: string
|
||||
fork_repo:
|
||||
description: 'Name of forked repo as user/repo'
|
||||
description: "Name of forked repo as user/repo"
|
||||
type: string
|
||||
fork_git_sha:
|
||||
description: 'Git SHA to checkout from fork'
|
||||
description: "Git SHA to checkout from fork"
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
echo "Fork git sha: ${{ inputs.fork_git_sha }}"
|
||||
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: ${{ inputs.fork_repo }}
|
||||
ref: ${{ inputs.fork_git_sha }}
|
||||
@@ -73,9 +73,17 @@ jobs:
|
||||
run: |
|
||||
make test_shortint_multi_bit_ci
|
||||
|
||||
- name: Run integer multi-bit tests
|
||||
- name: Run signed integer multi-bit tests
|
||||
run: |
|
||||
make test_integer_multi_bit_ci
|
||||
AVX512_SUPPORT=ON make test_signed_integer_multi_bit_ci
|
||||
|
||||
- name: Gen Keys if required
|
||||
run: |
|
||||
make gen_key_cache
|
||||
|
||||
- name: Run signed integer tests
|
||||
run: |
|
||||
AVX512_SUPPORT=ON BIG_TESTS_INSTANCE=TRUE make test_signed_integer_ci
|
||||
|
||||
- name: Slack Notification
|
||||
if: ${{ always() }}
|
||||
10
.github/workflows/aws_tfhe_tests.yml
vendored
10
.github/workflows/aws_tfhe_tests.yml
vendored
@@ -50,7 +50,7 @@ jobs:
|
||||
echo "Fork git sha: ${{ inputs.fork_git_sha }}"
|
||||
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: ${{ inputs.fork_repo }}
|
||||
ref: ${{ inputs.fork_git_sha }}
|
||||
@@ -83,7 +83,7 @@ jobs:
|
||||
|
||||
- name: Run user docs tests
|
||||
run: |
|
||||
make test_user_doc
|
||||
CARGO_PROFILE=release_lto_off make test_user_doc
|
||||
|
||||
- name: Gen Keys if required
|
||||
run: |
|
||||
@@ -100,6 +100,12 @@ jobs:
|
||||
- name: Run example tests
|
||||
run: |
|
||||
make test_examples
|
||||
make dark_market
|
||||
|
||||
- name: Run apps tests
|
||||
run: |
|
||||
make test_trivium
|
||||
make test_kreyvium
|
||||
|
||||
- name: Slack Notification
|
||||
if: ${{ always() }}
|
||||
|
||||
2
.github/workflows/aws_tfhe_wasm_tests.yml
vendored
2
.github/workflows/aws_tfhe_wasm_tests.yml
vendored
@@ -50,7 +50,7 @@ jobs:
|
||||
echo "Fork git sha: ${{ inputs.fork_git_sha }}"
|
||||
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: ${{ inputs.fork_repo }}
|
||||
ref: ${{ inputs.fork_git_sha }}
|
||||
|
||||
4
.github/workflows/boolean_benchmark.yml
vendored
4
.github/workflows/boolean_benchmark.yml
vendored
@@ -51,7 +51,7 @@ jobs:
|
||||
echo "BENCH_DATE=$(date --iso-8601=seconds)" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -102,7 +102,7 @@ jobs:
|
||||
path: ${{ env.RESULTS_FILENAME }}
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
|
||||
2
.github/workflows/cargo_build.yml
vendored
2
.github/workflows/cargo_build.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
|
||||
- name: Install and run newline linter checks
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
|
||||
4
.github/workflows/code_coverage.yml
vendored
4
.github/workflows/code_coverage.yml
vendored
@@ -50,7 +50,7 @@ jobs:
|
||||
echo "Fork git sha: ${{ inputs.fork_git_sha }}"
|
||||
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: ${{ inputs.fork_repo }}
|
||||
ref: ${{ inputs.fork_git_sha }}
|
||||
@@ -67,7 +67,7 @@ jobs:
|
||||
|
||||
- name: Check for file changes
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@408093d9ff9c134c33b974e0722ce06b9d6e8263
|
||||
uses: tj-actions/changed-files@25ef3926d147cd02fc7e931c1ef50772bbb0d25d
|
||||
with:
|
||||
files_yaml: |
|
||||
tfhe:
|
||||
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: ${{ inputs.fork_repo }}
|
||||
ref: ${{ inputs.fork_git_sha }}
|
||||
|
||||
4
.github/workflows/integer_benchmark.yml
vendored
4
.github/workflows/integer_benchmark.yml
vendored
@@ -44,7 +44,7 @@ jobs:
|
||||
echo "BENCH_DATE=$(date --iso-8601=seconds)" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
path: ${{ env.RESULTS_FILENAME }}
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
|
||||
4
.github/workflows/integer_full_benchmark.yml
vendored
4
.github/workflows/integer_full_benchmark.yml
vendored
@@ -74,7 +74,7 @@ jobs:
|
||||
echo "Request ID: ${{ inputs.request_id }}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
override: true
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
echo "BENCH_DATE=$(date --iso-8601=seconds)" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
path: ${{ env.RESULTS_FILENAME }}
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
|
||||
12
.github/workflows/m1_tests.yml
vendored
12
.github/workflows/m1_tests.yml
vendored
@@ -15,7 +15,6 @@ env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUSTFLAGS: "-C target-cpu=native"
|
||||
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
CARGO_PROFILE: release_lto_off
|
||||
FAST_TESTS: "TRUE"
|
||||
|
||||
concurrency:
|
||||
@@ -28,7 +27,7 @@ jobs:
|
||||
runs-on: ["self-hosted", "m1mac"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
|
||||
- name: Install latest stable
|
||||
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
|
||||
@@ -86,7 +85,7 @@ jobs:
|
||||
|
||||
- name: Run user docs tests
|
||||
run: |
|
||||
make test_user_doc
|
||||
CARGO_PROFILE=release_lto_off make 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.
|
||||
@@ -111,10 +110,9 @@ jobs:
|
||||
run: |
|
||||
make 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
|
||||
- name: Run integer multi bit tests
|
||||
run: |
|
||||
make test_integer_multi_bit_ci
|
||||
|
||||
remove_label:
|
||||
name: Remove m1_test label
|
||||
|
||||
6
.github/workflows/make_release.yml
vendored
6
.github/workflows/make_release.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
|
||||
- name: Publish web package
|
||||
if: ${{ inputs.push_web_package }}
|
||||
uses: JS-DevTools/npm-publish@fe72237be0920f7a0cafd6a966c9b929c9466e9b
|
||||
uses: JS-DevTools/npm-publish@4b07b26a2f6e0a51846e1870223e545bae91c552
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
package: tfhe/pkg/package.json
|
||||
@@ -65,7 +65,7 @@ jobs:
|
||||
|
||||
- name: Publish Node package
|
||||
if: ${{ inputs.push_node_package }}
|
||||
uses: JS-DevTools/npm-publish@fe72237be0920f7a0cafd6a966c9b929c9466e9b
|
||||
uses: JS-DevTools/npm-publish@4b07b26a2f6e0a51846e1870223e545bae91c552
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
package: tfhe/pkg/package.json
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
4
.github/workflows/parameters_check.yml
vendored
4
.github/workflows/parameters_check.yml
vendored
@@ -17,10 +17,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
|
||||
- name: Checkout lattice-estimator
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: malb/lattice-estimator
|
||||
path: lattice_estimator
|
||||
|
||||
4
.github/workflows/pbs_benchmark.yml
vendored
4
.github/workflows/pbs_benchmark.yml
vendored
@@ -51,7 +51,7 @@ jobs:
|
||||
echo "BENCH_DATE=$(date --iso-8601=seconds)" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -92,7 +92,7 @@ jobs:
|
||||
path: ${{ env.RESULTS_FILENAME }}
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
|
||||
4
.github/workflows/shortint_benchmark.yml
vendored
4
.github/workflows/shortint_benchmark.yml
vendored
@@ -43,7 +43,7 @@ jobs:
|
||||
echo "BENCH_DATE=$(date --iso-8601=seconds)" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -94,7 +94,7 @@ jobs:
|
||||
path: ${{ env.RESULTS_FILENAME }}
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
echo "Request ID: ${{ inputs.request_id }}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -73,7 +73,7 @@ jobs:
|
||||
override: true
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
|
||||
129
.github/workflows/signed_integer_benchmark.yml
vendored
Normal file
129
.github/workflows/signed_integer_benchmark.yml
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
# Run signed integer benchmarks on an AWS instance and return parsed results to Slab CI bot.
|
||||
name: Signed Integer benchmarks
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
instance_id:
|
||||
description: "Instance ID"
|
||||
type: string
|
||||
instance_image_id:
|
||||
description: "Instance AMI ID"
|
||||
type: string
|
||||
instance_type:
|
||||
description: "Instance product type"
|
||||
type: string
|
||||
runner_name:
|
||||
description: "Action runner name"
|
||||
type: string
|
||||
request_id:
|
||||
description: "Slab request ID"
|
||||
type: string
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RESULTS_FILENAME: parsed_benchmark_results_${{ github.sha }}.json
|
||||
PARSE_INTEGER_BENCH_CSV_FILE: tfhe_rs_integer_benches_${{ github.sha }}.csv
|
||||
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
|
||||
jobs:
|
||||
run-integer-benchmarks:
|
||||
name: Execute signed integer benchmarks in EC2
|
||||
runs-on: ${{ github.event.inputs.runner_name }}
|
||||
if: ${{ !cancelled() }}
|
||||
steps:
|
||||
- name: Instance configuration used
|
||||
run: |
|
||||
echo "IDs: ${{ inputs.instance_id }}"
|
||||
echo "AMI: ${{ inputs.instance_image_id }}"
|
||||
echo "Type: ${{ inputs.instance_type }}"
|
||||
echo "Request ID: ${{ inputs.request_id }}"
|
||||
|
||||
- name: Get benchmark date
|
||||
run: |
|
||||
echo "BENCH_DATE=$(date --iso-8601=seconds)" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up home
|
||||
# "Install rust" step require root user to have a HOME directory which is not set.
|
||||
run: |
|
||||
echo "HOME=/home/ubuntu" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Install rust
|
||||
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
|
||||
- name: Run benchmarks with AVX512
|
||||
run: |
|
||||
make AVX512_SUPPORT=ON FAST_BENCH=TRUE bench_signed_integer
|
||||
|
||||
- name: Parse benchmarks to csv
|
||||
run: |
|
||||
make PARSE_INTEGER_BENCH_CSV_FILE=${{ env.PARSE_INTEGER_BENCH_CSV_FILE }} \
|
||||
parse_integer_benches
|
||||
|
||||
- name: Upload csv results artifact
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
|
||||
with:
|
||||
name: ${{ github.sha }}_csv_integer
|
||||
path: ${{ env.PARSE_INTEGER_BENCH_CSV_FILE }}
|
||||
|
||||
- name: Parse results
|
||||
run: |
|
||||
COMMIT_DATE="$(git --no-pager show -s --format=%cd --date=iso8601-strict ${{ github.sha }})"
|
||||
COMMIT_HASH="$(git describe --tags --dirty)"
|
||||
python3 ./ci/benchmark_parser.py target/criterion ${{ env.RESULTS_FILENAME }} \
|
||||
--database tfhe_rs \
|
||||
--hardware ${{ inputs.instance_type }} \
|
||||
--project-version "${COMMIT_HASH}" \
|
||||
--branch ${{ github.ref_name }} \
|
||||
--commit-date "${COMMIT_DATE}" \
|
||||
--bench-date "${{ env.BENCH_DATE }}" \
|
||||
--walk-subdirs \
|
||||
--name-suffix avx512 \
|
||||
--throughput
|
||||
|
||||
- name: Upload parsed results artifact
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
|
||||
with:
|
||||
name: ${{ github.sha }}_integer
|
||||
path: ${{ env.RESULTS_FILENAME }}
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
token: ${{ secrets.CONCRETE_ACTIONS_TOKEN }}
|
||||
|
||||
- name: Send data to Slab
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Computing HMac on results file"
|
||||
SIGNATURE="$(slab/scripts/hmac_calculator.sh ${{ env.RESULTS_FILENAME }} '${{ secrets.JOB_SECRET }}')"
|
||||
echo "Sending results to Slab..."
|
||||
curl -v -k \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-Slab-Repository: ${{ github.repository }}" \
|
||||
-H "X-Slab-Command: store_data_v2" \
|
||||
-H "X-Hub-Signature-256: sha256=${SIGNATURE}" \
|
||||
-d @${{ env.RESULTS_FILENAME }} \
|
||||
${{ secrets.SLAB_URL }}
|
||||
|
||||
- name: Slack Notification
|
||||
if: ${{ failure() }}
|
||||
continue-on-error: true
|
||||
uses: rtCamp/action-slack-notify@b24d75fe0e728a4bf9fc42ee217caa686d141ee8
|
||||
env:
|
||||
SLACK_COLOR: ${{ job.status }}
|
||||
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
|
||||
SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png
|
||||
SLACK_MESSAGE: "Signed integer benchmarks failed. (${{ env.ACTION_RUN_URL }})"
|
||||
SLACK_USERNAME: ${{ secrets.BOT_USERNAME }}
|
||||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
||||
133
.github/workflows/signed_integer_full_benchmark.yml
vendored
Normal file
133
.github/workflows/signed_integer_full_benchmark.yml
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
# Run all signed integer benchmarks on an AWS instance and return parsed results to Slab CI bot.
|
||||
name: Signed Integer full benchmarks
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
instance_id:
|
||||
description: "Instance ID"
|
||||
type: string
|
||||
instance_image_id:
|
||||
description: "Instance AMI ID"
|
||||
type: string
|
||||
instance_type:
|
||||
description: "Instance product type"
|
||||
type: string
|
||||
runner_name:
|
||||
description: "Action runner name"
|
||||
type: string
|
||||
request_id:
|
||||
description: "Slab request ID"
|
||||
type: string
|
||||
user_inputs:
|
||||
description: "Type of benchmarks to run"
|
||||
type: string
|
||||
default: "weekly_benchmarks"
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RESULTS_FILENAME: parsed_benchmark_results_${{ github.sha }}.json
|
||||
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
|
||||
jobs:
|
||||
integer-benchmarks:
|
||||
name: Execute signed integer benchmarks for all operations flavor
|
||||
runs-on: ${{ github.event.inputs.runner_name }}
|
||||
if: ${{ !cancelled() }}
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
max-parallel: 1
|
||||
matrix:
|
||||
command: [ integer, integer_multi_bit ]
|
||||
op_flavor: [ default, default_comp, default_scalar, default_scalar_comp,
|
||||
unchecked, unchecked_comp, unchecked_scalar, unchecked_scalar_comp ]
|
||||
steps:
|
||||
- name: Instance configuration used
|
||||
run: |
|
||||
echo "IDs: ${{ inputs.instance_id }}"
|
||||
echo "AMI: ${{ inputs.instance_image_id }}"
|
||||
echo "Type: ${{ inputs.instance_type }}"
|
||||
echo "Request ID: ${{ inputs.request_id }}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get benchmark details
|
||||
run: |
|
||||
echo "BENCH_DATE=$(date --iso-8601=seconds)" >> "${GITHUB_ENV}"
|
||||
echo "COMMIT_DATE=$(git --no-pager show -s --format=%cd --date=iso8601-strict ${{ github.sha }})" >> "${GITHUB_ENV}"
|
||||
echo "COMMIT_HASH=$(git describe --tags --dirty)" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Set up home
|
||||
# "Install rust" step require root user to have a HOME directory which is not set.
|
||||
run: |
|
||||
echo "HOME=/home/ubuntu" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Install rust
|
||||
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
token: ${{ secrets.CONCRETE_ACTIONS_TOKEN }}
|
||||
|
||||
- name: Run benchmarks with AVX512
|
||||
run: |
|
||||
make AVX512_SUPPORT=ON BENCH_OP_FLAVOR=${{ matrix.op_flavor }} bench_signed_${{ matrix.command }}
|
||||
|
||||
- name: Parse results
|
||||
run: |
|
||||
python3 ./ci/benchmark_parser.py target/criterion ${{ env.RESULTS_FILENAME }} \
|
||||
--database tfhe_rs \
|
||||
--hardware ${{ inputs.instance_type }} \
|
||||
--project-version "${{ env.COMMIT_HASH }}" \
|
||||
--branch ${{ github.ref_name }} \
|
||||
--commit-date "${{ env.COMMIT_DATE }}" \
|
||||
--bench-date "${{ env.BENCH_DATE }}" \
|
||||
--walk-subdirs \
|
||||
--name-suffix avx512 \
|
||||
--throughput
|
||||
|
||||
- name: Upload parsed results artifact
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
|
||||
with:
|
||||
name: ${{ github.sha }}_${{ matrix.command }}_${{ matrix.op_flavor }}
|
||||
path: ${{ env.RESULTS_FILENAME }}
|
||||
|
||||
- name: Send data to Slab
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Computing HMac on results file"
|
||||
SIGNATURE="$(slab/scripts/hmac_calculator.sh ${{ env.RESULTS_FILENAME }} '${{ secrets.JOB_SECRET }}')"
|
||||
echo "Sending results to Slab..."
|
||||
curl -v -k \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-Slab-Repository: ${{ github.repository }}" \
|
||||
-H "X-Slab-Command: store_data_v2" \
|
||||
-H "X-Hub-Signature-256: sha256=${SIGNATURE}" \
|
||||
-d @${{ env.RESULTS_FILENAME }} \
|
||||
${{ secrets.SLAB_URL }}
|
||||
|
||||
slack-notification:
|
||||
name: Slack Notification
|
||||
runs-on: ${{ github.event.inputs.runner_name }}
|
||||
if: ${{ failure() }}
|
||||
needs: integer-benchmarks
|
||||
steps:
|
||||
- name: Notify
|
||||
continue-on-error: true
|
||||
uses: rtCamp/action-slack-notify@b24d75fe0e728a4bf9fc42ee217caa686d141ee8
|
||||
env:
|
||||
SLACK_COLOR: ${{ job.status }}
|
||||
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
|
||||
SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png
|
||||
SLACK_MESSAGE: "Signed integer full benchmarks failed. (${{ env.ACTION_RUN_URL }})"
|
||||
SLACK_USERNAME: ${{ secrets.BOT_USERNAME }}
|
||||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
||||
129
.github/workflows/signed_integer_multi_bit_benchmark.yml
vendored
Normal file
129
.github/workflows/signed_integer_multi_bit_benchmark.yml
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
# Run signed integer benchmarks with multi-bit cryptographic parameters on an AWS instance and return parsed results to Slab CI bot.
|
||||
name: Signed Integer Multi-bit benchmarks
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
instance_id:
|
||||
description: "Instance ID"
|
||||
type: string
|
||||
instance_image_id:
|
||||
description: "Instance AMI ID"
|
||||
type: string
|
||||
instance_type:
|
||||
description: "Instance product type"
|
||||
type: string
|
||||
runner_name:
|
||||
description: "Action runner name"
|
||||
type: string
|
||||
request_id:
|
||||
description: "Slab request ID"
|
||||
type: string
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RESULTS_FILENAME: parsed_benchmark_results_${{ github.sha }}.json
|
||||
PARSE_INTEGER_BENCH_CSV_FILE: tfhe_rs_integer_benches_${{ github.sha }}.csv
|
||||
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
|
||||
jobs:
|
||||
run-integer-benchmarks:
|
||||
name: Execute signed integer multi-bit benchmarks in EC2
|
||||
runs-on: ${{ github.event.inputs.runner_name }}
|
||||
if: ${{ !cancelled() }}
|
||||
steps:
|
||||
- name: Instance configuration used
|
||||
run: |
|
||||
echo "IDs: ${{ inputs.instance_id }}"
|
||||
echo "AMI: ${{ inputs.instance_image_id }}"
|
||||
echo "Type: ${{ inputs.instance_type }}"
|
||||
echo "Request ID: ${{ inputs.request_id }}"
|
||||
|
||||
- name: Get benchmark date
|
||||
run: |
|
||||
echo "BENCH_DATE=$(date --iso-8601=seconds)" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up home
|
||||
# "Install rust" step require root user to have a HOME directory which is not set.
|
||||
run: |
|
||||
echo "HOME=/home/ubuntu" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Install rust
|
||||
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
|
||||
- name: Run multi-bit benchmarks with AVX512
|
||||
run: |
|
||||
make AVX512_SUPPORT=ON FAST_BENCH=TRUE bench_signed_integer_multi_bit
|
||||
|
||||
- name: Parse benchmarks to csv
|
||||
run: |
|
||||
make PARSE_INTEGER_BENCH_CSV_FILE=${{ env.PARSE_INTEGER_BENCH_CSV_FILE }} \
|
||||
parse_integer_benches
|
||||
|
||||
- name: Upload csv results artifact
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
|
||||
with:
|
||||
name: ${{ github.sha }}_csv_integer
|
||||
path: ${{ env.PARSE_INTEGER_BENCH_CSV_FILE }}
|
||||
|
||||
- name: Parse results
|
||||
run: |
|
||||
COMMIT_DATE="$(git --no-pager show -s --format=%cd --date=iso8601-strict ${{ github.sha }})"
|
||||
COMMIT_HASH="$(git describe --tags --dirty)"
|
||||
python3 ./ci/benchmark_parser.py target/criterion ${{ env.RESULTS_FILENAME }} \
|
||||
--database tfhe_rs \
|
||||
--hardware ${{ inputs.instance_type }} \
|
||||
--project-version "${COMMIT_HASH}" \
|
||||
--branch ${{ github.ref_name }} \
|
||||
--commit-date "${COMMIT_DATE}" \
|
||||
--bench-date "${{ env.BENCH_DATE }}" \
|
||||
--walk-subdirs \
|
||||
--name-suffix avx512 \
|
||||
--throughput
|
||||
|
||||
- name: Upload parsed results artifact
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
|
||||
with:
|
||||
name: ${{ github.sha }}_integer
|
||||
path: ${{ env.RESULTS_FILENAME }}
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
token: ${{ secrets.CONCRETE_ACTIONS_TOKEN }}
|
||||
|
||||
- name: Send data to Slab
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Computing HMac on results file"
|
||||
SIGNATURE="$(slab/scripts/hmac_calculator.sh ${{ env.RESULTS_FILENAME }} '${{ secrets.JOB_SECRET }}')"
|
||||
echo "Sending results to Slab..."
|
||||
curl -v -k \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-Slab-Repository: ${{ github.repository }}" \
|
||||
-H "X-Slab-Command: store_data_v2" \
|
||||
-H "X-Hub-Signature-256: sha256=${SIGNATURE}" \
|
||||
-d @${{ env.RESULTS_FILENAME }} \
|
||||
${{ secrets.SLAB_URL }}
|
||||
|
||||
- name: Slack Notification
|
||||
if: ${{ failure() }}
|
||||
continue-on-error: true
|
||||
uses: rtCamp/action-slack-notify@b24d75fe0e728a4bf9fc42ee217caa686d141ee8
|
||||
env:
|
||||
SLACK_COLOR: ${{ job.status }}
|
||||
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
|
||||
SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png
|
||||
SLACK_MESSAGE: "Signed integer benchmarks failed. (${{ env.ACTION_RUN_URL }})"
|
||||
SLACK_USERNAME: ${{ secrets.BOT_USERNAME }}
|
||||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
||||
35
.github/workflows/start_benchmarks.yml
vendored
35
.github/workflows/start_benchmarks.yml
vendored
@@ -20,10 +20,18 @@ on:
|
||||
description: "Run integer benches"
|
||||
type: boolean
|
||||
default: true
|
||||
signed_integer_bench:
|
||||
description: "Run signed integer benches"
|
||||
type: boolean
|
||||
default: true
|
||||
integer_multi_bit_bench:
|
||||
description: "Run integer multi bit benches"
|
||||
type: boolean
|
||||
default: true
|
||||
signed_integer_multi_bit_bench:
|
||||
description: "Run signed integer multi bit benches"
|
||||
type: boolean
|
||||
default: true
|
||||
pbs_bench:
|
||||
description: "Run PBS benches"
|
||||
type: boolean
|
||||
@@ -38,17 +46,20 @@ jobs:
|
||||
if: ${{ (github.event_name == 'push' && github.repository == 'zama-ai/tfhe-rs') || github.event_name == 'workflow_dispatch' }}
|
||||
strategy:
|
||||
matrix:
|
||||
command: [boolean_bench, shortint_bench, integer_bench, integer_multi_bit_bench, pbs_bench, wasm_client_bench]
|
||||
command: [ boolean_bench, shortint_bench,
|
||||
integer_bench, integer_multi_bit_bench,
|
||||
signed_integer_bench, signed_integer_multi_bit_bench,
|
||||
pbs_bench, wasm_client_bench ]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check for file changes
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@408093d9ff9c134c33b974e0722ce06b9d6e8263
|
||||
uses: tj-actions/changed-files@25ef3926d147cd02fc7e931c1ef50772bbb0d25d
|
||||
with:
|
||||
files_yaml: |
|
||||
common_benches:
|
||||
@@ -69,13 +80,23 @@ jobs:
|
||||
integer_bench:
|
||||
- tfhe/src/shortint/**
|
||||
- tfhe/src/integer/**
|
||||
- tfhe/benches/integer/**
|
||||
- tfhe/benches/integer/bench.rs
|
||||
- .github/workflows/integer_benchmark.yml
|
||||
integer_multi_bit_bench:
|
||||
- tfhe/src/shortint/**
|
||||
- tfhe/src/integer/**
|
||||
- tfhe/benches/integer/**
|
||||
- .github/workflows/integer_benchmark.yml
|
||||
- tfhe/benches/integer/bench.rs
|
||||
- .github/workflows/integer_multi_bit_benchmark.yml
|
||||
signed_integer_bench:
|
||||
- tfhe/src/shortint/**
|
||||
- tfhe/src/integer/**
|
||||
- tfhe/benches/integer/signed_bench.rs
|
||||
- .github/workflows/signed_integer_benchmark.yml
|
||||
signed_integer_multi_bit_bench:
|
||||
- tfhe/src/shortint/**
|
||||
- tfhe/src/integer/**
|
||||
- tfhe/benches/integer/signed_bench.rs
|
||||
- .github/workflows/signed_integer_multi_bit_benchmark.yml
|
||||
pbs_bench:
|
||||
- tfhe/src/core_crypto/**
|
||||
- tfhe/benches/core_crypto/**
|
||||
@@ -85,7 +106,7 @@ jobs:
|
||||
- .github/workflows/wasm_client_benchmark.yml
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
|
||||
7
.github/workflows/start_full_benchmarks.yml
vendored
7
.github/workflows/start_full_benchmarks.yml
vendored
@@ -24,16 +24,17 @@ jobs:
|
||||
if: ${{ (github.event_name == 'schedule' && github.repository == 'zama-ai/tfhe-rs') || github.event_name == 'workflow_dispatch' }}
|
||||
strategy:
|
||||
matrix:
|
||||
command: [ boolean_bench, shortint_full_bench, integer_full_bench, pbs_bench, wasm_client_bench ]
|
||||
command: [ boolean_bench, shortint_full_bench, integer_full_bench,
|
||||
signed_integer_full_bench, pbs_bench, wasm_client_bench ]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
|
||||
2
.github/workflows/sync_on_push.yml
vendored
2
.github/workflows/sync_on_push.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Save repo
|
||||
|
||||
4
.github/workflows/wasm_client_benchmark.yml
vendored
4
.github/workflows/wasm_client_benchmark.yml
vendored
@@ -51,7 +51,7 @@ jobs:
|
||||
echo "BENCH_DATE=$(date --iso-8601=seconds)" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Checkout tfhe-rs repo with tags
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -103,7 +103,7 @@ jobs:
|
||||
path: ${{ env.RESULTS_FILENAME }}
|
||||
|
||||
- name: Checkout Slab repo
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
with:
|
||||
repository: zama-ai/slab
|
||||
path: slab
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,9 +3,9 @@ target/
|
||||
.vscode/
|
||||
|
||||
# Path we use for internal-keycache during tests
|
||||
./keys/
|
||||
keys/
|
||||
# In case of symlinked keys
|
||||
./keys
|
||||
keys
|
||||
|
||||
**/Cargo.lock
|
||||
**/*.bin
|
||||
|
||||
165
Makefile
165
Makefile
@@ -6,7 +6,7 @@ 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)
|
||||
MIN_RUST_VERSION:=$(shell grep '^rust-version[[:space:]]*=' tfhe/Cargo.toml | cut -d '=' -f 2 | xargs)
|
||||
AVX512_SUPPORT?=OFF
|
||||
WASM_RUSTFLAGS:=
|
||||
BIG_TESTS_INSTANCE?=FALSE
|
||||
@@ -16,6 +16,17 @@ PARSE_INTEGER_BENCH_CSV_FILE?=tfhe_rs_integer_benches.csv
|
||||
FAST_TESTS?=FALSE
|
||||
FAST_BENCH?=FALSE
|
||||
BENCH_OP_FLAVOR?=DEFAULT
|
||||
NODE_VERSION=20
|
||||
# sed: -n, do not print input stream, -e means a script/expression
|
||||
# 1,/version/ indicates from the first line, to the line matching version at the start of the line
|
||||
# p indicates to print, so we keep only the start of the Cargo.toml until we hit the first version
|
||||
# entry which should be the version of tfhe
|
||||
TFHE_CURRENT_VERSION:=\
|
||||
$(shell sed -n -e '1,/^version/p' tfhe/Cargo.toml | \
|
||||
grep '^version[[:space:]]*=' | cut -d '=' -f 2 | xargs)
|
||||
# Cargo has a hard time distinguishing between our package from the workspace and a package that
|
||||
# could be a dependency, so we build an unambiguous spec here
|
||||
TFHE_SPEC:=tfhe@$(TFHE_CURRENT_VERSION)
|
||||
# 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
|
||||
@@ -99,7 +110,7 @@ install_wasm_pack: install_rs_build_toolchain
|
||||
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' || \
|
||||
$(SHELL) -i -c 'nvm install $(NODE_VERSION)' || \
|
||||
( echo "Unable to install node, unknown error." && exit 1 )
|
||||
|
||||
.PHONY: install_dieharder # Install dieharder for apt distributions or macOS
|
||||
@@ -120,7 +131,7 @@ install_tarpaulin: install_rs_build_toolchain
|
||||
.PHONY: check_linelint_installed # Check if linelint newline linter is installed
|
||||
check_linelint_installed:
|
||||
@printf "\n" | linelint - > /dev/null 2>&1 || \
|
||||
( echo "Unable to locate linelint. Try installing it: https://github.com/fernandrone/linelint/releases" && exit 1 )
|
||||
( echo "Unable to locate linelint. Try installing it: https://github.com/fernandrone/linelint/releases" && exit 1 )
|
||||
|
||||
.PHONY: fmt # Format rust code
|
||||
fmt: install_rs_check_toolchain
|
||||
@@ -142,46 +153,46 @@ check_newline: check_linelint_installed
|
||||
clippy_core: install_rs_check_toolchain
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
|
||||
--features=$(TARGET_ARCH_FEATURE) \
|
||||
-p tfhe -- --no-deps -D warnings
|
||||
-p $(TFHE_SPEC) -- --no-deps -D warnings
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
|
||||
--features=$(TARGET_ARCH_FEATURE),experimental \
|
||||
-p tfhe -- --no-deps -D warnings
|
||||
-p $(TFHE_SPEC) -- --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
|
||||
-p $(TFHE_SPEC) -- --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
|
||||
-p $(TFHE_SPEC) -- --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
|
||||
-p $(TFHE_SPEC) -- --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
|
||||
-p $(TFHE_SPEC) -- --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
|
||||
-p $(TFHE_SPEC) -- --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
|
||||
-p $(TFHE_SPEC) -- --no-deps -D warnings
|
||||
|
||||
.PHONY: clippy_tasks # Run clippy lints on helper tasks crate.
|
||||
clippy_tasks:
|
||||
@@ -192,13 +203,13 @@ clippy_tasks:
|
||||
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
|
||||
-p $(TFHE_SPEC) -- --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,safe-deserialization \
|
||||
-p tfhe -- --no-deps -D warnings
|
||||
-p $(TFHE_SPEC) -- --no-deps -D warnings
|
||||
|
||||
.PHONY: clippy_concrete_csprng # Run clippy lints on concrete-csprng
|
||||
clippy_concrete_csprng:
|
||||
@@ -218,58 +229,58 @@ clippy_concrete_csprng
|
||||
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),boolean,shortint,internal-keycache -p tfhe -- \
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,internal-keycache -- \
|
||||
$(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
|
||||
--features=$(TARGET_ARCH_FEATURE) -p $(TFHE_SPEC)
|
||||
@if [[ "$(AVX512_SUPPORT)" == "ON" ]]; then \
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
|
||||
--features=$(TARGET_ARCH_FEATURE),$(AVX512_FEATURE) -p tfhe; \
|
||||
--features=$(TARGET_ARCH_FEATURE),$(AVX512_FEATURE) -p $(TFHE_SPEC); \
|
||||
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
|
||||
--features=$(TARGET_ARCH_FEATURE),experimental -p $(TFHE_SPEC)
|
||||
@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; \
|
||||
--features=$(TARGET_ARCH_FEATURE),experimental,$(AVX512_FEATURE) -p $(TFHE_SPEC); \
|
||||
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
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean -p $(TFHE_SPEC) --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
|
||||
--features=$(TARGET_ARCH_FEATURE),shortint -p $(TFHE_SPEC) --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
|
||||
--features=$(TARGET_ARCH_FEATURE),integer -p $(TFHE_SPEC) --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
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer -p $(TFHE_SPEC) --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,safe-deserialization \
|
||||
-p tfhe
|
||||
-p $(TFHE_SPEC)
|
||||
|
||||
.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,safe-deserialization,experimental-force_fft_algo_dif4 \
|
||||
-p tfhe
|
||||
-p $(TFHE_SPEC)
|
||||
|
||||
.PHONY: build_web_js_api # Build the js API targeting the web browser
|
||||
build_web_js_api: install_rs_build_toolchain install_wasm_pack
|
||||
@@ -302,16 +313,16 @@ build_concrete_csprng: install_rs_build_toolchain
|
||||
.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::
|
||||
--features=$(TARGET_ARCH_FEATURE),experimental -p $(TFHE_SPEC) -- 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::; \
|
||||
--features=$(TARGET_ARCH_FEATURE),experimental,$(AVX512_FEATURE) -p $(TFHE_SPEC) -- 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::
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean -p $(TFHE_SPEC) -- boolean::
|
||||
|
||||
.PHONY: test_boolean_cov # Run the tests of the boolean module with code coverage
|
||||
test_boolean_cov: install_rs_check_toolchain install_tarpaulin
|
||||
@@ -319,13 +330,13 @@ test_boolean_cov: install_rs_check_toolchain install_tarpaulin
|
||||
--out xml --output-dir coverage/boolean --line --engine llvm --timeout 500 \
|
||||
$(COVERAGE_EXCLUDED_FILES) \
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,internal-keycache,__coverage \
|
||||
-p tfhe -- boolean::
|
||||
-p $(TFHE_SPEC) -- 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,safe-deserialization \
|
||||
-p tfhe \
|
||||
-p $(TFHE_SPEC) \
|
||||
c_api
|
||||
|
||||
.PHONY: test_c_api_c # Run the C tests for the C API
|
||||
@@ -352,7 +363,7 @@ test_shortint_multi_bit_ci: install_rs_build_toolchain install_cargo_nextest
|
||||
.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::
|
||||
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache -p $(TFHE_SPEC) -- shortint::
|
||||
|
||||
.PHONY: test_shortint_cov # Run the tests of the shortint module with code coverage
|
||||
test_shortint_cov: install_rs_check_toolchain install_tarpaulin
|
||||
@@ -360,42 +371,74 @@ test_shortint_cov: install_rs_check_toolchain install_tarpaulin
|
||||
--out xml --output-dir coverage/shortint --line --engine llvm --timeout 500 \
|
||||
$(COVERAGE_EXCLUDED_FILES) \
|
||||
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache,__coverage \
|
||||
-p tfhe -- shortint::
|
||||
-p $(TFHE_SPEC) -- shortint::
|
||||
|
||||
.PHONY: test_integer_ci # Run the tests for integer ci
|
||||
test_integer_ci: install_rs_build_toolchain install_cargo_nextest
|
||||
test_integer_ci: install_rs_check_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)"
|
||||
./scripts/integer-tests.sh --rust-toolchain $(CARGO_RS_CHECK_TOOLCHAIN) \
|
||||
--cargo-profile "$(CARGO_PROFILE)" --avx512-support "$(AVX512_SUPPORT)"
|
||||
|
||||
.PHONY: test_unsigned_integer_ci # Run the tests for unsigned integer ci
|
||||
test_unsigned_integer_ci: install_rs_check_toolchain install_cargo_nextest
|
||||
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
|
||||
FAST_TESTS="$(FAST_TESTS)" \
|
||||
./scripts/integer-tests.sh --rust-toolchain $(CARGO_RS_CHECK_TOOLCHAIN) \
|
||||
--cargo-profile "$(CARGO_PROFILE)" --avx512-support "$(AVX512_SUPPORT)" \
|
||||
--unsigned-only
|
||||
|
||||
.PHONY: test_signed_integer_ci # Run the tests for signed integer ci
|
||||
test_signed_integer_ci: install_rs_check_toolchain install_cargo_nextest
|
||||
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
|
||||
FAST_TESTS="$(FAST_TESTS)" \
|
||||
./scripts/integer-tests.sh --rust-toolchain $(CARGO_RS_CHECK_TOOLCHAIN) \
|
||||
--cargo-profile "$(CARGO_PROFILE)" --avx512-support "$(AVX512_SUPPORT)" \
|
||||
--signed-only
|
||||
|
||||
.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
|
||||
test_integer_multi_bit_ci: install_rs_check_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
|
||||
./scripts/integer-tests.sh --rust-toolchain $(CARGO_RS_CHECK_TOOLCHAIN) \
|
||||
--cargo-profile "$(CARGO_PROFILE)" --multi-bit --avx512-support "$(AVX512_SUPPORT)"
|
||||
|
||||
.PHONY: test_unsigned_integer_multi_bit_ci # Run the tests for nsigned integer ci running only multibit tests
|
||||
test_unsigned_integer_multi_bit_ci: install_rs_check_toolchain install_cargo_nextest
|
||||
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
|
||||
FAST_TESTS="$(FAST_TESTS)" \
|
||||
./scripts/integer-tests.sh --rust-toolchain $(CARGO_RS_CHECK_TOOLCHAIN) \
|
||||
--cargo-profile "$(CARGO_PROFILE)" --multi-bit --avx512-support "$(AVX512_SUPPORT)" \
|
||||
--unsigned-only
|
||||
|
||||
.PHONY: test_signed_integer_multi_bit_ci # Run the tests for nsigned integer ci running only multibit tests
|
||||
test_signed_integer_multi_bit_ci: install_rs_check_toolchain install_cargo_nextest
|
||||
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
|
||||
FAST_TESTS="$(FAST_TESTS)" \
|
||||
./scripts/integer-tests.sh --rust-toolchain $(CARGO_RS_CHECK_TOOLCHAIN) \
|
||||
--cargo-profile "$(CARGO_PROFILE)" --multi-bit --avx512-support "$(AVX512_SUPPORT)" \
|
||||
--signed-only
|
||||
|
||||
.PHONY: test_safe_deserialization # Run the tests for safe deserialization
|
||||
test_safe_deserialization: install_rs_build_toolchain install_cargo_nextest
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,safe-deserialization -p tfhe -- safe_deserialization::
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,safe-deserialization -p $(TFHE_SPEC) -- safe_deserialization::
|
||||
|
||||
.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::
|
||||
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache -p $(TFHE_SPEC) -- 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 \
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache -p $(TFHE_SPEC) \
|
||||
-- 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 \
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache -p $(TFHE_SPEC) \
|
||||
-- test_user_docs::
|
||||
|
||||
.PHONY: test_regex_engine # Run tests for regex_engine example
|
||||
@@ -459,17 +502,17 @@ format_doc_latex:
|
||||
check_compile_tests:
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --no-run \
|
||||
--features=$(TARGET_ARCH_FEATURE),experimental,boolean,shortint,integer,internal-keycache,safe-deserialization \
|
||||
-p tfhe
|
||||
-p $(TFHE_SPEC)
|
||||
|
||||
@if [[ "$(OS)" == "Linux" || "$(OS)" == "Darwin" ]]; then \
|
||||
"$(MAKE)" build_c_api; \
|
||||
"$(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 .
|
||||
-f docker/Dockerfile.wasm_tests --build-arg NODE_VERSION=$(NODE_VERSION) -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
|
||||
@@ -493,7 +536,8 @@ test_web_js_api_parallel: build_web_js_api_parallel
|
||||
.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 && \
|
||||
nvm install $(NODE_VERSION) && \
|
||||
nvm use $(NODE_VERSION) && \
|
||||
$(MAKE) -C tfhe/web_wasm_parallel_tests test-ci
|
||||
|
||||
.PHONY: no_tfhe_typo # Check we did not invert the h and f in tfhe
|
||||
@@ -512,27 +556,42 @@ dieharder_csprng: install_dieharder build_concrete_csprng
|
||||
# Benchmarks
|
||||
#
|
||||
|
||||
.PHONY: bench_integer # Run benchmarks for integer
|
||||
.PHONY: bench_integer # Run benchmarks for unsigned 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 --
|
||||
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache,$(AVX512_FEATURE) -p $(TFHE_SPEC) --
|
||||
|
||||
.PHONY: bench_integer_multi_bit # Run benchmarks for integer using multi-bit parameters
|
||||
.PHONY: bench_integer_multi_bit # Run benchmarks for unsigned 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 --
|
||||
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache,$(AVX512_FEATURE) -p $(TFHE_SPEC) --
|
||||
|
||||
.PHONY: bench_signed_integer # Run benchmarks for signed integer
|
||||
bench_signed_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-signed-bench \
|
||||
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache,$(AVX512_FEATURE) -p $(TFHE_SPEC) --
|
||||
|
||||
.PHONY: bench_signed_integer_multi_bit # Run benchmarks for signed integer using multi-bit parameters
|
||||
bench_signed_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-signed-bench \
|
||||
--features=$(TARGET_ARCH_FEATURE),integer,internal-keycache,$(AVX512_FEATURE) -p $(TFHE_SPEC) --
|
||||
|
||||
.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
|
||||
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache,$(AVX512_FEATURE) -p $(TFHE_SPEC)
|
||||
|
||||
.PHONY: bench_shortint_multi_bit # Run benchmarks for shortint using multi-bit parameters
|
||||
bench_shortint_multi_bit: install_rs_check_toolchain
|
||||
@@ -540,20 +599,20 @@ bench_shortint_multi_bit: install_rs_check_toolchain
|
||||
__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 --
|
||||
--features=$(TARGET_ARCH_FEATURE),shortint,internal-keycache,$(AVX512_FEATURE) -p $(TFHE_SPEC) --
|
||||
|
||||
|
||||
.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
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,internal-keycache,$(AVX512_FEATURE) -p $(TFHE_SPEC)
|
||||
|
||||
.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
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,internal-keycache,$(AVX512_FEATURE) -p $(TFHE_SPEC)
|
||||
|
||||
.PHONY: bench_web_js_api_parallel # Run benchmarks for the web wasm api
|
||||
bench_web_js_api_parallel: build_web_js_api_parallel
|
||||
|
||||
@@ -70,9 +70,7 @@ use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint32, FheUint8};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Basic configuration to use homomorphic integers
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
|
||||
// Key generation
|
||||
let (client_key, server_keys) = generate_keys(config);
|
||||
|
||||
@@ -6,7 +6,7 @@ use tfhe_trivium::KreyviumStream;
|
||||
use criterion::Criterion;
|
||||
|
||||
pub fn kreyvium_bool_gen(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_bool().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
|
||||
@@ -41,7 +41,7 @@ pub fn kreyvium_bool_gen(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn kreyvium_bool_warmup(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_bool().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
|
||||
|
||||
@@ -6,9 +6,8 @@ use tfhe_trivium::{KreyviumStreamByte, TransCiphering};
|
||||
use criterion::Criterion;
|
||||
|
||||
pub fn kreyvium_byte_gen(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.enable_function_evaluation_integers()
|
||||
let config = ConfigBuilder::default()
|
||||
.enable_function_evaluation()
|
||||
.build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
@@ -36,9 +35,8 @@ pub fn kreyvium_byte_gen(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn kreyvium_byte_trans(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.enable_function_evaluation_integers()
|
||||
let config = ConfigBuilder::default()
|
||||
.enable_function_evaluation()
|
||||
.build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
@@ -67,9 +65,8 @@ pub fn kreyvium_byte_trans(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn kreyvium_byte_warmup(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.enable_function_evaluation_integers()
|
||||
let config = ConfigBuilder::default()
|
||||
.enable_function_evaluation()
|
||||
.build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ use tfhe_trivium::{KreyviumStreamShortint, TransCiphering};
|
||||
use criterion::Criterion;
|
||||
|
||||
pub fn kreyvium_shortint_warmup(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
@@ -60,9 +58,7 @@ pub fn kreyvium_shortint_warmup(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn kreyvium_shortint_gen(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
@@ -107,9 +103,7 @@ pub fn kreyvium_shortint_gen(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn kreyvium_shortint_trans(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
@@ -6,7 +6,7 @@ use tfhe_trivium::TriviumStream;
|
||||
use criterion::Criterion;
|
||||
|
||||
pub fn trivium_bool_gen(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_bool().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
@@ -41,7 +41,7 @@ pub fn trivium_bool_gen(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn trivium_bool_warmup(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_bool().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
|
||||
@@ -6,9 +6,7 @@ use tfhe_trivium::{TransCiphering, TriviumStreamByte};
|
||||
use criterion::Criterion;
|
||||
|
||||
pub fn trivium_byte_gen(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
@@ -35,9 +33,7 @@ pub fn trivium_byte_gen(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn trivium_byte_trans(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
@@ -65,9 +61,7 @@ pub fn trivium_byte_trans(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn trivium_byte_warmup(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
|
||||
@@ -8,9 +8,7 @@ use tfhe_trivium::{TransCiphering, TriviumStreamShortint};
|
||||
use criterion::Criterion;
|
||||
|
||||
pub fn trivium_shortint_warmup(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
@@ -60,9 +58,7 @@ pub fn trivium_shortint_warmup(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn trivium_shortint_gen(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
@@ -107,9 +103,7 @@ pub fn trivium_shortint_gen(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn trivium_shortint_trans(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
@@ -170,7 +170,7 @@ fn kreyvium_test_4() {
|
||||
|
||||
#[test]
|
||||
fn kreyvium_test_fhe_long() {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_bool().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
|
||||
@@ -217,9 +217,7 @@ use tfhe::shortint::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn kreyvium_test_shortint_long() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
@@ -302,9 +300,8 @@ fn kreyvium_test_clear_byte() {
|
||||
|
||||
#[test]
|
||||
fn kreyvium_test_byte_long() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.enable_function_evaluation_integers()
|
||||
let config = ConfigBuilder::default()
|
||||
.enable_function_evaluation()
|
||||
.build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
@@ -342,9 +339,8 @@ fn kreyvium_test_byte_long() {
|
||||
|
||||
#[test]
|
||||
fn kreyvium_test_fhe_byte_transciphering_long() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.enable_function_evaluation_integers()
|
||||
let config = ConfigBuilder::default()
|
||||
.enable_function_evaluation()
|
||||
.build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
use crate::{KreyviumStreamByte, KreyviumStreamShortint, TriviumStreamByte, TriviumStreamShortint};
|
||||
use tfhe::shortint::Ciphertext;
|
||||
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::{set_server_key, unset_server_key, FheUint64, FheUint8, ServerKey};
|
||||
|
||||
use rayon::prelude::*;
|
||||
|
||||
@@ -232,7 +232,7 @@ fn trivium_test_clear_byte() {
|
||||
|
||||
#[test]
|
||||
fn trivium_test_fhe_long() {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_bool().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
@@ -277,9 +277,7 @@ fn trivium_test_fhe_long() {
|
||||
|
||||
#[test]
|
||||
fn trivium_test_fhe_byte_long() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
@@ -316,9 +314,7 @@ fn trivium_test_fhe_byte_long() {
|
||||
|
||||
#[test]
|
||||
fn trivium_test_fhe_byte_transciphering_long() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
@@ -357,9 +353,7 @@ use tfhe::shortint::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn trivium_test_shortint_long() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
@@ -20,7 +20,10 @@ def main(args):
|
||||
bench_function_id = bench_data["function_id"]
|
||||
|
||||
split = bench_function_id.split("::")
|
||||
(_, function_name, parameter_set, bits) = split
|
||||
if split.len() == 5: # Signed integers
|
||||
(_, _, function_name, parameter_set, bits) = split
|
||||
else: # Unsigned integers
|
||||
(_, function_name, parameter_set, bits) = split
|
||||
|
||||
if "_scalar_" in bits:
|
||||
(bits, scalar) = bits.split("_bits_scalar_")
|
||||
|
||||
21
ci/slab.toml
21
ci/slab.toml
@@ -21,12 +21,12 @@ check_run_name = "CPU AWS Tests"
|
||||
[command.cpu_integer_test]
|
||||
workflow = "aws_tfhe_integer_tests.yml"
|
||||
profile = "cpu-big"
|
||||
check_run_name = "CPU Integer AWS Tests"
|
||||
check_run_name = "CPU Unsigned Integer AWS Tests"
|
||||
|
||||
[command.cpu_multi_bit_test]
|
||||
workflow = "aws_tfhe_multi_bit_tests.yml"
|
||||
workflow = "aws_tfhe_signed_integer_tests.yml"
|
||||
profile = "cpu-big"
|
||||
check_run_name = "CPU AWS Multi Bit Tests"
|
||||
check_run_name = "CPU Signed Integer AWS Tests"
|
||||
|
||||
[command.cpu_wasm_test]
|
||||
workflow = "aws_tfhe_wasm_tests.yml"
|
||||
@@ -43,6 +43,11 @@ workflow = "integer_full_benchmark.yml"
|
||||
profile = "bench"
|
||||
check_run_name = "Integer CPU AWS Benchmarks Full Suite"
|
||||
|
||||
[command.signed_integer_full_bench]
|
||||
workflow = "signed_integer_full_benchmark.yml"
|
||||
profile = "bench"
|
||||
check_run_name = "Signed Integer CPU AWS Benchmarks Full Suite"
|
||||
|
||||
[command.integer_bench]
|
||||
workflow = "integer_benchmark.yml"
|
||||
profile = "bench"
|
||||
@@ -53,6 +58,16 @@ workflow = "integer_multi_bit_benchmark.yml"
|
||||
profile = "bench"
|
||||
check_run_name = "Integer multi bit CPU AWS Benchmarks"
|
||||
|
||||
[command.signed_integer_bench]
|
||||
workflow = "signed_integer_benchmark.yml"
|
||||
profile = "bench"
|
||||
check_run_name = "Signed integer CPU AWS Benchmarks"
|
||||
|
||||
[command.signed_integer_multi_bit_bench]
|
||||
workflow = "signed_integer_multi_bit_benchmark.yml"
|
||||
profile = "bench"
|
||||
check_run_name = "Signed integer multi bit CPU AWS Benchmarks"
|
||||
|
||||
[command.shortint_full_bench]
|
||||
workflow = "shortint_full_benchmark.yml"
|
||||
profile = "bench"
|
||||
|
||||
@@ -11,6 +11,7 @@ RUN sed -i 's|^deb http://archive.ubuntu.com/ubuntu/|deb http://mirror.ubuntu.ik
|
||||
ENV CARGO_TARGET_DIR=/root/tfhe-rs-target
|
||||
|
||||
ARG RUST_TOOLCHAIN="stable"
|
||||
ARG NODE_VERSION
|
||||
|
||||
WORKDIR /tfhe-wasm-tests
|
||||
|
||||
@@ -34,6 +35,6 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > install-rustup.s
|
||||
chmod +x install-node.sh && \
|
||||
./install-node.sh && \
|
||||
. "$HOME/.nvm/nvm.sh" && \
|
||||
bash -i -c 'nvm install node && nvm use node'
|
||||
bash -i -c 'nvm install ${NODE_VERSION} && nvm use ${NODE_VERSION}'
|
||||
|
||||
WORKDIR /tfhe-wasm-tests/tfhe-rs/
|
||||
|
||||
@@ -8,14 +8,23 @@ function usage() {
|
||||
echo "--help Print this message"
|
||||
echo "--rust-toolchain The toolchain to run the tests with default: stable"
|
||||
echo "--multi-bit Run multi-bit tests only: default off"
|
||||
echo "--unsigned-only Run only unsigned integer tests, by default both signed and unsigned tests are run"
|
||||
echo "--signed-only Run only signed integer tests, by default both signed and unsigned tests are run"
|
||||
echo "--cargo-profile The cargo profile used to build tests"
|
||||
echo "--avx512-support Set to ON to enable avx512"
|
||||
echo
|
||||
}
|
||||
|
||||
RUST_TOOLCHAIN="+stable"
|
||||
multi_bit=""
|
||||
not_multi_bit="_multi_bit"
|
||||
# Run signed test by default
|
||||
signed=""
|
||||
not_signed=""
|
||||
cargo_profile="release"
|
||||
# TODO: revert to release once the bug is properly fixed/identified
|
||||
cargo_profile_doctests="release_lto_off"
|
||||
avx512_feature=""
|
||||
|
||||
while [ -n "$1" ]
|
||||
do
|
||||
@@ -35,11 +44,28 @@ do
|
||||
not_multi_bit=""
|
||||
;;
|
||||
|
||||
"--unsigned-only" )
|
||||
signed=""
|
||||
not_signed="_signed"
|
||||
;;
|
||||
|
||||
"--signed-only" )
|
||||
signed="_signed"
|
||||
not_signed=""
|
||||
;;
|
||||
|
||||
"--cargo-profile" )
|
||||
shift
|
||||
cargo_profile="$1"
|
||||
;;
|
||||
|
||||
"--avx512-support" )
|
||||
shift
|
||||
if [[ "$1" == "ON" ]]; then
|
||||
avx512_feature=nightly-avx512
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown param : $1"
|
||||
exit 1
|
||||
@@ -62,104 +88,86 @@ if [[ $(uname) == "Darwin" ]]; then
|
||||
nproc_bin="sysctl -n hw.logicalcpu"
|
||||
fi
|
||||
|
||||
n_threads="$(${nproc_bin})"
|
||||
# TODO autodetect/have a finer CPU count depending on memory
|
||||
num_cpu_threads="$(${nproc_bin})"
|
||||
|
||||
if uname -a | grep "arm64"; then
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
# Keys are 4.7 gigs at max, CI M1 macs only has 8 gigs of RAM
|
||||
n_threads=1
|
||||
small_instance_n_threads=1
|
||||
fi
|
||||
else
|
||||
# Keys are 4.7 gigs at max, test machine has 32 gigs of RAM
|
||||
n_threads=6
|
||||
small_instance_n_threads=6
|
||||
fi
|
||||
|
||||
if [[ "${BIG_TESTS_INSTANCE}" != TRUE ]]; then
|
||||
if [[ "${FAST_TESTS}" != TRUE ]]; then
|
||||
# block pbs are too slow for high params
|
||||
# mul_crt_4_4 is extremely flaky (~80% failure)
|
||||
# test_wopbs_bivariate_crt_wopbs_param_message generate tables that are too big at the moment
|
||||
# test_integer_smart_mul_param_message_4_carry_4_ks_pbs is too slow
|
||||
# so is test_integer_default_add_sequence_multi_thread_param_message_4_carry_4_ks_pbs
|
||||
filter_expression="""\
|
||||
test(/^integer::.*${multi_bit}/) \
|
||||
${not_multi_bit:+"and not test(~${not_multi_bit})"} \
|
||||
and not test(/.*_block_pbs(_base)?_param_message_[34]_carry_[34]_ks_pbs$/) \
|
||||
and not test(~mul_crt_param_message_4_carry_4_ks_pbs) \
|
||||
and not test(/.*test_wopbs_bivariate_crt_wopbs_param_message_[34]_carry_[34]_ks_pbs$/) \
|
||||
and not test(/.*test_integer_smart_mul_param_message_4_carry_4_ks_pbs$/) \
|
||||
and not test(/.*test_integer_default_add_sequence_multi_thread_param_message_4_carry_4_ks_pbs$/)"""
|
||||
else
|
||||
# test only fast default operations with only two set of parameters
|
||||
filter_expression="""\
|
||||
test(/^integer::.*${multi_bit}/) \
|
||||
${not_multi_bit:+"and not test(~${not_multi_bit})"} \
|
||||
and test(/.*_default_.*?_param${multi_bit}_message_[2-3]_carry_[2-3]${multi_bit:+"_group_2"}_ks_pbs/) \
|
||||
and not test(/.*_param_message_[14]_carry_[14]_ks_pbs$/) \
|
||||
and not test(/.*default_add_sequence_multi_thread_param_message_3_carry_3_ks_pbs$/)"""
|
||||
fi
|
||||
|
||||
cargo "${RUST_TOOLCHAIN}" nextest run \
|
||||
--tests \
|
||||
--cargo-profile "${cargo_profile}" \
|
||||
--package tfhe \
|
||||
--profile ci \
|
||||
--features="${ARCH_FEATURE}",integer,internal-keycache \
|
||||
--test-threads "${n_threads}" \
|
||||
-E "$filter_expression"
|
||||
|
||||
if [[ "${multi_bit}" == "" ]]; then
|
||||
cargo "${RUST_TOOLCHAIN}" test \
|
||||
--profile "${cargo_profile}" \
|
||||
--package tfhe \
|
||||
--features="${ARCH_FEATURE}",integer,internal-keycache \
|
||||
--doc \
|
||||
-- integer::
|
||||
fi
|
||||
if [[ "${BIG_TESTS_INSTANCE}" == TRUE ]]; then
|
||||
test_threads="$((num_cpu_threads * 1 / 2))"
|
||||
doctest_threads="${num_cpu_threads}"
|
||||
else
|
||||
if [[ "${FAST_TESTS}" != TRUE ]]; then
|
||||
# block pbs are too slow for high params
|
||||
# mul_crt_4_4 is extremely flaky (~80% failure)
|
||||
# test_wopbs_bivariate_crt_wopbs_param_message generate tables that are too big at the moment
|
||||
# test_integer_smart_mul_param_message_4_carry_4_ks_pbs is too slow
|
||||
# so is test_integer_default_add_sequence_multi_thread_param_message_4_carry_4_ks_pbs
|
||||
filter_expression="""\
|
||||
test_threads="${small_instance_n_threads}"
|
||||
doctest_threads="${num_cpu_threads}"
|
||||
fi
|
||||
|
||||
# block pbs are too slow for high params
|
||||
# mul_crt_4_4 is extremely flaky (~80% failure)
|
||||
# test_wopbs_bivariate_crt_wopbs_param_message generate tables that are too big at the moment
|
||||
# test_integer_smart_mul_param_message_4_carry_4_ks_pbs is too slow
|
||||
# so is test_integer_default_add_sequence_multi_thread_param_message_4_carry_4_ks_pbs
|
||||
# we skip smart_div, smart_rem which are already covered by the smar_div_rem test
|
||||
# we similarly skip default_div, default_rem which are covered by default_div_rem
|
||||
full_test_filter_expression="""\
|
||||
test(/^integer::.*${multi_bit}/) \
|
||||
${signed:+"and test(/^integer::.*${signed}/)"} \
|
||||
${not_multi_bit:+"and not test(~${not_multi_bit})"} \
|
||||
${not_signed:+"and not test(~${not_signed})"} \
|
||||
and not test(/.*integer_smart_div_param/) \
|
||||
and not test(/.*integer_smart_rem_param/) \
|
||||
and not test(/.*integer_default_div_param/) \
|
||||
and not test(/.*integer_default_rem_param/) \
|
||||
and not test(/.*_block_pbs(_base)?_param_message_[34]_carry_[34]_ks_pbs$/) \
|
||||
and not test(~mul_crt_param_message_4_carry_4_ks_pbs) \
|
||||
and not test(/.*test_wopbs_bivariate_crt_wopbs_param_message_[34]_carry_[34]_ks_pbs$/) \
|
||||
and not test(/.*test_integer_smart_mul_param_message_4_carry_4_ks_pbs$/) \
|
||||
and not test(/.*test_integer_default_add_sequence_multi_thread_param_message_4_carry_4_ks_pbs$/)"""
|
||||
else
|
||||
# test only fast default operations with only two set of parameters
|
||||
filter_expression="""\
|
||||
|
||||
# test only fast default operations with only two set of parameters
|
||||
# we skip default_div, default_rem which are covered by default_div_rem
|
||||
fast_test_filter_expression="""\
|
||||
test(/^integer::.*${multi_bit}/) \
|
||||
${signed:+"and test(/^integer::.*${signed}/)"} \
|
||||
${not_multi_bit:+"and not test(~${not_multi_bit})"} \
|
||||
${not_signed:+"and not test(~${not_signed})"} \
|
||||
and test(/.*_default_.*?_param${multi_bit}_message_[2-3]_carry_[2-3]${multi_bit:+"_group_2"}_ks_pbs/) \
|
||||
and not test(/.*integer_default_div_param/) \
|
||||
and not test(/.*integer_default_rem_param/) \
|
||||
and not test(/.*_param_message_[14]_carry_[14]_ks_pbs$/) \
|
||||
and not test(/.*default_add_sequence_multi_thread_param_message_3_carry_3_ks_pbs$/)"""
|
||||
fi
|
||||
|
||||
num_cpu_threads="$(${nproc_bin})"
|
||||
num_threads=$((num_cpu_threads * 1 / 2))
|
||||
cargo "${RUST_TOOLCHAIN}" nextest run \
|
||||
--tests \
|
||||
--cargo-profile "${cargo_profile}" \
|
||||
if [[ "${FAST_TESTS}" == "TRUE" ]]; then
|
||||
echo "Running 'fast' test set'"
|
||||
filter_expression="${fast_test_filter_expression}"
|
||||
else
|
||||
echo "Running 'slow' test set"
|
||||
filter_expression="${full_test_filter_expression}"
|
||||
fi
|
||||
|
||||
cargo "${RUST_TOOLCHAIN}" nextest run \
|
||||
--tests \
|
||||
--cargo-profile "${cargo_profile}" \
|
||||
--package tfhe \
|
||||
--profile ci \
|
||||
--features="${ARCH_FEATURE}",integer,internal-keycache,"${avx512_feature}" \
|
||||
--test-threads "${test_threads}" \
|
||||
-E "$filter_expression"
|
||||
|
||||
if [[ "${multi_bit}" == "" ]]; then
|
||||
cargo "${RUST_TOOLCHAIN}" test \
|
||||
--profile "${cargo_profile_doctests}" \
|
||||
--package tfhe \
|
||||
--profile ci \
|
||||
--features="${ARCH_FEATURE}",integer,internal-keycache \
|
||||
--test-threads $num_threads \
|
||||
-E "$filter_expression"
|
||||
|
||||
if [[ "${multi_bit}" == "" ]]; then
|
||||
cargo "${RUST_TOOLCHAIN}" test \
|
||||
--profile "${cargo_profile}" \
|
||||
--package tfhe \
|
||||
--features="${ARCH_FEATURE}",integer,internal-keycache \
|
||||
--doc \
|
||||
-- --test-threads="$(${nproc_bin})" integer::
|
||||
fi
|
||||
--features="${ARCH_FEATURE}",integer,internal-keycache,"${avx512_feature}" \
|
||||
--doc \
|
||||
-- --test-threads="${doctest_threads}" integer::
|
||||
fi
|
||||
|
||||
echo "Test ran in $SECONDS seconds"
|
||||
|
||||
@@ -94,6 +94,7 @@ or test(/^shortint::.*_param${multi_bit}_message_2_carry_3${multi_bit:+"_group_[
|
||||
or test(/^shortint::.*_param${multi_bit}_message_3_carry_1${multi_bit:+"_group_[0-9]"}(_compact_pk)?_ks_pbs/) \
|
||||
or test(/^shortint::.*_param${multi_bit}_message_3_carry_2${multi_bit:+"_group_[0-9]"}(_compact_pk)?_ks_pbs/) \
|
||||
or test(/^shortint::.*_param${multi_bit}_message_3_carry_3${multi_bit:+"_group_[0-9]"}(_compact_pk)?_ks_pbs/) \
|
||||
or test(/^shortint::.*_ci_run_filter/) \
|
||||
)\
|
||||
and not test(~smart_add_and_mul)""" # This test is too slow
|
||||
else
|
||||
@@ -159,6 +160,7 @@ or test(/^shortint::.*_param${multi_bit}_message_3_carry_1${multi_bit:+"_group_[
|
||||
or test(/^shortint::.*_param${multi_bit}_message_3_carry_2${multi_bit:+"_group_[0-9]"}(_compact_pk)?_ks_pbs/) \
|
||||
or test(/^shortint::.*_param${multi_bit}_message_3_carry_3${multi_bit:+"_group_[0-9]"}(_compact_pk)?_ks_pbs/) \
|
||||
or test(/^shortint::.*_param${multi_bit}_message_4_carry_4${multi_bit:+"_group_[0-9]"}(_compact_pk)?_ks_pbs/) \
|
||||
or test(/^shortint::.*_ci_run_filter/) \
|
||||
)\
|
||||
and not test(~smart_add_and_mul)""" # This test is too slow
|
||||
else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tfhe"
|
||||
version = "0.4.0"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
readme = "../README.md"
|
||||
keywords = ["fully", "homomorphic", "encryption", "fhe", "cryptography"]
|
||||
@@ -49,7 +49,7 @@ log = "0.4.19"
|
||||
cbindgen = { version = "0.26.0", optional = true }
|
||||
|
||||
[dependencies]
|
||||
concrete-csprng = { version = "0.4.0", path= "../concrete-csprng", features = [
|
||||
concrete-csprng = { version = "0.4.0", path = "../concrete-csprng", features = [
|
||||
"generator_fallback",
|
||||
"parallel",
|
||||
] }
|
||||
@@ -82,7 +82,7 @@ bytemuck = "1.13.1"
|
||||
boolean = ["dep:paste"]
|
||||
shortint = ["dep:paste"]
|
||||
integer = ["shortint", "dep:paste"]
|
||||
internal-keycache = ["lazy_static", "dep:fs2", "dep:bincode", "dep:paste"]
|
||||
internal-keycache = ["dep:lazy_static", "dep:fs2", "dep:bincode", "dep:paste"]
|
||||
safe-deserialization = ["dep:bincode"]
|
||||
|
||||
# Experimental section
|
||||
@@ -90,17 +90,19 @@ experimental = []
|
||||
experimental-force_fft_algo_dif4 = []
|
||||
# End experimental section
|
||||
|
||||
__c_api = ["cbindgen", "dep:bincode", "dep:paste"]
|
||||
__c_api = ["dep:cbindgen", "dep:bincode", "dep:paste"]
|
||||
# For the semver trick to skip the build.rs
|
||||
__force_skip_cbindgen = []
|
||||
boolean-c-api = ["boolean", "__c_api"]
|
||||
shortint-c-api = ["shortint", "__c_api"]
|
||||
high-level-c-api = ["boolean-c-api", "shortint-c-api", "integer", "__c_api"]
|
||||
|
||||
__wasm_api = [
|
||||
"wasm-bindgen",
|
||||
"js-sys",
|
||||
"console_error_panic_hook",
|
||||
"serde-wasm-bindgen",
|
||||
"getrandom",
|
||||
"dep:wasm-bindgen",
|
||||
"dep:js-sys",
|
||||
"dep:console_error_panic_hook",
|
||||
"dep:serde-wasm-bindgen",
|
||||
"dep:getrandom",
|
||||
"getrandom/js",
|
||||
"dep:bincode",
|
||||
"safe-deserialization",
|
||||
@@ -109,7 +111,7 @@ boolean-client-js-wasm-api = ["boolean", "__wasm_api"]
|
||||
shortint-client-js-wasm-api = ["shortint", "__wasm_api"]
|
||||
integer-client-js-wasm-api = ["integer", "__wasm_api"]
|
||||
high-level-client-js-wasm-api = ["boolean", "shortint", "integer", "__wasm_api"]
|
||||
parallel-wasm-api = ["wasm-bindgen-rayon"]
|
||||
parallel-wasm-api = ["dep:wasm-bindgen-rayon"]
|
||||
|
||||
nightly-avx512 = ["concrete-fft/nightly", "pulp/nightly"]
|
||||
|
||||
@@ -212,7 +214,7 @@ required-features = ["shortint", "internal-keycache"]
|
||||
[[example]]
|
||||
name = "generates_test_keys"
|
||||
path = "examples/utilities/generates_test_keys.rs"
|
||||
required-features = ["shortint", "internal-keycache"]
|
||||
required-features = ["boolean", "shortint", "internal-keycache"]
|
||||
|
||||
[[example]]
|
||||
name = "boolean_key_sizes"
|
||||
|
||||
@@ -130,7 +130,7 @@ fn multi_bit_pbs<Scalar: UnsignedTorus + CastInto<usize> + CastFrom<usize> + Syn
|
||||
);
|
||||
|
||||
let id = format!("Multi Bit PBS {}", Scalar::BITS);
|
||||
#[allow(clippy::unit_arg)]
|
||||
|
||||
{
|
||||
c.bench_function(&id, |b| {
|
||||
b.iter(|| {
|
||||
|
||||
@@ -12,7 +12,7 @@ use rand::prelude::*;
|
||||
use rand::Rng;
|
||||
use std::vec::IntoIter;
|
||||
use tfhe::integer::keycache::KEY_CACHE;
|
||||
use tfhe::integer::{RadixCiphertext, ServerKey};
|
||||
use tfhe::integer::{IntegerKeyKind, RadixCiphertext, ServerKey};
|
||||
use tfhe::keycache::NamedParam;
|
||||
|
||||
use tfhe::integer::U256;
|
||||
@@ -118,7 +118,7 @@ fn bench_server_key_binary_function_dirty_inputs<F>(
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_two_values = || {
|
||||
let clear_0 = gen_random_u256(&mut rng);
|
||||
@@ -186,7 +186,7 @@ fn bench_server_key_binary_function_clean_inputs<F>(
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_two_values = || {
|
||||
let clear_0 = gen_random_u256(&mut rng);
|
||||
@@ -243,7 +243,7 @@ fn bench_server_key_unary_function_dirty_inputs<F>(
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_one_value = || {
|
||||
let clear_0 = gen_random_u256(&mut rng);
|
||||
@@ -308,7 +308,7 @@ fn bench_server_key_unary_function_clean_inputs<F>(
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_one_value = || {
|
||||
let clear_0 = gen_random_u256(&mut rng);
|
||||
@@ -362,7 +362,7 @@ fn bench_server_key_binary_scalar_function_dirty_inputs<F, G>(
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_one_value = || {
|
||||
let clear_0 = gen_random_u256(&mut rng);
|
||||
@@ -435,7 +435,7 @@ fn bench_server_key_binary_scalar_function_clean_inputs<F, G>(
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits_scalar_{bit_size}");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_one_value = || {
|
||||
let clear_0 = gen_random_u256(&mut rng);
|
||||
@@ -515,7 +515,7 @@ fn if_then_else_parallelized(c: &mut Criterion) {
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_tree_values = || {
|
||||
let clear_0 = gen_random_u256(&mut rng);
|
||||
@@ -524,7 +524,7 @@ fn if_then_else_parallelized(c: &mut Criterion) {
|
||||
let clear_1 = gen_random_u256(&mut rng);
|
||||
let ct_1 = cks.encrypt_radix(clear_1, num_block);
|
||||
|
||||
let cond = sks.create_trivial_radix(rng.gen_bool(0.5) as u64, num_block);
|
||||
let cond = sks.create_trivial_boolean_block(rng.gen_bool(0.5));
|
||||
|
||||
(cond, ct_0, ct_1)
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ use rand::prelude::*;
|
||||
use rand::Rng;
|
||||
use std::vec::IntoIter;
|
||||
use tfhe::integer::keycache::KEY_CACHE;
|
||||
use tfhe::integer::{RadixCiphertext, ServerKey, SignedRadixCiphertext, I256};
|
||||
use tfhe::integer::{IntegerKeyKind, RadixCiphertext, ServerKey, SignedRadixCiphertext, I256};
|
||||
use tfhe::keycache::NamedParam;
|
||||
|
||||
use tfhe::shortint::parameters::{
|
||||
@@ -114,7 +114,7 @@ fn bench_server_key_signed_binary_function_clean_inputs<F>(
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_two_values = || {
|
||||
let ct_0 = cks.encrypt_signed_radix(gen_random_i256(&mut rng), num_block);
|
||||
@@ -167,7 +167,7 @@ fn bench_server_key_signed_shift_function_clean_inputs<F>(
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_two_values = || {
|
||||
let clear_1 = rng.gen_range(0u128..bit_size as u128);
|
||||
@@ -223,7 +223,7 @@ fn bench_server_key_unary_function_clean_inputs<F>(
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_one_value =
|
||||
|| cks.encrypt_signed_radix(gen_random_i256(&mut rng), num_block);
|
||||
@@ -266,13 +266,13 @@ fn signed_if_then_else_parallelized(c: &mut Criterion) {
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_tree_values = || {
|
||||
let ct_0 = cks.encrypt_signed_radix(gen_random_i256(&mut rng), num_block);
|
||||
let ct_1 = cks.encrypt_signed_radix(gen_random_i256(&mut rng), num_block);
|
||||
|
||||
let cond = sks.create_trivial_radix(rng.gen_bool(0.5) as u64, num_block);
|
||||
let cond = sks.create_trivial_boolean_block(rng.gen_bool(0.5));
|
||||
|
||||
(cond, ct_0, ct_1)
|
||||
};
|
||||
@@ -348,6 +348,169 @@ macro_rules! define_server_key_bench_unary_signed_clean_input_fn (
|
||||
};
|
||||
);
|
||||
|
||||
define_server_key_bench_unary_signed_clean_input_fn!(
|
||||
method_name: neg_parallelized,
|
||||
display_name: negation
|
||||
);
|
||||
define_server_key_bench_unary_signed_clean_input_fn!(
|
||||
method_name: abs_parallelized,
|
||||
display_name: abs
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: add_parallelized,
|
||||
display_name: add
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: sub_parallelized,
|
||||
display_name: sub
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: mul_parallelized,
|
||||
display_name: mul
|
||||
);
|
||||
// define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
// method_name: div_parallelized,
|
||||
// display_name: div,
|
||||
// sample_size:10
|
||||
// );
|
||||
// define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
// method_name: rem_parallelized,
|
||||
// display_name: modulo,
|
||||
// sample_size:10
|
||||
// );
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: div_rem_parallelized,
|
||||
display_name: div_mod,
|
||||
sample_size:10
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: bitand_parallelized,
|
||||
display_name: bitand
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: bitxor_parallelized,
|
||||
display_name: bitxor
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: bitor_parallelized,
|
||||
display_name: bitor
|
||||
);
|
||||
define_server_key_bench_unary_signed_clean_input_fn!(
|
||||
method_name: bitnot_parallelized,
|
||||
display_name: bitnot
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: max_parallelized,
|
||||
display_name: max
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: min_parallelized,
|
||||
display_name: min
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: eq_parallelized,
|
||||
display_name: equal
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: ne_parallelized,
|
||||
display_name: not_equal
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: lt_parallelized,
|
||||
display_name: less_than
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: le_parallelized,
|
||||
display_name: less_or_equal
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: gt_parallelized,
|
||||
display_name: greater_than
|
||||
);
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: ge_parallelized,
|
||||
display_name: greater_or_equal
|
||||
);
|
||||
|
||||
fn left_shift_parallelized(c: &mut Criterion) {
|
||||
bench_server_key_signed_shift_function_clean_inputs(
|
||||
c,
|
||||
concat!("integer::signed::", "left_shift_parallelized"),
|
||||
"left_shift",
|
||||
|server_key, lhs, rhs| {
|
||||
server_key.left_shift_parallelized(lhs, rhs);
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn right_shift_parallelized(c: &mut Criterion) {
|
||||
bench_server_key_signed_shift_function_clean_inputs(
|
||||
c,
|
||||
concat!("integer::signed::", "right_shift_parallelized"),
|
||||
"right_shift",
|
||||
|server_key, lhs, rhs| {
|
||||
server_key.right_shift_parallelized(lhs, rhs);
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn rotate_left_parallelized(c: &mut Criterion) {
|
||||
bench_server_key_signed_shift_function_clean_inputs(
|
||||
c,
|
||||
concat!("integer::signed::", "rotate_left_parallelized"),
|
||||
"rotate_left",
|
||||
|server_key, lhs, rhs| {
|
||||
server_key.rotate_left_parallelized(lhs, rhs);
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn rotate_right_parallelized(c: &mut Criterion) {
|
||||
bench_server_key_signed_shift_function_clean_inputs(
|
||||
c,
|
||||
concat!("integer::signed::", "rotate_right_parallelized"),
|
||||
"rotate_right",
|
||||
|server_key, lhs, rhs| {
|
||||
server_key.rotate_right_parallelized(lhs, rhs);
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
criterion_group!(
|
||||
default_parallelized_ops,
|
||||
neg_parallelized,
|
||||
abs_parallelized,
|
||||
add_parallelized,
|
||||
sub_parallelized,
|
||||
mul_parallelized,
|
||||
// div_parallelized,
|
||||
// rem_parallelized,
|
||||
div_rem_parallelized, // For ciphertext div == rem == div_rem
|
||||
bitand_parallelized,
|
||||
bitnot_parallelized,
|
||||
bitor_parallelized,
|
||||
bitxor_parallelized,
|
||||
left_shift_parallelized,
|
||||
right_shift_parallelized,
|
||||
rotate_left_parallelized,
|
||||
rotate_right_parallelized,
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
default_parallelized_ops_comp,
|
||||
max_parallelized,
|
||||
min_parallelized,
|
||||
eq_parallelized,
|
||||
ne_parallelized,
|
||||
lt_parallelized,
|
||||
le_parallelized,
|
||||
gt_parallelized,
|
||||
ge_parallelized,
|
||||
signed_if_then_else_parallelized,
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: unchecked_mul_parallelized,
|
||||
display_name: mul
|
||||
@@ -370,32 +533,32 @@ define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: unchecked_eq_parallelized,
|
||||
display_name: eq
|
||||
display_name: equal
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: unchecked_ne_parallelized,
|
||||
display_name: ne
|
||||
display_name: not_equal
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: unchecked_le_parallelized,
|
||||
display_name: le
|
||||
display_name: less_or_equal
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: unchecked_lt_parallelized,
|
||||
display_name: lt
|
||||
display_name: less_than
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: unchecked_ge_parallelized,
|
||||
display_name: ge
|
||||
display_name: greater_or_equal
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: unchecked_gt_parallelized,
|
||||
display_name: gt
|
||||
display_name: greater_than
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
@@ -410,13 +573,13 @@ define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: unchecked_div_rem_parallelized,
|
||||
display_name: div_rem,
|
||||
display_name: div_mod,
|
||||
sample_size: 10,
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_signed_clean_inputs_fn!(
|
||||
method_name: unchecked_div_rem_floor_parallelized,
|
||||
display_name: div_rem_floor,
|
||||
display_name: div_mod_floor,
|
||||
sample_size: 10,
|
||||
);
|
||||
|
||||
@@ -528,7 +691,7 @@ fn bench_server_key_binary_scalar_function_clean_inputs<F, G>(
|
||||
|
||||
let bench_id = format!("{bench_name}::{param_name}::{bit_size}_bits_scalar_{bit_size}");
|
||||
bench_group.bench_function(&bench_id, |b| {
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param);
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let encrypt_one_value = || {
|
||||
let ct_0 = cks.encrypt_signed_radix(gen_random_i256(&mut rng), num_block);
|
||||
@@ -651,111 +814,248 @@ macro_rules! define_server_key_bench_binary_scalar_clean_inputs_fn (
|
||||
}
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_add_parallelized,
|
||||
display_name: add,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_sub_parallelized,
|
||||
display_name: sub,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_mul_parallelized,
|
||||
display_name: mul,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: signed_scalar_div_parallelized,
|
||||
display_name: div,
|
||||
rng_func: div_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: signed_scalar_rem_parallelized,
|
||||
display_name: modulo,
|
||||
rng_func: div_scalar
|
||||
);
|
||||
// define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
// method_name: signed_scalar_div_rem_parallelized,
|
||||
// display_name: div_mod,
|
||||
// rng_func: div_scalar
|
||||
// );
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_bitand_parallelized,
|
||||
display_name: bitand,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_bitxor_parallelized,
|
||||
display_name: bitxor,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_bitor_parallelized,
|
||||
display_name: bitor,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_left_shift_parallelized,
|
||||
display_name: left_shift,
|
||||
rng_func: shift_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_right_shift_parallelized,
|
||||
display_name: right_shift,
|
||||
rng_func: shift_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_rotate_left_parallelized,
|
||||
display_name: rotate_left,
|
||||
rng_func: shift_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_rotate_right_parallelized,
|
||||
display_name: rotate_right,
|
||||
rng_func: shift_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_max_parallelized,
|
||||
display_name: max,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_min_parallelized,
|
||||
display_name: min,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_eq_parallelized,
|
||||
display_name: equal,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_ne_parallelized,
|
||||
display_name: not_equal,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_lt_parallelized,
|
||||
display_name: less_than,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_le_parallelized,
|
||||
display_name: less_or_equal,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_gt_parallelized,
|
||||
display_name: greater_than,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: scalar_ge_parallelized,
|
||||
display_name: greater_or_equal,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
default_scalar_parallelized_ops,
|
||||
scalar_add_parallelized,
|
||||
scalar_sub_parallelized,
|
||||
scalar_mul_parallelized,
|
||||
signed_scalar_div_parallelized,
|
||||
signed_scalar_rem_parallelized, // For scalar rem == div_rem
|
||||
// signed_scalar_div_rem_parallelized,
|
||||
scalar_bitand_parallelized,
|
||||
scalar_bitor_parallelized,
|
||||
scalar_bitxor_parallelized,
|
||||
scalar_left_shift_parallelized,
|
||||
scalar_right_shift_parallelized,
|
||||
scalar_rotate_left_parallelized,
|
||||
scalar_rotate_right_parallelized,
|
||||
);
|
||||
|
||||
criterion_group!(
|
||||
default_scalar_parallelized_ops_comp,
|
||||
scalar_max_parallelized,
|
||||
scalar_min_parallelized,
|
||||
scalar_eq_parallelized,
|
||||
scalar_ne_parallelized,
|
||||
scalar_lt_parallelized,
|
||||
scalar_le_parallelized,
|
||||
scalar_gt_parallelized,
|
||||
scalar_ge_parallelized,
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_left_shift_parallelized,
|
||||
display_name: scalar_left_shift,
|
||||
display_name: left_shift,
|
||||
rng_func: shift_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_right_shift_parallelized,
|
||||
display_name: scalar_right_shift,
|
||||
display_name: right_shift,
|
||||
rng_func: shift_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_rotate_right_parallelized,
|
||||
display_name: scalar_rotate_right,
|
||||
display_name: rotate_right,
|
||||
rng_func: shift_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_rotate_left_parallelized,
|
||||
display_name: scalar_rotate_left,
|
||||
display_name: rotate_left,
|
||||
rng_func: shift_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_mul_parallelized,
|
||||
display_name: scalar_mul,
|
||||
display_name: mul,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_bitand_parallelized,
|
||||
display_name: scalar_bitand,
|
||||
display_name: bitand,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_bitor_parallelized,
|
||||
display_name: scalar_bitor,
|
||||
display_name: bitor,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_bitxor_parallelized,
|
||||
display_name: scalar_bitxor,
|
||||
display_name: bitxor,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_eq_parallelized,
|
||||
display_name: scalar_eq,
|
||||
display_name: equal,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_ne_parallelized,
|
||||
display_name: scalar_ne,
|
||||
display_name: not_equal,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_le_parallelized,
|
||||
display_name: scalar_le,
|
||||
display_name: less_or_equal,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_lt_parallelized,
|
||||
display_name: scalar_lt,
|
||||
display_name: less_than,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_ge_parallelized,
|
||||
display_name: scalar_ge,
|
||||
display_name: greater_or_equal,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_gt_parallelized,
|
||||
display_name: scalar_gt,
|
||||
display_name: greater_than,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_max_parallelized,
|
||||
display_name: scalar_max,
|
||||
display_name: max,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_scalar_min_parallelized,
|
||||
display_name: scalar_min,
|
||||
display_name: min,
|
||||
rng_func: default_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_signed_scalar_div_rem_parallelized,
|
||||
display_name: scalar_div_rem,
|
||||
display_name: div_mod,
|
||||
rng_func: div_scalar
|
||||
);
|
||||
|
||||
define_server_key_bench_binary_scalar_clean_inputs_fn!(
|
||||
method_name: unchecked_signed_scalar_div_parallelized,
|
||||
display_name: scalar_div,
|
||||
display_name: div,
|
||||
rng_func: div_scalar
|
||||
);
|
||||
|
||||
@@ -786,12 +1086,14 @@ criterion_group!(
|
||||
unchecked_scalar_min_parallelized,
|
||||
);
|
||||
|
||||
criterion_group!(default_ops, signed_if_then_else_parallelized,);
|
||||
|
||||
fn main() {
|
||||
match env::var("__TFHE_RS_BENCH_OP_FLAVOR") {
|
||||
Ok(val) => {
|
||||
match val.to_lowercase().as_str() {
|
||||
"default" => default_parallelized_ops(),
|
||||
"default_comp" => default_parallelized_ops_comp(),
|
||||
"default_scalar" => default_scalar_parallelized_ops(),
|
||||
"default_scalar_comp" => default_scalar_parallelized_ops_comp(),
|
||||
"unchecked" => unchecked_ops(),
|
||||
"unchecked_comp" => unchecked_ops_comp(),
|
||||
"unchecked_scalar" => unchecked_scalar_ops(),
|
||||
@@ -800,10 +1102,8 @@ fn main() {
|
||||
};
|
||||
}
|
||||
Err(_) => {
|
||||
unchecked_ops();
|
||||
unchecked_ops_comp();
|
||||
unchecked_scalar_ops();
|
||||
unchecked_scalar_ops_comp();
|
||||
default_parallelized_ops();
|
||||
default_scalar_parallelized_ops();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg(feature = "__c_api")]
|
||||
#[cfg(all(feature = "__c_api", not(feature = "__force_skip_cbindgen")))]
|
||||
fn gen_c_api() {
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
@@ -32,14 +32,15 @@ fn gen_c_api() {
|
||||
}
|
||||
|
||||
extern crate cbindgen;
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
let crate_dir: PathBuf = env::var("CARGO_MANIFEST_DIR").unwrap().into();
|
||||
let package_name = env::var("CARGO_PKG_NAME").unwrap();
|
||||
let output_file = target_dir()
|
||||
.join(format!("{package_name}.h"))
|
||||
.display()
|
||||
.to_string();
|
||||
let output_file = target_dir().join(format!("{package_name}.h"));
|
||||
|
||||
let parse_expand_features_vec = vec![
|
||||
// Note that this list may not be complete, but as macro expansion is used mostly/only for
|
||||
// the C API and the HL API, this is fine, if the C API build fails or generates invalid
|
||||
// headers then you likely need to add other features that will be forwarded to Cargo
|
||||
// expand
|
||||
#[cfg(feature = "__c_api")]
|
||||
"__c_api",
|
||||
#[cfg(feature = "boolean-c-api")]
|
||||
@@ -63,8 +64,8 @@ fn gen_c_api() {
|
||||
};
|
||||
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(crate_dir.clone())
|
||||
.with_config(cbindgen::Config::from_root_or_default(crate_dir))
|
||||
.with_crate(crate_dir.as_path())
|
||||
.with_config(cbindgen::Config::from_file(crate_dir.join("cbindgen.toml")).unwrap())
|
||||
.with_parse_expand(&parse_expand_vec)
|
||||
.with_parse_expand_features(&parse_expand_features_vec)
|
||||
.generate()
|
||||
@@ -73,6 +74,6 @@ fn gen_c_api() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
#[cfg(feature = "__c_api")]
|
||||
#[cfg(all(feature = "__c_api", not(feature = "__force_skip_cbindgen")))]
|
||||
gen_c_api()
|
||||
}
|
||||
|
||||
@@ -99,8 +99,7 @@ int main(void) {
|
||||
ConfigBuilder *builder;
|
||||
Config *config;
|
||||
|
||||
config_builder_all_disabled(&builder);
|
||||
config_builder_enable_default_integers_small(&builder);
|
||||
config_builder_default(&builder);
|
||||
config_builder_build(builder, &config);
|
||||
|
||||
ClientKey *client_key = NULL;
|
||||
|
||||
@@ -243,8 +243,7 @@ int main(void) {
|
||||
ConfigBuilder *builder;
|
||||
Config *config;
|
||||
|
||||
config_builder_all_disabled(&builder);
|
||||
config_builder_enable_default_integers_small(&builder);
|
||||
config_builder_default(&builder);
|
||||
config_builder_build(builder, &config);
|
||||
|
||||
ClientKey *client_key = NULL;
|
||||
|
||||
@@ -102,8 +102,7 @@ int main(void) {
|
||||
ConfigBuilder *builder;
|
||||
Config *config;
|
||||
|
||||
config_builder_all_disabled(&builder);
|
||||
config_builder_enable_default_bool(&builder);
|
||||
config_builder_default(&builder);
|
||||
config_builder_build(builder, &config);
|
||||
|
||||
ClientKey *client_key = NULL;
|
||||
|
||||
@@ -238,8 +238,8 @@ int main(void) {
|
||||
ConfigBuilder *builder;
|
||||
Config *config;
|
||||
|
||||
config_builder_all_disabled(&builder);
|
||||
config_builder_enable_custom_integers(&builder,
|
||||
config_builder_default(&builder);
|
||||
config_builder_use_custom_parameters(&builder,
|
||||
SHORTINT_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
config_builder_build(builder, &config);
|
||||
|
||||
@@ -266,8 +266,8 @@ int main(void) {
|
||||
ConfigBuilder *builder;
|
||||
Config *config;
|
||||
|
||||
config_builder_all_disabled(&builder);
|
||||
config_builder_enable_custom_integers(&builder,
|
||||
config_builder_default(&builder);
|
||||
config_builder_use_custom_parameters(&builder,
|
||||
SHORTINT_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
config_builder_build(builder, &config);
|
||||
|
||||
|
||||
@@ -203,9 +203,7 @@ int main(void) {
|
||||
ConfigBuilder *builder;
|
||||
Config *config;
|
||||
|
||||
ok = config_builder_all_disabled(&builder);
|
||||
assert(ok == 0);
|
||||
ok = config_builder_enable_default_integers(&builder);
|
||||
ok = config_builder_default(&builder);
|
||||
assert(ok == 0);
|
||||
ok = config_builder_build(builder, &config);
|
||||
assert(ok == 0);
|
||||
@@ -242,9 +240,7 @@ int main(void) {
|
||||
ConfigBuilder *builder;
|
||||
Config *config;
|
||||
|
||||
ok = config_builder_all_disabled(&builder);
|
||||
assert(ok == 0);
|
||||
ok = config_builder_enable_default_integers_small(&builder);
|
||||
ok = config_builder_default_with_small_encryption(&builder);
|
||||
assert(ok == 0);
|
||||
ok = config_builder_build(builder, &config);
|
||||
assert(ok == 0);
|
||||
|
||||
@@ -114,14 +114,15 @@ bitflags = false
|
||||
############## Options for How Your Rust library Should Be Parsed ##############
|
||||
|
||||
[parse]
|
||||
parse_deps = true
|
||||
include = ["tfhe"]
|
||||
parse_deps = false
|
||||
include = []
|
||||
exclude = []
|
||||
clean = false
|
||||
extra_bindings = []
|
||||
|
||||
|
||||
[parse.expand]
|
||||
# Managed by build.rs to programmatically select features when required
|
||||
crates = []
|
||||
all_features = false
|
||||
default_features = true
|
||||
|
||||
@@ -9,7 +9,7 @@ Welcome to this tutorial about `TFHE-rs` `core_crypto` module.
|
||||
To use `TFHE-rs`, it first has to be added as a dependency in the `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.4.0", features = [ "x86_64-unix" ] }
|
||||
tfhe = { version = "0.5.0", features = [ "x86_64-unix" ] }
|
||||
```
|
||||
|
||||
This enables the `x86_64-unix` feature to have efficient implementations of various algorithms for `x86_64` CPUs on a Unix-like system. The 'unix' suffix indicates that the `UnixSeeder`, which uses `/dev/random` to generate random numbers, is activated as a fallback if no hardware number generator is available (like `rdseed` on `x86_64` or if the [`Randomization Services`](https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc) on Apple platforms are not available). To avoid having the `UnixSeeder` as a potential fallback or to run on non-Unix systems (e.g., Windows), the `x86_64` feature is sufficient.
|
||||
@@ -19,19 +19,19 @@ For Apple Silicon, the `aarch64-unix` or `aarch64` feature should be enabled. `a
|
||||
In short: For `x86_64`-based machines running Unix-like OSes:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.4.0", features = ["x86_64-unix"] }
|
||||
tfhe = { version = "0.5.0", features = ["x86_64-unix"] }
|
||||
```
|
||||
|
||||
For Apple Silicon or aarch64-based machines running Unix-like OSes:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.4.0", features = ["aarch64-unix"] }
|
||||
tfhe = { version = "0.5.0", features = ["aarch64-unix"] }
|
||||
```
|
||||
|
||||
For `x86_64`-based machines with the [`rdseed instruction`](https://en.wikipedia.org/wiki/RDRAND) running Windows:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.4.0", features = ["x86_64"] }
|
||||
tfhe = { version = "0.5.0", features = ["x86_64"] }
|
||||
```
|
||||
|
||||
### Commented code to double a 2-bit message in a leveled fashion and using a PBS with the `core_crypto` module.
|
||||
|
||||
@@ -35,7 +35,7 @@ fn main() {
|
||||
Note that both the `client_key` and `server_key` implement the `Serialize` and `Deserialize` traits. This way you can use any compatible serializer to store/send the data. To store the `server_key` in a binary file, you can use the `bincode` library:
|
||||
|
||||
```rust
|
||||
use std::fs::File;
|
||||
use std::fs::{File, create_dir_all};
|
||||
use std::io::{Write, Read};
|
||||
use tfhe::boolean::prelude::*;
|
||||
|
||||
@@ -49,7 +49,13 @@ fn main() {
|
||||
// We serialize the server key to bytes, and store them in a file:
|
||||
let encoded: Vec<u8> = bincode::serialize(&server_key).unwrap();
|
||||
|
||||
let server_key_file = "/tmp/tutorial_server_key.bin";
|
||||
// Create a tmp dir with the current user name to avoid cluttering the /tmp dir
|
||||
let user = std::env::var("USER").unwrap_or_else(|_| "unknown_user".to_string());
|
||||
let tmp_dir_for_user = &format!("/tmp/{user}");
|
||||
|
||||
create_dir_all(tmp_dir_for_user).unwrap();
|
||||
|
||||
let server_key_file = &format!("{tmp_dir_for_user}/tutorial_server_key.bin");
|
||||
|
||||
// We write the server key to a file:
|
||||
let mut file = File::create(server_key_file)
|
||||
|
||||
@@ -8,7 +8,7 @@ Here is an example using the `bincode` serialization library, which serializes t
|
||||
binary format:
|
||||
|
||||
```rust
|
||||
use std::fs::File;
|
||||
use std::fs::{File, create_dir_all};
|
||||
use std::io::{Write, Read};
|
||||
use tfhe::boolean::prelude::*;
|
||||
|
||||
@@ -20,8 +20,14 @@ fn main() {
|
||||
let encoded_server_key: Vec<u8> = bincode::serialize(&server_key).unwrap();
|
||||
let encoded_client_key: Vec<u8> = bincode::serialize(&client_key).unwrap();
|
||||
|
||||
let server_key_file = "/tmp/ser_example_server_key.bin";
|
||||
let client_key_file = "/tmp/ser_example_client_key.bin";
|
||||
// Create a tmp dir with the current user name to avoid cluttering the /tmp dir
|
||||
let user = std::env::var("USER").unwrap_or_else(|_| "unknown_user".to_string());
|
||||
let tmp_dir_for_user = &format!("/tmp/{user}");
|
||||
|
||||
create_dir_all(tmp_dir_for_user).unwrap();
|
||||
|
||||
let server_key_file = &format!("{tmp_dir_for_user}/ser_example_server_key.bin");
|
||||
let client_key_file = &format!("{tmp_dir_for_user}/ser_example_client_key.bin");
|
||||
|
||||
// We write the keys to files:
|
||||
let mut file = File::create(server_key_file)
|
||||
|
||||
@@ -40,8 +40,7 @@ use tfhe::{ConfigBuilder, generate_keys, set_server_key, FheUint8};
|
||||
use tfhe::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = ConfigBuilder::default()
|
||||
.build();
|
||||
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
@@ -373,14 +373,14 @@ fn main() {
|
||||
let modulus = client_key.parameters.message_modulus().0 as u64;
|
||||
|
||||
// We use the private client key to encrypt two messages:
|
||||
let ct_1 = client_key.encrypt(msg1);
|
||||
let mut ct_1 = client_key.encrypt(msg1);
|
||||
let mut ct_2 = client_key.encrypt(msg2);
|
||||
|
||||
// Compute the lookup table for the bivariate functions
|
||||
let acc = server_key.generate_lookup_table_bivariate(|x,y| (x.count_ones()
|
||||
+ y.count_ones()) as u64 % modulus );
|
||||
|
||||
let ct_res = server_key.smart_apply_lookup_table_bivariate(&ct_1, &mut ct_2, &acc);
|
||||
let ct_res = server_key.smart_apply_lookup_table_bivariate(&mut ct_1, &mut ct_2, &acc);
|
||||
|
||||
// We use the client key to decrypt the output of the circuit:
|
||||
let output = client_key.decrypt(&ct_res);
|
||||
|
||||
@@ -8,12 +8,12 @@ To use `TFHE-rs` in your project, you first need to add it as a dependency in yo
|
||||
|
||||
If you are using an `x86` machine:
|
||||
```toml
|
||||
tfhe = { version = "0.4.0", features = [ "boolean", "shortint", "integer", "x86_64-unix" ] }
|
||||
tfhe = { version = "0.5.0", features = [ "boolean", "shortint", "integer", "x86_64-unix" ] }
|
||||
```
|
||||
|
||||
If you are using an `ARM` machine:
|
||||
```toml
|
||||
tfhe = { version = "0.4.0", features = [ "boolean", "shortint", "integer", "aarch64-unix" ] }
|
||||
tfhe = { version = "0.5.0", features = [ "boolean", "shortint", "integer", "aarch64-unix" ] }
|
||||
```
|
||||
|
||||
{% hint style="info" %}
|
||||
|
||||
@@ -78,7 +78,7 @@ use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheInt8, FheUint8};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_integers().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (keys, server_keys) = generate_keys(config);
|
||||
set_server_key(server_keys);
|
||||
|
||||
@@ -134,7 +134,7 @@ use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint8};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_integers().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (keys, server_keys) = generate_keys(config);
|
||||
set_server_key(server_keys);
|
||||
|
||||
@@ -188,7 +188,7 @@ use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheInt8};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_integers().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (keys, server_keys) = generate_keys(config);
|
||||
set_server_key(server_keys);
|
||||
|
||||
@@ -204,18 +204,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let lower_or_equal = a.le(&b);
|
||||
let equal = a.eq(&b);
|
||||
|
||||
let dec_gt: i8 = greater.decrypt(&keys);
|
||||
let dec_ge: i8 = greater_or_equal.decrypt(&keys);
|
||||
let dec_lt: i8 = lower.decrypt(&keys);
|
||||
let dec_le: i8 = lower_or_equal.decrypt(&keys);
|
||||
let dec_eq: i8 = equal.decrypt(&keys);
|
||||
let dec_gt = greater.decrypt(&keys);
|
||||
let dec_ge = greater_or_equal.decrypt(&keys);
|
||||
let dec_lt = lower.decrypt(&keys);
|
||||
let dec_le = lower_or_equal.decrypt(&keys);
|
||||
let dec_eq = equal.decrypt(&keys);
|
||||
|
||||
// We homomorphically swapped values using bitwise operations
|
||||
assert_eq!(dec_gt, (clear_a > clear_b ) as i8);
|
||||
assert_eq!(dec_ge, (clear_a >= clear_b) as i8);
|
||||
assert_eq!(dec_lt, (clear_a < clear_b ) as i8);
|
||||
assert_eq!(dec_le, (clear_a <= clear_b) as i8);
|
||||
assert_eq!(dec_eq, (clear_a == clear_b) as i8);
|
||||
assert_eq!(dec_gt, clear_a > clear_b);
|
||||
assert_eq!(dec_ge, clear_a >= clear_b);
|
||||
assert_eq!(dec_lt, clear_a < clear_b);
|
||||
assert_eq!(dec_le, clear_a <= clear_b);
|
||||
assert_eq!(dec_eq, clear_a == clear_b);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -237,7 +236,7 @@ use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint8};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_integers().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (keys, server_keys) = generate_keys(config);
|
||||
set_server_key(server_keys);
|
||||
|
||||
@@ -253,7 +252,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let dec_min : u8 = min.decrypt(&keys);
|
||||
let dec_max : u8 = max.decrypt(&keys);
|
||||
|
||||
// We homomorphically swapped values using bitwise operations
|
||||
assert_eq!(dec_min, u8::min(clear_a, clear_b));
|
||||
assert_eq!(dec_max, u8::max(clear_a, clear_b));
|
||||
|
||||
@@ -276,9 +274,7 @@ use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheInt32};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Basic configuration to use homomorphic integers
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
|
||||
// Key generation
|
||||
let (client_key, server_keys) = generate_keys(config);
|
||||
@@ -296,11 +292,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Clear equivalent computations: 32 > -45
|
||||
let encrypted_comp = &encrypted_a.gt(&encrypted_b);
|
||||
let clear_res: i32 = encrypted_comp.decrypt(&client_key);
|
||||
assert_eq!(clear_res, (clear_a > clear_b) as i32);
|
||||
let clear_res = encrypted_comp.decrypt(&client_key);
|
||||
assert_eq!(clear_res, clear_a > clear_b);
|
||||
|
||||
// `encrypted_comp` contains the result of the comparison, i.e.,
|
||||
// a boolean value. This acts as a condition on which the
|
||||
// `encrypted_comp` is a FheBool, thus it encrypts a boolean value.
|
||||
// This acts as a condition on which the
|
||||
// `if_then_else` function can be applied on.
|
||||
// Clear equivalent computations:
|
||||
// if 32 > -45 {result = 32} else {result = -45}
|
||||
@@ -323,9 +319,7 @@ use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheInt16, FheUint8, FheUint32, FheUint16};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
// Casting requires server_key to set
|
||||
@@ -377,222 +371,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
```
|
||||
|
||||
|
||||
|
||||
## ShortInt Operations
|
||||
|
||||
Native small homomorphic integer types (e.g., FheUint3 or FheUint4) can easily compute various operations. In general, computing over encrypted data in `TFHE-rs` is as easy as computing over clear data, since the same operation symbol is used. The addition between two ciphertexts is done using the symbol `+` between two FheUint values. Many operations can be computed between a clear value (i.e. a scalar) and a ciphertext.
|
||||
|
||||
In Rust, operations on native types are modular. For example, computations on `u8` are carried out modulo $$2^{8}$$. A similar idea applies for FheUintX, where operations are done modulo $$2^{X}$$. For FheUint3, operations are done modulo $$8 = 2^{3}$$.
|
||||
|
||||
### Arithmetic operations.
|
||||
|
||||
Small homomorphic integer types support all common arithmetic operations, meaning `+`, `-`, `x`, `/`, `mod`.
|
||||
|
||||
The division operation presents a subtlety: since data is encrypted, it is possible to compute a division by 0. In this case, the division is tweaked so that dividing by 0 returns the maximum possible value for the message.
|
||||
|
||||
The list of supported operations is:
|
||||
|
||||
| name | symbol | type |
|
||||
| ------------------------------------------------------- | ------ | ------ |
|
||||
| [Add](https://doc.rust-lang.org/std/ops/trait.Add.html) | `+` | Binary |
|
||||
| [Sub](https://doc.rust-lang.org/std/ops/trait.Sub.html) | `-` | Binary |
|
||||
| [Mul](https://doc.rust-lang.org/std/ops/trait.Mul.html) | `*` | Binary |
|
||||
| [Div](https://doc.rust-lang.org/std/ops/trait.Div.html) | `/` | Binary |
|
||||
| [Rem](https://doc.rust-lang.org/std/ops/trait.Rem.html) | `%` | Binary |
|
||||
| [Neg](https://doc.rust-lang.org/std/ops/trait.Neg.html) | `-` | Unary |
|
||||
|
||||
A simple example of how to use these operations:
|
||||
|
||||
```rust
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint3};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_uint3().build();
|
||||
let (keys, server_keys) = generate_keys(config);
|
||||
set_server_key(server_keys);
|
||||
|
||||
let clear_a = 7;
|
||||
let clear_b = 3;
|
||||
let clear_c = 2;
|
||||
|
||||
let mut a = FheUint3::try_encrypt(clear_a, &keys)?;
|
||||
let mut b = FheUint3::try_encrypt(clear_b, &keys)?;
|
||||
let mut c = FheUint3::try_encrypt(clear_c, &keys)?;
|
||||
|
||||
|
||||
a = a * &b; // Clear equivalent computations: 7 * 3 mod 8 = 5
|
||||
b = &b + &c; // Clear equivalent computations: 3 + 2 mod 8 = 5
|
||||
b = b - 5; // Clear equivalent computations: 5 - 5 mod 8 = 0
|
||||
|
||||
let dec_a = a.decrypt(&keys);
|
||||
let dec_b = b.decrypt(&keys);
|
||||
|
||||
// We homomorphically swapped values using bitwise operations
|
||||
assert_eq!(dec_a, (clear_a * clear_b) % 8);
|
||||
assert_eq!(dec_b, ((clear_b + clear_c) - 5) % 8);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
### Bitwise operations.
|
||||
|
||||
Small homomorphic integer types support some bitwise operations.
|
||||
|
||||
The list of supported operations is:
|
||||
|
||||
| name | symbol | type |
|
||||
|--------------------------------------------------------------------------------------|----------------|--------|
|
||||
| [Not](https://doc.rust-lang.org/std/ops/trait.Not.html) | `!` | Unary |
|
||||
| [BitAnd](https://doc.rust-lang.org/std/ops/trait.BitAnd.html) | `&` | Binary |
|
||||
| [BitOr](https://doc.rust-lang.org/std/ops/trait.BitOr.html) | `\|` | Binary |
|
||||
| [BitXor](https://doc.rust-lang.org/std/ops/trait.BitXor.html) | `^` | Binary |
|
||||
| [Shr](https://doc.rust-lang.org/std/ops/trait.Shr.html) | `>>` | Binary |
|
||||
| [Shl](https://doc.rust-lang.org/std/ops/trait.Shl.html) | `<<` | Binary |
|
||||
| [Rotate Right](https://doc.rust-lang.org/std/primitive.u32.html#method.rotate_right) | `rotate_right` | Binary |
|
||||
| [Rotate Left](https://doc.rust-lang.org/std/primitive.u32.html#method.rotate_left) | `rotate_left` | Binary |
|
||||
|
||||
A simple example of how to use these operations:
|
||||
|
||||
```rust
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint3};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_uint3().build();
|
||||
let (keys, server_keys) = generate_keys(config);
|
||||
set_server_key(server_keys);
|
||||
|
||||
let clear_a = 7;
|
||||
let clear_b = 3;
|
||||
|
||||
let mut a = FheUint3::try_encrypt(clear_a, &keys)?;
|
||||
let mut b = FheUint3::try_encrypt(clear_b, &keys)?;
|
||||
|
||||
a = a ^ &b;
|
||||
b = b ^ &a;
|
||||
a = a ^ &b;
|
||||
|
||||
let dec_a = a.decrypt(&keys);
|
||||
let dec_b = b.decrypt(&keys);
|
||||
|
||||
// We homomorphically swapped values using bitwise operations
|
||||
assert_eq!(dec_a, clear_b);
|
||||
assert_eq!(dec_b, clear_a);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
### Comparisons.
|
||||
|
||||
Small homomorphic integer types support comparison operations.
|
||||
|
||||
Due to some Rust limitations, it is not possible to overload the comparison symbols because of the inner definition of the operations. Rust expects to have a Boolean as an output, whereas a ciphertext is returned when using homomorphic types.
|
||||
|
||||
You will need to use different methods instead of using symbols for the comparisons. These methods follow the same naming conventions as the two standard Rust traits:
|
||||
|
||||
* [PartialOrd](https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html)
|
||||
* [PartialEq](https://doc.rust-lang.org/std/cmp/trait.PartialEq.html)
|
||||
|
||||
The list of supported operations is:
|
||||
|
||||
| name | symbol | type |
|
||||
|-----------------------------------------------------------------------------|--------|--------|
|
||||
| [Equal ](https://doc.rust-lang.org/std/cmp/trait.PartialEq.html) | `eq` | Binary |
|
||||
| [Not Equal ](https://doc.rust-lang.org/std/cmp/trait.PartialEq.html) | `ne` | Binary |
|
||||
| [Greater Than ](https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html) | `gt` | Binary |
|
||||
| [Greater or Equal](https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html) | `ge` | Binary |
|
||||
| [Lower ](https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html) | `lt` | Binary |
|
||||
| [Lower or Equal ](https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html) | `le` | Binary |
|
||||
|
||||
|
||||
A simple example of how to use these operations:
|
||||
|
||||
```rust
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint3};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_uint3().build();
|
||||
let (keys, server_keys) = generate_keys(config);
|
||||
set_server_key(server_keys);
|
||||
|
||||
let clear_a = 7;
|
||||
let clear_b = 3;
|
||||
|
||||
let mut a = FheUint3::try_encrypt(clear_a, &keys)?;
|
||||
let mut b = FheUint3::try_encrypt(clear_b, &keys)?;
|
||||
|
||||
assert_eq!(a.gt(&b).decrypt(&keys) != 0, true);
|
||||
assert_eq!(b.le(&a).decrypt(&keys) != 0, true);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
### Univariate function evaluation.
|
||||
|
||||
The shortint type also supports the computation of univariate functions, which make use of TFHE's _programmable bootstrapping_.
|
||||
|
||||
A simple example of how to use these operations:
|
||||
|
||||
```rust
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint4};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_uint4().build();
|
||||
let (keys, server_keys) = generate_keys(config);
|
||||
set_server_key(server_keys);
|
||||
|
||||
let pow_5 = |value: u64| {
|
||||
value.pow(5) % FheUint4::MODULUS as u64
|
||||
};
|
||||
|
||||
let clear_a = 12;
|
||||
let a = FheUint4::try_encrypt(12, &keys)?;
|
||||
|
||||
let c = a.map(pow_5);
|
||||
let decrypted = c.decrypt(&keys);
|
||||
assert_eq!(decrypted, pow_5(clear_a) as u8);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
### Bivariate function evaluations.
|
||||
|
||||
Using the shortint type allows you to evaluate bivariate functions (i.e., functions that take two ciphertexts as input).
|
||||
|
||||
A simple code example:
|
||||
|
||||
```rust
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_uint2().build();
|
||||
let (keys, server_keys) = generate_keys(config);
|
||||
set_server_key(server_keys);
|
||||
|
||||
let clear_a = 1;
|
||||
let clear_b = 3;
|
||||
let a = FheUint2::try_encrypt(clear_a, &keys)?;
|
||||
let b = FheUint2::try_encrypt(clear_b, &keys)?;
|
||||
|
||||
|
||||
let c = a.bivariate_function(&b, std::cmp::max);
|
||||
let decrypted = c.decrypt(&keys);
|
||||
assert_eq!(decrypted, std::cmp::max(clear_a, clear_b) as u8);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Boolean Operations
|
||||
|
||||
Native homomorphic Booleans support common Boolean operations.
|
||||
|
||||
@@ -18,9 +18,7 @@ use tfhe::{ConfigBuilder, generate_keys, set_server_key, FheUint8};
|
||||
use tfhe::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
|
||||
// Client-side
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
@@ -46,7 +44,7 @@ fn main() {
|
||||
|
||||
The default configuration for x86 Unix machines:
|
||||
```toml
|
||||
tfhe = { version = "0.4.0", features = ["integer", "x86_64-unix"]}
|
||||
tfhe = { version = "0.5.0", features = ["integer", "x86_64-unix"]}
|
||||
```
|
||||
|
||||
Configuration options for different platforms can be found [here](../getting_started/installation.md). Other rust and homomorphic types features can be found [here](../how_to/rust_configuration.md).
|
||||
@@ -76,9 +74,8 @@ The config is generated by first creating a builder with all types deactivated.
|
||||
use tfhe::{ConfigBuilder, generate_keys};
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
|
||||
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
}
|
||||
@@ -98,9 +95,7 @@ This function will **move** the server key to an internal state of the crate and
|
||||
use tfhe::{ConfigBuilder, generate_keys, set_server_key};
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
|
||||
@@ -13,9 +13,7 @@ use tfhe::prelude::*;
|
||||
use tfhe::{ConfigBuilder, generate_keys, set_server_key, CompressedFheUint16};
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
let clear = 12_837u16;
|
||||
@@ -48,9 +46,7 @@ use tfhe::{
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
|
||||
let cks = ClientKey::generate(config);
|
||||
let compressed_sks = CompressedServerKey::new(&cks);
|
||||
@@ -92,9 +88,7 @@ use tfhe::prelude::*;
|
||||
use tfhe::{ConfigBuilder, generate_keys, set_server_key, FheUint8, CompressedPublicKey};
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
let compressed_public_key = CompressedPublicKey::new(&client_key);
|
||||
@@ -122,8 +116,8 @@ use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, CompressedCompactPublicKey, ConfigBuilder, FheUint8};
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_custom_integers(
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS,
|
||||
None,
|
||||
)
|
||||
|
||||
@@ -10,8 +10,8 @@ use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint32};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_custom_integers(
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
tfhe::shortint::parameters::PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
None,
|
||||
)
|
||||
@@ -41,8 +41,8 @@ use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint32};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_custom_integers(
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
tfhe::shortint::parameters::PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS.with_deterministic_execution(),
|
||||
None,
|
||||
)
|
||||
|
||||
@@ -12,9 +12,7 @@ use tfhe::prelude::*;
|
||||
use tfhe::{ConfigBuilder, generate_keys, set_server_key, FheUint8, PublicKey};
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
let public_key = PublicKey::new(&client_key);
|
||||
@@ -34,8 +32,8 @@ use tfhe::prelude::*;
|
||||
use tfhe::{ConfigBuilder, generate_keys, set_server_key, FheUint8, CompactPublicKey};
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_custom_integers(
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS,
|
||||
None,
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ To serialize our data, a [data format](https://serde.rs/#data-formats) should be
|
||||
|
||||
[dependencies]
|
||||
# ...
|
||||
tfhe = { version = "0.4.0", features = ["integer","x86_64-unix"]}
|
||||
tfhe = { version = "0.5.0", features = ["integer","x86_64-unix"]}
|
||||
bincode = "1.3.3"
|
||||
```
|
||||
|
||||
@@ -26,9 +26,7 @@ use tfhe::{ConfigBuilder, ServerKey, generate_keys, set_server_key, FheUint8};
|
||||
use tfhe::prelude::*;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>>{
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
|
||||
let ( client_key, server_key) = generate_keys(config);
|
||||
|
||||
|
||||
@@ -68,8 +68,7 @@ pub fn ex4<FheType, ClearType>(a: FheType, b: FheType, pt: ClearType) -> FheType
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = ConfigBuilder::default()
|
||||
.build();
|
||||
|
||||
let (client_key, server_keys) = generate_keys(config);
|
||||
|
||||
@@ -11,9 +11,7 @@ the server can do a *trivial encryption*
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint8};
|
||||
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, sks) = generate_keys(config);
|
||||
|
||||
set_server_key(sks);
|
||||
@@ -38,9 +36,7 @@ value if the ciphertext/clear-value operation (often called scalar operation) yo
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint32};
|
||||
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
.build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, sks) = generate_keys(config);
|
||||
|
||||
set_server_key(sks);
|
||||
|
||||
@@ -24,7 +24,7 @@ To use the `FheUint8` type, the `integer` feature must be activated:
|
||||
|
||||
[dependencies]
|
||||
# Default configuration for x86 Unix machines:
|
||||
tfhe = { version = "0.4.0", features = ["integer", "x86_64-unix"]}
|
||||
tfhe = { version = "0.5.0", features = ["integer", "x86_64-unix"]}
|
||||
```
|
||||
|
||||
Other configurations can be found [here](../getting_started/installation.md).
|
||||
@@ -69,7 +69,7 @@ use tfhe::FheUint8;
|
||||
pub const UP_LOW_DISTANCE: u8 = 32;
|
||||
|
||||
fn to_lower(c: &FheUint8) -> FheUint8 {
|
||||
c + (c.gt(64) & c.lt(91)) * UP_LOW_DISTANCE
|
||||
c + FheUint8::cast_from(c.gt(64) & c.lt(91)) * UP_LOW_DISTANCE
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,11 +86,11 @@ struct FheAsciiString {
|
||||
}
|
||||
|
||||
fn to_upper(c: &FheUint8) -> FheUint8 {
|
||||
c - (c.gt(96) & c.lt(123)) * UP_LOW_DISTANCE
|
||||
c - FheUint8::cast_from(c.gt(96) & c.lt(123)) * UP_LOW_DISTANCE
|
||||
}
|
||||
|
||||
fn to_lower(c: &FheUint8) -> FheUint8 {
|
||||
c + (c.gt(64) & c.lt(91)) * UP_LOW_DISTANCE
|
||||
c + FheUint8::cast_from(c.gt(64) & c.lt(91)) * UP_LOW_DISTANCE
|
||||
}
|
||||
|
||||
impl FheAsciiString {
|
||||
@@ -131,8 +131,7 @@ impl FheAsciiString {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = ConfigBuilder::default()
|
||||
.build();
|
||||
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
@@ -15,13 +15,11 @@ This function returns a Boolean that will be either `true` or `false` so that th
|
||||
|
||||
### Non-generic version.
|
||||
|
||||
To use Booleans, the `booleans` feature in our Cargo.toml must be enabled:
|
||||
|
||||
```toml
|
||||
# Cargo.toml
|
||||
|
||||
# Default configuration for x86 Unix machines:
|
||||
tfhe = { version = "0.4.0", features = ["boolean", "x86_64-unix"]}
|
||||
tfhe = { version = "0.5.0", features = ["integer", "x86_64-unix"]}
|
||||
```
|
||||
|
||||
Other configurations can be found [here](../getting_started/installation.md).
|
||||
@@ -129,7 +127,7 @@ fn check_parity_bit_validity(bits: &[bool], mode: ParityMode, parity_bit: bool)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_bool().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
@@ -347,7 +345,7 @@ fn check_parity_bit_validity(bits: &[bool], mode: ParityMode, parity_bit: bool)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::all_disabled().enable_default_bool().build();
|
||||
let config = ConfigBuilder::default().build();
|
||||
|
||||
let ( client_key, server_key) = generate_keys(config);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::time::Instant;
|
||||
use rayon::prelude::*;
|
||||
|
||||
use tfhe::integer::ciphertext::RadixCiphertext;
|
||||
use tfhe::integer::ServerKey;
|
||||
use tfhe::integer::{IntegerCiphertext, ServerKey};
|
||||
|
||||
use crate::NUMBER_OF_BLOCKS;
|
||||
|
||||
@@ -70,10 +70,12 @@ fn fill_orders(
|
||||
);
|
||||
|
||||
// total_orders > prefix_sum
|
||||
let mut cond = server_key.smart_gt_parallelized(
|
||||
&mut total_orders.clone(),
|
||||
&mut previous_prefix_sum.clone(),
|
||||
);
|
||||
let mut cond = server_key
|
||||
.smart_gt_parallelized(
|
||||
&mut total_orders.clone(),
|
||||
&mut previous_prefix_sum.clone(),
|
||||
)
|
||||
.into_radix(diff.blocks().len(), server_key);
|
||||
|
||||
// (total_orders - previous_prefix_sum) * (total_orders > previous_prefix_sum)
|
||||
// = (total_orders - previous_prefix_sum).max(0)
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::time::Instant;
|
||||
|
||||
use tfhe::integer::ciphertext::RadixCiphertext;
|
||||
use tfhe::integer::keycache::IntegerKeyCache;
|
||||
use tfhe::integer::ServerKey;
|
||||
use tfhe::integer::{IntegerKeyKind, ServerKey};
|
||||
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
|
||||
mod fhe;
|
||||
@@ -73,7 +73,8 @@ fn test_volume_match_fhe(
|
||||
) {
|
||||
println!("Generating keys...");
|
||||
let time = Instant::now();
|
||||
let (client_key, server_key) = IntegerKeyCache.get_from_params(PARAM_MESSAGE_2_CARRY_2_KS_PBS);
|
||||
let (client_key, server_key) =
|
||||
IntegerKeyCache.get_from_params(PARAM_MESSAGE_2_CARRY_2_KS_PBS, IntegerKeyKind::Radix);
|
||||
println!("Keys generated in {:?}", time.elapsed());
|
||||
|
||||
println!("Running test cases for the FHE implementation");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use tfhe::integer::{RadixCiphertext, ServerKey};
|
||||
use tfhe::integer::{IntegerCiphertext, RadixCiphertext, ServerKey};
|
||||
|
||||
use crate::parser::u8_to_char;
|
||||
|
||||
@@ -72,7 +72,12 @@ impl Execution {
|
||||
|
||||
let mut ct_a = a.0.clone();
|
||||
let mut ct_b = b.0.clone();
|
||||
(exec.sk.smart_eq(&mut ct_a, &mut ct_b), ctx.clone())
|
||||
(
|
||||
exec.sk
|
||||
.smart_eq(&mut ct_a, &mut ct_b)
|
||||
.into_radix(ct_a.blocks().len(), &exec.sk),
|
||||
ctx.clone(),
|
||||
)
|
||||
}),
|
||||
)
|
||||
}
|
||||
@@ -89,7 +94,12 @@ impl Execution {
|
||||
|
||||
let mut ct_a = a.0.clone();
|
||||
let mut ct_b = b.0.clone();
|
||||
(exec.sk.smart_gt(&mut ct_a, &mut ct_b), ctx.clone())
|
||||
(
|
||||
exec.sk
|
||||
.smart_gt(&mut ct_a, &mut ct_b)
|
||||
.into_radix(ct_a.blocks().len(), &exec.sk),
|
||||
ctx.clone(),
|
||||
)
|
||||
}),
|
||||
)
|
||||
}
|
||||
@@ -106,7 +116,12 @@ impl Execution {
|
||||
|
||||
let mut ct_a = a.0.clone();
|
||||
let mut ct_b = b.0.clone();
|
||||
(exec.sk.smart_le(&mut ct_a, &mut ct_b), ctx.clone())
|
||||
(
|
||||
exec.sk
|
||||
.smart_le(&mut ct_a, &mut ct_b)
|
||||
.into_radix(ct_a.blocks().len(), &exec.sk),
|
||||
ctx.clone(),
|
||||
)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
|
||||
|
||||
{
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS;
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_custom_integers(params, None)
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(params, None)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
let test_name = format!("hlapi_sizes_{}_cpk", params.name());
|
||||
@@ -99,8 +99,8 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
|
||||
|
||||
{
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS;
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_custom_integers(params, None)
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(params, None)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
let test_name = format!("hlapi_sizes_{}_cpk", params.name());
|
||||
@@ -159,8 +159,8 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
|
||||
// 256 bits
|
||||
{
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS;
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_custom_integers(params, None)
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(params, None)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
@@ -208,8 +208,8 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
|
||||
|
||||
{
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS;
|
||||
let config = ConfigBuilder::all_disabled()
|
||||
.enable_custom_integers(params, None)
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(params, None)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ init_panic_hook();
|
||||
|
||||
|
||||
test('hlapi_client_key_encrypt_decrypt_int8_big', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
@@ -58,8 +57,7 @@ test('hlapi_client_key_encrypt_decrypt_int8_big', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_compressed_public_client_int8_big', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
@@ -82,11 +80,9 @@ test('hlapi_compressed_public_client_int8_big', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_public_key_encrypt_decrypt_int32_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
let config = TfheConfigBuilder.default_with_small_encryption()
|
||||
.build();
|
||||
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
let publicKey = TfhePublicKey.new(clientKey);
|
||||
|
||||
@@ -106,8 +102,7 @@ test('hlapi_public_key_encrypt_decrypt_int32_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_decompress_public_key_then_encrypt_decrypt_int32_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
let config = TfheConfigBuilder.default_with_small_encryption()
|
||||
.build();
|
||||
|
||||
|
||||
@@ -141,8 +136,7 @@ test('hlapi_decompress_public_key_then_encrypt_decrypt_int32_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_client_key_encrypt_decrypt_int128_big', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
@@ -179,11 +173,9 @@ test('hlapi_client_key_encrypt_decrypt_int128_big', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_client_key_encrypt_decrypt_int128_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
let config = TfheConfigBuilder.default_with_small_encryption()
|
||||
.build();
|
||||
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
|
||||
let encrypted = FheInt128.encrypt_with_client_key(I128_MIN, clientKey);
|
||||
@@ -218,8 +210,7 @@ test('hlapi_client_key_encrypt_decrypt_int128_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_client_key_encrypt_decrypt_int256_big', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
|
||||
@@ -268,8 +259,7 @@ test('hlapi_client_key_encrypt_decrypt_int256_big', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_client_key_encrypt_decrypt_int256_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
let config = TfheConfigBuilder.default_with_small_encryption()
|
||||
.build();
|
||||
|
||||
|
||||
@@ -316,8 +306,7 @@ test('hlapi_client_key_encrypt_decrypt_int256_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_decompress_public_key_then_encrypt_decrypt_int256_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
let config = TfheConfigBuilder.default_with_small_encryption()
|
||||
.build();
|
||||
|
||||
|
||||
@@ -342,10 +331,7 @@ test('hlapi_decompress_public_key_then_encrypt_decrypt_int256_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_public_key_encrypt_decrypt_int256_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
.build();
|
||||
|
||||
let config = TfheConfigBuilder.default_with_small_encryption().build();
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
let publicKey = TfhePublicKey.new(clientKey);
|
||||
@@ -392,8 +378,8 @@ function hlapi_compact_public_key_encrypt_decrypt_int32_single(config) {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int32_big_single', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int32_single(config);
|
||||
@@ -401,8 +387,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_int32_big_single', (t) => {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int32_small_single', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int32_single(config);
|
||||
@@ -430,8 +416,8 @@ function hlapi_compact_public_key_encrypt_decrypt_int32_single_compact(config) {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int32_small_single_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int32_single_compact(config);
|
||||
@@ -439,8 +425,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_int32_small_single_compact', (t)
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int32_big_single_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int32_single_compact(config);
|
||||
@@ -478,8 +464,8 @@ function hlapi_compact_public_key_encrypt_decrypt_int32_list_compact(config) {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int32_small_list_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int32_list_compact(config);
|
||||
@@ -487,8 +473,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_int32_small_list_compact', (t) =>
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int32_big_list_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int32_list_compact(config);
|
||||
@@ -520,8 +506,8 @@ function hlapi_compact_public_key_encrypt_decrypt_int256_single(config) {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int256_big_single', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int256_single(config);
|
||||
@@ -529,8 +515,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_int256_big_single', (t) => {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int256_small_single', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int256_single(config);
|
||||
@@ -558,8 +544,8 @@ function hlapi_compact_public_key_encrypt_decrypt_int256_single_compact(config)
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int256_small_single_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int256_single_compact(config);
|
||||
@@ -567,8 +553,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_int256_small_single_compact', (t)
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int256_big_single_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int256_single_compact(config);
|
||||
@@ -606,8 +592,8 @@ function hlapi_compact_public_key_encrypt_decrypt_int256_list_compact(config) {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int256_small_list_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int256_list_compact(config);
|
||||
@@ -615,8 +601,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_int256_small_list_compact', (t) =
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_int256_big_list_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_int256_list_compact(config);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert').strict;
|
||||
const { performance } = require('perf_hooks');
|
||||
const {performance} = require('perf_hooks');
|
||||
const {
|
||||
init_panic_hook,
|
||||
ShortintParametersName,
|
||||
@@ -40,7 +40,7 @@ init_panic_hook();
|
||||
// but we try to use them, so an error should be returned
|
||||
// as the underlying panic should have been trapped
|
||||
test('hlapi_panic', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
@@ -58,8 +58,7 @@ test('hlapi_panic', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_key_gen_big', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
|
||||
@@ -77,11 +76,9 @@ test('hlapi_key_gen_big', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_key_gen_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
let config = TfheConfigBuilder.default_with_small_encryption()
|
||||
.build();
|
||||
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
let compressedServerKey = TfheCompressedServerKey.new(clientKey);
|
||||
let publicKey = TfhePublicKey.new(clientKey);
|
||||
@@ -92,8 +89,7 @@ test('hlapi_key_gen_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_client_key_encrypt_decrypt_uint8_big', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
|
||||
@@ -116,8 +112,7 @@ test('hlapi_client_key_encrypt_decrypt_uint8_big', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_compressed_public_client_uint8_big', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
@@ -140,9 +135,7 @@ test('hlapi_compressed_public_client_uint8_big', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_public_key_encrypt_decrypt_uint32_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
.build();
|
||||
let config = TfheConfigBuilder.default_with_small_encryption().build();
|
||||
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
@@ -164,9 +157,7 @@ test('hlapi_public_key_encrypt_decrypt_uint32_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_decompress_public_key_then_encrypt_decrypt_uint32_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
.build();
|
||||
let config = TfheConfigBuilder.default_with_small_encryption().build();
|
||||
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
@@ -199,8 +190,7 @@ test('hlapi_decompress_public_key_then_encrypt_decrypt_uint32_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_client_key_encrypt_decrypt_uint128_big', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
|
||||
@@ -238,9 +228,7 @@ test('hlapi_client_key_encrypt_decrypt_uint128_big', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_client_key_encrypt_decrypt_uint128_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
.build();
|
||||
let config = TfheConfigBuilder.default_with_small_encryption().build();
|
||||
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
@@ -277,8 +265,7 @@ test('hlapi_client_key_encrypt_decrypt_uint128_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_client_key_encrypt_decrypt_uint256_big', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers()
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
|
||||
@@ -316,9 +303,7 @@ test('hlapi_client_key_encrypt_decrypt_uint256_big', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_client_key_encrypt_decrypt_uint256_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
.build();
|
||||
let config = TfheConfigBuilder.default_with_small_encryption().build();
|
||||
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
@@ -355,9 +340,7 @@ test('hlapi_client_key_encrypt_decrypt_uint256_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_decompress_public_key_then_encrypt_decrypt_uint256_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
.build();
|
||||
let config = TfheConfigBuilder.default_with_small_encryption().build();
|
||||
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
@@ -381,10 +364,7 @@ test('hlapi_decompress_public_key_then_encrypt_decrypt_uint256_small', (t) => {
|
||||
});
|
||||
|
||||
test('hlapi_public_key_encrypt_decrypt_uint256_small', (t) => {
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_default_integers_small()
|
||||
.build();
|
||||
|
||||
let config = TfheConfigBuilder.default_with_small_encryption().build();
|
||||
|
||||
let clientKey = TfheClientKey.generate(config);
|
||||
let publicKey = TfhePublicKey.new(clientKey);
|
||||
@@ -405,7 +385,6 @@ test('hlapi_public_key_encrypt_decrypt_uint256_small', (t) => {
|
||||
});
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// 32 bits compact
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -431,8 +410,8 @@ function hlapi_compact_public_key_encrypt_decrypt_uint32_single(config) {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint32_big_single', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint32_single(config);
|
||||
@@ -440,8 +419,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_uint32_big_single', (t) => {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint32_small_single', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint32_single(config);
|
||||
@@ -469,8 +448,8 @@ function hlapi_compact_public_key_encrypt_decrypt_uint32_single_compact(config)
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint32_small_single_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint32_single_compact(config);
|
||||
@@ -478,8 +457,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_uint32_small_single_compact', (t)
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint32_big_single_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint32_single_compact(config);
|
||||
@@ -517,8 +496,8 @@ function hlapi_compact_public_key_encrypt_decrypt_uint32_list_compact(config) {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint32_small_list_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint32_list_compact(config);
|
||||
@@ -526,8 +505,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_uint32_small_list_compact', (t) =
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint32_big_list_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint32_list_compact(config);
|
||||
@@ -559,8 +538,8 @@ function hlapi_compact_public_key_encrypt_decrypt_uint256_single(config) {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint256_big_single', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint256_single(config);
|
||||
@@ -568,8 +547,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_uint256_big_single', (t) => {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint256_small_single', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint256_single(config);
|
||||
@@ -597,8 +576,8 @@ function hlapi_compact_public_key_encrypt_decrypt_uint256_single_compact(config)
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint256_small_single_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint256_single_compact(config);
|
||||
@@ -606,8 +585,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_uint256_small_single_compact', (t
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint256_big_single_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint256_single_compact(config);
|
||||
@@ -645,8 +624,8 @@ function hlapi_compact_public_key_encrypt_decrypt_uint256_list_compact(config) {
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint256_small_list_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint256_list_compact(config);
|
||||
@@ -654,8 +633,8 @@ test('hlapi_compact_public_key_encrypt_decrypt_uint256_small_list_compact', (t)
|
||||
|
||||
test('hlapi_compact_public_key_encrypt_decrypt_uint256_big_list_compact', (t) => {
|
||||
const block_params = new ShortintParameters(ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS);
|
||||
let config = TfheConfigBuilder.all_disabled()
|
||||
.enable_custom_integers(block_params)
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
.build();
|
||||
|
||||
hlapi_compact_public_key_encrypt_decrypt_uint256_list_compact(config);
|
||||
|
||||
@@ -131,7 +131,7 @@ impl ClientKey {
|
||||
/// let cks = ClientKey::new(&PARAMETERS_ERROR_PROB_2_POW_MINUS_165);
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn new(parameter_set: &BooleanParameters) -> ClientKey {
|
||||
pub fn new(parameter_set: &BooleanParameters) -> Self {
|
||||
BooleanEngine::with_thread_local_mut(|engine| engine.create_client_key(*parameter_set))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ pub(crate) struct Bootstrapper {
|
||||
|
||||
impl Bootstrapper {
|
||||
pub fn new(seeder: &mut dyn Seeder) -> Self {
|
||||
Bootstrapper {
|
||||
Self {
|
||||
memory: Default::default(),
|
||||
encryption_generator: EncryptionRandomGenerator::<_>::new(seeder.seed(), seeder),
|
||||
computation_buffers: Default::default(),
|
||||
|
||||
@@ -74,8 +74,8 @@ impl BooleanParameters {
|
||||
ks_base_log: DecompositionBaseLog,
|
||||
ks_level: DecompositionLevelCount,
|
||||
encryption_key_choice: EncryptionKeyChoice,
|
||||
) -> BooleanParameters {
|
||||
BooleanParameters {
|
||||
) -> Self {
|
||||
Self {
|
||||
lwe_dimension,
|
||||
glwe_dimension,
|
||||
polynomial_size,
|
||||
@@ -91,7 +91,7 @@ impl BooleanParameters {
|
||||
}
|
||||
|
||||
/// A set of cryptographic parameters for homomorphic Boolean key switching.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct BooleanKeySwitchingParameters {
|
||||
pub ks_base_log: DecompositionBaseLog,
|
||||
pub ks_level: DecompositionLevelCount,
|
||||
@@ -106,11 +106,8 @@ impl BooleanKeySwitchingParameters {
|
||||
/// Unless you are a cryptographer who really knows the impact of each of those parameters,
|
||||
/// you __must__ stick with the provided parameters (if any), which both offer correct
|
||||
/// results with 128 bits of security.
|
||||
pub fn new(
|
||||
ks_base_log: DecompositionBaseLog,
|
||||
ks_level: DecompositionLevelCount,
|
||||
) -> BooleanKeySwitchingParameters {
|
||||
BooleanKeySwitchingParameters {
|
||||
pub fn new(ks_base_log: DecompositionBaseLog, ks_level: DecompositionLevelCount) -> Self {
|
||||
Self {
|
||||
ks_level,
|
||||
ks_base_log,
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ impl PublicKey {
|
||||
/// let pks = PublicKey::new(&cks);
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn new(client_key: &ClientKey) -> PublicKey {
|
||||
pub fn new(client_key: &ClientKey) -> Self {
|
||||
BooleanEngine::with_thread_local_mut(|engine| engine.create_public_key(client_key))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,40 +47,40 @@ mod implementation {
|
||||
|
||||
impl<Lhs, Rhs> BinaryBooleanGates<Lhs, Rhs> for ServerKey
|
||||
where
|
||||
<ServerKey as DefaultImplementation>::Engine: BinaryGatesEngine<Lhs, Rhs, ServerKey>,
|
||||
<Self as DefaultImplementation>::Engine: BinaryGatesEngine<Lhs, Rhs, Self>,
|
||||
{
|
||||
fn and(&self, ct_left: Lhs, ct_right: Rhs) -> Ciphertext {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.and(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
fn nand(&self, ct_left: Lhs, ct_right: Rhs) -> Ciphertext {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.nand(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
fn nor(&self, ct_left: Lhs, ct_right: Rhs) -> Ciphertext {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.nor(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
fn or(&self, ct_left: Lhs, ct_right: Rhs) -> Ciphertext {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.or(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
fn xor(&self, ct_left: Lhs, ct_right: Rhs) -> Ciphertext {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.xor(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
fn xnor(&self, ct_left: Lhs, ct_right: Rhs) -> Ciphertext {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.xnor(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
@@ -88,40 +88,40 @@ where
|
||||
|
||||
impl<Lhs, Rhs> BinaryBooleanGatesAssign<Lhs, Rhs> for ServerKey
|
||||
where
|
||||
<ServerKey as DefaultImplementation>::Engine: BinaryGatesAssignEngine<Lhs, Rhs, ServerKey>,
|
||||
<Self as DefaultImplementation>::Engine: BinaryGatesAssignEngine<Lhs, Rhs, Self>,
|
||||
{
|
||||
fn and_assign(&self, ct_left: Lhs, ct_right: Rhs) {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.and_assign(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
fn nand_assign(&self, ct_left: Lhs, ct_right: Rhs) {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.nand_assign(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
fn nor_assign(&self, ct_left: Lhs, ct_right: Rhs) {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.nor_assign(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
fn or_assign(&self, ct_left: Lhs, ct_right: Rhs) {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.or_assign(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
fn xor_assign(&self, ct_left: Lhs, ct_right: Rhs) {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.xor_assign(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
fn xnor_assign(&self, ct_left: Lhs, ct_right: Rhs) {
|
||||
<ServerKey as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
<Self as DefaultImplementation>::Engine::with_thread_local_mut(|engine| {
|
||||
engine.xnor_assign(ct_left, ct_right, self)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,12 +15,8 @@ impl From<BooleanEncryptionKeyChoice>
|
||||
{
|
||||
fn from(value: BooleanEncryptionKeyChoice) -> Self {
|
||||
match value {
|
||||
BooleanEncryptionKeyChoice::BooleanEncryptionKeyChoiceBig => {
|
||||
crate::core_crypto::commons::parameters::EncryptionKeyChoice::Big
|
||||
}
|
||||
BooleanEncryptionKeyChoice::BooleanEncryptionKeyChoiceSmall => {
|
||||
crate::core_crypto::commons::parameters::EncryptionKeyChoice::Small
|
||||
}
|
||||
BooleanEncryptionKeyChoice::BooleanEncryptionKeyChoiceBig => Self::Big,
|
||||
BooleanEncryptionKeyChoice::BooleanEncryptionKeyChoiceSmall => Self::Small,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::high_level_api::prelude::*;
|
||||
|
||||
use std::ops::{BitAnd, BitOr, BitXor, Not};
|
||||
|
||||
pub struct FheBool(crate::high_level_api::FheBool);
|
||||
pub struct FheBool(pub(in crate::c_api) crate::high_level_api::FheBool);
|
||||
|
||||
impl_destroy_on_type!(FheBool);
|
||||
impl_clone_on_type!(FheBool);
|
||||
|
||||
@@ -8,16 +8,40 @@ impl_destroy_on_type!(ConfigBuilder);
|
||||
impl_destroy_on_type!(Config);
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn config_builder_all_disabled(result: *mut *mut ConfigBuilder) -> c_int {
|
||||
pub unsafe extern "C" fn config_builder_default(result: *mut *mut ConfigBuilder) -> c_int {
|
||||
catch_panic(|| {
|
||||
check_ptr_is_non_null_and_aligned(result).unwrap();
|
||||
|
||||
let inner_builder = crate::high_level_api::ConfigBuilder::all_disabled();
|
||||
let inner_builder = crate::high_level_api::ConfigBuilder::default();
|
||||
|
||||
*result = Box::into_raw(Box::new(ConfigBuilder(inner_builder)));
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn config_builder_default_with_small_encryption(
|
||||
builder: *mut *mut ConfigBuilder,
|
||||
) -> c_int {
|
||||
catch_panic(|| {
|
||||
check_ptr_is_non_null_and_aligned(builder).unwrap();
|
||||
|
||||
let inner_builder = crate::high_level_api::ConfigBuilder::default_with_small_encryption();
|
||||
*builder = Box::into_raw(Box::new(ConfigBuilder(inner_builder)));
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn config_builder_default_with_big_encryption(
|
||||
builder: *mut *mut ConfigBuilder,
|
||||
) -> c_int {
|
||||
catch_panic(|| {
|
||||
check_ptr_is_non_null_and_aligned(builder).unwrap();
|
||||
|
||||
let inner_builder = crate::high_level_api::ConfigBuilder::default_with_big_encryption();
|
||||
*builder = Box::into_raw(Box::new(ConfigBuilder(inner_builder)));
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn config_builder_clone(
|
||||
input: *const ConfigBuilder,
|
||||
@@ -32,61 +56,23 @@ pub unsafe extern "C" fn config_builder_clone(
|
||||
})
|
||||
}
|
||||
|
||||
macro_rules! define_enable_default_fn(
|
||||
($type_name:ident) => {
|
||||
::paste::paste!{
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn [<config_builder_enable_default_ $type_name>](
|
||||
builder: *mut *mut ConfigBuilder,
|
||||
) -> ::std::os::raw::c_int {
|
||||
catch_panic(|| {
|
||||
check_ptr_is_non_null_and_aligned(builder).unwrap();
|
||||
|
||||
let inner = Box::from_raw(*builder).0.[<enable_default_ $type_name>]();
|
||||
*builder = Box::into_raw(Box::new(ConfigBuilder(inner)));
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
($type_name:ident @small) => {
|
||||
::paste::paste!{
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn [<config_builder_enable_default_ $type_name _small>](
|
||||
builder: *mut *mut ConfigBuilder,
|
||||
) -> ::std::os::raw::c_int {
|
||||
catch_panic(|| {
|
||||
check_ptr_is_non_null_and_aligned(builder).unwrap();
|
||||
|
||||
let inner = Box::from_raw(*builder).0.[<enable_default_ $type_name _small>]();
|
||||
*builder = Box::into_raw(Box::new(ConfigBuilder(inner)));
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
#[cfg(feature = "boolean")]
|
||||
define_enable_default_fn!(bool);
|
||||
#[cfg(feature = "integer")]
|
||||
define_enable_default_fn!(integers);
|
||||
#[cfg(feature = "integer")]
|
||||
define_enable_default_fn!(integers @small);
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn config_builder_enable_custom_integers(
|
||||
pub unsafe extern "C" fn config_builder_use_custom_parameters(
|
||||
builder: *mut *mut ConfigBuilder,
|
||||
shortint_block_parameters: crate::c_api::shortint::parameters::ShortintPBSParameters,
|
||||
) -> ::std::os::raw::c_int {
|
||||
) -> c_int {
|
||||
catch_panic(|| {
|
||||
check_ptr_is_non_null_and_aligned(builder).unwrap();
|
||||
|
||||
let params: crate::shortint::ClassicPBSParameters = shortint_block_parameters.into();
|
||||
let params: crate::shortint::ClassicPBSParameters =
|
||||
shortint_block_parameters.try_into().unwrap();
|
||||
let inner = Box::from_raw(*builder)
|
||||
.0
|
||||
.enable_custom_integers(params, None);
|
||||
.use_custom_parameters(params, None);
|
||||
*builder = Box::into_raw(Box::new(ConfigBuilder(inner)));
|
||||
})
|
||||
}
|
||||
|
||||
/// Takes ownership of the builder
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn config_builder_build(
|
||||
|
||||
@@ -17,6 +17,6 @@ impl From<i128> for I128 {
|
||||
|
||||
impl From<I128> for i128 {
|
||||
fn from(value: I128) -> Self {
|
||||
((value.w1 as i128) << 64u128) | value.w0 as i128
|
||||
((value.w1 as Self) << 64u128) | value.w0 as Self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::ops::{
|
||||
Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign,
|
||||
};
|
||||
|
||||
use crate::c_api::high_level_api::booleans::FheBool;
|
||||
use crate::c_api::high_level_api::i128::I128;
|
||||
use crate::c_api::high_level_api::i256::I256;
|
||||
use crate::c_api::high_level_api::u128::U128;
|
||||
@@ -33,18 +34,26 @@ macro_rules! impl_operations_for_integer_type {
|
||||
bitand,
|
||||
bitor,
|
||||
bitxor,
|
||||
eq,
|
||||
ne,
|
||||
ge,
|
||||
gt,
|
||||
le,
|
||||
lt,
|
||||
min,
|
||||
max,
|
||||
div,
|
||||
rem,
|
||||
);
|
||||
|
||||
// Handle comparisons separately as they return FheBool
|
||||
impl_comparison_fn_on_type!(
|
||||
lhs_type: $name,
|
||||
rhs_type: $name,
|
||||
comparison_fn_names: eq, ne, ge, gt, le, lt,
|
||||
);
|
||||
|
||||
// Handle comparisons separately as they return FheBool
|
||||
impl_scalar_comparison_fn_on_type!(
|
||||
lhs_type: $name,
|
||||
clear_type: $clear_scalar_type,
|
||||
comparison_fn_names: eq, ne, ge, gt, le, lt,
|
||||
);
|
||||
|
||||
// handle shift separately as they require
|
||||
// rhs to be an unsigned type
|
||||
impl_binary_fn_on_type!(
|
||||
@@ -79,12 +88,6 @@ macro_rules! impl_operations_for_integer_type {
|
||||
bitand,
|
||||
bitor,
|
||||
bitxor,
|
||||
eq,
|
||||
ne,
|
||||
ge,
|
||||
gt,
|
||||
le,
|
||||
lt,
|
||||
min,
|
||||
max,
|
||||
div,
|
||||
@@ -165,10 +168,12 @@ macro_rules! impl_operations_for_integer_type {
|
||||
}
|
||||
}
|
||||
|
||||
// Even though if_then_else/cmux is a method of FheBool, it still takes as
|
||||
// integers inputs, so its easier to keep the definition here
|
||||
::paste::paste! {
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn [<$name:snake _if_then_else>](
|
||||
condition_ct: *const $name,
|
||||
condition_ct: *const FheBool,
|
||||
then_ct: *const $name,
|
||||
else_ct: *const $name,
|
||||
result: *mut *mut $name,
|
||||
@@ -186,7 +191,7 @@ macro_rules! impl_operations_for_integer_type {
|
||||
|
||||
// map cmux to if_then_else
|
||||
pub unsafe extern "C" fn [<$name:snake _cmux>](
|
||||
condition_ct: *const $name,
|
||||
condition_ct: *const FheBool,
|
||||
then_ct: *const $name,
|
||||
else_ct: *const $name,
|
||||
result: *mut *mut $name,
|
||||
|
||||
@@ -52,13 +52,20 @@ pub unsafe extern "C" fn set_server_key(server_key: *const ServerKey) -> c_int {
|
||||
}
|
||||
|
||||
/// result can be null
|
||||
///
|
||||
/// `result` may be set to null if no previous server key was set
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn unset_server_key(result: *mut *mut ServerKey) -> c_int {
|
||||
catch_panic(|| {
|
||||
let previous_key = crate::high_level_api::unset_server_key();
|
||||
|
||||
if !result.is_null() {
|
||||
*result = Box::into_raw(Box::new(ServerKey(previous_key)))
|
||||
match previous_key {
|
||||
None => {
|
||||
*result = std::ptr::null_mut();
|
||||
}
|
||||
Some(key) => *result = Box::into_raw(Box::new(ServerKey(key))),
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ impl From<u128> for U128 {
|
||||
|
||||
impl From<U128> for u128 {
|
||||
fn from(value: U128) -> Self {
|
||||
((value.w1 as u128) << 64u128) | value.w0 as u128
|
||||
((value.w1 as Self) << 64u128) | value.w0 as Self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,13 +366,76 @@ macro_rules! impl_binary_fn_on_type {
|
||||
// Usual binary fn case, where lhs, rhs and result are all of the same type
|
||||
($wrapper_type:ty => $($binary_fn_name:ident),* $(,)?) => {
|
||||
impl_binary_fn_on_type!(
|
||||
lhs_type: $wrapper_type,
|
||||
lhs_type: $wrapper_type,
|
||||
rhs_type: $wrapper_type,
|
||||
binary_fn_names: $($binary_fn_name),*
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
// Comparisons returns FheBool so we use a specialized
|
||||
// macro for them
|
||||
macro_rules! impl_comparison_fn_on_type {
|
||||
(
|
||||
lhs_type: $lhs_type:ty,
|
||||
rhs_type: $rhs_type:ty,
|
||||
comparison_fn_names: $($comparison_fn_name:ident),*
|
||||
$(,)?
|
||||
) => {
|
||||
$( // unroll comparison_fn_names
|
||||
::paste::paste! {
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn [<$lhs_type:snake _ $comparison_fn_name>](
|
||||
lhs: *const $lhs_type,
|
||||
rhs: *const $rhs_type,
|
||||
result: *mut *mut $crate::c_api::high_level_api::booleans::FheBool,
|
||||
) -> ::std::os::raw::c_int {
|
||||
$crate::c_api::utils::catch_panic(|| {
|
||||
let lhs = $crate::c_api::utils::get_ref_checked(lhs).unwrap();
|
||||
let rhs = $crate::c_api::utils::get_ref_checked(rhs).unwrap();
|
||||
|
||||
let inner = (&lhs.0).$comparison_fn_name(&rhs.0);
|
||||
|
||||
let inner = $crate::c_api::high_level_api::booleans::FheBool(inner);
|
||||
*result = Box::into_raw(Box::new(inner));
|
||||
})
|
||||
}
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! impl_scalar_comparison_fn_on_type {
|
||||
(
|
||||
lhs_type: $lhs_type:ty,
|
||||
clear_type: $scalar_type:ty,
|
||||
comparison_fn_names: $($comparison_fn_name:ident),*
|
||||
$(,)?
|
||||
) => {
|
||||
$( // unroll comparison_fn_names
|
||||
::paste::paste! {
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn [<$lhs_type:snake _scalar_ $comparison_fn_name>](
|
||||
lhs: *const $lhs_type,
|
||||
rhs: $scalar_type,
|
||||
result: *mut *mut $crate::c_api::high_level_api::booleans::FheBool,
|
||||
) -> ::std::os::raw::c_int {
|
||||
$crate::c_api::utils::catch_panic(|| {
|
||||
let lhs = $crate::c_api::utils::get_ref_checked(lhs).unwrap();
|
||||
let rhs = <$scalar_type as $crate::c_api::high_level_api::utils::CApiIntegerType>::to_rust(rhs);
|
||||
|
||||
|
||||
let inner = (&lhs.0).$comparison_fn_name(rhs);
|
||||
|
||||
let inner = $crate::c_api::high_level_api::booleans::FheBool(inner);
|
||||
*result = Box::into_raw(Box::new(inner));
|
||||
})
|
||||
}
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! impl_unary_fn_on_type {
|
||||
($wrapper_type:ty => $($unary_fn_name:ident),* $(,)?) => {
|
||||
$(
|
||||
|
||||
@@ -20,7 +20,7 @@ pub unsafe extern "C" fn shortint_gen_client_key(
|
||||
*result_client_key = std::ptr::null_mut();
|
||||
|
||||
let shortint_parameters: crate::shortint::parameters::ClassicPBSParameters =
|
||||
shortint_parameters.into();
|
||||
shortint_parameters.try_into().unwrap();
|
||||
|
||||
let client_key = shortint::client_key::ClientKey::new(shortint_parameters);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ pub unsafe extern "C" fn shortint_gen_keys_with_parameters(
|
||||
*result_server_key = std::ptr::null_mut();
|
||||
|
||||
let shortint_parameters: crate::shortint::parameters::ClassicPBSParameters =
|
||||
shortint_parameters.into();
|
||||
shortint_parameters.try_into().unwrap();
|
||||
|
||||
let client_key = shortint::client_key::ClientKey::new(shortint_parameters);
|
||||
let server_key = shortint::server_key::ServerKey::new(&client_key);
|
||||
|
||||
@@ -7,8 +7,6 @@ pub use crate::shortint::parameters::parameters_compact_pk::*;
|
||||
pub use crate::shortint::parameters::*;
|
||||
use std::os::raw::c_int;
|
||||
|
||||
use crate::shortint;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum ShortintEncryptionKeyChoice {
|
||||
@@ -19,12 +17,8 @@ pub enum ShortintEncryptionKeyChoice {
|
||||
impl From<ShortintEncryptionKeyChoice> for crate::shortint::parameters::EncryptionKeyChoice {
|
||||
fn from(value: ShortintEncryptionKeyChoice) -> Self {
|
||||
match value {
|
||||
ShortintEncryptionKeyChoice::ShortintEncryptionKeyChoiceBig => {
|
||||
shortint::parameters::EncryptionKeyChoice::Big
|
||||
}
|
||||
ShortintEncryptionKeyChoice::ShortintEncryptionKeyChoiceSmall => {
|
||||
shortint::parameters::EncryptionKeyChoice::Small
|
||||
}
|
||||
ShortintEncryptionKeyChoice::ShortintEncryptionKeyChoiceBig => Self::Big,
|
||||
ShortintEncryptionKeyChoice::ShortintEncryptionKeyChoiceSmall => Self::Small,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,9 +41,11 @@ pub struct ShortintPBSParameters {
|
||||
pub encryption_key_choice: ShortintEncryptionKeyChoice,
|
||||
}
|
||||
|
||||
impl From<ShortintPBSParameters> for crate::shortint::ClassicPBSParameters {
|
||||
fn from(c_params: ShortintPBSParameters) -> Self {
|
||||
Self {
|
||||
impl TryFrom<ShortintPBSParameters> for crate::shortint::ClassicPBSParameters {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(c_params: ShortintPBSParameters) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
lwe_dimension: LweDimension(c_params.lwe_dimension),
|
||||
glwe_dimension: GlweDimension(c_params.glwe_dimension),
|
||||
polynomial_size: PolynomialSize(c_params.polynomial_size),
|
||||
@@ -63,10 +59,9 @@ impl From<ShortintPBSParameters> for crate::shortint::ClassicPBSParameters {
|
||||
carry_modulus: crate::shortint::parameters::CarryModulus(c_params.carry_modulus),
|
||||
ciphertext_modulus: crate::shortint::parameters::CiphertextModulus::try_new_power_of_2(
|
||||
c_params.modulus_power_of_2_exponent,
|
||||
)
|
||||
.unwrap(),
|
||||
)?,
|
||||
encryption_key_choice: c_params.encryption_key_choice.into(),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +144,7 @@ macro_rules! expose_as_shortint_pbs_parameters(
|
||||
{
|
||||
let rust_params = crate::shortint::parameters::$param_name;
|
||||
let c_params = ShortintPBSParameters::from(rust_params);
|
||||
let rust_params_from_c = crate::shortint::parameters::ClassicPBSParameters::from(c_params);
|
||||
let rust_params_from_c = crate::shortint::parameters::ClassicPBSParameters::try_from(c_params).unwrap();
|
||||
assert_eq!(rust_params, rust_params_from_c);
|
||||
}
|
||||
)*
|
||||
|
||||
@@ -119,7 +119,7 @@ pub unsafe extern "C" fn shortint_server_key_generate_bivariate_pbs_lookup_table
|
||||
pub unsafe extern "C" fn shortint_server_key_bivariate_programmable_bootstrap(
|
||||
server_key: *const ShortintServerKey,
|
||||
lookup_table: *const ShortintBivariatePBSLookupTable,
|
||||
ct_left: *const ShortintCiphertext,
|
||||
ct_left: *mut ShortintCiphertext,
|
||||
ct_right: *mut ShortintCiphertext,
|
||||
result: *mut *mut ShortintCiphertext,
|
||||
) -> c_int {
|
||||
@@ -132,18 +132,16 @@ pub unsafe extern "C" fn shortint_server_key_bivariate_programmable_bootstrap(
|
||||
|
||||
let server_key = get_ref_checked(server_key).unwrap();
|
||||
let lookup_table = get_ref_checked(lookup_table).unwrap();
|
||||
let ct_left = get_ref_checked(ct_left).unwrap();
|
||||
let ct_left = get_mut_checked(ct_left).unwrap();
|
||||
let ct_right = get_mut_checked(ct_right).unwrap();
|
||||
|
||||
let res = crate::shortint::engine::ShortintEngine::with_thread_local_mut(|engine| {
|
||||
engine
|
||||
.smart_apply_lookup_table_bivariate(
|
||||
&server_key.0,
|
||||
&ct_left.0,
|
||||
&mut ct_right.0,
|
||||
&lookup_table.0,
|
||||
)
|
||||
.unwrap()
|
||||
engine.smart_apply_lookup_table_bivariate(
|
||||
&server_key.0,
|
||||
&mut ct_left.0,
|
||||
&mut ct_right.0,
|
||||
&lookup_table.0,
|
||||
)
|
||||
});
|
||||
|
||||
let heap_allocated_result = Box::new(ShortintCiphertext(res));
|
||||
@@ -166,14 +164,12 @@ pub unsafe extern "C" fn shortint_server_key_bivariate_programmable_bootstrap_as
|
||||
let ct_right = get_mut_checked(ct_right).unwrap();
|
||||
|
||||
crate::shortint::engine::ShortintEngine::with_thread_local_mut(|engine| {
|
||||
engine
|
||||
.smart_apply_lookup_table_bivariate_assign(
|
||||
&server_key.0,
|
||||
&mut ct_left_and_result.0,
|
||||
&mut ct_right.0,
|
||||
&lookup_table.0,
|
||||
)
|
||||
.unwrap()
|
||||
engine.smart_apply_lookup_table_bivariate_assign(
|
||||
&server_key.0,
|
||||
&mut ct_left_and_result.0,
|
||||
&mut ct_right.0,
|
||||
&lookup_table.0,
|
||||
)
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
@@ -19,21 +19,18 @@ pub struct ListSizeConstraint {
|
||||
}
|
||||
|
||||
impl ListSizeConstraint {
|
||||
pub fn exact_size(size: usize) -> ListSizeConstraint {
|
||||
ListSizeConstraint {
|
||||
pub fn exact_size(size: usize) -> Self {
|
||||
Self {
|
||||
min_inclusive_group_count: size,
|
||||
max_inclusive_group_count: size,
|
||||
group_size: 1,
|
||||
}
|
||||
}
|
||||
pub fn try_size_in_range(
|
||||
min_inclusive: usize,
|
||||
max_inclusive: usize,
|
||||
) -> Result<ListSizeConstraint, String> {
|
||||
pub fn try_size_in_range(min_inclusive: usize, max_inclusive: usize) -> Result<Self, String> {
|
||||
if max_inclusive < min_inclusive {
|
||||
return Err("max_inclusive < min_inclusive".to_owned());
|
||||
}
|
||||
Ok(ListSizeConstraint {
|
||||
Ok(Self {
|
||||
min_inclusive_group_count: min_inclusive,
|
||||
max_inclusive_group_count: max_inclusive,
|
||||
group_size: 1,
|
||||
@@ -43,11 +40,11 @@ impl ListSizeConstraint {
|
||||
group_size: usize,
|
||||
min_inclusive_group_count: usize,
|
||||
max_inclusive_group_count: usize,
|
||||
) -> Result<ListSizeConstraint, String> {
|
||||
) -> Result<Self, String> {
|
||||
if max_inclusive_group_count < min_inclusive_group_count {
|
||||
return Err("max_inclusive < min_inclusive".to_owned());
|
||||
}
|
||||
Ok(ListSizeConstraint {
|
||||
Ok(Self {
|
||||
min_inclusive_group_count,
|
||||
max_inclusive_group_count,
|
||||
group_size,
|
||||
@@ -55,7 +52,7 @@ impl ListSizeConstraint {
|
||||
}
|
||||
|
||||
pub fn multiply_group_size(&self, group_size_multiplier: usize) -> Self {
|
||||
ListSizeConstraint {
|
||||
Self {
|
||||
min_inclusive_group_count: self.min_inclusive_group_count,
|
||||
max_inclusive_group_count: self.max_inclusive_group_count,
|
||||
group_size: self.group_size * group_size_multiplier,
|
||||
|
||||
@@ -320,17 +320,14 @@ fn encrypt_constant_ggsw_level_matrix_row<Scalar, KeyCont, OutputCont, Gen>(
|
||||
body.as_mut().copy_from_slice(sk_poly.as_ref());
|
||||
|
||||
slice_wrapping_scalar_mul_assign(body.as_mut(), factor);
|
||||
|
||||
encrypt_glwe_ciphertext_assign(glwe_secret_key, row_as_glwe, noise_parameters, generator);
|
||||
} else {
|
||||
// The last row needs a slightly different treatment
|
||||
let mut body = row_as_glwe.get_mut_body();
|
||||
|
||||
body.as_mut().fill(Scalar::ZERO);
|
||||
body.as_mut()[0] = factor.wrapping_neg();
|
||||
|
||||
encrypt_glwe_ciphertext_assign(glwe_secret_key, row_as_glwe, noise_parameters, generator);
|
||||
}
|
||||
encrypt_glwe_ciphertext_assign(glwe_secret_key, row_as_glwe, noise_parameters, generator);
|
||||
}
|
||||
|
||||
/// Convenience function to share the core logic of the seeded GGSW encryption between all
|
||||
@@ -717,27 +714,19 @@ fn encrypt_constant_seeded_ggsw_level_matrix_row<Scalar, KeyCont, OutputCont, Ge
|
||||
body.as_mut().copy_from_slice(sk_poly.as_ref());
|
||||
|
||||
slice_wrapping_scalar_mul_assign(body.as_mut(), factor);
|
||||
|
||||
encrypt_seeded_glwe_ciphertext_assign_with_existing_generator(
|
||||
glwe_secret_key,
|
||||
row_as_glwe,
|
||||
noise_parameters,
|
||||
generator,
|
||||
);
|
||||
} else {
|
||||
// The last row needs a slightly different treatment
|
||||
let mut body = row_as_glwe.get_mut_body();
|
||||
|
||||
body.as_mut().fill(Scalar::ZERO);
|
||||
body.as_mut()[0] = factor.wrapping_neg();
|
||||
|
||||
encrypt_seeded_glwe_ciphertext_assign_with_existing_generator(
|
||||
glwe_secret_key,
|
||||
row_as_glwe,
|
||||
noise_parameters,
|
||||
generator,
|
||||
);
|
||||
}
|
||||
encrypt_seeded_glwe_ciphertext_assign_with_existing_generator(
|
||||
glwe_secret_key,
|
||||
row_as_glwe,
|
||||
noise_parameters,
|
||||
generator,
|
||||
);
|
||||
}
|
||||
|
||||
/// Decrypt a [`GGSW ciphertext`](`GgswCiphertext`) only yielding the plaintext from the constant
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::core_crypto::commons::math::decomposition::SignedDecomposer;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::fft_impl::common::pbs_modulus_switch;
|
||||
use crate::core_crypto::fft_impl::common::fast_pbs_modulus_switch;
|
||||
use crate::core_crypto::fft_impl::fft64::crypto::ggsw::{
|
||||
add_external_product_assign, add_external_product_assign_scratch, update_with_fmadd_factor,
|
||||
};
|
||||
@@ -61,7 +61,7 @@ pub fn prepare_multi_bit_ggsw_mem_optimized<
|
||||
monomial_degree.wrapping_add(selection_bit.wrapping_mul(mask_element));
|
||||
}
|
||||
|
||||
let switched_degree = pbs_modulus_switch(
|
||||
let switched_degree = fast_pbs_modulus_switch(
|
||||
monomial_degree,
|
||||
polynomial_size,
|
||||
ModulusSwitchOffset(0),
|
||||
@@ -370,7 +370,7 @@ pub fn multi_bit_blind_rotate_assign<Scalar, InputCont, OutputCont, KeyCont>(
|
||||
let work_queue = Mutex::new(work_queue);
|
||||
|
||||
let lut_poly_size = accumulator.polynomial_size();
|
||||
let monomial_degree = pbs_modulus_switch(
|
||||
let monomial_degree = fast_pbs_modulus_switch(
|
||||
*lwe_body.data,
|
||||
lut_poly_size,
|
||||
ModulusSwitchOffset(0),
|
||||
@@ -455,6 +455,8 @@ pub fn multi_bit_blind_rotate_assign<Scalar, InputCont, OutputCont, KeyCont>(
|
||||
}
|
||||
};
|
||||
|
||||
// false positive as the mapping function has side effects (thread spawning)
|
||||
#[allow(clippy::needless_collect)]
|
||||
let threads: Vec<_> = (0..thread_count.0)
|
||||
.map(|id| {
|
||||
let tx = tx.clone();
|
||||
@@ -617,7 +619,7 @@ pub fn multi_bit_deterministic_blind_rotate_assign<Scalar, InputCont, OutputCont
|
||||
let work_queue = &work_queue;
|
||||
|
||||
let lut_poly_size = accumulator.polynomial_size();
|
||||
let monomial_degree = pbs_modulus_switch(
|
||||
let monomial_degree = fast_pbs_modulus_switch(
|
||||
*lwe_body.data,
|
||||
lut_poly_size,
|
||||
ModulusSwitchOffset(0),
|
||||
@@ -700,7 +702,7 @@ pub fn multi_bit_deterministic_blind_rotate_assign<Scalar, InputCont, OutputCont
|
||||
monomial_degree.wrapping_add(selection_bit.wrapping_mul(mask_element));
|
||||
}
|
||||
|
||||
let switched_degree = pbs_modulus_switch(
|
||||
let switched_degree = fast_pbs_modulus_switch(
|
||||
monomial_degree,
|
||||
lut_poly_size,
|
||||
ModulusSwitchOffset(0),
|
||||
@@ -731,6 +733,8 @@ pub fn multi_bit_deterministic_blind_rotate_assign<Scalar, InputCont, OutputCont
|
||||
}
|
||||
};
|
||||
|
||||
// false positive as the mapping function has side effects (thread spawning)
|
||||
#[allow(clippy::needless_collect)]
|
||||
let threads: Vec<_> = (0..thread_count.0)
|
||||
.map(|idx| s.spawn(move || produce_multi_bit_fourier_ggsw(idx)))
|
||||
.collect();
|
||||
@@ -1257,7 +1261,7 @@ pub fn std_prepare_multi_bit_ggsw<Scalar, GgswBufferCont, TmpGgswBufferCont, Ggs
|
||||
monomial_degree.wrapping_add(selection_bit.wrapping_mul(mask_element));
|
||||
}
|
||||
|
||||
let switched_degree = pbs_modulus_switch(
|
||||
let switched_degree = fast_pbs_modulus_switch(
|
||||
monomial_degree,
|
||||
polynomial_size,
|
||||
ModulusSwitchOffset(0),
|
||||
@@ -1363,7 +1367,7 @@ pub fn std_multi_bit_blind_rotate_assign<Scalar, InputCont, OutputCont, KeyCont>
|
||||
let work_queue = Mutex::new(work_queue);
|
||||
|
||||
let lut_poly_size = accumulator.polynomial_size();
|
||||
let monomial_degree = pbs_modulus_switch(
|
||||
let monomial_degree = fast_pbs_modulus_switch(
|
||||
*lwe_body.data,
|
||||
lut_poly_size,
|
||||
ModulusSwitchOffset(0),
|
||||
@@ -1473,6 +1477,8 @@ pub fn std_multi_bit_blind_rotate_assign<Scalar, InputCont, OutputCont, KeyCont>
|
||||
}
|
||||
};
|
||||
|
||||
// false positive as the mapping function has side effects (thread spawning)
|
||||
#[allow(clippy::needless_collect)]
|
||||
let threads: Vec<_> = (0..thread_count.0)
|
||||
.map(|id| {
|
||||
let tx = tx.clone();
|
||||
@@ -1645,7 +1651,7 @@ pub fn std_multi_bit_deterministic_blind_rotate_assign<Scalar, InputCont, Output
|
||||
let work_queue = &work_queue;
|
||||
|
||||
let lut_poly_size = accumulator.polynomial_size();
|
||||
let monomial_degree = pbs_modulus_switch(
|
||||
let monomial_degree = fast_pbs_modulus_switch(
|
||||
*lwe_body.data,
|
||||
lut_poly_size,
|
||||
ModulusSwitchOffset(0),
|
||||
@@ -1744,6 +1750,8 @@ pub fn std_multi_bit_deterministic_blind_rotate_assign<Scalar, InputCont, Output
|
||||
}
|
||||
};
|
||||
|
||||
// false positive as the mapping function has side effects (thread spawning)
|
||||
#[allow(clippy::needless_collect)]
|
||||
let threads: Vec<_> = (0..thread_count.0)
|
||||
.map(|id| s.spawn(move || produce_multi_bit_fourier_ggsw(id)))
|
||||
.collect();
|
||||
|
||||
@@ -186,8 +186,8 @@ pub fn keyswitch_lwe_ciphertext_into_glwe_ciphertext<Scalar, KeyCont, InputCont,
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply a private functional keyswitch on each [`LWE ciphertext`](`LweCiphertext`) of an input
|
||||
/// [`LWE ciphertext list`](`LweCiphertextList`) and pack the result in an output [`GLWE
|
||||
/// Apply a keyswitch on each [`LWE ciphertext`](`LweCiphertext`) of an input [`LWE ciphertext
|
||||
/// list`](`LweCiphertextList`) and pack the result in an output [`GLWE
|
||||
/// ciphertext`](`GlweCiphertext`).
|
||||
///
|
||||
/// ```
|
||||
|
||||
@@ -108,9 +108,30 @@ pub fn torus_modular_diff<T: UnsignedInteger>(
|
||||
}
|
||||
}
|
||||
|
||||
/// Compute the distance over the torus, taking the absolute value of the smallest distance between
|
||||
/// two torus values.
|
||||
pub fn modular_distance<T: UnsignedInteger>(first: T, other: T) -> T {
|
||||
let d0 = first.wrapping_sub(other);
|
||||
let d1 = other.wrapping_sub(first);
|
||||
d0.min(d1)
|
||||
}
|
||||
|
||||
/// Compute the distance over the torus, taking the absolute value of the smallest distance between
|
||||
/// two torus values, considering a non native modulus.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// first and other must already be in `0..custom_modulus`.
|
||||
pub fn modular_distance_custom_mod<T: UnsignedInteger>(first: T, other: T, custom_modulus: T) -> T {
|
||||
let d0 = first.wrapping_sub_custom_mod(other, custom_modulus);
|
||||
let d1 = other.wrapping_sub_custom_mod(first, custom_modulus);
|
||||
d0.min(d1)
|
||||
}
|
||||
|
||||
// Our representation of non native power of 2 moduli puts the information in the MSBs and leaves
|
||||
// the LSBs empty, this is what this function is checking
|
||||
pub fn check_content_respects_mod<Scalar: UnsignedInteger, Input: AsRef<[Scalar]>>(
|
||||
#[track_caller]
|
||||
pub fn check_encrypted_content_respects_mod<Scalar: UnsignedInteger, Input: AsRef<[Scalar]>>(
|
||||
input: &Input,
|
||||
modulus: CiphertextModulus<Scalar>,
|
||||
) -> bool {
|
||||
@@ -132,6 +153,54 @@ pub fn check_content_respects_mod<Scalar: UnsignedInteger, Input: AsRef<[Scalar]
|
||||
}
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn check_clear_content_respects_mod<Scalar: UnsignedInteger, Input: AsRef<[Scalar]>>(
|
||||
input: &Input,
|
||||
modulus: CiphertextModulus<Scalar>,
|
||||
) -> bool {
|
||||
if modulus.is_native_modulus() {
|
||||
true
|
||||
} else {
|
||||
let scalar_modulus: Scalar = modulus.get_custom_modulus().cast_into();
|
||||
|
||||
input.as_ref().iter().all(|&x| x < scalar_modulus)
|
||||
}
|
||||
}
|
||||
|
||||
/// This function converts an unsigned integer to a float value but does so selecting the truncated
|
||||
/// value of the input integer, meaning it will not try to round to the closest representable
|
||||
/// integer by the floating point type, it will always select the closest representable integer by
|
||||
/// the given floating point type that is inferior to the input integer.
|
||||
///
|
||||
/// This is used to get an approximation of an integer modulus in the float domain that is
|
||||
/// guaranteed to not be greater than the integer value.
|
||||
pub fn convert_unsigned_integer_to_float_truncate<Scalar, Float>(input: Scalar) -> Float
|
||||
where
|
||||
Scalar: UnsignedInteger + CastInto<Float>,
|
||||
Float: FloatingPoint,
|
||||
{
|
||||
let float_mantissa_bits = Float::MANTISSA_DIGITS;
|
||||
|
||||
// Reasoning with f64
|
||||
// An f64 being able to represent all values from 0 to 2^53 without approximation we have a fast
|
||||
// path here
|
||||
if Scalar::BITS <= float_mantissa_bits || input <= (Scalar::ONE << float_mantissa_bits) {
|
||||
input.cast_into()
|
||||
} else {
|
||||
// 0 indexed
|
||||
// Here as input > 2^53 leading zeros is always less than Scalar::BITS - 1, this does not
|
||||
// underflow
|
||||
// The formula is Scalar::BITS - 1 - leading_zeros which also happens to be the ilog2 of the
|
||||
// value
|
||||
let first_most_significant_non_zero_bit_position = input.ilog2() as usize;
|
||||
let last_representable_bit =
|
||||
first_most_significant_non_zero_bit_position - float_mantissa_bits;
|
||||
let mask_zeroing_unrepresentable_bits =
|
||||
!((Scalar::ONE << (last_representable_bit + 1)) - Scalar::ONE);
|
||||
(input & mask_zeroing_unrepresentable_bits).cast_into()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
@@ -177,4 +246,60 @@ mod test {
|
||||
assert_eq!(expected_ceiled_u64, ceiled);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_convert_integer_truncate_u64_f64() {
|
||||
let check_value = |value, exact_match: bool| {
|
||||
let value_trunc_f64: f64 = convert_unsigned_integer_to_float_truncate(value);
|
||||
let roundtrip_value = value_trunc_f64 as u64;
|
||||
|
||||
if exact_match {
|
||||
assert_eq!(roundtrip_value, value);
|
||||
} else {
|
||||
assert!(
|
||||
roundtrip_value <= value,
|
||||
"expected roundtrip_value={roundtrip_value} <= value={value}\n\
|
||||
roundtrip_value={roundtrip_value:064b}, value={value:064b}"
|
||||
);
|
||||
|
||||
let max_expected_diff =
|
||||
1 << (value.ceil_ilog2().saturating_sub(f64::MANTISSA_DIGITS));
|
||||
let abs_diff = roundtrip_value.abs_diff(value);
|
||||
assert!(
|
||||
abs_diff < max_expected_diff,
|
||||
"expected abs_diff={abs_diff} < max_expected_diff={max_expected_diff}"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
let values_and_exact_match = [
|
||||
(((1u128 << 64) - (1 << 32) + 1) as u64, false),
|
||||
(((1u128 << 64) - (1 << 32)) as u64, true),
|
||||
(((1u128 << 64) - (1 << 32) + (1 << 12) - 1) as u64, false),
|
||||
(1 << 53, true),
|
||||
((1 << 53) - 1, true),
|
||||
((1 << 53) + 1, false),
|
||||
(1 << 32, true),
|
||||
(1, true),
|
||||
(0, true),
|
||||
];
|
||||
|
||||
for (value, exact_match) in values_and_exact_match {
|
||||
check_value(value, exact_match);
|
||||
}
|
||||
}
|
||||
{
|
||||
use rand::Rng;
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
for _ in 0..1_000_000_000 {
|
||||
let value: u64 = rng.gen();
|
||||
// This is an easy case where we expect the values to match exactly, to cover other
|
||||
// cases we would be re coding the algorithms here.
|
||||
let exact_match = value <= (1 << 53);
|
||||
check_value(value, exact_match);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,10 @@ fn ggsw_encrypt_decrypt_custom_mod<Scalar: UnsignedTorus>(params: TestParams<Sca
|
||||
&mut rsc.encryption_random_generator,
|
||||
);
|
||||
|
||||
assert!(check_content_respects_mod(&ggsw, ciphertext_modulus));
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&ggsw,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
let decoded = decrypt_constant_ggsw_ciphertext(&glwe_sk, &ggsw);
|
||||
|
||||
@@ -285,7 +288,10 @@ fn ggsw_par_encrypt_decrypt_custom_mod<Scalar: UnsignedTorus + Send + Sync>(
|
||||
&mut rsc.encryption_random_generator,
|
||||
);
|
||||
|
||||
assert!(check_content_respects_mod(&ggsw, ciphertext_modulus));
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&ggsw,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
let decoded = decrypt_constant_ggsw_ciphertext(&glwe_sk, &ggsw);
|
||||
|
||||
@@ -348,7 +354,10 @@ fn ggsw_seeded_encrypt_decrypt_custom_mod<Scalar: UnsignedTorus>(params: TestPar
|
||||
|
||||
let ggsw = seeded_ggsw.decompress_into_ggsw_ciphertext();
|
||||
|
||||
assert!(check_content_respects_mod(&ggsw, ciphertext_modulus));
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&ggsw,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
let decoded = decrypt_constant_ggsw_ciphertext(&glwe_sk, &ggsw);
|
||||
|
||||
@@ -413,7 +422,10 @@ fn ggsw_seeded_par_encrypt_decrypt_custom_mod<Scalar: UnsignedTorus + Sync + Sen
|
||||
|
||||
let ggsw = seeded_ggsw.decompress_into_ggsw_ciphertext();
|
||||
|
||||
assert!(check_content_respects_mod(&ggsw, ciphertext_modulus));
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&ggsw,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
let decoded = decrypt_constant_ggsw_ciphertext(&glwe_sk, &ggsw);
|
||||
|
||||
|
||||
@@ -38,7 +38,10 @@ fn glwe_encrypt_assign_decrypt_custom_mod<Scalar: UnsignedTorus>(params: TestPar
|
||||
&mut rsc.encryption_random_generator,
|
||||
);
|
||||
|
||||
assert!(check_content_respects_mod(&glwe, ciphertext_modulus));
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&glwe,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
let mut plaintext_list =
|
||||
PlaintextList::new(Scalar::ZERO, PlaintextCount(glwe.polynomial_size().0));
|
||||
@@ -101,7 +104,10 @@ fn glwe_encrypt_decrypt_custom_mod<Scalar: UnsignedTorus>(params: TestParams<Sca
|
||||
&mut rsc.encryption_random_generator,
|
||||
);
|
||||
|
||||
assert!(check_content_respects_mod(&glwe, ciphertext_modulus));
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&glwe,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
let mut plaintext_list =
|
||||
PlaintextList::new(Scalar::ZERO, PlaintextCount(glwe.polynomial_size().0));
|
||||
@@ -168,7 +174,10 @@ fn glwe_list_encrypt_decrypt_custom_mod<Scalar: UnsignedTorus>(params: TestParam
|
||||
&mut rsc.encryption_random_generator,
|
||||
);
|
||||
|
||||
assert!(check_content_respects_mod(&glwe_list, ciphertext_modulus));
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&glwe_list,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
let mut plaintext_list = PlaintextList::new(
|
||||
Scalar::ZERO,
|
||||
@@ -226,7 +235,10 @@ fn glwe_trivial_encrypt_decrypt_custom_mod<Scalar: UnsignedTorus>(params: TestPa
|
||||
|
||||
trivially_encrypt_glwe_ciphertext(&mut glwe, &plaintext_list);
|
||||
|
||||
assert!(check_content_respects_mod(&glwe, ciphertext_modulus));
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&glwe,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
let mut plaintext_list =
|
||||
PlaintextList::new(Scalar::ZERO, PlaintextCount(glwe.polynomial_size().0));
|
||||
@@ -280,7 +292,10 @@ fn glwe_allocate_trivial_encrypt_decrypt_custom_mod<Scalar: UnsignedTorus>(
|
||||
ciphertext_modulus,
|
||||
);
|
||||
|
||||
assert!(check_content_respects_mod(&ct, ciphertext_modulus));
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&ct,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
let mut output_plaintext_list =
|
||||
PlaintextList::new(Scalar::ZERO, PlaintextCount(polynomial_size.0));
|
||||
@@ -341,11 +356,14 @@ fn glwe_seeded_encrypt_decrypt_custom_mod<Scalar: UnsignedTorus>(params: TestPar
|
||||
rsc.seeder.as_mut(),
|
||||
);
|
||||
|
||||
assert!(check_content_respects_mod(&seeded_glwe, ciphertext_modulus));
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&seeded_glwe,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
let decompressed_glwe = seeded_glwe.decompress_into_glwe_ciphertext();
|
||||
|
||||
assert!(check_content_respects_mod(
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&decompressed_glwe,
|
||||
ciphertext_modulus
|
||||
));
|
||||
@@ -418,7 +436,7 @@ fn glwe_seeded_list_encrypt_decrypt_custom_mod<Scalar: UnsignedTorus>(params: Te
|
||||
rsc.seeder.as_mut(),
|
||||
);
|
||||
|
||||
assert!(check_content_respects_mod(
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&glwe_seeded_list,
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user