Compare commits

...

11 Commits
0.2.5 ... 0.1.4

Author SHA1 Message Date
Arthur Meyre
e2bcad8fe7 chore(tfhe): bump version to 0.1.4 2022-11-16 14:10:52 +01:00
Arthur Meyre
c39d6ca753 feat(wasm): add boolean server key primitives 2022-11-16 11:33:22 +01:00
Arthur Meyre
1c8f3859dd chore(wasm): fix clippy lints 2022-11-16 11:33:22 +01:00
Arthur Meyre
d62bc1cb4c chore(ci): add commit checks for all branches 2022-11-16 11:33:22 +01:00
Arthur Meyre
7a32e54469 chore(tfhe): fix Makefile typo 2022-11-16 11:33:22 +01:00
Arthur Meyre
8ebbac0dae chore(ci): update workflows 2022-11-16 11:33:22 +01:00
Arthur Meyre
45f503ae56 chore(tfhe): bump version to 0.1.3 2022-11-10 20:29:44 +01:00
Arthur Meyre
4b1e648848 chore(doc): fix docs.rs build by adding katex header 2022-11-10 20:28:36 +01:00
Arthur Meyre
94b9f62c17 chore(tfhe): update version to 0.1.2 2022-11-10 20:18:04 +01:00
J-B Orfila
62f8ecc568 fix(thfe): update public key parameters 2022-11-10 20:17:24 +01:00
Arthur Meyre
aa7129baf1 chore(crate): fix description metadata 2022-11-10 19:18:32 +01:00
12 changed files with 71 additions and 11 deletions

View File

@@ -22,6 +22,9 @@ on:
runner_name:
description: "Action runner name"
type: string
request_id:
description: 'Slab request ID'
type: string
jobs:
shortint-tests:
@@ -36,6 +39,7 @@ jobs:
echo "ID: ${{ github.event.inputs.instance_id }}"
echo "AMI: ${{ github.event.inputs.instance_image_id }}"
echo "Type: ${{ github.event.inputs.instance_type }}"
echo "Request ID: ${{ github.event.inputs.request_id }}"
- uses: actions/checkout@v2

View File

@@ -17,6 +17,9 @@ on:
runner_name:
description: "Action runner name"
type: string
request_id:
description: 'Slab request ID'
type: string
env:
CARGO_TERM_COLOR: always
@@ -50,6 +53,7 @@ jobs:
echo "IDs: ${{ github.event.inputs.instance_id }}"
echo "AMI: ${{ github.event.inputs.instance_image_id }}"
echo "Type: ${{ github.event.inputs.instance_type }}"
echo "Request ID: ${{ github.event.inputs.request_id }}"
- uses: actions/checkout@v2
- name: Set up home
run: |

View File

@@ -67,3 +67,10 @@ jobs:
- name: Build Release c_api
run: |
make build_c_api
- name: wasm API Clippy
run: |
make clippy_js_wasm_api
# The wasm build check is a bit annoying to set-up here and is done during the tests in
# aws_tfhe_tests.yml

View File

@@ -2,9 +2,6 @@
name: Check commit and PR compliance
on:
pull_request:
branches:
- main
- dev
jobs:
check-commit-pr:
name: Check commit and PR

View File

@@ -75,6 +75,12 @@ clippy_cuda: install_rs_check_toolchain
--features=$(TARGET_ARCH_FEATURE),cuda,boolean-c-api,shortint-c-api \
-p tfhe -- --no-deps -D warnings
.PHONY: clippy_js_wasm_api # Run clippy lints enabling the boolean, shortint and the js wasm API
clippy_js_wasm_api: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
--features=boolean-client-js-wasm-api,shortint-client-js-wasm-api \
-p tfhe -- --no-deps -D warnings
.PHONY: gen_key_cache # Run the script to generate keys and cache them for shortint tests
gen_key_cache: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) run --release \
@@ -98,7 +104,7 @@ build_boolean_and_shortint: install_rs_build_toolchain
.PHONY: build_c_api # Build the C API for boolean and shortint
build_c_api: install_rs_build_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) build --release
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) build --release \
--features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api -p tfhe
.PHONY: test_core_crypto # Run the tests of the core_crypto module

View File

@@ -1,6 +1,6 @@
[package]
name = "tfhe"
version = "0.1.0"
version = "0.1.4"
edition = "2021"
readme = "../README.md"
keywords = ["fully", "homomorphic", "encryption", "fhe", "cryptography"]
@@ -8,7 +8,7 @@ homepage = "https://zama.ai/"
documentation = "https://docs.zama.ai/tfhe-rs"
repository = "https://github.com/zama-ai/tfhe-rs"
license = "BSD-3-Clause-Clear"
description = "Concrete is a fully homomorphic encryption (FHE) library that implements Zama's variant of TFHE."
description = "TFHE-rs is a fully homomorphic encryption (FHE) library that implements Zama's variant of TFHE."
build = "build.rs"
exclude = ["/docs/", "/c_api_tests/", "/CMakeLists.txt"]

15
tfhe/katex-header.html Normal file
View File

@@ -0,0 +1,15 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.css" integrity="sha384-KiWOvVjnN8qwAZbuQyWDIbfCLFhLXNETzBQjA/92pIowpC0d2O3nppDGQVgwd2nB" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.js" integrity="sha384-0fdwu/T/EQMsQlrHCCHoH10pkPLlKA1jL5dFyUOvB3lfeT2540/2g6YgSi2BL14p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body, {
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "\\(", right: "\\)", display: false},
{left: "$", right: "$", display: false},
{left: "\\[", right: "\\]", display: true}
]
});
});
</script>

View File

@@ -92,8 +92,8 @@ impl BooleanEngine<CudaBootstrapper> {
}
}
// We have q = 32 so log2q = 5
const LOG2_Q_32: usize = 5;
// We have q = 2^32 so log2q = 32
const LOG2_Q_32: usize = 32;
impl<B> BooleanEngine<B> {
pub fn create_client_key(&mut self, parameters: BooleanParameters) -> ClientKey {

View File

@@ -14,6 +14,9 @@ pub struct BooleanClientKey(pub(crate) crate::boolean::client_key::ClientKey);
#[wasm_bindgen]
pub struct BooleanPublicKey(pub(crate) crate::boolean::public_key::PublicKey);
#[wasm_bindgen]
pub struct BooleanServerKey(pub(crate) crate::boolean::server_key::ServerKey);
#[wasm_bindgen]
pub struct Boolean {}
@@ -57,6 +60,7 @@ impl Boolean {
}
#[wasm_bindgen]
#[allow(clippy::too_many_arguments)]
pub fn new_boolean_parameters(
lwe_dimension: usize,
glwe_dimension: usize,
@@ -117,6 +121,13 @@ impl Boolean {
BooleanPublicKey(crate::boolean::public_key::PublicKey::new(&client_key.0))
}
#[wasm_bindgen]
pub fn new_server_key(client_key: &BooleanClientKey) -> BooleanServerKey {
set_hook(Box::new(console_error_panic_hook::hook));
BooleanServerKey(crate::boolean::server_key::ServerKey::new(&client_key.0))
}
#[wasm_bindgen]
pub fn encrypt(client_key: &BooleanClientKey, message: bool) -> BooleanCiphertext {
set_hook(Box::new(console_error_panic_hook::hook));
@@ -191,4 +202,19 @@ impl Boolean {
.map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str()))
.map(BooleanPublicKey)
}
#[wasm_bindgen]
pub fn serialize_boolean_server_key(server_key: &BooleanServerKey) -> Result<Vec<u8>, JsError> {
set_hook(Box::new(console_error_panic_hook::hook));
bincode::serialize(&server_key.0)
.map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str()))
}
#[wasm_bindgen]
pub fn deserialize_boolean_server_key(buffer: &[u8]) -> Result<BooleanServerKey, JsError> {
set_hook(Box::new(console_error_panic_hook::hook));
bincode::deserialize(buffer)
.map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str()))
.map(BooleanServerKey)
}
}

View File

@@ -79,6 +79,7 @@ impl Shortint {
}
#[wasm_bindgen]
#[allow(clippy::too_many_arguments)]
pub fn new_shortint_parameters(
lwe_dimension: usize,
glwe_dimension: usize,

View File

@@ -1,5 +1,5 @@
use crate::core_crypto::commons::math::random::Seeder;
#[cfg(target_os = "macos")]
#[cfg(all(target_os = "macos", not(feature = "__wasm_api")))]
use concrete_csprng::seeders::AppleSecureEnclaveSeeder;
#[cfg(feature = "seeder_x86_64_rdseed")]
use concrete_csprng::seeders::RdseedSeeder;

View File

@@ -5,8 +5,8 @@ use crate::shortint::ciphertext::Degree;
use crate::shortint::parameters::{CarryModulus, MessageModulus};
use crate::shortint::{Ciphertext, ClientKey, PublicKey, ServerKey};
// We have q = 64 so log2q = 6
const LOG2_Q_64: usize = 6;
// We have q = 2^64 so log2q = 64
const LOG2_Q_64: usize = 64;
impl ShortintEngine {
pub(crate) fn new_public_key(&mut self, client_key: &ClientKey) -> EngineResult<PublicKey> {