mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-09 14:47:56 -05:00
feat(wasm): add missing push_u{512,1024,2048}
This adds the missing push functions for some big uint type that the fhEVM needs
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user