mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-11 23:58:23 -05:00
Compare commits
37 Commits
create-pul
...
release/0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42f741f31e | ||
|
|
6be6df3804 | ||
|
|
6e863a0df9 | ||
|
|
1c25212779 | ||
|
|
4045e2df34 | ||
|
|
8f3d56623a | ||
|
|
6b2bf7b66b | ||
|
|
8707234817 | ||
|
|
61794d4534 | ||
|
|
68b86648f8 | ||
|
|
a678ce88dc | ||
|
|
6c65548db5 | ||
|
|
da90e89d38 | ||
|
|
87b882c460 | ||
|
|
fb7a95ffd7 | ||
|
|
0da0bfde06 | ||
|
|
10ff0ad968 | ||
|
|
3bf0fc80b7 | ||
|
|
b4dc1a2e9e | ||
|
|
607c831b95 | ||
|
|
838d3ea6de | ||
|
|
26a167be68 | ||
|
|
4148ea7139 | ||
|
|
abcdfe0dbd | ||
|
|
9009f3a71a | ||
|
|
21e2ba8f67 | ||
|
|
6c2979737b | ||
|
|
64eb80beef | ||
|
|
e786241806 | ||
|
|
d0f60a9646 | ||
|
|
f67da1c8c8 | ||
|
|
5738e2880c | ||
|
|
4a5bde08b8 | ||
|
|
6c927e0619 | ||
|
|
9189ea26d9 | ||
|
|
c8772100f9 | ||
|
|
681f23e445 |
5
.github/workflows/aws_tfhe_fast_tests.yml
vendored
5
.github/workflows/aws_tfhe_fast_tests.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -119,6 +119,7 @@ jobs:
|
||||
repository: zama-ai/tfhe-backward-compat-data
|
||||
path: tfhe/tfhe-backward-compat-data
|
||||
lfs: 'true'
|
||||
ref: 'v0.1'
|
||||
|
||||
- name: Run backward compatibility tests
|
||||
run: |
|
||||
@@ -140,7 +141,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
4
.github/workflows/aws_tfhe_gpu_tests.yml
vendored
4
.github/workflows/aws_tfhe_gpu_tests.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -187,7 +187,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
4
.github/workflows/aws_tfhe_integer_tests.yml
vendored
4
.github/workflows/aws_tfhe_integer_tests.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -93,7 +93,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -117,7 +117,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -97,7 +97,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
4
.github/workflows/aws_tfhe_tests.yml
vendored
4
.github/workflows/aws_tfhe_tests.yml
vendored
@@ -129,7 +129,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -235,7 +235,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
4
.github/workflows/aws_tfhe_wasm_tests.yml
vendored
4
.github/workflows/aws_tfhe_wasm_tests.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -90,7 +90,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
2
.github/workflows/check_commit.yml
vendored
2
.github/workflows/check_commit.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
- name: Check first line
|
||||
uses: gsactions/commit-message-checker@16fa2d5de096ae0d35626443bcd24f1e756cafee
|
||||
with:
|
||||
pattern: '^((feat|fix|chore|refactor|style|test|docs|doc)(\([\w\-_]+\))?\:) .+$'
|
||||
pattern: '^((feat|fix|chore|refactor|style|test|docs|doc)(\([\w\-_]+\))?\!?\:) .+$'
|
||||
flags: "gs"
|
||||
error: 'Your first line has to contain a commit type and scope like "feat(my_feature): msg".'
|
||||
excludeDescription: "true" # optional: this excludes the description body of a pull request
|
||||
|
||||
4
.github/workflows/code_coverage.yml
vendored
4
.github/workflows/code_coverage.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -125,7 +125,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -175,7 +175,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -78,7 +78,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -143,7 +143,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
4
.github/workflows/integer_gpu_benchmark.yml
vendored
4
.github/workflows/integer_gpu_benchmark.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -187,7 +187,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -180,7 +180,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -189,7 +189,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -164,7 +164,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -168,7 +168,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
4
.github/workflows/make_release_cuda.yml
vendored
4
.github/workflows/make_release_cuda.yml
vendored
@@ -29,7 +29,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -112,7 +112,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
4
.github/workflows/wasm_client_benchmark.yml
vendored
4
.github/workflows/wasm_client_benchmark.yml
vendored
@@ -62,7 +62,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -171,7 +171,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
4
.github/workflows/zk_pke_benchmark.yml
vendored
4
.github/workflows/zk_pke_benchmark.yml
vendored
@@ -65,7 +65,7 @@ jobs:
|
||||
steps:
|
||||
- name: Start instance
|
||||
id: start-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: start
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
@@ -182,7 +182,7 @@ jobs:
|
||||
steps:
|
||||
- name: Stop instance
|
||||
id: stop-instance
|
||||
uses: zama-ai/slab-github-runner@58f2cae4bf2c0b6728083f5f009b6dc0eb6dc3ac
|
||||
uses: zama-ai/slab-github-runner@447a2d0fd2d1a9d647aa0d0723a6e9255372f261
|
||||
with:
|
||||
mode: stop
|
||||
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,6 +7,7 @@ target/
|
||||
# In case of symlinked keys
|
||||
/keys
|
||||
|
||||
**/*.rmeta
|
||||
**/Cargo.lock
|
||||
**/*.bin
|
||||
|
||||
|
||||
@@ -8,10 +8,13 @@ members = [
|
||||
"concrete-csprng",
|
||||
"backends/tfhe-cuda-backend",
|
||||
"utils/tfhe-versionable",
|
||||
"utils/tfhe-versionable-derive"
|
||||
"utils/tfhe-versionable-derive",
|
||||
]
|
||||
|
||||
exclude = [
|
||||
"tfhe/backward_compatibility_tests"
|
||||
"tfhe/backward_compatibility_tests",
|
||||
"utils/cargo-tfhe-lints-inner",
|
||||
"utils/cargo-tfhe-lints"
|
||||
]
|
||||
|
||||
[profile.bench]
|
||||
|
||||
18
Makefile
18
Makefile
@@ -20,6 +20,7 @@ BENCH_OP_FLAVOR?=DEFAULT
|
||||
NODE_VERSION=20
|
||||
FORWARD_COMPAT?=OFF
|
||||
BACKWARD_COMPAT_DATA_URL=https://github.com/zama-ai/tfhe-backward-compat-data.git
|
||||
BACKWARD_COMPAT_DATA_BRANCH=v0.1
|
||||
BACKWARD_COMPAT_DATA_DIR=tfhe-backward-compat-data
|
||||
# sed: -n, do not print input stream, -e means a script/expression
|
||||
# 1,/version/ indicates from the first line, to the line matching version at the start of the line
|
||||
@@ -117,7 +118,7 @@ install_cargo_nextest: install_rs_build_toolchain
|
||||
.PHONY: install_wasm_pack # Install wasm-pack to build JS packages
|
||||
install_wasm_pack: install_rs_build_toolchain
|
||||
@wasm-pack --version > /dev/null 2>&1 || \
|
||||
cargo $(CARGO_RS_BUILD_TOOLCHAIN) install wasm-pack || \
|
||||
cargo $(CARGO_RS_BUILD_TOOLCHAIN) install --locked wasm-pack@0.12.1 || \
|
||||
( echo "Unable to install cargo wasm-pack, unknown error." && exit 1 )
|
||||
|
||||
.PHONY: install_node # Install last version of NodeJS via nvm
|
||||
@@ -147,6 +148,11 @@ install_tarpaulin: install_rs_build_toolchain
|
||||
cargo $(CARGO_RS_BUILD_TOOLCHAIN) install cargo-tarpaulin --locked || \
|
||||
( echo "Unable to install cargo tarpaulin, unknown error." && exit 1 )
|
||||
|
||||
.PHONY: install_tfhe_lints # Install custom tfhe-rs lints
|
||||
install_tfhe_lints:
|
||||
(cd utils/cargo-tfhe-lints-inner && cargo install --path .) && \
|
||||
cd utils/cargo-tfhe-lints && cargo install --path .
|
||||
|
||||
.PHONY: check_linelint_installed # Check if linelint newline linter is installed
|
||||
check_linelint_installed:
|
||||
@printf "\n" | linelint - > /dev/null 2>&1 || \
|
||||
@@ -318,6 +324,11 @@ clippy_cuda_backend: install_rs_check_toolchain
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy --all-targets \
|
||||
-p tfhe-cuda-backend -- --no-deps -D warnings
|
||||
|
||||
.PHONY: tfhe_lints # Run custom tfhe-rs lints
|
||||
tfhe_lints: install_tfhe_lints
|
||||
cd tfhe && RUSTFLAGS="$(RUSTFLAGS)" cargo tfhe-lints \
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer -- -D warnings
|
||||
|
||||
.PHONY: build_core # Build core_crypto without experimental features
|
||||
build_core: install_rs_build_toolchain install_rs_check_toolchain
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) build --profile $(CARGO_PROFILE) \
|
||||
@@ -403,6 +414,7 @@ build_web_js_api_parallel: install_rs_check_toolchain install_wasm_pack
|
||||
wasm-pack build --release --target=web \
|
||||
-- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,parallel-wasm-api,zk-pok \
|
||||
-Z build-std=panic_abort,std
|
||||
jq '.files += ["snippets"]' tfhe/pkg/package.json > tmp_pkg.json && mv -f tmp_pkg.json tfhe/pkg/package.json
|
||||
|
||||
.PHONY: build_node_js_api # Build the js API targeting nodejs
|
||||
build_node_js_api: install_rs_build_toolchain install_wasm_pack
|
||||
@@ -960,7 +972,7 @@ write_params_to_file: install_rs_check_toolchain
|
||||
|
||||
.PHONY: clone_backward_compat_data # Clone the data repo needed for backward compatibility tests
|
||||
clone_backward_compat_data:
|
||||
./scripts/clone_backward_compat_data.sh $(BACKWARD_COMPAT_DATA_URL) tfhe/$(BACKWARD_COMPAT_DATA_DIR)
|
||||
./scripts/clone_backward_compat_data.sh $(BACKWARD_COMPAT_DATA_URL) $(BACKWARD_COMPAT_DATA_BRANCH) tfhe/$(BACKWARD_COMPAT_DATA_DIR)
|
||||
|
||||
tfhe/$(BACKWARD_COMPAT_DATA_DIR): clone_backward_compat_data
|
||||
|
||||
@@ -990,7 +1002,7 @@ sha256_bool: install_rs_check_toolchain
|
||||
|
||||
.PHONY: pcc # pcc stands for pre commit checks (except GPU)
|
||||
pcc: no_tfhe_typo no_dbg_log check_fmt lint_doc check_md_docs_are_tested check_intra_md_links \
|
||||
clippy_all check_compile_tests
|
||||
clippy_all tfhe_lints check_compile_tests
|
||||
|
||||
.PHONY: pcc_gpu # pcc stands for pre commit checks for GPU compilation
|
||||
pcc_gpu: clippy_gpu clippy_cuda_backend check_compile_tests_benches_gpu
|
||||
|
||||
@@ -208,7 +208,7 @@ When a new update is published in the Lattice Estimator, we update parameters ac
|
||||
|
||||
### Security model
|
||||
|
||||
The default parameters for the TFHE-rs library are chosen considering the IND-CPA security model, and are selected with a bootstrapping failure probability fixed at p_error = $2^{-40}$. In particular, it is assumed that the results of decrypted computations are not shared by the secret key owner with any third parties, as such an action can lead to leakage of the secret encryption key. If you are designing an application where decryptions must be shared, you will need to craft custom encryption parameters which are chosen in consideration of the IND-CPA^D security model [1].
|
||||
The default parameters for the TFHE-rs library are chosen considering the IND-CPA security model, and are selected with a bootstrapping failure probability fixed at p_error = $2^{-64}$. In particular, it is assumed that the results of decrypted computations are not shared by the secret key owner with any third parties, as such an action can lead to leakage of the secret encryption key. If you are designing an application where decryptions must be shared, you will need to craft custom encryption parameters which are chosen in consideration of the IND-CPA^D security model [1].
|
||||
|
||||
[1] Li, Baiyu, et al. "Securing approximate homomorphic encryption using differential privacy." Annual International Cryptology Conference. Cham: Springer Nature Switzerland, 2022. https://eprint.iacr.org/2022/816.pdf
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[backend.aws.cpu-big]
|
||||
region = "eu-west-3"
|
||||
image_id = "ami-051942e4055555752"
|
||||
image_id = "ami-09b5f2f71828035d4"
|
||||
instance_type = "m6i.32xlarge"
|
||||
|
||||
[backend.aws.cpu-big_fallback]
|
||||
@@ -10,7 +10,7 @@ instance_type = "m6i.32xlarge"
|
||||
|
||||
[backend.aws.cpu-small]
|
||||
region = "eu-west-3"
|
||||
image_id = "ami-051942e4055555752"
|
||||
image_id = "ami-09b5f2f71828035d4"
|
||||
instance_type = "m6i.4xlarge"
|
||||
|
||||
[backend.aws.bench]
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "$0 git_url dest_path"
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "invalid arguments, usage:\n"
|
||||
echo "$0 git_url branch dest_path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -12,8 +13,9 @@ if ! git lfs env 2>/dev/null >/dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d $2 ]; then
|
||||
cd $2 && git pull
|
||||
if [ -d $3 ]; then
|
||||
cd $3 && git fetch --depth 1 && git reset --hard origin/$2 && git clean -dfx
|
||||
|
||||
else
|
||||
git clone $1 $2
|
||||
git clone $1 -b $2 --depth 1 $3
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tfhe-zk-pok"
|
||||
version = "0.2.0"
|
||||
version = "0.2.2"
|
||||
edition = "2021"
|
||||
keywords = ["zero", "knowledge", "proof", "vector-commitments"]
|
||||
homepage = "https://zama.ai/"
|
||||
@@ -13,9 +13,9 @@ description = "tfhe-zk-pok: An implementation of zero-knowledge proofs of encryp
|
||||
|
||||
[dependencies]
|
||||
ark-bls12-381 = { package = "tfhe-ark-bls12-381", version = "0.4.0" }
|
||||
ark-ec = { package = "tfhe-ark-ec", version = "0.4.2" }
|
||||
ark-ff = { package = "tfhe-ark-ff", version = "0.4.3" }
|
||||
ark-poly = { package = "tfhe-ark-poly", version = "0.4.2" }
|
||||
ark-ec = { package = "tfhe-ark-ec", version = "0.4.2", features = ["parallel"] }
|
||||
ark-ff = { package = "tfhe-ark-ff", version = "0.4.3", features = ["parallel"] }
|
||||
ark-poly = { package = "tfhe-ark-poly", version = "0.4.2", features = ["parallel"] }
|
||||
ark-serialize = { version = "0.4.2" }
|
||||
rand = "0.8.5"
|
||||
rayon = "1.8.0"
|
||||
|
||||
@@ -242,6 +242,96 @@ mod g2 {
|
||||
.unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
// m is an intermediate variable that's used in both the curve point addition and pairing
|
||||
// functions. we cache it since it requires a Zp division
|
||||
// https://hackmd.io/@tazAymRSQCGXTUKkbh1BAg/Sk27liTW9#Math-Formula-for-Point-Addition
|
||||
pub(crate) fn compute_m(self, other: G2Affine) -> Option<crate::curve_446::Fq2> {
|
||||
let zero = crate::curve_446::Fq2::ZERO;
|
||||
|
||||
// in the context of elliptic curves, the point at infinity is the zero element of the
|
||||
// group
|
||||
if self.inner.infinity || other.inner.infinity {
|
||||
return None;
|
||||
}
|
||||
|
||||
if self == other {
|
||||
let x = self.inner.x;
|
||||
let y = self.inner.y;
|
||||
if y == zero {
|
||||
None
|
||||
} else {
|
||||
let xx = x.square();
|
||||
Some((xx.double() + xx) / y.double())
|
||||
}
|
||||
} else {
|
||||
let x1 = self.inner.x;
|
||||
let y1 = self.inner.y;
|
||||
let x2 = other.inner.x;
|
||||
let y2 = other.inner.y;
|
||||
|
||||
let x_delta = x2 - x1;
|
||||
let y_delta = y2 - y1;
|
||||
|
||||
if x_delta == zero {
|
||||
None
|
||||
} else {
|
||||
Some(y_delta / x_delta)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn double(self, m: Option<crate::curve_446::Fq2>) -> Self {
|
||||
// in the context of elliptic curves, the point at infinity is the zero element of the
|
||||
// group
|
||||
if self.inner.infinity {
|
||||
return self;
|
||||
}
|
||||
|
||||
let mut result = self;
|
||||
|
||||
let x = self.inner.x;
|
||||
let y = self.inner.y;
|
||||
|
||||
if let Some(m) = m {
|
||||
let x3 = m.square() - x.double();
|
||||
let y3 = m * (x - x3) - y;
|
||||
|
||||
(result.inner.x, result.inner.y) = (x3, y3);
|
||||
} else {
|
||||
result.inner.infinity = true;
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
pub(crate) fn add_unequal(self, other: G2Affine, m: Option<crate::curve_446::Fq2>) -> Self {
|
||||
// in the context of elliptic curves, the point at infinity is the zero element of the
|
||||
// group
|
||||
if self.inner.infinity {
|
||||
return other;
|
||||
}
|
||||
if other.inner.infinity {
|
||||
return self;
|
||||
}
|
||||
|
||||
let mut result = self;
|
||||
|
||||
let x1 = self.inner.x;
|
||||
let y1 = self.inner.y;
|
||||
let x2 = other.inner.x;
|
||||
|
||||
if let Some(m) = m {
|
||||
let x3 = m.square() - x1 - x2;
|
||||
let y3 = m * (x1 - x3) - y1;
|
||||
|
||||
(result.inner.x, result.inner.y) = (x3, y3);
|
||||
} else {
|
||||
result.inner.infinity = true;
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
@@ -373,9 +463,9 @@ mod g2 {
|
||||
}
|
||||
|
||||
pub fn double(self) -> Self {
|
||||
Self {
|
||||
inner: self.inner.double(),
|
||||
}
|
||||
let mut this = self;
|
||||
this.inner.double_in_place();
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,51 +521,79 @@ mod g2 {
|
||||
}
|
||||
|
||||
mod gt {
|
||||
use crate::curve_446::{Fq, Fq12, Fq2};
|
||||
|
||||
use super::*;
|
||||
use ark_ec::bls12::Bls12Config;
|
||||
use ark_ec::pairing::{MillerLoopOutput, Pairing};
|
||||
use ark_ff::{CubicExtField, Fp12, Fp2, QuadExtField};
|
||||
use ark_ff::{CubicExtField, QuadExtField};
|
||||
|
||||
type Bls = crate::curve_446::Bls12_446;
|
||||
type Config = crate::curve_446::Config;
|
||||
|
||||
const ONE: Fp2<<Config as Bls12Config>::Fp2Config> = QuadExtField {
|
||||
c0: MontFp!("1"),
|
||||
c1: MontFp!("0"),
|
||||
};
|
||||
const ZERO: Fp2<<Config as Bls12Config>::Fp2Config> = QuadExtField {
|
||||
const ZERO: Fq2 = QuadExtField {
|
||||
c0: MontFp!("0"),
|
||||
c1: MontFp!("0"),
|
||||
};
|
||||
|
||||
const U1: Fp12<<Config as Bls12Config>::Fp12Config> = QuadExtField {
|
||||
c0: CubicExtField {
|
||||
c0: ZERO,
|
||||
c1: ZERO,
|
||||
c2: ZERO,
|
||||
},
|
||||
c1: CubicExtField {
|
||||
c0: ONE,
|
||||
c1: ZERO,
|
||||
c2: ZERO,
|
||||
},
|
||||
// computed by copying the result from
|
||||
// let two: Fq = MontFp!("2"); println!("{}", two.inverse().unwrap()), which we can't compute in
|
||||
// a const context;
|
||||
const TWO_INV: Fq = {
|
||||
MontFp!("86412351771428577990035638289747981121746346761394949218917418178192828331138736448451251370148591845087981000773214233672031082665302")
|
||||
};
|
||||
const U3: Fp12<<Config as Bls12Config>::Fp12Config> = QuadExtField {
|
||||
c0: CubicExtField {
|
||||
c0: ZERO,
|
||||
c1: ZERO,
|
||||
c2: ZERO,
|
||||
},
|
||||
c1: CubicExtField {
|
||||
c0: ZERO,
|
||||
c1: ONE,
|
||||
c2: ZERO,
|
||||
},
|
||||
const TWO_INV_MINUS_1: Fq = {
|
||||
MontFp!("86412351771428577990035638289747981121746346761394949218917418178192828331138736448451251370148591845087981000773214233672031082665301")
|
||||
};
|
||||
|
||||
const fn fp2_to_fp12(
|
||||
x: Fp2<<Config as Bls12Config>::Fp2Config>,
|
||||
) -> Fp12<<Config as Bls12Config>::Fp12Config> {
|
||||
// the only non zero value in inv(U1) and inv(U3), which come from Olivier's equations.
|
||||
const C: Fq2 = QuadExtField {
|
||||
c0: TWO_INV,
|
||||
c1: TWO_INV_MINUS_1,
|
||||
};
|
||||
|
||||
fn fp2_mul_c(x: Fq2) -> Fq2 {
|
||||
let x0_c0 = x.c0 * C.c0;
|
||||
let x1_c0 = x.c1 * C.c0;
|
||||
|
||||
let x0_c1 = x0_c0 - x.c0;
|
||||
let x1_c1 = x1_c0 - x.c1;
|
||||
|
||||
QuadExtField {
|
||||
c0: x0_c0 - x1_c1,
|
||||
c1: x0_c1 + x1_c0,
|
||||
}
|
||||
}
|
||||
|
||||
fn fp2_mul_u1_inv(x: Fq2) -> Fq12 {
|
||||
QuadExtField {
|
||||
c0: CubicExtField {
|
||||
c0: ZERO,
|
||||
c1: ZERO,
|
||||
c2: ZERO,
|
||||
},
|
||||
c1: CubicExtField {
|
||||
c0: ZERO,
|
||||
c1: ZERO,
|
||||
c2: fp2_mul_c(x),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn fp2_mul_u3_inv(x: Fq2) -> Fq12 {
|
||||
QuadExtField {
|
||||
c0: CubicExtField {
|
||||
c0: ZERO,
|
||||
c1: ZERO,
|
||||
c2: ZERO,
|
||||
},
|
||||
c1: CubicExtField {
|
||||
c0: ZERO,
|
||||
c1: fp2_mul_c(x),
|
||||
c2: ZERO,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const fn fp2_to_fp12(x: Fq2) -> Fq12 {
|
||||
QuadExtField {
|
||||
c0: CubicExtField {
|
||||
c0: x,
|
||||
@@ -490,52 +608,59 @@ mod gt {
|
||||
}
|
||||
}
|
||||
|
||||
const fn fp_to_fp12(
|
||||
x: <Config as Bls12Config>::Fp,
|
||||
) -> Fp12<<Config as Bls12Config>::Fp12Config> {
|
||||
fp2_to_fp12(QuadExtField {
|
||||
const fn fp_to_fp2(x: Fq) -> Fq2 {
|
||||
QuadExtField {
|
||||
c0: x,
|
||||
c1: MontFp!("0"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn ate_tangent_ev(qt: G2, evpt: G1) -> Fp12<<Config as Bls12Config>::Fp12Config> {
|
||||
let qt = qt.inner.into_affine();
|
||||
let evpt = evpt.inner.into_affine();
|
||||
const fn fp_to_fp12(x: Fq) -> Fq12 {
|
||||
fp2_to_fp12(fp_to_fp2(x))
|
||||
}
|
||||
|
||||
fn ate_tangent_ev(qt: G2Affine, evpt: G1Affine, m: Fq2) -> Fq12 {
|
||||
let qt = qt.inner;
|
||||
let evpt = evpt.inner;
|
||||
|
||||
let (xt, yt) = (qt.x, qt.y);
|
||||
let (xe, ye) = (evpt.x, evpt.y);
|
||||
|
||||
let xt = fp2_to_fp12(xt);
|
||||
let yt = fp2_to_fp12(yt);
|
||||
let xe = fp_to_fp12(xe);
|
||||
let ye = fp_to_fp12(ye);
|
||||
let l = m;
|
||||
let mut l_xe = l;
|
||||
l_xe.c0 *= xe;
|
||||
l_xe.c1 *= xe;
|
||||
|
||||
let three = fp_to_fp12(MontFp!("3"));
|
||||
let two = fp_to_fp12(MontFp!("2"));
|
||||
let mut r0 = fp_to_fp12(ye);
|
||||
let r1 = fp2_mul_u1_inv(l_xe);
|
||||
let r2 = fp2_mul_u3_inv(l * xt - yt);
|
||||
|
||||
let l = three * xt.square() / (two * yt);
|
||||
ye - (l * xe) / U1 + (l * xt - yt) / U3
|
||||
r0.c1.c1 = r2.c1.c1;
|
||||
r0.c1.c2 = -r1.c1.c2;
|
||||
|
||||
r0
|
||||
}
|
||||
|
||||
fn ate_line_ev(q1: G2, q2: G2, evpt: G1) -> Fp12<<Config as Bls12Config>::Fp12Config> {
|
||||
let q1 = q1.inner.into_affine();
|
||||
let q2 = q2.inner.into_affine();
|
||||
let evpt = evpt.inner.into_affine();
|
||||
fn ate_line_ev(q1: G2Affine, evpt: G1Affine, m: Fq2) -> Fq12 {
|
||||
let q1 = q1.inner;
|
||||
let evpt = evpt.inner;
|
||||
|
||||
let (x1, y1) = (q1.x, q1.y);
|
||||
let (x2, y2) = (q2.x, q2.y);
|
||||
let (xe, ye) = (evpt.x, evpt.y);
|
||||
|
||||
let x1 = fp2_to_fp12(x1);
|
||||
let y1 = fp2_to_fp12(y1);
|
||||
let x2 = fp2_to_fp12(x2);
|
||||
let y2 = fp2_to_fp12(y2);
|
||||
let xe = fp_to_fp12(xe);
|
||||
let ye = fp_to_fp12(ye);
|
||||
let l = m;
|
||||
let mut l_xe = l;
|
||||
l_xe.c0 *= xe;
|
||||
l_xe.c1 *= xe;
|
||||
|
||||
let l = (y2 - y1) / (x2 - x1);
|
||||
ye - (l * xe) / U1 + (l * x1 - y1) / U3
|
||||
let mut r0 = fp_to_fp12(ye);
|
||||
let r1 = fp2_mul_u1_inv(l * fp_to_fp2(xe));
|
||||
let r2 = fp2_mul_u3_inv(l * x1 - y1);
|
||||
|
||||
r0.c1.c1 = r2.c1.c1;
|
||||
r0.c1.c2 = -r1.c1.c2;
|
||||
|
||||
r0
|
||||
}
|
||||
|
||||
#[allow(clippy::needless_range_loop)]
|
||||
@@ -544,22 +669,24 @@ mod gt {
|
||||
let t_bits = b"110000000001000001000000100000000000000000000000000000000100000000000000001";
|
||||
|
||||
let mut fk = fp_to_fp12(MontFp!("1"));
|
||||
let p = p.normalize();
|
||||
let q = q.normalize();
|
||||
|
||||
let mut qk = q;
|
||||
|
||||
for k in 1..t_log2 {
|
||||
let lkk = ate_tangent_ev(qk, p);
|
||||
qk = qk + qk;
|
||||
let m = qk.compute_m(qk).unwrap();
|
||||
let lkk = ate_tangent_ev(qk, p, m);
|
||||
qk = qk.double(Some(m));
|
||||
fk = fk.square() * lkk;
|
||||
|
||||
if t_bits[k] == b'1' {
|
||||
assert_ne!(q, qk);
|
||||
let lkp1 = if q != -qk {
|
||||
ate_line_ev(q, qk, p)
|
||||
} else {
|
||||
fp_to_fp12(MontFp!("1"))
|
||||
};
|
||||
qk += q;
|
||||
fk *= lkp1;
|
||||
let m = q.compute_m(qk);
|
||||
let new_qk = q.add_unequal(qk, m);
|
||||
if !new_qk.inner.infinity {
|
||||
fk *= ate_line_ev(q, p, m.unwrap());
|
||||
}
|
||||
qk = new_qk;
|
||||
}
|
||||
}
|
||||
let mlo = MillerLoopOutput(fk);
|
||||
|
||||
@@ -332,7 +332,7 @@ pub fn prove<G: Curve>(
|
||||
|
||||
let x_bytes = &*[
|
||||
q.to_le_bytes().as_slice(),
|
||||
d.to_le_bytes().as_slice(),
|
||||
(d as u64).to_le_bytes().as_slice(),
|
||||
b_i.to_le_bytes().as_slice(),
|
||||
t.to_le_bytes().as_slice(),
|
||||
&*a.iter().flat_map(|&x| x.to_le_bytes()).collect::<Box<_>>(),
|
||||
@@ -745,7 +745,7 @@ pub fn verify<G: Curve>(
|
||||
|
||||
let x_bytes = &*[
|
||||
q.to_le_bytes().as_slice(),
|
||||
d.to_le_bytes().as_slice(),
|
||||
(d as u64).to_le_bytes().as_slice(),
|
||||
b_i.to_le_bytes().as_slice(),
|
||||
t.to_le_bytes().as_slice(),
|
||||
&*a.iter().flat_map(|&x| x.to_le_bytes()).collect::<Box<_>>(),
|
||||
|
||||
@@ -221,7 +221,7 @@ pub fn prove<G: Curve>(
|
||||
core::slice::from_mut(s),
|
||||
&[
|
||||
hash_s,
|
||||
&i.to_le_bytes(),
|
||||
&(i as u64).to_le_bytes(),
|
||||
v_hat.to_bytes().as_ref(),
|
||||
c_hat.to_bytes().as_ref(),
|
||||
c_y.to_bytes().as_ref(),
|
||||
@@ -328,7 +328,7 @@ pub fn verify<G: Curve>(
|
||||
core::slice::from_mut(s),
|
||||
&[
|
||||
hash_s,
|
||||
&i.to_le_bytes(),
|
||||
&(i as u64).to_le_bytes(),
|
||||
v_hat.to_bytes().as_ref(),
|
||||
c_hat.to_bytes().as_ref(),
|
||||
c_y.to_bytes().as_ref(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tfhe"
|
||||
version = "0.7.0"
|
||||
version = "0.7.5"
|
||||
edition = "2021"
|
||||
readme = "../README.md"
|
||||
keywords = ["fully", "homomorphic", "encryption", "fhe", "cryptography"]
|
||||
@@ -17,7 +17,7 @@ exclude = [
|
||||
"/js_on_wasm_tests/",
|
||||
"/web_wasm_parallel_tests/",
|
||||
]
|
||||
rust-version = "1.73"
|
||||
rust-version = "1.76"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -65,7 +65,7 @@ rayon = { version = "1.5.0" }
|
||||
bincode = "1.3.3"
|
||||
concrete-fft = { version = "0.4.1", features = ["serde", "fft128"] }
|
||||
concrete-ntt = { version = "0.1.2" }
|
||||
pulp = "0.18.8"
|
||||
pulp = ">=0.18.8, <0.18.22"
|
||||
tfhe-cuda-backend = { version = "0.3.0", path = "../backends/tfhe-cuda-backend", optional = true }
|
||||
aligned-vec = { version = "0.5", features = ["serde"] }
|
||||
dyn-stack = { version = "0.9" }
|
||||
@@ -76,11 +76,11 @@ sha3 = { version = "0.10", optional = true }
|
||||
# While we wait for repeat_n in rust standard library
|
||||
itertools = "0.11.0"
|
||||
rand_core = { version = "0.6.4", features = ["std"] }
|
||||
tfhe-zk-pok = { version = "0.2.0", path = "../tfhe-zk-pok", optional = true }
|
||||
tfhe-versionable = { version = "0.1.0", path = "../utils/tfhe-versionable" }
|
||||
tfhe-zk-pok = { version = "0.2.2", path = "../tfhe-zk-pok", optional = true }
|
||||
tfhe-versionable = { version = "0.2.0", path = "../utils/tfhe-versionable" }
|
||||
|
||||
# wasm deps
|
||||
wasm-bindgen = { version = "0.2.86", features = [
|
||||
wasm-bindgen = { version = ">=0.2.86,<0.2.94", features = [
|
||||
"serde-serialize",
|
||||
], optional = true }
|
||||
wasm-bindgen-rayon = { version = "1.0", optional = true }
|
||||
@@ -324,3 +324,10 @@ required-features = ["integer", "internal-keycache"]
|
||||
|
||||
[lib]
|
||||
crate-type = ["lib", "staticlib", "cdylib"]
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = [
|
||||
'cfg(bench)',
|
||||
'cfg(tarpaulin)',
|
||||
'cfg(tfhe_lints)'
|
||||
] }
|
||||
|
||||
@@ -59,16 +59,15 @@ The following example shows how to compress and decompress a list containing 4 m
|
||||
|
||||
```rust
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::{COMP_PARAM_MESSAGE_2_CARRY_2, PARAM_MESSAGE_2_CARRY_2};
|
||||
use tfhe::{
|
||||
set_server_key, CompressedCiphertextList, CompressedCiphertextListBuilder, FheBool,
|
||||
FheInt64, FheUint16, FheUint2, FheUint32,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let config = tfhe::ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, None)
|
||||
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
let config = tfhe::ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2, None)
|
||||
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2)
|
||||
.build();
|
||||
|
||||
let ck = tfhe::ClientKey::generate(config);
|
||||
@@ -121,7 +120,6 @@ fn main() {
|
||||
|
||||
// Correct type but wrong number of bits
|
||||
assert!(compressed_list.get::<FheUint16>(0).is_err());
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Here is a full example:
|
||||
|
||||
[dependencies]
|
||||
# ...
|
||||
tfhe = { version = "0.7.0", features = ["integer","x86_64-unix"]}
|
||||
tfhe = { version = "0.7.5", features = ["integer","x86_64-unix"]}
|
||||
bincode = "1.3.3"
|
||||
```
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ First, add **TFHE-rs** as a dependency in your `Cargo.toml`.
|
||||
**For `x86_64` machine running a Unix-like OS:**
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.7.0", features = [ "boolean", "shortint", "integer", "x86_64-unix" ] }
|
||||
tfhe = { version = "0.7.5", features = [ "boolean", "shortint", "integer", "x86_64-unix" ] }
|
||||
```
|
||||
|
||||
**For `ARM` machine running a Unix-like OS:**
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.7.0", features = [ "boolean", "shortint", "integer", "aarch64-unix" ] }
|
||||
tfhe = { version = "0.7.5", features = [ "boolean", "shortint", "integer", "aarch64-unix" ] }
|
||||
```
|
||||
|
||||
**For `x86_64` machines with the** [**`rdseed instruction`**](https://en.wikipedia.org/wiki/RDRAND) **running Windows:**
|
||||
|
||||
@@ -47,7 +47,7 @@ fn main() {
|
||||
The default configuration for x86 Unix machines is as follows:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.7.0", features = ["integer", "x86_64-unix"]}
|
||||
tfhe = { version = "0.7.5", features = ["integer", "x86_64-unix"]}
|
||||
```
|
||||
|
||||
Refer to the [installation documentation](installation.md) for configuration options of different platforms.Learn more about homomorphic types features in the [configuration documentation.](../guides/rust\_configuration.md)
|
||||
|
||||
@@ -16,8 +16,8 @@ You can load serialized data with the `unversionize` function, even in newer ver
|
||||
|
||||
[dependencies]
|
||||
# ...
|
||||
tfhe = { version = "0.7.0", features = ["integer","x86_64-unix"]}
|
||||
tfhe-versionable = "0.1.0"
|
||||
tfhe = { version = "0.7.5", features = ["integer","x86_64-unix"]}
|
||||
tfhe-versionable = "0.2.0"
|
||||
bincode = "1.3.3"
|
||||
```
|
||||
|
||||
|
||||
@@ -19,13 +19,13 @@ To use the **TFHE-rs** GPU backend in your project, add the following dependency
|
||||
If you are using an `x86` machine:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.7.0", features = [ "boolean", "shortint", "integer", "x86_64-unix", "gpu" ] }
|
||||
tfhe = { version = "0.7.5", features = [ "boolean", "shortint", "integer", "x86_64-unix", "gpu" ] }
|
||||
```
|
||||
|
||||
If you are using an `ARM` machine:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.7.0", features = [ "boolean", "shortint", "integer", "aarch64-unix", "gpu" ] }
|
||||
tfhe = { version = "0.7.5", features = [ "boolean", "shortint", "integer", "aarch64-unix", "gpu" ] }
|
||||
```
|
||||
|
||||
{% hint style="success" %}
|
||||
|
||||
@@ -9,7 +9,7 @@ Welcome to this tutorial about `TFHE-rs` `core_crypto` module.
|
||||
To use `TFHE-rs`, it first has to be added as a dependency in the `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.7.0", features = [ "x86_64-unix" ] }
|
||||
tfhe = { version = "0.7.5", features = [ "x86_64-unix" ] }
|
||||
```
|
||||
|
||||
This enables the `x86_64-unix` feature to have efficient implementations of various algorithms for `x86_64` CPUs on a Unix-like system. The 'unix' suffix indicates that the `UnixSeeder`, which uses `/dev/random` to generate random numbers, is activated as a fallback if no hardware number generator is available (like `rdseed` on `x86_64` or if the [`Randomization Services`](https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc) on Apple platforms are not available). To avoid having the `UnixSeeder` as a potential fallback or to run on non-Unix systems (e.g., Windows), the `x86_64` feature is sufficient.
|
||||
@@ -19,19 +19,19 @@ For Apple Silicon, the `aarch64-unix` or `aarch64` feature should be enabled. `a
|
||||
In short: For `x86_64`-based machines running Unix-like OSes:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.7.0", features = ["x86_64-unix"] }
|
||||
tfhe = { version = "0.7.5", features = ["x86_64-unix"] }
|
||||
```
|
||||
|
||||
For Apple Silicon or aarch64-based machines running Unix-like OSes:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.7.0", features = ["aarch64-unix"] }
|
||||
tfhe = { version = "0.7.5", features = ["aarch64-unix"] }
|
||||
```
|
||||
|
||||
For `x86_64`-based machines with the [`rdseed instruction`](https://en.wikipedia.org/wiki/RDRAND) running Windows:
|
||||
|
||||
```toml
|
||||
tfhe = { version = "0.7.0", features = ["x86_64"] }
|
||||
tfhe = { version = "0.7.5", features = ["x86_64"] }
|
||||
```
|
||||
|
||||
### Commented code to double a 2-bit message in a leveled fashion and using a PBS with the `core_crypto` module.
|
||||
|
||||
@@ -25,7 +25,7 @@ To use the `FheUint8` type, enable the `integer` feature:
|
||||
|
||||
[dependencies]
|
||||
# Default configuration for x86 Unix machines:
|
||||
tfhe = { version = "0.7.0", features = ["integer", "x86_64-unix"]}
|
||||
tfhe = { version = "0.7.5", features = ["integer", "x86_64-unix"]}
|
||||
```
|
||||
|
||||
Refer to the [installation guide](../getting\_started/installation.md) for other configurations.
|
||||
|
||||
@@ -18,7 +18,7 @@ This function returns a Boolean (`true` or `false`) so that the total count of `
|
||||
# Cargo.toml
|
||||
|
||||
# Default configuration for x86 Unix machines:
|
||||
tfhe = { version = "0.7.0", features = ["integer", "x86_64-unix"]}
|
||||
tfhe = { version = "0.7.5", features = ["integer", "x86_64-unix"]}
|
||||
```
|
||||
|
||||
Refer to the [installation](../getting\_started/installation.md) for other configurations.
|
||||
|
||||
@@ -14,5 +14,5 @@
|
||||
* [Regular Expression Engine with TFHE-rs](https://www.zama.ai/post/regex-engine-tfhe-rs) - June 30, 2023
|
||||
|
||||
#### Video tutorials
|
||||
|
||||
* [Implement GPU acceleration on homomorphic computation using TFHE-rs](https://www.zama.ai/post/video-tutorial-implement-gpu-acceleration-on-homomorphic-computation-using-tfhe-rs) - May 2024
|
||||
* [Implement signed integers using TFHE-rs](https://www.youtube.com/watch?v=O0aGj\_xUo40) - Nov 8, 2023
|
||||
|
||||
13
tfhe/src/boolean/backward_compatibility/ciphertext.rs
Normal file
13
tfhe/src/boolean/backward_compatibility/ciphertext.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::boolean::ciphertext::{Ciphertext, CompressedCiphertext};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum CiphertextVersions {
|
||||
V0(Ciphertext),
|
||||
}
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum CompressedCiphertextVersions {
|
||||
V0(CompressedCiphertext),
|
||||
}
|
||||
8
tfhe/src/boolean/backward_compatibility/client_key.rs
Normal file
8
tfhe/src/boolean/backward_compatibility/client_key.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::boolean::client_key::ClientKey;
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum ClientKeyVersions {
|
||||
V0(ClientKey),
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::boolean::key_switching_key::KeySwitchingKey;
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum KeySwitchingKeyVersions {
|
||||
V0(KeySwitchingKey),
|
||||
}
|
||||
6
tfhe/src/boolean/backward_compatibility/mod.rs
Normal file
6
tfhe/src/boolean/backward_compatibility/mod.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
pub mod ciphertext;
|
||||
pub mod client_key;
|
||||
pub mod key_switching_key;
|
||||
pub mod parameters;
|
||||
pub mod public_key;
|
||||
pub mod server_key;
|
||||
13
tfhe/src/boolean/backward_compatibility/parameters.rs
Normal file
13
tfhe/src/boolean/backward_compatibility/parameters.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::boolean::parameters::{BooleanKeySwitchingParameters, BooleanParameters};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum BooleanParametersVersions {
|
||||
V0(BooleanParameters),
|
||||
}
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum BooleanKeySwitchingParametersVersions {
|
||||
V0(BooleanKeySwitchingParameters),
|
||||
}
|
||||
13
tfhe/src/boolean/backward_compatibility/public_key.rs
Normal file
13
tfhe/src/boolean/backward_compatibility/public_key.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::boolean::public_key::{CompressedPublicKey, PublicKey};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum PublicKeyVersions {
|
||||
V0(PublicKey),
|
||||
}
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum CompressedPublicKeyVersions {
|
||||
V0(CompressedPublicKey),
|
||||
}
|
||||
13
tfhe/src/boolean/backward_compatibility/server_key.rs
Normal file
13
tfhe/src/boolean/backward_compatibility/server_key.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::boolean::server_key::{CompressedServerKey, ServerKey};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum ServerKeyVersions {
|
||||
V0(ServerKey),
|
||||
}
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum CompressedServerKeyVersions {
|
||||
V0(CompressedServerKey),
|
||||
}
|
||||
@@ -4,11 +4,15 @@
|
||||
|
||||
use crate::core_crypto::entities::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use super::backward_compatibility::ciphertext::{CiphertextVersions, CompressedCiphertextVersions};
|
||||
|
||||
/// A structure containing a ciphertext, meant to encrypt a Boolean message.
|
||||
///
|
||||
/// It is used to evaluate a Boolean circuits homomorphically.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(CiphertextVersions)]
|
||||
pub enum Ciphertext {
|
||||
Encrypted(LweCiphertextOwned<u32>),
|
||||
Trivial(bool),
|
||||
@@ -17,7 +21,8 @@ pub enum Ciphertext {
|
||||
/// A structure containing a compressed ciphertext, meant to encrypt a Boolean message.
|
||||
///
|
||||
/// It has to be decompressed before evaluating a Boolean circuit.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(CompressedCiphertextVersions)]
|
||||
pub struct CompressedCiphertext {
|
||||
pub(crate) ciphertext: SeededLweCiphertext<u32>,
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ use crate::boolean::parameters::{BooleanParameters, DynamicDistribution, Encrypt
|
||||
use crate::core_crypto::entities::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use super::backward_compatibility::client_key::ClientKeyVersions;
|
||||
|
||||
/// A structure containing the client key, which must be kept secret.
|
||||
///
|
||||
@@ -18,7 +21,8 @@ use std::fmt::{Debug, Formatter};
|
||||
/// * `glwe_secret_key` - a GLWE secret key, used to generate the bootstrapping keys and key
|
||||
/// switching keys.
|
||||
/// * `parameters` - the cryptographic parameter set.
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(ClientKeyVersions)]
|
||||
pub struct ClientKey {
|
||||
pub(crate) lwe_secret_key: LweSecretKeyOwned<u32>,
|
||||
pub(crate) glwe_secret_key: GlweSecretKeyOwned<u32>,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
use crate::boolean::backward_compatibility::server_key::{
|
||||
CompressedServerKeyVersions, ServerKeyVersions,
|
||||
};
|
||||
use crate::boolean::ciphertext::Ciphertext;
|
||||
use crate::boolean::{ClientKey, PLAINTEXT_TRUE};
|
||||
use crate::core_crypto::algorithms::*;
|
||||
@@ -8,6 +11,7 @@ use crate::core_crypto::commons::parameters::{CiphertextModulus, PBSOrder};
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::fft_impl::fft64::math::fft::Fft;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
/// Memory used as buffer for the bootstrap
|
||||
///
|
||||
@@ -89,7 +93,8 @@ impl Memory {
|
||||
/// In more details, it contains:
|
||||
/// * `bootstrapping_key` - a public key, used to perform the bootstrapping operation.
|
||||
/// * `key_switching_key` - a public key, used to perform the key-switching operation.
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(ServerKeyVersions)]
|
||||
pub struct ServerKey {
|
||||
pub(crate) bootstrapping_key: FourierLweBootstrapKeyOwned,
|
||||
pub(crate) key_switching_key: LweKeyswitchKeyOwned<u32>,
|
||||
@@ -182,7 +187,8 @@ impl ServerKey {
|
||||
/// In more details, it contains:
|
||||
/// * `bootstrapping_key` - a public key, used to perform the bootstrapping operation.
|
||||
/// * `key_switching_key` - a public key, used to perform the key-switching operation.
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(CompressedServerKeyVersions)]
|
||||
pub struct CompressedServerKey {
|
||||
pub(crate) bootstrapping_key: SeededLweBootstrapKeyOwned<u32>,
|
||||
pub(crate) key_switching_key: SeededLweKeyswitchKeyOwned<u32>,
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use crate::boolean::engine::{BooleanEngine, WithThreadLocalEngine};
|
||||
use crate::boolean::parameters::BooleanKeySwitchingParameters;
|
||||
use crate::boolean::prelude::Ciphertext;
|
||||
use crate::boolean::ClientKey;
|
||||
use crate::core_crypto::prelude::{keyswitch_lwe_ciphertext, LweKeyswitchKeyOwned};
|
||||
|
||||
use super::backward_compatibility::key_switching_key::KeySwitchingKeyVersions;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test;
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(KeySwitchingKeyVersions)]
|
||||
pub struct KeySwitchingKey {
|
||||
pub(crate) key_switching_key: LweKeyswitchKeyOwned<u32>,
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ use crate::boolean::server_key::ServerKey;
|
||||
#[cfg(test)]
|
||||
use rand::Rng;
|
||||
|
||||
pub mod backward_compatibility;
|
||||
pub mod ciphertext;
|
||||
pub mod client_key;
|
||||
pub mod engine;
|
||||
|
||||
@@ -25,6 +25,11 @@ pub use crate::core_crypto::commons::parameters::{
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use super::backward_compatibility::parameters::{
|
||||
BooleanKeySwitchingParametersVersions, BooleanParametersVersions,
|
||||
};
|
||||
|
||||
/// A set of cryptographic parameters for homomorphic Boolean circuit evaluation.
|
||||
/// The choice of encryption key for (`boolean ciphertext`)[`super::ciphertext::Ciphertext`].
|
||||
@@ -39,7 +44,8 @@ use serde::{Deserialize, Serialize};
|
||||
/// key`)[`super::public_key::PublicKey`] sizes are much more manageable and should always fit in
|
||||
/// memory. When refreshing a ciphertext and/or evaluating a table lookup the keyswitch is
|
||||
/// computed first followed by a PBS.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(BooleanParametersVersions)]
|
||||
pub struct BooleanParameters {
|
||||
pub lwe_dimension: LweDimension,
|
||||
pub glwe_dimension: GlweDimension,
|
||||
@@ -91,7 +97,8 @@ impl BooleanParameters {
|
||||
}
|
||||
|
||||
/// A set of cryptographic parameters for homomorphic Boolean key switching.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(BooleanKeySwitchingParametersVersions)]
|
||||
pub struct BooleanKeySwitchingParameters {
|
||||
pub ks_base_log: DecompositionBaseLog,
|
||||
pub ks_level: DecompositionLevelCount,
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
use crate::boolean::backward_compatibility::public_key::CompressedPublicKeyVersions;
|
||||
use crate::boolean::engine::{BooleanEngine, WithThreadLocalEngine};
|
||||
use crate::boolean::prelude::{BooleanParameters, Ciphertext, ClientKey};
|
||||
use crate::core_crypto::prelude::SeededLwePublicKeyOwned;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
/// A structure containing a compressed public key.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(CompressedPublicKeyVersions)]
|
||||
pub struct CompressedPublicKey {
|
||||
pub(crate) compressed_lwe_public_key: SeededLwePublicKeyOwned<u32>,
|
||||
pub parameters: BooleanParameters,
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
//! Module with the definition of the encryption PublicKey.
|
||||
|
||||
use super::compressed::CompressedPublicKey;
|
||||
use crate::boolean::backward_compatibility::public_key::PublicKeyVersions;
|
||||
use crate::boolean::ciphertext::Ciphertext;
|
||||
use crate::boolean::client_key::ClientKey;
|
||||
use crate::boolean::engine::{BooleanEngine, WithThreadLocalEngine};
|
||||
use crate::boolean::parameters::BooleanParameters;
|
||||
use crate::core_crypto::entities::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
/// A structure containing a public key.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(PublicKeyVersions)]
|
||||
pub struct PublicKey {
|
||||
pub(crate) lwe_public_key: LwePublicKeyOwned<u32>,
|
||||
pub(crate) parameters: BooleanParameters,
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
use crate::core_crypto::commons::dispersion::StandardDev;
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum StandardDevVersions {
|
||||
V0(StandardDev),
|
||||
}
|
||||
@@ -19,6 +19,7 @@ pub enum DynamicDistributionVersions<T: UnsignedInteger> {
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub enum CompressionSeedVersioned<'vers> {
|
||||
V0(&'vers CompressionSeed),
|
||||
}
|
||||
@@ -30,6 +31,7 @@ impl<'vers> From<&'vers CompressionSeed> for CompressionSeedVersioned<'vers> {
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub enum CompressionSeedVersionedOwned {
|
||||
V0(CompressionSeed),
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod ciphertext_modulus;
|
||||
pub mod dispersion;
|
||||
pub mod math;
|
||||
pub mod parameters;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Cleartext, Numeric};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum CleartextVersions<T: Numeric> {
|
||||
V0(Cleartext<T>),
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::compressed_modulus_switched_glwe_ciphertext::CompressedModulusSwitchedGlweCiphertext;
|
||||
use crate::core_crypto::prelude::UnsignedInteger;
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum CompressedModulusSwitchedGlweCiphertextVersions<Scalar: UnsignedInteger> {
|
||||
V0(CompressedModulusSwitchedGlweCiphertext<Scalar>),
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::convert::Infallible;
|
||||
|
||||
use tfhe_versionable::{Upgrade, Version, VersionsDispatch};
|
||||
|
||||
use crate::core_crypto::prelude::compressed_modulus_switched_lwe_ciphertext::CompressedModulusSwitchedLweCiphertext;
|
||||
@@ -17,7 +19,9 @@ pub struct CompressedModulusSwitchedLweCiphertextV0<Scalar: UnsignedInteger> {
|
||||
impl<Scalar: UnsignedInteger> Upgrade<CompressedModulusSwitchedLweCiphertext<Scalar>>
|
||||
for CompressedModulusSwitchedLweCiphertextV0<Scalar>
|
||||
{
|
||||
fn upgrade(self) -> Result<CompressedModulusSwitchedLweCiphertext<Scalar>, String> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn upgrade(self) -> Result<CompressedModulusSwitchedLweCiphertext<Scalar>, Self::Error> {
|
||||
let packed_integers = PackedIntegers {
|
||||
packed_coeffs: self.packed_coeffs,
|
||||
log_modulus: self.log_modulus,
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, GswCiphertext};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum GswCiphertextVersions<C: Container> {
|
||||
V0(GswCiphertext<C>),
|
||||
}
|
||||
@@ -17,6 +17,7 @@ where
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub enum FourierLweMultiBitBootstrapKeyVersioned<'vers> {
|
||||
V0(FourierLweMultiBitBootstrapKeyVersion<'vers>),
|
||||
}
|
||||
@@ -30,14 +31,15 @@ impl<'vers, C: Container<Element = c64>> From<&'vers FourierLweMultiBitBootstrap
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub enum FourierLweMultiBitBootstrapKeyVersionedOwned {
|
||||
V0(FourierLweMultiBitBootstrapKeyVersionOwned),
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> From<&FourierLweMultiBitBootstrapKey<C>>
|
||||
impl<C: Container<Element = c64>> From<FourierLweMultiBitBootstrapKey<C>>
|
||||
for FourierLweMultiBitBootstrapKeyVersionedOwned
|
||||
{
|
||||
fn from(value: &FourierLweMultiBitBootstrapKey<C>) -> Self {
|
||||
fn from(value: FourierLweMultiBitBootstrapKey<C>) -> Self {
|
||||
Self::V0(value.into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
pub mod cleartext;
|
||||
pub mod compressed_modulus_switched_glwe_ciphertext;
|
||||
pub mod compressed_modulus_switched_lwe_ciphertext;
|
||||
pub mod compressed_modulus_switched_multi_bit_lwe_ciphertext;
|
||||
pub mod ggsw_ciphertext;
|
||||
@@ -5,6 +7,7 @@ pub mod ggsw_ciphertext_list;
|
||||
pub mod glwe_ciphertext;
|
||||
pub mod glwe_ciphertext_list;
|
||||
pub mod glwe_secret_key;
|
||||
pub mod gsw_ciphertext;
|
||||
pub mod lwe_bootstrap_key;
|
||||
pub mod lwe_ciphertext;
|
||||
pub mod lwe_ciphertext_list;
|
||||
@@ -17,7 +20,14 @@ pub mod lwe_private_functional_packing_keyswitch_key;
|
||||
pub mod lwe_private_functional_packing_keyswitch_key_list;
|
||||
pub mod lwe_public_key;
|
||||
pub mod lwe_secret_key;
|
||||
pub mod ntt_ggsw_ciphertext;
|
||||
pub mod ntt_ggsw_ciphertext_list;
|
||||
pub mod ntt_lwe_bootstrap_key;
|
||||
pub mod packed_integers;
|
||||
pub mod plaintext;
|
||||
pub mod plaintext_list;
|
||||
pub mod polynomial;
|
||||
pub mod polynomial_list;
|
||||
pub mod seeded_ggsw_ciphertext;
|
||||
pub mod seeded_ggsw_ciphertext_list;
|
||||
pub mod seeded_glwe_ciphertext;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, NttGgswCiphertext, UnsignedInteger};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum NttGgswCiphertextVersions<C: Container>
|
||||
where
|
||||
C::Element: UnsignedInteger,
|
||||
{
|
||||
V0(NttGgswCiphertext<C>),
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, NttGgswCiphertextList, UnsignedInteger};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum NttGgswCiphertextListVersions<C: Container>
|
||||
where
|
||||
C::Element: UnsignedInteger,
|
||||
{
|
||||
V0(NttGgswCiphertextList<C>),
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, NttLweBootstrapKey, UnsignedInteger};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum NttLweBootstrapKeyVersions<C: Container>
|
||||
where
|
||||
C::Element: UnsignedInteger,
|
||||
{
|
||||
V0(NttLweBootstrapKey<C>),
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Numeric, Plaintext};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum PlaintextVersions<T: Numeric> {
|
||||
V0(Plaintext<T>),
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, PlaintextList};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum PlaintextListVersions<C: Container> {
|
||||
V0(PlaintextList<C>),
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, Polynomial};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum PolynomialVersions<C: Container> {
|
||||
V0(Polynomial<C>),
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, PolynomialList};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum PolynomialListVersions<C: Container> {
|
||||
V0(PolynomialList<C>),
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
use tfhe_versionable::UnversionizeError;
|
||||
use tfhe_versionable::{UnversionizeError, VersionsDispatch};
|
||||
|
||||
use aligned_vec::ABox;
|
||||
use concrete_fft::c64;
|
||||
@@ -7,10 +7,17 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::core_crypto::fft_impl::fft64::crypto::bootstrap::{
|
||||
FourierLweBootstrapKeyVersion, FourierLweBootstrapKeyVersionOwned,
|
||||
};
|
||||
use crate::core_crypto::fft_impl::fft64::crypto::ggsw::{
|
||||
FourierGgswCiphertextVersion, FourierGgswCiphertextVersionOwned,
|
||||
};
|
||||
use crate::core_crypto::fft_impl::fft64::math::fft::FourierPolynomialList;
|
||||
use crate::core_crypto::prelude::{Container, FourierLweBootstrapKey, IntoContainerOwned};
|
||||
use crate::core_crypto::prelude::{
|
||||
Container, Fourier128GgswCiphertext, Fourier128LweBootstrapKey, FourierGgswCiphertext,
|
||||
FourierLweBootstrapKey, IntoContainerOwned,
|
||||
};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub enum FourierPolynomialListVersioned<'vers> {
|
||||
V0(FourierPolynomialList<&'vers [c64]>),
|
||||
}
|
||||
@@ -29,14 +36,15 @@ impl<'vers, C: Container<Element = c64>> From<&'vers FourierPolynomialList<C>>
|
||||
|
||||
// Here we do not derive "VersionsDispatch" so that we can implement a non recursive Versionize
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub enum FourierPolynomialListVersionedOwned {
|
||||
V0(FourierPolynomialList<ABox<[c64]>>),
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> From<&FourierPolynomialList<C>>
|
||||
impl<C: Container<Element = c64>> From<FourierPolynomialList<C>>
|
||||
for FourierPolynomialListVersionedOwned
|
||||
{
|
||||
fn from(value: &FourierPolynomialList<C>) -> Self {
|
||||
fn from(value: FourierPolynomialList<C>) -> Self {
|
||||
let owned_poly = FourierPolynomialList {
|
||||
data: ABox::collect(value.data.as_ref().iter().copied()),
|
||||
polynomial_size: value.polynomial_size,
|
||||
@@ -59,6 +67,7 @@ impl<C: IntoContainerOwned<Element = c64>> From<FourierPolynomialListVersionedOw
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub enum FourierLweBootstrapKeyVersioned<'vers> {
|
||||
V0(FourierLweBootstrapKeyVersion<'vers>),
|
||||
}
|
||||
@@ -72,14 +81,15 @@ impl<'vers, C: Container<Element = c64>> From<&'vers FourierLweBootstrapKey<C>>
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub enum FourierLweBootstrapKeyVersionedOwned {
|
||||
V0(FourierLweBootstrapKeyVersionOwned),
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> From<&FourierLweBootstrapKey<C>>
|
||||
impl<C: Container<Element = c64>> From<FourierLweBootstrapKey<C>>
|
||||
for FourierLweBootstrapKeyVersionedOwned
|
||||
{
|
||||
fn from(value: &FourierLweBootstrapKey<C>) -> Self {
|
||||
fn from(value: FourierLweBootstrapKey<C>) -> Self {
|
||||
Self::V0(value.into())
|
||||
}
|
||||
}
|
||||
@@ -95,3 +105,53 @@ impl<C: IntoContainerOwned<Element = c64>> TryFrom<FourierLweBootstrapKeyVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub enum FourierGgswCiphertextVersioned<'vers> {
|
||||
V0(FourierGgswCiphertextVersion<'vers>),
|
||||
}
|
||||
|
||||
impl<'vers, C: Container<Element = c64>> From<&'vers FourierGgswCiphertext<C>>
|
||||
for FourierGgswCiphertextVersioned<'vers>
|
||||
{
|
||||
fn from(value: &'vers FourierGgswCiphertext<C>) -> Self {
|
||||
Self::V0(value.into())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub enum FourierGgswCiphertextVersionedOwned {
|
||||
V0(FourierGgswCiphertextVersionOwned),
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> From<FourierGgswCiphertext<C>>
|
||||
for FourierGgswCiphertextVersionedOwned
|
||||
{
|
||||
fn from(value: FourierGgswCiphertext<C>) -> Self {
|
||||
Self::V0(value.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: IntoContainerOwned<Element = c64>> TryFrom<FourierGgswCiphertextVersionedOwned>
|
||||
for FourierGgswCiphertext<C>
|
||||
{
|
||||
type Error = UnversionizeError;
|
||||
|
||||
fn try_from(value: FourierGgswCiphertextVersionedOwned) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
FourierGgswCiphertextVersionedOwned::V0(v0) => Self::try_from(v0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum Fourier128LweBootstrapKeyVersions<C: Container<Element = f64>> {
|
||||
V0(Fourier128LweBootstrapKey<C>),
|
||||
}
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum Fourier128GgswCiphertextVersions<C: Container<Element = f64>> {
|
||||
V0(Fourier128GgswCiphertext<C>),
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use crate::core_crypto::commons::traits::UnsignedInteger;
|
||||
use crate::core_crypto::prelude::CastInto;
|
||||
use core::num::NonZeroU128;
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::Display;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
@@ -58,6 +59,31 @@ pub struct SerializableCiphertextModulus {
|
||||
pub scalar_bits: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum CiphertextModulusDeserializationError {
|
||||
InvalidBitWidth { expected: usize, found: usize },
|
||||
ZeroCustomModulus,
|
||||
}
|
||||
|
||||
impl Display for CiphertextModulusDeserializationError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::InvalidBitWidth { expected, found } => write!(
|
||||
f,
|
||||
"Expected an unsigned integer with {expected} bits, \
|
||||
found {found} bits during deserialization of CiphertextModulus, \
|
||||
have you mixed types during deserialization?",
|
||||
),
|
||||
Self::ZeroCustomModulus => write!(
|
||||
f,
|
||||
"Got zero modulus for CiphertextModulusInner::Custom variant"
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for CiphertextModulusDeserializationError {}
|
||||
|
||||
impl<Scalar: UnsignedInteger> From<CiphertextModulus<Scalar>> for SerializableCiphertextModulus {
|
||||
fn from(value: CiphertextModulus<Scalar>) -> Self {
|
||||
let modulus = match value.inner {
|
||||
@@ -73,17 +99,14 @@ impl<Scalar: UnsignedInteger> From<CiphertextModulus<Scalar>> for SerializableCi
|
||||
}
|
||||
|
||||
impl<Scalar: UnsignedInteger> TryFrom<SerializableCiphertextModulus> for CiphertextModulus<Scalar> {
|
||||
type Error = String;
|
||||
type Error = CiphertextModulusDeserializationError;
|
||||
|
||||
fn try_from(value: SerializableCiphertextModulus) -> Result<Self, Self::Error> {
|
||||
if value.scalar_bits != Scalar::BITS {
|
||||
return Err(format!(
|
||||
"Expected an unsigned integer with {} bits, \
|
||||
found {} bits during deserialization of CiphertextModulus, \
|
||||
have you mixed types during deserialization?",
|
||||
Scalar::BITS,
|
||||
value.scalar_bits
|
||||
));
|
||||
return Err(CiphertextModulusDeserializationError::InvalidBitWidth {
|
||||
expected: Scalar::BITS,
|
||||
found: value.scalar_bits,
|
||||
});
|
||||
}
|
||||
|
||||
let res = if value.modulus == 0 {
|
||||
@@ -93,9 +116,10 @@ impl<Scalar: UnsignedInteger> TryFrom<SerializableCiphertextModulus> for Ciphert
|
||||
}
|
||||
} else {
|
||||
Self {
|
||||
inner: CiphertextModulusInner::Custom(NonZeroU128::new(value.modulus).ok_or_else(
|
||||
|| "Got zero modulus for CiphertextModulusInner::Custom variant".to_string(),
|
||||
)?),
|
||||
inner: CiphertextModulusInner::Custom(
|
||||
NonZeroU128::new(value.modulus)
|
||||
.ok_or(CiphertextModulusDeserializationError::ZeroCustomModulus)?,
|
||||
),
|
||||
_scalar: PhantomData,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
//! defined.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use crate::core_crypto::backward_compatibility::commons::dispersion::StandardDevVersions;
|
||||
|
||||
/// A trait for types representing distribution parameters, for a given unsigned integer type.
|
||||
// Warning:
|
||||
@@ -110,7 +113,8 @@ impl DispersionParameter for LogStandardDev {
|
||||
/// 2_f64.powf(32. - 25.).powi(2)
|
||||
/// );
|
||||
/// ```
|
||||
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(StandardDevVersions)]
|
||||
pub struct StandardDev(pub f64);
|
||||
|
||||
impl StandardDev {
|
||||
|
||||
@@ -31,7 +31,7 @@ pub mod serialization_proxy {
|
||||
}
|
||||
|
||||
pub(crate) use serialization_proxy::*;
|
||||
use tfhe_versionable::{Unversionize, Versionize};
|
||||
use tfhe_versionable::{Unversionize, Versionize, VersionizeOwned};
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
/// New type to manage seeds used for compressed/seeded types.
|
||||
@@ -46,11 +46,13 @@ impl Versionize for CompressionSeed {
|
||||
fn versionize(&self) -> Self::Versioned<'_> {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl VersionizeOwned for CompressionSeed {
|
||||
type VersionedOwned = CompressionSeedVersionedOwned;
|
||||
|
||||
fn versionize_owned(&self) -> Self::VersionedOwned {
|
||||
(*self).into()
|
||||
fn versionize_owned(self) -> Self::VersionedOwned {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
//! Module containing the definition of the Cleartext.
|
||||
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use crate::core_crypto::backward_compatibility::entities::cleartext::CleartextVersions;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
|
||||
/// A cleartext, not encoded, value.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(CleartextVersions)]
|
||||
pub struct Cleartext<T: Numeric>(pub T);
|
||||
/// An immutable reference to a cleartext value.
|
||||
///
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use self::packed_integers::PackedIntegers;
|
||||
use crate::conformance::ParameterSetConformant;
|
||||
use crate::core_crypto::backward_compatibility::entities::compressed_modulus_switched_glwe_ciphertext::CompressedModulusSwitchedGlweCiphertextVersions;
|
||||
use crate::core_crypto::fft_impl::common::modulus_switch;
|
||||
use crate::core_crypto::prelude::*;
|
||||
|
||||
@@ -74,7 +77,8 @@ use crate::core_crypto::prelude::*;
|
||||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(CompressedModulusSwitchedGlweCiphertextVersions)]
|
||||
pub struct CompressedModulusSwitchedGlweCiphertext<Scalar: UnsignedInteger> {
|
||||
packed_integers: PackedIntegers<Scalar>,
|
||||
glwe_dimension: GlweDimension,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
//! Module containing the definition of the GswCiphertext.
|
||||
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use crate::core_crypto::backward_compatibility::entities::gsw_ciphertext::GswCiphertextVersions;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
|
||||
@@ -153,7 +156,8 @@ use crate::core_crypto::commons::traits::*;
|
||||
/// Simply use the
|
||||
/// [`LWE decryption algorithm`](`crate::core_crypto::algorithms::decrypt_lwe_ciphertext`)
|
||||
/// on one of the LWE ciphertexts contained in the Lev ciphertext.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(GswCiphertextVersions)]
|
||||
pub struct GswCiphertext<C: Container> {
|
||||
data: C,
|
||||
lwe_size: LweSize,
|
||||
|
||||
@@ -15,7 +15,7 @@ use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::fft_impl::fft64::math::fft::FourierPolynomialList;
|
||||
use aligned_vec::{avec, ABox};
|
||||
use concrete_fft::c64;
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize};
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize, VersionizeOwned};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(LweMultiBitBootstrapKeyVersions)]
|
||||
@@ -403,6 +403,7 @@ pub struct FourierLweMultiBitBootstrapKey<C: Container<Element = c64>> {
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub struct FourierLweMultiBitBootstrapKeyVersion<'vers> {
|
||||
fourier: FourierPolynomialListVersioned<'vers>,
|
||||
input_lwe_dimension: <LweDimension as Versionize>::Versioned<'vers>,
|
||||
@@ -413,13 +414,14 @@ pub struct FourierLweMultiBitBootstrapKeyVersion<'vers> {
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub struct FourierLweMultiBitBootstrapKeyVersionOwned {
|
||||
fourier: FourierPolynomialListVersionedOwned,
|
||||
input_lwe_dimension: <LweDimension as Versionize>::VersionedOwned,
|
||||
glwe_size: <GlweSize as Versionize>::VersionedOwned,
|
||||
decomposition_base_log: <DecompositionBaseLog as Versionize>::VersionedOwned,
|
||||
decomposition_level_count: <DecompositionLevelCount as Versionize>::VersionedOwned,
|
||||
grouping_factor: <LweBskGroupingFactor as Versionize>::VersionedOwned,
|
||||
input_lwe_dimension: <LweDimension as VersionizeOwned>::VersionedOwned,
|
||||
glwe_size: <GlweSize as VersionizeOwned>::VersionedOwned,
|
||||
decomposition_base_log: <DecompositionBaseLog as VersionizeOwned>::VersionedOwned,
|
||||
decomposition_level_count: <DecompositionLevelCount as VersionizeOwned>::VersionedOwned,
|
||||
grouping_factor: <LweBskGroupingFactor as VersionizeOwned>::VersionedOwned,
|
||||
}
|
||||
|
||||
impl<'vers, C: Container<Element = c64>> From<&'vers FourierLweMultiBitBootstrapKey<C>>
|
||||
@@ -437,10 +439,10 @@ impl<'vers, C: Container<Element = c64>> From<&'vers FourierLweMultiBitBootstrap
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> From<&FourierLweMultiBitBootstrapKey<C>>
|
||||
impl<C: Container<Element = c64>> From<FourierLweMultiBitBootstrapKey<C>>
|
||||
for FourierLweMultiBitBootstrapKeyVersionOwned
|
||||
{
|
||||
fn from(value: &FourierLweMultiBitBootstrapKey<C>) -> Self {
|
||||
fn from(value: FourierLweMultiBitBootstrapKey<C>) -> Self {
|
||||
Self {
|
||||
fourier: value.fourier.versionize_owned(),
|
||||
input_lwe_dimension: value.input_lwe_dimension.versionize_owned(),
|
||||
@@ -478,10 +480,12 @@ impl<C: Container<Element = c64>> Versionize for FourierLweMultiBitBootstrapKey<
|
||||
fn versionize(&self) -> Self::Versioned<'_> {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> VersionizeOwned for FourierLweMultiBitBootstrapKey<C> {
|
||||
type VersionedOwned = FourierLweMultiBitBootstrapKeyVersionedOwned;
|
||||
|
||||
fn versionize_owned(&self) -> Self::VersionedOwned {
|
||||
fn versionize_owned(self) -> Self::VersionedOwned {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::core_crypto::backward_compatibility::entities::ntt_ggsw_ciphertext::NttGgswCiphertextVersions;
|
||||
use crate::core_crypto::commons::math::decomposition::DecompositionLevel;
|
||||
use crate::core_crypto::commons::numeric::UnsignedInteger;
|
||||
use crate::core_crypto::commons::parameters::{
|
||||
@@ -9,12 +10,14 @@ pub use crate::core_crypto::entities::ggsw_ciphertext::{
|
||||
};
|
||||
pub use crate::core_crypto::entities::glwe_ciphertext::glwe_ciphertext_size;
|
||||
use aligned_vec::{avec, ABox};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
/// A [`GGSW ciphertext in the Ntt domain`](`crate::core_crypto::entities::GgswCiphertext`).
|
||||
///
|
||||
/// See [`the formal definition of a GGSW
|
||||
/// ciphertext`](`crate::core_crypto::entities::GgswCiphertext#formal-definition`)
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(NttGgswCiphertextVersions)]
|
||||
pub struct NttGgswCiphertext<C: Container>
|
||||
where
|
||||
C::Element: UnsignedInteger,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::core_crypto::backward_compatibility::entities::ntt_ggsw_ciphertext_list::NttGgswCiphertextListVersions;
|
||||
use crate::core_crypto::commons::numeric::UnsignedInteger;
|
||||
use crate::core_crypto::commons::parameters::{
|
||||
CiphertextModulus, DecompositionBaseLog, DecompositionLevelCount, GgswCiphertextCount,
|
||||
@@ -11,10 +12,12 @@ use crate::core_crypto::entities::polynomial_list::{
|
||||
PolynomialList, PolynomialListMutView, PolynomialListView,
|
||||
};
|
||||
use aligned_vec::{avec, ABox};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
/// A contiguous list containing
|
||||
/// [`GGSW ciphertexts in the NTT domain`](`crate::core_crypto::entities::NttGgswCiphertext`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(NttGgswCiphertextListVersions)]
|
||||
pub struct NttGgswCiphertextList<C: Container>
|
||||
where
|
||||
C::Element: UnsignedInteger,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::core_crypto::backward_compatibility::entities::ntt_lwe_bootstrap_key::NttLweBootstrapKeyVersions;
|
||||
use crate::core_crypto::commons::numeric::UnsignedInteger;
|
||||
use crate::core_crypto::commons::parameters::{
|
||||
CiphertextModulus, DecompositionBaseLog, DecompositionLevelCount, GgswCiphertextCount,
|
||||
@@ -9,8 +10,10 @@ use crate::core_crypto::entities::ntt_ggsw_ciphertext::NttGgswCiphertext;
|
||||
use crate::core_crypto::entities::ntt_ggsw_ciphertext_list::NttGgswCiphertextList;
|
||||
use crate::core_crypto::entities::polynomial_list::{PolynomialListMutView, PolynomialListView};
|
||||
use aligned_vec::ABox;
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(NttLweBootstrapKeyVersions)]
|
||||
pub struct NttLweBootstrapKey<C: Container>
|
||||
where
|
||||
C::Element: UnsignedInteger,
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
//! Module containing the definition of the Plaintext.
|
||||
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use crate::core_crypto::backward_compatibility::entities::plaintext::PlaintextVersions;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
|
||||
/// A plaintext (encoded) value.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(PlaintextVersions)]
|
||||
pub struct Plaintext<T: Numeric>(pub T);
|
||||
/// An immutable reference to a plaintext (encoded) value.
|
||||
///
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
//! Module containing the definition of the PlaintextList.
|
||||
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use crate::core_crypto::backward_compatibility::entities::plaintext_list::PlaintextListVersions;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
|
||||
/// A contiguous list containing [`plaintexts`](`crate::core_crypto::entities::Plaintext`).
|
||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(PlaintextListVersions)]
|
||||
pub struct PlaintextList<C: Container> {
|
||||
data: C,
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
//! Module containing the definition of the Polynomial.
|
||||
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use crate::core_crypto::backward_compatibility::entities::polynomial::PolynomialVersions;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
/// A [`polynomial`](`Polynomial`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(PolynomialVersions)]
|
||||
pub struct Polynomial<C: Container> {
|
||||
data: C,
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
//! Module containing the definition of the PolynomialList.
|
||||
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use crate::core_crypto::backward_compatibility::entities::polynomial_list::PolynomialListVersions;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
|
||||
/// A contiguous list containing
|
||||
/// [`polynomials`](`crate::core_crypto::entities::Polynomial`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(PolynomialListVersions)]
|
||||
pub struct PolynomialList<C: Container> {
|
||||
data: C,
|
||||
polynomial_size: PolynomialSize,
|
||||
|
||||
@@ -2,6 +2,7 @@ use super::super::math::fft::{Fft128, Fft128View};
|
||||
use super::ggsw::{cmux, cmux_scratch};
|
||||
use crate::core_crypto::algorithms::extract_lwe_sample_from_glwe_ciphertext;
|
||||
use crate::core_crypto::algorithms::polynomial_algorithms::*;
|
||||
use crate::core_crypto::backward_compatibility::fft_impl::Fourier128LweBootstrapKeyVersions;
|
||||
use crate::core_crypto::commons::math::decomposition::SignedDecomposer;
|
||||
use crate::core_crypto::commons::math::torus::UnsignedTorus;
|
||||
use crate::core_crypto::commons::numeric::CastInto;
|
||||
@@ -20,8 +21,10 @@ use aligned_vec::{avec, ABox, CACHELINE_ALIGN};
|
||||
use core::any::TypeId;
|
||||
use core::mem::transmute;
|
||||
use dyn_stack::{PodStack, ReborrowMut, SizeOverflow, StackReq};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(Fourier128LweBootstrapKeyVersions)]
|
||||
pub struct Fourier128LweBootstrapKey<C: Container<Element = f64>> {
|
||||
data_re0: C,
|
||||
data_re1: C,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::super::math::fft::Fft128View;
|
||||
use crate::core_crypto::backward_compatibility::fft_impl::Fourier128GgswCiphertextVersions;
|
||||
use crate::core_crypto::commons::math::decomposition::{DecompositionLevel, SignedDecomposer};
|
||||
use crate::core_crypto::commons::math::torus::UnsignedTorus;
|
||||
use crate::core_crypto::commons::parameters::{
|
||||
@@ -17,9 +18,11 @@ use crate::core_crypto::prelude::ContainerMut;
|
||||
use aligned_vec::CACHELINE_ALIGN;
|
||||
use concrete_fft::fft128::f128;
|
||||
use dyn_stack::{PodStack, ReborrowMut, SizeOverflow, StackReq};
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
/// A GGSW ciphertext in the Fourier domain.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Versionize)]
|
||||
#[versionize(Fourier128GgswCiphertextVersions)]
|
||||
pub struct Fourier128GgswCiphertext<C: Container<Element = f64>> {
|
||||
data_re0: C,
|
||||
data_re1: C,
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::core_crypto::prelude::ContainerMut;
|
||||
use aligned_vec::{avec, ABox, CACHELINE_ALIGN};
|
||||
use concrete_fft::c64;
|
||||
use dyn_stack::{PodStack, ReborrowMut, SizeOverflow, StackReq};
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize};
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize, VersionizeOwned};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(bound(deserialize = "C: IntoContainerOwned"))]
|
||||
@@ -37,6 +37,7 @@ pub struct FourierLweBootstrapKey<C: Container<Element = c64>> {
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub struct FourierLweBootstrapKeyVersion<'vers> {
|
||||
fourier: FourierPolynomialListVersioned<'vers>,
|
||||
input_lwe_dimension: <LweDimension as Versionize>::Versioned<'vers>,
|
||||
@@ -46,12 +47,13 @@ pub struct FourierLweBootstrapKeyVersion<'vers> {
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub struct FourierLweBootstrapKeyVersionOwned {
|
||||
fourier: FourierPolynomialListVersionedOwned,
|
||||
input_lwe_dimension: <LweDimension as Versionize>::VersionedOwned,
|
||||
glwe_size: <GlweSize as Versionize>::VersionedOwned,
|
||||
decomposition_base_log: <DecompositionBaseLog as Versionize>::VersionedOwned,
|
||||
decomposition_level_count: <DecompositionLevelCount as Versionize>::VersionedOwned,
|
||||
input_lwe_dimension: <LweDimension as VersionizeOwned>::VersionedOwned,
|
||||
glwe_size: <GlweSize as VersionizeOwned>::VersionedOwned,
|
||||
decomposition_base_log: <DecompositionBaseLog as VersionizeOwned>::VersionedOwned,
|
||||
decomposition_level_count: <DecompositionLevelCount as VersionizeOwned>::VersionedOwned,
|
||||
}
|
||||
|
||||
impl<'vers, C: Container<Element = c64>> From<&'vers FourierLweBootstrapKey<C>>
|
||||
@@ -68,10 +70,10 @@ impl<'vers, C: Container<Element = c64>> From<&'vers FourierLweBootstrapKey<C>>
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> From<&FourierLweBootstrapKey<C>>
|
||||
impl<C: Container<Element = c64>> From<FourierLweBootstrapKey<C>>
|
||||
for FourierLweBootstrapKeyVersionOwned
|
||||
{
|
||||
fn from(value: &FourierLweBootstrapKey<C>) -> Self {
|
||||
fn from(value: FourierLweBootstrapKey<C>) -> Self {
|
||||
Self {
|
||||
fourier: value.fourier.versionize_owned(),
|
||||
input_lwe_dimension: value.input_lwe_dimension.versionize_owned(),
|
||||
@@ -107,10 +109,12 @@ impl<C: Container<Element = c64>> Versionize for FourierLweBootstrapKey<C> {
|
||||
fn versionize(&self) -> Self::Versioned<'_> {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> VersionizeOwned for FourierLweBootstrapKey<C> {
|
||||
type VersionedOwned = FourierLweBootstrapKeyVersionedOwned;
|
||||
|
||||
fn versionize_owned(&self) -> Self::VersionedOwned {
|
||||
fn versionize_owned(self) -> Self::VersionedOwned {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
use super::super::math::decomposition::TensorSignedDecompositionLendingIter;
|
||||
use super::super::math::fft::{FftView, FourierPolynomialList};
|
||||
use super::super::math::polynomial::FourierPolynomialMutView;
|
||||
use crate::core_crypto::backward_compatibility::fft_impl::{
|
||||
FourierGgswCiphertextVersioned, FourierGgswCiphertextVersionedOwned,
|
||||
FourierPolynomialListVersioned, FourierPolynomialListVersionedOwned,
|
||||
};
|
||||
use crate::core_crypto::commons::math::decomposition::{DecompositionLevel, SignedDecomposer};
|
||||
use crate::core_crypto::commons::math::torus::UnsignedTorus;
|
||||
use crate::core_crypto::commons::parameters::{
|
||||
@@ -17,6 +21,7 @@ use crate::core_crypto::entities::glwe_ciphertext::{GlweCiphertextMutView, GlweC
|
||||
use aligned_vec::{avec, ABox, CACHELINE_ALIGN};
|
||||
use concrete_fft::c64;
|
||||
use dyn_stack::{PodStack, ReborrowMut, SizeOverflow, StackReq};
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize, VersionizeOwned};
|
||||
|
||||
/// A GGSW ciphertext in the Fourier domain.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
@@ -28,6 +33,90 @@ pub struct FourierGgswCiphertext<C: Container<Element = c64>> {
|
||||
decomposition_level_count: DecompositionLevelCount,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub struct FourierGgswCiphertextVersion<'vers> {
|
||||
fourier: FourierPolynomialListVersioned<'vers>,
|
||||
glwe_size: <GlweSize as Versionize>::Versioned<'vers>,
|
||||
decomposition_base_log: <DecompositionBaseLog as Versionize>::Versioned<'vers>,
|
||||
decomposition_level_count: <DecompositionLevelCount as Versionize>::Versioned<'vers>,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub struct FourierGgswCiphertextVersionOwned {
|
||||
fourier: FourierPolynomialListVersionedOwned,
|
||||
glwe_size: <GlweSize as VersionizeOwned>::VersionedOwned,
|
||||
decomposition_base_log: <DecompositionBaseLog as VersionizeOwned>::VersionedOwned,
|
||||
decomposition_level_count: <DecompositionLevelCount as VersionizeOwned>::VersionedOwned,
|
||||
}
|
||||
|
||||
impl<'vers, C: Container<Element = c64>> From<&'vers FourierGgswCiphertext<C>>
|
||||
for FourierGgswCiphertextVersion<'vers>
|
||||
{
|
||||
fn from(value: &'vers FourierGgswCiphertext<C>) -> Self {
|
||||
Self {
|
||||
fourier: value.fourier.versionize(),
|
||||
glwe_size: value.glwe_size.versionize(),
|
||||
decomposition_base_log: value.decomposition_base_log.versionize(),
|
||||
decomposition_level_count: value.decomposition_level_count.versionize(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> From<FourierGgswCiphertext<C>>
|
||||
for FourierGgswCiphertextVersionOwned
|
||||
{
|
||||
fn from(value: FourierGgswCiphertext<C>) -> Self {
|
||||
Self {
|
||||
fourier: value.fourier.versionize_owned(),
|
||||
glwe_size: value.glwe_size.versionize_owned(),
|
||||
decomposition_base_log: value.decomposition_base_log.versionize_owned(),
|
||||
decomposition_level_count: value.decomposition_level_count.versionize_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: IntoContainerOwned<Element = c64>> TryFrom<FourierGgswCiphertextVersionOwned>
|
||||
for FourierGgswCiphertext<C>
|
||||
{
|
||||
type Error = UnversionizeError;
|
||||
fn try_from(value: FourierGgswCiphertextVersionOwned) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
fourier: FourierPolynomialList::unversionize(value.fourier)?,
|
||||
glwe_size: GlweSize::unversionize(value.glwe_size)?,
|
||||
decomposition_base_log: DecompositionBaseLog::unversionize(
|
||||
value.decomposition_base_log,
|
||||
)?,
|
||||
decomposition_level_count: DecompositionLevelCount::unversionize(
|
||||
value.decomposition_level_count,
|
||||
)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> Versionize for FourierGgswCiphertext<C> {
|
||||
type Versioned<'vers> = FourierGgswCiphertextVersioned<'vers> where C: 'vers;
|
||||
|
||||
fn versionize(&self) -> Self::Versioned<'_> {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> VersionizeOwned for FourierGgswCiphertext<C> {
|
||||
type VersionedOwned = FourierGgswCiphertextVersionedOwned;
|
||||
|
||||
fn versionize_owned(self) -> Self::VersionedOwned {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: IntoContainerOwned<Element = c64>> Unversionize for FourierGgswCiphertext<C> {
|
||||
fn unversionize(versioned: Self::VersionedOwned) -> Result<Self, UnversionizeError> {
|
||||
Self::try_from(versioned)
|
||||
}
|
||||
}
|
||||
|
||||
/// A matrix containing a single level of gadget decomposition, in the Fourier domain.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct FourierGgswLevelMatrix<C: Container<Element = c64>> {
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::mem::{align_of, size_of};
|
||||
use std::sync::{Arc, OnceLock, RwLock};
|
||||
#[cfg(not(feature = "experimental-force_fft_algo_dif4"))]
|
||||
use std::time::Duration;
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize};
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize, VersionizeOwned};
|
||||
|
||||
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
|
||||
mod x86;
|
||||
@@ -595,10 +595,12 @@ impl<C: Container<Element = c64>> Versionize for FourierPolynomialList<C> {
|
||||
fn versionize(&self) -> Self::Versioned<'_> {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Container<Element = c64>> VersionizeOwned for FourierPolynomialList<C> {
|
||||
type VersionedOwned = FourierPolynomialListVersionedOwned;
|
||||
|
||||
fn versionize_owned(&self) -> Self::VersionedOwned {
|
||||
fn versionize_owned(self) -> Self::VersionedOwned {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
@@ -618,6 +620,7 @@ impl<C: Container<Element = c64>> serde::Serialize for FourierPolynomialList<C>
|
||||
) -> Result<S::Ok, S::Error> {
|
||||
use crate::core_crypto::commons::traits::Split;
|
||||
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub struct SingleFourierPolynomial<'a> {
|
||||
fft: FftView<'a>,
|
||||
buf: &'a [c64],
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::{CompactCiphertextList as HlCompactCiphertextList, CompressedFheBool,
|
||||
|
||||
// Manual impl
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub(crate) enum InnerBooleanVersionedOwned {
|
||||
V0(InnerBooleanVersionOwned),
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::CompressedCiphertextList;
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum CompressedCiphertextListVersions {
|
||||
V0(CompressedCiphertextList),
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use std::convert::Infallible;
|
||||
|
||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||
use tfhe_versionable::{Upgrade, Version, Versionize, VersionsDispatch};
|
||||
|
||||
@@ -21,11 +23,13 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
// Manual impl
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub(crate) enum SignedRadixCiphertextVersionedOwned {
|
||||
V0(SignedRadixCiphertextVersionOwned),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub(crate) enum UnsignedRadixCiphertextVersionedOwned {
|
||||
V0(UnsignedRadixCiphertextVersionOwned),
|
||||
}
|
||||
@@ -51,7 +55,9 @@ pub enum CompressedSignedRadixCiphertextV0 {
|
||||
}
|
||||
|
||||
impl Upgrade<CompressedSignedRadixCiphertext> for CompressedSignedRadixCiphertextV0 {
|
||||
fn upgrade(self) -> Result<CompressedSignedRadixCiphertext, String> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn upgrade(self) -> Result<CompressedSignedRadixCiphertext, Self::Error> {
|
||||
match self {
|
||||
Self::Seeded(ct) => Ok(CompressedSignedRadixCiphertext::Seeded(ct)),
|
||||
|
||||
@@ -87,7 +93,9 @@ pub enum CompressedRadixCiphertextV0 {
|
||||
}
|
||||
|
||||
impl Upgrade<CompressedRadixCiphertext> for CompressedRadixCiphertextV0 {
|
||||
fn upgrade(self) -> Result<CompressedRadixCiphertext, String> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn upgrade(self) -> Result<CompressedRadixCiphertext, Self::Error> {
|
||||
match self {
|
||||
Self::Seeded(ct) => Ok(CompressedRadixCiphertext::Seeded(ct)),
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::convert::Infallible;
|
||||
use std::sync::Arc;
|
||||
|
||||
use tfhe_versionable::{Upgrade, Version, VersionsDispatch};
|
||||
|
||||
use crate::high_level_api::keys::*;
|
||||
@@ -8,14 +10,27 @@ pub enum ClientKeyVersions {
|
||||
V0(ClientKey),
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub enum ServerKeyVersioned<'vers> {
|
||||
V0(ServerKeyVersion<'vers>),
|
||||
// This type was previously versioned using a manual implementation with a conversion
|
||||
// to a type where the inner key was name `integer_key`
|
||||
#[derive(Version)]
|
||||
pub struct ServerKeyV0 {
|
||||
pub(crate) integer_key: Arc<IntegerServerKey>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum ServerKeyVersionedOwned {
|
||||
V0(ServerKeyVersionOwned),
|
||||
impl Upgrade<ServerKey> for ServerKeyV0 {
|
||||
type Error = Infallible;
|
||||
|
||||
fn upgrade(self) -> Result<ServerKey, Self::Error> {
|
||||
Ok(ServerKey {
|
||||
key: self.integer_key,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum ServerKeyVersions {
|
||||
V0(ServerKeyV0),
|
||||
V1(ServerKey),
|
||||
}
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
@@ -56,7 +71,9 @@ pub(crate) struct IntegerClientKeyV0 {
|
||||
}
|
||||
|
||||
impl Upgrade<IntegerClientKey> for IntegerClientKeyV0 {
|
||||
fn upgrade(self) -> Result<IntegerClientKey, String> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn upgrade(self) -> Result<IntegerClientKey, Self::Error> {
|
||||
Ok(IntegerClientKey {
|
||||
key: self.key,
|
||||
wopbs_block_parameters: self.wopbs_block_parameters,
|
||||
@@ -80,7 +97,9 @@ pub struct IntegerServerKeyV0 {
|
||||
}
|
||||
|
||||
impl Upgrade<IntegerServerKey> for IntegerServerKeyV0 {
|
||||
fn upgrade(self) -> Result<IntegerServerKey, String> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn upgrade(self) -> Result<IntegerServerKey, Self::Error> {
|
||||
Ok(IntegerServerKey {
|
||||
key: self.key,
|
||||
wopbs_key: self.wopbs_key,
|
||||
@@ -103,7 +122,9 @@ pub struct IntegerCompressedServerKeyV0 {
|
||||
}
|
||||
|
||||
impl Upgrade<IntegerCompressedServerKey> for IntegerCompressedServerKeyV0 {
|
||||
fn upgrade(self) -> Result<IntegerCompressedServerKey, String> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn upgrade(self) -> Result<IntegerCompressedServerKey, Self::Error> {
|
||||
Ok(IntegerCompressedServerKey {
|
||||
key: self.key,
|
||||
cpk_key_switching_key_material: None,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
pub mod booleans;
|
||||
pub mod compact_list;
|
||||
pub mod compressed_ciphertext_list;
|
||||
pub mod config;
|
||||
pub mod integers;
|
||||
pub mod keys;
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::high_level_api::global_state::{self, with_thread_local_cuda_streams};
|
||||
use crate::integer::BooleanBlock;
|
||||
use crate::Device;
|
||||
use serde::{Deserializer, Serializer};
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize};
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize, VersionizeOwned};
|
||||
|
||||
/// Enum that manages the current inner representation of a boolean.
|
||||
pub(in crate::high_level_api) enum InnerBoolean {
|
||||
@@ -51,8 +51,9 @@ impl<'de> serde::Deserialize<'de> for InnerBoolean {
|
||||
|
||||
// Only CPU data are serialized so we only versionize the CPU type.
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub(crate) struct InnerBooleanVersionOwned(
|
||||
<crate::integer::BooleanBlock as Versionize>::VersionedOwned,
|
||||
<crate::integer::BooleanBlock as VersionizeOwned>::VersionedOwned,
|
||||
);
|
||||
|
||||
impl Versionize for InnerBoolean {
|
||||
@@ -60,15 +61,18 @@ impl Versionize for InnerBoolean {
|
||||
|
||||
fn versionize(&self) -> Self::Versioned<'_> {
|
||||
let data = self.on_cpu();
|
||||
let versioned = data.versionize_owned();
|
||||
let versioned = data.into_owned().versionize_owned();
|
||||
InnerBooleanVersionedOwned::V0(InnerBooleanVersionOwned(versioned))
|
||||
}
|
||||
|
||||
}
|
||||
impl VersionizeOwned for InnerBoolean {
|
||||
type VersionedOwned = InnerBooleanVersionedOwned;
|
||||
|
||||
fn versionize_owned(&self) -> Self::VersionedOwned {
|
||||
fn versionize_owned(self) -> Self::VersionedOwned {
|
||||
let cpu_data = self.on_cpu();
|
||||
InnerBooleanVersionedOwned::V0(InnerBooleanVersionOwned(cpu_data.versionize_owned()))
|
||||
InnerBooleanVersionedOwned::V0(InnerBooleanVersionOwned(
|
||||
cpu_data.into_owned().versionize_owned(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use super::keys::InternalServerKey;
|
||||
use crate::backward_compatibility::compressed_ciphertext_list::CompressedCiphertextListVersions;
|
||||
use crate::core_crypto::commons::math::random::{Deserialize, Serialize};
|
||||
use crate::high_level_api::integers::{FheIntId, FheUintId};
|
||||
use crate::integer::ciphertext::{Compressible, DataKind, Expandable};
|
||||
@@ -68,11 +71,12 @@ impl CompressedCiphertextListBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize, Versionize)]
|
||||
#[versionize(CompressedCiphertextListVersions)]
|
||||
pub struct CompressedCiphertextList(crate::integer::ciphertext::CompressedCiphertextList);
|
||||
|
||||
impl Named for CompressedCiphertextList {
|
||||
const NAME: &'static str = "high_level_api::CompactCiphertextList";
|
||||
const NAME: &'static str = "high_level_api::CompressedCiphertextList";
|
||||
}
|
||||
|
||||
impl CompressedCiphertextList {
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::integer::gpu::ciphertext::CudaIntegerRadixCiphertext;
|
||||
use crate::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
use crate::Device;
|
||||
use serde::{Deserializer, Serializer};
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize};
|
||||
use tfhe_versionable::{Unversionize, UnversionizeError, Versionize, VersionizeOwned};
|
||||
|
||||
pub(crate) enum RadixCiphertext {
|
||||
Cpu(crate::integer::SignedRadixCiphertext),
|
||||
@@ -66,8 +66,9 @@ impl<'de> serde::Deserialize<'de> for RadixCiphertext {
|
||||
|
||||
// Only CPU data are serialized so we only versionize the CPU type.
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[cfg_attr(tfhe_lints, allow(tfhe_lints::serialize_without_versionize))]
|
||||
pub(crate) struct RadixCiphertextVersionOwned(
|
||||
<crate::integer::SignedRadixCiphertext as Versionize>::VersionedOwned,
|
||||
<crate::integer::SignedRadixCiphertext as VersionizeOwned>::VersionedOwned,
|
||||
);
|
||||
|
||||
impl Versionize for RadixCiphertext {
|
||||
@@ -75,16 +76,18 @@ impl Versionize for RadixCiphertext {
|
||||
|
||||
fn versionize(&self) -> Self::Versioned<'_> {
|
||||
let data = self.on_cpu();
|
||||
let versioned = data.versionize_owned();
|
||||
let versioned = data.into_owned().versionize_owned();
|
||||
SignedRadixCiphertextVersionedOwned::V0(RadixCiphertextVersionOwned(versioned))
|
||||
}
|
||||
}
|
||||
|
||||
impl VersionizeOwned for RadixCiphertext {
|
||||
type VersionedOwned = SignedRadixCiphertextVersionedOwned;
|
||||
|
||||
fn versionize_owned(&self) -> Self::VersionedOwned {
|
||||
fn versionize_owned(self) -> Self::VersionedOwned {
|
||||
let cpu_data = self.on_cpu();
|
||||
SignedRadixCiphertextVersionedOwned::V0(RadixCiphertextVersionOwned(
|
||||
cpu_data.versionize_owned(),
|
||||
cpu_data.into_owned().versionize_owned(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user