mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-11 07:38:08 -05:00
Compare commits
11 Commits
al/debug_s
...
0.1.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2bcad8fe7 | ||
|
|
c39d6ca753 | ||
|
|
1c8f3859dd | ||
|
|
d62bc1cb4c | ||
|
|
7a32e54469 | ||
|
|
8ebbac0dae | ||
|
|
45f503ae56 | ||
|
|
4b1e648848 | ||
|
|
94b9f62c17 | ||
|
|
62f8ecc568 | ||
|
|
aa7129baf1 |
4
.github/workflows/aws_tfhe_tests.yml
vendored
4
.github/workflows/aws_tfhe_tests.yml
vendored
@@ -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
|
||||
|
||||
|
||||
4
.github/workflows/aws_tfhe_tests_w_gpu.yml
vendored
4
.github/workflows/aws_tfhe_tests_w_gpu.yml
vendored
@@ -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: |
|
||||
|
||||
7
.github/workflows/cargo_build.yml
vendored
7
.github/workflows/cargo_build.yml
vendored
@@ -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
|
||||
|
||||
3
.github/workflows/check_commit.yml
vendored
3
.github/workflows/check_commit.yml
vendored
@@ -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
|
||||
|
||||
8
Makefile
8
Makefile
@@ -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
|
||||
|
||||
@@ -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
15
tfhe/katex-header.html
Normal 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>
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ impl Shortint {
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new_shortint_parameters(
|
||||
lwe_dimension: usize,
|
||||
glwe_dimension: usize,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user