mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-11 07:38:08 -05:00
Compare commits
6 Commits
main
...
tm/update-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e7ff77932 | ||
|
|
40e96d4c84 | ||
|
|
aaec3fd109 | ||
|
|
9bcc3507a7 | ||
|
|
d08a7eb097 | ||
|
|
ef044fca9c |
213
.github/workflows/aws_tfhe_param_prod_tests.yml
vendored
Normal file
213
.github/workflows/aws_tfhe_param_prod_tests.yml
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
# Run a small subset of tests to ensure quick feedback.
|
||||
name: aws_tfhe_param_prod_tests
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
RUSTFLAGS: "-C target-cpu=native"
|
||||
RUST_BACKTRACE: "full"
|
||||
RUST_MIN_STACK: "8388608"
|
||||
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
|
||||
SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png
|
||||
SLACK_USERNAME: ${{ secrets.BOT_USERNAME }}
|
||||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
||||
SLACKIFY_MARKDOWN: true
|
||||
IS_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
|
||||
PULL_REQUEST_MD_LINK: ""
|
||||
CHECKOUT_TOKEN: ${{ secrets.REPO_CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
# Secrets will be available only to zama-ai organization members
|
||||
SECRETS_AVAILABLE: ${{ secrets.JOB_SECRET != '' }}
|
||||
EXTERNAL_CONTRIBUTION_RUNNER: "large_ubuntu_64-22.04"
|
||||
|
||||
on:
|
||||
# Allows you to run this workflow manually from the Actions tab as an alternative.
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
types: [ labeled ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# zizmor: ignore[concurrency-limits] concurrency is managed after instance setup to ensure safe provisioning
|
||||
|
||||
jobs:
|
||||
should-run:
|
||||
name: aws_tfhe_param_prod_tests/should-run
|
||||
if: (github.event_name == 'pull_request' && contains(github.event.label.name, 'approved')) || github.event_name == 'workflow_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: read # Needed to check for file change
|
||||
outputs:
|
||||
csprng_test: ${{ env.IS_PULL_REQUEST == 'false' || steps.changed-files.outputs.csprng_any_changed }}
|
||||
zk_pok_test: ${{ env.IS_PULL_REQUEST == 'false' || steps.changed-files.outputs.zk_pok_any_changed }}
|
||||
versionable_test: ${{ env.IS_PULL_REQUEST == 'false' || steps.changed-files.outputs.versionable_any_changed }}
|
||||
shortint_test: ${{ env.IS_PULL_REQUEST == 'false' ||
|
||||
steps.changed-files.outputs.shortint_any_changed ||
|
||||
steps.changed-files.outputs.dependencies_any_changed }}
|
||||
integer_test: ${{ env.IS_PULL_REQUEST == 'false' ||
|
||||
steps.changed-files.outputs.integer_any_changed ||
|
||||
steps.changed-files.outputs.dependencies_any_changed }}
|
||||
high_level_api_test: ${{ env.IS_PULL_REQUEST == 'false' ||
|
||||
steps.changed-files.outputs.high_level_api_any_changed ||
|
||||
steps.changed-files.outputs.dependencies_any_changed }}
|
||||
any_file_changed: ${{ env.IS_PULL_REQUEST == 'false' || steps.aggregated-changes.outputs.any_changed }}
|
||||
steps:
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: 'false'
|
||||
token: ${{ env.CHECKOUT_TOKEN }}
|
||||
|
||||
- name: Check for file changes
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47.0.0
|
||||
with:
|
||||
files_yaml: |
|
||||
dependencies:
|
||||
- tfhe/Cargo.toml
|
||||
- tfhe-csprng/**
|
||||
- tfhe-fft/**
|
||||
- tfhe-zk-pok/**
|
||||
- utils/tfhe-versionable/**
|
||||
- utils/tfhe-versionable-derive/**
|
||||
versionable:
|
||||
- utils/tfhe-versionable/**
|
||||
- utils/tfhe-versionable-derive/**
|
||||
shortint:
|
||||
- tfhe/src/core_crypto/**
|
||||
- tfhe/src/shortint/**
|
||||
integer:
|
||||
- tfhe/src/core_crypto/**
|
||||
- tfhe/src/shortint/**
|
||||
- tfhe/src/integer/**
|
||||
high_level_api:
|
||||
- tfhe/src/**
|
||||
- '!tfhe/src/c_api/**'
|
||||
- '!tfhe/src/boolean/**'
|
||||
- '!tfhe/src/c_api/**'
|
||||
- '!tfhe/src/js_on_wasm_api/**'
|
||||
|
||||
- name: Aggregate file changes
|
||||
id: aggregated-changes
|
||||
if: ( steps.changed-files.outputs.dependencies_any_changed == 'true' ||
|
||||
steps.changed-files.outputs.csprng_any_changed == 'true' ||
|
||||
steps.changed-files.outputs.zk_pok_any_changed == 'true' ||
|
||||
steps.changed-files.outputs.versionable_any_changed == 'true' ||
|
||||
steps.changed-files.outputs.core_crypto_any_changed == 'true' ||
|
||||
steps.changed-files.outputs.boolean_any_changed == 'true' ||
|
||||
steps.changed-files.outputs.shortint_any_changed == 'true' ||
|
||||
steps.changed-files.outputs.integer_any_changed == 'true' ||
|
||||
steps.changed-files.outputs.wasm_any_changed == 'true' ||
|
||||
steps.changed-files.outputs.high_level_api_any_changed == 'true' ||
|
||||
steps.changed-files.outputs.user_docs_any_changed == 'true')
|
||||
run: |
|
||||
echo "any_changed=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
setup-instance:
|
||||
name: aws_tfhe_param_prod_tests/setup-instance
|
||||
if: github.event_name == 'workflow_dispatch' ||
|
||||
(github.event_name != 'workflow_dispatch' && needs.should-run.outputs.any_file_changed == 'true')
|
||||
needs: should-run
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
runner-name: ${{ steps.start-remote-instance.outputs.label || steps.start-github-instance.outputs.runner_group }}
|
||||
steps:
|
||||
- name: Start remote instance
|
||||
id: start-remote-instance
|
||||
if: env.SECRETS_AVAILABLE == 'true'
|
||||
uses: zama-ai/slab-github-runner@973c1d22702de8d0acd2b34e83404c96ed92c264 # v1.4.2
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
slab-url: ${{ secrets.SLAB_BASE_URL }}
|
||||
job-secret: ${{ secrets.JOB_SECRET }}
|
||||
backend: aws
|
||||
profile: cpu-big
|
||||
|
||||
# This instance will be spawned especially for pull-request from forked repository
|
||||
- name: Start GitHub instance
|
||||
id: start-github-instance
|
||||
if: env.SECRETS_AVAILABLE == 'false'
|
||||
run: |
|
||||
echo "runner_group=${EXTERNAL_CONTRIBUTION_RUNNER}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
param-prod-tests:
|
||||
name: aws_tfhe_param_prod_tests/param-prod-tests
|
||||
needs: [ should-run, setup-instance ]
|
||||
concurrency:
|
||||
group: ${{ github.workflow_ref }}
|
||||
cancel-in-progress: true
|
||||
runs-on: ${{ needs.setup-instance.outputs.runner-name }}
|
||||
steps:
|
||||
- name: Checkout tfhe-rs
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
|
||||
with:
|
||||
persist-credentials: 'false'
|
||||
token: ${{ env.CHECKOUT_TOKEN }}
|
||||
|
||||
- name: Install latest stable
|
||||
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # zizmor: ignore[stale-action-refs] this action doesn't create releases
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Gen Keys if required
|
||||
if: needs.should-run.outputs.shortint_test == 'true' ||
|
||||
needs.should-run.outputs.integer_test == 'true'
|
||||
run: |
|
||||
make gen_key_cache
|
||||
|
||||
- name: Run shortint tests
|
||||
if: needs.should-run.outputs.shortint_test == 'true'
|
||||
run: |
|
||||
BIG_TESTS_INSTANCE=TRUE FAST_TESTS=FALSE make test_param_prod_shortint_ci
|
||||
|
||||
- name: Run integer tests
|
||||
if: needs.should-run.outputs.integer_test == 'true'
|
||||
run: |
|
||||
BIG_TESTS_INSTANCE=TRUE FAST_TESTS=FALSE make test_param_prod_integer_ci
|
||||
|
||||
- name: Run high-level API tests
|
||||
if: needs.should-run.outputs.high_level_api_test == 'true'
|
||||
run: |
|
||||
make test_high_level_api
|
||||
|
||||
- name: Set pull-request URL
|
||||
if: ${{ failure() && github.event_name == 'pull_request' }}
|
||||
run: |
|
||||
echo "PULL_REQUEST_MD_LINK=[pull-request](${PR_BASE_URL}${PR_NUMBER}), " >> "${GITHUB_ENV}"
|
||||
env:
|
||||
PR_BASE_URL: ${{ vars.PR_BASE_URL }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
|
||||
- name: Slack Notification
|
||||
if: ${{ failure() && env.SECRETS_AVAILABLE == 'true' }}
|
||||
continue-on-error: true
|
||||
uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661
|
||||
env:
|
||||
SLACK_COLOR: ${{ job.status }}
|
||||
SLACK_MESSAGE: "Fast AWS tests finished with status: ${{ job.status }}. (${{ env.PULL_REQUEST_MD_LINK }}[action run](${{ env.ACTION_RUN_URL }}))"
|
||||
|
||||
teardown-instance:
|
||||
name: aws_tfhe_param_prod_tests/teardown-instance
|
||||
if: ${{ always() && needs.setup-instance.result == 'success' }}
|
||||
needs: [ setup-instance, param-prod-tests ]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Stop remote instance
|
||||
id: stop-instance
|
||||
if: env.SECRETS_AVAILABLE == 'true'
|
||||
uses: zama-ai/slab-github-runner@973c1d22702de8d0acd2b34e83404c96ed92c264 # v1.4.2
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
slab-url: ${{ secrets.SLAB_BASE_URL }}
|
||||
job-secret: ${{ secrets.JOB_SECRET }}
|
||||
label: ${{ needs.setup-instance.outputs.runner-name }}
|
||||
|
||||
- name: Slack Notification
|
||||
if: ${{ failure() || (cancelled() && github.event_name != 'pull_request') }}
|
||||
uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661
|
||||
env:
|
||||
SLACK_COLOR: ${{ job.status }}
|
||||
SLACK_MESSAGE: "Instance teardown (param-prod-tests) finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})"
|
||||
17
Makefile
17
Makefile
@@ -905,6 +905,14 @@ test_shortint_ci: install_cargo_nextest
|
||||
./scripts/shortint-tests.sh \
|
||||
--cargo-profile "$(CARGO_PROFILE)" --tfhe-package "tfhe"
|
||||
|
||||
.PHONY: test_param_prod_shortint_ci # Run the tests for shortint ci
|
||||
test_param_prod_shortint_ci: install_cargo_nextest
|
||||
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
|
||||
FAST_TESTS="$(FAST_TESTS)" \
|
||||
./scripts/shortint-tests.sh \
|
||||
--cargo-profile "$(CARGO_PROFILE)" --run-prod-only --tfhe-package "tfhe"
|
||||
|
||||
|
||||
.PHONY: test_shortint_multi_bit_ci # Run the tests for shortint ci running only multibit tests
|
||||
test_shortint_multi_bit_ci: install_cargo_nextest
|
||||
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
|
||||
@@ -934,6 +942,15 @@ test_integer_ci: install_cargo_nextest
|
||||
--cargo-profile "$(CARGO_PROFILE)" --avx512-support "$(AVX512_SUPPORT)" \
|
||||
--tfhe-package "tfhe"
|
||||
|
||||
.PHONY: test_param_prod_integer_ci # Run the tests for integer ci
|
||||
test_param_prod_integer_ci: install_cargo_nextest
|
||||
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
|
||||
FAST_TESTS="$(FAST_TESTS)" \
|
||||
NIGHTLY_TESTS="$(NIGHTLY_TESTS)" \
|
||||
./scripts/integer-tests.sh \
|
||||
--cargo-profile "$(CARGO_PROFILE)" --avx512-support "$(AVX512_SUPPORT)" \
|
||||
--run-prod-only --tfhe-package "tfhe"
|
||||
|
||||
.PHONY: test_unsigned_integer_ci # Run the tests for unsigned integer ci
|
||||
test_unsigned_integer_ci: install_cargo_nextest
|
||||
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
|
||||
|
||||
@@ -3,21 +3,23 @@
|
||||
set -e
|
||||
|
||||
function usage() {
|
||||
echo "$0: integer test runner"
|
||||
echo
|
||||
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 "--nightly-tests Run integer tests configured for nightly runs (3_3 params)"
|
||||
echo "--fast-tests Run integer set but skip a subset of longer tests"
|
||||
echo "--long-tests Run only long run integer tests"
|
||||
echo "--cargo-profile The cargo profile used to build tests"
|
||||
echo "--backend Backend to use with tfhe-rs"
|
||||
echo "--avx512-support Set to ON to enable avx512"
|
||||
echo "--tfhe-package The package spec like tfhe@0.4.2, default=tfhe"
|
||||
echo
|
||||
echo "$0: integer test runner"
|
||||
echo
|
||||
echo "--help Print this message"
|
||||
echo "--no-run Does not run the tests, but prints which tests would be ran (except doctests)"
|
||||
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 "--run-prod-only Run only the tests using the prod parameters"
|
||||
echo "--nightly-tests Run integer tests configured for nightly runs (3_3 params)"
|
||||
echo "--fast-tests Run integer set but skip a subset of longer tests"
|
||||
echo "--long-tests Run only long run integer tests"
|
||||
echo "--cargo-profile The cargo profile used to build tests"
|
||||
echo "--backend Backend to use with tfhe-rs"
|
||||
echo "--avx512-support Set to ON to enable avx512"
|
||||
echo "--tfhe-package The package spec like tfhe@0.4.2, default=tfhe"
|
||||
echo
|
||||
}
|
||||
|
||||
RUST_TOOLCHAIN=""
|
||||
@@ -33,87 +35,96 @@ backend="cpu"
|
||||
gpu_feature=""
|
||||
avx512_feature=""
|
||||
tfhe_package="tfhe"
|
||||
prod_param_argument=
|
||||
no_run=false
|
||||
|
||||
while [ -n "$1" ]
|
||||
do
|
||||
case "$1" in
|
||||
"--help" | "-h" )
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
"--help" | "-h")
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
|
||||
"--rust-toolchain" )
|
||||
shift
|
||||
RUST_TOOLCHAIN="$1"
|
||||
;;
|
||||
"--no-run")
|
||||
no_run=true
|
||||
;;
|
||||
|
||||
"--multi-bit" )
|
||||
multi_bit_argument=--multi-bit
|
||||
;;
|
||||
"--run-prod-only")
|
||||
prod_param_argument="--run-prod-only"
|
||||
;;
|
||||
|
||||
"--unsigned-only" )
|
||||
sign_argument=--unsigned-only
|
||||
;;
|
||||
"--rust-toolchain")
|
||||
shift
|
||||
RUST_TOOLCHAIN="$1"
|
||||
;;
|
||||
|
||||
"--signed-only" )
|
||||
sign_argument=--signed-only
|
||||
;;
|
||||
"--multi-bit")
|
||||
multi_bit_argument=--multi-bit
|
||||
;;
|
||||
|
||||
"--cargo-profile" )
|
||||
shift
|
||||
cargo_profile="$1"
|
||||
;;
|
||||
"--unsigned-only")
|
||||
sign_argument=--unsigned-only
|
||||
;;
|
||||
|
||||
"--backend" )
|
||||
shift
|
||||
backend="$1"
|
||||
;;
|
||||
"--avx512-support" )
|
||||
shift
|
||||
if [[ "$1" == "ON" ]]; then
|
||||
avx512_feature=avx512
|
||||
fi
|
||||
;;
|
||||
"--signed-only")
|
||||
sign_argument=--signed-only
|
||||
;;
|
||||
|
||||
"--tfhe-package" )
|
||||
shift
|
||||
tfhe_package="$1"
|
||||
;;
|
||||
"--cargo-profile")
|
||||
shift
|
||||
cargo_profile="$1"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown param : $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
"--backend")
|
||||
shift
|
||||
backend="$1"
|
||||
;;
|
||||
"--avx512-support")
|
||||
shift
|
||||
if [[ "$1" == "ON" ]]; then
|
||||
avx512_feature=avx512
|
||||
fi
|
||||
;;
|
||||
|
||||
"--tfhe-package")
|
||||
shift
|
||||
tfhe_package="$1"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown param : $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ "${RUST_TOOLCHAIN::1}" != "+" ]]; then
|
||||
RUST_TOOLCHAIN=${RUST_TOOLCHAIN:+"+${RUST_TOOLCHAIN}"}
|
||||
RUST_TOOLCHAIN=${RUST_TOOLCHAIN:+"+${RUST_TOOLCHAIN}"}
|
||||
fi
|
||||
|
||||
if [[ "${FAST_TESTS}" == TRUE ]]; then
|
||||
fast_tests_argument=--fast-tests
|
||||
fast_tests_argument=--fast-tests
|
||||
fi
|
||||
|
||||
if [[ "${LONG_TESTS}" == TRUE ]]; then
|
||||
long_tests_argument=--long-tests
|
||||
long_tests_argument=--long-tests
|
||||
fi
|
||||
|
||||
if [[ "${NIGHTLY_TESTS}" == TRUE ]]; then
|
||||
nightly_tests_argument=--nightly-tests
|
||||
nightly_tests_argument=--nightly-tests
|
||||
fi
|
||||
|
||||
if [[ "${NO_BIG_PARAMS}" == TRUE ]]; then
|
||||
no_big_params_argument=--no-big-params
|
||||
no_big_params_argument=--no-big-params
|
||||
fi
|
||||
|
||||
if [[ "${NO_BIG_PARAMS_GPU}" == TRUE ]]; then
|
||||
no_big_params_argument_gpu=--no-big-params-gpu
|
||||
no_big_params_argument_gpu=--no-big-params-gpu
|
||||
fi
|
||||
|
||||
if [[ "${backend}" == "gpu" ]]; then
|
||||
gpu_feature="gpu"
|
||||
gpu_feature="gpu"
|
||||
fi
|
||||
|
||||
CURR_DIR="$(dirname "$0")"
|
||||
@@ -122,70 +133,80 @@ CURR_DIR="$(dirname "$0")"
|
||||
num_cpu_threads="$("${CURR_DIR}"/cpu_count.sh)"
|
||||
|
||||
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
|
||||
small_instance_n_threads=1
|
||||
fi
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
# Keys are 4.7 gigs at max, CI M1 macs only has 8 gigs of RAM
|
||||
small_instance_n_threads=1
|
||||
fi
|
||||
else
|
||||
# Keys are 4.7 gigs at max, test machine has 32 gigs of RAM
|
||||
small_instance_n_threads=6
|
||||
# Keys are 4.7 gigs at max, test machine has 32 gigs of RAM
|
||||
small_instance_n_threads=6
|
||||
fi
|
||||
|
||||
if [[ "${BIG_TESTS_INSTANCE}" == TRUE ]]; then
|
||||
test_threads="$((num_cpu_threads * 1 / 4))"
|
||||
doctest_threads="${num_cpu_threads}"
|
||||
test_threads="$((num_cpu_threads * 1 / 4))"
|
||||
doctest_threads="${num_cpu_threads}"
|
||||
else
|
||||
test_threads="${small_instance_n_threads}"
|
||||
doctest_threads="${num_cpu_threads}"
|
||||
test_threads="${small_instance_n_threads}"
|
||||
doctest_threads="${num_cpu_threads}"
|
||||
fi
|
||||
|
||||
# Override test-threads number to avoid Out-of-memory issues on GPU instances
|
||||
if [[ "${backend}" == "gpu" ]]; then
|
||||
if [[ "${BIG_TESTS_INSTANCE}" == TRUE ]]; then
|
||||
test_threads=8
|
||||
doctest_threads=8
|
||||
else
|
||||
test_threads=4
|
||||
doctest_threads=4
|
||||
fi
|
||||
if [[ "${BIG_TESTS_INSTANCE}" == TRUE ]]; then
|
||||
test_threads=8
|
||||
doctest_threads=8
|
||||
else
|
||||
test_threads=4
|
||||
doctest_threads=4
|
||||
fi
|
||||
fi
|
||||
|
||||
filter_expression=$(/usr/bin/python3 scripts/test_filtering.py --layer integer --backend "${backend}" ${fast_tests_argument:+$fast_tests_argument} ${long_tests_argument:+$long_tests_argument} ${nightly_tests_argument:+$nightly_tests_argument} ${no_big_params_argument_gpu:+$no_big_params_argument_gpu} ${multi_bit_argument:+$multi_bit_argument} ${sign_argument:+$sign_argument} ${no_big_params_argument:+$no_big_params_argument})
|
||||
filter_expression=$(/usr/bin/python3 scripts/test_filtering.py --layer integer --backend "${backend}" ${fast_tests_argument:+$fast_tests_argument} ${long_tests_argument:+$long_tests_argument} ${nightly_tests_argument:+$nightly_tests_argument} ${no_big_params_argument_gpu:+$no_big_params_argument_gpu} ${multi_bit_argument:+$multi_bit_argument} ${sign_argument:+$sign_argument} ${no_big_params_argument:+$no_big_params_argument} ${prod_param_argument:+$prod_param_argument})
|
||||
|
||||
if [[ "${FAST_TESTS}" == "TRUE" ]]; then
|
||||
echo "Running 'fast' test set"
|
||||
echo "Running 'fast' test set"
|
||||
elif [[ "${LONG_TESTS}" == "FALSE" ]]; then
|
||||
echo "Running 'slow' test set"
|
||||
echo "Running 'slow' test set"
|
||||
fi
|
||||
|
||||
if [[ "${LONG_TESTS}" == "TRUE" ]]; then
|
||||
echo "Running 'long run' test set"
|
||||
echo "Running 'long run' test set"
|
||||
fi
|
||||
|
||||
if [[ "${NIGHTLY_TESTS}" == "TRUE" ]]; then
|
||||
echo "Running 'nightly' test set"
|
||||
echo "Running 'nightly' test set"
|
||||
fi
|
||||
|
||||
echo "${filter_expression}"
|
||||
|
||||
cargo ${RUST_TOOLCHAIN:+"$RUST_TOOLCHAIN"} nextest run \
|
||||
--tests \
|
||||
--cargo-profile "${cargo_profile}" \
|
||||
--package "${tfhe_package}" \
|
||||
--profile ci \
|
||||
--no-default-features \
|
||||
--features=integer,internal-keycache,zk-pok,experimental,"${avx512_feature}","${gpu_feature}" \
|
||||
--test-threads "${test_threads}" \
|
||||
-E "$filter_expression"
|
||||
if $no_run; then
|
||||
nextest_command="list"
|
||||
nextest_extra_flags=""
|
||||
else
|
||||
nextest_command="run"
|
||||
nextest_extra_flags="--profile ci --test-threads ${test_threads}"
|
||||
fi
|
||||
|
||||
if [[ -z ${multi_bit_argument} && -z ${long_tests_argument} ]]; then
|
||||
cargo ${RUST_TOOLCHAIN:+"$RUST_TOOLCHAIN"} test \
|
||||
--profile "${cargo_profile}" \
|
||||
--package "${tfhe_package}" \
|
||||
--no-default-features \
|
||||
--features=integer,internal-keycache,experimental,"${avx512_feature}","${gpu_feature}" \
|
||||
--doc \
|
||||
-- --test-threads="${doctest_threads}" integer::"${gpu_feature}"
|
||||
cargo ${RUST_TOOLCHAIN:+"$RUST_TOOLCHAIN"} nextest ${nextest_command} \
|
||||
--tests \
|
||||
--cargo-profile "${cargo_profile}" \
|
||||
--package "${tfhe_package}" \
|
||||
--no-default-features \
|
||||
--features=integer,internal-keycache,zk-pok,experimental,"${avx512_feature}","${gpu_feature}" \
|
||||
${nexttest_extra_flags} \
|
||||
-E "$filter_expression"
|
||||
|
||||
if ! $no_run; then
|
||||
# Unfortunately, we cannot skip running doctest with `--no-run`
|
||||
if [[ -z ${multi_bit_argument} && -z ${long_tests_argument} ]]; then
|
||||
cargo ${RUST_TOOLCHAIN:+"$RUST_TOOLCHAIN"} test \
|
||||
--profile "${cargo_profile}" \
|
||||
--package "${tfhe_package}" \
|
||||
--no-default-features \
|
||||
--features=integer,internal-keycache,experimental,"${avx512_feature}","${gpu_feature}" \
|
||||
--doc \
|
||||
-- --test-threads="${doctest_threads}" integer::"${gpu_feature}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Test ran in $SECONDS seconds"
|
||||
|
||||
@@ -8,6 +8,7 @@ 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 "--run-prod-only Run only the tests using the prod parameters"
|
||||
echo "--cargo-profile The cargo profile used to build tests"
|
||||
echo "--tfhe-package The package spec like tfhe@0.4.2, default=tfhe"
|
||||
echo
|
||||
@@ -19,6 +20,7 @@ multi_bit_argument=
|
||||
fast_tests_argument=
|
||||
cargo_profile="release"
|
||||
tfhe_package="tfhe"
|
||||
prod_param_argument=
|
||||
|
||||
while [ -n "$1" ]
|
||||
do
|
||||
@@ -38,6 +40,9 @@ do
|
||||
multi_bit_argument=--multi-bit
|
||||
;;
|
||||
|
||||
"--run-prod-only")
|
||||
prod_param_argument="--run-prod-only"
|
||||
;;
|
||||
"--cargo-profile" )
|
||||
shift
|
||||
cargo_profile="$1"
|
||||
@@ -85,7 +90,7 @@ else
|
||||
fi
|
||||
|
||||
if [[ "${BIG_TESTS_INSTANCE}" != TRUE ]]; then
|
||||
filter_expression_small_params=$(/usr/bin/python3 scripts/test_filtering.py --layer shortint ${fast_tests_argument} ${multi_bit_argument})
|
||||
filter_expression_small_params=$(/usr/bin/python3 scripts/test_filtering.py --layer shortint ${fast_tests_argument} ${multi_bit_argument} ${prod_param_argument})
|
||||
|
||||
# Run tests only no examples or benches with small params and more threads
|
||||
cargo ${RUST_TOOLCHAIN:+"$RUST_TOOLCHAIN"} nextest run \
|
||||
@@ -125,7 +130,7 @@ and not test(~smart_add_and_mul)"""
|
||||
fi
|
||||
fi
|
||||
else
|
||||
filter_expression=$(/usr/bin/python3 scripts/test_filtering.py --layer shortint --big-instance ${fast_tests_argument} ${multi_bit_argument})
|
||||
filter_expression=$(/usr/bin/python3 scripts/test_filtering.py --layer shortint --big-instance ${fast_tests_argument} ${multi_bit_argument} ${prod_param_argument})
|
||||
|
||||
# Run tests only no examples or benches with small params and more threads
|
||||
cargo ${RUST_TOOLCHAIN:+"$RUST_TOOLCHAIN"} nextest run \
|
||||
|
||||
@@ -74,12 +74,17 @@ parser.add_argument(
|
||||
action="store_true",
|
||||
help="Do not run tests with big parameters set (e.g. 3bits message with 3 bits carry) for GPU",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--run-prod-only",
|
||||
action="store_true",
|
||||
help="Specify to run the CPU tests with the prod KS_PBS 2_2 parameters, \
|
||||
only the 'layer' parameter will be taken into account if this flag is specified",
|
||||
)
|
||||
|
||||
# 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_gaussian_2m64 is too slow
|
||||
# so is test_integer_default_add_sequence_multi_thread_param_message_4_carry_4_ks_pbs_gaussian_2m64
|
||||
# skip smart_div, smart_rem which are already covered by the smar_div_rem test
|
||||
# skip default_div, default_rem which are covered by default_div_rem
|
||||
EXCLUDED_INTEGER_TESTS = [
|
||||
@@ -91,7 +96,6 @@ EXCLUDED_INTEGER_TESTS = [
|
||||
"~mul_crt_param_message_4_carry_4_ks_pbs_gaussian_2m64",
|
||||
"/.*test_wopbs_bivariate_crt_wopbs_param_message_[34]_carry_[34]_ks_pbs_gaussian_2m64$/",
|
||||
"/.*test_integer_smart_mul_param_message_4_carry_4_ks_pbs_gaussian_2m64$/",
|
||||
"/.*test_integer_default_add_sequence_multi_thread_param_message_4_carry_4_ks_pbs_gaussian_2m64$/",
|
||||
"/.*::tests_long_run::.*/",
|
||||
]
|
||||
|
||||
@@ -100,7 +104,6 @@ EXCLUDED_INTEGER_FAST_TESTS = [
|
||||
"/.*integer_default_div_param/",
|
||||
"/.*integer_default_rem_param/",
|
||||
"/.*_param_message_[14]_carry_[14]_ks_pbs_gaussian_2m64$/",
|
||||
"/.*default_add_sequence_multi_thread_param_message_3_carry_3_ks_pbs_gaussian_2m64$/",
|
||||
]
|
||||
|
||||
EXCLUDED_BIG_PARAMETERS = [
|
||||
@@ -125,7 +128,13 @@ def filter_integer_tests(input_args):
|
||||
# For now, GPU only has specific parameters set for multi-bit
|
||||
multi_bit_filter = "_gpu_multi_bit"
|
||||
|
||||
filter_expression = [f"test(/^integer::{backend_filter}.*/)"]
|
||||
if input_args.run_prod_only:
|
||||
filter_expression = [f"test(/^integer::{backend_filter}.*_param_prod.*/)"]
|
||||
else:
|
||||
filter_expression = [
|
||||
f"test(/^integer::{backend_filter}.*/)",
|
||||
"not test(/.*_param_prod.*/)",
|
||||
]
|
||||
|
||||
if input_args.multi_bit:
|
||||
filter_expression.append("test(~_multi_bit)")
|
||||
@@ -161,29 +170,32 @@ def filter_integer_tests(input_args):
|
||||
f"test(/.*_default_.*?_param{multi_bit_filter}{group_filter}_message_3_carry_3_.*/)"
|
||||
)
|
||||
excluded_tests = (
|
||||
EXCLUDED_INTEGER_FAST_TESTS if input_args.fast_tests else EXCLUDED_INTEGER_TESTS
|
||||
EXCLUDED_INTEGER_FAST_TESTS
|
||||
if input_args.fast_tests
|
||||
else EXCLUDED_INTEGER_TESTS
|
||||
)
|
||||
for pattern in excluded_tests:
|
||||
filter_expression.append(f"not test({pattern})")
|
||||
|
||||
else:
|
||||
if input_args.backend == "gpu":
|
||||
filter_expression = ["test(/^integer::gpu::server_key::radix::tests_long_run.*/)"]
|
||||
filter_expression = [
|
||||
"test(/^integer::gpu::server_key::radix::tests_long_run.*/)"
|
||||
]
|
||||
elif input_args.backend == "cpu":
|
||||
filter_expression = ["test(/^integer::server_key::radix_parallel::tests_long_run.*/)"]
|
||||
|
||||
|
||||
filter_expression = [
|
||||
"test(/^integer::server_key::radix_parallel::tests_long_run.*/)"
|
||||
]
|
||||
# Do not run noise check tests by default as they can be very slow
|
||||
# they will be run e.g. nightly or on demand
|
||||
filter = filter_expression.append(f"not test(/^integer::gpu::server_key::radix::tests_noise_distribution::.*::test_gpu_noise_check.*/)")
|
||||
|
||||
filter_expression.append(
|
||||
"not test(/^integer::gpu::server_key::radix::tests_noise_distribution::.*::test_gpu_noise_check.*/)"
|
||||
)
|
||||
return " and ".join(filter_expression)
|
||||
|
||||
|
||||
def filter_shortint_tests(input_args):
|
||||
multi_bit_filter, group_filter = (
|
||||
("_multi_bit", "_group_[0-9]") if input_args.multi_bit else ("", "")
|
||||
)
|
||||
def shortint_normal_filter(input_args):
|
||||
multi_bit_filter = "_multi_bit_group_[0-9]" if input_args.multi_bit else ""
|
||||
|
||||
if input_args.fast_tests:
|
||||
msg_carry_pairs = [(2, 1), (2, 2), (2, 3)]
|
||||
@@ -206,13 +218,31 @@ def filter_shortint_tests(input_args):
|
||||
msg_carry_pairs.append((4, 4))
|
||||
|
||||
filter_expression = [
|
||||
f"test(/^shortint::.*_param{multi_bit_filter}{group_filter}_message_{msg}_carry_{carry}(_compact_pk)?_ks(32)?_pbs.*/)"
|
||||
f"test(/^shortint::.*_param{multi_bit_filter}_message_{msg}_carry_{carry}\
|
||||
(_compact_pk)?_ks(32)?_pbs.*/)"
|
||||
for msg, carry in msg_carry_pairs
|
||||
]
|
||||
filter_expression.append("test(/^shortint::.*meta_param_cpu_2_2/)")
|
||||
|
||||
filter_expression.append("test(/^shortint::.*meta_param_cpu_2_2_ks32_pbs/)")
|
||||
filter_expression.append("test(/^shortint::.*_ci_run_filter/)")
|
||||
|
||||
if input_args.run_prod_only:
|
||||
filter_expression.append("test(/^shortint::.*_param_prod.*")
|
||||
else:
|
||||
filter_expression.append("not test(shortint::.*_param_prod.*/)")
|
||||
|
||||
return filter_expression
|
||||
|
||||
|
||||
def filter_shortint_tests(input_args):
|
||||
# We special case the CPU KS_PBS 2_2 parameters to be able to run them alone
|
||||
if input_args.run_prod_only:
|
||||
filter_expression = [
|
||||
"test(/^shortint::.*_param_prod/)",
|
||||
]
|
||||
else:
|
||||
filter_expression = shortint_normal_filter(input_args)
|
||||
|
||||
opt_in_tests = " or ".join(filter_expression)
|
||||
|
||||
# Do not run noise check tests by default as they can be very slow
|
||||
|
||||
@@ -17,7 +17,8 @@ use tfhe::shortint::parameters::key_switching::ShortintKeySwitchingParameters;
|
||||
|
||||
use tfhe::shortint::parameters::current_params::*;
|
||||
use tfhe::shortint::parameters::{
|
||||
ClassicPBSParameters, PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
AtomicPatternParameters, ClassicPBSParameters, PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
#[cfg(feature = "experimental")]
|
||||
use tfhe::shortint::parameters::{
|
||||
@@ -129,6 +130,8 @@ fn client_server_keys() {
|
||||
];
|
||||
generate_pbs_keys(&PBS_KEYS);
|
||||
|
||||
generate_pbs_keys(&[PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128]);
|
||||
|
||||
#[cfg(feature = "experimental")]
|
||||
{
|
||||
const WOPBS_PARAMS: [(ClassicPBSParameters, WopbsParameters); 4] = [
|
||||
@@ -155,10 +158,11 @@ fn client_server_keys() {
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_pbs_keys(params: &[ClassicPBSParameters]) {
|
||||
fn generate_pbs_keys<P: Into<AtomicPatternParameters> + Copy>(params: &[P]) {
|
||||
println!("Generating shortint (ClientKey, ServerKey)");
|
||||
|
||||
for (i, param) in params.iter().copied().enumerate() {
|
||||
let param: AtomicPatternParameters = param.into();
|
||||
println!(
|
||||
"Generating [{} / {}] : {}",
|
||||
i + 1,
|
||||
|
||||
@@ -320,7 +320,7 @@ mod cpu {
|
||||
use super::*;
|
||||
use crate::high_level_api::booleans::compressed::CompressedFheBoolConformanceParams;
|
||||
use crate::safe_serialization::{DeserializationConfig, SerializationConfig};
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
use crate::shortint::parameters::test_params::TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
use crate::FheBoolConformanceParams;
|
||||
use rand::random;
|
||||
|
||||
@@ -675,7 +675,7 @@ mod cpu {
|
||||
|
||||
#[test]
|
||||
fn test_safe_deserialize_conformant_fhe_bool() {
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
let block_params = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let (keys, server_key) = generate_keys(ConfigBuilder::with_custom_parameters(block_params));
|
||||
set_server_key(server_key.clone());
|
||||
|
||||
@@ -698,7 +698,7 @@ mod cpu {
|
||||
|
||||
#[test]
|
||||
fn test_safe_deserialize_conformant_compressed_fhe_bool() {
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
let block_params = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let (keys, server_key) = generate_keys(ConfigBuilder::with_custom_parameters(block_params));
|
||||
set_server_key(server_key.clone());
|
||||
let clear_a = random::<bool>();
|
||||
|
||||
@@ -850,7 +850,7 @@ mod zk {
|
||||
fn conformance_zk_compact_ciphertext_list() {
|
||||
let mut rng = thread_rng();
|
||||
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
|
||||
let cpk_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
|
||||
@@ -957,12 +957,13 @@ pub mod gpu {
|
||||
mod tests {
|
||||
use crate::prelude::*;
|
||||
use crate::safe_serialization::{safe_deserialize, safe_serialize};
|
||||
#[cfg(any(not(feature = "gpu"), feature = "strings"))]
|
||||
use crate::shortint::parameters::test_params::TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
#[cfg(feature = "gpu")]
|
||||
use crate::shortint::parameters::COMP_PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
#[cfg(feature = "gpu")]
|
||||
use crate::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
use crate::shortint::parameters::{
|
||||
COMP_PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
@@ -983,9 +984,10 @@ mod tests {
|
||||
),
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128.into(),
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128.into(),
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
),
|
||||
#[cfg(feature = "gpu")]
|
||||
(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into(),
|
||||
COMP_PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
@@ -1147,7 +1149,7 @@ mod tests {
|
||||
#[cfg(feature = "strings")]
|
||||
#[test]
|
||||
fn test_compressed_strings_cpu() {
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let config = crate::ConfigBuilder::with_custom_parameters(params)
|
||||
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128)
|
||||
.build();
|
||||
|
||||
@@ -628,24 +628,25 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::prelude::*;
|
||||
use crate::safe_serialization::{safe_deserialize, safe_serialize};
|
||||
use crate::shortint::parameters::current_params::*;
|
||||
use crate::{generate_keys, set_server_key, ConfigBuilder, FheBool, FheInt32, FheUint32};
|
||||
use crate::shortint::parameters::test_params::TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
#[cfg(feature = "gpu")]
|
||||
use crate::shortint::parameters::v1_5::{
|
||||
V1_5_NOISE_SQUASHING_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_5_NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_5_NOISE_SQUASHING_PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_5_PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_5_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
#[cfg(feature = "gpu")]
|
||||
use crate::ConfigBuilder;
|
||||
use crate::{generate_keys, set_server_key, FheBool, FheInt32, FheUint32};
|
||||
use rand::Rng;
|
||||
|
||||
#[test]
|
||||
fn test_compressed_squashed_noise_ciphertext_list() {
|
||||
let params = V1_5_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let noise_squashing_params =
|
||||
V1_5_NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let noise_squashing_compression_params =
|
||||
V1_5_NOISE_SQUASHING_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let meta_params = TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
|
||||
let config = ConfigBuilder::with_custom_parameters(params)
|
||||
.enable_noise_squashing(noise_squashing_params)
|
||||
.enable_noise_squashing_compression(noise_squashing_compression_params)
|
||||
.build();
|
||||
|
||||
let (cks, sks) = generate_keys(config);
|
||||
let (cks, sks) = generate_keys(meta_params);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ use crate::prelude::{
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128,
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
};
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
use crate::{
|
||||
generate_keys, set_server_key, CompactCiphertextList, CompactPublicKey, CompressedFheInt16,
|
||||
CompressedFheInt32, CompressedFheInt32ConformanceParams, ConfigBuilder, DeserializationConfig,
|
||||
@@ -205,7 +205,7 @@ fn test_leading_trailing_zeros_ones() {
|
||||
|
||||
#[test]
|
||||
fn test_safe_deserialize_conformant_fhe_int32() {
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let block_params = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let (client_key, server_key) =
|
||||
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
|
||||
set_server_key(server_key.clone());
|
||||
@@ -230,7 +230,7 @@ fn test_safe_deserialize_conformant_fhe_int32() {
|
||||
|
||||
#[test]
|
||||
fn test_safe_deserialize_conformant_compressed_fhe_int32() {
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let block_params = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let (client_key, server_key) =
|
||||
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
|
||||
set_server_key(server_key.clone());
|
||||
|
||||
@@ -1850,7 +1850,10 @@ mod test {
|
||||
use super::*;
|
||||
use crate::core_crypto::prelude::UnsignedInteger;
|
||||
use crate::prelude::*;
|
||||
use crate::shortint::parameters::{AtomicPatternKind, PARAM_MESSAGE_2_CARRY_2_KS_PBS};
|
||||
use crate::shortint::parameters::{
|
||||
AtomicPatternKind, PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
};
|
||||
use crate::shortint::{CiphertextModulus, PBSOrder};
|
||||
use crate::{generate_keys, set_server_key, ConfigBuilder, FheUint8};
|
||||
use rand::{thread_rng, Rng};
|
||||
@@ -1880,7 +1883,7 @@ mod test {
|
||||
let ct = FheUint8::try_encrypt(0_u64, &client_key).unwrap();
|
||||
|
||||
assert!(ct.is_conformant(&FheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
)));
|
||||
|
||||
let breaker_lists = [
|
||||
@@ -1940,7 +1943,7 @@ mod test {
|
||||
breaker(i, &mut ct_clone);
|
||||
|
||||
assert!(!ct_clone.is_conformant(&FheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -1957,7 +1960,7 @@ mod test {
|
||||
let ct = FheUint8::try_encrypt(0_u64, &client_key).unwrap();
|
||||
|
||||
assert!(ct.is_conformant(&FheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
)));
|
||||
|
||||
let mut rng = thread_rng();
|
||||
@@ -1975,7 +1978,7 @@ mod test {
|
||||
}
|
||||
|
||||
assert!(ct.is_conformant(&FheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
)));
|
||||
|
||||
ct_clone += &ct_clone.clone();
|
||||
|
||||
@@ -263,7 +263,7 @@ where
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::core_crypto::prelude::UnsignedInteger;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
use crate::shortint::{CiphertextModulus, CompressedCiphertext};
|
||||
use crate::{generate_keys, set_server_key, CompressedFheUint8, ConfigBuilder};
|
||||
use rand::{thread_rng, Rng};
|
||||
@@ -315,7 +315,7 @@ mod test {
|
||||
let ct = CompressedFheUint8::try_encrypt(0_u64, &client_key).unwrap();
|
||||
|
||||
assert!(ct.is_conformant(&CompressedFheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128
|
||||
)));
|
||||
|
||||
let breaker_lists = [
|
||||
@@ -340,7 +340,7 @@ mod test {
|
||||
|
||||
assert!(
|
||||
!ct_clone.is_conformant(&CompressedFheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128
|
||||
))
|
||||
);
|
||||
}
|
||||
@@ -373,7 +373,7 @@ mod test {
|
||||
|
||||
assert!(
|
||||
!ct_clone.is_conformant(&CompressedFheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128
|
||||
))
|
||||
);
|
||||
}
|
||||
@@ -391,7 +391,7 @@ mod test {
|
||||
let ct = CompressedFheUint8::try_encrypt(0_u64, &client_key).unwrap();
|
||||
|
||||
assert!(ct.is_conformant(&CompressedFheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128
|
||||
)));
|
||||
|
||||
let mut rng = thread_rng();
|
||||
@@ -410,9 +410,10 @@ mod test {
|
||||
.seed
|
||||
.0 = rng.gen::<u128>();
|
||||
}
|
||||
|
||||
assert!(
|
||||
ct_clone.is_conformant(&CompressedFheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128
|
||||
))
|
||||
);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ use crate::high_level_api::{generate_keys, set_server_key, ConfigBuilder, FheUin
|
||||
use crate::integer::U256;
|
||||
use crate::safe_serialization::{DeserializationConfig, SerializationConfig};
|
||||
use crate::shortint::parameters::test_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
use crate::{
|
||||
ClientKey, CompactCiphertextList, CompactCiphertextListConformanceParams, CompactPublicKey,
|
||||
CompressedCompactPublicKey, CompressedFheUint16, CompressedFheUint256, CompressedFheUint32,
|
||||
@@ -470,7 +469,7 @@ fn test_match_value() {
|
||||
|
||||
#[test]
|
||||
fn test_safe_deserialize_conformant_fhe_uint32() {
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let block_params = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let (client_key, server_key) =
|
||||
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
|
||||
set_server_key(server_key.clone());
|
||||
@@ -494,7 +493,7 @@ fn test_safe_deserialize_conformant_fhe_uint32() {
|
||||
|
||||
#[test]
|
||||
fn test_safe_deserialize_conformant_compressed_fhe_uint32() {
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
let block_params = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let (client_key, server_key) =
|
||||
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
|
||||
set_server_key(server_key.clone());
|
||||
@@ -519,7 +518,7 @@ fn test_safe_deserialize_conformant_compressed_fhe_uint32() {
|
||||
|
||||
#[test]
|
||||
fn test_safe_deserialize_conformant_compact_fhe_uint32() {
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
let block_params = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let (client_key, server_key) =
|
||||
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
|
||||
set_server_key(server_key);
|
||||
@@ -555,9 +554,9 @@ fn test_safe_deserialize_conformant_compact_fhe_uint32() {
|
||||
|
||||
#[test]
|
||||
fn test_cpk_encrypt_cast_compute_hl() {
|
||||
let param_pke_only = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_fhe = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_ksk = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_fhe = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let param_pke_only = TEST_PARAM_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV2;
|
||||
let param_ksk = TEST_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let num_block = 4usize;
|
||||
|
||||
@@ -604,10 +603,9 @@ fn test_cpk_encrypt_cast_compute_hl() {
|
||||
|
||||
#[test]
|
||||
fn test_compressed_cpk_encrypt_cast_compute_hl() {
|
||||
let param_pke_only = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_fhe = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_ksk = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let param_fhe = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let param_pke_only = TEST_PARAM_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV2;
|
||||
let param_ksk = TEST_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let num_block = 4usize;
|
||||
|
||||
assert_eq!(param_pke_only.message_modulus, param_fhe.message_modulus);
|
||||
|
||||
@@ -117,7 +117,7 @@ impl Default for IntegerConfig {
|
||||
fn default() -> Self {
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
let params =
|
||||
crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into();
|
||||
crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128.into();
|
||||
#[cfg(feature = "gpu")]
|
||||
let params =
|
||||
crate::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
|
||||
@@ -57,7 +57,7 @@ impl PublicKey {
|
||||
}
|
||||
|
||||
pub(crate) fn message_modulus(&self) -> MessageModulus {
|
||||
self.key.parameters().message_modulus()
|
||||
self.key.key.parameters.message_modulus()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::high_level_api::{
|
||||
CompactPublicKey, CompressedCiphertextListBuilder, ConfigBuilder, FheBool, FheInt8, FheUint64,
|
||||
ReRandomizationContext,
|
||||
};
|
||||
use crate::shortint::parameters::v1_5::meta::cpu::V1_5_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_BIG_ZKV2_TUNIFORM_2M128;
|
||||
use crate::shortint::parameters::test_params::TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
#[cfg(feature = "gpu")]
|
||||
use crate::shortint::parameters::v1_5::meta::gpu::V1_5_META_PARAM_GPU_2_2_MULTI_BIT_GROUP_4_KS_PBS_PKE_TO_BIG_ZKV2_TUNIFORM_2M128;
|
||||
use crate::shortint::parameters::{MetaParameters, ShortintKeySwitchingParameters};
|
||||
@@ -211,7 +211,7 @@ fn setup_re_rand_test(
|
||||
|
||||
#[test]
|
||||
fn test_re_rand() {
|
||||
let params = V1_5_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_BIG_ZKV2_TUNIFORM_2M128;
|
||||
let params = TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let (cks, sks, cpk) = setup_re_rand_test(params);
|
||||
|
||||
set_server_key(sks.decompress());
|
||||
|
||||
@@ -10,6 +10,7 @@ use crate::high_level_api::{
|
||||
generate_keys, ClientKey, ConfigBuilder, FheBool, FheUint256, FheUint8, PublicKey, ServerKey,
|
||||
};
|
||||
use crate::integer::U256;
|
||||
use crate::shortint::parameters::test_params::TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
use crate::shortint::parameters::TestParameters;
|
||||
use crate::shortint::ClassicPBSParameters;
|
||||
use crate::{
|
||||
@@ -186,7 +187,7 @@ fn test_serialize_deserialize_are_implemented() {
|
||||
|
||||
#[test]
|
||||
fn test_try_from_single_lwe_encryption_key() {
|
||||
let parameters = crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let parameters = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let lwe_sk = crate::shortint::engine::ShortintEngine::with_thread_local_mut(|engine| {
|
||||
crate::core_crypto::algorithms::allocate_and_generate_new_binary_lwe_secret_key(
|
||||
parameters
|
||||
|
||||
@@ -15,6 +15,7 @@ use crate::shortint::parameters::{
|
||||
AtomicPatternParameters, ClassicPBSParameters, CompactPublicKeyEncryptionParameters,
|
||||
ShortintKeySwitchingParameters,
|
||||
};
|
||||
use crate::shortint::AtomicPatternKind;
|
||||
use crate::{ClientKey, CompactCiphertextList, CompactPublicKey, ConfigBuilder, FheUint2};
|
||||
|
||||
use rayon::prelude::*;
|
||||
@@ -120,8 +121,9 @@ fn noise_check_compact_public_key_encryption_noise_tuniform(
|
||||
block_params: ClassicPBSParameters,
|
||||
) {
|
||||
// Hack to avoid server key needs and get the ciphertext directly
|
||||
cpke_params.expansion_kind =
|
||||
CompactCiphertextListExpansionKind::NoCasting(block_params.encryption_key_choice.into());
|
||||
cpke_params.expansion_kind = CompactCiphertextListExpansionKind::NoCasting(
|
||||
AtomicPatternKind::Standard(block_params.encryption_key_choice.into_pbs_order()),
|
||||
);
|
||||
|
||||
let modulus_as_f64 = cpke_params.ciphertext_modulus.raw_modulus_float();
|
||||
|
||||
|
||||
@@ -549,7 +549,7 @@ mod tests {
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::upgrade::{DecompressionUpgradeKey, UpgradeKeyChain};
|
||||
use crate::*;
|
||||
@@ -621,7 +621,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_keychain_upgrade() {
|
||||
let compute_params = TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let compute_params = TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
let compression_parameters = TEST_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let config = ConfigBuilder::with_custom_parameters(compute_params)
|
||||
|
||||
@@ -1306,6 +1306,7 @@ mod zk_pok_tests {
|
||||
};
|
||||
use crate::shortint::ciphertext::Degree;
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1,
|
||||
TEST_PARAM_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1,
|
||||
};
|
||||
@@ -1319,9 +1320,16 @@ mod zk_pok_tests {
|
||||
use rand::random;
|
||||
|
||||
fn test_zk_list(is_packed: bool) {
|
||||
let pke_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let pke_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.pke_params;
|
||||
let ksk_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.ksk_params;
|
||||
let fhe_params = params.compute_parameters;
|
||||
|
||||
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
|
||||
|
||||
@@ -1411,9 +1419,16 @@ mod zk_pok_tests {
|
||||
|
||||
#[test]
|
||||
fn test_zk_empty_list() {
|
||||
let pke_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let pke_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.pke_params;
|
||||
let ksk_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.ksk_params;
|
||||
let fhe_params = params.compute_parameters;
|
||||
|
||||
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
|
||||
|
||||
@@ -1563,9 +1578,16 @@ mod zk_pok_tests {
|
||||
/// is modified
|
||||
#[test]
|
||||
fn test_attack_list_info() {
|
||||
let pke_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let pke_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.pke_params;
|
||||
let ksk_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.ksk_params;
|
||||
let fhe_params = params.compute_parameters;
|
||||
|
||||
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
|
||||
|
||||
@@ -1683,9 +1705,16 @@ mod zk_pok_tests {
|
||||
|
||||
#[test]
|
||||
fn test_attack_proven_list_metadata() {
|
||||
let pke_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let pke_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.pke_params;
|
||||
let ksk_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.ksk_params;
|
||||
let fhe_params = params.compute_parameters;
|
||||
|
||||
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
|
||||
|
||||
@@ -1795,9 +1824,16 @@ mod zk_pok_tests {
|
||||
|
||||
#[test]
|
||||
fn test_several_proven_lists() {
|
||||
let pke_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let pke_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.pke_params;
|
||||
let ksk_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.ksk_params;
|
||||
let fhe_params = params.compute_parameters;
|
||||
|
||||
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
|
||||
|
||||
@@ -1858,9 +1894,16 @@ mod zk_pok_tests {
|
||||
fn test_malicious_boolean_proven_lists() {
|
||||
use super::DataKind;
|
||||
|
||||
let pke_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let pke_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.pke_params;
|
||||
let ksk_params = params
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.ksk_params;
|
||||
let fhe_params = params.compute_parameters;
|
||||
|
||||
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
|
||||
|
||||
|
||||
@@ -224,6 +224,8 @@ mod tests {
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_COMP_PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
@@ -278,6 +280,22 @@ mod tests {
|
||||
TEST_PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into(),
|
||||
TEST_COMP_PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
),
|
||||
(
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128
|
||||
.compute_parameters
|
||||
.into(),
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128
|
||||
.compression_parameters
|
||||
.unwrap(),
|
||||
),
|
||||
(
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128
|
||||
.compute_parameters
|
||||
.into(),
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128
|
||||
.compression_parameters
|
||||
.unwrap(),
|
||||
),
|
||||
] {
|
||||
let (cks, sks) = gen_keys::<ShortintParameterSet>(params, IntegerKeyKind::Radix);
|
||||
|
||||
|
||||
@@ -420,18 +420,14 @@ impl CompressedSquashedNoiseCiphertextListBuilder {
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::integer::noise_squashing::NoiseSquashingKey;
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_NOISE_SQUASHING_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::shortint::parameters::test_params::TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
use rand::Rng;
|
||||
|
||||
#[test]
|
||||
fn test_compressed_noise_squashed_ciphertext_list() {
|
||||
let param = TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let noise_squashing_parameters =
|
||||
TEST_PARAM_NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let meta_param = TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let param = meta_param.compute_parameters;
|
||||
let noise_squashing_parameters = meta_param.noise_squashing_parameters.unwrap().parameters;
|
||||
|
||||
// The goal is to test that encrypting a value stored in a type
|
||||
// for which the bit count does not match the target block count of the encrypted
|
||||
@@ -442,7 +438,11 @@ mod test {
|
||||
let noise_squashing_key = NoiseSquashingKey::new(&cks, &noise_squashing_private_key);
|
||||
|
||||
let noise_squashing_compression_private_key = NoiseSquashingCompressionPrivateKey::new(
|
||||
TEST_PARAM_NOISE_SQUASHING_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
meta_param
|
||||
.noise_squashing_parameters
|
||||
.unwrap()
|
||||
.compression_parameters
|
||||
.unwrap(),
|
||||
);
|
||||
let compression_key = noise_squashing_private_key
|
||||
.new_noise_squashing_compression_key(&noise_squashing_compression_private_key);
|
||||
|
||||
@@ -5,12 +5,7 @@ use crate::integer::{
|
||||
gen_keys, BooleanBlock, CompactPrivateKey, CompactPublicKey, IntegerKeyKind, RadixCiphertext,
|
||||
SignedRadixCiphertext,
|
||||
};
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV2,
|
||||
};
|
||||
use crate::shortint::parameters::test_params::TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
use crate::shortint::ShortintParameterSet;
|
||||
use itertools::Itertools;
|
||||
use rand::Rng;
|
||||
@@ -20,12 +15,20 @@ const NUM_BLOCKS: usize = 32;
|
||||
|
||||
#[test]
|
||||
fn test_ciphertext_re_randomization_after_compression() {
|
||||
let params = TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into();
|
||||
let comp_params = TEST_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let cpk_params = TEST_PARAM_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV2;
|
||||
let ks_params = TEST_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let meta_param = TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let params = meta_param.compute_parameters;
|
||||
let comp_params = meta_param.compression_parameters.unwrap();
|
||||
let cpk_params = meta_param
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.pke_params;
|
||||
let ks_params = meta_param
|
||||
.dedicated_compact_public_key_parameters
|
||||
.unwrap()
|
||||
.re_randomization_parameters
|
||||
.unwrap();
|
||||
|
||||
let (cks, sks) = gen_keys::<ShortintParameterSet>(params, IntegerKeyKind::Radix);
|
||||
let (cks, sks) = gen_keys::<ShortintParameterSet>(params.into(), IntegerKeyKind::Radix);
|
||||
|
||||
let private_compression_key = cks.new_compression_private_key(comp_params);
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
use crate::integer::keycache::KEY_CACHE;
|
||||
use crate::integer::noise_squashing::{NoiseSquashingKey, NoiseSquashingPrivateKey};
|
||||
use crate::integer::IntegerKeyKind;
|
||||
use crate::shortint::parameters::{
|
||||
NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::shortint::parameters::test_params::TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
use rand::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn test_integer_noise_squashing_decrypt_auto_cast_and_bool() {
|
||||
let param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let noise_squashing_parameters = NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let meta_param = TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let param = meta_param.compute_parameters;
|
||||
let noise_squashing_parameters = meta_param.noise_squashing_parameters.unwrap().parameters;
|
||||
|
||||
// The goal is to test that encrypting a value stored in a type
|
||||
// for which the bit count does not match the target block count of the encrypted
|
||||
@@ -21,7 +19,7 @@ fn test_integer_noise_squashing_decrypt_auto_cast_and_bool() {
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let num_blocks = 32u32.div_ceil(param.message_modulus.0.ilog2()) as usize;
|
||||
let num_blocks = 32u32.div_ceil(param.message_modulus().0.ilog2()) as usize;
|
||||
|
||||
// Positive signed value
|
||||
let value = rng.gen_range(0..=i32::MAX);
|
||||
|
||||
@@ -70,8 +70,8 @@ impl CompressedPublicKey {
|
||||
encrypt_many_crt(&self.key, message, base_vec, encrypt_block)
|
||||
}
|
||||
|
||||
pub fn parameters(&self) -> crate::shortint::PBSParameters {
|
||||
self.key.parameters.pbs_parameters().unwrap()
|
||||
pub fn parameters(&self) -> crate::shortint::ShortintParameterSet {
|
||||
self.key.parameters
|
||||
}
|
||||
|
||||
pub fn encrypt_radix<T: DecomposableInto<u64>>(
|
||||
|
||||
@@ -67,8 +67,8 @@ impl PublicKey {
|
||||
encrypt_crt(&self.key, message, base_vec, encrypt_block)
|
||||
}
|
||||
|
||||
pub fn parameters(&self) -> crate::shortint::PBSParameters {
|
||||
self.key.parameters.pbs_parameters().unwrap()
|
||||
pub fn parameters(&self) -> crate::shortint::ShortintParameterSet {
|
||||
self.key.parameters
|
||||
}
|
||||
|
||||
pub fn encrypt_radix<T>(&self, message: T, num_blocks: usize) -> RadixCiphertext
|
||||
@@ -118,14 +118,16 @@ mod tests {
|
||||
use crate::integer::keycache::KEY_CACHE;
|
||||
use crate::integer::tests::create_parameterized_test;
|
||||
use crate::integer::IntegerKeyKind;
|
||||
use crate::shortint::parameters::test_params::TEST_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
use crate::shortint::parameters::ClassicPBSParameters;
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TestParameters, TEST_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128,
|
||||
};
|
||||
|
||||
create_parameterized_test!(integer_public_key_decompression_small {
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128,
|
||||
});
|
||||
|
||||
fn integer_public_key_decompression_small(param: ClassicPBSParameters) {
|
||||
fn integer_public_key_decompression_small<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let compressed_pk = crate::integer::CompressedPublicKey::new(&cks);
|
||||
|
||||
@@ -15,7 +15,8 @@ create_parameterized_test!(big_radix_encrypt_decrypt_128_bits {
|
||||
},
|
||||
no_coverage => {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
/* PARAM_MESSAGE_3_CARRY_3_KS_PBS, Skipped as the key requires 32GB
|
||||
* PARAM_MESSAGE_4_CARRY_4_KS_PBS, Skipped as the key requires 550GB */
|
||||
}
|
||||
@@ -29,7 +30,8 @@ create_parameterized_test!(
|
||||
},
|
||||
no_coverage => {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
/* PARAM_MESSAGE_3_CARRY_3_KS_PBS, Skipped as its slow
|
||||
* PARAM_MESSAGE_4_CARRY_4_KS_PBS, Skipped as its slow */
|
||||
}
|
||||
@@ -37,35 +39,27 @@ create_parameterized_test!(
|
||||
);
|
||||
|
||||
create_parameterized_test!(
|
||||
big_radix_encrypt_decrypt_compact_128_bits_list {
|
||||
radix_encrypt_decrypt_compact_128_bits_list {
|
||||
coverage => {
|
||||
COVERAGE_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64,
|
||||
},
|
||||
no_coverage => {
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
create_parameterized_test!(
|
||||
small_radix_encrypt_decrypt_compact_128_bits_list {
|
||||
coverage => {
|
||||
COVERAGE_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64,
|
||||
},
|
||||
no_coverage => {
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/// Test that the public key can encrypt a 128 bit number
|
||||
/// in radix decomposition, and that the client key can decrypt it
|
||||
fn big_radix_encrypt_decrypt_128_bits(param: ClassicPBSParameters) {
|
||||
fn big_radix_encrypt_decrypt_128_bits<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, _) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
let public_key = PublicKey::new(&cks);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let num_block = (128f64 / (param.message_modulus.0 as f64).log(2.0)).ceil() as usize;
|
||||
let num_block = (128f64 / (param.message_modulus().0 as f64).log(2.0)).ceil() as usize;
|
||||
|
||||
let clear = rng.gen::<u128>();
|
||||
|
||||
@@ -76,12 +70,13 @@ fn big_radix_encrypt_decrypt_128_bits(param: ClassicPBSParameters) {
|
||||
assert_eq!(clear, dec);
|
||||
}
|
||||
|
||||
fn radix_encrypt_decrypt_compressed_128_bits(param: ClassicPBSParameters) {
|
||||
fn radix_encrypt_decrypt_compressed_128_bits<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, _) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
let public_key = CompressedPublicKey::new(&cks);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let num_block = (128f64 / (param.message_modulus.0 as f64).log(2.0)).ceil() as usize;
|
||||
let num_block = (128f64 / (param.message_modulus().0 as f64).log(2.0)).ceil() as usize;
|
||||
|
||||
let clear = rng.gen::<u128>();
|
||||
|
||||
@@ -92,14 +87,6 @@ fn radix_encrypt_decrypt_compressed_128_bits(param: ClassicPBSParameters) {
|
||||
assert_eq!(clear, dec);
|
||||
}
|
||||
|
||||
fn big_radix_encrypt_decrypt_compact_128_bits_list(params: ClassicPBSParameters) {
|
||||
radix_encrypt_decrypt_compact_128_bits_list(params);
|
||||
}
|
||||
|
||||
fn small_radix_encrypt_decrypt_compact_128_bits_list(params: ClassicPBSParameters) {
|
||||
radix_encrypt_decrypt_compact_128_bits_list(params);
|
||||
}
|
||||
|
||||
fn radix_encrypt_decrypt_compact_128_bits_list(params: ClassicPBSParameters) {
|
||||
let (cks, sks) = gen_keys(params, IntegerKeyKind::Radix);
|
||||
let pk = crate::integer::public_key::CompactPublicKey::new(&cks);
|
||||
|
||||
@@ -227,14 +227,15 @@ fn integer_unchecked_crt_scalar_sub_32_bits() {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_unchecked_crt_mul(param: ClassicPBSParameters) {
|
||||
fn integer_unchecked_crt_mul<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
// generate the server-client key set
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::CRT);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// Define CRT basis, and global modulus
|
||||
let basis = make_basis(param.message_modulus.0);
|
||||
let basis = make_basis(param.message_modulus().0);
|
||||
let modulus = basis.iter().product::<u64>();
|
||||
|
||||
for _ in 0..NB_TESTS {
|
||||
@@ -253,9 +254,10 @@ fn integer_unchecked_crt_mul(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_smart_crt_add(param: ClassicPBSParameters) {
|
||||
fn integer_smart_crt_add<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
// Define CRT basis, and global modulus
|
||||
let basis = make_basis(param.message_modulus.0);
|
||||
let basis = make_basis(param.message_modulus().0);
|
||||
let modulus = basis.iter().product::<u64>();
|
||||
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::CRT);
|
||||
@@ -279,12 +281,13 @@ fn integer_smart_crt_add(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_smart_crt_mul(param: ClassicPBSParameters) {
|
||||
fn integer_smart_crt_mul<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
// generate the server-client key set
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::CRT);
|
||||
|
||||
// Define CRT basis, and global modulus
|
||||
let basis = make_basis(param.message_modulus.0);
|
||||
let basis = make_basis(param.message_modulus().0);
|
||||
let modulus = basis.iter().product::<u64>();
|
||||
|
||||
println!("BASIS = {basis:?}");
|
||||
@@ -308,9 +311,10 @@ fn integer_smart_crt_mul(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_smart_crt_neg(param: ClassicPBSParameters) {
|
||||
fn integer_smart_crt_neg<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
// Define CRT basis, and global modulus
|
||||
let basis = make_basis(param.message_modulus.0);
|
||||
let basis = make_basis(param.message_modulus().0);
|
||||
let modulus = basis.iter().product::<u64>();
|
||||
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::CRT);
|
||||
@@ -334,9 +338,10 @@ fn integer_smart_crt_neg(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_smart_crt_scalar_add(param: ClassicPBSParameters) {
|
||||
fn integer_smart_crt_scalar_add<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
// Define CRT basis, and global modulus
|
||||
let basis = make_basis(param.message_modulus.0);
|
||||
let basis = make_basis(param.message_modulus().0);
|
||||
let modulus = basis.iter().product::<u64>();
|
||||
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::CRT);
|
||||
@@ -358,9 +363,10 @@ fn integer_smart_crt_scalar_add(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_smart_crt_scalar_mul(param: ClassicPBSParameters) {
|
||||
fn integer_smart_crt_scalar_mul<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
// Define CRT basis, and global modulus
|
||||
let basis = make_basis(param.message_modulus.0);
|
||||
let basis = make_basis(param.message_modulus().0);
|
||||
let modulus = basis.iter().product::<u64>();
|
||||
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::CRT);
|
||||
@@ -382,9 +388,10 @@ fn integer_smart_crt_scalar_mul(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_smart_crt_scalar_sub(param: ClassicPBSParameters) {
|
||||
fn integer_smart_crt_scalar_sub<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
// Define CRT basis, and global modulus
|
||||
let basis = make_basis(param.message_modulus.0);
|
||||
let basis = make_basis(param.message_modulus().0);
|
||||
let modulus = basis.iter().product::<u64>();
|
||||
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::CRT);
|
||||
@@ -409,9 +416,10 @@ fn integer_smart_crt_scalar_sub(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_smart_crt_sub(param: ClassicPBSParameters) {
|
||||
fn integer_smart_crt_sub<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
// Define CRT basis, and global modulus
|
||||
let basis = make_basis(param.message_modulus.0);
|
||||
let basis = make_basis(param.message_modulus().0);
|
||||
let modulus = basis.iter().product::<u64>();
|
||||
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::CRT);
|
||||
|
||||
@@ -129,19 +129,21 @@ create_parameterized_test!(integer_unchecked_min {
|
||||
COVERAGE_PARAM_MESSAGE_2_CARRY_2_KS_PBS
|
||||
},
|
||||
no_coverage => {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
}
|
||||
});
|
||||
|
||||
fn integer_encrypt_decrypt(param: ClassicPBSParameters) {
|
||||
fn integer_encrypt_decrypt<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, _) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let modulus = param.message_modulus.0.pow(NB_CTXT as u32);
|
||||
let modulus = param.message_modulus().0.pow(NB_CTXT as u32);
|
||||
|
||||
for _ in 0..NB_TESTS {
|
||||
let clear = rng.gen::<u64>() % modulus;
|
||||
@@ -154,11 +156,12 @@ fn integer_encrypt_decrypt(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_encrypt_decrypt_128_bits(param: ClassicPBSParameters) {
|
||||
fn integer_encrypt_decrypt_128_bits<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, _) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let num_block = 128u32.div_ceil(param.message_modulus.0.ilog2()) as usize;
|
||||
let num_block = 128u32.div_ceil(param.message_modulus().0.ilog2()) as usize;
|
||||
for _ in 0..10 {
|
||||
let clear = rng.gen::<u128>();
|
||||
|
||||
@@ -170,10 +173,11 @@ fn integer_encrypt_decrypt_128_bits(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_encrypt_decrypt_128_bits_specific_values(param: ClassicPBSParameters) {
|
||||
fn integer_encrypt_decrypt_128_bits_specific_values<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let num_block = 128u32.div_ceil(param.message_modulus.0.ilog2()) as usize;
|
||||
let num_block = 128u32.div_ceil(param.message_modulus().0.ilog2()) as usize;
|
||||
{
|
||||
let a = u64::MAX as u128;
|
||||
let ct = cks.encrypt_radix(a, num_block);
|
||||
@@ -218,10 +222,11 @@ fn integer_encrypt_decrypt_128_bits_specific_values(param: ClassicPBSParameters)
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_encrypt_decrypt_256_bits_specific_values(param: ClassicPBSParameters) {
|
||||
fn integer_encrypt_decrypt_256_bits_specific_values<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, _) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let num_block = 256u32.div_ceil(param.message_modulus.0.ilog2()) as usize;
|
||||
let num_block = 256u32.div_ceil(param.message_modulus().0.ilog2()) as usize;
|
||||
{
|
||||
let a = (u64::MAX as u128) << 64;
|
||||
let b = 0;
|
||||
@@ -242,11 +247,12 @@ fn integer_encrypt_decrypt_256_bits_specific_values(param: ClassicPBSParameters)
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_encrypt_decrypt_256_bits(param: ClassicPBSParameters) {
|
||||
fn integer_encrypt_decrypt_256_bits<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, _) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let num_block = 256u32.div_ceil(param.message_modulus.0.ilog2()) as usize;
|
||||
let num_block = 256u32.div_ceil(param.message_modulus().0.ilog2()) as usize;
|
||||
|
||||
for _ in 0..10 {
|
||||
let clear0 = rng.gen::<u128>();
|
||||
@@ -262,7 +268,8 @@ fn integer_encrypt_decrypt_256_bits(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_encrypt_auto_cast(param: ClassicPBSParameters) {
|
||||
fn integer_encrypt_auto_cast<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
// The goal is to test that encrypting a value stored in a type
|
||||
// for which the bit count does not match the target block count of the encrypted
|
||||
// radix properly applies upcasting/downcasting
|
||||
@@ -270,7 +277,7 @@ fn integer_encrypt_auto_cast(param: ClassicPBSParameters) {
|
||||
let (cks, _) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let num_blocks = 32u32.div_ceil(param.message_modulus.0.ilog2()) as usize;
|
||||
let num_blocks = 32u32.div_ceil(param.message_modulus().0.ilog2()) as usize;
|
||||
|
||||
// Positive signed value
|
||||
let value = rng.gen_range(0..=i32::MAX);
|
||||
@@ -311,11 +318,12 @@ fn integer_encrypt_auto_cast(param: ClassicPBSParameters) {
|
||||
assert_eq!(value as u16, d);
|
||||
}
|
||||
|
||||
fn integer_smart_add_128_bits(param: ClassicPBSParameters) {
|
||||
fn integer_smart_add_128_bits<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let num_block = 128u32.div_ceil(param.message_modulus.0.ilog2()) as usize;
|
||||
let num_block = 128u32.div_ceil(param.message_modulus().0.ilog2()) as usize;
|
||||
|
||||
for _ in 0..100 {
|
||||
let clear_0 = rng.gen::<u128>();
|
||||
@@ -346,12 +354,14 @@ fn integer_smart_add_128_bits(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_unchecked_add(param: ClassicPBSParameters) {
|
||||
fn integer_unchecked_add<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::unchecked_add);
|
||||
unchecked_add_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_smart_add(param: ClassicPBSParameters) {
|
||||
fn integer_smart_add<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_add);
|
||||
smart_add_test(param, executor);
|
||||
}
|
||||
@@ -404,15 +414,16 @@ where
|
||||
smart_bitxor_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_unchecked_small_scalar_mul(param: ClassicPBSParameters) {
|
||||
fn integer_unchecked_small_scalar_mul<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// message_modulus^vec_length
|
||||
let modulus = param.message_modulus.0.pow(NB_CTXT as u32);
|
||||
let modulus = param.message_modulus().0.pow(NB_CTXT as u32);
|
||||
|
||||
let scalar_modulus = param.message_modulus.0;
|
||||
let scalar_modulus = param.message_modulus().0;
|
||||
|
||||
for _ in 0..NB_TESTS {
|
||||
let clear = rng.gen::<u64>() % modulus;
|
||||
@@ -430,15 +441,16 @@ fn integer_unchecked_small_scalar_mul(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_smart_small_scalar_mul(param: ClassicPBSParameters) {
|
||||
fn integer_smart_small_scalar_mul<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// message_modulus^vec_length
|
||||
let modulus = param.message_modulus.0.pow(NB_CTXT as u32);
|
||||
let modulus = param.message_modulus().0.pow(NB_CTXT as u32);
|
||||
|
||||
let scalar_modulus = param.message_modulus.0;
|
||||
let scalar_modulus = param.message_modulus().0;
|
||||
|
||||
let mut clear_res;
|
||||
for _ in 0..NB_TESTS_SMALLER {
|
||||
@@ -463,13 +475,14 @@ fn integer_smart_small_scalar_mul(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_blockshift(param: ClassicPBSParameters) {
|
||||
fn integer_blockshift<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// message_modulus^vec_length
|
||||
let modulus = param.message_modulus.0.pow(NB_CTXT as u32);
|
||||
let modulus = param.message_modulus().0.pow(NB_CTXT as u32);
|
||||
|
||||
for _ in 0..NB_TESTS {
|
||||
let clear = rng.gen::<u64>() % modulus;
|
||||
@@ -484,19 +497,20 @@ fn integer_blockshift(param: ClassicPBSParameters) {
|
||||
let dec_res: u64 = cks.decrypt_radix(&ct_res);
|
||||
|
||||
assert_eq!(
|
||||
(clear * param.message_modulus.0.pow(power as u32) as u64) % modulus,
|
||||
(clear * param.message_modulus().0.pow(power as u32) as u64) % modulus,
|
||||
dec_res
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_blockshift_right(param: ClassicPBSParameters) {
|
||||
fn integer_blockshift_right<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// message_modulus^vec_length
|
||||
let modulus = param.message_modulus.0.pow(NB_CTXT as u32);
|
||||
let modulus = param.message_modulus().0.pow(NB_CTXT as u32);
|
||||
|
||||
for _ in 0..NB_TESTS {
|
||||
let clear = rng.gen::<u64>() % modulus;
|
||||
@@ -511,19 +525,20 @@ fn integer_blockshift_right(param: ClassicPBSParameters) {
|
||||
let dec_res: u64 = cks.decrypt_radix(&ct_res);
|
||||
|
||||
assert_eq!(
|
||||
(clear / param.message_modulus.0.pow(power as u32) as u64) % modulus,
|
||||
(clear / param.message_modulus().0.pow(power as u32) as u64) % modulus,
|
||||
dec_res
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_smart_scalar_mul(param: ClassicPBSParameters) {
|
||||
fn integer_smart_scalar_mul<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// message_modulus^vec_length
|
||||
let modulus = param.message_modulus.0.pow(NB_CTXT as u32);
|
||||
let modulus = param.message_modulus().0.pow(NB_CTXT as u32);
|
||||
|
||||
for _ in 0..NB_TESTS {
|
||||
let clear = rng.gen::<u64>() % modulus;
|
||||
@@ -565,7 +580,8 @@ where
|
||||
unchecked_neg_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_smart_neg(param: ClassicPBSParameters) {
|
||||
fn integer_smart_neg<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_neg);
|
||||
smart_neg_test(param, executor);
|
||||
}
|
||||
@@ -578,7 +594,8 @@ where
|
||||
unchecked_sub_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_smart_sub(param: ClassicPBSParameters) {
|
||||
fn integer_smart_sub<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_sub);
|
||||
smart_sub_test(param, executor);
|
||||
}
|
||||
@@ -591,15 +608,16 @@ where
|
||||
unchecked_block_mul_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_smart_block_mul(param: ClassicPBSParameters) {
|
||||
fn integer_smart_block_mul<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// message_modulus^vec_length
|
||||
let modulus = param.message_modulus.0.pow(NB_CTXT as u32);
|
||||
let modulus = param.message_modulus().0.pow(NB_CTXT as u32);
|
||||
|
||||
let block_modulus = param.message_modulus.0;
|
||||
let block_modulus = param.message_modulus().0;
|
||||
|
||||
for _ in 0..5 {
|
||||
// Define the cleartexts
|
||||
@@ -675,7 +693,8 @@ where
|
||||
smart_scalar_sub_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_unchecked_scalar_decomposition_overflow(param: ClassicPBSParameters) {
|
||||
fn integer_unchecked_scalar_decomposition_overflow<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
// This is a regression test.
|
||||
//
|
||||
// The purpose here is to check the behaviour when the scalar value has less bits
|
||||
@@ -683,7 +702,7 @@ fn integer_unchecked_scalar_decomposition_overflow(param: ClassicPBSParameters)
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let num_block = (128_f64 / (param.message_modulus.0 as f64).log(2.0)).ceil() as usize;
|
||||
let num_block = (128_f64 / (param.message_modulus().0 as f64).log(2.0)).ceil() as usize;
|
||||
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
@@ -828,47 +847,56 @@ fn integer_signed_decryption_correctly_sign_extend(param: impl Into<TestParamete
|
||||
assert_eq!(trivial.decrypt_trivial::<i128>().unwrap(), value as i128);
|
||||
}
|
||||
|
||||
fn integer_scalar_blockslice(param: ClassicPBSParameters) {
|
||||
fn integer_scalar_blockslice<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::scalar_blockslice);
|
||||
scalar_blockslice_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_scalar_blockslice_assign(param: ClassicPBSParameters) {
|
||||
fn integer_scalar_blockslice_assign<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::scalar_blockslice_assign);
|
||||
scalar_blockslice_assign_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_unchecked_scalar_slice(param: ClassicPBSParameters) {
|
||||
fn integer_unchecked_scalar_slice<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::unchecked_scalar_bitslice);
|
||||
unchecked_scalar_bitslice_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_unchecked_scalar_slice_assign(param: ClassicPBSParameters) {
|
||||
fn integer_unchecked_scalar_slice_assign<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::unchecked_scalar_bitslice_assign);
|
||||
unchecked_scalar_bitslice_assign_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_default_scalar_slice(param: ClassicPBSParameters) {
|
||||
fn integer_default_scalar_slice<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::scalar_bitslice);
|
||||
default_scalar_bitslice_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_default_scalar_slice_assign(param: ClassicPBSParameters) {
|
||||
fn integer_default_scalar_slice_assign<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::scalar_bitslice_assign);
|
||||
default_scalar_bitslice_assign_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_smart_scalar_slice(param: ClassicPBSParameters) {
|
||||
fn integer_smart_scalar_slice<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_scalar_bitslice);
|
||||
smart_scalar_bitslice_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_smart_scalar_slice_assign(param: ClassicPBSParameters) {
|
||||
fn integer_smart_scalar_slice_assign<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_scalar_bitslice_assign);
|
||||
smart_scalar_bitslice_assign_test(param, executor);
|
||||
}
|
||||
|
||||
fn integer_unchecked_min(param: ClassicPBSParameters) {
|
||||
fn integer_unchecked_min<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::unchecked_min);
|
||||
test_unchecked_minmax(param, 2, executor, std::cmp::min::<u64>);
|
||||
}
|
||||
|
||||
@@ -439,10 +439,7 @@ mod tests {
|
||||
use crate::integer::{
|
||||
gen_keys, ClientKey, IntegerKeyKind, RadixCiphertext, SignedRadixCiphertext,
|
||||
};
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::shortint::parameters::test_params::TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
use crate::shortint::ShortintParameterSet;
|
||||
|
||||
fn assert_store_unsigned_matches(
|
||||
@@ -471,12 +468,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_compression_serialization_unsigned() {
|
||||
let params = TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into();
|
||||
let meta_params = TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let params = meta_params.compute_parameters.into();
|
||||
|
||||
let (cks, _) = gen_keys::<ShortintParameterSet>(params, IntegerKeyKind::Radix);
|
||||
|
||||
let private_compression_key = cks
|
||||
.new_compression_private_key(TEST_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
let private_compression_key =
|
||||
cks.new_compression_private_key(meta_params.compression_parameters.unwrap());
|
||||
|
||||
let (compression_key, decompression_key) =
|
||||
cks.new_compression_decompression_keys(&private_compression_key);
|
||||
@@ -538,12 +536,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_compression_serialization_signed() {
|
||||
let params = TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into();
|
||||
let meta_params = TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
let params = meta_params.compute_parameters.into();
|
||||
|
||||
let (cks, _) = gen_keys::<ShortintParameterSet>(params, IntegerKeyKind::Radix);
|
||||
|
||||
let private_compression_key = cks
|
||||
.new_compression_private_key(TEST_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
let private_compression_key =
|
||||
cks.new_compression_private_key(meta_params.compression_parameters.unwrap());
|
||||
|
||||
let (compression_key, decompression_key) =
|
||||
cks.new_compression_decompression_keys(&private_compression_key);
|
||||
|
||||
@@ -8,21 +8,26 @@ use crate::integer::tests::create_parameterized_test;
|
||||
use crate::integer::{
|
||||
BooleanBlock, IntegerCiphertext, IntegerKeyKind, RadixCiphertext, RadixClientKey, ServerKey,
|
||||
};
|
||||
use crate::shortint::parameters::test_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
use rand::Rng;
|
||||
use std::sync::Arc;
|
||||
|
||||
create_parameterized_test!(safe_erc20 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
create_parameterized_test!(whitepaper_erc20 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
create_parameterized_test!(no_cmux_erc20 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
create_parameterized_test!(overflow_erc20 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn safe_erc20<P>(param: P)
|
||||
|
||||
@@ -7,17 +7,20 @@ use crate::integer::server_key::radix_parallel::tests_long_run::{
|
||||
use crate::integer::server_key::radix_parallel::tests_unsigned::OpSequenceCpuFunctionExecutor;
|
||||
use crate::integer::tests::create_parameterized_test;
|
||||
use crate::integer::{BooleanBlock, IntegerKeyKind, RadixCiphertext, RadixClientKey, ServerKey};
|
||||
use crate::shortint::parameters::test_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
use crate::{ClientKey, CompressedServerKey, MatchValues, Seed, Tag};
|
||||
use std::cmp::{max, min};
|
||||
use std::sync::Arc;
|
||||
|
||||
create_parameterized_test!(random_op_sequence {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
create_parameterized_test!(random_op_sequence_data_generator {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
pub(crate) type BinaryOpExecutor = Box<
|
||||
|
||||
@@ -9,15 +9,18 @@ use crate::integer::{
|
||||
BooleanBlock, IntegerCiphertext, IntegerKeyKind, RadixClientKey, ServerKey,
|
||||
SignedRadixCiphertext,
|
||||
};
|
||||
use crate::shortint::parameters::test_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
use rand::Rng;
|
||||
use std::sync::Arc;
|
||||
|
||||
create_parameterized_test!(whitepaper_erc20 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
create_parameterized_test!(no_cmux_erc20 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn whitepaper_erc20<P>(param: P)
|
||||
|
||||
@@ -9,13 +9,15 @@ use crate::integer::tests::create_parameterized_test;
|
||||
use crate::integer::{
|
||||
BooleanBlock, IntegerKeyKind, RadixCiphertext, RadixClientKey, ServerKey, SignedRadixCiphertext,
|
||||
};
|
||||
use crate::shortint::parameters::test_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
use crate::{ClientKey, CompressedServerKey, Seed, Tag};
|
||||
use std::cmp::{max, min};
|
||||
use std::sync::Arc;
|
||||
|
||||
create_parameterized_test!(random_op_sequence {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
pub(crate) type SignedBinaryOpExecutor = Box<
|
||||
|
||||
@@ -31,7 +31,8 @@ create_parameterized_test!(
|
||||
no_coverage => {
|
||||
// Requires 4 bits, so 1_1 parameters are not supported
|
||||
// until they get their own version of the algorithm
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -59,7 +60,8 @@ create_parameterized_test!(
|
||||
no_coverage => {
|
||||
// Requires 4 bits, so 1_1 parameters are not supported
|
||||
// until they get their own version of the algorithm
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -350,7 +350,8 @@ macro_rules! define_signed_comparison_test_functions {
|
||||
{
|
||||
// Non parallelized does not support 1_1
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
@@ -364,7 +365,8 @@ macro_rules! define_signed_comparison_test_functions {
|
||||
{
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
@@ -378,7 +380,8 @@ macro_rules! define_signed_comparison_test_functions {
|
||||
{
|
||||
// Non parallelized does not support PARAM_MESSAGE_1_CARRY_1_KS_PBS,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as smart test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -394,7 +397,8 @@ macro_rules! define_signed_comparison_test_functions {
|
||||
{
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as smart test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -410,7 +414,8 @@ macro_rules! define_signed_comparison_test_functions {
|
||||
{
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -720,7 +725,8 @@ mod no_coverage {
|
||||
create_parameterized_test!(integer_signed_unchecked_min_parallelized_128_bits);
|
||||
create_parameterized_test!(integer_signed_smart_max_parallelized_128_bits {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -730,7 +736,8 @@ mod no_coverage {
|
||||
});
|
||||
create_parameterized_test!(integer_signed_smart_min_parallelized_128_bits {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -740,7 +747,8 @@ mod no_coverage {
|
||||
});
|
||||
create_parameterized_test!(integer_signed_max_parallelized_128_bits {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -750,7 +758,8 @@ mod no_coverage {
|
||||
});
|
||||
create_parameterized_test!(integer_signed_min_parallelized_128_bits {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
|
||||
@@ -23,7 +23,8 @@ create_parameterized_test!(
|
||||
},
|
||||
no_coverage => {
|
||||
// Does not support 1_1
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -42,7 +43,8 @@ create_parameterized_test!(
|
||||
},
|
||||
no_coverage => {
|
||||
// Does not support 1_1
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -26,7 +26,8 @@ create_parameterized_test!(integer_signed_default_leading_ones);
|
||||
create_parameterized_test!(integer_signed_default_ilog2);
|
||||
create_parameterized_test!(integer_signed_default_checked_ilog2 {
|
||||
// uses comparison so 1_1 parameters are not supported
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -26,7 +26,8 @@ create_parameterized_test!(
|
||||
},
|
||||
no_coverage => {
|
||||
// Uses comparisons internally, so no 1_1
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::integer::server_key::radix_parallel::tests_cases_unsigned::FunctionEx
|
||||
use crate::integer::server_key::radix_parallel::tests_unsigned::CpuFunctionExecutor;
|
||||
use crate::integer::tests::create_parameterized_test;
|
||||
use crate::integer::{IntegerKeyKind, RadixClientKey, ServerKey, SignedRadixCiphertext};
|
||||
use crate::shortint::parameters::test_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
use statrs::distribution::ContinuousCDF;
|
||||
use std::collections::HashMap;
|
||||
@@ -10,11 +11,13 @@ use std::sync::Arc;
|
||||
use tfhe_csprng::seeders::Seed;
|
||||
|
||||
create_parameterized_test!(oprf_signed_uniformity_bounded {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
create_parameterized_test!(oprf_signed_uniformity_unbounded {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn oprf_signed_uniformity_bounded<P>(param: P)
|
||||
|
||||
@@ -269,7 +269,8 @@ macro_rules! define_signed_scalar_comparison_test_functions {
|
||||
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
@@ -284,7 +285,8 @@ macro_rules! define_signed_scalar_comparison_test_functions {
|
||||
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as smart test might overflow values
|
||||
// and when using 3_3 to represent 128 we actually have more than 128 bits
|
||||
@@ -301,7 +303,8 @@ macro_rules! define_signed_scalar_comparison_test_functions {
|
||||
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 128 we actually have more than 128 bits
|
||||
@@ -316,9 +319,10 @@ macro_rules! define_signed_scalar_comparison_test_functions {
|
||||
};
|
||||
}
|
||||
|
||||
fn integer_signed_is_scalar_out_of_bounds(param: ClassicPBSParameters) {
|
||||
fn integer_signed_is_scalar_out_of_bounds<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
let num_block = (128f64 / (param.message_modulus.0 as f64).log(2.0)).ceil() as usize;
|
||||
let num_block = (128f64 / (param.message_modulus().0 as f64).log(2.0)).ceil() as usize;
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
@@ -574,61 +578,56 @@ pub(crate) fn test_signed_default_scalar_minmax<P, T, ClearF, Scalar>(
|
||||
mod no_coverage {
|
||||
use super::*;
|
||||
|
||||
fn integer_signed_unchecked_scalar_min_parallelized_i128(
|
||||
params: crate::shortint::ClassicPBSParameters,
|
||||
) {
|
||||
fn integer_signed_unchecked_scalar_min_parallelized_i128(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::unchecked_scalar_min_parallelized);
|
||||
test_signed_unchecked_scalar_minmax(params, 2, executor, std::cmp::min::<i128>);
|
||||
}
|
||||
|
||||
fn integer_signed_unchecked_scalar_max_parallelized_i128(
|
||||
params: crate::shortint::ClassicPBSParameters,
|
||||
) {
|
||||
fn integer_signed_unchecked_scalar_max_parallelized_i128(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::unchecked_scalar_max_parallelized);
|
||||
test_signed_unchecked_scalar_minmax(params, 2, executor, std::cmp::max::<i128>);
|
||||
}
|
||||
|
||||
fn integer_signed_smart_scalar_min_parallelized_i128(
|
||||
params: crate::shortint::ClassicPBSParameters,
|
||||
) {
|
||||
fn integer_signed_smart_scalar_min_parallelized_i128(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_scalar_min_parallelized);
|
||||
test_signed_smart_scalar_minmax(params, 2, executor, std::cmp::min::<i128>);
|
||||
}
|
||||
|
||||
fn integer_signed_smart_scalar_max_parallelized_i128(
|
||||
params: crate::shortint::ClassicPBSParameters,
|
||||
) {
|
||||
fn integer_signed_smart_scalar_max_parallelized_i128(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_scalar_max_parallelized);
|
||||
test_signed_smart_scalar_minmax(params, 2, executor, std::cmp::max::<i128>);
|
||||
}
|
||||
|
||||
fn integer_signed_scalar_min_parallelized_i128(params: crate::shortint::ClassicPBSParameters) {
|
||||
fn integer_signed_scalar_min_parallelized_i128(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::scalar_min_parallelized);
|
||||
test_signed_default_scalar_minmax(params, 2, executor, std::cmp::min::<i128>);
|
||||
}
|
||||
|
||||
fn integer_signed_scalar_max_parallelized_i128(params: crate::shortint::ClassicPBSParameters) {
|
||||
fn integer_signed_scalar_max_parallelized_i128(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::scalar_max_parallelized);
|
||||
test_signed_default_scalar_minmax(params, 2, executor, std::cmp::max::<i128>);
|
||||
}
|
||||
|
||||
create_parameterized_test!(integer_signed_unchecked_scalar_max_parallelized_i128 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
});
|
||||
create_parameterized_test!(integer_signed_unchecked_scalar_min_parallelized_i128 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
});
|
||||
create_parameterized_test!(integer_signed_smart_scalar_max_parallelized_i128 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -638,7 +637,8 @@ mod no_coverage {
|
||||
});
|
||||
create_parameterized_test!(integer_signed_smart_scalar_min_parallelized_i128 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -648,7 +648,8 @@ mod no_coverage {
|
||||
});
|
||||
create_parameterized_test!(integer_signed_scalar_max_parallelized_i128 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -658,7 +659,8 @@ mod no_coverage {
|
||||
});
|
||||
create_parameterized_test!(integer_signed_scalar_min_parallelized_i128 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -676,7 +678,8 @@ mod no_coverage {
|
||||
|
||||
create_parameterized_test!(integer_signed_is_scalar_out_of_bounds {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as the test relies on the ciphertext to encrypt 128bits
|
||||
// but with param 3_3 we actually encrypt more that 128bits
|
||||
@@ -691,39 +694,31 @@ mod coverage {
|
||||
use super::*;
|
||||
use crate::integer::tests::create_parameterized_test_classical_params;
|
||||
|
||||
fn integer_signed_unchecked_scalar_min_parallelized_i8(
|
||||
params: crate::shortint::ClassicPBSParameters,
|
||||
) {
|
||||
fn integer_signed_unchecked_scalar_min_parallelized_i8(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::unchecked_scalar_min_parallelized);
|
||||
test_signed_unchecked_scalar_minmax(params, 1, executor, std::cmp::min::<i8>);
|
||||
}
|
||||
|
||||
fn integer_signed_unchecked_scalar_max_parallelized_i8(
|
||||
params: crate::shortint::ClassicPBSParameters,
|
||||
) {
|
||||
fn integer_signed_unchecked_scalar_max_parallelized_i8(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::unchecked_scalar_max_parallelized);
|
||||
test_signed_unchecked_scalar_minmax(params, 1, executor, std::cmp::max::<i8>);
|
||||
}
|
||||
fn integer_signed_smart_scalar_min_parallelized_i8(
|
||||
params: crate::shortint::ClassicPBSParameters,
|
||||
) {
|
||||
fn integer_signed_smart_scalar_min_parallelized_i8(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_scalar_min_parallelized);
|
||||
test_signed_smart_scalar_minmax(params, 1, executor, std::cmp::min::<i8>);
|
||||
}
|
||||
|
||||
fn integer_signed_smart_scalar_max_parallelized_i8(
|
||||
params: crate::shortint::ClassicPBSParameters,
|
||||
) {
|
||||
fn integer_signed_smart_scalar_max_parallelized_i8(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_scalar_max_parallelized);
|
||||
test_signed_smart_scalar_minmax(params, 1, executor, std::cmp::max::<i8>);
|
||||
}
|
||||
|
||||
fn integer_signed_scalar_min_parallelized_i8(params: crate::shortint::ClassicPBSParameters) {
|
||||
fn integer_signed_scalar_min_parallelized_i8(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::scalar_min_parallelized);
|
||||
test_signed_default_scalar_minmax(params, 1, executor, std::cmp::min::<i8>);
|
||||
}
|
||||
|
||||
fn integer_signed_scalar_max_parallelized_i8(params: crate::shortint::ClassicPBSParameters) {
|
||||
fn integer_signed_scalar_max_parallelized_i8(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::scalar_max_parallelized);
|
||||
test_signed_default_scalar_minmax(params, 1, executor, std::cmp::max::<i8>);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ create_parameterized_test!(integer_signed_default_overflowing_sub_parallel {
|
||||
COVERAGE_PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS
|
||||
},
|
||||
no_coverage => {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -520,7 +520,8 @@ create_parameterized_test!(
|
||||
},
|
||||
no_coverage => {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_3_KS_PBS_GAUSSIAN_2M128, // Test case where carry_modulus > message_modulus
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
|
||||
@@ -30,7 +30,8 @@ create_parameterized_test!(integer_advanced_overflowing_add_assign_with_carry_at
|
||||
COVERAGE_PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS
|
||||
},
|
||||
no_coverage => {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -47,7 +48,8 @@ create_parameterized_test!(integer_extensive_trivial_overflowing_advanced_add_as
|
||||
COVERAGE_PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS
|
||||
},
|
||||
no_coverage => {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -321,7 +321,8 @@ macro_rules! define_comparison_test_functions {
|
||||
{
|
||||
// Non parallelized does not support 1_1
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
@@ -334,7 +335,8 @@ macro_rules! define_comparison_test_functions {
|
||||
{
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
@@ -348,7 +350,8 @@ macro_rules! define_comparison_test_functions {
|
||||
{
|
||||
// Non parallelized does not support 1_1
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as smart test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -364,7 +367,8 @@ macro_rules! define_comparison_test_functions {
|
||||
{
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as smart test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -380,7 +384,8 @@ macro_rules! define_comparison_test_functions {
|
||||
{
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -670,28 +675,32 @@ mod no_coverage {
|
||||
create_parameterized_test!(integer_unchecked_max_parallelized_u256);
|
||||
create_parameterized_test!(integer_smart_min_parallelized_u256 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// No test for 3_3, see define_comparison_test_functions macro
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
});
|
||||
create_parameterized_test!(integer_smart_max_parallelized_u256 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// No test for 3_3, see define_comparison_test_functions macro
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
});
|
||||
create_parameterized_test!(integer_min_parallelized_u256 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// No test for 3_3, see define_comparison_test_functions macro
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
});
|
||||
create_parameterized_test!(integer_max_parallelized_u256 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// No test for 3_3, see define_comparison_test_functions macro
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
|
||||
@@ -21,7 +21,8 @@ create_parameterized_test!(
|
||||
no_coverage => {
|
||||
// Due to the use of comparison,
|
||||
// this algorithm requires 3 bits
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -41,7 +42,8 @@ create_parameterized_test!(
|
||||
no_coverage => {
|
||||
// Due to the use of comparison,
|
||||
// this algorithm requires 3 bits
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -61,7 +63,8 @@ create_parameterized_test!(
|
||||
no_coverage => {
|
||||
// Due to the use of comparison,
|
||||
// this algorithm requires 3 bits
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -81,7 +84,8 @@ create_parameterized_test!(
|
||||
no_coverage => {
|
||||
// Due to the use of comparison,
|
||||
// this algorithm requires 3 bits
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -101,7 +105,8 @@ create_parameterized_test!(
|
||||
no_coverage => {
|
||||
// Due to the use of comparison,
|
||||
// this algorithm requires 3 bits
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -121,7 +126,8 @@ create_parameterized_test!(
|
||||
no_coverage => {
|
||||
// Due to the use of comparison,
|
||||
// this algorithm requires 3 bits
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -142,7 +148,8 @@ create_parameterized_test!(
|
||||
// Due to the use of comparison,
|
||||
// this algorithm requires 3 bits
|
||||
// The algorithm is agnostic to multibit so we don't test those params
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ create_parameterized_test!(integer_default_leading_ones);
|
||||
create_parameterized_test!(integer_default_ilog2);
|
||||
create_parameterized_test!(integer_default_checked_ilog2 {
|
||||
// This uses comparisons, so require more than 1 bit
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -18,7 +18,8 @@ create_parameterized_test!(
|
||||
},
|
||||
no_coverage => {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -37,7 +38,8 @@ create_parameterized_test!(
|
||||
},
|
||||
no_coverage => {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -248,7 +248,8 @@ macro_rules! define_scalar_comparison_test_functions {
|
||||
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
|
||||
@@ -262,7 +263,8 @@ macro_rules! define_scalar_comparison_test_functions {
|
||||
{
|
||||
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as smart test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -278,7 +280,8 @@ macro_rules! define_scalar_comparison_test_functions {
|
||||
{
|
||||
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as default test might overflow values
|
||||
// and when using 3_3 to represent 256 we actually have more than 256 bits
|
||||
@@ -296,10 +299,11 @@ macro_rules! define_scalar_comparison_test_functions {
|
||||
/// The goal of this function is to ensure that scalar comparisons
|
||||
/// work when the scalar type used is either bigger or smaller (in bit size)
|
||||
/// compared to the ciphertext
|
||||
fn integer_unchecked_scalar_comparisons_edge(param: ClassicPBSParameters) {
|
||||
fn integer_unchecked_scalar_comparisons_edge<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let num_block = (128f64 / (param.message_modulus.0 as f64).log(2.0)).ceil() as usize;
|
||||
let num_block = (128f64 / (param.message_modulus().0 as f64).log(2.0)).ceil() as usize;
|
||||
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
@@ -402,7 +406,8 @@ fn integer_unchecked_scalar_comparisons_edge(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_unchecked_scalar_comparisons_edge_one_block(param: ClassicPBSParameters) {
|
||||
fn integer_unchecked_scalar_comparisons_edge_one_block<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let num_block = 1;
|
||||
@@ -486,7 +491,8 @@ fn integer_unchecked_scalar_comparisons_edge_one_block(param: ClassicPBSParamete
|
||||
|
||||
// Given a ciphertext that consists of empty blocks,
|
||||
// the function tests whether comparisons still hold.
|
||||
fn integer_comparisons_for_empty_blocks(param: ClassicPBSParameters) {
|
||||
fn integer_comparisons_for_empty_blocks<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let mut rng = rand::thread_rng();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
|
||||
@@ -519,9 +525,10 @@ fn integer_comparisons_for_empty_blocks(param: ClassicPBSParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_is_scalar_out_of_bounds(param: ClassicPBSParameters) {
|
||||
fn integer_is_scalar_out_of_bounds<P: Into<TestParameters>>(param: P) {
|
||||
let param: TestParameters = param.into();
|
||||
let (cks, sks) = KEY_CACHE.get_from_params(param, IntegerKeyKind::Radix);
|
||||
let num_block = 128usize.div_ceil(param.message_modulus.0.ilog2() as usize);
|
||||
let num_block = 128usize.div_ceil(param.message_modulus().0.ilog2() as usize);
|
||||
|
||||
let mut rng = thread_rng();
|
||||
|
||||
@@ -764,64 +771,64 @@ pub(crate) fn test_default_scalar_minmax<P, T, ClearF, Scalar>(
|
||||
mod no_coverage {
|
||||
use super::*;
|
||||
|
||||
fn integer_unchecked_scalar_min_parallelized_u256(
|
||||
params: crate::shortint::ClassicPBSParameters,
|
||||
) {
|
||||
fn integer_unchecked_scalar_min_parallelized_u256(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::unchecked_scalar_min_parallelized);
|
||||
test_unchecked_scalar_minmax(params, 2, executor, std::cmp::min::<U256>);
|
||||
}
|
||||
|
||||
fn integer_unchecked_scalar_max_parallelized_u256(
|
||||
params: crate::shortint::ClassicPBSParameters,
|
||||
) {
|
||||
fn integer_unchecked_scalar_max_parallelized_u256(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::unchecked_scalar_max_parallelized);
|
||||
test_unchecked_scalar_minmax(params, 2, executor, std::cmp::max::<U256>);
|
||||
}
|
||||
|
||||
fn integer_smart_scalar_min_parallelized_u256(params: crate::shortint::ClassicPBSParameters) {
|
||||
fn integer_smart_scalar_min_parallelized_u256(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_scalar_min_parallelized);
|
||||
test_smart_scalar_minmax(params, 2, executor, std::cmp::min::<U256>);
|
||||
}
|
||||
|
||||
fn integer_smart_scalar_max_parallelized_u256(params: crate::shortint::ClassicPBSParameters) {
|
||||
fn integer_smart_scalar_max_parallelized_u256(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::smart_scalar_max_parallelized);
|
||||
test_smart_scalar_minmax(params, 2, executor, std::cmp::max::<U256>);
|
||||
}
|
||||
|
||||
fn integer_scalar_min_parallelized_u256(params: crate::shortint::ClassicPBSParameters) {
|
||||
fn integer_scalar_min_parallelized_u256(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::scalar_min_parallelized);
|
||||
test_default_scalar_minmax(params, 2, executor, std::cmp::min::<U256>);
|
||||
}
|
||||
|
||||
fn integer_scalar_max_parallelized_u256(params: crate::shortint::ClassicPBSParameters) {
|
||||
fn integer_scalar_max_parallelized_u256(params: impl Into<TestParameters>) {
|
||||
let executor = CpuFunctionExecutor::new(&ServerKey::scalar_max_parallelized);
|
||||
test_default_scalar_minmax(params, 2, executor, std::cmp::max::<U256>);
|
||||
}
|
||||
|
||||
create_parameterized_test!(integer_unchecked_scalar_min_parallelized_u256 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
});
|
||||
create_parameterized_test!(integer_unchecked_scalar_max_parallelized_u256 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
});
|
||||
create_parameterized_test!(integer_smart_scalar_min_parallelized_u256 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// No test for 3_3, see define_scalar_comparison_test_functions macro
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
});
|
||||
create_parameterized_test!(integer_smart_scalar_max_parallelized_u256 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// No test for 3_3, see define_scalar_comparison_test_functions macro
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
@@ -829,14 +836,16 @@ mod no_coverage {
|
||||
|
||||
create_parameterized_test!(integer_scalar_min_parallelized_u256 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// No test for 3_3, see define_scalar_comparison_test_functions macro
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
});
|
||||
create_parameterized_test!(integer_scalar_max_parallelized_u256 {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// No test for 3_3, see define_scalar_comparison_test_functions macro
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
@@ -851,7 +860,8 @@ mod no_coverage {
|
||||
|
||||
create_parameterized_test!(integer_unchecked_scalar_comparisons_edge {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
@@ -859,14 +869,16 @@ mod no_coverage {
|
||||
|
||||
create_parameterized_test!(integer_unchecked_scalar_comparisons_edge_one_block {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
});
|
||||
|
||||
create_parameterized_test!(integer_is_scalar_out_of_bounds {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// We don't use PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
// as the test relies on the ciphertext to encrypt 128bits
|
||||
// but with param 3_3 we actually encrypt more that 128bits
|
||||
@@ -876,7 +888,8 @@ mod no_coverage {
|
||||
|
||||
create_parameterized_test!(integer_comparisons_for_empty_blocks {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -17,7 +17,8 @@ create_parameterized_test!(
|
||||
},
|
||||
no_coverage => {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -28,7 +29,8 @@ create_parameterized_test!(
|
||||
COVERAGE_PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
},
|
||||
no_coverage => {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -30,7 +30,8 @@ create_parameterized_test!(integer_advanced_sub_assign_with_borrow_at_least_4_bi
|
||||
COVERAGE_PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS
|
||||
},
|
||||
no_coverage => {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -24,7 +24,7 @@ macro_rules! create_parameterized_test {
|
||||
},
|
||||
no_coverage => {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -33,7 +33,9 @@ macro_rules! create_parameterized_test {
|
||||
TEST_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
// Test prod params
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -67,10 +69,12 @@ macro_rules! create_parameterized_test_classical_params {
|
||||
},
|
||||
no_coverage => {
|
||||
TEST_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
TEST_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M128 is too slow for 4_4, it is estimated to be 2x slower
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64
|
||||
TEST_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
// Test prod params
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -82,7 +82,9 @@ impl Upgrade<CompactCiphertextListV1> for CompactCiphertextListV0 {
|
||||
degree: self.degree,
|
||||
message_modulus: self.message_modulus,
|
||||
carry_modulus: self.carry_modulus,
|
||||
expansion_kind: CompactCiphertextListExpansionKind::NoCasting(self.pbs_order),
|
||||
expansion_kind: CompactCiphertextListExpansionKind::NoCasting(
|
||||
AtomicPatternKind::Standard(self.pbs_order),
|
||||
),
|
||||
noise_level: self.noise_level,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,10 +7,31 @@ use super::parameters::{
|
||||
CompactCiphertextListExpansionKind, DynamicDistribution, SupportedCompactPkeZkScheme,
|
||||
};
|
||||
use super::prelude::*;
|
||||
use crate::shortint::AtomicPatternKind;
|
||||
|
||||
#[derive(Version)]
|
||||
pub enum CompactCiphertextListExpansionKindV0 {
|
||||
RequiresCasting,
|
||||
NoCasting(PBSOrder),
|
||||
}
|
||||
|
||||
impl Upgrade<CompactCiphertextListExpansionKind> for CompactCiphertextListExpansionKindV0 {
|
||||
type Error = Infallible;
|
||||
|
||||
fn upgrade(self) -> Result<CompactCiphertextListExpansionKind, Self::Error> {
|
||||
Ok(match self {
|
||||
Self::RequiresCasting => CompactCiphertextListExpansionKind::RequiresCasting,
|
||||
Self::NoCasting(pbsorder) => {
|
||||
CompactCiphertextListExpansionKind::NoCasting(AtomicPatternKind::Standard(pbsorder))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum CompactCiphertextListExpansionKindVersions {
|
||||
V0(CompactCiphertextListExpansionKind),
|
||||
V0(CompactCiphertextListExpansionKindV0),
|
||||
V1(CompactCiphertextListExpansionKind),
|
||||
}
|
||||
|
||||
#[derive(Version)]
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::shortint::atomic_pattern::AtomicPattern;
|
||||
use crate::shortint::backward_compatibility::ciphertext::CompactCiphertextListVersions;
|
||||
pub use crate::shortint::parameters::ShortintCompactCiphertextListCastingMode;
|
||||
use crate::shortint::parameters::{
|
||||
AtomicPatternKind, CarryModulus, CompactCiphertextListExpansionKind, MessageModulus,
|
||||
CarryModulus, CompactCiphertextListExpansionKind, MessageModulus,
|
||||
};
|
||||
use rayon::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -144,7 +144,7 @@ impl CompactCiphertextList {
|
||||
.collect::<Vec<_>>();
|
||||
Ok(res)
|
||||
}
|
||||
(CompactCiphertextListExpansionKind::NoCasting(pbs_order), _) => {
|
||||
(CompactCiphertextListExpansionKind::NoCasting(atomic_pattern), _) => {
|
||||
let res = output_lwe_ciphertext_list
|
||||
.iter()
|
||||
.map(|lwe_view| {
|
||||
@@ -152,7 +152,6 @@ impl CompactCiphertextList {
|
||||
lwe_view.as_ref().to_vec(),
|
||||
self.ct_list.ciphertext_modulus(),
|
||||
);
|
||||
let atomic_pattern = AtomicPatternKind::Standard(pbs_order);
|
||||
|
||||
Ciphertext::new(
|
||||
ct,
|
||||
|
||||
@@ -4,6 +4,7 @@ use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::shortint::ciphertext::{Degree, NoiseLevel};
|
||||
use crate::shortint::client_key::atomic_pattern::EncryptionAtomicPattern;
|
||||
use crate::shortint::parameters::{AtomicPatternKind, CarryModulus, MessageModulus};
|
||||
use crate::shortint::{
|
||||
Ciphertext, ClientKey, CompressedPublicKey, PaddingBit, PublicKey, ShortintEncoding,
|
||||
@@ -47,12 +48,11 @@ impl ShortintEngine {
|
||||
client_key.parameters().ciphertext_modulus(),
|
||||
&mut self.encryption_generator,
|
||||
);
|
||||
|
||||
PublicKey {
|
||||
lwe_public_key,
|
||||
parameters: client_key.parameters(),
|
||||
atomic_pattern: AtomicPatternKind::Standard(
|
||||
client_key.parameters().encryption_key_choice().into(),
|
||||
),
|
||||
atomic_pattern: client_key.atomic_pattern.kind(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,11 +74,6 @@ pub const PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64: ClassicPBSParameters =
|
||||
pub const PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128: ClassicPBSParameters =
|
||||
V1_5_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
pub const PARAM_MESSAGE_2_CARRY_2_KS_PBS: ClassicPBSParameters =
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
pub const PARAM_MESSAGE_2_CARRY_2: ClassicPBSParameters = PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
|
||||
// 2M64
|
||||
pub const PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64: ClassicPBSParameters =
|
||||
V1_5_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
@@ -88,6 +83,15 @@ pub const PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64: ClassicPBSParameters =
|
||||
pub const PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128: KeySwitch32PBSParameters =
|
||||
V1_5_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
|
||||
// "Naked" aliases
|
||||
pub const PARAM_MESSAGE_2_CARRY_2_KS_PBS: ClassicPBSParameters =
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
pub const PARAM_MESSAGE_2_CARRY_2_KS32_PBS: KeySwitch32PBSParameters =
|
||||
PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128;
|
||||
|
||||
pub const PARAM_MESSAGE_2_CARRY_2: KeySwitch32PBSParameters = PARAM_MESSAGE_2_CARRY_2_KS32_PBS;
|
||||
|
||||
// Compression Gaussian
|
||||
// 2M128
|
||||
pub const COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128: CompressionParameters =
|
||||
|
||||
@@ -4,8 +4,8 @@ use crate::shortint::backward_compatibility::parameters::compact_public_key_only
|
||||
};
|
||||
use crate::shortint::parameters::{
|
||||
AtomicPatternKind, CarryModulus, CiphertextModulus, ClassicPBSParameters, DynamicDistribution,
|
||||
LweDimension, MessageModulus, MultiBitPBSParameters, PBSOrder, PBSParameters,
|
||||
ShortintParameterSet, SupportedCompactPkeZkScheme,
|
||||
LweDimension, MessageModulus, MultiBitPBSParameters, PBSParameters, ShortintParameterSet,
|
||||
SupportedCompactPkeZkScheme,
|
||||
};
|
||||
use crate::shortint::{KeySwitchingKeyView, PaddingBit, ShortintEncoding};
|
||||
use crate::Error;
|
||||
@@ -16,7 +16,7 @@ use tfhe_versionable::Versionize;
|
||||
#[versionize(CompactCiphertextListExpansionKindVersions)]
|
||||
pub enum CompactCiphertextListExpansionKind {
|
||||
RequiresCasting,
|
||||
NoCasting(PBSOrder),
|
||||
NoCasting(AtomicPatternKind),
|
||||
}
|
||||
|
||||
pub type CastingFunctionsOwned<'functions> =
|
||||
@@ -35,10 +35,7 @@ pub enum ShortintCompactCiphertextListCastingMode<'a> {
|
||||
|
||||
impl From<AtomicPatternKind> for CompactCiphertextListExpansionKind {
|
||||
fn from(value: AtomicPatternKind) -> Self {
|
||||
match value {
|
||||
AtomicPatternKind::Standard(pbsorder) => Self::NoCasting(pbsorder),
|
||||
AtomicPatternKind::KeySwitch32 => Self::NoCasting(PBSOrder::KeyswitchBootstrap),
|
||||
}
|
||||
Self::NoCasting(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,9 +126,7 @@ impl TryFrom<ShortintParameterSet> for CompactPublicKeyEncryptionParameters {
|
||||
let message_modulus = parameters.message_modulus();
|
||||
let carry_modulus = parameters.carry_modulus();
|
||||
let ciphertext_modulus = parameters.ciphertext_modulus();
|
||||
let output_ciphertext_kind = CompactCiphertextListExpansionKind::NoCasting(
|
||||
parameters.encryption_key_choice().into(),
|
||||
);
|
||||
let output_ciphertext_kind = parameters.atomic_pattern().into();
|
||||
|
||||
Self::try_new(
|
||||
encryption_lwe_dimension,
|
||||
|
||||
@@ -237,3 +237,10 @@ pub const TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128: Met
|
||||
|
||||
pub const TEST_META_PARAM_CPU_2_2_KS_PBS_GAUSSIAN_2M128: MetaParameters =
|
||||
V1_5_META_PARAM_CPU_2_2_KS_PBS_GAUSSIAN_2M128;
|
||||
|
||||
// Prod params
|
||||
pub const TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128: ClassicPBSParameters =
|
||||
crate::shortint::parameters::v1_4::V1_4_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
pub const TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128: MetaParameters =
|
||||
crate::shortint::parameters::v1_4::meta::cpu::V1_4_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128;
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::shortint::engine::ShortintEngine;
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::shortint::parameters::{AtomicPatternParameters, CarryModulus, MetaParameters};
|
||||
use crate::shortint::server_key::tests::noise_distribution::utils::noise_simulation::NoiseSimulationModulus;
|
||||
@@ -167,8 +167,8 @@ fn sanity_check_encrypt_br_dp_ks_pbs(meta_params: MetaParameters) {
|
||||
|
||||
create_parameterized_test!(sanity_check_encrypt_br_dp_ks_pbs {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn encrypt_br_dp_ks_any_ms_inner_helper(
|
||||
@@ -500,8 +500,8 @@ fn noise_check_encrypt_br_dp_ks_ms_noise(meta_params: MetaParameters) {
|
||||
|
||||
create_parameterized_test!(noise_check_encrypt_br_dp_ks_ms_noise {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn noise_check_encrypt_br_dp_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
@@ -566,6 +566,6 @@ fn noise_check_encrypt_br_dp_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
|
||||
create_parameterized_test!(noise_check_encrypt_br_dp_ks_ms_pfail {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::shortint::engine::ShortintEngine;
|
||||
use crate::shortint::list_compression::{CompressionKey, CompressionPrivateKeys};
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::shortint::parameters::{
|
||||
AtomicPatternParameters, CarryModulus, CiphertextModulusLog, CompressionParameters,
|
||||
@@ -159,8 +159,8 @@ fn sanity_check_encrypt_br_dp_packing_ks_ms(meta_params: MetaParameters) {
|
||||
}
|
||||
|
||||
create_parameterized_test!(sanity_check_encrypt_br_dp_packing_ks_ms {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
@@ -518,8 +518,8 @@ fn noise_check_encrypt_br_dp_packing_ks_ms_noise(meta_params: MetaParameters) {
|
||||
assert!(before_ms_normality.null_hypothesis_is_valid && after_ms_is_ok);
|
||||
}
|
||||
create_parameterized_test!(noise_check_encrypt_br_dp_packing_ks_ms_noise {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn noise_check_encrypt_br_dp_packing_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
@@ -683,6 +683,6 @@ fn noise_check_encrypt_br_dp_packing_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
}
|
||||
|
||||
create_parameterized_test!(noise_check_encrypt_br_dp_packing_ks_ms_pfail {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ use crate::shortint::key_switching_key::{KeySwitchingKeyBuildHelper, KeySwitchin
|
||||
use crate::shortint::list_compression::{CompressionPrivateKeys, DecompressionKey};
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::shortint::parameters::{
|
||||
AtomicPatternParameters, CarryModulus, CompactCiphertextListExpansionKind,
|
||||
@@ -595,9 +595,7 @@ fn noise_check_encrypt_br_rerand_dp_ks_ms_noise(meta_params: MetaParameters) {
|
||||
// expand
|
||||
let cpk_params = {
|
||||
let mut cpk_params = dedicated_cpk_params.pke_params;
|
||||
cpk_params.expansion_kind = CompactCiphertextListExpansionKind::NoCasting(
|
||||
compute_params.encryption_key_choice().into_pbs_order(),
|
||||
);
|
||||
cpk_params.expansion_kind = compute_params.atomic_pattern().into();
|
||||
cpk_params
|
||||
};
|
||||
|
||||
@@ -789,8 +787,8 @@ fn noise_check_encrypt_br_rerand_dp_ks_ms_noise(meta_params: MetaParameters) {
|
||||
}
|
||||
|
||||
create_parameterized_test!(noise_check_encrypt_br_rerand_dp_ks_ms_noise {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn noise_check_encrypt_br_rerand_dp_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
@@ -801,9 +799,8 @@ fn noise_check_encrypt_br_rerand_dp_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
// expand
|
||||
let cpk_params = {
|
||||
let mut cpk_params = dedicated_cpk_params.pke_params;
|
||||
cpk_params.expansion_kind = CompactCiphertextListExpansionKind::NoCasting(
|
||||
compute_params.encryption_key_choice().into_pbs_order(),
|
||||
);
|
||||
cpk_params.expansion_kind =
|
||||
CompactCiphertextListExpansionKind::NoCasting(compute_params.atomic_pattern());
|
||||
cpk_params
|
||||
};
|
||||
|
||||
@@ -896,8 +893,8 @@ fn noise_check_encrypt_br_rerand_dp_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
}
|
||||
|
||||
create_parameterized_test!(noise_check_encrypt_br_rerand_dp_ks_ms_pfail {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn sanity_check_encrypt_br_rerand_dp_ks_ms_pbs(meta_params: MetaParameters) {
|
||||
@@ -908,9 +905,8 @@ fn sanity_check_encrypt_br_rerand_dp_ks_ms_pbs(meta_params: MetaParameters) {
|
||||
// expand
|
||||
let cpk_params = {
|
||||
let mut cpk_params = dedicated_cpk_params.pke_params;
|
||||
cpk_params.expansion_kind = CompactCiphertextListExpansionKind::NoCasting(
|
||||
compute_params.encryption_key_choice().into_pbs_order(),
|
||||
);
|
||||
cpk_params.expansion_kind =
|
||||
CompactCiphertextListExpansionKind::NoCasting(compute_params.atomic_pattern());
|
||||
cpk_params
|
||||
};
|
||||
|
||||
@@ -1057,6 +1053,6 @@ fn sanity_check_encrypt_br_rerand_dp_ks_ms_pbs(meta_params: MetaParameters) {
|
||||
}
|
||||
|
||||
create_parameterized_test!(sanity_check_encrypt_br_rerand_dp_ks_ms_pbs {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ use crate::shortint::engine::ShortintEngine;
|
||||
use crate::shortint::key_switching_key::{KeySwitchingKeyBuildHelper, KeySwitchingKeyView};
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::shortint::parameters::{
|
||||
AtomicPatternParameters, CarryModulus, CompactCiphertextListExpansionKind,
|
||||
@@ -333,9 +333,7 @@ fn noise_check_encrypt_cpk_ks_ms_noise(meta_params: MetaParameters) {
|
||||
// expand
|
||||
let cpk_params = {
|
||||
let mut cpk_params = dedicated_cpk_params.pke_params;
|
||||
cpk_params.expansion_kind = CompactCiphertextListExpansionKind::NoCasting(
|
||||
compute_params.encryption_key_choice().into_pbs_order(),
|
||||
);
|
||||
cpk_params.expansion_kind = compute_params.atomic_pattern().into();
|
||||
cpk_params
|
||||
};
|
||||
|
||||
@@ -452,8 +450,8 @@ fn noise_check_encrypt_cpk_ks_ms_noise(meta_params: MetaParameters) {
|
||||
}
|
||||
|
||||
create_parameterized_test!(noise_check_encrypt_cpk_ks_ms_noise {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn noise_check_encrypt_cpk_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
@@ -464,9 +462,7 @@ fn noise_check_encrypt_cpk_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
// expand
|
||||
let cpk_params = {
|
||||
let mut cpk_params = dedicated_cpk_params.pke_params;
|
||||
cpk_params.expansion_kind = CompactCiphertextListExpansionKind::NoCasting(
|
||||
compute_params.encryption_key_choice().into_pbs_order(),
|
||||
);
|
||||
cpk_params.expansion_kind = compute_params.atomic_pattern().into();
|
||||
cpk_params
|
||||
};
|
||||
|
||||
@@ -546,8 +542,8 @@ fn noise_check_encrypt_cpk_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
}
|
||||
|
||||
create_parameterized_test!(noise_check_encrypt_cpk_ks_ms_pfail {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn sanity_check_encrypt_cpk_ks_ms_pbs(meta_params: MetaParameters) {
|
||||
@@ -559,9 +555,7 @@ fn sanity_check_encrypt_cpk_ks_ms_pbs(meta_params: MetaParameters) {
|
||||
let (cpk_params, orig_cast_mode) = {
|
||||
let mut cpk_params = dedicated_cpk_params.pke_params;
|
||||
let orig_cast_mode = cpk_params.expansion_kind;
|
||||
cpk_params.expansion_kind = CompactCiphertextListExpansionKind::NoCasting(
|
||||
compute_params.encryption_key_choice().into_pbs_order(),
|
||||
);
|
||||
cpk_params.expansion_kind = compute_params.atomic_pattern().into();
|
||||
(cpk_params, orig_cast_mode)
|
||||
};
|
||||
|
||||
@@ -642,6 +636,6 @@ fn sanity_check_encrypt_cpk_ks_ms_pbs(meta_params: MetaParameters) {
|
||||
}
|
||||
|
||||
create_parameterized_test!(sanity_check_encrypt_cpk_ks_ms_pbs {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::shortint::engine::ShortintEngine;
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::shortint::parameters::{AtomicPatternParameters, CarryModulus, MetaParameters};
|
||||
use crate::shortint::server_key::tests::parameterized_test::create_parameterized_test;
|
||||
@@ -190,8 +190,8 @@ fn sanity_check_encrypt_dp_ks_pbs(meta_params: MetaParameters) {
|
||||
|
||||
create_parameterized_test!(sanity_check_encrypt_dp_ks_pbs {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn encrypt_dp_ks_any_ms_inner_helper(
|
||||
@@ -480,8 +480,8 @@ fn noise_check_encrypt_dp_ks_ms_noise(meta_params: MetaParameters) {
|
||||
|
||||
create_parameterized_test!(noise_check_encrypt_dp_ks_ms_noise {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
fn noise_check_encrypt_dp_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
@@ -546,6 +546,6 @@ fn noise_check_encrypt_dp_ks_ms_pfail(meta_params: MetaParameters) {
|
||||
|
||||
create_parameterized_test!(noise_check_encrypt_dp_ks_ms_pfail {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::shortint::noise_squashing::{NoiseSquashingKey, NoiseSquashingPrivateK
|
||||
use crate::shortint::parameters::noise_squashing::NoiseSquashingParameters;
|
||||
use crate::shortint::parameters::test_params::{
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::shortint::parameters::{
|
||||
AtomicPatternParameters, MetaParameters, NoiseSquashingCompressionParameters,
|
||||
@@ -327,8 +327,8 @@ fn sanity_check_encrypt_dp_ks_standard_pbs128_packing_ks(meta_params: MetaParame
|
||||
}
|
||||
|
||||
create_parameterized_test!(sanity_check_encrypt_dp_ks_standard_pbs128_packing_ks {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
@@ -804,6 +804,6 @@ fn noise_check_encrypt_dp_ks_standard_pbs128_packing_ks_noise(meta_params: MetaP
|
||||
}
|
||||
|
||||
create_parameterized_test!(noise_check_encrypt_dp_ks_standard_pbs128_packing_ks_noise {
|
||||
TEST_META_PARAM_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_CPU_2_2_KS32_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
TEST_META_PARAM_PROD_CPU_2_2_KS_PBS_PKE_TO_SMALL_ZKV2_TUNIFORM_2M128,
|
||||
});
|
||||
|
||||
@@ -56,7 +56,9 @@ macro_rules! create_parameterized_test{
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
// To still be able to test prod
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,7 +63,10 @@ macro_rules! create_parameterized_test_bivariate_pbs_compliant{
|
||||
TEST_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64
|
||||
TEST_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
TEST_PARAM_MESSAGE_2_CARRY_2_KS32_PBS_TUNIFORM_2M128,
|
||||
// To still be able to test prod
|
||||
TEST_PARAM_PROD_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user