From 2990cb69fbc1508244ec8c33abafacea96321806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20=27birdy=27=20Danjou?= Date: Sat, 15 Jul 2023 21:56:40 +0200 Subject: [PATCH] add test for encrypt 0 --- src/sdk/encrypt.test.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/sdk/encrypt.test.ts b/src/sdk/encrypt.test.ts index bd3923b..09e8f3a 100644 --- a/src/sdk/encrypt.test.ts +++ b/src/sdk/encrypt.test.ts @@ -21,6 +21,16 @@ describe('encrypt8', () => { publicKey = keypair.publicKey; }); + it('encrypt/decrypt 0 8bits', async () => { + const buffer = encrypt8(0, publicKey); + const compactList = CompactFheUint8List.deserialize(buffer); + let encryptedList = compactList.expand(); + encryptedList.forEach((v: FheUint8) => { + const decrypted = v.decrypt(clientKey); + expect(decrypted).toBe(0); + }); + }); + it('encrypt/decrypt 8bits', async () => { const buffer = encrypt8(34, publicKey); const compactList = CompactFheUint8List.deserialize(buffer); @@ -31,6 +41,16 @@ describe('encrypt8', () => { }); }); + it('encrypt/decrypt 0 16bits', async () => { + const buffer = encrypt16(0, publicKey); + const compactList = CompactFheUint8List.deserialize(buffer); + let encryptedList = compactList.expand(); + encryptedList.forEach((v: FheUint8) => { + const decrypted = v.decrypt(clientKey); + expect(decrypted).toBe(0); + }); + }); + it('encrypt/decrypt 16bits', async () => { const buffer = encrypt16(434, publicKey); const compactList = CompactFheUint16List.deserialize(buffer); @@ -41,6 +61,16 @@ describe('encrypt8', () => { }); }); + it('encrypt/decrypt 0 32bits', async () => { + const buffer = encrypt32(0, publicKey); + const compactList = CompactFheUint8List.deserialize(buffer); + let encryptedList = compactList.expand(); + encryptedList.forEach((v: FheUint8) => { + const decrypted = v.decrypt(clientKey); + expect(decrypted).toBe(0); + }); + }); + it('encrypt/decrypt 32bits', async () => { const buffer = encrypt32(30210, publicKey); const compactList = CompactFheUint32List.deserialize(buffer);