CEA-LIST / Cingulata

Cingulata (pronounced "tchingulata") is a compiler toolchain and RTE for running C++ programs over encrypted data by means of fully homomorphic encryption techniques.
Other
402 stars 43 forks source link

select oprator issue(working correctly for positive numbers) negative numbers giving wrong result #26

Closed bpradeep508 closed 4 years ago

bpradeep508 commented 4 years ago

a= -29 b= 0 c=select(a>b,a,b); c=-29 c=select(a<b,a,b); c=0

ssmiler commented 4 years ago

Are a and b signed integers?

bpradeep508 commented 4 years ago

encrypt.cxx int main(int argc, char* argv[]) { if (argc < 3) { cerr << "Usage: " << argv[0] << " " << endl; exit(-1); }

/ get input values / int a_val = -29; int b_val = 0;

/ Only tfhe bit executor is needed for encryption/decryption and IO operations / CiContext::set_bit_exec(make_shared("tfhe.sk", TfheBitExec::Secret));

CiInt a{a_val, 16, false}; CiInt b{b_val, 16, false};

a.encrypt().write("a"); b.encrypt().write("b");

} hello.cxx

CiInt a{0, 16, false}; // create from unsigned 8-bit template CiInt b{0, 16, false}; // manually specify value, size and signedness CiInt c{0, 16, false}; // automatically determine size and signedness from value CiInt shift{0,16,false}; CiInt temp{0, 16, false}; a.read("a"); b.read("b"); shift.read("shift"); //temp=(shift<<15)*b; // c = a-temp; //CiBit r=a>b; c = select(a<b,a,b);

c.write("c");

On Tue, Mar 10, 2020 at 2:33 PM Sergiu Carpov notifications@github.com wrote:

Are a and b signed integers?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CEA-LIST/Cingulata/issues/26?email_source=notifications&email_token=ALBYDJDN5LXXTQZKJNKKP2LRGX64JA5CNFSM4LEYCCVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOKR7TI#issuecomment-596975565, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALBYDJGRJGOMS5RTMXR33XTRGX64JANCNFSM4LEYCCVA .

ssmiler commented 4 years ago

You do a comparison between unsigned values and in this case -29 is bigger than 0.

bpradeep508 commented 4 years ago

can you give both positive and negative examples in select

On Tue, Mar 10, 2020 at 6:32 PM Sergiu Carpov notifications@github.com wrote:

You do a comparison between unsigned values and in this case -29 is bigger than 0.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CEA-LIST/Cingulata/issues/26?email_source=notifications&email_token=ALBYDJECLHMSH4GPB4M6XODRGY26NA5CNFSM4LEYCCVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOLJ2RY#issuecomment-597073223, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALBYDJDWR4NXF6P5X22RLK3RGY26NANCNFSM4LEYCCVA .

ssmiler commented 4 years ago

No activity, closing issue