Re: [viff-devel] Accessing functions in Protocol from outside

2009-05-14 Thread Martin Geisler
Håvard Vegge hava...@stud.ntnu.no writes:

 Your answer was useful, thanks!

 Well, I'm still here, playing around with VIFF and a simple web
 application, while I really should have been writing my master's
 thesis;-)

Hmm, maybe we should put a warning sign on the download page: Master
and PhD students should be aware that programming with VIFF might be
addictive, use with care. :-)

 Now my only problem is to get my VIFF program and SimpleXMLRPCServer
 to work together. I have three MPC servers which receive the same
 XML-RPC message. When this happens, they will start the multiparty
 protocol. It works for one such request, but when setting the
 XML-RPC server to serve_forever() weird things start to happen.

Right -- you have to use the Twisted XML-RPC server, at least on the
three MPC servers:

  http://twistedmatrix.com/projects/web/documentation/howto/xmlrpc.html

The SimpleXMLRPCServer in Python does not know about Twisted, so they
will not play together.

-- 
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


Re: [viff-devel] Accessing functions in Protocol from outside

2009-05-14 Thread Håvard Vegge
Awesome! Now it works, why didn't I think of Twisted's XML-RPC server 
before...
Well, I'll probably post the URL of the (simple) web application on this 
mailing list some time, but not yet. It needs some minor adjustments;-)


Well, back to the report writing. Thanks again!

håvard


Martin Geisler wrote:

Håvard Vegge hava...@stud.ntnu.no writes:

  

Your answer was useful, thanks!

Well, I'm still here, playing around with VIFF and a simple web
application, while I really should have been writing my master's
thesis;-)



Hmm, maybe we should put a warning sign on the download page: Master
and PhD students should be aware that programming with VIFF might be
addictive, use with care. :-)

  

Now my only problem is to get my VIFF program and SimpleXMLRPCServer
to work together. I have three MPC servers which receive the same
XML-RPC message. When this happens, they will start the multiparty
protocol. It works for one such request, but when setting the
XML-RPC server to serve_forever() weird things start to happen.



Right -- you have to use the Twisted XML-RPC server, at least on the
three MPC servers:

  http://twistedmatrix.com/projects/web/documentation/howto/xmlrpc.html

The SimpleXMLRPCServer in Python does not know about Twisted, so they
will not play together.

___
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk


Re: [viff-devel] Accessing functions in Protocol from outside

2009-05-14 Thread Martin Geisler
Håvard Vegge hava...@stud.ntnu.no writes:

 Awesome! Now it works, why didn't I think of Twisted's XML-RPC server
 before...

Yeah, always look there first -- they have a quite large tool box... :-)

 Well, I'll probably post the URL of the (simple) web application on
 this mailing list some time, but not yet. It needs some minor
 adjustments;-)

 Well, back to the report writing. Thanks again!

Sounds great, I'll look forward to seeing more.

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.


pgpGZ7FIv9PTq.pgp
Description: PGP signature
___
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk


Re: [viff-devel] Accessing functions in Protocol from outside

2009-05-13 Thread Martin Geisler
Håvard Vegge hava...@stud.ntnu.no writes:

Hi Håvard, good to hear from you!

 I have a program with two classes (as outlined below). From the
 class MyFunctions I would like to call a function in the class
 Protocol, is this possible? Normally one would save the instance of
 a class p = Protocol() and then be able to call p.some_function()...

Right, that is the correct way to invoke a method on an object.

 But I don't see how this is possible because the Protocol is started
 as a callback. Does anyone have some suggestions?

 Best regards, Håvard


 class MyFunctions:
def initiate_computation(self, code):
   // want to call Protocol.some_function(code)

You must then have access to the Protocol object. Let's pass that as
another parameter:

def initiate_computation(self, protocol, code):

and then do

  protocol.some_function(code)

 class Protocol:
def __init__(self, runtime):
   ...

Somewhere -- maybe here -- you must invoke the initiate_computation
method in MyFunctions. Otherwise it cannot wish to call the
Protocol.some_function method.

If __init__ is that place, then do it like this:

  myfunc = MyFunctions()

  myfunc.initiate_computation(self, code...)

Here self is a reference to the Protocol object, exactly what
initiate_computation needs in the MyFunctions class.

By the way, if MyFunctions only contain functions, then you might not
need a class at all. Python is much more free-form than, say, Java in
this way -- in Java you must put static functions into a class,
whereas you can just put them in a module in Python.

I hope that makes some sense, otherwise please ask again :-)

-- 
Martin Geisler
___
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk


Re: [viff-devel] Accessing functions in Protocol from outside

2009-05-13 Thread Håvard Vegge

Your answer was useful, thanks!

Well, I'm still here, playing around with VIFF and a simple web 
application, while I really should have been writing my master's thesis;-)


Now my only problem is to get my VIFF program and SimpleXMLRPCServer to 
work together. I have three MPC servers which receive the same XML-RPC 
message. When this happens, they will start the multiparty protocol. It 
works for one such request, but when setting the XML-RPC server to 
serve_forever() weird things start to happen.


I don't know if I need to shutdown the runtime in order to start the 
protocol once more, or if the runtime can stay alive forever. Also, 
I'm thinking that maybe the XML-RPC part of the program should run as an 
own thread? Right now this part doesn't work - that's for sure! 
Hopefully I'll figure it out soon.


håvard


Martin Geisler wrote:

Håvard Vegge hava...@stud.ntnu.no writes:

Hi Håvard, good to hear from you!

  
* useful answer *



I hope that makes some sense, otherwise please ask again :-)

___
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk