Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zk): fix zk wasm x86_64 tests #1755

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tfhe/js_on_wasm_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"test": "node --test --test-reporter=tap"
},
"author": "",
"license": "BSD-3-Clause"
"license": "BSD-3-Clause-Clear"
}
2 changes: 1 addition & 1 deletion tfhe/src/high_level_api/compact_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ mod tests {

set_server_key(sks);

// Intentionally low to that we test when multiple lists and proofs are needed
// 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'];
Expand Down
15 changes: 13 additions & 2 deletions tfhe/tests/zk_wasm_x86_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,25 @@ use std::fs::File;
use std::path::{Path, PathBuf};
use std::process::Command;
use tfhe::safe_serialization::{safe_deserialize, safe_serialize};
use tfhe::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
use tfhe::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
use tfhe::zk::{CompactPkeCrs, CompactPkePublicParams};
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'];

fn gen_key_and_crs() -> (CompactPublicKey, CompactPkeCrs) {
println!("Generating keys");
let config = ConfigBuilder::default().build();
let config =
crate::ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
.use_dedicated_compact_public_key_parameters((
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
))
.build();

let client_key = ClientKey::generate(config);
let pub_key = CompactPublicKey::new(&client_key);

Expand Down Expand Up @@ -52,7 +63,7 @@ fn verify_proof(
proven_ct: &ProvenCompactCiphertextList,
) {
println!("Verifying proof");
match proven_ct.verify(crs, public_key, &[]) {
match proven_ct.verify(crs, public_key, &METADATA) {
tfhe::zk::ZkVerificationOutCome::Valid => {
println!("proof verification succeeded");
}
Expand Down
6 changes: 4 additions & 2 deletions tfhe/tests/zk_wasm_x86_test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
const fs = require('fs');

const SIZE_LIMIT = BigInt(1024) * BigInt(1024) * BigInt(1024);
const METADATA = "wasm64";

const tfhe_proof = async () => {
const publicKeyBuf = fs.readFileSync(`${__dirname}/public_key.bin`);
Expand All @@ -17,12 +18,13 @@ const tfhe_proof = async () => {

const builder = CompactCiphertextList.builder(publicKey);
builder.push_u4(1);
builder.push_u8(0xff);

builder.push_u8(0xff);
const metadata = Uint8Array.from(METADATA.split('').map(letter => letter.charCodeAt(0)));

const encrypted = builder.build_with_proof_packed(
publicParams,
new Uint8Array(),
metadata,
ZkComputeLoad.Proof,
);

Expand Down
2 changes: 1 addition & 1 deletion tfhe/tests/zk_wasm_x86_test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"type": "commonjs",
"author": "",
"license": "BSD-3-Clause",
"license": "BSD-3-Clause-Clear",
"dependencies": {
"node-tfhe": "file:../../pkg"
}
Expand Down
2 changes: 1 addition & 1 deletion tfhe/web_wasm_parallel_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"check-format": "prettier . --check"
},
"author": "",
"license": "BSD-3-Clause",
"license": "BSD-3-Clause-Clear",
"devDependencies": {
"@babel/preset-env": "^7.25.4",
"prettier": "^3.3.3",
Expand Down
Loading