Compare commits

...

13 Commits

Author SHA1 Message Date
Arthur Meyre
bb400ed85a chore: fix cleatext -> cleartext typo 2026-04-27 16:14:50 +02:00
Arthur Meyre
1c05b863f4 chore: custom fft base_n variable rename
- base_n has a different meaning in the tfhe-fft code, to make it less
confusing when working on such code, renamed base_n
2026-04-27 16:14:49 +02:00
dependabot[bot]
5ceb25bfc2 chore(deps): bump tj-actions/changed-files from 47.0.5 to 47.0.6
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 47.0.5 to 47.0.6.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](22103cc46b...9426d40962)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-version: 47.0.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-27 14:30:11 +02:00
dependabot[bot]
680c2e3eb6 chore(deps): bump actions/cache from 5.0.4 to 5.0.5
Bumps [actions/cache](https://github.com/actions/cache) from 5.0.4 to 5.0.5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](668228422a...27d5ce7f10)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: 5.0.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-27 11:03:30 +02:00
dependabot[bot]
8bc080355d chore(deps): bump zizmorcore/zizmor-action from 0.5.2 to 0.5.3
Bumps [zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action) from 0.5.2 to 0.5.3.
- [Release notes](https://github.com/zizmorcore/zizmor-action/releases)
- [Commits](71321a20a9...b1d7e1fb5d)

---
updated-dependencies:
- dependency-name: zizmorcore/zizmor-action
  dependency-version: 0.5.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-27 10:29:38 +02:00
dependabot[bot]
0cc8d625e4 chore(deps): bump actions/setup-node from 6.3.0 to 6.4.0
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.3.0 to 6.4.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](53b83947a5...48b55a011b)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: 6.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-27 10:29:25 +02:00
Arthur Meyre
ec5d0da883 chore: bump ntt requirement which should have been 0.7.1 already 2026-04-27 09:49:03 +02:00
Arthur Meyre
8ed5633300 chore(hl): export two missing (Compressed)ReRandomizationKey types 2026-04-23 15:32:17 +02:00
David Testé
cf07dcf6a3 chore(docs): update leading-trailing zeros results 2026-04-23 15:16:54 +02:00
Arthur Meyre
20dad23256 chore: bump rand to 0.8.6 in data generation crate
- 1.6 is done in a separate PR which will use the officially published tag
as source for the code, which also updates the lock
2026-04-23 14:35:02 +02:00
Nicolas Sarlin
d7380e4264 chore(backward): use released tfhe for generate_1_6 dep 2026-04-23 14:34:41 +02:00
Nicolas Sarlin
093ffb7699 chore(ci): update toolchain to nightly 2026-04-22 2026-04-23 10:08:57 +02:00
Arthur Meyre
c804b838cb chore: update typos file filter
- with HPU data file checked out the typos CLI finds typos in essentially
binary data
- exclude .hpu files from the checks
2026-04-22 17:22:15 +02:00
83 changed files with 266 additions and 295 deletions

View File

@@ -4,9 +4,6 @@ ignore = [
"RUSTSEC-2024-0436",
# Ignoring unmaintained 'bincode' crate. Getting rid of it would be too complex on the short term.
"RUSTSEC-2025-0141",
# Ignoring unsoundness in 'rand' with custom logger. Rand update is currently blocked by
# arkworks and we do not use custom loggers.
"RUSTSEC-2026-0097",
]
[output]

View File

@@ -54,7 +54,7 @@ jobs:
- name: Retrieve data from cache
id: retrieve-data-cache
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
with:
path: |
utils/tfhe-backward-compat-data/**/*.cbor
@@ -89,7 +89,7 @@ jobs:
- name: Store data in cache
if: steps.retrieve-data-cache.outputs.cache-hit != 'true'
continue-on-error: true
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
with:
path: |
utils/tfhe-backward-compat-data/**/*.cbor

View File

@@ -69,7 +69,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
dependencies:
@@ -200,7 +200,7 @@ jobs:
- name: Node cache restoration
id: node-cache
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
with:
path: |
~/.nvm
@@ -213,7 +213,7 @@ jobs:
make install_node
- name: Node cache save
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
if: steps.node-cache.outputs.cache-hit != 'true'
with:
path: |

View File

@@ -56,7 +56,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
integer:

View File

@@ -57,7 +57,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
integer:

View File

@@ -78,7 +78,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
dependencies:

View File

@@ -45,7 +45,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
wasm:
@@ -92,7 +92,7 @@ jobs:
- name: Node cache restoration
id: node-cache
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
with:
path: |
~/.nvm
@@ -105,7 +105,7 @@ jobs:
make install_node
- name: Node cache save
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
if: steps.node-cache.outputs.cache-hit != 'true'
with:
path: |

View File

@@ -34,7 +34,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
backward:

View File

@@ -204,7 +204,7 @@ jobs:
uses: foundry-rs/foundry-toolchain@8789b3e21e6c11b2697f5eb56eddae542f746c10
- name: Cache cargo
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cargo/registry
@@ -232,7 +232,7 @@ jobs:
working-directory: fhevm/coprocessor/fhevm-engine/tfhe-worker
- name: Use Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 20.x

View File

@@ -46,7 +46,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
wasm_bench:

View File

@@ -124,7 +124,7 @@ jobs:
- name: Node cache restoration
id: node-cache
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
with:
path: |
~/.nvm
@@ -137,7 +137,7 @@ jobs:
make install_node
- name: Node cache save
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
if: steps.node-cache.outputs.cache-hit != 'true'
with:
path: |

View File

@@ -138,7 +138,7 @@ jobs:
- name: Node cache restoration
if: inputs.run-pcc-cpu-batch == 'pcc_batch_2'
id: node-cache
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
with:
path: |
~/.nvm
@@ -151,7 +151,7 @@ jobs:
make install_node
- name: Node cache save
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
if: inputs.run-pcc-cpu-batch == 'pcc_batch_2' && steps.node-cache.outputs.cache-hit != 'true'
with:
path: |

View File

@@ -40,7 +40,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
fft:

View File

@@ -42,7 +42,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
ntt:

View File

@@ -43,7 +43,7 @@ jobs:
echo "version=$(make zizmor_version)" >> "${GITHUB_OUTPUT}"
- name: Check workflows security
uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2
uses: zizmorcore/zizmor-action@b1d7e1fb5de872772f31590499237e7cce841e8e # v0.5.3
with:
advanced-security: 'false' # Print results directly in logs
persona: pedantic

View File

@@ -44,7 +44,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
tfhe:

View File

@@ -46,7 +46,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
csprng:

View File

@@ -49,7 +49,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -47,7 +47,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -48,7 +48,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -49,7 +49,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -45,7 +45,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -48,7 +48,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -48,7 +48,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -48,7 +48,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -49,7 +49,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -49,7 +49,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -48,7 +48,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -49,7 +49,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -49,7 +49,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -47,7 +47,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
gpu:

View File

@@ -41,7 +41,7 @@ jobs:
- name: Check for file changes
id: changed-files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_yaml: |
hpu:

View File

@@ -89,7 +89,7 @@ jobs:
make build_web_js_api_parallel
- name: Authenticate on NPM
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'

View File

@@ -53,7 +53,7 @@ jobs:
- name: Restore Sagemath image from cache
id: docker-cache
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
with:
path: /tmp/sagemath_image
key: sagemath-image-${{ env.SAGEMATH_VERSION }}-${{ github.sha }}
@@ -76,7 +76,7 @@ jobs:
- name: Store Sagemath image in cache
if: steps.docker-cache.outputs.cache-hit != 'true'
continue-on-error: true
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
with:
path: /tmp/sagemath_image
key: sagemath-image-${{ env.SAGEMATH_VERSION }}-${{ github.sha }}

View File

@@ -360,7 +360,7 @@ check_fmt_toml: install_taplo
.PHONY: check_typos # Check for typos in codebase
check_typos: install_typos_checker
@git ls-files ":!*.png" ":!*.cbor" ":!*.bcode" ":!*.ico" ":!*/twiddles.cu" | typos --file-list - && echo "No typos found"
@git ls-files ":!*.png" ":!*.cbor" ":!*.bcode" ":!*.ico" ":!*/twiddles.cu" ":!*.hpu" | typos --file-list - && echo "No typos found"
.PHONY: clippy_gpu # Run clippy lints on tfhe with "gpu" enabled
clippy_gpu: install_rs_check_toolchain

View File

@@ -156,7 +156,7 @@ impl HpuVarWrapped {
{
let mut inner = var.inner.lock().unwrap();
for (slot, ct) in std::iter::zip(inner.bundle.iter_mut(), ct.into_iter()) {
for (slot, ct) in std::iter::zip(inner.bundle.iter_mut(), ct) {
#[cfg(feature = "io-dump")]
let params = ct.params().clone();
for (id, cut) in ct.into_container().iter().enumerate() {

View File

@@ -1 +1 @@
nightly-2026-01-14
nightly-2026-04-22

View File

@@ -168,7 +168,7 @@ mod generic_tests {
fn test_xof_seed_getters() {
let seed_bytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
let bits = u128::from_le_bytes(seed_bytes);
let dsep = [b't', b'f', b'h', b'e', b'k', b's', b'p', b's'];
let dsep = *b"tfheksps";
let seed = XofSeed::new_u128(bits, dsep);
let s = u128::from_le_bytes(seed.seed().try_into().unwrap());

View File

@@ -64,7 +64,7 @@ tfhe-fft = { version = "0.10.1", path = "../tfhe-fft", features = [
"serde",
"fft128",
] }
tfhe-ntt = { version = "0.7.0", path = "../tfhe-ntt" }
tfhe-ntt = { version = "0.7.1", path = "../tfhe-ntt" }
pulp = { workspace = true, features = ["default"] }
tfhe-cuda-backend = { version = "0.14.0", path = "../backends/tfhe-cuda-backend", optional = true }
aligned-vec = { workspace = true, features = ["default", "serde"] }

View File

@@ -75,11 +75,11 @@
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="594.0" y="420.0">121 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="678.0" y="420.0">165 ms</text>
<text dominant-baseline="middle" text-anchor="start" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="6" y="460.0">Leading / Trailing zeros/ones</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="342.0" y="460.0">88.4 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="426.0" y="460.0">148 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="510.0" y="460.0">169 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="594.0" y="460.0">222 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="678.0" y="460.0">275 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="342.0" y="460.0">67.2 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="426.0" y="460.0">70.6 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="510.0" y="460.0">89.8 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="594.0" y="460.0">92.6 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="678.0" y="460.0">113 ms</text>
<text dominant-baseline="middle" text-anchor="start" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="6" y="500.0">Log2</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="342.0" y="500.0">110 ms</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="426.0" y="500.0">163 ms</text>

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -75,11 +75,11 @@
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="594.0" y="420.0">32.5 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="678.0" y="420.0">14.0 ops/s</text>
<text dominant-baseline="middle" text-anchor="start" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="6" y="460.0">Leading / Trailing zeros/ones</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="342.0" y="460.0">625 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="426.0" y="460.0">247 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="510.0" y="460.0">108 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="594.0" y="460.0">44.1 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="678.0" y="460.0">19.0 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="342.0" y="460.0">824 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="426.0" y="460.0">487 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="510.0" y="460.0">222 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="594.0" y="460.0">119 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="678.0" y="460.0">57.8 ops/s</text>
<text dominant-baseline="middle" text-anchor="start" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="6" y="500.0">Log2</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="342.0" y="500.0">542 ops/s</text>
<text dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="14" font-weight="normal" fill="black" x="426.0" y="500.0">220 ops/s</text>

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -85,7 +85,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let public_key = tfhe::CompactPublicKey::try_new(&client_key).unwrap();
// This can be left empty, but if provided allows to tie the proof to arbitrary data
let metadata = [b'T', b'F', b'H', b'E', b'-', b'r', b's'];
let metadata = b"TFHE-rs";
let clear_a = random::<u64>();
let clear_b = random::<u64>();
@@ -93,7 +93,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let proven_compact_list = tfhe::ProvenCompactCiphertextList::builder(&public_key)
.push(clear_a)
.push(clear_b)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Verify)?;
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Verify)?;
// Server side
let result = {
@@ -101,7 +101,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
// Verify the proofs and expand the ciphertexts
let expander =
proven_compact_list.verify_and_expand(&crs, &public_key, &metadata)?;
proven_compact_list.verify_and_expand(&crs, &public_key, metadata)?;
let a: tfhe::FheUint64 = expander.get(0)?.unwrap();
let b: tfhe::FheUint64 = expander.get(1)?.unwrap();

View File

@@ -120,7 +120,7 @@ pub fn main() {
let rerand_domain_separator = *b"TFHE_Rrd";
let crs = CompactPkeCrs::from_config(config, 2048).unwrap();
let metadata = [b'r', b'e', b'r', b'a', b'n', b'd'];
let metadata = b"rerand";
set_server_key(sks);
@@ -132,7 +132,7 @@ pub fn main() {
.push(clear_a)
.push(clear_b)
.push(false)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
// Simulate a 256 bits nonce
@@ -151,7 +151,7 @@ pub fn main() {
// Verify, re_randomize and expand
let expander = compact_list
.verify_re_randomize_and_expand(&crs, &cpk, &metadata, seed_gen.next_seed().unwrap())
.verify_re_randomize_and_expand(&crs, &cpk, metadata, seed_gen.next_seed().unwrap())
.unwrap();
let a: FheUint64 = expander.get(0).unwrap().unwrap();

View File

@@ -46,7 +46,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let server_key = tfhe::ServerKey::new(&client_key);
let public_key = tfhe::CompactPublicKey::try_new(&client_key).unwrap();
// This can be left empty, but if provided allows to tie the proof to arbitrary data
let metadata = [b'T', b'F', b'H', b'E', b'-', b'r', b's'];
let metadata = b"TFHE-rs";
let clear_a = rng.gen::<u64>();
let clear_b = rng.gen::<u64>();
@@ -54,7 +54,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let proven_compact_list = tfhe::ProvenCompactCiphertextList::builder(&public_key)
.push(clear_a)
.push(clear_b)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Verify)?;
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Verify)?;
// Server side
let result = {
@@ -62,7 +62,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
// Verify the ciphertexts
let expander =
proven_compact_list.verify_and_expand(&crs, &public_key, &metadata)?;
proven_compact_list.verify_and_expand(&crs, &public_key, metadata)?;
let a: tfhe::FheUint64 = expander.get(0)?.unwrap();
let b: tfhe::FheUint64 = expander.get(1)?.unwrap();
@@ -118,7 +118,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let server_key = tfhe::ServerKey::new(&client_key);
let public_key = tfhe::CompactPublicKey::try_new(&client_key).unwrap();
// This can be left empty, but if provided allows to tie the proof to arbitrary data
let metadata = [b'T', b'F', b'H', b'E', b'-', b'r', b's'];
let metadata = b"TFHE-rs";
let clear_a = rng.gen::<u64>();
let clear_b = rng.gen::<u64>();
@@ -126,7 +126,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let proven_compact_list = tfhe::ProvenCompactCiphertextList::builder(&public_key)
.push(clear_a)
.push(clear_b)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Verify)?;
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Verify)?;
// Server side
let result = {
@@ -134,7 +134,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
// Verify the ciphertexts
let expander =
proven_compact_list.verify_and_expand(&crs, &public_key, &metadata)?;
proven_compact_list.verify_and_expand(&crs, &public_key, metadata)?;
let a: tfhe::FheUint64 = expander.get(0)?.unwrap();
let b: tfhe::FheUint64 = expander.get(1)?.unwrap();

View File

@@ -252,9 +252,7 @@ where
))
}
const NON_ESCAPABLE_SYMBOLS: [u8; 14] = [
b'&', b';', b':', b',', b'`', b'~', b'-', b'_', b'!', b'@', b'#', b'%', b'\'', b'\"',
];
const NON_ESCAPABLE_SYMBOLS: [u8; 14] = *b"&;:,`~-_!@#%'\"";
fn atom<Input>() -> impl Parser<Input, Output = RegExpr>
where

View File

@@ -1251,7 +1251,7 @@ pub fn encrypt_lwe_ciphertext_iterator_with_seeded_public_key<Scalar, KeyCont, O
}
}
for (output_ct, plaintext) in output.iter_mut().zip(encoded.into_iter()) {
for (output_ct, plaintext) in output.iter_mut().zip(encoded) {
lwe_ciphertext_plaintext_add_assign(output_ct, plaintext);
}
}
@@ -2123,7 +2123,7 @@ pub fn encrypt_lwe_ciphertext_with_compact_public_key<
///
/// // We can add custom metadata that will be required for verification, allowing to tie the proof
/// // to some arbitrary data.
/// let metadata = [b'T', b'F', b'H', b'E', b'-', b'r', b's'];
/// let metadata = b"TFHE-rs";
///
/// // Create the PRNG
/// let mut seeder = new_seeder();
@@ -2170,14 +2170,14 @@ pub fn encrypt_lwe_ciphertext_with_compact_public_key<
/// glwe_noise_distribution,
/// encryption_generator.noise_generator_mut(),
/// &crs,
/// &metadata,
/// metadata,
/// ZkComputeLoad::Proof,
/// )
/// .unwrap();
///
/// // verify the ciphertext list with the proof
/// assert!(
/// verify_lwe_ciphertext(&lwe, &lwe_compact_public_key, &proof, &crs, &metadata).is_valid()
/// verify_lwe_ciphertext(&lwe, &lwe_compact_public_key, &proof, &crs, metadata).is_valid()
/// );
///
/// let decrypted_plaintext = decrypt_lwe_ciphertext(&lwe_secret_key, &lwe);
@@ -2572,7 +2572,7 @@ pub fn encrypt_lwe_compact_ciphertext_list_with_compact_public_key<
///
/// // We can add custom metadata that will be required for verification, allowing to tie the proof
/// // to some arbitrary data.
/// let metadata = [b'T', b'F', b'H', b'E', b'-', b'r', b's'];
/// let metadata = b"TFHE-rs";
///
/// // Create the PRNG
/// let mut seeder = new_seeder();
@@ -2623,7 +2623,7 @@ pub fn encrypt_lwe_compact_ciphertext_list_with_compact_public_key<
/// glwe_noise_distribution,
/// encryption_generator.noise_generator_mut(),
/// &crs,
/// &metadata,
/// metadata,
/// ZkComputeLoad::Proof,
/// )
/// .unwrap();
@@ -2634,7 +2634,7 @@ pub fn encrypt_lwe_compact_ciphertext_list_with_compact_public_key<
/// &lwe_compact_public_key,
/// &proof,
/// &crs,
/// &metadata,
/// metadata,
/// )
/// .is_valid());
///
@@ -3045,7 +3045,7 @@ pub fn par_encrypt_lwe_compact_ciphertext_list_with_compact_public_key<
///
/// // We can add custom metadata that will be required for verification, allowing to tie the proof
/// // to some arbitrary data.
/// let metadata = [b'T', b'F', b'H', b'E', b'-', b'r', b's'];
/// let metadata = b"TFHE-rs";
///
/// // Create the PRNG
/// let mut seeder = new_seeder();
@@ -3096,7 +3096,7 @@ pub fn par_encrypt_lwe_compact_ciphertext_list_with_compact_public_key<
/// glwe_noise_distribution,
/// encryption_generator.noise_generator_mut(),
/// &crs,
/// &metadata,
/// metadata,
/// ZkComputeLoad::Proof,
/// )
/// .unwrap();
@@ -3107,7 +3107,7 @@ pub fn par_encrypt_lwe_compact_ciphertext_list_with_compact_public_key<
/// &lwe_compact_public_key,
/// &proof,
/// &crs,
/// &metadata,
/// metadata,
/// )
/// .is_valid());
///

View File

@@ -1010,7 +1010,7 @@ fn lwe_compact_public_encrypt_prove_verify_decrypt_custom_mod<Scalar>(
let message_modulus_log = params.message_modulus_log;
let encoding_with_padding = get_encoding_with_padding(ciphertext_modulus);
let metadata = [b'c', b'o', b'r', b'e'];
let metadata = b"core";
let mut rsc = TestResources::new();
let mut random_generator = RandomGenerator::<DefaultRandomGenerator>::new(rsc.seeder.seed());
@@ -1073,7 +1073,7 @@ fn lwe_compact_public_encrypt_prove_verify_decrypt_custom_mod<Scalar>(
glwe_noise_distribution,
rsc.encryption_random_generator.noise_generator_mut(),
crs,
&metadata,
metadata,
ZkComputeLoad::Proof,
)
.unwrap();
@@ -1090,13 +1090,13 @@ fn lwe_compact_public_encrypt_prove_verify_decrypt_custom_mod<Scalar>(
assert_eq!(msg, decoded);
// Verify the proof
assert!(verify_lwe_ciphertext(&ct, &pk, &proof, crs, &metadata).is_valid());
assert!(verify_lwe_ciphertext(&ct, &pk, &proof, crs, metadata).is_valid());
// verify proof with invalid ciphertext
let index = random_generator.gen::<usize>() % ct.as_ref().len();
let value_to_add = random_generator.gen::<Scalar>();
ct.as_mut()[index] = ct.as_mut()[index].wrapping_add(value_to_add);
assert!(verify_lwe_ciphertext(&ct, &pk, &proof, crs, &metadata).is_invalid());
assert!(verify_lwe_ciphertext(&ct, &pk, &proof, crs, metadata).is_invalid());
}
// In coverage, we break after one while loop iteration, changing message values does
@@ -1122,7 +1122,7 @@ fn test_par_compact_lwe_list_public_key_encryption_and_proof() {
let glwe_noise_distribution = TUniform::new(9);
let ciphertext_modulus = CiphertextModulus::new_native();
let metadata = [b'c', b'o', b'r', b'e'];
let metadata = b"core";
let delta_log = 59;
let delta = 1u64 << delta_log;
@@ -1195,7 +1195,7 @@ fn test_par_compact_lwe_list_public_key_encryption_and_proof() {
glwe_noise_distribution,
encryption_random_generator.noise_generator_mut(),
&crs,
&metadata,
metadata,
ZkComputeLoad::Proof,
)
.unwrap();
@@ -1205,7 +1205,7 @@ fn test_par_compact_lwe_list_public_key_encryption_and_proof() {
&compact_lwe_pk,
&proof,
&crs,
&metadata
metadata
)
.is_valid());
@@ -1236,7 +1236,7 @@ fn test_par_compact_lwe_list_public_key_encryption_and_proof() {
&compact_lwe_pk,
&proof,
&crs,
&metadata
metadata
)
.is_invalid());
@@ -1284,7 +1284,7 @@ fn test_par_compact_lwe_list_public_key_encryption_and_proof() {
glwe_noise_distribution,
encryption_random_generator.noise_generator_mut(),
&crs,
&metadata,
metadata,
ZkComputeLoad::Proof,
)
.unwrap();
@@ -1294,7 +1294,7 @@ fn test_par_compact_lwe_list_public_key_encryption_and_proof() {
&compact_lwe_pk,
&proof,
&crs,
&metadata
metadata
)
.is_valid());
@@ -1325,7 +1325,7 @@ fn test_par_compact_lwe_list_public_key_encryption_and_proof() {
&compact_lwe_pk,
&proof,
&crs,
&metadata
metadata
)
.is_invalid());

View File

@@ -538,4 +538,5 @@ macro_rules! create_parameterized_test_with_non_native_parameters {
};
}
pub(crate) use {create_parameterized_test, create_parameterized_test_with_non_native_parameters};
pub(crate) use create_parameterized_test;
pub(crate) use create_parameterized_test_with_non_native_parameters;

View File

@@ -19,7 +19,7 @@ pub fn pbs_variance_132_bits_security_gaussian(
lwe_dimension.0 as f64,
glwe_dimension.0 as f64,
polynomial_size.0 as f64,
var_min.0 as f64,
var_min.0,
decomposition_level_count.0 as f64,
decomposition_base_log.0 as f64,
ciphertext_modulus,
@@ -45,7 +45,7 @@ pub fn pbs_variance_132_bits_security_tuniform(
lwe_dimension.0 as f64,
glwe_dimension.0 as f64,
polynomial_size.0 as f64,
var_min.0 as f64,
var_min.0,
decomposition_level_count.0 as f64,
decomposition_base_log.0 as f64,
ciphertext_modulus,

View File

@@ -53,7 +53,7 @@ macro_rules! implement_gaussian {
for a in uniform_rand_bytes_v.iter_mut() {
*a = generator.generate_next();
}
let size = <$T>::BITS as i32;
let size = <$T as crate::core_crypto::commons::numeric::Numeric>::BITS as i32;
let mut u: $T = <$S>::from_le_bytes(uniform_rand_bytes_u).cast_into();
u *= <$T>::TWO.powi(-size + 1);
let mut v: $T = <$S>::from_le_bytes(uniform_rand_bytes_v).cast_into();

View File

@@ -102,7 +102,7 @@ macro_rules! implement {
self.floor()
}
fn to_bit_string(&self) -> String {
if Self::BITS == 32 {
if <Self as Numeric>::BITS == 32 {
let mut bit_string = format!("{:032b}", self.to_bits());
bit_string.insert(1, ' ');
bit_string.insert(10, ' ');

View File

@@ -108,14 +108,14 @@ fn plans() -> &'static PlanMap {
}
pub fn setup_custom_fft_plan(plan: Plan) {
let base_n = FourierPolynomialSize(plan.fft_size());
let n = base_n.to_standard_polynomial_size();
let fft_size = FourierPolynomialSize(plan.fft_size());
let std_poly_size = fft_size.to_standard_polynomial_size();
let plan = Arc::new((Twisties::new(base_n.0), plan));
let plan = Arc::new((Twisties::new(fft_size.0), plan));
let global_plans = plans();
global_plans.set(n, plan);
global_plans.set(std_poly_size, plan);
}
/// Return the input slice, cast to the same type.

View File

@@ -99,7 +99,6 @@ macro_rules! create_gpu_multi_bit_ks32_parameterized_test{
}
use crate::core_crypto::gpu::algorithms::test::params::MultiBitTestKS32Params;
use crate::core_crypto::gpu::lwe_packing_keyswitch_key::CudaLwePackingKeyswitchKey;
use {
create_gpu_multi_bit_ks32_parameterized_test, create_gpu_multi_bit_parameterized_test,
create_gpu_parameterized_test,
};
use create_gpu_multi_bit_ks32_parameterized_test;
use create_gpu_multi_bit_parameterized_test;
use create_gpu_parameterized_test;

View File

@@ -870,7 +870,7 @@ mod zk {
let crs = CompactPkeCrs::from_config(config.into(), 64).unwrap();
let public_key = crate::CompactPublicKey::try_new(&client_key).unwrap();
let metadata = [b'T', b'F', b'H', b'E', b'-', b'r', b's'];
let metadata = b"TFHE-rs";
let clear_a = rng.gen::<u64>();
let clear_b = rng.gen::<bool>();
@@ -878,7 +878,7 @@ mod zk {
let proven_compact_list = crate::ProvenCompactCiphertextList::builder(&public_key)
.push(clear_a)
.push(clear_b)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let params =
@@ -1628,7 +1628,7 @@ mod tests {
// Intentionally low so that we test when multiple lists and proofs are needed
let crs = CompactPkeCrs::from_config(config, 32).unwrap();
let metadata = [b'h', b'l', b'a', b'p', b'i'];
let metadata = b"hlapi";
let compact_list = ProvenCompactCiphertextList::builder(&pk)
.push(17u32)
@@ -1636,14 +1636,12 @@ mod tests {
.push(false)
.push_with_num_bits(3u32, 2)
.unwrap()
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let serialized = bincode::serialize(&compact_list).unwrap();
let compact_list: ProvenCompactCiphertextList = bincode::deserialize(&serialized).unwrap();
let expander = compact_list
.verify_and_expand(&crs, &pk, &metadata)
.unwrap();
let expander = compact_list.verify_and_expand(&crs, &pk, metadata).unwrap();
{
let a: FheUint32 = expander.get(0).unwrap().unwrap();
@@ -1709,7 +1707,7 @@ mod tests {
set_server_key(sks);
let crs = CompactPkeCrs::from_config(config, 32).unwrap();
let metadata = [b's', b'e', b'e', b'd'];
let metadata = b"seed";
let mut rng = thread_rng();
let seed_a: [u8; 16] = rng.gen();
@@ -1721,7 +1719,7 @@ mod tests {
.push(17u32)
.push(-1i64)
.push(false)
.build_with_proof_packed_seeded(&crs, &metadata, ZkComputeLoad::Proof, seed)
.build_with_proof_packed_seeded(&crs, metadata, ZkComputeLoad::Proof, seed)
.unwrap()
};
@@ -1738,7 +1736,7 @@ mod tests {
"different seeds must produce different output"
);
let expander = list_a1.verify_and_expand(&crs, &pk, &metadata).unwrap();
let expander = list_a1.verify_and_expand(&crs, &pk, metadata).unwrap();
let a: FheUint32 = expander.get(0).unwrap().unwrap();
let b: FheInt64 = expander.get(1).unwrap().unwrap();
let c: FheBool = expander.get(2).unwrap().unwrap();
@@ -1769,15 +1767,13 @@ mod tests {
let crs = CompactPkeCrs::from_config(config, 32).unwrap();
let metadata = [b'h', b'l', b'a', b'p', b'i'];
let metadata = b"hlapi";
let compact_list = CompactCiphertextList::builder(&pk)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let expander = compact_list
.verify_and_expand(&crs, &pk, &metadata)
.unwrap();
let expander = compact_list.verify_and_expand(&crs, &pk, metadata).unwrap();
assert!(expander.get::<FheBool>(0).unwrap().is_none());
}
@@ -1818,7 +1814,7 @@ mod tests {
// Intentionally low so that we test when multiple lists and proofs are needed
let crs = CompactPkeCrs::from_config(config, 32).unwrap();
let metadata = [b'h', b'l', b'a', b'p', b'i'];
let metadata = b"hlapi";
let compact_list = ProvenCompactCiphertextList::builder(&pk)
.push(17u32)
@@ -1826,15 +1822,13 @@ mod tests {
.push(false)
.push_with_num_bits(3u32, 2)
.unwrap()
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let serialized = bincode::serialize(&compact_list).unwrap();
let compact_list: ProvenCompactCiphertextList =
bincode::deserialize(&serialized).unwrap();
let expander = compact_list
.verify_and_expand(&crs, &pk, &metadata)
.unwrap();
let expander = compact_list.verify_and_expand(&crs, &pk, metadata).unwrap();
{
let a: FheUint32 = expander.get(0).unwrap().unwrap();

View File

@@ -260,7 +260,7 @@ impl SignedRadixCiphertext {
}
#[cfg(feature = "hpu")]
(_, Device::Hpu) => {
panic!("Hpu device do not support signed integer yet",)
panic!("Hpu device do not support signed integer yet")
}
}
}

View File

@@ -70,8 +70,8 @@ pub use integers::{
pub use keys::CudaServerKey;
pub use keys::{
generate_keys, ClientKey, CompactPublicKey, CompressedCompactPublicKey, CompressedPublicKey,
CompressedReRandomizationKeySwitchingKey, CompressedServerKey, KeySwitchingKey, PublicKey,
ReRandomizationKeySwitchingKey, ServerKey,
CompressedReRandomizationKey, CompressedReRandomizationKeySwitchingKey, CompressedServerKey,
KeySwitchingKey, PublicKey, ReRandomizationKey, ReRandomizationKeySwitchingKey, ServerKey,
};
use strum::FromRepr;

View File

@@ -347,7 +347,7 @@ mod zk {
// Intentionally low so that we test when multiple lists and proofs are needed
let crs = CompactPkeCrs::from_config(config, 32).unwrap();
let metadata = [b'r', b'e', b'r', b'a', b'n', b'd'];
let metadata = b"rerand";
// Case where we want to re-randomize a CompactCiphertextList containing
// FheUint64, FheInt8, and FheBool
@@ -359,7 +359,7 @@ mod zk {
.push(clear_a)
.push(clear_b)
.push(false)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
// Simulate a 256 bits nonce
@@ -378,12 +378,7 @@ mod zk {
// Verify, re_randomize and expand
let expander = compact_list
.verify_re_randomize_and_expand(
&crs,
&cpk,
&metadata,
seed_gen.next_seed().unwrap(),
)
.verify_re_randomize_and_expand(&crs, &cpk, metadata, seed_gen.next_seed().unwrap())
.unwrap();
let a: FheUint64 = expander.get(0).unwrap().unwrap();
@@ -407,7 +402,7 @@ mod zk {
.push(clear_a)
.push(clear_b)
.push(false)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let nonce: [u8; 256 / 8] = core::array::from_fn(|_| rand::random());

View File

@@ -47,7 +47,7 @@ fn test_tag_propagation_zk_pok() {
.build();
let crs = crate::zk::CompactPkeCrs::from_config(config, (2 * 32) + (2 * 64) + 2).unwrap();
let metadata = [b'h', b'l', b'a', b'p', b'i'];
let metadata = b"hlapi";
let mut cks = ClientKey::generate(config);
let tag_value = random();
@@ -70,15 +70,13 @@ fn test_tag_propagation_zk_pok() {
.push(i64::MIN)
.push(false)
.push(true)
.build_with_proof_packed(&crs, &metadata, crate::zk::ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, crate::zk::ZkComputeLoad::Proof)
.unwrap();
let list_packed: ProvenCompactCiphertextList = serialize_then_deserialize(&list_packed);
assert_eq!(list_packed.tag(), cks.tag());
let expander = list_packed
.verify_and_expand(&crs, &cpk, &metadata)
.unwrap();
let expander = list_packed.verify_and_expand(&crs, &cpk, metadata).unwrap();
{
let au32: FheUint32 = expander.get(0).unwrap().unwrap();
@@ -157,7 +155,7 @@ fn test_tag_propagation_zk_pok_gpu() {
.build();
let crs = crate::zk::CompactPkeCrs::from_config(config, (2 * 32) + (2 * 64) + 2).unwrap();
let metadata = [b'h', b'l', b'a', b'p', b'i'];
let metadata = b"hlapi";
let mut cks = ClientKey::generate(config);
let tag_value = random();
@@ -182,12 +180,10 @@ fn test_tag_propagation_zk_pok_gpu() {
.push(i64::MIN)
.push(false)
.push(true)
.build_with_proof_packed(&crs, &metadata, crate::zk::ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, crate::zk::ZkComputeLoad::Proof)
.unwrap();
let expander = list_packed
.verify_and_expand(&crs, &cpk, &metadata)
.unwrap();
let expander = list_packed.verify_and_expand(&crs, &cpk, metadata).unwrap();
{
let au32: FheUint32 = expander.get(0).unwrap().unwrap();

View File

@@ -1403,7 +1403,7 @@ mod zk_pok_tests {
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
let metadata = b"integer";
let num_blocks = 4usize;
let modulus = pke_params
@@ -1433,11 +1433,11 @@ mod zk_pok_tests {
let proven_ct = if is_packed {
builder
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap()
} else {
builder
.build_with_proof(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof(&crs, metadata, ZkComputeLoad::Proof)
.unwrap()
};
@@ -1452,7 +1452,7 @@ mod zk_pok_tests {
.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.as_view()),
)
.unwrap();
@@ -1495,7 +1495,7 @@ mod zk_pok_tests {
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
let metadata = b"integer";
let crs = CompactPkeCrs::from_shortint_params(pke_params, LweCiphertextCount(512)).unwrap();
let cks = ClientKey::new(fhe_params);
@@ -1514,13 +1514,13 @@ mod zk_pok_tests {
let proven_ct = CompactCiphertextList::builder(&pk)
.push_with_num_blocks(1u8, 0)
.push_with_num_blocks(-1i8, 0)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
assert!(proven_ct.is_empty());
assert_eq!(proven_ct.len(), 0);
assert_eq!(
proven_ct.verify(&crs, &pk, &metadata),
proven_ct.verify(&crs, &pk, metadata),
ZkVerificationOutcome::Valid
);
assert!(proven_ct.is_conformant(&conformance_params));
@@ -1528,7 +1528,7 @@ mod zk_pok_tests {
proven_ct.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.as_view()),
),
Ok(vec) if vec.is_empty()
@@ -1538,13 +1538,13 @@ mod zk_pok_tests {
// Test by pushing with nothing
{
let proven_ct = CompactCiphertextList::builder(&pk)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
assert!(proven_ct.is_empty());
assert_eq!(proven_ct.len(), 0);
assert_eq!(
proven_ct.verify(&crs, &pk, &metadata),
proven_ct.verify(&crs, &pk, metadata),
ZkVerificationOutcome::Valid
);
assert!(proven_ct.is_conformant(&conformance_params));
@@ -1552,7 +1552,7 @@ mod zk_pok_tests {
proven_ct.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.as_view()),
),
Ok(vec) if vec.is_empty()
@@ -1564,7 +1564,7 @@ mod zk_pok_tests {
let mut proven_ct = CompactCiphertextList::builder(&pk)
.push(1u8)
.push(-1i8)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
proven_ct.ct_list.proved_lists = Vec::new();
@@ -1577,7 +1577,7 @@ mod zk_pok_tests {
let mut proven_ct = CompactCiphertextList::builder(&pk)
.push(1u8)
.push(-1i8)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
proven_ct.info = Vec::new();
@@ -1647,7 +1647,7 @@ mod zk_pok_tests {
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
let metadata = b"integer";
let crs = CompactPkeCrs::from_shortint_params(pke_params, LweCiphertextCount(2)).unwrap();
let cks = ClientKey::new(fhe_params);
@@ -1664,7 +1664,7 @@ mod zk_pok_tests {
let mut proven_ct = CompactCiphertextList::builder(&pk)
.push_with_num_blocks(1u8, 4)
.push_with_num_blocks(-1i8, 4)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
assert_eq!(proven_ct.len(), 2);
@@ -1684,14 +1684,14 @@ mod zk_pok_tests {
assert!(!proven_ct.is_conformant(&conformance_params));
assert!(proven_ct.is_empty());
assert_eq!(
proven_ct.verify(&crs, &pk, &metadata),
proven_ct.verify(&crs, &pk, metadata),
ZkVerificationOutcome::Valid
);
assert!(matches!(
proven_ct.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.
as_view()),
),
@@ -1706,14 +1706,14 @@ mod zk_pok_tests {
assert!(!proven_ct.is_empty());
assert!(proven_ct.is_packed());
assert_eq!(
proven_ct.verify(&crs, &pk, &metadata),
proven_ct.verify(&crs, &pk, metadata),
ZkVerificationOutcome::Valid
);
assert!(proven_ct
.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.as_view())
)
.is_err());
@@ -1729,14 +1729,14 @@ mod zk_pok_tests {
assert!(!proven_ct.is_empty());
assert!(proven_ct.is_packed());
assert_eq!(
proven_ct.verify(&crs, &pk, &metadata),
proven_ct.verify(&crs, &pk, metadata),
ZkVerificationOutcome::Valid
);
assert!(proven_ct
.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.as_view())
)
.is_ok());
@@ -1748,14 +1748,14 @@ mod zk_pok_tests {
assert!(!proven_ct.is_empty());
assert!(proven_ct.is_packed());
assert_eq!(
proven_ct.verify(&crs, &pk, &metadata),
proven_ct.verify(&crs, &pk, metadata),
ZkVerificationOutcome::Valid
);
assert!(proven_ct
.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.as_view())
)
.is_err());
@@ -1767,7 +1767,7 @@ mod zk_pok_tests {
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
let metadata = b"integer";
let crs = CompactPkeCrs::from_shortint_params(pke_params, LweCiphertextCount(2)).unwrap();
let cks = ClientKey::new(fhe_params);
@@ -1784,7 +1784,7 @@ mod zk_pok_tests {
let mut proven_ct = CompactCiphertextList::builder(&pk)
.push_with_num_blocks(1u8, 4)
.push_with_num_blocks(-1i8, 4)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
assert!(proven_ct.is_conformant(&conformance_params));
@@ -1803,7 +1803,7 @@ mod zk_pok_tests {
let expander = proven_ct.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.as_view()),
);
assert!(expander.is_err());
@@ -1817,7 +1817,7 @@ mod zk_pok_tests {
TEST_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1;
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
let metadata = b"integer";
let num_blocks = 4usize;
let modulus = pke_params
@@ -1839,14 +1839,14 @@ mod zk_pok_tests {
let proven_ct = CompactCiphertextList::builder(&pk)
.extend_with_num_blocks(msgs.iter().copied(), num_blocks)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let expander = proven_ct
.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.as_view()),
)
.unwrap();
@@ -1879,7 +1879,7 @@ mod zk_pok_tests {
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
let metadata = b"integer";
let crs_blocks_for_64_bits =
64 / ((pke_params.message_modulus.0 * pke_params.carry_modulus.0).ilog2() as usize);
@@ -1900,14 +1900,14 @@ mod zk_pok_tests {
let proven_ct = CompactCiphertextList::builder(&pk)
.extend_with_num_blocks(msgs.iter().copied(), encryption_num_blocks)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let expander = proven_ct
.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.as_view()),
)
.unwrap();
@@ -1942,7 +1942,7 @@ mod zk_pok_tests {
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
let metadata = b"integer";
let crs_blocks_for_64_bits =
64 / ((pke_params.message_modulus.0 * pke_params.carry_modulus.0).ilog2() as usize);
@@ -1963,7 +1963,7 @@ mod zk_pok_tests {
let proven_ct = CompactCiphertextList::builder(&pk)
.extend_with_num_blocks(msgs.iter().copied(), encryption_num_blocks)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let infos_block_count = {
@@ -2023,7 +2023,7 @@ mod zk_pok_tests {
.verify_and_expand(
&crs,
&pk,
&metadata,
metadata,
IntegerCompactCiphertextListExpansionMode::CastAndUnpackIfNecessary(ksk.as_view()),
)
.unwrap();

View File

@@ -245,7 +245,7 @@ mod zk {
let fhe_params = TEST_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let num_blocks = 4usize;
let metadata = [b't', b'e', b's', b't'];
let metadata = *b"test";
let rerand_domain_separator = *b"TFHE_Rrd";
let compact_public_encryption_domain_separator = *b"TFHE_Enc";
@@ -403,7 +403,7 @@ mod zk {
// Intentionally low so that we test when multiple lists and proofs are needed
let crs = CompactPkeCrs::from_shortint_params(pke_params, LweCiphertextCount(8)).unwrap();
let metadata = [b'r', b'e', b'r', b'a', b'n', b'd'];
let metadata = b"rerand";
let clear_a = rand::random::<u64>();
let clear_b = rand::random::<i8>();
@@ -412,7 +412,7 @@ mod zk {
.push(clear_a)
.push(clear_b)
.push(false)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
// Clone the list so both CPU and GPU start from the same state

View File

@@ -68,8 +68,9 @@ macro_rules! create_gpu_parameterized_stringified_test{
}
use crate::integer::gpu::server_key::radix::tests_signed::GpuMultiDeviceFunctionExecutor;
pub(crate) use create_gpu_parameterized_stringified_test;
pub(crate) use create_gpu_parameterized_test;
use tfhe_csprng::seeders::Seed;
pub(crate) use {create_gpu_parameterized_stringified_test, create_gpu_parameterized_test};
pub(crate) struct GpuContext {
pub(crate) streams: CudaStreams,

View File

@@ -271,7 +271,7 @@ mod tests {
];
for (ksk_params, pke_params, fhe_params) in params {
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
let metadata = b"integer";
let num_blocks = 4usize;
let modulus = pke_params
@@ -304,7 +304,7 @@ mod tests {
let proven_ct = CompactCiphertextList::builder(&pk)
.extend_with_num_blocks(msgs.iter().copied(), num_blocks)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let gpu_proven_ct =
CudaProvenCompactCiphertextList::from_proven_compact_ciphertext_list(
@@ -312,7 +312,7 @@ mod tests {
);
let gpu_expander = gpu_proven_ct
.verify_and_expand(&crs, &pk, &metadata, &d_ksk, &streams)
.verify_and_expand(&crs, &pk, metadata, &d_ksk, &streams)
.unwrap();
for (idx, msg) in msgs.iter().copied().enumerate() {
@@ -362,7 +362,7 @@ mod tests {
];
for (ksk_params, pke_params, fhe_params) in params {
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
let metadata = b"integer";
let crs_blocks_for_64_bits =
64 / ((pke_params.message_modulus.0 * pke_params.carry_modulus.0).ilog2() as usize);
@@ -392,7 +392,7 @@ mod tests {
let proven_ct = CompactCiphertextList::builder(&pk)
.extend_with_num_blocks(msgs.iter().copied(), encryption_num_blocks)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let gpu_proven_ct =
CudaProvenCompactCiphertextList::from_proven_compact_ciphertext_list(
@@ -400,7 +400,7 @@ mod tests {
);
let gpu_expander = gpu_proven_ct
.verify_and_expand(&crs, &pk, &metadata, &d_ksk, &streams)
.verify_and_expand(&crs, &pk, metadata, &d_ksk, &streams)
.unwrap();
for (idx, msg) in msgs.iter().copied().enumerate() {
@@ -452,7 +452,7 @@ mod tests {
];
for (ksk_params, pke_params, fhe_params) in params {
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
let metadata = b"integer";
let crs_blocks_for_64_bits =
64 / ((pke_params.message_modulus.0 * pke_params.carry_modulus.0).ilog2() as usize);
@@ -482,7 +482,7 @@ mod tests {
let proven_ct = CompactCiphertextList::builder(&pk)
.extend_with_num_blocks(msgs.iter().copied(), encryption_num_blocks)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Proof)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Proof)
.unwrap();
let infos_block_count = {
@@ -543,7 +543,7 @@ mod tests {
);
let gpu_expander = gpu_proven_ct
.verify_and_expand(&crs, &pk, &metadata, &d_ksk, &streams)
.verify_and_expand(&crs, &pk, metadata, &d_ksk, &streams)
.unwrap();
for idx in boolean_block_idx.iter().copied() {
@@ -595,7 +595,7 @@ mod tests {
let crs = CompactPkeCrs::from_config(config, 64).unwrap();
let public_key = crate::CompactPublicKey::try_new(&client_key).unwrap();
let metadata = [b'T', b'F', b'H', b'E', b'-', b'r', b's'];
let metadata = b"TFHE-rs";
// Create a proven compact list with 6 items (matching user's scenario)
let m0 = true;
@@ -611,7 +611,7 @@ mod tests {
.push(m3)
.push(m4)
.push(m5)
.build_with_proof_packed(&crs, &metadata, ZkComputeLoad::Verify)
.build_with_proof_packed(&crs, metadata, ZkComputeLoad::Verify)
.unwrap();
// Set GPU server key
@@ -619,7 +619,7 @@ mod tests {
// Verify and expand on GPU
let expander = proven_compact_list
.verify_and_expand(&crs, &public_key, &metadata)
.verify_and_expand(&crs, &public_key, metadata)
.unwrap();
// The expander should have length 6 (number of data items), not 66 (total blocks)

View File

@@ -570,7 +570,7 @@ mod test {
for num_blocks in 1..64 {
let num_bits = 2 * num_blocks;
println!("num_bits: {num_bits}",);
println!("num_bits: {num_bits}");
for target_result in 0..=num_bits {
for _ in 0..10 {

View File

@@ -75,4 +75,5 @@ macro_rules! create_parameterized_test_classical_params {
});
};
}
pub(crate) use {create_parameterized_test, create_parameterized_test_classical_params};
pub(crate) use create_parameterized_test;
pub(crate) use create_parameterized_test_classical_params;

View File

@@ -667,7 +667,7 @@ mod test {
let pubk = CompactPublicKey::new(&privk);
let crs = CompactPkeCrs::from_shortint_params(cpk_params, LweCiphertextCount(4)).unwrap();
let metadata = [b's', b'h', b'o', b'r', b't', b'i', b'n', b't'];
let metadata = b"shortint";
let ksk_builder = KeySwitchingKeyBuildHelper::new((&privk, None), (&cks, &sks), ks_params);
let casting_key: KeySwitchingKeyView<'_> = ksk_builder.as_key_switching_key_view();
@@ -688,7 +688,7 @@ mod test {
.encrypt_and_prove_slice(
&messages,
&crs,
&metadata,
metadata,
ZkComputeLoad::Verify,
cpk_params.message_modulus.0,
)

View File

@@ -192,7 +192,7 @@ impl ProvenCompactCiphertextList {
let expanded = self
.proved_lists
.iter()
.zip(per_list_casting_mode.into_iter())
.zip(per_list_casting_mode)
.map(|((ct_list, _proof), casting_mode)| ct_list.expand(casting_mode))
.collect::<Result<Vec<Vec<_>>, _>>()?
.into_iter()
@@ -385,7 +385,7 @@ mod tests {
let functions = vec![Some(vec![dyn_id; 1]); 1];
let metadata = [b's', b'h', b'o', b'r', b't', b'i', b'n', b't'];
let metadata = b"shortint";
let msg = random::<u64>() % pke_params.message_modulus.0;
// No packing
@@ -395,7 +395,7 @@ mod tests {
.encrypt_and_prove(
msg,
&crs,
&metadata,
metadata,
ZkComputeLoad::Proof,
encryption_modulus,
)
@@ -417,7 +417,7 @@ mod tests {
let proven_ct = proven_ct.verify_and_expand(
&crs,
&pub_key,
&metadata,
metadata,
ShortintCompactCiphertextListCastingMode::CastIfNecessary {
casting_key: ksk.as_view(),
functions: Some(functions.as_slice()),
@@ -447,7 +447,7 @@ mod tests {
let functions = vec![Some(vec![dyn_id; 1]); 512];
let metadata = [b's', b'h', b'o', b'r', b't', b'i', b'n', b't'];
let metadata = b"shortint";
let msgs = (0..512)
.map(|_| random::<u64>() % params.message_modulus.0)
@@ -457,18 +457,18 @@ mod tests {
.encrypt_and_prove_slice(
&msgs,
&crs,
&metadata,
metadata,
ZkComputeLoad::Proof,
params.message_modulus.0,
)
.unwrap();
assert!(proven_ct.verify(&crs, &pub_key, &metadata).is_valid());
assert!(proven_ct.verify(&crs, &pub_key, metadata).is_valid());
let expanded = proven_ct
.verify_and_expand(
&crs,
&pub_key,
&metadata,
metadata,
ShortintCompactCiphertextListCastingMode::CastIfNecessary {
casting_key: ksk.as_view(),
functions: Some(functions.as_slice()),
@@ -496,7 +496,7 @@ mod tests {
let sk = ServerKey::new(&ck);
let ksk = KeySwitchingKey::new((&priv_key, None), (&ck, &sk), ksk_params);
let metadata = [b's', b'h', b'o', b'r', b't', b'i', b'n', b't'];
let metadata = b"shortint";
let msgs = (0..512)
.map(|_| random::<u64>() % params.message_modulus.0)
@@ -506,18 +506,18 @@ mod tests {
.encrypt_and_prove_slice(
&msgs,
&crs,
&metadata,
metadata,
ZkComputeLoad::Proof,
params.message_modulus.0,
)
.unwrap();
assert!(proven_ct.verify(&crs, &pub_key, &metadata).is_valid());
assert!(proven_ct.verify(&crs, &pub_key, metadata).is_valid());
let expanded = proven_ct
.verify_and_expand(
&crs,
&pub_key,
&metadata,
metadata,
ShortintCompactCiphertextListCastingMode::CastIfNecessary {
casting_key: ksk.as_view(),
functions: None,
@@ -544,7 +544,7 @@ mod tests {
let priv_key = CompactPrivateKey::new(pke_params);
let pub_key = CompactPublicKey::new(&priv_key);
let metadata = [b's', b'h', b'o', b'r', b't', b'i', b'n', b't'];
let metadata = b"shortint";
let msgs = (0..total_lwe_count)
.map(|_| random::<u64>() % params.message_modulus.0)
@@ -554,12 +554,12 @@ mod tests {
.encrypt_and_prove_slice(
&msgs,
&crs,
&metadata,
metadata,
ZkComputeLoad::Verify,
params.message_modulus.0 * params.carry_modulus.0,
)
.unwrap();
assert!(proven_ct.verify(&crs, &pub_key, &metadata).is_valid());
assert!(proven_ct.verify(&crs, &pub_key, metadata).is_valid());
let zk_conformance_params = CompactPkeProofConformanceParams::new(crs.scheme_version());

View File

@@ -56,7 +56,7 @@ impl<Scalar: UnsignedInteger + CastFrom<u64>> ShortintEncoding<Scalar> {
}
impl<Scalar: UnsignedInteger + CastFrom<u64>> ShortintEncoding<Scalar> {
/// Return the cleatext space including the space for the [`Self::padding_bit`] if it is set to
/// Return the cleartext space including the space for the [`Self::padding_bit`] if it is set to
/// [`PaddingBit::Yes`].
pub(crate) fn full_cleartext_space(&self) -> Scalar {
let cleartext_modulus = self.cleartext_space_without_padding();
@@ -69,7 +69,7 @@ impl<Scalar: UnsignedInteger + CastFrom<u64>> ShortintEncoding<Scalar> {
}
}
/// Return the cleatext space defined by the [`Self::message_modulus`] and
/// Return the cleartext space defined by the [`Self::message_modulus`] and
/// [`Self::carry_modulus`], not taking the value of the [`Self::padding_bit`] into account.
pub(crate) fn cleartext_space_without_padding(&self) -> Scalar {
(self.message_modulus.0 * self.carry_modulus.0).cast_into()

View File

@@ -1130,7 +1130,7 @@ pub mod test_utils {
/// to 0 to keep the carry free.
/// output_modulus: the output cleartext space, continuing the above example, it must contain
/// the padding bit, so for 4 bits of cleartext this is actually 2^(1 + 4)==32
pub fn cleatext_prf(
pub fn cleartext_prf(
input_cleartext: u64,
random_bits_count: u64,
output_modulus: u64,
@@ -1163,7 +1163,7 @@ pub mod test_utils {
#[cfg(test)]
pub(crate) mod test {
use super::test_utils::cleatext_prf;
use super::test_utils::cleartext_prf;
use super::*;
use crate::core_crypto::commons::math::random::Seed;
use crate::core_crypto::prelude::{decrypt_lwe_ciphertext, CastInto, LweSecretKeyView};
@@ -1244,7 +1244,7 @@ pub(crate) mod test {
// includes padding bit
let output_modulus = 2 * params.message_modulus().0 * params.carry_modulus().0;
let expected_output = cleatext_prf(
let expected_output = cleartext_prf(
plain_prf_input,
random_bits_count,
output_modulus,

View File

@@ -167,7 +167,7 @@ impl MetaParameters {
return self;
}
panic!("Invalid MetaParameters",);
panic!("Invalid MetaParameters");
}
}

View File

@@ -179,7 +179,7 @@ impl<AP: AtomicPattern> GenericServerKey<AP> {
pub fn unchecked_div_assign(&self, ct_left: &mut Ciphertext, ct_right: &Ciphertext) {
let value_on_div_by_zero = ct_left.message_modulus.0 - 1;
self.unchecked_evaluate_bivariate_function_assign(ct_left, ct_right, |x, y| {
safe_division(x, y, value_on_div_by_zero)
x.checked_div(y).unwrap_or(value_on_div_by_zero)
});
}
@@ -218,7 +218,7 @@ impl<AP: AtomicPattern> GenericServerKey<AP> {
pub fn smart_div(&self, ct_left: &mut Ciphertext, ct_right: &mut Ciphertext) -> Ciphertext {
let value_on_div_by_zero = ct_left.message_modulus.0 - 1;
self.smart_evaluate_bivariate_function(ct_left, ct_right, |x, y| {
safe_division(x, y, value_on_div_by_zero)
x.checked_div(y).unwrap_or(value_on_div_by_zero)
})
}
@@ -257,16 +257,7 @@ impl<AP: AtomicPattern> GenericServerKey<AP> {
pub fn smart_div_assign(&self, ct_left: &mut Ciphertext, ct_right: &mut Ciphertext) {
let value_on_div_by_zero = ct_left.message_modulus.0 - 1;
self.smart_evaluate_bivariate_function_assign(ct_left, ct_right, |x, y| {
safe_division(x, y, value_on_div_by_zero)
x.checked_div(y).unwrap_or(value_on_div_by_zero)
});
}
}
// Specific division function returning value_on_div_by_zero in case of a division by 0
pub(crate) fn safe_division(x: u64, y: u64, value_on_div_by_zero: u64) -> u64 {
if y == 0 {
value_on_div_by_zero
} else {
x / y
}
}

View File

@@ -97,7 +97,8 @@ macro_rules! create_parameterized_test{
};
}
pub(crate) use {create_parameterized_stringified_test, create_parameterized_test};
pub(crate) use create_parameterized_stringified_test;
pub(crate) use create_parameterized_test;
//These functions are compatible with all parameter sets.
create_parameterized_test!(shortint_encrypt_decrypt);

View File

@@ -266,15 +266,15 @@ impl<T: Borrow<IntegerServerKey> + Sync> ServerKey<T> {
match self.length_checks(str, &trivial_or_enc_from) {
IsMatch::Clear(false) => return result,
IsMatch::Clear(true) => {
// If `from` is empty and str too, there's only one match and one replacement
if str.is_empty() {
if let UIntArg::Clear(_) = count {
// If `from` is empty and str too, there's only one match and one replacement
IsMatch::Clear(true) if str.is_empty() => {
match count {
UIntArg::Clear(_) => {
return to.clone();
}
// We have to take into account that encrypted n could be 0
if let UIntArg::Enc(enc_n) = count {
UIntArg::Enc(enc_n) => {
let n_is_zero = sk.scalar_eq_parallelized(enc_n.cipher(), 0);
let mut re = self.conditional_string(&n_is_zero, &result, to);
@@ -290,21 +290,22 @@ impl<T: Borrow<IntegerServerKey> + Sync> ServerKey<T> {
// This happens when str is empty, so it's again one replacement if there's match or
// if there isn't we return the str
IsMatch::Cipher(val) => {
if let UIntArg::Clear(_) = count {
return self.conditional_string(&val, to, str);
}
match count {
UIntArg::Clear(_) => {
return self.conditional_string(&val, to, str);
}
UIntArg::Enc(enc_n) => {
let n_not_zero = sk.scalar_ne_parallelized(enc_n.cipher(), 0);
let and_val = sk.boolean_bitand(&n_not_zero, &val);
if let UIntArg::Enc(enc_n) = count {
let n_not_zero = sk.scalar_ne_parallelized(enc_n.cipher(), 0);
let and_val = sk.boolean_bitand(&n_not_zero, &val);
let mut re = self.conditional_string(&and_val, to, str);
let mut re = self.conditional_string(&and_val, to, str);
// When result or to are empty we get padding via the conditional_string
// (pad_ciphertexts_lsb). And the condition result may or may not have
// padding in this case.
re.append_null(self);
return re;
// When result or to are empty we get padding via the conditional_string
// (pad_ciphertexts_lsb). And the condition result may or may not have
// padding in this case.
re.append_null(self);
return re;
}
}
}
_ => (),
@@ -383,11 +384,9 @@ impl<T: Borrow<IntegerServerKey> + Sync> ServerKey<T> {
match self.length_checks(str, &trivial_or_enc_from) {
IsMatch::Clear(false) => return result,
IsMatch::Clear(true) => {
// If `from` is empty and str too, there's only one match and one replacement
if str.is_empty() {
return to.clone();
}
// If `from` is empty and str too, there's only one match and one replacement
IsMatch::Clear(true) if str.is_empty() => {
return to.clone();
}
// This happens when str is empty, so it's again one replacement if there's match or
// if there isn't we return the str

View File

@@ -16,7 +16,7 @@ use tfhe::zk::CompactPkeCrs;
use tfhe::{ClientKey, CompactPublicKey, ConfigBuilder, ProvenCompactCiphertextList};
const SIZE_LIMIT: u64 = 1024 * 1024 * 1024;
const METADATA: [u8; 6] = [b'w', b'a', b's', b'm', b'6', b'4'];
const METADATA: [u8; 6] = *b"wasm64";
fn gen_key_and_crs() -> (CompactPublicKey, CompactPkeCrs) {
println!("Generating keys");

View File

@@ -635,9 +635,9 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [
"libc",
"rand_chacha",

View File

@@ -710,9 +710,9 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [
"libc",
"rand_chacha",

View File

@@ -635,9 +635,9 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [
"libc",
"rand_chacha",

View File

@@ -719,9 +719,9 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [
"libc",
"rand_chacha",

View File

@@ -721,9 +721,9 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [
"libc",
"rand_chacha",

View File

@@ -721,9 +721,9 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [
"libc",
"rand_chacha",

View File

@@ -763,9 +763,9 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [
"libc",
"rand_chacha",

View File

@@ -779,9 +779,9 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [
"libc",
"rand_chacha",

View File

@@ -781,9 +781,9 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [
"libc",
"rand_chacha",
@@ -977,6 +977,7 @@ dependencies = [
[[package]]
name = "tfhe"
version = "1.6.0"
source = "git+https://github.com/zama-ai/tfhe-rs.git?tag=tfhe-rs-1.6.0#7b174b1865736e3291b5e35294acfe02946c42db"
dependencies = [
"aligned-vec",
"bincode",
@@ -1015,6 +1016,7 @@ dependencies = [
[[package]]
name = "tfhe-csprng"
version = "0.9.0"
source = "git+https://github.com/zama-ai/tfhe-rs.git?tag=tfhe-rs-1.6.0#7b174b1865736e3291b5e35294acfe02946c42db"
dependencies = [
"aes",
"getrandom",
@@ -1027,6 +1029,7 @@ dependencies = [
[[package]]
name = "tfhe-fft"
version = "0.10.1"
source = "git+https://github.com/zama-ai/tfhe-rs.git?tag=tfhe-rs-1.6.0#7b174b1865736e3291b5e35294acfe02946c42db"
dependencies = [
"aligned-vec",
"bytemuck",
@@ -1040,6 +1043,7 @@ dependencies = [
[[package]]
name = "tfhe-ntt"
version = "0.7.1"
source = "git+https://github.com/zama-ai/tfhe-rs.git?tag=tfhe-rs-1.6.0#7b174b1865736e3291b5e35294acfe02946c42db"
dependencies = [
"aligned-vec",
"bytemuck",
@@ -1049,6 +1053,7 @@ dependencies = [
[[package]]
name = "tfhe-safe-serialize"
version = "0.1.0"
source = "git+https://github.com/zama-ai/tfhe-rs.git?tag=tfhe-rs-1.6.0#7b174b1865736e3291b5e35294acfe02946c42db"
dependencies = [
"bincode",
"serde",
@@ -1058,6 +1063,7 @@ dependencies = [
[[package]]
name = "tfhe-versionable"
version = "0.7.0"
source = "git+https://github.com/zama-ai/tfhe-rs.git?tag=tfhe-rs-1.6.0#7b174b1865736e3291b5e35294acfe02946c42db"
dependencies = [
"aligned-vec",
"num-complex",
@@ -1068,6 +1074,7 @@ dependencies = [
[[package]]
name = "tfhe-versionable-derive"
version = "0.7.0"
source = "git+https://github.com/zama-ai/tfhe-rs.git?tag=tfhe-rs-1.6.0#7b174b1865736e3291b5e35294acfe02946c42db"
dependencies = [
"proc-macro2",
"quote",
@@ -1077,6 +1084,7 @@ dependencies = [
[[package]]
name = "tfhe-zk-pok"
version = "0.8.1"
source = "git+https://github.com/zama-ai/tfhe-rs.git?tag=tfhe-rs-1.6.0#7b174b1865736e3291b5e35294acfe02946c42db"
dependencies = [
"ark-bls12-381",
"ark-ec",

View File

@@ -10,23 +10,13 @@ license = "BSD-3-Clause-Clear"
clap = { version = "4.5", features = ["derive"] }
# TFHE-rs
tfhe = { features = [
tfhe = { git = "https://github.com/zama-ai/tfhe-rs.git", tag = "tfhe-rs-1.6.0", features = [
"boolean",
"integer",
"shortint",
"zk-pok",
"experimental-force_fft_algo_dif4",
], path = "../../../../tfhe" }
tfhe-versionable = { path = "../../../tfhe-versionable" }
# Uncomment this and remove the lines above once the current tfhe-rs version has been released
# tfhe = { git = "https://github.com/zama-ai/tfhe-rs.git", tag = "tfhe-rs-1.6.0", features = [
# "boolean",
# "integer",
# "shortint",
# "zk-pok",
# "experimental-force_fft_algo_dif4",
# ] }
# tfhe-versionable = { git = "https://github.com/zama-ai/tfhe-rs.git", tag = "tfhe-rs-1.6.0" }
] }
tfhe-versionable = { git = "https://github.com/zama-ai/tfhe-rs.git", tag = "tfhe-rs-1.6.0" }
tfhe-backward-compat-data = { path = "../.." }