From febaf12dee8281ddb0df8d550420b28a80042935 Mon Sep 17 00:00:00 2001 From: tmontaigu Date: Fri, 16 Aug 2024 13:47:53 +0200 Subject: [PATCH 1/2] chore(tfhe): bump version to 0.8.0-alpha.3 --- tfhe/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tfhe/Cargo.toml b/tfhe/Cargo.toml index bb64110f59..db70c8d1c1 100644 --- a/tfhe/Cargo.toml +++ b/tfhe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tfhe" -version = "0.8.0-alpha.2" +version = "0.8.0-alpha.3" edition = "2021" readme = "../README.md" keywords = ["fully", "homomorphic", "encryption", "fhe", "cryptography"] From 53d159a4a59cb9292a2b67b9cef2889f36a92b85 Mon Sep 17 00:00:00 2001 From: tmontaigu Date: Fri, 16 Aug 2024 12:33:56 +0200 Subject: [PATCH 2/2] feat(wasm): add missing push_u{512,1024,2048} This adds the missing push functions for some big uint type that the fhEVM needs --- tfhe/js_on_wasm_tests/test-hlapi-signed.js | 9 +++++- .../js_high_level_api/integers.rs | 29 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/tfhe/js_on_wasm_tests/test-hlapi-signed.js b/tfhe/js_on_wasm_tests/test-hlapi-signed.js index 84b64fe174..c314ffa208 100644 --- a/tfhe/js_on_wasm_tests/test-hlapi-signed.js +++ b/tfhe/js_on_wasm_tests/test-hlapi-signed.js @@ -354,7 +354,6 @@ test('hlapi_public_key_encrypt_decrypt_int256_small', (t) => { }); - ////////////////////////////////////////////////////////////////////////////// /// 32 bits compact ////////////////////////////////////////////////////////////////////////////// @@ -423,12 +422,14 @@ test('hlapi_compact_ciphertext_list', (t) => { let clear_i32 = -3284; let clear_bool = true; let clear_u256 = generateRandomBigInt(256); + let clear_u2048 = generateRandomBigInt(2048); let builder = CompactCiphertextList.builder(publicKey); builder.push_u2(clear_u2); builder.push_i32(clear_i32); builder.push_boolean(clear_bool); builder.push_u256(clear_u256); + builder.push_u2048(clear_u2048); let list = builder.build(); let serialized = list.safe_serialize(BigInt(10000000)); @@ -455,6 +456,12 @@ test('hlapi_compact_ciphertext_list', (t) => { expander.get_uint256(3).decrypt(clientKey), clear_u256, ); + + assert.deepStrictEqual( + expander.get_uint2048(4).decrypt(clientKey), + clear_u2048, + ); + }); test('hlapi_compact_ciphertext_list_with_proof', (t) => { diff --git a/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs b/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs index 6f00bb5c6d..380eab7ee2 100644 --- a/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs +++ b/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs @@ -898,6 +898,33 @@ impl CompactCiphertextListBuilder { }) } + #[wasm_bindgen] + pub fn push_u512(&mut self, value: JsValue) -> Result<(), JsError> { + catch_panic_result(|| { + let value = U512::try_from(value)?; + self.0.push(value); + Ok(()) + }) + } + + #[wasm_bindgen] + pub fn push_u1024(&mut self, value: JsValue) -> Result<(), JsError> { + catch_panic_result(|| { + let value = U1024::try_from(value)?; + self.0.push(value); + Ok(()) + }) + } + + #[wasm_bindgen] + pub fn push_u2048(&mut self, value: JsValue) -> Result<(), JsError> { + catch_panic_result(|| { + let value = U2048::try_from(value)?; + self.0.push(value); + Ok(()) + }) + } + #[wasm_bindgen] pub fn push_i128(&mut self, value: JsValue) -> Result<(), JsError> { catch_panic_result(|| { @@ -1018,7 +1045,7 @@ macro_rules! define_expander_get_method { }; } define_expander_get_method!( - unsigned: { 2, 4, 6, 8, 10, 12, 14, 16, 32, 64, 128, 160, 256 } + unsigned: { 2, 4, 6, 8, 10, 12, 14, 16, 32, 64, 128, 160, 256, 512, 1024, 2048 } ); define_expander_get_method!( signed: { 2, 4, 6, 8, 10, 12, 14, 16, 32, 64, 128, 160, 256 }