MP-SPDZ
MP-SPDZ copied to clipboard
embed/extract negative integers to specific slot of a ring_element
Hi @mkskeller I tried to embed then extract negative integer to specific slot of a ring_element as follows:
Ring_Element org_m;
modp modp_spec;
to_modp(modp_spec, spec_int, org_m.value.get_prD());
org_m.value.set_element(slot, modp_spec);
bigint bigint_orgm;
to_bigint(bigint_orgm, org_m.value.get_element(1), org_m.value.get_prD());
cout<<"org m: "<<bigint_orgm<<endl;
However due to the org_m.value.get_prD(), when I embed -2, I would get org_m.value.get_prD()-2, Is there a way to directly get -2, or I have to do things such as (if <p/2 then is positive, else is negative):
if(ele<org_m.value.get_prD()/2)
set ele=ele
else
set ele=-ele
Thanks a lot!
This is done in a number of places, but it isn't exposed as an independent function for modp
, so you have to do it manually.
Thanks for the reply, is it possible that you can point out a place that done this as an example? thanks again for your help
For example here: https://github.com/data61/MP-SPDZ/blob/59a4e830cf09328cd2a5f699617b3f90526799fc/FHE/Rq_Element.cpp#L146