Tord Ingolf Reistad <to...@stud.ntnu.no> writes:

Hi Tord

> I have a simple question: After completing a VIFF program I have
> opened the shares and gotten the results, but the results are field
> elements (probably elements of class GFElement), how do I turn them
> back into integers?

You just access the value attribute of your GFElement: x.value. If you
update to the very latest version of VIFF you can now also use int(x)
to do the same.

> The documentation says nothing about how to turn them back into
> integers, which should be essencial if I am going to use these
> shares in other applications. There seems to be some code __repr__
> in GFElements, but I cannot see how I can use it.

That method is called when x is a field element and you do

  "foo %r bar" % x

or

  repr(x)

It just produces a string with the value.

> As an additional problem, the integers should not be integers in the
> set form 0 to p-1, but integers from -(p-1)/2 to +(p-1)/2. How
> should one do that efficiently?

That should be as simple as

  x.value - (x.modulus - 1) // 2

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
_______________________________________________
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk

Reply via email to