Tord Ingolf Reistad <[EMAIL PROTECTED]> writes:

(Please remember to send your replies to the list too.)

> [... use case about locating the nearest nurse securely...]

I found your use case very interesting, but probably also quite
difficult. But I really wanted to comment on the side note:

> As a side note:
> I am working on a new comparison protocol, I have some problems with
> it so it might not work, but if it does then I need to compute both
> in some field Z_p and Z_q for different primes p and q. Can VIFF
> handle that or is it hard wired to only work in one field?

Tomas needed VIFF to handle multiple fields, so this is indeed
possible! I'm glad to see that this feature is useful :-)

Try looking at the two-fields.py example, it shows how one can share
numbers over different fields and easily work with them. You basically
just have to avoid mixing Shares from different fields -- that will
give you an exception.

If you need to convert a GFElement from one field to another, then you
can do this by accessing the value field of a GFElement:

  >>> from viff.field import GF
  >>> Z17 = GF(17)
  >>> Z23 = GF(23)
  >>> x = Z17(15)
  >>> y = Z23(x.value)
  >>> x, y
  ({15}, {15})

If you have a Share (a Deferred GFElement) then you add a callback to
do the conversion:

   x.addCallback(lambda e: Zp(e.value))

Here x is a Share and Zp is a field (created by a call to GF as
above). The lambda function is called when x gets a value (when the
value arrives over the network). The value is a GFElement, and we can
simply use e.value to refer to the Python integer stored in the
GFElement. Passing that to Zp will yield another GFElement, and the
total effect is that x becomes a Share holding a Zp GFEelemnt.

If we continue the example above we can do this to make a Share object
holding the x GFElement:

  >>> from viff.runtime import Share
  >>> x_share = Share(None, x)

I'm passing None since I don't have a Runtime around. That is okay for
this example. Now x_share is a Share which has a value, and in that
case we can access that using

  >>> x_share.result
  {15}

We can check the modulus too:

  >>> x_share.result.modulus
  17

(Accessing the result field like this is a big no-no in normal
programs since you cannot be sure that it is there since the Share
might not have a value yet. That is why you need to use callbacks to
schedule your peeking until the result is ready.)

Adding the callback has the result of converting the GFElement at once
(since the value is already there):

  >>> x_share.addCallback(lambda e: Z23(e.value))
  <Share at 0xB7E994ECL  current result: {15}>
  >>> x_share.result.modulus
  23

I hope this makes sense, otherwise please ask again!

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multi-Party Computation) to Python. See: http://viff.dk/.
_______________________________________________
viff-devel mailing list (http://viff.dk/)
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk

Reply via email to